Changeset: c4fdcb5f8627 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c4fdcb5f8627
Added Files:
        sql/test/Tests/mediumint.sql
        sql/test/Tests/mediumint.stable.err
        sql/test/Tests/mediumint.stable.out
Modified Files:
        sql/test/Tests/All
Branch: Nov2019
Log Message:

Add test to test MySQL/MariaDB specific data type mediumint.
Note: in MySQL/MariaDB a MEDIUMINT is stored in 3 bytes and has a valid range 
of: -8388608 .. 8388607
In MonetDB it is mapped as a synonym of INTEGER data type.

I also extended 
https://www.monetdb.org/Documentation/Manuals/SQLreference/BuiltinTypes


diffs (107 lines):

diff --git a/sql/test/Tests/All b/sql/test/Tests/All
--- a/sql/test/Tests/All
+++ b/sql/test/Tests/All
@@ -48,6 +48,7 @@ cast_str2num
 big-example
 count
 
+mediumint
 decimal
 decimal2
 null
diff --git a/sql/test/Tests/mediumint.sql b/sql/test/Tests/mediumint.sql
new file mode 100644
--- /dev/null
+++ b/sql/test/Tests/mediumint.sql
@@ -0,0 +1,21 @@
+-- test support for MySQL/MariaDB specific data type: MEDIUMINT
+-- Note: in MySQL/MariaDB a MEDIUMINT is stored in 3 bytes and has a valid 
range of: -8388608 .. 8388607
+
+-- in MonetDB mediumint is accepted, but mapped to an int
+create table meditbl(medi MEDIUMINT);
+
+\d meditbl
+-- note: that the data type is now changed into: INTEGER
+select name, type, type_digits, type_scale, number from sys.columns where name 
= 'medi' and table_id in (select id from sys.tables where name = 'meditbl');
+
+-- it accepts all 32-bit signed integer values which are also possible in an 
int data type
+INsert into meditbl values (0), (1), (-1), (32767), (-32767), (8388607), 
(-8388607), (2147483647), (-2147483647), (NULL);
+
+-- check for overflows (same as on an int)
+INsert into meditbl values (2147483648);       -- Error: overflow in 
conversion of 2147483648 to int.
+INsert into meditbl values (-2147483648);      -- Error: overflow in 
conversion of -2147483648 to int.
+
+select * from meditbl order by 1;
+
+drop table meditbl;
+
diff --git a/sql/test/Tests/mediumint.stable.err 
b/sql/test/Tests/mediumint.stable.err
new file mode 100644
--- /dev/null
+++ b/sql/test/Tests/mediumint.stable.err
@@ -0,0 +1,20 @@
+stderr of test 'mediumint` in directory 'sql/test` itself:
+
+
+# 16:18:53 >  
+# 16:18:53 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-192912" "--port=32869"
+# 16:18:53 >  
+
+MAPI  = (monetdb) /var/tmp/mtest-192912/.s.monetdb.32869
+QUERY = INsert into meditbl values (2147483648);       -- Error: overflow in 
conversion of 2147483648 to int.
+ERROR = !overflow in conversion of 2147483648 to int.
+CODE  = 22003
+MAPI  = (monetdb) /var/tmp/mtest-192912/.s.monetdb.32869
+QUERY = INsert into meditbl values (-2147483648);      -- Error: overflow in 
conversion of -2147483648 to int.
+ERROR = !overflow in conversion of -2147483648 to int.
+CODE  = 22003
+
+# 16:18:53 >  
+# 16:18:53 >  "Done."
+# 16:18:53 >  
+
diff --git a/sql/test/Tests/mediumint.stable.out 
b/sql/test/Tests/mediumint.stable.out
new file mode 100644
--- /dev/null
+++ b/sql/test/Tests/mediumint.stable.out
@@ -0,0 +1,40 @@
+stdout of test 'mediumint` in directory 'sql/test` itself:
+
+
+# 16:18:53 >  
+# 16:18:53 >  "mclient" "-lsql" "-ftest" "-tnone" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-192912" "--port=32869"
+# 16:18:53 >  
+
+#create table meditbl(medi MEDIUMINT);
+CREATE TABLE "sys"."meditbl" (
+       "medi" INTEGER
+);
+#select name, type, type_digits, type_scale, number from sys.columns where 
name = 'medi' and table_id in (select id from sys.tables where name = 
'meditbl');
+% .columns,    .columns,       .columns,       .columns,       .columns # 
table_name
+% name,        type,   type_digits,    type_scale,     number # name
+% varchar,     varchar,        int,    int,    int # type
+% 4,   3,      2,      1,      1 # length
+[ "medi",      "int",  32,     0,      0       ]
+#INsert into meditbl values (0), (1), (-1), (32767), (-32767), (8388607), 
(-8388607), (2147483647), (-2147483647), (NULL);
+[ 10   ]
+#select * from meditbl order by 1;
+% sys.meditbl # table_name
+% medi # name
+% int # type
+% 11 # length
+[ NULL ]
+[ -2147483647  ]
+[ -8388607     ]
+[ -32767       ]
+[ -1   ]
+[ 0    ]
+[ 1    ]
+[ 32767        ]
+[ 8388607      ]
+[ 2147483647   ]
+#drop table meditbl;
+
+# 16:18:53 >  
+# 16:18:53 >  "Done."
+# 16:18:53 >  
+
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to