Changeset: 95fd5d7c9399 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/95fd5d7c9399
Added Files:
sql/test/bincopy/Tests/bincopy_inet4_on_client.SQL.py
sql/test/bincopy/Tests/bincopy_inet4_on_server.SQL.py
Modified Files:
clients/examples/C/bincopydata.c
sql/test/bincopy/Tests/All
sql/test/bincopy/Tests/bincopy_support.py
Branch: Dec2025
Log Message:
Test COPY BINARY support for inet4
diffs (115 lines):
diff --git a/clients/examples/C/bincopydata.c b/clients/examples/C/bincopydata.c
--- a/clients/examples/C/bincopydata.c
+++ b/clients/examples/C/bincopydata.c
@@ -276,6 +276,21 @@ gen_json(FILE *f, bool byteswap, long nr
}
}
+static void
+gen_inet4(FILE *f, bool byteswap, long nrecs, char *arg)
+{
+ (void)arg;
+ (void)byteswap;
+ for (int v = 0; v < nrecs; v++) {
+ uint64_t i = (v == 3) ? 0x00000000 : (v + 1) * 1001001001;
+ // always big endian
+ fputc((i >> 24) % 256, f);
+ fputc((i >> 16) % 256, f);
+ fputc((i >> 8) % 256, f);
+ fputc(i % 256, f);
+ }
+}
+
#define FUNCNAME gen_decimal_tinyints
#define STYP int8_t
#define UTYP uint8_t
@@ -355,6 +370,8 @@ static struct gen {
{ "timestamp_months", gen_timestamp_months },
{ "timestamp_years", gen_timestamp_years },
+ { "inet4", gen_inet4 },
+
{ "json_objects", gen_json },
{ "binary_uuids", gen_bin_uuids },
diff --git a/sql/test/bincopy/Tests/All b/sql/test/bincopy/Tests/All
--- a/sql/test/bincopy/Tests/All
+++ b/sql/test/bincopy/Tests/All
@@ -44,6 +44,9 @@ bincopy_json_objects_on_server
bincopy_uuids_on_client
bincopy_uuids_on_server
+bincopy_inet4_on_client
+bincopy_inet4_on_server
+
bincopy_nulls
bincopy_invalid_json
diff --git a/sql/test/bincopy/Tests/bincopy_inet4_on_client.SQL.py
b/sql/test/bincopy/Tests/bincopy_inet4_on_client.SQL.py
new file mode 100644
--- /dev/null
+++ b/sql/test/bincopy/Tests/bincopy_inet4_on_client.SQL.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+
+import sys
+import os
+sys.path.append(os.getenv('TSTSRCDIR'))
+from bincopy_support import run_test
+from bincopy_support import INET4 as testcode
+
+run_test('client', testcode)
diff --git a/sql/test/bincopy/Tests/bincopy_inet4_on_server.SQL.py
b/sql/test/bincopy/Tests/bincopy_inet4_on_server.SQL.py
new file mode 100644
--- /dev/null
+++ b/sql/test/bincopy/Tests/bincopy_inet4_on_server.SQL.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+
+import sys
+import os
+sys.path.append(os.getenv('TSTSRCDIR'))
+from bincopy_support import run_test
+from bincopy_support import INET4 as testcode
+
+run_test('server', testcode)
diff --git a/sql/test/bincopy/Tests/bincopy_support.py
b/sql/test/bincopy/Tests/bincopy_support.py
--- a/sql/test/bincopy/Tests/bincopy_support.py
+++ b/sql/test/bincopy/Tests/bincopy_support.py
@@ -732,3 +732,36 @@ SELECT
FROM foo;
""", [f"{NRECS},{42*NRECS},{(10 + NRECS+9) * NRECS // 2}"]
)
+
+INET4 = (f"""
+CREATE TABLE foo(id INT NOT NULL, i4 inet4);
+COPY BINARY INTO foo(id, i4) FROM @ints@, @inet4@ @ON@;
+COPY SELECT id, i4 FROM foo INTO BINARY @>ints@, @>inet4@ @ON@;
+--
+WITH
+ seeds AS (
+ SELECT
+ value AS id,
+ ifthenelse(value = 3, NULL, value) AS value
+ FROM sys.generate_series(0, {NRECS})
+ ),
+ numbers AS (
+ SELECT
+ id,
+ (value+1) * 1_001_001_001 AS i
+ FROM seeds
+ ),
+ strings AS (
+ SELECT
+ id,
+ '' || (i>>24) % 256 || '.' || (i>>16) % 256 || '.' || (i>>8) % 256
|| '.' || i % 256 AS i4s
+ FROM numbers
+ ),
+ refdata AS (
+ SELECT id, CAST(i4s AS inet4) AS i4 FROM strings
+ )
+SELECT COUNT(*)
+FROM foo FULL OUTER JOIN refdata ON foo.id = refdata.id
+WHERE foo.i4 = refdata.i4 OR (foo.i4 IS NULL AND refdata.i4 IS NULL);
+""", [f"{NRECS}"])
+
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]