Changeset: 1aed08ff63bd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1aed08ff63bd
Modified Files:
sql/test/bincopy/Tests/bincopy_decimal_range.test.in
sql/test/bincopy/Tests/bincopycollist-prepare.py
sql/test/bincopy/Tests/bincopycollist.test.in
Branch: Jun2023
Log Message:
Test both BIG and LITTLE ENDIAN in bincopy_decimal_range.test
diffs (145 lines):
diff --git a/sql/test/bincopy/Tests/bincopy_decimal_range.test.in
b/sql/test/bincopy/Tests/bincopy_decimal_range.test.in
--- a/sql/test/bincopy/Tests/bincopy_decimal_range.test.in
+++ b/sql/test/bincopy/Tests/bincopy_decimal_range.test.in
@@ -5,14 +5,20 @@ statement ok
CREATE TABLE foo(i INT)
statement ok
-COPY BIG ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/be123.bin'
+COPY LITTLE ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/maxint.le'
statement ok
-COPY BIG ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/maxint.bin'
+COPY BIG ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/123.be'
+
+statement ok
+COPY BIG ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/maxint.be'
query I nosort
SELECT i FROM foo
----
+2147483647
+2147483647
+2147483647
1
2
3
@@ -23,6 +29,9 @@ 2147483647
statement ok
ROLLBACK
+
+
+
statement ok
START TRANSACTION
@@ -30,7 +39,7 @@ statement ok
CREATE TABLE foo(d DECIMAL(8,2))
statement ok
-COPY BIG ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/be123.bin'
+COPY BIG ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/123.be'
query T nosort
SELECT CAST(d AS TEXT) FROM foo
@@ -40,8 +49,33 @@ 0.02
0.03
statement error
-COPY BIG ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/maxint.bin'
+COPY BIG ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/maxint.be'
statement ok
ROLLBACK
+
+
+
+statement ok
+START TRANSACTION
+
+statement ok
+CREATE TABLE foo(d DECIMAL(8,2))
+
+statement ok
+COPY LITTLE ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/123.le'
+
+query T nosort
+SELECT CAST(d AS TEXT) FROM foo
+----
+0.01
+0.02
+0.03
+
+statement error
+COPY LITTLE ENDIAN BINARY INTO foo FROM E'$QTSTTRGDIR/maxint.le'
+
+statement ok
+ROLLBACK
+
diff --git a/sql/test/bincopy/Tests/bincopycollist-prepare.py
b/sql/test/bincopy/Tests/bincopycollist-prepare.py
--- a/sql/test/bincopy/Tests/bincopycollist-prepare.py
+++ b/sql/test/bincopy/Tests/bincopycollist-prepare.py
@@ -3,15 +3,35 @@ import os
target_dir = os.getenv('TSTTRGDIR')
-testdata = dict(
- maxint=b'\x7f\xff\xff\xff\x7f\xff\xff\xff\x7f\xff\xff\xff',
- strings=b'one\x00two\x00three\x00',
- be456=b'\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00\x06',
- be123=b'\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03',
- bincopyint=struct.pack('10i', *range(10)),
-)
+
+MAXINT32 = 0x7FFF_FFFF
+
-for name, content in testdata.items():
- filename = os.path.join(target_dir, name + '.bin')
+def write_data(name, format, *items):
+ if name.endswith('.be'):
+ assert '>' in format
+ if name.endswith('.le'):
+ assert '<' in format
+ if format:
+ data = struct.pack(format, *items)
+ else:
+ data = b''
+ for item in items:
+ data += item
+ data += b'\0'
+ filename = os.path.join(target_dir, name)
with open(filename, 'wb') as f:
- f.write(content)
+ f.write(data)
+
+
+write_data('123.be', '>3i', 1, 2, 3)
+write_data('123.le', '<3i', 1, 2, 3)
+
+write_data('456.be', '>3i', 4, 5, 6)
+write_data('bincopyint.bin', '=10i', *range(10))
+
+write_data('maxint.be', '>3i', MAXINT32, MAXINT32, MAXINT32)
+write_data('maxint.le', '<3i', MAXINT32, MAXINT32, MAXINT32)
+
+write_data('strings.bin', '', b'one', b'two', b'three')
+
diff --git a/sql/test/bincopy/Tests/bincopycollist.test.in
b/sql/test/bincopy/Tests/bincopycollist.test.in
--- a/sql/test/bincopy/Tests/bincopycollist.test.in
+++ b/sql/test/bincopy/Tests/bincopycollist.test.in
@@ -28,10 +28,10 @@ statement ok
CREATE TABLE intvals(x INTEGER, y INTEGER)
statement ok
-COPY BIG ENDIAN BINARY INTO intvals FROM (E'$QTSTTRGDIR/be123.bin',
E'$QTSTTRGDIR/be456.bin')
+COPY BIG ENDIAN BINARY INTO intvals FROM (E'$QTSTTRGDIR/123.be',
E'$QTSTTRGDIR/456.be')
statement ok
-COPY BIG ENDIAN BINARY INTO intvals(y, x) FROM (E'$QTSTTRGDIR/be123.bin',
E'$QTSTTRGDIR/be456.bin')
+COPY BIG ENDIAN BINARY INTO intvals(y, x) FROM (E'$QTSTTRGDIR/123.be',
E'$QTSTTRGDIR/456.be')
query II nosort
SELECT x, y FROM intvals
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]