Skip to content

Commit

Permalink
SQL: Fix column size for IP data type (#53056)
Browse files Browse the repository at this point in the history
Set size/displaySize to 45 which is the maximum string for
an IP (v6), since IPs are returned as strings.

Fixes: #52762
  • Loading branch information
matriv authored Mar 4, 2020
1 parent dbe6769 commit 815f017
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public final class DataTypes {
// date
public static final DataType DATETIME = new DataType("DATETIME", "date", Long.BYTES, false, false, true);
// ip
public static final DataType IP = new DataType("ip", 39, false, false, true);
public static final DataType IP = new DataType("ip", 45, false, false, true);
// binary
public static final DataType BINARY = new DataType("binary", Integer.MAX_VALUE, false, false, true);
// complex types
Expand Down Expand Up @@ -162,4 +162,4 @@ public static boolean areCompatible(DataType left, DataType right) {
|| (left == DATETIME && right == DATETIME);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public void testDateTimes() throws IOException {
}

public void testIPs() throws IOException {
assertQuery("SELECT CAST('12.13.14.15' AS IP)", "CAST('12.13.14.15' AS IP)", "ip", "12.13.14.15", 0);
assertQuery("SELECT CAST('12.13.14.15' AS IP)", "CAST('12.13.14.15' AS IP)", "ip", "12.13.14.15", 45);
assertQuery("SELECT CAST('2001:0db8:0000:0000:0000:ff00:0042:8329' AS IP)", "CAST('2001:0db8:0000:0000:0000:ff00:0042:8329' AS IP)",
"ip", "2001:0db8:0000:0000:0000:ff00:0042:8329", 0);
"ip", "2001:0db8:0000:0000:0000:ff00:0042:8329", 45);
}

public void testDateTimeIntervals() throws IOException {
Expand Down
Loading

0 comments on commit 815f017

Please sign in to comment.