This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push: new 0cfd76d5c90 docs: add ip conversion documentation (#2653) 0cfd76d5c90 is described below commit 0cfd76d5c903ced717751058553fecd6ed408b2d Author: Mryange <2319153...@qq.com> AuthorDate: Sun Jul 27 00:02:50 2025 +0800 docs: add ip conversion documentation (#2653) ## Versions - [x] dev - [ ] 3.0 - [ ] 2.1 - [ ] 2.0 ## Languages - [x] Chinese - [x] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built --- .../sql-data-types/conversion/ip-conversion.md | 235 +++++++++++++++++++++ .../sql-data-types/conversion/ip-conversion.md | 235 +++++++++++++++++++++ sidebars.json | 1 + 3 files changed, 471 insertions(+) diff --git a/docs/sql-manual/basic-element/sql-data-types/conversion/ip-conversion.md b/docs/sql-manual/basic-element/sql-data-types/conversion/ip-conversion.md new file mode 100644 index 00000000000..fe5f2ff5dc2 --- /dev/null +++ b/docs/sql-manual/basic-element/sql-data-types/conversion/ip-conversion.md @@ -0,0 +1,235 @@ +--- +{ + "title": "Cast to IP Types", + "language": "en" +} +--- + +IP types are used to store and process IP addresses, including IPv4 and IPv6 types. IPv4 is stored as uint32, while IPv6 is stored as uint128. + +## Cast to IPv4 + +### FROM String + +#### Strict Mode + +##### BNF Definition + +```xml +<ipv4> ::= <whitespace>* <octet> "." <octet> "." <octet> "." <octet> <whitespace>* + +<octet> ::= <digit> | <digit><digit> | <digit><digit><digit> + +<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" + +<whitespace> ::= " " | "\t" | "\n" | "\r" | "\f" | "\v" +``` + +##### Rule Description + +An IPv4 address consists of 4 numeric segments separated by dots: number.number.number.number, for example: 192.168.1.1. Each segment must be within the range of 0 to 255. Numbers may have leading zeros. Any number of whitespace characters (including spaces, tabs, newlines, etc.) can be included before and after the address. + +If the format doesn't conform, an error is reported. + +##### Examples + +| Input String | Parse Result | Comment | +| --- | --- | --- | +| "192.168.1.1" | Success | Standard valid address | +| "0.0.0.0" | Success | Minimum value boundary | +| "255.255.255.255" | Success | Maximum value boundary | +| "10.20.30.40" | Success | Regular address | +| " 192.168.1.1 " | Success | Can have whitespace before and after | +| "192.168.01.1" | Success | Leading zeros allowed (01 = 1) | +| "1.2.3" | Error | Only 3 segments (must have 4) | +| "1.2.3.4.5" | Error | 5 segments (must have 4) | +| "256.0.0.1" | Error | First segment > 255 (256 out of range) | +| "1.300.2.3" | Error | Second segment > 255 | +| "1.2.3." | Error | Fourth segment missing | +| ".1.2.3" | Error | First segment missing | +| "1..2.3" | Error | Second segment missing | +| "a.b.c.d" | Error | Non-numeric characters | +| "1.2.+3.4" | Error | Sign + is invalid | + +#### Non-Strict Mode + +##### BNF Definition + +```xml +<ipv4> ::= <whitespace>* <octet> "." <octet> "." <octet> "." <octet> <whitespace>* + +<octet> ::= <digit> | <digit><digit> | <digit><digit><digit> + +<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" + +<whitespace> ::= " " | "\t" | "\n" | "\r" | "\f" | "\v" +``` + +##### Rule Description + +An IPv4 address consists of 4 numeric segments separated by dots: number.number.number.number, for example: 192.168.1.1. Each segment must be within the range of 0 to 255. Numbers may have leading zeros. Any number of whitespace characters (including spaces, tabs, newlines, etc.) can be included before and after the address. + +If the format doesn't conform, null is returned. + +##### Examples + +| Input String | Parse Result | Comment | +| --- | --- | --- | +| "192.168.1.1" | Success | Standard valid address | +| "0.0.0.0" | Success | Minimum value boundary | +| "255.255.255.255" | Success | Maximum value boundary | +| "10.20.30.40" | Success | Regular address | +| " 192.168.1.1 " | Success | Can have whitespace before and after | +| "192.168.01.1" | Success | Leading zeros allowed (01 = 1) | +| "1.2.3" | null | Only 3 segments (must have 4) | +| "1.2.3.4.5" | null | 5 segments (must have 4) | +| "256.0.0.1" | null | First segment > 255 (256 out of range) | +| "1.300.2.3" | null | Second segment > 255 | +| "1.2.3." | null | Fourth segment missing | +| ".1.2.3" | null | First segment missing | +| "1..2.3" | null | Second segment missing | +| "a.b.c.d" | null | Non-numeric characters | +| "1.2.+3.4" | null | Sign + is invalid | + +## Cast to IPv6 + +### FROM String + +:::caution Behavior Change +Before version 4.0, Doris had more relaxed requirements for IPv6 address formats, for example: +- Allowing multiple consecutive colons (like '1:1:::1') +- Allowing double colons without actually abbreviating anything (like '1:1:1::1:1:1:1:1') + +Starting from version 4.0, these two non-standard formats will result in an error in strict mode or return null in non-strict mode. +::: + +#### Strict Mode + +##### BNF Definition + +```xml +<ipv6> ::= <whitespace>* <ipv6-standard> <whitespace>* + | <whitespace>* <ipv6-compressed> <whitespace>* + | <whitespace>* <ipv6-ipv4-mapped> <whitespace>* + +<ipv6-standard> ::= <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> + +<h16> ::= <hexdigit>{1,4} + +<hexdigit> ::= <digit> | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F" + +<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" + +<whitespace> ::= " " | "\t" | "\n" | "\r" | "\f" | "\v" +``` + +##### Rule Description + +1. Standard format: 8 groups of hexadecimal digits, each group consisting of 1 to 4 hexadecimal digits, separated by colons. Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 +2. Compressed format: + - Double colons (::) can be used to represent one or more consecutive groups of zeros. + - Double colons (::) can only appear once in the entire address. + - Just :: is also a valid address, representing all zeros. + - 1:1:1::1:1:1:1:1 is not valid because :: doesn't represent consecutive zeros. + - The following addresses are all valid and identical: + - 2001:0db8:0000:0000:0000:0000:1428:57ab + - 2001:0db8:0000:0000:0000::1428:57ab + - 2001:0db8:0:0:0:0:1428:57ab + - 2001:0db8:0::0:1428:57ab + - 2001:0db8::1428:57ab +3. IPv4-mapped addresses: + - IPv4 dotted decimal format can be used in the last 32 bits (last two groups) of an IPv6 address. + - This format is typically used to represent the mapping of IPv4 addresses to IPv6. + - Example: ::ffff:192.168.89.9 is equivalent to ::ffff:c0a8:5909 +4. Any number of whitespace characters (including spaces, tabs, newlines, etc.) can be included before and after the address. +5. Hexadecimal letters can be uppercase (A-F) or lowercase (a-f). +6. The IPv4 part must follow IPv4 rules: each segment must be within the range of 0 to 255. +7. If the address format doesn't conform to the above rules, an error is reported. + +##### Examples + +| Input String | Parse Result | Comment | +| --- | --- | --- | +| 2001:db8:85a3:0000:0000:8a2e:0370:7334 | Success | Standard valid address | +| :: | Success | All zeros address | +| 2001:db8:: | Success | Using compressed format | +| ::ffff:192.168.1.1 | Success | IPv4-mapped address | +| 2001:db8::1 | Success | Can have whitespace before and after | +| 2001:db8::1::2 | Error | Double colons (::) appear twice | +| 2001:db8:85a3:0000:0000:8a2e:0370:7334:1234 | Error | More than 8 groups | +| 2001:db8:85a3:0000:8a2e:0370 | Error | Only 6 groups (must have 8 or use compressed format) | +| 2001:db8:85g3:0000:0000:8a2e:0370:7334 | Error | Contains invalid hexadecimal character 'g' | +| 2001:db8::ffff:192.168.1.260 | Error | IPv4 part out of range (260 > 255) | +| 2001:db8::ffff:192.168..1 | Error | IPv4 part format error (missing a segment) | +| 2001:0db8:85a3:::8a2e:0370:7334 | Error | Three colons in a row | +| 20001:db8::1 | Error | First group exceeds 4 hexadecimal digits | + +#### Non-Strict Mode + +##### BNF Definition + +```xml +<ipv6> ::= <whitespace>* <ipv6-standard> <whitespace>* + | <whitespace>* <ipv6-compressed> <whitespace>* + | <whitespace>* <ipv6-ipv4-mapped> <whitespace>* + +<ipv6-standard> ::= <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> + +<h16> ::= <hexdigit>{1,4} + +<hexdigit> ::= <digit> | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F" + +<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" + +<whitespace> ::= " " | "\t" | "\n" | "\r" | "\f" | "\v" +``` + +##### Rule Description + +1. Standard format: 8 groups of hexadecimal digits, each group consisting of 1 to 4 hexadecimal digits, separated by colons. Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334 +2. Compressed format: + - Double colons (::) can be used to represent one or more consecutive groups of zeros. + - Double colons (::) can only appear once in the entire address. + - Just :: is also a valid address, representing all zeros. + - 1:1:1::1:1:1:1:1 is not valid because :: doesn't represent consecutive zeros. + - The following addresses are all valid and identical: + - 2001:0db8:0000:0000:0000:0000:1428:57ab + - 2001:0db8:0000:0000:0000::1428:57ab + - 2001:0db8:0:0:0:0:1428:57ab + - 2001:0db8:0::0:1428:57ab + - 2001:0db8::1428:57ab +3. IPv4-mapped addresses: + - IPv4 dotted decimal format can be used in the last 32 bits (last two groups) of an IPv6 address. + - This format is typically used to represent the mapping of IPv4 addresses to IPv6. + - Example: ::ffff:192.168.89.9 is equivalent to ::ffff:c0a8:5909 +4. Any number of whitespace characters (including spaces, tabs, newlines, etc.) can be included before and after the address. +5. Hexadecimal letters can be uppercase (A-F) or lowercase (a-f). +6. The IPv4 part must follow IPv4 rules: each segment must be within the range of 0 to 255. +7. If the address format doesn't conform to the above rules, null is returned. + +##### Examples + +| Input String | Parse Result | Comment | +| --- | --- | --- | +| 2001:db8:85a3:0000:0000:8a2e:0370:7334 | Success | Standard valid address | +| :: | Success | All zeros address | +| 2001:db8:: | Success | Using compressed format | +| ::ffff:192.168.1.1 | Success | IPv4-mapped address | +| 2001:db8::1 | Success | Can have whitespace before and after | +| 2001:db8::1::2 | null | Double colons (::) appear twice | +| 2001:db8:85a3:0000:0000:8a2e:0370:7334:1234 | null | More than 8 groups | +| 2001:db8:85a3:0000:8a2e:0370 | null | Only 6 groups (must have 8 or use compressed format) | +| 2001:db8:85g3:0000:0000:8a2e:0370:7334 | null | Contains invalid hexadecimal character 'g' | +| 2001:db8::ffff:192.168.1.260 | null | IPv4 part out of range (260 > 255) | +| 2001:db8::ffff:192.168..1 | null | IPv4 part format error (missing a segment) | +| 2001:0db8:85a3:::8a2e:0370:7334 | null | Three colons in a row | +| 20001:db8::1 | null | First group exceeds 4 hexadecimal digits | + +### FROM IPv4 + +Any IPv4 address can be converted to IPv6. Conversion will always succeed, and behavior is consistent between strict and non-strict modes. + +| Input IPv4 | Converted IPv6 | +| --- | --- | +| 192.168.0.0 | ::ffff:192.168.0.0 | +| 0.0.0.0 | ::ffff:0.0.0.0 | diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/sql-data-types/conversion/ip-conversion.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/sql-data-types/conversion/ip-conversion.md new file mode 100644 index 00000000000..fb8b34a319d --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/basic-element/sql-data-types/conversion/ip-conversion.md @@ -0,0 +1,235 @@ +--- +{ + "title": "转换为 IP 类型", + "language": "zh-CN" +} +--- + +IP 类型用于存储和处理 IP 地址,包括 IPv4 和 IPv6 两种类型。IPv4 的底层存储为 uint32,而 IPv6 的底层存储为 uint128。 + +## 转换为 IPv4 + +### FROM String + +#### 严格模式 + +##### BNF 定义 + +```xml +<ipv4> ::= <whitespace>* <octet> "." <octet> "." <octet> "." <octet> <whitespace>* + +<octet> ::= <digit> | <digit><digit> | <digit><digit><digit> + +<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" + +<whitespace> ::= " " | "\t" | "\n" | "\r" | "\f" | "\v" +``` + +##### 规则描述 + +IPv4 地址由 4 个数字段组成,每段用点号分隔:数字。数字。数字。数字示例:192.168.1.1。每段数字值必须在 0~255 范围内。数字中可以有前导零。前后可以包含任意数量的空白字符(包括空格、制表符、换行符等)。 + +如果不满足,报错。 + +##### 例子 + +| 输入字符串 | 解析结果 | 说明 | +| --- | --- | --- | +| "192.168.1.1" | 成功 | 标准合法地址 | +| "0.0.0.0" | 成功 | 最小值边界 | +| "255.255.255.255" | 成功 | 最大值边界 | +| "10.20.30.40" | 成功 | 常规地址 | +| " 192.168.1.1 " | 成功 | 前后可以有空白符号 | +| "192.168.01.1" | 成功 | 前导零允许(01 = 1) | +| "1.2.3" | 报错 | 只有 3 段(必须 4 段) | +| "1.2.3.4.5" | 报错 | 5 段(必须 4 段) | +| "256.0.0.1" | 报错 | 首段 >255 (256 超范围) | +| "1.300.2.3" | 报错 | 第二段 >255 | +| "1.2.3." | 报错 | 第四段缺失 | +| ".1.2.3" | 报错 | 第一段缺失 | +| "1..2.3" | 报错 | 第二段缺失 | +| "a.b.c.d" | 报错 | 非数字字符 | +| "1.2.+3.4" | 报错 | 符号 + 非法 | + +#### 非严格模式 + +##### BNF 定义 + +```xml +<ipv4> ::= <whitespace>* <octet> "." <octet> "." <octet> "." <octet> <whitespace>* + +<octet> ::= <digit> | <digit><digit> | <digit><digit><digit> + +<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" + +<whitespace> ::= " " | "\t" | "\n" | "\r" | "\f" | "\v" +``` + +##### 规则描述 + +IPv4 地址由 4 个数字段组成,每段用点号分隔:数字。数字。数字。数字示例:192.168.1.1。每段数字值必须在 0~255 范围内。数字中可以有前导零。前后可以包含任意数量的空白字符(包括空格、制表符、换行符等)。 + +如果不满足,返回 null。 + +##### 例子 + +| 输入字符串 | 解析结果 | 说明 | +| --- | --- | --- | +| "192.168.1.1" | 成功 | 标准合法地址 | +| "0.0.0.0" | 成功 | 最小值边界 | +| "255.255.255.255" | 成功 | 最大值边界 | +| "10.20.30.40" | 成功 | 常规地址 | +| " 192.168.1.1 " | 成功 | 前后可以有空白符号 | +| "192.168.01.1" | 成功 | 前导零允许(01 = 1) | +| "1.2.3" | null | 只有 3 段(必须 4 段) | +| "1.2.3.4.5" | null | 5 段(必须 4 段) | +| "256.0.0.1" | null | 首段 >255 (256 超范围) | +| "1.300.2.3" | null | 第二段 >255 | +| "1.2.3." | null | 第四段缺失 | +| ".1.2.3" | null | 第一段缺失 | +| "1..2.3" | null | 第二段缺失 | +| "a.b.c.d" | null | 非数字字符 | +| "1.2.+3.4" | null | 符号 + 非法 | + +## 转换为 IPv6 + +### FROM String + +:::caution 行为变更 +在 4.0 版本之前,Doris 对 IPv6 地址格式的要求较为宽松,例如: +允许使用多个连续冒号(如 '1:1:::1') +允许使用双冒号但没有实际缩写任何内容(如 '1:1:1::1:1:1:1:1') + +从 4.0 版本开始,上面的两种非标准格式将在严格模式下报错,在非严格模式下返回 null。 +::: + +#### 严格模式 + +##### BNF 定义 + +```xml +<ipv6> ::= <whitespace>* <ipv6-standard> <whitespace>* + | <whitespace>* <ipv6-compressed> <whitespace>* + | <whitespace>* <ipv6-ipv4-mapped> <whitespace>* + +<ipv6-standard> ::= <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> + +<h16> ::= <hexdigit>{1,4} + +<hexdigit> ::= <digit> | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F" + +<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" + +<whitespace> ::= " " | "\t" | "\n" | "\r" | "\f" | "\v" +``` + +##### 规则描述 + +1. 标准格式:8 组十六进制数字,每组由 1 至 4 个十六进制数字组成,组与组之间用冒号分隔。例如:2001:0db8:85a3:0000:0000:8a2e:0370:7334 +2. 压缩格式: + - 允许使用双冒号(::)表示一个或者多个连续的 0 组。 + - 双冒号(::)在整个地址中只能出现一次。 + - 只有:: 也是合法的地址,表示地址全 0 + - 1:1:1::1:1:1:1:1 不是合法的,因为::没有表示连续的 0 + - 以下地址都是合法并且相同的 + - 2001:0db8:0000:0000:0000:0000:1428:57ab + - 2001:0db8:0000:0000:0000::1428:57ab + - 2001:0db8:0:0:0:0:1428:57ab + - 2001:0db8:0::0:1428:57ab + - 2001:0db8::1428:57ab +3. IPv4 映射地址: + - 允许在 IPv6 地址的后 32 位(最后两组)使用 IPv4 点分十进制格式。 + - 这种格式通常用于表示 IPv4 地址到 IPv6 的映射。 + - 例如:::ffff:192.168.89.9 等价于 ::ffff:c0a8:5909 +4. 前后可以包含任意数量的空白字符(包括空格、制表符、换行符等)。 +5. 十六进制字母可以是大写(A-F)或小写(a-f)。 +6. IPv4 部分必须遵循 IPv4 的规则:每段数字值必须在 0~255 范围内。 +7. 如果地址格式不符合上述规则,报错。 + +##### 例子 + +| 输入字符串 | 解析结果 | 说明 | +| --- | --- | --- | +| 2001:db8:85a3:0000:0000:8a2e:0370:7334 | 成功 | 标准合法地址 | +| :: | 成功 | 全 0 地址 | +| 2001:db8:: | 成功 | 使用压缩格式的地址 | +| ::ffff:192.168.1.1 | 成功 | IPv4 映射地址 | +| 2001:db8::1 | 成功 | 前后可以有空白符号 | +| 2001:db8::1::2 | 报错 | 双冒号 (::) 出现了两次 | +| 2001:db8:85a3:0000:0000:8a2e:0370:7334:1234 | 报错 | 超过 8 组 | +| 2001:db8:85a3:0000:8a2e:0370 | 报错 | 只有 6 组 (必须 8 组或使用压缩格式) | +| 2001:db8:85g3:0000:0000:8a2e:0370:7334 | 报错 | 含非法十六进制字符'g' | +| 2001:db8::ffff:192.168.1.260 | 报错 | IPv4 部分超出范围 (260>255) | +| 2001:db8::ffff:192.168..1 | 报错 | IPv4 部分格式错误 (缺少一段) | +| 2001:0db8:85a3:::8a2e:0370:7334 | 报错 | 三个冒号连用 | +| 20001:db8::1 | 报错 | 第一组超过 4 位十六进制数 | + +#### 非严格模式 + +##### BNF 定义 + +```xml +<ipv6> ::= <whitespace>* <ipv6-standard> <whitespace>* + | <whitespace>* <ipv6-compressed> <whitespace>* + | <whitespace>* <ipv6-ipv4-mapped> <whitespace>* + +<ipv6-standard> ::= <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> ":" <h16> + +<h16> ::= <hexdigit>{1,4} + +<hexdigit> ::= <digit> | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F" + +<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" + +<whitespace> ::= " " | "\t" | "\n" | "\r" | "\f" | "\v" +``` + +##### 规则描述 + +1. 标准格式:8 组十六进制数字,每组由 1 至 4 个十六进制数字组成,组与组之间用冒号分隔。例如:2001:0db8:85a3:0000:0000:8a2e:0370:7334 +2. 压缩格式: + - 允许使用双冒号(::)表示一个或者多个连续的 0 组。 + - 双冒号(::)在整个地址中只能出现一次。 + - 只有:: 也是合法的地址,表示地址全 0 + - 1:1:1::1:1:1:1:1 不是合法的,因为::没有表示连续的 0 + - 以下地址都是合法并且相同的 + - 2001:0db8:0000:0000:0000:0000:1428:57ab + - 2001:0db8:0000:0000:0000::1428:57ab + - 2001:0db8:0:0:0:0:1428:57ab + - 2001:0db8:0::0:1428:57ab + - 2001:0db8::1428:57ab +3. IPv4 映射地址: + - 允许在 IPv6 地址的后 32 位(最后两组)使用 IPv4 点分十进制格式。 + - 这种格式通常用于表示 IPv4 地址到 IPv6 的映射。 + - 例如:::ffff:192.168.89.9 等价于 ::ffff:c0a8:5909 +4. 前后可以包含任意数量的空白字符(包括空格、制表符、换行符等)。 +5. 十六进制字母可以是大写(A-F)或小写(a-f)。 +6. IPv4 部分必须遵循 IPv4 的规则:每段数字值必须在 0~255 范围内。 +7. 如果地址格式不符合上述规则,返回 null。 + +##### 例子 + +| 输入字符串 | 解析结果 | 说明 | +| --- | --- | --- | +| 2001:db8:85a3:0000:0000:8a2e:0370:7334 | 成功 | 标准合法地址 | +| :: | 成功 | 全 0 地址 | +| 2001:db8:: | 成功 | 使用压缩格式的地址 | +| ::ffff:192.168.1.1 | 成功 | IPv4 映射地址 | +| 2001:db8::1 | 成功 | 前后可以有空白符号 | +| 2001:db8::1::2 | null | 双冒号 (::) 出现了两次 | +| 2001:db8:85a3:0000:0000:8a2e:0370:7334:1234 | null | 超过 8 组 | +| 2001:db8:85a3:0000:8a2e:0370 | null | 只有 6 组 (必须 8 组或使用压缩格式) | +| 2001:db8:85g3:0000:0000:8a2e:0370:7334 | null | 含非法十六进制字符'g' | +| 2001:db8::ffff:192.168.1.260 | null | IPv4 部分超出范围 (260>255) | +| 2001:db8::ffff:192.168..1 | null | IPv4 部分格式错误 (缺少一段) | +| 2001:0db8:85a3:::8a2e:0370:7334 | null | 三个冒号连用 | +| 20001:db8::1 | null | 第一组超过 4 位十六进制数 | + +### FROM IPv4 + +任意的 IPv4 都可以转换成 IPv6。不会出现无法转换的情况,严格模式与非严格模式的行为一致。 + +| 输入 IPv4 | 转换 IPv6 | +| --- | --- | +| 192.168.0.0 | ::ffff:192.168.0.0 | +| 0.0.0.0 | ::ffff:0.0.0.0 | diff --git a/sidebars.json b/sidebars.json index 61e054fd1f4..1cad785a6db 100644 --- a/sidebars.json +++ b/sidebars.json @@ -1032,6 +1032,7 @@ "sql-manual/basic-element/sql-data-types/conversion/decimal-conversion", "sql-manual/basic-element/sql-data-types/conversion/float-double-conversion", "sql-manual/basic-element/sql-data-types/conversion/int-conversion", + "sql-manual/basic-element/sql-data-types/conversion/ip-conversion", "sql-manual/basic-element/sql-data-types/conversion/time-conversion" ] } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org