Skip to content

Commit ec4cf04

Browse files
authored
Merge pull request ClickHouse#79562 from muzammilar/docs-ipv4
[DOCSUP] Updating IPv4 and IPv6 Documentation
2 parents 9cd5936 + 13d5dc5 commit ec4cf04

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

docs/en/sql-reference/functions/ip-address-functions.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,21 +248,22 @@ SELECT IPv6CIDRToRange(toIPv6('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32);
248248

249249
## toIPv4 {#toipv4}
250250

251-
Like [`IPv4StringToNum`](#IPv4StringToNum) but takes a string form of IPv4 address and returns value of [IPv4](../data-types/ipv4.md) type.
251+
Converts a string or a UInt32 form of IPv4 address to [IPv4](../data-types/ipv4.md) type.
252+
Similar to [`IPv4StringToNum`](#IPv4StringToNum) and [IPv4NumToString](#IPv4NumToString) functions but it supports both string and unsigned integer data types as input arguments.
252253

253254
**Syntax**
254255

255256
```sql
256-
toIPv4(string)
257+
toIPv4(x)
257258
```
258259

259260
**Arguments**
260261

261-
- `string` — IPv4 address. [String](../data-types/string.md).
262+
- `x` — IPv4 address. [`String`](../data-types/string.md), [`UInt8/16/32`](../data-types/int-uint.md).
262263

263264
**Returned value**
264265

265-
- `string` converted to the IPv4 address. [IPv4](../data-types/ipv4.md).
266+
- IPv4 address. [IPv4](../data-types/ipv4.md).
266267

267268
**Examples**
268269

@@ -298,6 +299,21 @@ Result:
298299
└───────────────────────────────────┴──────────────────────────┘
299300
```
300301

302+
303+
Query:
304+
305+
```sql
306+
SELECT toIPv4(2130706433);
307+
```
308+
309+
Result:
310+
311+
```text
312+
┌─toIPv4(2130706433)─┐
313+
│ 127.0.0.1 │
314+
└────────────────────┘
315+
```
316+
301317
## toIPv4OrDefault {#toipv4ordefault}
302318

303319
Same as `toIPv4`, but if the IPv4 address has an invalid format, it returns `0.0.0.0` (0 IPv4), or the provided IPv4 default.
@@ -412,7 +428,7 @@ Result:
412428
## toIPv6 {#toipv6}
413429

414430
Converts a string or a UInt128 form of IPv6 address to [IPv6](../data-types/ipv6.md) type. For strings, if the IPv6 address has an invalid format, returns an empty value.
415-
Similar to [IPv6StringToNum](#ipv6stringtonum) function, which converts IPv6 address to binary format.
431+
Similar to [IPv6StringToNum](#ipv6stringtonum) and [IPv6NumToString](#ipv6numtostringx) functions, which convert IPv6 address to and from binary format (i.e. `FixedString(16)`).
416432

417433
If the input string contains a valid IPv4 address, then the IPv6 equivalent of the IPv4 address is returned.
418434

@@ -425,7 +441,7 @@ toIPv6(UInt128)
425441

426442
**Argument**
427443

428-
- `string` or `UInt128` — IP address. [String](../data-types/string.md).
444+
- `x` — IP address. [`String`](../data-types/string.md) or [`UInt128`](../data-types/int-uint.md).
429445

430446
**Returned value**
431447

0 commit comments

Comments
 (0)