Skip to content

IPv4OrZero or toIPv4OrNull does not exist. #22825

@UnamedRus

Description

@UnamedRus

Clickhouse recommend to use IPv4OrZero or toIPv4OrNull functions in error message, but they do not actually exist.

How to reproduce
Clickhouse version 21.5

SELECT CAST('127.0.0.1', 'IPv4')

Query id: f7ce4a55-0e57-41a8-b771-8fd6be54d41b


0 rows in set. Elapsed: 0.002 sec.

Received exception from server (version 21.5.1):
Code: 6. DB::Exception: Received from localhost:9000. DB::Exception: Cannot parse string '127.0.0.1' as IPv4: syntax error at position 3 (parsed just '127'). Note: there are toIPv4OrZero and toIPv4OrNull functions, which returns zero/NULL instead of throwing exception.: While processing CAST('127.0.0.1', 'IPv4').


localdomain  :) SELECT toIPv4OrZero('127.0.0.1') ;

SELECT toIPv4OrZero('127.0.0.1')

0 rows in set. Elapsed: 0.002 sec.

Received exception from server (version 21.5.1):
Code: 46. DB::Exception: Received from localhost:9000. DB::Exception: Unknown function toIPv4OrZero. Maybe you meant: ['toInt8OrZero','toInt64OrZero']: While processing toIPv4OrZero('127.0.0.1').

localdomain  :) SELECT toIPv4OrNull('127.0.0.1') ;

SELECT toIPv4OrNull('127.0.0.1')

0 rows in set. Elapsed: 0.002 sec.

Received exception from server (version 21.5.1):
Code: 46. DB::Exception: Received from localhost:9000. DB::Exception: Unknown function toIPv4OrNull. Maybe you meant: ['toInt8OrNull','toInt64OrNull']: While processing toIPv4OrNull('127.0.0.1').

localdomain  :) SELECT toIPv4('127.0.0.1') ;

SELECT toIPv4('127.0.0.1')


┌─toIPv4('127.0.0.1')─┐
│ 127.0.0.1           │
└─────────────────────┘

1 rows in set. Elapsed: 0.003 sec.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions