From 5318b756629349cd4af6798ba4c07eb7bc583e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Mon, 7 Aug 2023 16:23:48 +0300 Subject: [PATCH 01/14] Restore bit and varbit support with tests --- deparse.c | 12 ++- expected/11.17/type.out | 179 +++++++++++++++++++++++++++++++++++++++- expected/12.12/type.out | 179 +++++++++++++++++++++++++++++++++++++++- expected/13.8/type.out | 179 +++++++++++++++++++++++++++++++++++++++- expected/14.5/type.out | 179 +++++++++++++++++++++++++++++++++++++++- expected/15.0/type.out | 177 ++++++++++++++++++++++++++++++++++++++- sql/11.17/type.sql | 86 +++++++++++++++++++ sql/12.12/type.sql | 86 +++++++++++++++++++ sql/13.8/type.sql | 86 +++++++++++++++++++ sql/14.5/type.sql | 86 +++++++++++++++++++ sql/15.0/type.sql | 86 +++++++++++++++++++ sql/init_data/init.sql | 5 +- sqlite_fdw.h | 6 ++ sqlite_query.c | 59 ++++++++++++- 14 files changed, 1391 insertions(+), 14 deletions(-) diff --git a/deparse.c b/deparse.c index 557ce30d..1ab3f53a 100644 --- a/deparse.c +++ b/deparse.c @@ -2561,8 +2561,16 @@ sqlite_deparse_const(Const *node, deparse_expr_cxt *context, int showtype) break; case BITOID: case VARBITOID: - extval = OidOutputFunctionCall(typoutput, node->constvalue); - appendStringInfo(buf, "B\'%s\'", extval); + { + extval = OidOutputFunctionCall(typoutput, node->constvalue); + if (strlen(extval) > SQLITE_FDW_BIT_DATATYPE_BUF_SIZE - 1 ) + { + ereport(ERROR, (errcode(ERRCODE_FDW_INVALID_DATA_TYPE), + errmsg("SQLite FDW dosens't support very long bit/varbit data"), + errhint("bit length %ld, maxmum %ld", strlen(extval), SQLITE_FDW_BIT_DATATYPE_BUF_SIZE - 1))); + } + appendStringInfo(buf, "%lld", binstr2int(extval)); + } break; case BOOLOID: extval = OidOutputFunctionCall(typoutput, node->constvalue); diff --git a/expected/11.17/type.out b/expected/11.17/type.out index 4a70b2fe..d76bb8b0 100644 --- a/expected/11.17/type.out +++ b/expected/11.17/type.out @@ -499,9 +499,179 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; +--Testcase 178: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 179: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 180: +DROP FOREIGN TABLE "type_BIT+"; +ERROR: foreign table "type_BIT+" does not exist +--Testcase 181: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 182: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 183: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 184: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +ERROR: bit string length 1 does not match type bit(6) +--Testcase 185: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +ERROR: bit string length 2 does not match type bit(6) +--Testcase 186: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +ERROR: bit string length 3 does not match type bit(6) +--Testcase 187: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 188: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 189: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 190: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 191: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 192: +SELECT * FROM "type_BIT+"; + i | b | t | l | bi +---+--------+---------+---+---- + 6 | 110110 | integer | 2 | 54 + 7 | 111001 | integer | 2 | 57 + 8 | 110000 | integer | 2 | 48 + 9 | 100001 | integer | 2 | 33 +(4 rows) + +--Testcase 193: +SELECT * FROM "type_BIT" WHERE b < '110110'; + i | b +---+-------- + 8 | 110000 + 9 | 100001 +(2 rows) + +--Testcase 194: +SELECT * FROM "type_BIT" WHERE b > '110110'; + i | b +---+-------- + 7 | 111001 +(1 row) + +--Testcase 195: +SELECT * FROM "type_BIT" WHERE b = '110110'; + i | b +---+-------- + 6 | 110110 +(1 row) + +--Testcase 196: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 197: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 199: +DROP FOREIGN TABLE "type_VARBIT+"; +ERROR: foreign table "type_VARBIT+" does not exist +--Testcase 200: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 201: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 202: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 203: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 204: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 205: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 206: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 207: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 208: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 209: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 210: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 211: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); +--Testcase 212 +SELECT * FROM "type_VARBIT+"; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 6 | 110110 | integer | 2 + 7 | 111001 | integer | 2 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(11 rows) + +--Testcase 213: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; + i | b | t | l +---+--------+---------+--- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 +(7 rows) + +--Testcase 214: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 7 | 111001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(3 rows) + +--Testcase 215: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + i | b | t | l +---+--------+---------+--- + 6 | 110110 | integer | 2 +(1 row) + +--Testcase 216: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 217: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 218: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +ERROR: SQLite FDW dosens't support very long bit/varbit data +HINT: bit length 65, maxmum 64 +--Testcase 219: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + i | b | t | l +----+-----------------------------------------------------------------+---------+---- + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | integer | 19 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 40 other objects +NOTICE: drop cascades to 45 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -526,7 +696,6 @@ drop cascades to foreign table "type_TIMESTAMP" drop cascades to foreign table "type_BLOB" drop cascades to foreign table "type_DATE" drop cascades to foreign table "type_TIME" -drop cascades to foreign table "BitT" drop cascades to foreign table notype drop cascades to foreign table typetest drop cascades to foreign table "type_TEXT" @@ -539,6 +708,12 @@ drop cascades to foreign table fts_table_idx drop cascades to foreign table fts_table_content drop cascades to foreign table fts_table_docsize drop cascades to foreign table fts_table_config +drop cascades to foreign table "RO_RW_test" +drop cascades to foreign table "Unicode data" drop cascades to foreign table type_json drop cascades to foreign table "type_BOOLEAN" +drop cascades to foreign table "type_BIT" +drop cascades to foreign table "type_BIT+" +drop cascades to foreign table "type_VARBIT" +drop cascades to foreign table "type_VARBIT+" drop cascades to server sqlite2 diff --git a/expected/12.12/type.out b/expected/12.12/type.out index 4a70b2fe..d76bb8b0 100644 --- a/expected/12.12/type.out +++ b/expected/12.12/type.out @@ -499,9 +499,179 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; +--Testcase 178: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 179: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 180: +DROP FOREIGN TABLE "type_BIT+"; +ERROR: foreign table "type_BIT+" does not exist +--Testcase 181: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 182: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 183: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 184: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +ERROR: bit string length 1 does not match type bit(6) +--Testcase 185: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +ERROR: bit string length 2 does not match type bit(6) +--Testcase 186: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +ERROR: bit string length 3 does not match type bit(6) +--Testcase 187: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 188: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 189: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 190: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 191: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 192: +SELECT * FROM "type_BIT+"; + i | b | t | l | bi +---+--------+---------+---+---- + 6 | 110110 | integer | 2 | 54 + 7 | 111001 | integer | 2 | 57 + 8 | 110000 | integer | 2 | 48 + 9 | 100001 | integer | 2 | 33 +(4 rows) + +--Testcase 193: +SELECT * FROM "type_BIT" WHERE b < '110110'; + i | b +---+-------- + 8 | 110000 + 9 | 100001 +(2 rows) + +--Testcase 194: +SELECT * FROM "type_BIT" WHERE b > '110110'; + i | b +---+-------- + 7 | 111001 +(1 row) + +--Testcase 195: +SELECT * FROM "type_BIT" WHERE b = '110110'; + i | b +---+-------- + 6 | 110110 +(1 row) + +--Testcase 196: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 197: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 199: +DROP FOREIGN TABLE "type_VARBIT+"; +ERROR: foreign table "type_VARBIT+" does not exist +--Testcase 200: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 201: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 202: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 203: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 204: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 205: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 206: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 207: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 208: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 209: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 210: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 211: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); +--Testcase 212 +SELECT * FROM "type_VARBIT+"; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 6 | 110110 | integer | 2 + 7 | 111001 | integer | 2 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(11 rows) + +--Testcase 213: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; + i | b | t | l +---+--------+---------+--- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 +(7 rows) + +--Testcase 214: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 7 | 111001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(3 rows) + +--Testcase 215: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + i | b | t | l +---+--------+---------+--- + 6 | 110110 | integer | 2 +(1 row) + +--Testcase 216: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 217: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 218: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +ERROR: SQLite FDW dosens't support very long bit/varbit data +HINT: bit length 65, maxmum 64 +--Testcase 219: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + i | b | t | l +----+-----------------------------------------------------------------+---------+---- + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | integer | 19 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 40 other objects +NOTICE: drop cascades to 45 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -526,7 +696,6 @@ drop cascades to foreign table "type_TIMESTAMP" drop cascades to foreign table "type_BLOB" drop cascades to foreign table "type_DATE" drop cascades to foreign table "type_TIME" -drop cascades to foreign table "BitT" drop cascades to foreign table notype drop cascades to foreign table typetest drop cascades to foreign table "type_TEXT" @@ -539,6 +708,12 @@ drop cascades to foreign table fts_table_idx drop cascades to foreign table fts_table_content drop cascades to foreign table fts_table_docsize drop cascades to foreign table fts_table_config +drop cascades to foreign table "RO_RW_test" +drop cascades to foreign table "Unicode data" drop cascades to foreign table type_json drop cascades to foreign table "type_BOOLEAN" +drop cascades to foreign table "type_BIT" +drop cascades to foreign table "type_BIT+" +drop cascades to foreign table "type_VARBIT" +drop cascades to foreign table "type_VARBIT+" drop cascades to server sqlite2 diff --git a/expected/13.8/type.out b/expected/13.8/type.out index 4a70b2fe..d76bb8b0 100644 --- a/expected/13.8/type.out +++ b/expected/13.8/type.out @@ -499,9 +499,179 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; +--Testcase 178: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 179: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 180: +DROP FOREIGN TABLE "type_BIT+"; +ERROR: foreign table "type_BIT+" does not exist +--Testcase 181: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 182: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 183: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 184: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +ERROR: bit string length 1 does not match type bit(6) +--Testcase 185: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +ERROR: bit string length 2 does not match type bit(6) +--Testcase 186: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +ERROR: bit string length 3 does not match type bit(6) +--Testcase 187: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 188: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 189: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 190: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 191: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 192: +SELECT * FROM "type_BIT+"; + i | b | t | l | bi +---+--------+---------+---+---- + 6 | 110110 | integer | 2 | 54 + 7 | 111001 | integer | 2 | 57 + 8 | 110000 | integer | 2 | 48 + 9 | 100001 | integer | 2 | 33 +(4 rows) + +--Testcase 193: +SELECT * FROM "type_BIT" WHERE b < '110110'; + i | b +---+-------- + 8 | 110000 + 9 | 100001 +(2 rows) + +--Testcase 194: +SELECT * FROM "type_BIT" WHERE b > '110110'; + i | b +---+-------- + 7 | 111001 +(1 row) + +--Testcase 195: +SELECT * FROM "type_BIT" WHERE b = '110110'; + i | b +---+-------- + 6 | 110110 +(1 row) + +--Testcase 196: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 197: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 199: +DROP FOREIGN TABLE "type_VARBIT+"; +ERROR: foreign table "type_VARBIT+" does not exist +--Testcase 200: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 201: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 202: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 203: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 204: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 205: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 206: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 207: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 208: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 209: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 210: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 211: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); +--Testcase 212 +SELECT * FROM "type_VARBIT+"; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 6 | 110110 | integer | 2 + 7 | 111001 | integer | 2 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(11 rows) + +--Testcase 213: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; + i | b | t | l +---+--------+---------+--- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 +(7 rows) + +--Testcase 214: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 7 | 111001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(3 rows) + +--Testcase 215: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + i | b | t | l +---+--------+---------+--- + 6 | 110110 | integer | 2 +(1 row) + +--Testcase 216: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 217: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 218: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +ERROR: SQLite FDW dosens't support very long bit/varbit data +HINT: bit length 65, maxmum 64 +--Testcase 219: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + i | b | t | l +----+-----------------------------------------------------------------+---------+---- + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | integer | 19 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 40 other objects +NOTICE: drop cascades to 45 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -526,7 +696,6 @@ drop cascades to foreign table "type_TIMESTAMP" drop cascades to foreign table "type_BLOB" drop cascades to foreign table "type_DATE" drop cascades to foreign table "type_TIME" -drop cascades to foreign table "BitT" drop cascades to foreign table notype drop cascades to foreign table typetest drop cascades to foreign table "type_TEXT" @@ -539,6 +708,12 @@ drop cascades to foreign table fts_table_idx drop cascades to foreign table fts_table_content drop cascades to foreign table fts_table_docsize drop cascades to foreign table fts_table_config +drop cascades to foreign table "RO_RW_test" +drop cascades to foreign table "Unicode data" drop cascades to foreign table type_json drop cascades to foreign table "type_BOOLEAN" +drop cascades to foreign table "type_BIT" +drop cascades to foreign table "type_BIT+" +drop cascades to foreign table "type_VARBIT" +drop cascades to foreign table "type_VARBIT+" drop cascades to server sqlite2 diff --git a/expected/14.5/type.out b/expected/14.5/type.out index 4a70b2fe..d76bb8b0 100644 --- a/expected/14.5/type.out +++ b/expected/14.5/type.out @@ -499,9 +499,179 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; +--Testcase 178: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 179: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 180: +DROP FOREIGN TABLE "type_BIT+"; +ERROR: foreign table "type_BIT+" does not exist +--Testcase 181: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 182: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 183: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 184: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +ERROR: bit string length 1 does not match type bit(6) +--Testcase 185: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +ERROR: bit string length 2 does not match type bit(6) +--Testcase 186: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +ERROR: bit string length 3 does not match type bit(6) +--Testcase 187: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 188: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 189: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 190: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 191: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 192: +SELECT * FROM "type_BIT+"; + i | b | t | l | bi +---+--------+---------+---+---- + 6 | 110110 | integer | 2 | 54 + 7 | 111001 | integer | 2 | 57 + 8 | 110000 | integer | 2 | 48 + 9 | 100001 | integer | 2 | 33 +(4 rows) + +--Testcase 193: +SELECT * FROM "type_BIT" WHERE b < '110110'; + i | b +---+-------- + 8 | 110000 + 9 | 100001 +(2 rows) + +--Testcase 194: +SELECT * FROM "type_BIT" WHERE b > '110110'; + i | b +---+-------- + 7 | 111001 +(1 row) + +--Testcase 195: +SELECT * FROM "type_BIT" WHERE b = '110110'; + i | b +---+-------- + 6 | 110110 +(1 row) + +--Testcase 196: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 197: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 199: +DROP FOREIGN TABLE "type_VARBIT+"; +ERROR: foreign table "type_VARBIT+" does not exist +--Testcase 200: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 201: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 202: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 203: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 204: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 205: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 206: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 207: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 208: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 209: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 210: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 211: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); +--Testcase 212 +SELECT * FROM "type_VARBIT+"; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 6 | 110110 | integer | 2 + 7 | 111001 | integer | 2 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(11 rows) + +--Testcase 213: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; + i | b | t | l +---+--------+---------+--- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 +(7 rows) + +--Testcase 214: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 7 | 111001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(3 rows) + +--Testcase 215: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + i | b | t | l +---+--------+---------+--- + 6 | 110110 | integer | 2 +(1 row) + +--Testcase 216: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 217: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 218: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +ERROR: SQLite FDW dosens't support very long bit/varbit data +HINT: bit length 65, maxmum 64 +--Testcase 219: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + i | b | t | l +----+-----------------------------------------------------------------+---------+---- + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | integer | 19 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 40 other objects +NOTICE: drop cascades to 45 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -526,7 +696,6 @@ drop cascades to foreign table "type_TIMESTAMP" drop cascades to foreign table "type_BLOB" drop cascades to foreign table "type_DATE" drop cascades to foreign table "type_TIME" -drop cascades to foreign table "BitT" drop cascades to foreign table notype drop cascades to foreign table typetest drop cascades to foreign table "type_TEXT" @@ -539,6 +708,12 @@ drop cascades to foreign table fts_table_idx drop cascades to foreign table fts_table_content drop cascades to foreign table fts_table_docsize drop cascades to foreign table fts_table_config +drop cascades to foreign table "RO_RW_test" +drop cascades to foreign table "Unicode data" drop cascades to foreign table type_json drop cascades to foreign table "type_BOOLEAN" +drop cascades to foreign table "type_BIT" +drop cascades to foreign table "type_BIT+" +drop cascades to foreign table "type_VARBIT" +drop cascades to foreign table "type_VARBIT+" drop cascades to server sqlite2 diff --git a/expected/15.0/type.out b/expected/15.0/type.out index b361c2f1..d76bb8b0 100644 --- a/expected/15.0/type.out +++ b/expected/15.0/type.out @@ -499,9 +499,179 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; +--Testcase 178: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 179: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 180: +DROP FOREIGN TABLE "type_BIT+"; +ERROR: foreign table "type_BIT+" does not exist +--Testcase 181: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 182: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 183: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 184: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +ERROR: bit string length 1 does not match type bit(6) +--Testcase 185: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +ERROR: bit string length 2 does not match type bit(6) +--Testcase 186: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +ERROR: bit string length 3 does not match type bit(6) +--Testcase 187: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 188: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 189: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 190: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 191: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 192: +SELECT * FROM "type_BIT+"; + i | b | t | l | bi +---+--------+---------+---+---- + 6 | 110110 | integer | 2 | 54 + 7 | 111001 | integer | 2 | 57 + 8 | 110000 | integer | 2 | 48 + 9 | 100001 | integer | 2 | 33 +(4 rows) + +--Testcase 193: +SELECT * FROM "type_BIT" WHERE b < '110110'; + i | b +---+-------- + 8 | 110000 + 9 | 100001 +(2 rows) + +--Testcase 194: +SELECT * FROM "type_BIT" WHERE b > '110110'; + i | b +---+-------- + 7 | 111001 +(1 row) + +--Testcase 195: +SELECT * FROM "type_BIT" WHERE b = '110110'; + i | b +---+-------- + 6 | 110110 +(1 row) + +--Testcase 196: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 197: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 199: +DROP FOREIGN TABLE "type_VARBIT+"; +ERROR: foreign table "type_VARBIT+" does not exist +--Testcase 200: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 201: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 202: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 203: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 204: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 205: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 206: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 207: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 208: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 209: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 210: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 211: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); +--Testcase 212 +SELECT * FROM "type_VARBIT+"; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 6 | 110110 | integer | 2 + 7 | 111001 | integer | 2 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(11 rows) + +--Testcase 213: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; + i | b | t | l +---+--------+---------+--- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 +(7 rows) + +--Testcase 214: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 7 | 111001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(3 rows) + +--Testcase 215: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + i | b | t | l +---+--------+---------+--- + 6 | 110110 | integer | 2 +(1 row) + +--Testcase 216: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 217: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 218: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +ERROR: SQLite FDW dosens't support very long bit/varbit data +HINT: bit length 65, maxmum 64 +--Testcase 219: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + i | b | t | l +----+-----------------------------------------------------------------+---------+---- + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | integer | 19 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 42 other objects +NOTICE: drop cascades to 45 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -526,7 +696,6 @@ drop cascades to foreign table "type_TIMESTAMP" drop cascades to foreign table "type_BLOB" drop cascades to foreign table "type_DATE" drop cascades to foreign table "type_TIME" -drop cascades to foreign table "BitT" drop cascades to foreign table notype drop cascades to foreign table typetest drop cascades to foreign table "type_TEXT" @@ -543,4 +712,8 @@ drop cascades to foreign table "RO_RW_test" drop cascades to foreign table "Unicode data" drop cascades to foreign table type_json drop cascades to foreign table "type_BOOLEAN" +drop cascades to foreign table "type_BIT" +drop cascades to foreign table "type_BIT+" +drop cascades to foreign table "type_VARBIT" +drop cascades to foreign table "type_VARBIT+" drop cascades to server sqlite2 diff --git a/sql/11.17/type.sql b/sql/11.17/type.sql index c6442406..41c2a94e 100644 --- a/sql/11.17/type.sql +++ b/sql/11.17/type.sql @@ -266,5 +266,91 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; +--Testcase 178: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 179: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 180: +DROP FOREIGN TABLE "type_BIT+"; +--Testcase 181: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 182: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +--Testcase 183: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +--Testcase 184: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +--Testcase 185: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +--Testcase 186: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +--Testcase 187: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 188: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 189: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 190: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 191: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +--Testcase 192: +SELECT * FROM "type_BIT+"; +--Testcase 193: +SELECT * FROM "type_BIT" WHERE b < '110110'; +--Testcase 194: +SELECT * FROM "type_BIT" WHERE b > '110110'; +--Testcase 195: +SELECT * FROM "type_BIT" WHERE b = '110110'; + +--Testcase 196: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 197: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 199: +DROP FOREIGN TABLE "type_VARBIT+"; +--Testcase 200: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 201: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 202: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 203: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 204: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 205: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 206: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 207: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 208: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 209: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 210: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 211: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); + +--Testcase 212 +SELECT * FROM "type_VARBIT+"; +--Testcase 213: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; +--Testcase 214: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; +--Testcase 215: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + +--Testcase 216: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 217: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 218: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +--Testcase 219: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/12.12/type.sql b/sql/12.12/type.sql index c6442406..41c2a94e 100644 --- a/sql/12.12/type.sql +++ b/sql/12.12/type.sql @@ -266,5 +266,91 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; +--Testcase 178: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 179: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 180: +DROP FOREIGN TABLE "type_BIT+"; +--Testcase 181: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 182: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +--Testcase 183: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +--Testcase 184: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +--Testcase 185: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +--Testcase 186: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +--Testcase 187: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 188: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 189: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 190: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 191: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +--Testcase 192: +SELECT * FROM "type_BIT+"; +--Testcase 193: +SELECT * FROM "type_BIT" WHERE b < '110110'; +--Testcase 194: +SELECT * FROM "type_BIT" WHERE b > '110110'; +--Testcase 195: +SELECT * FROM "type_BIT" WHERE b = '110110'; + +--Testcase 196: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 197: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 199: +DROP FOREIGN TABLE "type_VARBIT+"; +--Testcase 200: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 201: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 202: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 203: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 204: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 205: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 206: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 207: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 208: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 209: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 210: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 211: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); + +--Testcase 212 +SELECT * FROM "type_VARBIT+"; +--Testcase 213: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; +--Testcase 214: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; +--Testcase 215: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + +--Testcase 216: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 217: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 218: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +--Testcase 219: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/13.8/type.sql b/sql/13.8/type.sql index c6442406..41c2a94e 100644 --- a/sql/13.8/type.sql +++ b/sql/13.8/type.sql @@ -266,5 +266,91 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; +--Testcase 178: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 179: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 180: +DROP FOREIGN TABLE "type_BIT+"; +--Testcase 181: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 182: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +--Testcase 183: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +--Testcase 184: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +--Testcase 185: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +--Testcase 186: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +--Testcase 187: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 188: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 189: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 190: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 191: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +--Testcase 192: +SELECT * FROM "type_BIT+"; +--Testcase 193: +SELECT * FROM "type_BIT" WHERE b < '110110'; +--Testcase 194: +SELECT * FROM "type_BIT" WHERE b > '110110'; +--Testcase 195: +SELECT * FROM "type_BIT" WHERE b = '110110'; + +--Testcase 196: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 197: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 199: +DROP FOREIGN TABLE "type_VARBIT+"; +--Testcase 200: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 201: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 202: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 203: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 204: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 205: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 206: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 207: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 208: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 209: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 210: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 211: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); + +--Testcase 212 +SELECT * FROM "type_VARBIT+"; +--Testcase 213: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; +--Testcase 214: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; +--Testcase 215: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + +--Testcase 216: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 217: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 218: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +--Testcase 219: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/14.5/type.sql b/sql/14.5/type.sql index c6442406..41c2a94e 100644 --- a/sql/14.5/type.sql +++ b/sql/14.5/type.sql @@ -266,5 +266,91 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; +--Testcase 178: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 179: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 180: +DROP FOREIGN TABLE "type_BIT+"; +--Testcase 181: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 182: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +--Testcase 183: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +--Testcase 184: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +--Testcase 185: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +--Testcase 186: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +--Testcase 187: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 188: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 189: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 190: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 191: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +--Testcase 192: +SELECT * FROM "type_BIT+"; +--Testcase 193: +SELECT * FROM "type_BIT" WHERE b < '110110'; +--Testcase 194: +SELECT * FROM "type_BIT" WHERE b > '110110'; +--Testcase 195: +SELECT * FROM "type_BIT" WHERE b = '110110'; + +--Testcase 196: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 197: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 199: +DROP FOREIGN TABLE "type_VARBIT+"; +--Testcase 200: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 201: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 202: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 203: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 204: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 205: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 206: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 207: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 208: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 209: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 210: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 211: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); + +--Testcase 212 +SELECT * FROM "type_VARBIT+"; +--Testcase 213: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; +--Testcase 214: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; +--Testcase 215: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + +--Testcase 216: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 217: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 218: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +--Testcase 219: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/15.0/type.sql b/sql/15.0/type.sql index c6442406..41c2a94e 100644 --- a/sql/15.0/type.sql +++ b/sql/15.0/type.sql @@ -266,5 +266,91 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; +--Testcase 178: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 179: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 180: +DROP FOREIGN TABLE "type_BIT+"; +--Testcase 181: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 182: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +--Testcase 183: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +--Testcase 184: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +--Testcase 185: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +--Testcase 186: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +--Testcase 187: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 188: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 189: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 190: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 191: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +--Testcase 192: +SELECT * FROM "type_BIT+"; +--Testcase 193: +SELECT * FROM "type_BIT" WHERE b < '110110'; +--Testcase 194: +SELECT * FROM "type_BIT" WHERE b > '110110'; +--Testcase 195: +SELECT * FROM "type_BIT" WHERE b = '110110'; + +--Testcase 196: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 197: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 199: +DROP FOREIGN TABLE "type_VARBIT+"; +--Testcase 200: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 201: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 202: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 203: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 204: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 205: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 206: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 207: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 208: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 209: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 210: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 211: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); + +--Testcase 212 +SELECT * FROM "type_VARBIT+"; +--Testcase 213: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; +--Testcase 214: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; +--Testcase 215: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + +--Testcase 216: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 217: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 218: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +--Testcase 219: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/init_data/init.sql b/sql/init_data/init.sql index 64db2b7b..564e0c6b 100644 --- a/sql/init_data/init.sql +++ b/sql/init_data/init.sql @@ -33,7 +33,10 @@ CREATE TABLE "type_TIMESTAMP" (col timestamp primary key, b timestamp);--, c dat CREATE TABLE "type_BLOB" (col blob primary key); CREATE TABLE "type_DATE" (col date primary key); CREATE TABLE "type_TIME" (col time primary key); -CREATE TABLE BitT (p integer primary key, a BIT(3), b BIT VARYING(5)); +CREATE TABLE "type_BIT" (i int, b bit); +CREATE VIEW "type_BIT+" AS SELECT *, typeof(b) t, length(b) l FROM "type_BIT"; +CREATE TABLE "type_VARBIT" (i int, b bit); +CREATE VIEW "type_VARBIT+" AS SELECT *, typeof(b) t, length(b) l FROM "type_VARBIT"; CREATE TABLE notype (a); CREATE TABLE typetest (i integer, v varchar(10) , c char(10), t text, d datetime, ti timestamp); CREATE TABLE type_TEXT (col text primary key); diff --git a/sqlite_fdw.h b/sqlite_fdw.h index 9441a3c6..aa0be8d5 100644 --- a/sqlite_fdw.h +++ b/sqlite_fdw.h @@ -43,6 +43,8 @@ #define CR_NO_ERROR 0 +#define SQLITE_FDW_BIT_DATATYPE_BUF_SIZE sizeof(sqlite3_int64)* CHAR_BIT + 1 + #if (PG_VERSION_NUM < 120000) #define table_close(rel, lock) heap_close(rel, lock) #define table_open(rel, lock) heap_open(rel, lock) @@ -377,4 +379,8 @@ NullableDatum sqlite_convert_to_pg(Oid pgtyp, int pgtypmod, sqlite3_stmt * stmt, void sqlite_bind_sql_var(Oid type, int attnum, Datum value, sqlite3_stmt * stmt, bool *isnull); extern void sqlite_do_sql_command(sqlite3 * conn, const char *sql, int level, List **busy_connection); + +/* sqlite_query.c haders */ +sqlite3_int64 binstr2int(const char *s); + #endif /* SQLITE_FDW_H */ diff --git a/sqlite_query.c b/sqlite_query.c index c6c14166..94931ee5 100644 --- a/sqlite_query.c +++ b/sqlite_query.c @@ -33,7 +33,9 @@ static const char* static void sqlite_value_to_pg_error (Oid pgtyp, int pgtypmod, sqlite3_stmt * stmt, int stmt_colid, int sqlite_value_affinity, int affinity_for_pg_column, int value_byte_size_blob_or_utf8); static char * - sqlite_text_value_to_pg_db_encoding(sqlite3_stmt * stmt, int stmt_colid); + sqlite_text_value_to_pg_db_encoding(sqlite3_stmt * stmt, int stmt_colid); +char * + int2binstr(sqlite3_int64 num, char *s, size_t len); /* * convert_sqlite_to_pg: Convert Sqlite data into PostgreSQL's compatible data types @@ -124,6 +126,16 @@ sqlite_convert_to_pg(Oid pgtyp, int pgtypmod, sqlite3_stmt * stmt, int stmt_coli valstr = DatumGetCString(DirectFunctionCall1(float8out, Float8GetDatum((float8) value))); break; } + case VARBITOID: + case BITOID: + { + char * buffer = palloc0(SQLITE_FDW_BIT_DATATYPE_BUF_SIZE); + sqlite3_int64 sqlti = sqlite3_column_int64(stmt, stmt_colid); + buffer = int2binstr(sqlti, buffer, SQLITE_FDW_BIT_DATATYPE_BUF_SIZE); + valstr = buffer; + elog(DEBUG4, "sqlite_fdw : BIT buf l=%ld v = %s", SQLITE_FDW_BIT_DATATYPE_BUF_SIZE, buffer); + break; + } /* some popular datatypes for default algorythm branch * case BPCHAROID: * case VARCHAROID: @@ -266,7 +278,27 @@ sqlite_bind_sql_var(Oid type, int attnum, Datum value, sqlite3_stmt * stmt, bool ret = sqlite3_bind_blob(stmt, attnum, dat, len, SQLITE_TRANSIENT); break; } + case VARBITOID: + case BITOID: + { + sqlite3_int64 dat; + char *outputString = NULL; + Oid outputFunctionId = InvalidOid; + bool typeVarLength = false; + getTypeOutputInfo(type, &outputFunctionId, &typeVarLength); + outputString = OidOutputFunctionCall(outputFunctionId, value); + elog(DEBUG4, "sqlite_fdw : BIT bind %s", outputString); + if (strlen(outputString) > SQLITE_FDW_BIT_DATATYPE_BUF_SIZE - 1 ) + { + ereport(ERROR, (errcode(ERRCODE_FDW_INVALID_DATA_TYPE), + errmsg("SQLite FDW dosens't support very long bit/varbit data"), + errhint("bit length %ld, maxmum %ld", strlen(outputString), SQLITE_FDW_BIT_DATATYPE_BUF_SIZE - 1))); + } + dat = binstr2int(outputString); + ret = sqlite3_bind_int64(stmt, attnum, dat); + break; + } default: { ereport(ERROR, (errcode(ERRCODE_FDW_INVALID_DATA_TYPE), @@ -371,3 +403,28 @@ static char * sqlite_text_value_to_pg_db_encoding(sqlite3_stmt * stmt, int stmt_ /* There is no UTF16 in PostgreSQL for fast sqlite3_column_text16, hence always convert */ return (char *) pg_do_encoding_conversion((unsigned char *) utf8_text_value, strlen(utf8_text_value), PG_UTF8, pg_database_encoding); } + +char *int2binstr(sqlite3_int64 num, char *s, size_t len) +{ + s[--len] = '\0'; + do + s[--len] = ((num & 1) ? '1' : '0'); + while ((num >>= 1) != 0); + return s + len; +} + +sqlite3_int64 binstr2int(const char *s) +{ + sqlite3_int64 rc; + for (rc = 0; '\0' != *s; s++) { + if ('1' == *s) { + rc = (rc * 2) + 1; + } else if ('0' == *s) { + rc *= 2; + } else { + errno = EINVAL; + return -1; + } + } + return rc; +} From 88cf54a474ce0584847127fe9f001ddf0c8d0bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= <41448637+mkgrgis@users.noreply.github.com> Date: Fri, 27 Oct 2023 14:25:01 +0300 Subject: [PATCH 02/14] Delete 11.17 test --- expected/11.17/type.out | 719 ---------------------------------------- 1 file changed, 719 deletions(-) delete mode 100644 expected/11.17/type.out diff --git a/expected/11.17/type.out b/expected/11.17/type.out deleted file mode 100644 index d76bb8b0..00000000 --- a/expected/11.17/type.out +++ /dev/null @@ -1,719 +0,0 @@ ---SET log_min_messages TO DEBUG1; ---SET client_min_messages TO DEBUG1; ---Testcase 44: -CREATE EXTENSION sqlite_fdw; ---Testcase 45: -CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw -OPTIONS (database '/tmp/sqlitefdw_test.db'); ---Testcase 46: -CREATE SERVER sqlite2 FOREIGN DATA WRAPPER sqlite_fdw; -IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO public; ---Testcase 1: -INSERT INTO "type_STRING"(col) VALUES ('string'); ---Testcase 2: -INSERT INTO "type_BOOLEAN"(col) VALUES (TRUE); ---Testcase 3: -INSERT INTO "type_BOOLEAN"(col) VALUES (FALSE); ---Testcase 4: -INSERT INTO "type_BYTE"(col) VALUES ('c'); ---Testcase 5: -INSERT INTO "type_SINT"(col) VALUES (32767); ---Testcase 6: -INSERT INTO "type_SINT"(col) VALUES (-32768); ---Testcase 7: -INSERT INTO "type_BINT"(col) VALUES (9223372036854775807); ---Testcase 8: -INSERT INTO "type_BINT"(col) VALUES (-9223372036854775808); ---Testcase 9: -INSERT INTO "type_INTEGER"(col) VALUES (9223372036854775807); ---Testcase 10: -INSERT INTO "type_FLOAT"(col) VALUES (3.1415); ---Testcase 11: -INSERT INTO "type_DOUBLE"(col) VALUES (3.14159265); ---Testcase 12: -INSERT INTO "type_TIMESTAMP" VALUES ('2017.11.06 12:34:56.789', '2017.11.06'); ---Testcase 13: -INSERT INTO "type_TIMESTAMP" VALUES ('2017.11.06 1:3:0', '2017.11.07'); ---Testcase 14: -INSERT INTO "type_BLOB"(col) VALUES (bytea('\xDEADBEEF')); ---Testcase 15: -INSERT INTO typetest VALUES(1,'a', 'b', 'c','2017.11.06 12:34:56.789', '2017.11.06 12:34:56.789' ) ; ---Testcase 16: -SELECT * FROM "type_STRING"; - col --------- - string -(1 row) - ---Testcase 17: -SELECT * FROM "type_BOOLEAN"; - col ------ - t - f -(2 rows) - ---Testcase 18: -SELECT * FROM "type_BYTE"; - col ------ - c -(1 row) - ---Testcase 19: -SELECT * FROM "type_SINT"; - col --------- - 32767 - -32768 -(2 rows) - ---Testcase 20: -SELECT * FROM "type_BINT"; - col ----------------------- - 9223372036854775807 - -9223372036854775808 -(2 rows) - ---Testcase 21: -SELECT * FROM "type_INTEGER"; - col ---------------------- - 9223372036854775807 -(1 row) - ---Testcase 22: -SELECT * FROM "type_FLOAT"; - col --------- - 3.1415 -(1 row) - ---Testcase 23: -SELECT * FROM "type_DOUBLE"; - col ------------- - 3.14159265 -(1 row) - -set datestyle=ISO; ---Testcase 24: -SELECT * FROM "type_TIMESTAMP"; - col | b --------------------------+--------------------- - 2017-11-06 12:34:56.789 | 2017-11-06 00:00:00 - 2017-11-06 01:03:00 | 2017-11-07 00:00:00 -(2 rows) - ---Testcase 25: -SELECT * FROM "type_BLOB"; - col ------------- - \xdeadbeef -(1 row) - ---Testcase 26: -SELECT * FROM typetest; - i | v | c | t | d | ti ----+---+------------+---+-------------------------+------------------------- - 1 | a | b | c | 2017-11-06 12:34:56.789 | 2017-11-06 12:34:56.789 -(1 row) - ---Testcase 27: -insert into "type_STRING" values('TYPE'); ---Testcase 28: -insert into "type_STRING" values('type'); --- not pushdown ---Testcase 29: -SELECT *FROM "type_STRING" WHERE col like 'TYP%'; - col ------- - TYPE -(1 row) - ---Testcase 30: -EXPLAIN SELECT *FROM "type_STRING" WHERE col like 'TYP%'; - QUERY PLAN -------------------------------------------------------------------- - Foreign Scan on "type_STRING" (cost=10.00..7.00 rows=7 width=32) -(1 row) - --- pushdown ---Testcase 31: -SELECT *FROM "type_STRING" WHERE col ilike 'typ%'; - col ------- - TYPE - type -(2 rows) - ---Testcase 32: -EXPLAIN SELECT *FROM "type_STRING" WHERE col ilike 'typ%'; - QUERY PLAN ---------------------------------------------------------------------- - Foreign Scan on "type_STRING" (cost=10.00..58.00 rows=58 width=32) - Filter: (col ~~* 'typ%'::text) -(2 rows) - ---Testcase 33: -SELECT *FROM "type_STRING" WHERE col ilike 'typ%' and col like 'TYPE'; - col ------- - TYPE -(1 row) - ---Testcase 34: -EXPLAIN SELECT *FROM "type_STRING" WHERE col ilike 'typ%' and col like 'TYPE'; - QUERY PLAN -------------------------------------------------------------------- - Foreign Scan on "type_STRING" (cost=10.00..1.00 rows=1 width=32) - Filter: (col ~~* 'typ%'::text) -(2 rows) - ---Testcase 35: -SELECT * FROM "type_TIMESTAMP"; - col | b --------------------------+--------------------- - 2017-11-06 12:34:56.789 | 2017-11-06 00:00:00 - 2017-11-06 01:03:00 | 2017-11-07 00:00:00 -(2 rows) - ---Testcase 36: -EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM "type_TIMESTAMP" WHERE col > date ('2017.11.06 12:34:56.789') ; - QUERY PLAN ---------------------------------------------------------------------------------------------- - Foreign Scan on public."type_TIMESTAMP" - Output: col, b - SQLite query: SELECT `col`, `b` FROM main."type_TIMESTAMP" WHERE ((`col` > '2017-11-06')) -(3 rows) - ---Testcase 37: -SELECT * FROM "type_TIMESTAMP" WHERE col > date ('2017.11.06 12:34:56.789') ; - col | b --------------------------+--------------------- - 2017-11-06 01:03:00 | 2017-11-07 00:00:00 - 2017-11-06 12:34:56.789 | 2017-11-06 00:00:00 -(2 rows) - ---Testcase 38: -EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM "type_TIMESTAMP" WHERE col::text > date ('2017.11.06 12:34:56.789')::text ; - QUERY PLAN ------------------------------------------------------------------------ - Foreign Scan on public."type_TIMESTAMP" - Output: col, b - Filter: (("type_TIMESTAMP".col)::text > ('2017-11-06'::date)::text) - SQLite query: SELECT `col`, `b` FROM main."type_TIMESTAMP" -(4 rows) - ---Testcase 39: -SELECT * FROM "type_TIMESTAMP" WHERE col::text > date ('2017.11.06 12:34:56.789')::text ; - col | b --------------------------+--------------------- - 2017-11-06 12:34:56.789 | 2017-11-06 00:00:00 - 2017-11-06 01:03:00 | 2017-11-07 00:00:00 -(2 rows) - ---Testcase 40: -EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM "type_TIMESTAMP" WHERE col > b - interval '1 hour'; - QUERY PLAN --------------------------------------------------------------------------------- - Foreign Scan on public."type_TIMESTAMP" - Output: col, b - Filter: ("type_TIMESTAMP".col > ("type_TIMESTAMP".b - '@ 1 hour'::interval)) - SQLite query: SELECT `col`, `b` FROM main."type_TIMESTAMP" -(4 rows) - ---Testcase 41: -SELECT * FROM "type_TIMESTAMP" WHERE col > b - interval '1 hour'; - col | b --------------------------+--------------------- - 2017-11-06 12:34:56.789 | 2017-11-06 00:00:00 -(1 row) - ---Testcase 42: -EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM "type_TIMESTAMP" WHERE col > b; - QUERY PLAN ------------------------------------------------------------------------------------- - Foreign Scan on public."type_TIMESTAMP" - Output: col, b - SQLite query: SELECT `col`, `b` FROM main."type_TIMESTAMP" WHERE ((`col` > `b`)) -(3 rows) - ---Testcase 43: -SELECT * FROM "type_TIMESTAMP" WHERE col > b; - col | b --------------------------+--------------------- - 2017-11-06 12:34:56.789 | 2017-11-06 00:00:00 -(1 row) - ---Testcase 48: -INSERT INTO "type_DATE"(col) VALUES ('2021.02.23'); ---Testcase 49: -INSERT INTO "type_DATE"(col) VALUES ('2021/03/08'); ---Testcase 50: -INSERT INTO "type_DATE"(col) VALUES ('9999-12-30'); ---Testcase 58: -SELECT * FROM "type_DATE"; - col ------------- - 2021-02-23 - 2021-03-08 - 9999-12-30 -(3 rows) - ---Testcase 51: -INSERT INTO "type_TIME"(col) VALUES ('01:23:45'); ---Testcase 52: -INSERT INTO "type_TIME"(col) VALUES ('01:23:45.6789'); ---Testcase 59: -SELECT * FROM "type_TIME"; - col ---------------- - 01:23:45 - 01:23:45.6789 -(2 rows) - ---Testcase 60: -EXPLAIN VERBOSE -SELECT c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c17, c18, c19, c2, c21, c22, c23, c24 FROM alltypetest; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - Foreign Scan on public.alltypetest (cost=10.00..57.00 rows=57 width=1400) - Output: c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c17, c18, c19, c2, c21, c22, c23, c24 - SQLite query: SELECT `c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`, `c9`, `c10`, `c11`, `c12`, `c13`, `c14`, `c15`, `c17`, `c18`, `c19`, `c21`, `c22`, `c23`, `c24` FROM main."alltypetest" -(3 rows) - ---Testcase 61: -SELECT c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c17, c18, c19, c2, c21, c22, c23, c24 FROM alltypetest; - c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 | c10 | c11 | c12 | c13 | c14 | c15 | c17 | c18 | c19 | c2 | c21 | c22 | c23 | c24 ---------+-----+-------+--------+---------------+--------------+---------------+------------+----------------------+------------------------+---------------------+------------------+-------------------------------------------+-----------------------------+--------------------------+---------+--------------+-------------+-----+------+-------------+------------+--------------------- - 583647 | 127 | 12767 | 388607 | 2036854775807 | 573709551615 | 2036854775807 | abcdefghij | abcdefghijjhgfjfuafh | Côte dIvoire Fijifoxju | Hôm nay tôi rất vui | I am happy today | 今日はとても幸せです 今日はとても幸せです | The quick brown fox jumps o | ABCDEFGHIJKLMNOPQRSTUVWX | 3.4e+18 | 1.79769e+108 | 1.79769e+88 | 127 | 1234 | 99999.99999 | 9999-12-31 | 9999-12-31 23:59:59 -(1 row) - ---Testcase 53: -CREATE FOREIGN TABLE type_JSON(col JSON OPTIONS (key 'true')) SERVER sqlite_svr OPTIONS (table 'type_TEXT'); ---Testcase 54: -INSERT INTO type_JSON(col) VALUES ('[1, 2, "foo", null]'); ---Testcase 55: -INSERT INTO type_JSON(col) VALUES ('{"bar": "baz", "balance": 7.77, "active": false}'::json); ---Testcase 56 -SELECT * FROM type_JSON; - col --------------------------------------------------- - [1, 2, "foo", null] - {"bar": "baz", "balance": 7.77, "active": false} -(2 rows) - ---Testcase 57 -DELETE FROM type_JSON; --- drop column ---Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; ---Testcase 63: -CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; ---Testcase 64: -ALTER FOREIGN TABLE "type_BOOLEAN" DROP COLUMN colx; ---Testcase 65: -SELECT * FROM "type_BOOLEAN"; -- OK - col ------ - t - f -(2 rows) - --- define INTEGER as TEXT column ---Testcase 67: -ALTER FOREIGN TABLE "type_INTEGER" ALTER COLUMN col TYPE text; ---Testcase 68: -SELECT * FROM "type_INTEGER"; -- OK - col ---------------------- - 9223372036854775807 -(1 row) - --- define INTEGER as bpchar ---Testcase 69: -ALTER FOREIGN TABLE "type_INTEGER" ALTER COLUMN col TYPE char(30); ---Testcase 70: -SELECT * FROM "type_INTEGER"; -- OK - col --------------------------------- - 9223372036854775807 -(1 row) - --- define INTEGER as varchar ---Testcase 71: -ALTER FOREIGN TABLE "type_INTEGER" ALTER COLUMN col TYPE varchar(30); ---Testcase 72: -SELECT * FROM "type_INTEGER"; -- OK - col ---------------------- - 9223372036854775807 -(1 row) - --- define INTEGER as name ---Testcase 73: -ALTER FOREIGN TABLE "type_INTEGER" ALTER COLUMN col TYPE name; ---Testcase 74: -SELECT * FROM "type_INTEGER"; -- OK - col ---------------------- - 9223372036854775807 -(1 row) - --- define INTEGER as json ---Testcase 75: -ALTER FOREIGN TABLE "type_INTEGER" ALTER COLUMN col TYPE json; ---Testcase 76: -SELECT * FROM "type_INTEGER"; -- OK - col ---------------------- - 9223372036854775807 -(1 row) - --- define INTEGER as time ---Testcase 77: -DELETE FROM "type_INTEGER"; ---Testcase 78: -ALTER FOREIGN TABLE "type_INTEGER" ALTER COLUMN col TYPE int; ---Testcase 79: -INSERT INTO "type_INTEGER" VALUES (120506); ---Testcase 80: -ALTER FOREIGN TABLE "type_INTEGER" ALTER COLUMN col TYPE time; ---Testcase 81: -SELECT * FROM "type_INTEGER"; -- OK - col ----------- - 12:05:06 -(1 row) - --- define INTEGER as date ---Testcase 82: -ALTER FOREIGN TABLE "type_INTEGER" ALTER COLUMN col TYPE date; ---Testcase 83: -SELECT * FROM "type_INTEGER"; -- OK - col ------------- - 2012-05-06 -(1 row) - ---Testcase 84: -ALTER FOREIGN TABLE "type_INTEGER" ALTER COLUMN col TYPE int; ---Testcase 85: -INSERT INTO "type_DOUBLE" VALUES (1.3e-5); ---Testcase 86: -SELECT * FROM "type_DOUBLE"; - col ------------- - 3.14159265 - 1.3e-05 -(2 rows) - --- define DOUBLE as TEXT column ---Testcase 87: -ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE text; ---Testcase 88: -SELECT * FROM "type_DOUBLE"; -- OK - col ------------- - 3.14159265 - 1.3e-05 -(2 rows) - --- define DOUBLE as bpchar ---Testcase 89: -ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE char(30); ---Testcase 90: -SELECT * FROM "type_DOUBLE"; -- OK - col --------------------------------- - 3.14159265 - 1.3e-05 -(2 rows) - --- define DOUBLE as varchar ---Testcase 91: -ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE varchar(30); ---Testcase 92: -SELECT * FROM "type_DOUBLE"; -- OK - col ------------- - 3.14159265 - 1.3e-05 -(2 rows) - --- define DOUBLE as name ---Testcase 93: -ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE name; ---Testcase 94: -SELECT * FROM "type_DOUBLE"; -- OK - col ------------- - 3.14159265 - 1.3e-05 -(2 rows) - --- define DOUBLE as json ---Testcase 95: -ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE json; ---Testcase 96: -SELECT * FROM "type_DOUBLE"; -- OK - col ------------- - 3.14159265 - 1.3e-05 -(2 rows) - ---Testcase 97: -DELETE FROM "type_DOUBLE"; ---Testcase 98: -ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; ---Testcase 99: -INSERT INTO "type_DOUBLE" VALUES (120506.12); --- define DOUBLE as time ---Testcase 100: -ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE time; ---Testcase 101: -SELECT * FROM "type_DOUBLE"; -- OK - col -------------- - 12:05:06.12 -(1 row) - ---Testcase 102: -DELETE FROM "type_DOUBLE"; ---Testcase 103: -ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; ---Testcase 104: -INSERT INTO "type_DOUBLE" VALUES (1999.012); --- define DOUBLE as date ---Testcase 105: -ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE date; ---Testcase 106: -SELECT * FROM "type_DOUBLE"; -- OK - col ------------- - 1999-01-12 -(1 row) - ---Testcase 107: -ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; ---Testcase 178: -DROP FOREIGN TABLE "type_BIT"; ---Testcase 179: -CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); ---Testcase 180: -DROP FOREIGN TABLE "type_BIT+"; -ERROR: foreign table "type_BIT+" does not exist ---Testcase 181: -CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 182: -INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); -ERROR: column "b" is of type bit but expression is of type integer -LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); - ^ -HINT: You will need to rewrite or cast the expression. ---Testcase 183: -INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); -ERROR: column "b" is of type bit but expression is of type integer -LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); - ^ -HINT: You will need to rewrite or cast the expression. ---Testcase 184: -INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); -ERROR: bit string length 1 does not match type bit(6) ---Testcase 185: -INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); -ERROR: bit string length 2 does not match type bit(6) ---Testcase 186: -INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); -ERROR: bit string length 3 does not match type bit(6) ---Testcase 187: -INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); ---Testcase 188: -INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); ---Testcase 189: -INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); ---Testcase 190: -INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 191: -INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); -ERROR: column "b" is of type bit but expression is of type integer -LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); - ^ -HINT: You will need to rewrite or cast the expression. ---Testcase 192: -SELECT * FROM "type_BIT+"; - i | b | t | l | bi ----+--------+---------+---+---- - 6 | 110110 | integer | 2 | 54 - 7 | 111001 | integer | 2 | 57 - 8 | 110000 | integer | 2 | 48 - 9 | 100001 | integer | 2 | 33 -(4 rows) - ---Testcase 193: -SELECT * FROM "type_BIT" WHERE b < '110110'; - i | b ----+-------- - 8 | 110000 - 9 | 100001 -(2 rows) - ---Testcase 194: -SELECT * FROM "type_BIT" WHERE b > '110110'; - i | b ----+-------- - 7 | 111001 -(1 row) - ---Testcase 195: -SELECT * FROM "type_BIT" WHERE b = '110110'; - i | b ----+-------- - 6 | 110110 -(1 row) - ---Testcase 196: -DROP FOREIGN TABLE "type_VARBIT"; ---Testcase 197: -CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); ---Testcase 199: -DROP FOREIGN TABLE "type_VARBIT+"; -ERROR: foreign table "type_VARBIT+" does not exist ---Testcase 200: -CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); ---Testcase 201: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); ---Testcase 202: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); ---Testcase 203: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); ---Testcase 204: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); ---Testcase 205: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); ---Testcase 206: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); ---Testcase 207: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); ---Testcase 208: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); ---Testcase 209: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); ---Testcase 210: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); ---Testcase 211: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); ---Testcase 212 -SELECT * FROM "type_VARBIT+"; - i | b | t | l -----+---------------------------------------------------------------+---------+---- - 1 | 1 | integer | 1 - 2 | 10 | integer | 1 - 3 | 11 | integer | 1 - 4 | 100 | integer | 1 - 5 | 101 | integer | 1 - 6 | 110110 | integer | 2 - 7 | 111001 | integer | 2 - 8 | 110000 | integer | 2 - 9 | 100001 | integer | 2 - 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 - 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 -(11 rows) - ---Testcase 213: -SELECT * FROM "type_VARBIT+" WHERE b < '110110'; - i | b | t | l ----+--------+---------+--- - 1 | 1 | integer | 1 - 2 | 10 | integer | 1 - 3 | 11 | integer | 1 - 4 | 100 | integer | 1 - 5 | 101 | integer | 1 - 8 | 110000 | integer | 2 - 9 | 100001 | integer | 2 -(7 rows) - ---Testcase 214: -SELECT * FROM "type_VARBIT+" WHERE b > '110110'; - i | b | t | l -----+---------------------------------------------------------------+---------+---- - 7 | 111001 | integer | 2 - 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 - 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 -(3 rows) - ---Testcase 215: -SELECT * FROM "type_VARBIT+" WHERE b = '110110'; - i | b | t | l ----+--------+---------+--- - 6 | 110110 | integer | 2 -(1 row) - ---Testcase 216: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); ---Testcase 217: -INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 218: 65 b -INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); -ERROR: SQLite FDW dosens't support very long bit/varbit data -HINT: bit length 65, maxmum 64 ---Testcase 219: -SELECT * FROM "type_VARBIT+" WHERE "i" > 10; - i | b | t | l -----+-----------------------------------------------------------------+---------+---- - 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 - 12 | 10010010101100101001010100011111011010110110111101100010101010 | integer | 19 - 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 -(3 rows) - ---Testcase 47: -DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 45 other objects -DETAIL: drop cascades to server sqlite_svr -drop cascades to foreign table department -drop cascades to foreign table employee -drop cascades to foreign table empdata -drop cascades to foreign table numbers -drop cascades to foreign table t -drop cascades to foreign table multiprimary -drop cascades to foreign table columntest -drop cascades to foreign table noprimary -drop cascades to foreign table limittest -drop cascades to foreign table grem1_1 -drop cascades to foreign table grem1_2 -drop cascades to foreign table case_exp -drop cascades to foreign table "type_STRING" -drop cascades to foreign table "type_BYTE" -drop cascades to foreign table "type_SINT" -drop cascades to foreign table "type_BINT" -drop cascades to foreign table "type_INTEGER" -drop cascades to foreign table "type_FLOAT" -drop cascades to foreign table "type_DOUBLE" -drop cascades to foreign table "type_TIMESTAMP" -drop cascades to foreign table "type_BLOB" -drop cascades to foreign table "type_DATE" -drop cascades to foreign table "type_TIME" -drop cascades to foreign table notype -drop cascades to foreign table typetest -drop cascades to foreign table "type_TEXT" -drop cascades to foreign table alltypetest -drop cascades to foreign table shorty -drop cascades to foreign table "A a" -drop cascades to foreign table fts_table -drop cascades to foreign table fts_table_data -drop cascades to foreign table fts_table_idx -drop cascades to foreign table fts_table_content -drop cascades to foreign table fts_table_docsize -drop cascades to foreign table fts_table_config -drop cascades to foreign table "RO_RW_test" -drop cascades to foreign table "Unicode data" -drop cascades to foreign table type_json -drop cascades to foreign table "type_BOOLEAN" -drop cascades to foreign table "type_BIT" -drop cascades to foreign table "type_BIT+" -drop cascades to foreign table "type_VARBIT" -drop cascades to foreign table "type_VARBIT+" -drop cascades to server sqlite2 From 918fe59b57eacca9fb7da85b6c94b29146274b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Fri, 27 Oct 2023 15:39:41 +0300 Subject: [PATCH 03/14] Fix warnings and tests after resolving conflicts --- expected/12.15/type.out | 11 +-- expected/13.11/type.out | 2 +- expected/14.8/type.out | 2 +- expected/15.3/type.out | 2 +- expected/16.0/type.out | 176 +++++++++++++++++++++++++++++++++++++++- sqlite_fdw.c | 10 +-- 6 files changed, 187 insertions(+), 16 deletions(-) diff --git a/expected/12.15/type.out b/expected/12.15/type.out index 8b5e106f..e739458e 100644 --- a/expected/12.15/type.out +++ b/expected/12.15/type.out @@ -1072,7 +1072,7 @@ SELECT * FROM "type_BIT" WHERE b = '110110'; 6 | 110110 (1 row) ---Testcase 217 +--Testcase 217: DROP FOREIGN TABLE "type_VARBIT"; --Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); @@ -1164,11 +1164,11 @@ SELECT * FROM "type_VARBIT+" WHERE "i" > 10; 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 12 | 10010010101100101001010100011111011010110110111101100010101010 | integer | 19 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 -(3 rows) +(3 rows) --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 45 other objects +NOTICE: drop cascades to 48 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -1193,6 +1193,7 @@ drop cascades to foreign table "type_TIMESTAMP" drop cascades to foreign table "type_BLOB" drop cascades to foreign table "type_DATE" drop cascades to foreign table "type_TIME" +drop cascades to foreign table "BitT" drop cascades to foreign table notype drop cascades to foreign table typetest drop cascades to foreign table "type_TEXT" @@ -1209,10 +1210,10 @@ drop cascades to foreign table "RO_RW_test" drop cascades to foreign table "Unicode data" drop cascades to foreign table type_json drop cascades to foreign table "type_BOOLEAN" +drop cascades to foreign table "type_UUID" +drop cascades to foreign table "type_UUID+" drop cascades to foreign table "type_BIT" drop cascades to foreign table "type_BIT+" drop cascades to foreign table "type_VARBIT" drop cascades to foreign table "type_VARBIT+" -drop cascades to foreign table "type_UUID" -drop cascades to foreign table "type_UUID+" drop cascades to server sqlite2 diff --git a/expected/13.11/type.out b/expected/13.11/type.out index a747c5e5..88c41347 100644 --- a/expected/13.11/type.out +++ b/expected/13.11/type.out @@ -671,7 +671,7 @@ SELECT * FROM "type_VARBIT+" WHERE "i" > 10; --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 45 other objects +NOTICE: drop cascades to 47 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee diff --git a/expected/14.8/type.out b/expected/14.8/type.out index a747c5e5..88c41347 100644 --- a/expected/14.8/type.out +++ b/expected/14.8/type.out @@ -671,7 +671,7 @@ SELECT * FROM "type_VARBIT+" WHERE "i" > 10; --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 45 other objects +NOTICE: drop cascades to 47 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee diff --git a/expected/15.3/type.out b/expected/15.3/type.out index a747c5e5..88c41347 100644 --- a/expected/15.3/type.out +++ b/expected/15.3/type.out @@ -671,7 +671,7 @@ SELECT * FROM "type_VARBIT+" WHERE "i" > 10; --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 45 other objects +NOTICE: drop cascades to 47 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee diff --git a/expected/16.0/type.out b/expected/16.0/type.out index ab915e55..e524cc90 100644 --- a/expected/16.0/type.out +++ b/expected/16.0/type.out @@ -997,9 +997,179 @@ SELECT * FROM "type_UUID+" WHERE "u" IS NOT NULL; SQLite query: SELECT `i`, coalesce(sqlite_fdw_uuid_blob(`u`),`u`), `t`, `l` FROM main."type_UUID+" WHERE ((coalesce(sqlite_fdw_uuid_blob(`u`),`u`) IS NOT NULL)) (3 rows) +--Testcase 199: +DROP FOREIGN TABLE "type_BIT"; +--Testcase 200: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 201: +DROP FOREIGN TABLE "type_BIT+"; +ERROR: foreign table "type_BIT+" does not exist +--Testcase 202: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 203: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 204: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 205: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +ERROR: bit string length 1 does not match type bit(6) +--Testcase 206: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +ERROR: bit string length 2 does not match type bit(6) +--Testcase 207: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +ERROR: bit string length 3 does not match type bit(6) +--Testcase 208: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 209: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 210: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 211: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 212: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 213: +SELECT * FROM "type_BIT+"; + i | b | t | l | bi +---+--------+---------+---+---- + 6 | 110110 | integer | 2 | 54 + 7 | 111001 | integer | 2 | 57 + 8 | 110000 | integer | 2 | 48 + 9 | 100001 | integer | 2 | 33 +(4 rows) + +--Testcase 214: +SELECT * FROM "type_BIT" WHERE b < '110110'; + i | b +---+-------- + 8 | 110000 + 9 | 100001 +(2 rows) + +--Testcase 215: +SELECT * FROM "type_BIT" WHERE b > '110110'; + i | b +---+-------- + 7 | 111001 +(1 row) + +--Testcase 216: +SELECT * FROM "type_BIT" WHERE b = '110110'; + i | b +---+-------- + 6 | 110110 +(1 row) + +--Testcase 217: +DROP FOREIGN TABLE "type_VARBIT"; +--Testcase 218: +CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); +--Testcase 219: +DROP FOREIGN TABLE "type_VARBIT+"; +ERROR: foreign table "type_VARBIT+" does not exist +--Testcase 220: +CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); +--Testcase 221: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); +--Testcase 222: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); +--Testcase 223: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); +--Testcase 224: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); +--Testcase 225: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); +--Testcase 226: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); +--Testcase 227: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); +--Testcase 228: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); +--Testcase 229: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); +--Testcase 230: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); +--Testcase 231: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); +--Testcase 232 +SELECT * FROM "type_VARBIT+"; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 6 | 110110 | integer | 2 + 7 | 111001 | integer | 2 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(11 rows) + +--Testcase 233: +SELECT * FROM "type_VARBIT+" WHERE b < '110110'; + i | b | t | l +---+--------+---------+--- + 1 | 1 | integer | 1 + 2 | 10 | integer | 1 + 3 | 11 | integer | 1 + 4 | 100 | integer | 1 + 5 | 101 | integer | 1 + 8 | 110000 | integer | 2 + 9 | 100001 | integer | 2 +(7 rows) + +--Testcase 234: +SELECT * FROM "type_VARBIT+" WHERE b > '110110'; + i | b | t | l +----+---------------------------------------------------------------+---------+---- + 7 | 111001 | integer | 2 + 10 | 100100101011001010010101000111110110101101101111011000101010 | integer | 18 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 +(3 rows) + +--Testcase 235: +SELECT * FROM "type_VARBIT+" WHERE b = '110110'; + i | b | t | l +---+--------+---------+--- + 6 | 110110 | integer | 2 +(1 row) + +--Testcase 236: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); +--Testcase 237: +INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); +--Testcase 238: 65 b +INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); +ERROR: SQLite FDW dosens't support very long bit/varbit data +HINT: bit length 65, maxmum 64 +--Testcase 239: +SELECT * FROM "type_VARBIT+" WHERE "i" > 10; + i | b | t | l +----+-----------------------------------------------------------------+---------+---- + 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | integer | 19 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 44 other objects +NOTICE: drop cascades to 48 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -1043,4 +1213,8 @@ drop cascades to foreign table type_json drop cascades to foreign table "type_BOOLEAN" drop cascades to foreign table "type_UUID" drop cascades to foreign table "type_UUID+" +drop cascades to foreign table "type_BIT" +drop cascades to foreign table "type_BIT+" +drop cascades to foreign table "type_VARBIT" +drop cascades to foreign table "type_VARBIT+" drop cascades to server sqlite2 diff --git a/sqlite_fdw.c b/sqlite_fdw.c index 9cb35f3e..2b12cc55 100644 --- a/sqlite_fdw.c +++ b/sqlite_fdw.c @@ -1114,8 +1114,6 @@ sqliteGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid ParamPathInfo *param_info = (ParamPathInfo *) lfirst(lc); double rows; int width; - Cost startup_cost; - Cost total_cost; /* Get a cost estimate from the remote */ sqlite_estimate_path_cost_size(root, baserel, @@ -3145,8 +3143,8 @@ sqliteImportForeignSchema(ImportForeignSchemaStmt *stmt, bool not_null; char *default_val; int primary_key; - int rc = sqlite3_step(pragma_stmt); - + + rc = sqlite3_step(pragma_stmt); if (rc == SQLITE_DONE) break; else if (rc != SQLITE_ROW) @@ -3758,7 +3756,7 @@ sqlite_foreign_grouping_ok(PlannerInfo *root, RelOptInfo *grouped_rel) PathTarget *grouping_target; SqliteFdwRelationInfo *fpinfo = (SqliteFdwRelationInfo *) grouped_rel->fdw_private; SqliteFdwRelationInfo *ofpinfo; - List *aggvars; + List *aggvars = NIL; ListCell *lc; int i; List *tlist = NIL; @@ -3934,8 +3932,6 @@ sqlite_foreign_grouping_ok(PlannerInfo *root, RelOptInfo *grouped_rel) */ if (fpinfo->local_conds) { - List *aggvars = NIL; - foreach(lc, fpinfo->local_conds) { RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc); From 77ba282682e6c158be8fd04a6b956e234554b7be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Thu, 2 Nov 2023 17:00:25 +0300 Subject: [PATCH 04/14] Fix code style and tests --- README.md | 10 ++++++---- deparse.c | 2 +- expected/12.15/type.out | 16 ++++++++-------- expected/13.11/type.out | 14 +++++++------- expected/14.8/type.out | 14 +++++++------- expected/15.3/type.out | 14 +++++++------- expected/16.0/type.out | 16 ++++++++-------- sql/12.15/type.sql | 12 ++++++------ sql/13.11/type.sql | 10 +++++----- sql/14.8/type.sql | 10 +++++----- sql/15.3/type.sql | 10 +++++----- sql/16.0/type.sql | 12 ++++++------ sqlite_fdw.h | 4 ++-- sqlite_query.c | 28 ++++++++++++++++++---------- 14 files changed, 91 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index 6d88c5d3..43eb8a49 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ Usage ### Datatypes **WARNING! The table above represents roadmap**, work still in progress. Untill it will be ended please refer real behaviour in non-obvious cases, where there is no ✔ or ∅ mark. -This table represents `sqlite_fdw` behaviour if in PostgreSQL foreign table column some [affinity](https://www.sqlite.org/datatype3.html) of SQLite data is detected. +This table represents `sqlite_fdw` behaviour if in PostgreSQL foreign table column some [affinity](https://www.sqlite.org/datatype3.html) of SQLite data is detected. Some details about data values support see in [limitations](#limitations). * **∅** - no support (runtime error) * **V** - transparent transformation @@ -133,7 +133,7 @@ SQLite `NULL` affinity always can be transparent converted for a nullable column | PostgreSQL | SQLite
INT | SQLite
REAL | SQLite
BLOB | SQLite
TEXT | SQLite
TEXT but
empty|SQLite
nearest
affinity| |-------------:|:------------:|:------------:|:------------:|:------------:|:------------:|-------------:| | bool | V | ? | T | - | ∅ | INT | -| bit(n) | V | ∅ | V | ? | ∅ | INT | +| bit(n) | V n<=64 | ∅ | V | ? | ∅ | INT | | bytea | b | b | ✔ | - | ? | BLOB | | date | V | V | T | V+ | `NULL` | ? | | float4 | V+ | ✔ | T | - | `NULL` | REAL | @@ -150,8 +150,7 @@ SQLite `NULL` affinity always can be transparent converted for a nullable column |timestamp + tz| V | V | T | V+ | `NULL` | ? | | uuid | ∅ | ∅ |V+
(only
16 bytes)| V+ | ∅ | TEXT, BLOB | | varchar | ? | ? | T | ✔ | V | TEXT | - - +| varbit(n) | V n<=64 | ∅ | V | ? | ∅ | INT | ### CREATE SERVER options @@ -523,6 +522,9 @@ Limitations - Expected affinity of UUID value in SQLite table determined by `column_type` option of the column for `INSERT` and `UPDATE` commands. +### bit and varbit support +- `sqlite_fdw` PostgreSQL `bit`/`varbit` values support based on `int` SQLite data affinity, because there is no per bit operations for SQLite `blob` affinity data. Maximum SQLite `int` affinity value is 8 bytes length, hence maximum `bit`/`varbit` values length is 64. + Tests ----- Test directory have structure as following: diff --git a/deparse.c b/deparse.c index 33f90177..85f1ba68 100644 --- a/deparse.c +++ b/deparse.c @@ -2629,7 +2629,7 @@ sqlite_deparse_const(Const *node, deparse_expr_cxt *context, int showtype) errmsg("SQLite FDW dosens't support very long bit/varbit data"), errhint("bit length %ld, maxmum %ld", strlen(extval), SQLITE_FDW_BIT_DATATYPE_BUF_SIZE - 1))); } - appendStringInfo(buf, "%lld", binstr2int(extval)); + appendStringInfo(buf, "%lld", binstr2int64(extval)); } break; case BOOLOID: diff --git a/expected/12.15/type.out b/expected/12.15/type.out index e739458e..29085711 100644 --- a/expected/12.15/type.out +++ b/expected/12.15/type.out @@ -309,7 +309,7 @@ SELECT * FROM type_JSON; DELETE FROM type_JSON; -- drop column --Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; +DROP FOREIGN TABLE IF EXISTS "type_BOOLEAN"; --Testcase 63: CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; --Testcase 64: @@ -501,7 +501,7 @@ SELECT * FROM "type_DOUBLE"; -- OK ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; --Testcase 108: -DROP FOREIGN TABLE "type_UUID"; +DROP FOREIGN TABLE IF EXISTS "type_UUID"; --Testcase 109: CREATE FOREIGN TABLE "type_UUID"( "i" int OPTIONS (key 'true'), "u" uuid) SERVER sqlite_svr OPTIONS (table 'type_UUID'); --Testcase 110: @@ -997,12 +997,12 @@ SELECT * FROM "type_UUID+" WHERE "u" IS NOT NULL; (3 rows) --Testcase 199: -DROP FOREIGN TABLE "type_BIT"; +DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 200: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); --Testcase 201: -DROP FOREIGN TABLE "type_BIT+"; -ERROR: foreign table "type_BIT+" does not exist +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; +NOTICE: foreign table "type_BIT+" does not exist, skipping --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); --Testcase 203: @@ -1073,12 +1073,12 @@ SELECT * FROM "type_BIT" WHERE b = '110110'; (1 row) --Testcase 217: -DROP FOREIGN TABLE "type_VARBIT"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; --Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); --Testcase 219: -DROP FOREIGN TABLE "type_VARBIT+"; -ERROR: foreign table "type_VARBIT+" does not exist +DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; +NOTICE: foreign table "type_VARBIT+" does not exist, skipping --Testcase 220: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); --Testcase 221: diff --git a/expected/13.11/type.out b/expected/13.11/type.out index 88c41347..0e28fe24 100644 --- a/expected/13.11/type.out +++ b/expected/13.11/type.out @@ -309,7 +309,7 @@ SELECT * FROM type_JSON; DELETE FROM type_JSON; -- drop column --Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; +DROP FOREIGN TABLE IF EXISTS "type_BOOLEAN"; --Testcase 63: CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; --Testcase 64: @@ -500,12 +500,12 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; --Testcase 178: -DROP FOREIGN TABLE "type_BIT"; +DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 179: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); --Testcase 180: -DROP FOREIGN TABLE "type_BIT+"; -ERROR: foreign table "type_BIT+" does not exist +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; +NOTICE: foreign table "type_BIT+" does not exist, skipping --Testcase 181: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); --Testcase 182: @@ -576,12 +576,12 @@ SELECT * FROM "type_BIT" WHERE b = '110110'; (1 row) --Testcase 196: -DROP FOREIGN TABLE "type_VARBIT"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; --Testcase 197: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); --Testcase 199: -DROP FOREIGN TABLE "type_VARBIT+"; -ERROR: foreign table "type_VARBIT+" does not exist +DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; +NOTICE: foreign table "type_VARBIT+" does not exist, skipping --Testcase 200: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); --Testcase 201: diff --git a/expected/14.8/type.out b/expected/14.8/type.out index 88c41347..0e28fe24 100644 --- a/expected/14.8/type.out +++ b/expected/14.8/type.out @@ -309,7 +309,7 @@ SELECT * FROM type_JSON; DELETE FROM type_JSON; -- drop column --Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; +DROP FOREIGN TABLE IF EXISTS "type_BOOLEAN"; --Testcase 63: CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; --Testcase 64: @@ -500,12 +500,12 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; --Testcase 178: -DROP FOREIGN TABLE "type_BIT"; +DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 179: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); --Testcase 180: -DROP FOREIGN TABLE "type_BIT+"; -ERROR: foreign table "type_BIT+" does not exist +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; +NOTICE: foreign table "type_BIT+" does not exist, skipping --Testcase 181: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); --Testcase 182: @@ -576,12 +576,12 @@ SELECT * FROM "type_BIT" WHERE b = '110110'; (1 row) --Testcase 196: -DROP FOREIGN TABLE "type_VARBIT"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; --Testcase 197: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); --Testcase 199: -DROP FOREIGN TABLE "type_VARBIT+"; -ERROR: foreign table "type_VARBIT+" does not exist +DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; +NOTICE: foreign table "type_VARBIT+" does not exist, skipping --Testcase 200: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); --Testcase 201: diff --git a/expected/15.3/type.out b/expected/15.3/type.out index 88c41347..0e28fe24 100644 --- a/expected/15.3/type.out +++ b/expected/15.3/type.out @@ -309,7 +309,7 @@ SELECT * FROM type_JSON; DELETE FROM type_JSON; -- drop column --Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; +DROP FOREIGN TABLE IF EXISTS "type_BOOLEAN"; --Testcase 63: CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; --Testcase 64: @@ -500,12 +500,12 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; --Testcase 178: -DROP FOREIGN TABLE "type_BIT"; +DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 179: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); --Testcase 180: -DROP FOREIGN TABLE "type_BIT+"; -ERROR: foreign table "type_BIT+" does not exist +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; +NOTICE: foreign table "type_BIT+" does not exist, skipping --Testcase 181: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); --Testcase 182: @@ -576,12 +576,12 @@ SELECT * FROM "type_BIT" WHERE b = '110110'; (1 row) --Testcase 196: -DROP FOREIGN TABLE "type_VARBIT"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; --Testcase 197: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); --Testcase 199: -DROP FOREIGN TABLE "type_VARBIT+"; -ERROR: foreign table "type_VARBIT+" does not exist +DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; +NOTICE: foreign table "type_VARBIT+" does not exist, skipping --Testcase 200: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); --Testcase 201: diff --git a/expected/16.0/type.out b/expected/16.0/type.out index e524cc90..6587d5b1 100644 --- a/expected/16.0/type.out +++ b/expected/16.0/type.out @@ -309,7 +309,7 @@ SELECT * FROM type_JSON; DELETE FROM type_JSON; -- drop column --Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; +DROP FOREIGN TABLE IF EXISTS "type_BOOLEAN"; --Testcase 63: CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; --Testcase 64: @@ -500,7 +500,7 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; --Testcase 108: -DROP FOREIGN TABLE "type_UUID"; +DROP FOREIGN TABLE IF EXISTS "type_UUID"; --Testcase 109: CREATE FOREIGN TABLE "type_UUID"( "i" int OPTIONS (key 'true'), "u" uuid) SERVER sqlite_svr OPTIONS (table 'type_UUID'); --Testcase 110: @@ -998,12 +998,12 @@ SELECT * FROM "type_UUID+" WHERE "u" IS NOT NULL; (3 rows) --Testcase 199: -DROP FOREIGN TABLE "type_BIT"; +DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 200: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); --Testcase 201: -DROP FOREIGN TABLE "type_BIT+"; -ERROR: foreign table "type_BIT+" does not exist +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; +NOTICE: foreign table "type_BIT+" does not exist, skipping --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); --Testcase 203: @@ -1074,12 +1074,12 @@ SELECT * FROM "type_BIT" WHERE b = '110110'; (1 row) --Testcase 217: -DROP FOREIGN TABLE "type_VARBIT"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; --Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); --Testcase 219: -DROP FOREIGN TABLE "type_VARBIT+"; -ERROR: foreign table "type_VARBIT+" does not exist +DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; +NOTICE: foreign table "type_VARBIT+" does not exist, skipping --Testcase 220: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); --Testcase 221: diff --git a/sql/12.15/type.sql b/sql/12.15/type.sql index 08d87720..e4dcc86f 100644 --- a/sql/12.15/type.sql +++ b/sql/12.15/type.sql @@ -146,7 +146,7 @@ DELETE FROM type_JSON; -- drop column --Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; +DROP FOREIGN TABLE IF EXISTS "type_BOOLEAN"; --Testcase 63: CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; --Testcase 64: @@ -267,7 +267,7 @@ SELECT * FROM "type_DOUBLE"; -- OK ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; --Testcase 108: -DROP FOREIGN TABLE "type_UUID"; +DROP FOREIGN TABLE IF EXISTS "type_UUID"; --Testcase 109: CREATE FOREIGN TABLE "type_UUID"( "i" int OPTIONS (key 'true'), "u" uuid) SERVER sqlite_svr OPTIONS (table 'type_UUID'); --Testcase 110: @@ -469,11 +469,11 @@ EXPLAIN VERBOSE SELECT * FROM "type_UUID+" WHERE "u" IS NOT NULL; --Testcase 199: -DROP FOREIGN TABLE "type_BIT"; +DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 200: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); --Testcase 201: -DROP FOREIGN TABLE "type_BIT+"; +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); --Testcase 203: @@ -506,11 +506,11 @@ SELECT * FROM "type_BIT" WHERE b > '110110'; SELECT * FROM "type_BIT" WHERE b = '110110'; --Testcase 217: -DROP FOREIGN TABLE "type_VARBIT"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; --Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); --Testcase 219: -DROP FOREIGN TABLE "type_VARBIT+"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; --Testcase 220: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); --Testcase 221: diff --git a/sql/13.11/type.sql b/sql/13.11/type.sql index 41c2a94e..196e8c4a 100644 --- a/sql/13.11/type.sql +++ b/sql/13.11/type.sql @@ -146,7 +146,7 @@ DELETE FROM type_JSON; -- drop column --Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; +DROP FOREIGN TABLE IF EXISTS "type_BOOLEAN"; --Testcase 63: CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; --Testcase 64: @@ -267,11 +267,11 @@ SELECT * FROM "type_DOUBLE"; -- OK ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; --Testcase 178: -DROP FOREIGN TABLE "type_BIT"; +DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 179: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); --Testcase 180: -DROP FOREIGN TABLE "type_BIT+"; +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; --Testcase 181: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); --Testcase 182: @@ -304,11 +304,11 @@ SELECT * FROM "type_BIT" WHERE b > '110110'; SELECT * FROM "type_BIT" WHERE b = '110110'; --Testcase 196: -DROP FOREIGN TABLE "type_VARBIT"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; --Testcase 197: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); --Testcase 199: -DROP FOREIGN TABLE "type_VARBIT+"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; --Testcase 200: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); --Testcase 201: diff --git a/sql/14.8/type.sql b/sql/14.8/type.sql index 41c2a94e..196e8c4a 100644 --- a/sql/14.8/type.sql +++ b/sql/14.8/type.sql @@ -146,7 +146,7 @@ DELETE FROM type_JSON; -- drop column --Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; +DROP FOREIGN TABLE IF EXISTS "type_BOOLEAN"; --Testcase 63: CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; --Testcase 64: @@ -267,11 +267,11 @@ SELECT * FROM "type_DOUBLE"; -- OK ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; --Testcase 178: -DROP FOREIGN TABLE "type_BIT"; +DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 179: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); --Testcase 180: -DROP FOREIGN TABLE "type_BIT+"; +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; --Testcase 181: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); --Testcase 182: @@ -304,11 +304,11 @@ SELECT * FROM "type_BIT" WHERE b > '110110'; SELECT * FROM "type_BIT" WHERE b = '110110'; --Testcase 196: -DROP FOREIGN TABLE "type_VARBIT"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; --Testcase 197: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); --Testcase 199: -DROP FOREIGN TABLE "type_VARBIT+"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; --Testcase 200: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); --Testcase 201: diff --git a/sql/15.3/type.sql b/sql/15.3/type.sql index 41c2a94e..196e8c4a 100644 --- a/sql/15.3/type.sql +++ b/sql/15.3/type.sql @@ -146,7 +146,7 @@ DELETE FROM type_JSON; -- drop column --Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; +DROP FOREIGN TABLE IF EXISTS "type_BOOLEAN"; --Testcase 63: CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; --Testcase 64: @@ -267,11 +267,11 @@ SELECT * FROM "type_DOUBLE"; -- OK ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; --Testcase 178: -DROP FOREIGN TABLE "type_BIT"; +DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 179: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); --Testcase 180: -DROP FOREIGN TABLE "type_BIT+"; +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; --Testcase 181: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); --Testcase 182: @@ -304,11 +304,11 @@ SELECT * FROM "type_BIT" WHERE b > '110110'; SELECT * FROM "type_BIT" WHERE b = '110110'; --Testcase 196: -DROP FOREIGN TABLE "type_VARBIT"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; --Testcase 197: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); --Testcase 199: -DROP FOREIGN TABLE "type_VARBIT+"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; --Testcase 200: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); --Testcase 201: diff --git a/sql/16.0/type.sql b/sql/16.0/type.sql index 08d87720..e4dcc86f 100644 --- a/sql/16.0/type.sql +++ b/sql/16.0/type.sql @@ -146,7 +146,7 @@ DELETE FROM type_JSON; -- drop column --Testcase 62: -DROP FOREIGN TABLE "type_BOOLEAN"; +DROP FOREIGN TABLE IF EXISTS "type_BOOLEAN"; --Testcase 63: CREATE FOREIGN TABLE "type_BOOLEAN" (colx int, col boolean) SERVER sqlite_svr; --Testcase 64: @@ -267,7 +267,7 @@ SELECT * FROM "type_DOUBLE"; -- OK ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; --Testcase 108: -DROP FOREIGN TABLE "type_UUID"; +DROP FOREIGN TABLE IF EXISTS "type_UUID"; --Testcase 109: CREATE FOREIGN TABLE "type_UUID"( "i" int OPTIONS (key 'true'), "u" uuid) SERVER sqlite_svr OPTIONS (table 'type_UUID'); --Testcase 110: @@ -469,11 +469,11 @@ EXPLAIN VERBOSE SELECT * FROM "type_UUID+" WHERE "u" IS NOT NULL; --Testcase 199: -DROP FOREIGN TABLE "type_BIT"; +DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 200: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); --Testcase 201: -DROP FOREIGN TABLE "type_BIT+"; +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); --Testcase 203: @@ -506,11 +506,11 @@ SELECT * FROM "type_BIT" WHERE b > '110110'; SELECT * FROM "type_BIT" WHERE b = '110110'; --Testcase 217: -DROP FOREIGN TABLE "type_VARBIT"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; --Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); --Testcase 219: -DROP FOREIGN TABLE "type_VARBIT+"; +DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; --Testcase 220: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); --Testcase 221: diff --git a/sqlite_fdw.h b/sqlite_fdw.h index 924fc3e3..5bf02e37 100644 --- a/sqlite_fdw.h +++ b/sqlite_fdw.h @@ -43,7 +43,7 @@ #define CR_NO_ERROR 0 -#define SQLITE_FDW_BIT_DATATYPE_BUF_SIZE sizeof(sqlite3_int64)* CHAR_BIT + 1 +#define SQLITE_FDW_BIT_DATATYPE_BUF_SIZE sizeof(sqlite3_int64) * CHAR_BIT + 1 #if (PG_VERSION_NUM < 120000) #define table_close(rel, lock) heap_close(rel, lock) @@ -383,6 +383,6 @@ extern void sqlite_do_sql_command(sqlite3 * conn, const char *sql, int level, Li int sqlite_fdw_data_norm_functs_init(sqlite3* db); /* sqlite_query.c haders */ -sqlite3_int64 binstr2int(const char *s); +sqlite3_int64 binstr2int64(const char *s); #endif /* SQLITE_FDW_H */ diff --git a/sqlite_query.c b/sqlite_query.c index 8ee35c47..2e02abcc 100644 --- a/sqlite_query.c +++ b/sqlite_query.c @@ -40,7 +40,7 @@ int static char * sqlite_text_value_to_pg_db_encoding(sqlite3_stmt * stmt, int stmt_colid); char * - int2binstr(sqlite3_int64 num, char *s, size_t len); + int642binstr(sqlite3_int64 num, char *s, size_t len); /* * convert_sqlite_to_pg: Convert Sqlite data into PostgreSQL's compatible data types @@ -376,7 +376,7 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_stmt * stmt, int stmt_colid, { char * buffer = palloc0(SQLITE_FDW_BIT_DATATYPE_BUF_SIZE); sqlite3_int64 sqlti = sqlite3_column_int64(stmt, stmt_colid); - buffer = int2binstr(sqlti, buffer, SQLITE_FDW_BIT_DATATYPE_BUF_SIZE); + buffer = int642binstr(sqlti, buffer, SQLITE_FDW_BIT_DATATYPE_BUF_SIZE); valstr = buffer; elog(DEBUG4, "sqlite_fdw : BIT buf l=%ld v = %s", SQLITE_FDW_BIT_DATATYPE_BUF_SIZE, buffer); break; @@ -604,7 +604,7 @@ sqlite_bind_sql_var(Form_pg_attribute att, int attnum, Datum value, sqlite3_stmt errmsg("SQLite FDW dosens't support very long bit/varbit data"), errhint("bit length %ld, maxmum %ld", strlen(outputString), SQLITE_FDW_BIT_DATATYPE_BUF_SIZE - 1))); } - dat = binstr2int(outputString); + dat = binstr2int64(outputString); ret = sqlite3_bind_int64(stmt, attnum, dat); break; } @@ -725,9 +725,10 @@ static char * sqlite_text_value_to_pg_db_encoding(sqlite3_stmt * stmt, int stmt_ } /* - * Converts int64 frrom SQLite to PostgreSQL string from 0 and 1 only + * Converts int64 from SQLite to PostgreSQL string from 0 and 1 only + * s must be allocated with length not less than len + 1 bytes */ -char *int2binstr(sqlite3_int64 num, char *s, size_t len) +char *int642binstr(sqlite3_int64 num, char *s, size_t len) { s[--len] = '\0'; do @@ -739,15 +740,22 @@ char *int2binstr(sqlite3_int64 num, char *s, size_t len) /* * Converts PostgreSQL string from 0 and 1 only to int64 for SQLite */ -sqlite3_int64 binstr2int(const char *s) +sqlite3_int64 binstr2int64(const char *s) { + char *bs = s; sqlite3_int64 rc; - for (rc = 0; '\0' != *s; s++) { - if ('1' == *s) { + for (rc = 0; '\0' != *bs; bs++) + { + if ('1' == *bs) + { rc = (rc * 2) + 1; - } else if ('0' == *s) { + } + else if ('0' == *bs) + { rc *= 2; - } else { + } + else + { errno = EINVAL; return -1; } From ff232874f174af1e29c12d30285bbf3ab512e7c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Thu, 2 Nov 2023 17:38:13 +0300 Subject: [PATCH 05/14] Fix variable ini blocks --- sqlite_query.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sqlite_query.c b/sqlite_query.c index 2e02abcc..ba089bd9 100644 --- a/sqlite_query.c +++ b/sqlite_query.c @@ -149,6 +149,7 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_stmt * stmt, int stmt_colid, case SQLITE_FLOAT: /* TODO: This code is untill mod() pushdowning fix here*/ { int value = sqlite3_column_int(stmt, stmt_colid); + elog(DEBUG2, "sqlite_fdw : real aff. was readed for pg int32"); return (struct NullableDatum) {Int32GetDatum(value), false}; } @@ -181,9 +182,10 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_stmt * stmt, int stmt_colid, case SQLITE_FLOAT: /* TODO: This code is untill mod() pushdowning fix here*/ { int value = sqlite3_column_int(stmt, stmt_colid); + elog(DEBUG2, "sqlite_fdw : real aff. was readed for pg int64"); return (struct NullableDatum) {Int32GetDatum(value), false}; - } + } case SQLITE_BLOB: default: { @@ -306,6 +308,7 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_stmt * stmt, int stmt_colid, case SQLITE_FLOAT: /* <-- proper and recommended SQLite affinity of value for pgtyp */ { double value = sqlite3_column_double(stmt, stmt_colid); + valstr = DatumGetCString(DirectFunctionCall1(float8out, Float8GetDatum((float8) value))); break; /* !!! use valstr later! */ } @@ -349,6 +352,7 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_stmt * stmt, int stmt_colid, { const unsigned char * sqlite_blob = 0; pg_uuid_t *retval = (pg_uuid_t *) palloc0(sizeof(pg_uuid_t)); + sqlite_blob = sqlite3_column_blob(stmt, stmt_colid); memcpy(retval->data, sqlite_blob, UUID_LEN); return (struct NullableDatum){UUIDPGetDatum(retval), false}; @@ -374,8 +378,9 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_stmt * stmt, int stmt_colid, case VARBITOID: case BITOID: { - char * buffer = palloc0(SQLITE_FDW_BIT_DATATYPE_BUF_SIZE); - sqlite3_int64 sqlti = sqlite3_column_int64(stmt, stmt_colid); + char * buffer = (char *) palloc0(SQLITE_FDW_BIT_DATATYPE_BUF_SIZE); + + sqlite3_int64 sqlti = sqlite3_column_int64(stmt, stmt_colid); buffer = int642binstr(sqlti, buffer, SQLITE_FDW_BIT_DATATYPE_BUF_SIZE); valstr = buffer; elog(DEBUG4, "sqlite_fdw : BIT buf l=%ld v = %s", SQLITE_FDW_BIT_DATATYPE_BUF_SIZE, buffer); @@ -569,13 +574,13 @@ sqlite_bind_sql_var(Form_pg_attribute att, int attnum, Datum value, sqlite3_stmt if (uuid_as_blob) { - unsigned char *dat = palloc0(UUID_LEN); + unsigned char *dat = palloc0(UUID_LEN); pg_uuid_t* pg_uuid = DatumGetUUIDP(value); elog(DEBUG2, "sqlite_fdw : bind uuid as blob"); - memcpy(dat, pg_uuid->data, UUID_LEN); + memcpy(dat, pg_uuid->data, UUID_LEN); ret = sqlite3_bind_blob(stmt, attnum, dat, UUID_LEN, SQLITE_TRANSIENT); } - else + else { /* uuid as text */ char *outputString = NULL; From 4f5de2578112027c4d683e498f6f9c2d2e8c6be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Thu, 2 Nov 2023 18:03:21 +0300 Subject: [PATCH 06/14] Fix rc usage --- sqlite_query.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sqlite_query.c b/sqlite_query.c index ba089bd9..c8623f70 100644 --- a/sqlite_query.c +++ b/sqlite_query.c @@ -747,9 +747,10 @@ char *int642binstr(sqlite3_int64 num, char *s, size_t len) */ sqlite3_int64 binstr2int64(const char *s) { + sqlite3_int64 rc = 0; char *bs = s; - sqlite3_int64 rc; - for (rc = 0; '\0' != *bs; bs++) + + for (; '\0' != *bs; bs++) { if ('1' == *bs) { From 9ec823394aa94b51c14a0e7f446e33ffa1a95b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Fri, 3 Nov 2023 15:37:41 +0300 Subject: [PATCH 07/14] Expand tests, fix code style --- README.md | 10 + expected/12.15/type.out | 328 ++++++++++++++++++++++++++++- expected/13.11/type.out | 406 ++++++++++++++++++++++++++++++++---- expected/14.8/type.out | 446 +++++++++++++++++++++++++++++++++++++--- expected/15.3/type.out | 406 ++++++++++++++++++++++++++++++++---- expected/16.0/type.out | 326 ++++++++++++++++++++++++++++- sql/12.15/type.sql | 64 +++++- sql/13.11/type.sql | 144 +++++++++---- sql/14.8/type.sql | 144 +++++++++---- sql/15.3/type.sql | 144 +++++++++---- sql/16.0/type.sql | 64 +++++- sqlite_query.c | 23 ++- 12 files changed, 2264 insertions(+), 241 deletions(-) diff --git a/README.md b/README.md index 43eb8a49..1c5fce4e 100644 --- a/README.md +++ b/README.md @@ -572,6 +572,16 @@ For pull request, please make sure these items below for testing: - Execute test cases and update expectations for the latest version of PostgreSQL - Test creation and execution for other PostgreSQL versions are welcome but not required. +Preferred code style see in PostgreSQL source codes. For example + +```C +for (;;) +{ +} +if () +{ +} +``` Useful links ------------ diff --git a/expected/12.15/type.out b/expected/12.15/type.out index 29085711..c4026514 100644 --- a/expected/12.15/type.out +++ b/expected/12.15/type.out @@ -1153,7 +1153,7 @@ SELECT * FROM "type_VARBIT+" WHERE b = '110110'; INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); --Testcase 237: INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 238: 65 b +--Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ERROR: SQLite FDW dosens't support very long bit/varbit data HINT: bit length 65, maxmum 64 @@ -1165,7 +1165,331 @@ SELECT * FROM "type_VARBIT+" WHERE "i" > 10; 12 | 10010010101100101001010100011111011010110110111101100010101010 | integer | 19 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 (3 rows) - + +--Testcase 240: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 110110 + 6 | 110110 | 7 | 111001 | 111111 + 6 | 110110 | 8 | 110000 | 110110 + 6 | 110110 | 9 | 100001 | 110111 + 7 | 111001 | 6 | 110110 | 111111 + 7 | 111001 | 7 | 111001 | 111001 + 7 | 111001 | 8 | 110000 | 111001 + 7 | 111001 | 9 | 100001 | 111001 + 8 | 110000 | 6 | 110110 | 110110 + 8 | 110000 | 7 | 111001 | 111001 + 8 | 110000 | 8 | 110000 | 110000 + 8 | 110000 | 9 | 100001 | 110001 + 9 | 100001 | 6 | 110110 | 110111 + 9 | 100001 | 7 | 111001 | 111001 + 9 | 100001 | 8 | 110000 | 110001 + 9 | 100001 | 9 | 100001 | 100001 +(16 rows) + +--Testcase 241: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 110110 + 6 | 110110 | 7 | 111001 | 110000 + 6 | 110110 | 8 | 110000 | 110000 + 6 | 110110 | 9 | 100001 | 100000 + 7 | 111001 | 6 | 110110 | 110000 + 7 | 111001 | 7 | 111001 | 111001 + 7 | 111001 | 8 | 110000 | 110000 + 7 | 111001 | 9 | 100001 | 100001 + 8 | 110000 | 6 | 110110 | 110000 + 8 | 110000 | 7 | 111001 | 110000 + 8 | 110000 | 8 | 110000 | 110000 + 8 | 110000 | 9 | 100001 | 100000 + 9 | 100001 | 6 | 110110 | 100000 + 9 | 100001 | 7 | 111001 | 100001 + 9 | 100001 | 8 | 110000 | 100000 + 9 | 100001 | 9 | 100001 | 100001 +(16 rows) + +--Testcase 242: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 000000 + 6 | 110110 | 7 | 111001 | 001111 + 6 | 110110 | 8 | 110000 | 000110 + 6 | 110110 | 9 | 100001 | 010111 + 7 | 111001 | 6 | 110110 | 001111 + 7 | 111001 | 7 | 111001 | 000000 + 7 | 111001 | 8 | 110000 | 001001 + 7 | 111001 | 9 | 100001 | 011000 + 8 | 110000 | 6 | 110110 | 000110 + 8 | 110000 | 7 | 111001 | 001001 + 8 | 110000 | 8 | 110000 | 000000 + 8 | 110000 | 9 | 100001 | 010001 + 9 | 100001 | 6 | 110110 | 010111 + 9 | 100001 | 7 | 111001 | 011000 + 9 | 100001 | 8 | 110000 | 010001 + 9 | 100001 | 9 | 100001 | 000000 +(16 rows) + +--Testcase 243: +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 001101 + 7 | 111001 | 001110 + 8 | 110000 | 001100 + 9 | 100001 | 001000 +(4 rows) + +--Testcase 244: +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 110000 + 7 | 111001 | 001000 + 8 | 110000 | 000000 + 9 | 100001 | 001000 +(4 rows) + +--Testcase 245: +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 001001 + 7 | 111001 | 000110 + 8 | 110000 | 001111 + 9 | 100001 | 011110 +(4 rows) + +--Testcase 246: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b | b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 247: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b & b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 248: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b # b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 249: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (b >> 2) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 250: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (b << 3) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 251: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (~ b) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 252: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot OR bit strings of different sizes +--Testcase 253: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot AND bit strings of different sizes +--Testcase 254: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot XOR bit strings of different sizes +--Testcase 255: +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 00 + 3 | 11 | 00 + 4 | 100 | 001 + 5 | 101 | 001 + 6 | 110110 | 001101 + 7 | 111001 | 001110 + 8 | 110000 | 001100 + 9 | 100001 | 001000 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 001001001010110010100101010001111101101011011011110110001010 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 0010010010101100101001010100011111011010110110111101100010101 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 00100100101011001010010101000111110110101101101111011000101010 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 001001001010110010100101010001111101101011011011110110001010101 +(13 rows) + +--Testcase 256: +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 00 + 3 | 11 | 00 + 4 | 100 | 000 + 5 | 101 | 000 + 6 | 110110 | 110000 + 7 | 111001 | 001000 + 8 | 110000 | 000000 + 9 | 100001 | 001000 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 100101011001010010101000111110110101101101111011000101010000 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 1001010110010100101010001111101101011011011110110001010101000 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 10010101100101001010100011111011010110110111101100010101010000 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 100101011001010010101000111110110101101101111011000101010101000 +(13 rows) + +--Testcase 257: +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 01 + 3 | 11 | 00 + 4 | 100 | 011 + 5 | 101 | 010 + 6 | 110110 | 001001 + 7 | 111001 | 000110 + 8 | 110000 | 001111 + 9 | 100001 | 011110 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 011011010100110101101010111000001001010010010000100111010101 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 0110110101001101011010101110000010010100100100001001110101010 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 01101101010011010110101011100000100101001001000010011101010101 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 011011010100110101101010111000001001010010010000100111010101010 +(13 rows) + +--Testcase 258: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" | (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 259: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" & (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 260: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" # (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 261: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, ((b)::"bit" >> 2) + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + +--Testcase 262: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, ((b)::"bit" << 3) + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + +--Testcase 263: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, (~ (b)::"bit") + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; NOTICE: drop cascades to 48 other objects diff --git a/expected/13.11/type.out b/expected/13.11/type.out index 0e28fe24..3929e822 100644 --- a/expected/13.11/type.out +++ b/expected/13.11/type.out @@ -499,51 +499,51 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; ---Testcase 178: +--Testcase 199: DROP FOREIGN TABLE IF EXISTS "type_BIT"; ---Testcase 179: +--Testcase 200: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); ---Testcase 180: +--Testcase 201: DROP FOREIGN TABLE IF EXISTS "type_BIT+"; NOTICE: foreign table "type_BIT+" does not exist, skipping ---Testcase 181: +--Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 182: +--Testcase 203: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 183: +--Testcase 204: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 184: +--Testcase 205: INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ERROR: bit string length 1 does not match type bit(6) ---Testcase 185: +--Testcase 206: INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ERROR: bit string length 2 does not match type bit(6) ---Testcase 186: +--Testcase 207: INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); ERROR: bit string length 3 does not match type bit(6) ---Testcase 187: +--Testcase 208: INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); ---Testcase 188: +--Testcase 209: INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); ---Testcase 189: +--Testcase 210: INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); ---Testcase 190: +--Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 191: +--Testcase 212: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 192: +--Testcase 213: SELECT * FROM "type_BIT+"; i | b | t | l | bi ---+--------+---------+---+---- @@ -553,7 +553,7 @@ SELECT * FROM "type_BIT+"; 9 | 100001 | integer | 2 | 33 (4 rows) ---Testcase 193: +--Testcase 214: SELECT * FROM "type_BIT" WHERE b < '110110'; i | b ---+-------- @@ -561,52 +561,52 @@ SELECT * FROM "type_BIT" WHERE b < '110110'; 9 | 100001 (2 rows) ---Testcase 194: +--Testcase 215: SELECT * FROM "type_BIT" WHERE b > '110110'; i | b ---+-------- 7 | 111001 (1 row) ---Testcase 195: +--Testcase 216: SELECT * FROM "type_BIT" WHERE b = '110110'; i | b ---+-------- 6 | 110110 (1 row) ---Testcase 196: +--Testcase 217: DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; ---Testcase 197: +--Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); ---Testcase 199: +--Testcase 219: DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; NOTICE: foreign table "type_VARBIT+" does not exist, skipping ---Testcase 200: +--Testcase 220: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); ---Testcase 201: +--Testcase 221: INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); ---Testcase 202: +--Testcase 222: INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); ---Testcase 203: +--Testcase 223: INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); ---Testcase 204: +--Testcase 224: INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); ---Testcase 205: +--Testcase 225: INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); ---Testcase 206: +--Testcase 226: INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); ---Testcase 207: +--Testcase 227: INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); ---Testcase 208: +--Testcase 228: INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); ---Testcase 209: +--Testcase 229: INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); ---Testcase 210: +--Testcase 230: INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); ---Testcase 211: +--Testcase 231: INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); ---Testcase 212 +--Testcase 232 SELECT * FROM "type_VARBIT+"; i | b | t | l ----+---------------------------------------------------------------+---------+---- @@ -623,7 +623,7 @@ SELECT * FROM "type_VARBIT+"; 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 (11 rows) ---Testcase 213: +--Testcase 233: SELECT * FROM "type_VARBIT+" WHERE b < '110110'; i | b | t | l ---+--------+---------+--- @@ -636,7 +636,7 @@ SELECT * FROM "type_VARBIT+" WHERE b < '110110'; 9 | 100001 | integer | 2 (7 rows) ---Testcase 214: +--Testcase 234: SELECT * FROM "type_VARBIT+" WHERE b > '110110'; i | b | t | l ----+---------------------------------------------------------------+---------+---- @@ -645,22 +645,22 @@ SELECT * FROM "type_VARBIT+" WHERE b > '110110'; 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 (3 rows) ---Testcase 215: +--Testcase 235: SELECT * FROM "type_VARBIT+" WHERE b = '110110'; i | b | t | l ---+--------+---------+--- 6 | 110110 | integer | 2 (1 row) ---Testcase 216: +--Testcase 236: INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); ---Testcase 217: +--Testcase 237: INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 218: 65 b +--Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ERROR: SQLite FDW dosens't support very long bit/varbit data HINT: bit length 65, maxmum 64 ---Testcase 219: +--Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; i | b | t | l ----+-----------------------------------------------------------------+---------+---- @@ -669,6 +669,330 @@ SELECT * FROM "type_VARBIT+" WHERE "i" > 10; 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 (3 rows) +--Testcase 240: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 110110 + 6 | 110110 | 7 | 111001 | 111111 + 6 | 110110 | 8 | 110000 | 110110 + 6 | 110110 | 9 | 100001 | 110111 + 7 | 111001 | 6 | 110110 | 111111 + 7 | 111001 | 7 | 111001 | 111001 + 7 | 111001 | 8 | 110000 | 111001 + 7 | 111001 | 9 | 100001 | 111001 + 8 | 110000 | 6 | 110110 | 110110 + 8 | 110000 | 7 | 111001 | 111001 + 8 | 110000 | 8 | 110000 | 110000 + 8 | 110000 | 9 | 100001 | 110001 + 9 | 100001 | 6 | 110110 | 110111 + 9 | 100001 | 7 | 111001 | 111001 + 9 | 100001 | 8 | 110000 | 110001 + 9 | 100001 | 9 | 100001 | 100001 +(16 rows) + +--Testcase 241: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 110110 + 6 | 110110 | 7 | 111001 | 110000 + 6 | 110110 | 8 | 110000 | 110000 + 6 | 110110 | 9 | 100001 | 100000 + 7 | 111001 | 6 | 110110 | 110000 + 7 | 111001 | 7 | 111001 | 111001 + 7 | 111001 | 8 | 110000 | 110000 + 7 | 111001 | 9 | 100001 | 100001 + 8 | 110000 | 6 | 110110 | 110000 + 8 | 110000 | 7 | 111001 | 110000 + 8 | 110000 | 8 | 110000 | 110000 + 8 | 110000 | 9 | 100001 | 100000 + 9 | 100001 | 6 | 110110 | 100000 + 9 | 100001 | 7 | 111001 | 100001 + 9 | 100001 | 8 | 110000 | 100000 + 9 | 100001 | 9 | 100001 | 100001 +(16 rows) + +--Testcase 242: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 000000 + 6 | 110110 | 7 | 111001 | 001111 + 6 | 110110 | 8 | 110000 | 000110 + 6 | 110110 | 9 | 100001 | 010111 + 7 | 111001 | 6 | 110110 | 001111 + 7 | 111001 | 7 | 111001 | 000000 + 7 | 111001 | 8 | 110000 | 001001 + 7 | 111001 | 9 | 100001 | 011000 + 8 | 110000 | 6 | 110110 | 000110 + 8 | 110000 | 7 | 111001 | 001001 + 8 | 110000 | 8 | 110000 | 000000 + 8 | 110000 | 9 | 100001 | 010001 + 9 | 100001 | 6 | 110110 | 010111 + 9 | 100001 | 7 | 111001 | 011000 + 9 | 100001 | 8 | 110000 | 010001 + 9 | 100001 | 9 | 100001 | 000000 +(16 rows) + +--Testcase 243: +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 001101 + 7 | 111001 | 001110 + 8 | 110000 | 001100 + 9 | 100001 | 001000 +(4 rows) + +--Testcase 244: +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 110000 + 7 | 111001 | 001000 + 8 | 110000 | 000000 + 9 | 100001 | 001000 +(4 rows) + +--Testcase 245: +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 001001 + 7 | 111001 | 000110 + 8 | 110000 | 001111 + 9 | 100001 | 011110 +(4 rows) + +--Testcase 246: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b | b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 247: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b & b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 248: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b # b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 249: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (b >> 2) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 250: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (b << 3) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 251: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (~ b) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 252: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot OR bit strings of different sizes +--Testcase 253: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot AND bit strings of different sizes +--Testcase 254: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot XOR bit strings of different sizes +--Testcase 255: +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 00 + 3 | 11 | 00 + 4 | 100 | 001 + 5 | 101 | 001 + 6 | 110110 | 001101 + 7 | 111001 | 001110 + 8 | 110000 | 001100 + 9 | 100001 | 001000 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 001001001010110010100101010001111101101011011011110110001010 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 0010010010101100101001010100011111011010110110111101100010101 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 00100100101011001010010101000111110110101101101111011000101010 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 001001001010110010100101010001111101101011011011110110001010101 +(13 rows) + +--Testcase 256: +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 00 + 3 | 11 | 00 + 4 | 100 | 000 + 5 | 101 | 000 + 6 | 110110 | 110000 + 7 | 111001 | 001000 + 8 | 110000 | 000000 + 9 | 100001 | 001000 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 100101011001010010101000111110110101101101111011000101010000 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 1001010110010100101010001111101101011011011110110001010101000 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 10010101100101001010100011111011010110110111101100010101010000 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 100101011001010010101000111110110101101101111011000101010101000 +(13 rows) + +--Testcase 257: +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 01 + 3 | 11 | 00 + 4 | 100 | 011 + 5 | 101 | 010 + 6 | 110110 | 001001 + 7 | 111001 | 000110 + 8 | 110000 | 001111 + 9 | 100001 | 011110 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 011011010100110101101010111000001001010010010000100111010101 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 0110110101001101011010101110000010010100100100001001110101010 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 01101101010011010110101011100000100101001001000010011101010101 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 011011010100110101101010111000001001010010010000100111010101010 +(13 rows) + +--Testcase 258: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" | (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 259: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" & (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 260: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" # (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 261: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, ((b)::"bit" >> 2) + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + +--Testcase 262: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, ((b)::"bit" << 3) + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + +--Testcase 263: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, (~ (b)::"bit") + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; NOTICE: drop cascades to 47 other objects diff --git a/expected/14.8/type.out b/expected/14.8/type.out index 0e28fe24..10eb1cd8 100644 --- a/expected/14.8/type.out +++ b/expected/14.8/type.out @@ -575,38 +575,114 @@ SELECT * FROM "type_BIT" WHERE b = '110110'; 6 | 110110 (1 row) ---Testcase 196: +--Testcase 199: +DROP FOREIGN TABLE IF EXISTS "type_BIT"; +--Testcase 200: +CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); +--Testcase 201: +DROP FOREIGN TABLE IF EXISTS "type_BIT+"; +NOTICE: foreign table "type_BIT+" does not exist, skipping +--Testcase 202: +CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); +--Testcase 203: +INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 204: +INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 205: +INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); +ERROR: bit string length 1 does not match type bit(6) +--Testcase 206: +INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); +ERROR: bit string length 2 does not match type bit(6) +--Testcase 207: +INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); +ERROR: bit string length 3 does not match type bit(6) +--Testcase 208: +INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); +--Testcase 209: +INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); +--Testcase 210: +INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); +--Testcase 211: +INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); +--Testcase 212: +INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); +ERROR: column "b" is of type bit but expression is of type integer +LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); + ^ +HINT: You will need to rewrite or cast the expression. +--Testcase 213: +SELECT * FROM "type_BIT+"; + i | b | t | l | bi +---+--------+---------+---+---- + 6 | 110110 | integer | 2 | 54 + 7 | 111001 | integer | 2 | 57 + 8 | 110000 | integer | 2 | 48 + 9 | 100001 | integer | 2 | 33 +(4 rows) + +--Testcase 214: +SELECT * FROM "type_BIT" WHERE b < '110110'; + i | b +---+-------- + 8 | 110000 + 9 | 100001 +(2 rows) + +--Testcase 215: +SELECT * FROM "type_BIT" WHERE b > '110110'; + i | b +---+-------- + 7 | 111001 +(1 row) + +--Testcase 216: +SELECT * FROM "type_BIT" WHERE b = '110110'; + i | b +---+-------- + 6 | 110110 +(1 row) + +--Testcase 217: DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; ---Testcase 197: +--Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); ---Testcase 199: +--Testcase 219: DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; NOTICE: foreign table "type_VARBIT+" does not exist, skipping ---Testcase 200: +--Testcase 220: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); ---Testcase 201: +--Testcase 221: INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); ---Testcase 202: +--Testcase 222: INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); ---Testcase 203: +--Testcase 223: INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); ---Testcase 204: +--Testcase 224: INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); ---Testcase 205: +--Testcase 225: INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); ---Testcase 206: +--Testcase 226: INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); ---Testcase 207: +--Testcase 227: INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); ---Testcase 208: +--Testcase 228: INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); ---Testcase 209: +--Testcase 229: INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); ---Testcase 210: +--Testcase 230: INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); ---Testcase 211: +--Testcase 231: INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); ---Testcase 212 +--Testcase 232 SELECT * FROM "type_VARBIT+"; i | b | t | l ----+---------------------------------------------------------------+---------+---- @@ -623,7 +699,7 @@ SELECT * FROM "type_VARBIT+"; 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 (11 rows) ---Testcase 213: +--Testcase 233: SELECT * FROM "type_VARBIT+" WHERE b < '110110'; i | b | t | l ---+--------+---------+--- @@ -636,7 +712,7 @@ SELECT * FROM "type_VARBIT+" WHERE b < '110110'; 9 | 100001 | integer | 2 (7 rows) ---Testcase 214: +--Testcase 234: SELECT * FROM "type_VARBIT+" WHERE b > '110110'; i | b | t | l ----+---------------------------------------------------------------+---------+---- @@ -645,22 +721,22 @@ SELECT * FROM "type_VARBIT+" WHERE b > '110110'; 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 (3 rows) ---Testcase 215: +--Testcase 235: SELECT * FROM "type_VARBIT+" WHERE b = '110110'; i | b | t | l ---+--------+---------+--- 6 | 110110 | integer | 2 (1 row) ---Testcase 216: +--Testcase 236: INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); ---Testcase 217: +--Testcase 237: INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 218: 65 b +--Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ERROR: SQLite FDW dosens't support very long bit/varbit data HINT: bit length 65, maxmum 64 ---Testcase 219: +--Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; i | b | t | l ----+-----------------------------------------------------------------+---------+---- @@ -669,6 +745,330 @@ SELECT * FROM "type_VARBIT+" WHERE "i" > 10; 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 (3 rows) +--Testcase 240: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 110110 + 6 | 110110 | 7 | 111001 | 111111 + 6 | 110110 | 8 | 110000 | 110110 + 6 | 110110 | 9 | 100001 | 110111 + 7 | 111001 | 6 | 110110 | 111111 + 7 | 111001 | 7 | 111001 | 111001 + 7 | 111001 | 8 | 110000 | 111001 + 7 | 111001 | 9 | 100001 | 111001 + 8 | 110000 | 6 | 110110 | 110110 + 8 | 110000 | 7 | 111001 | 111001 + 8 | 110000 | 8 | 110000 | 110000 + 8 | 110000 | 9 | 100001 | 110001 + 9 | 100001 | 6 | 110110 | 110111 + 9 | 100001 | 7 | 111001 | 111001 + 9 | 100001 | 8 | 110000 | 110001 + 9 | 100001 | 9 | 100001 | 100001 +(16 rows) + +--Testcase 241: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 110110 + 6 | 110110 | 7 | 111001 | 110000 + 6 | 110110 | 8 | 110000 | 110000 + 6 | 110110 | 9 | 100001 | 100000 + 7 | 111001 | 6 | 110110 | 110000 + 7 | 111001 | 7 | 111001 | 111001 + 7 | 111001 | 8 | 110000 | 110000 + 7 | 111001 | 9 | 100001 | 100001 + 8 | 110000 | 6 | 110110 | 110000 + 8 | 110000 | 7 | 111001 | 110000 + 8 | 110000 | 8 | 110000 | 110000 + 8 | 110000 | 9 | 100001 | 100000 + 9 | 100001 | 6 | 110110 | 100000 + 9 | 100001 | 7 | 111001 | 100001 + 9 | 100001 | 8 | 110000 | 100000 + 9 | 100001 | 9 | 100001 | 100001 +(16 rows) + +--Testcase 242: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 000000 + 6 | 110110 | 7 | 111001 | 001111 + 6 | 110110 | 8 | 110000 | 000110 + 6 | 110110 | 9 | 100001 | 010111 + 7 | 111001 | 6 | 110110 | 001111 + 7 | 111001 | 7 | 111001 | 000000 + 7 | 111001 | 8 | 110000 | 001001 + 7 | 111001 | 9 | 100001 | 011000 + 8 | 110000 | 6 | 110110 | 000110 + 8 | 110000 | 7 | 111001 | 001001 + 8 | 110000 | 8 | 110000 | 000000 + 8 | 110000 | 9 | 100001 | 010001 + 9 | 100001 | 6 | 110110 | 010111 + 9 | 100001 | 7 | 111001 | 011000 + 9 | 100001 | 8 | 110000 | 010001 + 9 | 100001 | 9 | 100001 | 000000 +(16 rows) + +--Testcase 243: +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 001101 + 7 | 111001 | 001110 + 8 | 110000 | 001100 + 9 | 100001 | 001000 +(4 rows) + +--Testcase 244: +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 110000 + 7 | 111001 | 001000 + 8 | 110000 | 000000 + 9 | 100001 | 001000 +(4 rows) + +--Testcase 245: +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 001001 + 7 | 111001 | 000110 + 8 | 110000 | 001111 + 9 | 100001 | 011110 +(4 rows) + +--Testcase 246: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b | b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 247: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b & b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 248: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b # b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 249: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (b >> 2) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 250: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (b << 3) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 251: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (~ b) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 252: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot OR bit strings of different sizes +--Testcase 253: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot AND bit strings of different sizes +--Testcase 254: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot XOR bit strings of different sizes +--Testcase 255: +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 00 + 3 | 11 | 00 + 4 | 100 | 001 + 5 | 101 | 001 + 6 | 110110 | 001101 + 7 | 111001 | 001110 + 8 | 110000 | 001100 + 9 | 100001 | 001000 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 001001001010110010100101010001111101101011011011110110001010 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 0010010010101100101001010100011111011010110110111101100010101 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 00100100101011001010010101000111110110101101101111011000101010 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 001001001010110010100101010001111101101011011011110110001010101 +(13 rows) + +--Testcase 256: +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 00 + 3 | 11 | 00 + 4 | 100 | 000 + 5 | 101 | 000 + 6 | 110110 | 110000 + 7 | 111001 | 001000 + 8 | 110000 | 000000 + 9 | 100001 | 001000 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 100101011001010010101000111110110101101101111011000101010000 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 1001010110010100101010001111101101011011011110110001010101000 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 10010101100101001010100011111011010110110111101100010101010000 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 100101011001010010101000111110110101101101111011000101010101000 +(13 rows) + +--Testcase 257: +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 01 + 3 | 11 | 00 + 4 | 100 | 011 + 5 | 101 | 010 + 6 | 110110 | 001001 + 7 | 111001 | 000110 + 8 | 110000 | 001111 + 9 | 100001 | 011110 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 011011010100110101101010111000001001010010010000100111010101 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 0110110101001101011010101110000010010100100100001001110101010 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 01101101010011010110101011100000100101001001000010011101010101 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 011011010100110101101010111000001001010010010000100111010101010 +(13 rows) + +--Testcase 258: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" | (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 259: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" & (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 260: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" # (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 261: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, ((b)::"bit" >> 2) + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + +--Testcase 262: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, ((b)::"bit" << 3) + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + +--Testcase 263: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, (~ (b)::"bit") + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; NOTICE: drop cascades to 47 other objects diff --git a/expected/15.3/type.out b/expected/15.3/type.out index 0e28fe24..3929e822 100644 --- a/expected/15.3/type.out +++ b/expected/15.3/type.out @@ -499,51 +499,51 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; ---Testcase 178: +--Testcase 199: DROP FOREIGN TABLE IF EXISTS "type_BIT"; ---Testcase 179: +--Testcase 200: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); ---Testcase 180: +--Testcase 201: DROP FOREIGN TABLE IF EXISTS "type_BIT+"; NOTICE: foreign table "type_BIT+" does not exist, skipping ---Testcase 181: +--Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 182: +--Testcase 203: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 183: +--Testcase 204: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 184: +--Testcase 205: INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ERROR: bit string length 1 does not match type bit(6) ---Testcase 185: +--Testcase 206: INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ERROR: bit string length 2 does not match type bit(6) ---Testcase 186: +--Testcase 207: INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); ERROR: bit string length 3 does not match type bit(6) ---Testcase 187: +--Testcase 208: INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); ---Testcase 188: +--Testcase 209: INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); ---Testcase 189: +--Testcase 210: INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); ---Testcase 190: +--Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 191: +--Testcase 212: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 192: +--Testcase 213: SELECT * FROM "type_BIT+"; i | b | t | l | bi ---+--------+---------+---+---- @@ -553,7 +553,7 @@ SELECT * FROM "type_BIT+"; 9 | 100001 | integer | 2 | 33 (4 rows) ---Testcase 193: +--Testcase 214: SELECT * FROM "type_BIT" WHERE b < '110110'; i | b ---+-------- @@ -561,52 +561,52 @@ SELECT * FROM "type_BIT" WHERE b < '110110'; 9 | 100001 (2 rows) ---Testcase 194: +--Testcase 215: SELECT * FROM "type_BIT" WHERE b > '110110'; i | b ---+-------- 7 | 111001 (1 row) ---Testcase 195: +--Testcase 216: SELECT * FROM "type_BIT" WHERE b = '110110'; i | b ---+-------- 6 | 110110 (1 row) ---Testcase 196: +--Testcase 217: DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; ---Testcase 197: +--Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); ---Testcase 199: +--Testcase 219: DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; NOTICE: foreign table "type_VARBIT+" does not exist, skipping ---Testcase 200: +--Testcase 220: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); ---Testcase 201: +--Testcase 221: INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); ---Testcase 202: +--Testcase 222: INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); ---Testcase 203: +--Testcase 223: INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); ---Testcase 204: +--Testcase 224: INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); ---Testcase 205: +--Testcase 225: INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); ---Testcase 206: +--Testcase 226: INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); ---Testcase 207: +--Testcase 227: INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); ---Testcase 208: +--Testcase 228: INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); ---Testcase 209: +--Testcase 229: INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); ---Testcase 210: +--Testcase 230: INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); ---Testcase 211: +--Testcase 231: INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); ---Testcase 212 +--Testcase 232 SELECT * FROM "type_VARBIT+"; i | b | t | l ----+---------------------------------------------------------------+---------+---- @@ -623,7 +623,7 @@ SELECT * FROM "type_VARBIT+"; 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 (11 rows) ---Testcase 213: +--Testcase 233: SELECT * FROM "type_VARBIT+" WHERE b < '110110'; i | b | t | l ---+--------+---------+--- @@ -636,7 +636,7 @@ SELECT * FROM "type_VARBIT+" WHERE b < '110110'; 9 | 100001 | integer | 2 (7 rows) ---Testcase 214: +--Testcase 234: SELECT * FROM "type_VARBIT+" WHERE b > '110110'; i | b | t | l ----+---------------------------------------------------------------+---------+---- @@ -645,22 +645,22 @@ SELECT * FROM "type_VARBIT+" WHERE b > '110110'; 11 | 1001001010110010100101010001111101101011011011110110001010101 | integer | 19 (3 rows) ---Testcase 215: +--Testcase 235: SELECT * FROM "type_VARBIT+" WHERE b = '110110'; i | b | t | l ---+--------+---------+--- 6 | 110110 | integer | 2 (1 row) ---Testcase 216: +--Testcase 236: INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); ---Testcase 217: +--Testcase 237: INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 218: 65 b +--Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ERROR: SQLite FDW dosens't support very long bit/varbit data HINT: bit length 65, maxmum 64 ---Testcase 219: +--Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; i | b | t | l ----+-----------------------------------------------------------------+---------+---- @@ -669,6 +669,330 @@ SELECT * FROM "type_VARBIT+" WHERE "i" > 10; 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 (3 rows) +--Testcase 240: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 110110 + 6 | 110110 | 7 | 111001 | 111111 + 6 | 110110 | 8 | 110000 | 110110 + 6 | 110110 | 9 | 100001 | 110111 + 7 | 111001 | 6 | 110110 | 111111 + 7 | 111001 | 7 | 111001 | 111001 + 7 | 111001 | 8 | 110000 | 111001 + 7 | 111001 | 9 | 100001 | 111001 + 8 | 110000 | 6 | 110110 | 110110 + 8 | 110000 | 7 | 111001 | 111001 + 8 | 110000 | 8 | 110000 | 110000 + 8 | 110000 | 9 | 100001 | 110001 + 9 | 100001 | 6 | 110110 | 110111 + 9 | 100001 | 7 | 111001 | 111001 + 9 | 100001 | 8 | 110000 | 110001 + 9 | 100001 | 9 | 100001 | 100001 +(16 rows) + +--Testcase 241: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 110110 + 6 | 110110 | 7 | 111001 | 110000 + 6 | 110110 | 8 | 110000 | 110000 + 6 | 110110 | 9 | 100001 | 100000 + 7 | 111001 | 6 | 110110 | 110000 + 7 | 111001 | 7 | 111001 | 111001 + 7 | 111001 | 8 | 110000 | 110000 + 7 | 111001 | 9 | 100001 | 100001 + 8 | 110000 | 6 | 110110 | 110000 + 8 | 110000 | 7 | 111001 | 110000 + 8 | 110000 | 8 | 110000 | 110000 + 8 | 110000 | 9 | 100001 | 100000 + 9 | 100001 | 6 | 110110 | 100000 + 9 | 100001 | 7 | 111001 | 100001 + 9 | 100001 | 8 | 110000 | 100000 + 9 | 100001 | 9 | 100001 | 100001 +(16 rows) + +--Testcase 242: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 000000 + 6 | 110110 | 7 | 111001 | 001111 + 6 | 110110 | 8 | 110000 | 000110 + 6 | 110110 | 9 | 100001 | 010111 + 7 | 111001 | 6 | 110110 | 001111 + 7 | 111001 | 7 | 111001 | 000000 + 7 | 111001 | 8 | 110000 | 001001 + 7 | 111001 | 9 | 100001 | 011000 + 8 | 110000 | 6 | 110110 | 000110 + 8 | 110000 | 7 | 111001 | 001001 + 8 | 110000 | 8 | 110000 | 000000 + 8 | 110000 | 9 | 100001 | 010001 + 9 | 100001 | 6 | 110110 | 010111 + 9 | 100001 | 7 | 111001 | 011000 + 9 | 100001 | 8 | 110000 | 010001 + 9 | 100001 | 9 | 100001 | 000000 +(16 rows) + +--Testcase 243: +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 001101 + 7 | 111001 | 001110 + 8 | 110000 | 001100 + 9 | 100001 | 001000 +(4 rows) + +--Testcase 244: +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 110000 + 7 | 111001 | 001000 + 8 | 110000 | 000000 + 9 | 100001 | 001000 +(4 rows) + +--Testcase 245: +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 001001 + 7 | 111001 | 000110 + 8 | 110000 | 001111 + 9 | 100001 | 011110 +(4 rows) + +--Testcase 246: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b | b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 247: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b & b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 248: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b # b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 249: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (b >> 2) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 250: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (b << 3) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 251: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (~ b) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 252: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot OR bit strings of different sizes +--Testcase 253: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot AND bit strings of different sizes +--Testcase 254: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot XOR bit strings of different sizes +--Testcase 255: +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 00 + 3 | 11 | 00 + 4 | 100 | 001 + 5 | 101 | 001 + 6 | 110110 | 001101 + 7 | 111001 | 001110 + 8 | 110000 | 001100 + 9 | 100001 | 001000 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 001001001010110010100101010001111101101011011011110110001010 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 0010010010101100101001010100011111011010110110111101100010101 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 00100100101011001010010101000111110110101101101111011000101010 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 001001001010110010100101010001111101101011011011110110001010101 +(13 rows) + +--Testcase 256: +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 00 + 3 | 11 | 00 + 4 | 100 | 000 + 5 | 101 | 000 + 6 | 110110 | 110000 + 7 | 111001 | 001000 + 8 | 110000 | 000000 + 9 | 100001 | 001000 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 100101011001010010101000111110110101101101111011000101010000 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 1001010110010100101010001111101101011011011110110001010101000 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 10010101100101001010100011111011010110110111101100010101010000 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 100101011001010010101000111110110101101101111011000101010101000 +(13 rows) + +--Testcase 257: +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 01 + 3 | 11 | 00 + 4 | 100 | 011 + 5 | 101 | 010 + 6 | 110110 | 001001 + 7 | 111001 | 000110 + 8 | 110000 | 001111 + 9 | 100001 | 011110 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 011011010100110101101010111000001001010010010000100111010101 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 0110110101001101011010101110000010010100100100001001110101010 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 01101101010011010110101011100000100101001001000010011101010101 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 011011010100110101101010111000001001010010010000100111010101010 +(13 rows) + +--Testcase 258: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" | (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 259: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" & (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 260: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" # (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 261: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, ((b)::"bit" >> 2) + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + +--Testcase 262: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, ((b)::"bit" << 3) + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + +--Testcase 263: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, (~ (b)::"bit") + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; NOTICE: drop cascades to 47 other objects diff --git a/expected/16.0/type.out b/expected/16.0/type.out index 6587d5b1..60425acf 100644 --- a/expected/16.0/type.out +++ b/expected/16.0/type.out @@ -1154,7 +1154,7 @@ SELECT * FROM "type_VARBIT+" WHERE b = '110110'; INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); --Testcase 237: INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 238: 65 b +--Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ERROR: SQLite FDW dosens't support very long bit/varbit data HINT: bit length 65, maxmum 64 @@ -1167,6 +1167,330 @@ SELECT * FROM "type_VARBIT+" WHERE "i" > 10; 13 | 100100101011001010010101000111110110101101101111011000101010101 | integer | 19 (3 rows) +--Testcase 240: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 110110 + 6 | 110110 | 7 | 111001 | 111111 + 6 | 110110 | 8 | 110000 | 110110 + 6 | 110110 | 9 | 100001 | 110111 + 7 | 111001 | 6 | 110110 | 111111 + 7 | 111001 | 7 | 111001 | 111001 + 7 | 111001 | 8 | 110000 | 111001 + 7 | 111001 | 9 | 100001 | 111001 + 8 | 110000 | 6 | 110110 | 110110 + 8 | 110000 | 7 | 111001 | 111001 + 8 | 110000 | 8 | 110000 | 110000 + 8 | 110000 | 9 | 100001 | 110001 + 9 | 100001 | 6 | 110110 | 110111 + 9 | 100001 | 7 | 111001 | 111001 + 9 | 100001 | 8 | 110000 | 110001 + 9 | 100001 | 9 | 100001 | 100001 +(16 rows) + +--Testcase 241: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 110110 + 6 | 110110 | 7 | 111001 | 110000 + 6 | 110110 | 8 | 110000 | 110000 + 6 | 110110 | 9 | 100001 | 100000 + 7 | 111001 | 6 | 110110 | 110000 + 7 | 111001 | 7 | 111001 | 111001 + 7 | 111001 | 8 | 110000 | 110000 + 7 | 111001 | 9 | 100001 | 100001 + 8 | 110000 | 6 | 110110 | 110000 + 8 | 110000 | 7 | 111001 | 110000 + 8 | 110000 | 8 | 110000 | 110000 + 8 | 110000 | 9 | 100001 | 100000 + 9 | 100001 | 6 | 110110 | 100000 + 9 | 100001 | 7 | 111001 | 100001 + 9 | 100001 | 8 | 110000 | 100000 + 9 | 100001 | 9 | 100001 | 100001 +(16 rows) + +--Testcase 242: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + i₁ | b₁ | i₂ | b₂ | res +----+--------+----+--------+-------- + 6 | 110110 | 6 | 110110 | 000000 + 6 | 110110 | 7 | 111001 | 001111 + 6 | 110110 | 8 | 110000 | 000110 + 6 | 110110 | 9 | 100001 | 010111 + 7 | 111001 | 6 | 110110 | 001111 + 7 | 111001 | 7 | 111001 | 000000 + 7 | 111001 | 8 | 110000 | 001001 + 7 | 111001 | 9 | 100001 | 011000 + 8 | 110000 | 6 | 110110 | 000110 + 8 | 110000 | 7 | 111001 | 001001 + 8 | 110000 | 8 | 110000 | 000000 + 8 | 110000 | 9 | 100001 | 010001 + 9 | 100001 | 6 | 110110 | 010111 + 9 | 100001 | 7 | 111001 | 011000 + 9 | 100001 | 8 | 110000 | 010001 + 9 | 100001 | 9 | 100001 | 000000 +(16 rows) + +--Testcase 243: +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 001101 + 7 | 111001 | 001110 + 8 | 110000 | 001100 + 9 | 100001 | 001000 +(4 rows) + +--Testcase 244: +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 110000 + 7 | 111001 | 001000 + 8 | 110000 | 000000 + 9 | 100001 | 001000 +(4 rows) + +--Testcase 245: +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 001001 + 7 | 111001 | 000110 + 8 | 110000 | 001111 + 9 | 100001 | 011110 +(4 rows) + +--Testcase 246: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b | b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 247: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b & b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 248: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; + QUERY PLAN +-------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) + Output: b1.i, b1.b, b2.i, b2.b, (b1.b # b2.b) + -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" + -> Materialize (cost=10.00..2225.07 rows=2214 width=13) + Output: b2.i, b2.b + -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(10 rows) + +--Testcase 249: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (b >> 2) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 250: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (b << 3) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 251: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2219.53 rows=2214 width=45) + Output: i, b, (~ b) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(3 rows) + +--Testcase 252: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot OR bit strings of different sizes +--Testcase 253: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot AND bit strings of different sizes +--Testcase 254: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +ERROR: cannot XOR bit strings of different sizes +--Testcase 255: +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 00 + 3 | 11 | 00 + 4 | 100 | 001 + 5 | 101 | 001 + 6 | 110110 | 001101 + 7 | 111001 | 001110 + 8 | 110000 | 001100 + 9 | 100001 | 001000 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 001001001010110010100101010001111101101011011011110110001010 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 0010010010101100101001010100011111011010110110111101100010101 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 00100100101011001010010101000111110110101101101111011000101010 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 001001001010110010100101010001111101101011011011110110001010101 +(13 rows) + +--Testcase 256: +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 00 + 3 | 11 | 00 + 4 | 100 | 000 + 5 | 101 | 000 + 6 | 110110 | 110000 + 7 | 111001 | 001000 + 8 | 110000 | 000000 + 9 | 100001 | 001000 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 100101011001010010101000111110110101101101111011000101010000 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 1001010110010100101010001111101101011011011110110001010101000 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 10010101100101001010100011111011010110110111101100010101010000 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 100101011001010010101000111110110101101101111011000101010101000 +(13 rows) + +--Testcase 257: +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + i | b | res +----+-----------------------------------------------------------------+----------------------------------------------------------------- + 1 | 1 | 0 + 2 | 10 | 01 + 3 | 11 | 00 + 4 | 100 | 011 + 5 | 101 | 010 + 6 | 110110 | 001001 + 7 | 111001 | 000110 + 8 | 110000 | 001111 + 9 | 100001 | 011110 + 10 | 100100101011001010010101000111110110101101101111011000101010 | 011011010100110101101010111000001001010010010000100111010101 + 11 | 1001001010110010100101010001111101101011011011110110001010101 | 0110110101001101011010101110000010010100100100001001110101010 + 12 | 10010010101100101001010100011111011010110110111101100010101010 | 01101101010011010110101011100000100101001001000010011101010101 + 13 | 100100101011001010010101000111110110101101101111011000101010101 | 011011010100110101101010111000001001010010010000100111010101010 +(13 rows) + +--Testcase 258: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" | (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 259: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" & (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 260: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; + QUERY PLAN +----------------------------------------------------------------------------------------------- + Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) + Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" # (b2.b)::"bit") + -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) + Output: b1.i, b1.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" + -> Materialize (cost=10.00..1829.10 rows=1820 width=21) + Output: b2.i, b2.b + -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) + Output: b2.i, b2.b + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(10 rows) + +--Testcase 261: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, ((b)::"bit" >> 2) + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + +--Testcase 262: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, ((b)::"bit" << 3) + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + +--Testcase 263: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public."type_VARBIT" (cost=10.00..1824.55 rows=1820 width=53) + Output: i, b, (~ (b)::"bit") + SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; NOTICE: drop cascades to 48 other objects diff --git a/sql/12.15/type.sql b/sql/12.15/type.sql index e4dcc86f..8740f3f4 100644 --- a/sql/12.15/type.sql +++ b/sql/12.15/type.sql @@ -549,10 +549,72 @@ SELECT * FROM "type_VARBIT+" WHERE b = '110110'; INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); --Testcase 237: INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 238: 65 b +--Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); --Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; +--Testcase 240: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 241: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 242: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 243: +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; +--Testcase 244: +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; +--Testcase 245: +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; +--Testcase 246: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 247: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 248: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 249: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; +--Testcase 250: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; +--Testcase 251: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + +--Testcase 252: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 253: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 254: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 255: +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; +--Testcase 256: +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; +--Testcase 257: +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; +--Testcase 258: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 259: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 260: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 261: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; +--Testcase 262: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; +--Testcase 263: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/13.11/type.sql b/sql/13.11/type.sql index 196e8c4a..5f638cb1 100644 --- a/sql/13.11/type.sql +++ b/sql/13.11/type.sql @@ -266,91 +266,153 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; ---Testcase 178: +--Testcase 199: DROP FOREIGN TABLE IF EXISTS "type_BIT"; ---Testcase 179: +--Testcase 200: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); ---Testcase 180: +--Testcase 201: DROP FOREIGN TABLE IF EXISTS "type_BIT+"; ---Testcase 181: +--Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 182: +--Testcase 203: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ---Testcase 183: +--Testcase 204: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ---Testcase 184: +--Testcase 205: INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ---Testcase 185: +--Testcase 206: INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ---Testcase 186: +--Testcase 207: INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); ---Testcase 187: +--Testcase 208: INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); ---Testcase 188: +--Testcase 209: INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); ---Testcase 189: +--Testcase 210: INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); ---Testcase 190: +--Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 191: +--Testcase 212: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ---Testcase 192: +--Testcase 213: SELECT * FROM "type_BIT+"; ---Testcase 193: +--Testcase 214: SELECT * FROM "type_BIT" WHERE b < '110110'; ---Testcase 194: +--Testcase 215: SELECT * FROM "type_BIT" WHERE b > '110110'; ---Testcase 195: +--Testcase 216: SELECT * FROM "type_BIT" WHERE b = '110110'; ---Testcase 196: +--Testcase 217: DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; ---Testcase 197: +--Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); ---Testcase 199: +--Testcase 219: DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; ---Testcase 200: +--Testcase 220: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); ---Testcase 201: +--Testcase 221: INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); ---Testcase 202: +--Testcase 222: INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); ---Testcase 203: +--Testcase 223: INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); ---Testcase 204: +--Testcase 224: INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); ---Testcase 205: +--Testcase 225: INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); ---Testcase 206: +--Testcase 226: INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); ---Testcase 207: +--Testcase 227: INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); ---Testcase 208: +--Testcase 228: INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); ---Testcase 209: +--Testcase 229: INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); ---Testcase 210: +--Testcase 230: INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); ---Testcase 211: +--Testcase 231: INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); ---Testcase 212 +--Testcase 232 SELECT * FROM "type_VARBIT+"; ---Testcase 213: +--Testcase 233: SELECT * FROM "type_VARBIT+" WHERE b < '110110'; ---Testcase 214: +--Testcase 234: SELECT * FROM "type_VARBIT+" WHERE b > '110110'; ---Testcase 215: +--Testcase 235: SELECT * FROM "type_VARBIT+" WHERE b = '110110'; ---Testcase 216: +--Testcase 236: INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); ---Testcase 217: +--Testcase 237: INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 218: 65 b +--Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ---Testcase 219: +--Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; +--Testcase 240: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 241: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 242: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 243: +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; +--Testcase 244: +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; +--Testcase 245: +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; +--Testcase 246: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 247: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 248: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 249: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; +--Testcase 250: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; +--Testcase 251: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + +--Testcase 252: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 253: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 254: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 255: +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; +--Testcase 256: +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; +--Testcase 257: +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; +--Testcase 258: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 259: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 260: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 261: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; +--Testcase 262: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; +--Testcase 263: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/14.8/type.sql b/sql/14.8/type.sql index 196e8c4a..5f638cb1 100644 --- a/sql/14.8/type.sql +++ b/sql/14.8/type.sql @@ -266,91 +266,153 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; ---Testcase 178: +--Testcase 199: DROP FOREIGN TABLE IF EXISTS "type_BIT"; ---Testcase 179: +--Testcase 200: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); ---Testcase 180: +--Testcase 201: DROP FOREIGN TABLE IF EXISTS "type_BIT+"; ---Testcase 181: +--Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 182: +--Testcase 203: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ---Testcase 183: +--Testcase 204: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ---Testcase 184: +--Testcase 205: INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ---Testcase 185: +--Testcase 206: INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ---Testcase 186: +--Testcase 207: INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); ---Testcase 187: +--Testcase 208: INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); ---Testcase 188: +--Testcase 209: INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); ---Testcase 189: +--Testcase 210: INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); ---Testcase 190: +--Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 191: +--Testcase 212: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ---Testcase 192: +--Testcase 213: SELECT * FROM "type_BIT+"; ---Testcase 193: +--Testcase 214: SELECT * FROM "type_BIT" WHERE b < '110110'; ---Testcase 194: +--Testcase 215: SELECT * FROM "type_BIT" WHERE b > '110110'; ---Testcase 195: +--Testcase 216: SELECT * FROM "type_BIT" WHERE b = '110110'; ---Testcase 196: +--Testcase 217: DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; ---Testcase 197: +--Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); ---Testcase 199: +--Testcase 219: DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; ---Testcase 200: +--Testcase 220: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); ---Testcase 201: +--Testcase 221: INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); ---Testcase 202: +--Testcase 222: INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); ---Testcase 203: +--Testcase 223: INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); ---Testcase 204: +--Testcase 224: INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); ---Testcase 205: +--Testcase 225: INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); ---Testcase 206: +--Testcase 226: INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); ---Testcase 207: +--Testcase 227: INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); ---Testcase 208: +--Testcase 228: INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); ---Testcase 209: +--Testcase 229: INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); ---Testcase 210: +--Testcase 230: INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); ---Testcase 211: +--Testcase 231: INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); ---Testcase 212 +--Testcase 232 SELECT * FROM "type_VARBIT+"; ---Testcase 213: +--Testcase 233: SELECT * FROM "type_VARBIT+" WHERE b < '110110'; ---Testcase 214: +--Testcase 234: SELECT * FROM "type_VARBIT+" WHERE b > '110110'; ---Testcase 215: +--Testcase 235: SELECT * FROM "type_VARBIT+" WHERE b = '110110'; ---Testcase 216: +--Testcase 236: INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); ---Testcase 217: +--Testcase 237: INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 218: 65 b +--Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ---Testcase 219: +--Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; +--Testcase 240: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 241: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 242: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 243: +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; +--Testcase 244: +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; +--Testcase 245: +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; +--Testcase 246: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 247: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 248: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 249: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; +--Testcase 250: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; +--Testcase 251: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + +--Testcase 252: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 253: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 254: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 255: +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; +--Testcase 256: +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; +--Testcase 257: +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; +--Testcase 258: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 259: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 260: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 261: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; +--Testcase 262: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; +--Testcase 263: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/15.3/type.sql b/sql/15.3/type.sql index 196e8c4a..5f638cb1 100644 --- a/sql/15.3/type.sql +++ b/sql/15.3/type.sql @@ -266,91 +266,153 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; ---Testcase 178: +--Testcase 199: DROP FOREIGN TABLE IF EXISTS "type_BIT"; ---Testcase 179: +--Testcase 200: CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); ---Testcase 180: +--Testcase 201: DROP FOREIGN TABLE IF EXISTS "type_BIT+"; ---Testcase 181: +--Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 182: +--Testcase 203: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ---Testcase 183: +--Testcase 204: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ---Testcase 184: +--Testcase 205: INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ---Testcase 185: +--Testcase 206: INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ---Testcase 186: +--Testcase 207: INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); ---Testcase 187: +--Testcase 208: INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); ---Testcase 188: +--Testcase 209: INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); ---Testcase 189: +--Testcase 210: INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); ---Testcase 190: +--Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 191: +--Testcase 212: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ---Testcase 192: +--Testcase 213: SELECT * FROM "type_BIT+"; ---Testcase 193: +--Testcase 214: SELECT * FROM "type_BIT" WHERE b < '110110'; ---Testcase 194: +--Testcase 215: SELECT * FROM "type_BIT" WHERE b > '110110'; ---Testcase 195: +--Testcase 216: SELECT * FROM "type_BIT" WHERE b = '110110'; ---Testcase 196: +--Testcase 217: DROP FOREIGN TABLE IF EXISTS "type_VARBIT"; ---Testcase 197: +--Testcase 218: CREATE FOREIGN TABLE "type_VARBIT"( "i" int OPTIONS (key 'true'), "b" varbit(70)) SERVER sqlite_svr OPTIONS (table 'type_VARBIT'); ---Testcase 199: +--Testcase 219: DROP FOREIGN TABLE IF EXISTS "type_VARBIT+"; ---Testcase 200: +--Testcase 220: CREATE FOREIGN TABLE "type_VARBIT+"( "i" int OPTIONS (key 'true'), "b" varbit(70), "t" text, "l" smallint) SERVER sqlite_svr OPTIONS (table 'type_VARBIT+'); ---Testcase 201: +--Testcase 221: INSERT INTO "type_VARBIT" ("i", "b") VALUES (1, '1'); ---Testcase 202: +--Testcase 222: INSERT INTO "type_VARBIT" ("i", "b") VALUES (2, '10'); ---Testcase 203: +--Testcase 223: INSERT INTO "type_VARBIT" ("i", "b") VALUES (3, '11'); ---Testcase 204: +--Testcase 224: INSERT INTO "type_VARBIT" ("i", "b") VALUES (4, '100'); ---Testcase 205: +--Testcase 225: INSERT INTO "type_VARBIT" ("i", "b") VALUES (5, '101'); ---Testcase 206: +--Testcase 226: INSERT INTO "type_VARBIT" ("i", "b") VALUES (6, '110110'); ---Testcase 207: +--Testcase 227: INSERT INTO "type_VARBIT" ("i", "b") VALUES (7, '111001'); ---Testcase 208: +--Testcase 228: INSERT INTO "type_VARBIT" ("i", "b") VALUES (8, '110000'); ---Testcase 209: +--Testcase 229: INSERT INTO "type_VARBIT" ("i", "b") VALUES (9, '100001'); ---Testcase 210: +--Testcase 230: INSERT INTO "type_VARBIT" ("i", "b") VALUES (10, '0100100101011001010010101000111110110101101101111011000101010'); ---Testcase 211: +--Testcase 231: INSERT INTO "type_VARBIT" ("i", "b") VALUES (11, '01001001010110010100101010001111101101011011011110110001010101'); ---Testcase 212 +--Testcase 232 SELECT * FROM "type_VARBIT+"; ---Testcase 213: +--Testcase 233: SELECT * FROM "type_VARBIT+" WHERE b < '110110'; ---Testcase 214: +--Testcase 234: SELECT * FROM "type_VARBIT+" WHERE b > '110110'; ---Testcase 215: +--Testcase 235: SELECT * FROM "type_VARBIT+" WHERE b = '110110'; ---Testcase 216: +--Testcase 236: INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); ---Testcase 217: +--Testcase 237: INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 218: 65 b +--Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ---Testcase 219: +--Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; +--Testcase 240: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 241: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 242: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 243: +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; +--Testcase 244: +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; +--Testcase 245: +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; +--Testcase 246: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 247: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 248: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 249: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; +--Testcase 250: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; +--Testcase 251: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + +--Testcase 252: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 253: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 254: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 255: +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; +--Testcase 256: +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; +--Testcase 257: +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; +--Testcase 258: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 259: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 260: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 261: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; +--Testcase 262: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; +--Testcase 263: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/16.0/type.sql b/sql/16.0/type.sql index e4dcc86f..8740f3f4 100644 --- a/sql/16.0/type.sql +++ b/sql/16.0/type.sql @@ -549,10 +549,72 @@ SELECT * FROM "type_VARBIT+" WHERE b = '110110'; INSERT INTO "type_VARBIT" ("i", "b") VALUES (12, '010010010101100101001010100011111011010110110111101100010101010'); --Testcase 237: INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '0100100101011001010010101000111110110101101101111011000101010101'); ---Testcase 238: 65 b +--Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); --Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; +--Testcase 240: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 241: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 242: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 243: +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; +--Testcase 244: +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; +--Testcase 245: +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; +--Testcase 246: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 247: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 248: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +--Testcase 249: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; +--Testcase 250: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; +--Testcase 251: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; + +--Testcase 252: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 253: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 254: +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 255: +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; +--Testcase 256: +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; +--Testcase 257: +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; +--Testcase 258: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 259: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 260: +EXPLAIN VERBOSE +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 261: +EXPLAIN VERBOSE +SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; +--Testcase 262: +EXPLAIN VERBOSE +SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; +--Testcase 263: +EXPLAIN VERBOSE +SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sqlite_query.c b/sqlite_query.c index c8623f70..40a4e53b 100644 --- a/sqlite_query.c +++ b/sqlite_query.c @@ -39,7 +39,7 @@ int sqlite_bind_blob_algo (int attnum, Datum value, sqlite3_stmt * stmt); static char * sqlite_text_value_to_pg_db_encoding(sqlite3_stmt * stmt, int stmt_colid); -char * +static char * int642binstr(sqlite3_int64 num, char *s, size_t len); /* @@ -412,7 +412,8 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_stmt * stmt, int stmt_colid, * Common part of extracting and preparing PostgreSQL bytea data * for SQLite binding as blob */ -int sqlite_bind_blob_algo (int attnum, Datum value, sqlite3_stmt * stmt) +int +sqlite_bind_blob_algo (int attnum, Datum value, sqlite3_stmt * stmt) { int len; char *dat = NULL; @@ -661,7 +662,8 @@ sqlite_affinity_eqv_to_pgtype(Oid type) * Give equivalent string for SQLite data affinity by int from enum * SQLITE_INTEGER etc. */ -static const char* sqlite_datatype(int t) +static const char* +sqlite_datatype(int t) { static const char *azType[] = { "?", "integer", "real", "text", "blob", "null" }; switch (t) @@ -685,7 +687,8 @@ static const char* sqlite_datatype(int t) * Human readable message about disallowed combination of PostgreSQL columnn * data type and SQLite data value affinity */ -static void sqlite_value_to_pg_error (Form_pg_attribute att, sqlite3_stmt * stmt, int stmt_colid, int sqlite_value_affinity, int affinity_for_pg_column, int value_byte_size_blob_or_utf8) +static void +sqlite_value_to_pg_error (Form_pg_attribute att, sqlite3_stmt * stmt, int stmt_colid, int sqlite_value_affinity, int affinity_for_pg_column, int value_byte_size_blob_or_utf8) { Oid pgtyp = att->atttypid; int32 pgtypmod = att->atttypmod; @@ -714,7 +717,8 @@ static void sqlite_value_to_pg_error (Form_pg_attribute att, sqlite3_stmt * stmt } } -static char * sqlite_text_value_to_pg_db_encoding(sqlite3_stmt * stmt, int stmt_colid) +static char * +sqlite_text_value_to_pg_db_encoding(sqlite3_stmt * stmt, int stmt_colid) { int pg_database_encoding = GetDatabaseEncoding(); /* very fast call, see PostgreSQL mbutils.c */ char *utf8_text_value; @@ -733,7 +737,8 @@ static char * sqlite_text_value_to_pg_db_encoding(sqlite3_stmt * stmt, int stmt_ * Converts int64 from SQLite to PostgreSQL string from 0 and 1 only * s must be allocated with length not less than len + 1 bytes */ -char *int642binstr(sqlite3_int64 num, char *s, size_t len) +static char * +int642binstr(sqlite3_int64 num, char *s, size_t len) { s[--len] = '\0'; do @@ -745,10 +750,11 @@ char *int642binstr(sqlite3_int64 num, char *s, size_t len) /* * Converts PostgreSQL string from 0 and 1 only to int64 for SQLite */ -sqlite3_int64 binstr2int64(const char *s) +sqlite3_int64 +binstr2int64(const char *s) { sqlite3_int64 rc = 0; - char *bs = s; + char *bs = (char *)s; for (; '\0' != *bs; bs++) { @@ -768,3 +774,4 @@ sqlite3_int64 binstr2int64(const char *s) } return rc; } + From 77b0efb62db35bea88b8752d43ad6266bbcfcb00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Mon, 6 Nov 2023 13:47:07 +0300 Subject: [PATCH 08/14] Expand tests, fix operators `#` and `~` --- README.md | 17 +- deparse.c | 6 +- expected/12.15/type.out | 423 +++++++++++++++++++++++++++++++--------- expected/13.11/type.out | 290 ++++++++++++++++++++++++++- expected/14.8/type.out | 366 ++++++++++++++++++++++++++-------- expected/15.3/type.out | 290 ++++++++++++++++++++++++++- expected/16.0/type.out | 290 ++++++++++++++++++++++++++- sql/12.15/type.sql | 116 +++++++++-- sql/13.11/type.sql | 86 +++++++- sql/14.8/type.sql | 86 +++++++- sql/15.3/type.sql | 86 +++++++- sql/16.0/type.sql | 86 +++++++- sqlite_query.c | 3 +- 13 files changed, 1896 insertions(+), 249 deletions(-) diff --git a/README.md b/README.md index 1c5fce4e..a4b0b60f 100644 --- a/README.md +++ b/README.md @@ -523,7 +523,8 @@ Limitations for `INSERT` and `UPDATE` commands. ### bit and varbit support -- `sqlite_fdw` PostgreSQL `bit`/`varbit` values support based on `int` SQLite data affinity, because there is no per bit operations for SQLite `blob` affinity data. Maximum SQLite `int` affinity value is 8 bytes length, hence maximum `bit`/`varbit` values length is 64. +- `sqlite_fdw` PostgreSQL `bit`/`varbit` values support based on `int` SQLite data affinity, because there is no per bit operations for SQLite `blob` affinity data. Maximum SQLite `int` affinity value is 8 bytes length, hence maximum `bit`/`varbit` values length is 64 bits. +- `sqlite_fdw` doesn't support `#` (XOR) operator becasuse there is no equal SQLite operator. Tests ----- @@ -568,18 +569,22 @@ Contributing Opening issues and pull requests on GitHub are welcome. For pull request, please make sure these items below for testing: -- Create test cases (if needed) for the latest version of PostgreSQL supported by sqlite_fdw. +- Create test cases (if needed) for the latest version of PostgreSQL supported by `sqlite_fdw`. All error testcases should have a comment about test purpose. - Execute test cases and update expectations for the latest version of PostgreSQL - Test creation and execution for other PostgreSQL versions are welcome but not required. Preferred code style see in PostgreSQL source codes. For example ```C -for (;;) -{ -} -if () +type +funct_name (type arg ...) { + for (;;) + { + } + if () + { + } } ``` Useful links diff --git a/deparse.c b/deparse.c index 85f1ba68..288bd36a 100644 --- a/deparse.c +++ b/deparse.c @@ -2888,12 +2888,14 @@ sqlite_deparse_operator_name(StringInfo buf, Form_pg_operator opform) } else if (strcmp(cur_opname, "~~*") == 0 || strcmp(cur_opname, "!~~*") == 0 || - strcmp(cur_opname, "~") == 0 || + strcmp(cur_opname, "#") == 0 || strcmp(cur_opname, "!~") == 0 || strcmp(cur_opname, "~*") == 0 || strcmp(cur_opname, "!~*") == 0) { - elog(ERROR, "OPERATOR is not supported"); + ereport(ERROR, (errcode(ERRCODE_FDW_ERROR), + errmsg("SQL operator is not supported"), + errhint("operator name: %s", cur_opname))); } else diff --git a/expected/12.15/type.out b/expected/12.15/type.out index c4026514..27daa2df 100644 --- a/expected/12.15/type.out +++ b/expected/12.15/type.out @@ -499,7 +499,6 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; - --Testcase 108: DROP FOREIGN TABLE IF EXISTS "type_UUID"; --Testcase 109: @@ -1005,25 +1004,25 @@ DROP FOREIGN TABLE IF EXISTS "type_BIT+"; NOTICE: foreign table "type_BIT+" does not exist, skipping --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 203: +--Testcase 203: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 204: +--Testcase 204: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 205: +--Testcase 205: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ERROR: bit string length 1 does not match type bit(6) ---Testcase 206: +--Testcase 206: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ERROR: bit string length 2 does not match type bit(6) ---Testcase 207: +--Testcase 207: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); ERROR: bit string length 3 does not match type bit(6) --Testcase 208: @@ -1034,7 +1033,7 @@ INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); --Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 212: +--Testcase 212: type mismatch with proper data length INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); @@ -1167,7 +1166,7 @@ SELECT * FROM "type_VARBIT+" WHERE "i" > 10; (3 rows) --Testcase 240: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); i₁ | b₁ | i₂ | b₂ | res ----+--------+----+--------+-------- 6 | 110110 | 6 | 110110 | 110110 @@ -1189,7 +1188,7 @@ SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2." (16 rows) --Testcase 241: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); i₁ | b₁ | i₂ | b₂ | res ----+--------+----+--------+-------- 6 | 110110 | 6 | 110110 | 110110 @@ -1211,7 +1210,7 @@ SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2." (16 rows) --Testcase 242: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); i₁ | b₁ | i₂ | b₂ | res ----+--------+----+--------+-------- 6 | 110110 | 6 | 110110 | 000000 @@ -1264,54 +1263,33 @@ SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; --Testcase 246: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; - QUERY PLAN --------------------------------------------------------------------------------------------- - Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=100.00..73691.22 rows=1633932 width=58) Output: b1.i, b1.b, b2.i, b2.b, (b1.b | b2.b) - -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) - Output: b1.i, b1.b - SQLite query: SELECT `i`, `b` FROM main."type_BIT" - -> Materialize (cost=10.00..2225.07 rows=2214 width=13) - Output: b2.i, b2.b - -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) - Output: b2.i, b2.b - SQLite query: SELECT `i`, `b` FROM main."type_BIT" -(10 rows) + SQLite query: SELECT r1.`i`, r1.`b`, r2.`i`, r2.`b` FROM (main."type_BIT" r1 INNER JOIN main."type_BIT" r2 ON ((((r1.`b` >> 2) < (r1.`b` & r2.`b`))))) +(3 rows) --Testcase 247: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; - QUERY PLAN --------------------------------------------------------------------------------------------- - Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=100.00..73691.22 rows=1633932 width=58) Output: b1.i, b1.b, b2.i, b2.b, (b1.b & b2.b) - -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) - Output: b1.i, b1.b - SQLite query: SELECT `i`, `b` FROM main."type_BIT" - -> Materialize (cost=10.00..2225.07 rows=2214 width=13) - Output: b2.i, b2.b - -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) - Output: b2.i, b2.b - SQLite query: SELECT `i`, `b` FROM main."type_BIT" -(10 rows) + SQLite query: SELECT r1.`i`, r1.`b`, r2.`i`, r2.`b` FROM (main."type_BIT" r1 INNER JOIN main."type_BIT" r2 ON ((((r1.`b` >> 2) < (r1.`b` & r2.`b`))))) +(3 rows) --Testcase 248: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; - QUERY PLAN --------------------------------------------------------------------------------------------- - Nested Loop (cost=20.00..77960.48 rows=4901796 width=58) +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=100.00..73691.22 rows=1633932 width=58) Output: b1.i, b1.b, b2.i, b2.b, (b1.b # b2.b) - -> Foreign Scan on public."type_BIT" b1 (cost=10.00..2214.00 rows=2214 width=13) - Output: b1.i, b1.b - SQLite query: SELECT `i`, `b` FROM main."type_BIT" - -> Materialize (cost=10.00..2225.07 rows=2214 width=13) - Output: b2.i, b2.b - -> Foreign Scan on public."type_BIT" b2 (cost=10.00..2214.00 rows=2214 width=13) - Output: b2.i, b2.b - SQLite query: SELECT `i`, `b` FROM main."type_BIT" -(10 rows) + SQLite query: SELECT r1.`i`, r1.`b`, r2.`i`, r2.`b` FROM (main."type_BIT" r1 INNER JOIN main."type_BIT" r2 ON ((((r1.`b` >> 2) < (r1.`b` & r2.`b`))))) +(3 rows) --Testcase 249: EXPLAIN VERBOSE @@ -1343,14 +1321,14 @@ SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; SQLite query: SELECT `i`, `b` FROM main."type_BIT" (3 rows) ---Testcase 252: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 252: bit strings of different sizes +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); ERROR: cannot OR bit strings of different sizes ---Testcase 253: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 253: bit strings of different sizes +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); ERROR: cannot AND bit strings of different sizes ---Testcase 254: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 254: bit strings of different sizes +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); ERROR: cannot XOR bit strings of different sizes --Testcase 255: SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; @@ -1411,54 +1389,33 @@ SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; --Testcase 258: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; - QUERY PLAN ------------------------------------------------------------------------------------------------ - Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=100.00..49842.39 rows=1104133 width=74) Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" | (b2.b)::"bit") - -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) - Output: b1.i, b1.b - SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" - -> Materialize (cost=10.00..1829.10 rows=1820 width=21) - Output: b2.i, b2.b - -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) - Output: b2.i, b2.b - SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" -(10 rows) + SQLite query: SELECT r1.`i`, r1.`b`, r2.`i`, r2.`b` FROM (main."type_VARBIT" r1 INNER JOIN main."type_VARBIT" r2 ON ((((r1.`b` >> 2) < (r1.`b` & r2.`b`))))) +(3 rows) --Testcase 259: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; - QUERY PLAN ------------------------------------------------------------------------------------------------ - Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=100.00..49842.39 rows=1104133 width=74) Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" & (b2.b)::"bit") - -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) - Output: b1.i, b1.b - SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" - -> Materialize (cost=10.00..1829.10 rows=1820 width=21) - Output: b2.i, b2.b - -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) - Output: b2.i, b2.b - SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" -(10 rows) + SQLite query: SELECT r1.`i`, r1.`b`, r2.`i`, r2.`b` FROM (main."type_VARBIT" r1 INNER JOIN main."type_VARBIT" r2 ON ((((r1.`b` >> 2) < (r1.`b` & r2.`b`))))) +(3 rows) --Testcase 260: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; - QUERY PLAN ------------------------------------------------------------------------------------------------ - Nested Loop (cost=20.00..53330.55 rows=3312400 width=74) +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=100.00..49842.39 rows=1104133 width=74) Output: b1.i, b1.b, b2.i, b2.b, ((b1.b)::"bit" # (b2.b)::"bit") - -> Foreign Scan on public."type_VARBIT" b1 (cost=10.00..1820.00 rows=1820 width=21) - Output: b1.i, b1.b - SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" - -> Materialize (cost=10.00..1829.10 rows=1820 width=21) - Output: b2.i, b2.b - -> Foreign Scan on public."type_VARBIT" b2 (cost=10.00..1820.00 rows=1820 width=21) - Output: b2.i, b2.b - SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" -(10 rows) + SQLite query: SELECT r1.`i`, r1.`b`, r2.`i`, r2.`b` FROM (main."type_VARBIT" r1 INNER JOIN main."type_VARBIT" r2 ON ((((r1.`b` >> 2) < (r1.`b` & r2.`b`))))) +(3 rows) --Testcase 261: EXPLAIN VERBOSE @@ -1490,6 +1447,284 @@ SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" (3 rows) +--Testcase 264: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 100010 + 7 | 111001 | 101001 + 8 | 110000 | 100000 + 9 | 100001 | 100001 +(4 rows) + +--Testcase 265: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 111111 + 7 | 111001 | 111011 + 8 | 110000 | 111011 + 9 | 100001 | 101011 +(4 rows) + +--Testcase 266: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 011101 + 7 | 111001 | 010010 + 8 | 110000 | 011011 + 9 | 100001 | 001010 +(4 rows) + +--Testcase 267: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 268: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 269: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 270: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 271: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 272: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 273: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` & 43) IS NOT NULL)) +(3 rows) + +--Testcase 274: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` | 43) IS NOT NULL)) +(3 rows) + +--Testcase 275: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 276: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` >> 1) IS NOT NULL)) +(3 rows) + +--Testcase 277: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` << 2) IS NOT NULL)) +(3 rows) + +--Testcase 278: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((~ `b`) IS NOT NULL)) +(3 rows) + +--Testcase 279: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 100010 + 7 | 111001 | 101001 + 8 | 110000 | 100000 + 9 | 100001 | 100001 +(4 rows) + +--Testcase 280: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 111111 + 7 | 111001 | 111011 + 8 | 110000 | 111011 + 9 | 100001 | 101011 +(4 rows) + +--Testcase 281: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 011101 + 7 | 111001 | 010010 + 8 | 110000 | 011011 + 9 | 100001 | 001010 +(4 rows) + +--Testcase 282: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 283: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 284: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 285: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 286: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 287: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 288: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` & 43) IS NOT NULL)) +(3 rows) + +--Testcase 289: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` | 43) IS NOT NULL)) +(3 rows) + +--Testcase 290: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 291: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` >> 1) IS NOT NULL)) +(3 rows) + +--Testcase 292: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` << 2) IS NOT NULL)) +(3 rows) + +--Testcase 293: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((~ `b`) IS NOT NULL)) +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; NOTICE: drop cascades to 48 other objects diff --git a/expected/13.11/type.out b/expected/13.11/type.out index 3929e822..6ec76ba6 100644 --- a/expected/13.11/type.out +++ b/expected/13.11/type.out @@ -508,25 +508,25 @@ DROP FOREIGN TABLE IF EXISTS "type_BIT+"; NOTICE: foreign table "type_BIT+" does not exist, skipping --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 203: +--Testcase 203: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 204: +--Testcase 204: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 205: +--Testcase 205: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ERROR: bit string length 1 does not match type bit(6) ---Testcase 206: +--Testcase 206: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ERROR: bit string length 2 does not match type bit(6) ---Testcase 207: +--Testcase 207: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); ERROR: bit string length 3 does not match type bit(6) --Testcase 208: @@ -537,7 +537,7 @@ INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); --Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 212: +--Testcase 212: type mismatch with proper data length INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); @@ -993,6 +993,284 @@ SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" (3 rows) +--Testcase 264: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 100010 + 7 | 111001 | 101001 + 8 | 110000 | 100000 + 9 | 100001 | 100001 +(4 rows) + +--Testcase 265: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 111111 + 7 | 111001 | 111011 + 8 | 110000 | 111011 + 9 | 100001 | 101011 +(4 rows) + +--Testcase 266: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 011101 + 7 | 111001 | 010010 + 8 | 110000 | 011011 + 9 | 100001 | 001010 +(4 rows) + +--Testcase 267: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 268: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 269: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 270: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 271: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 272: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 273: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` & 43) IS NOT NULL)) +(3 rows) + +--Testcase 274: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` | 43) IS NOT NULL)) +(3 rows) + +--Testcase 275: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 276: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` >> 1) IS NOT NULL)) +(3 rows) + +--Testcase 277: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` << 2) IS NOT NULL)) +(3 rows) + +--Testcase 278: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((~ `b`) IS NOT NULL)) +(3 rows) + +--Testcase 279: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 100010 + 7 | 111001 | 101001 + 8 | 110000 | 100000 + 9 | 100001 | 100001 +(4 rows) + +--Testcase 280: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 111111 + 7 | 111001 | 111011 + 8 | 110000 | 111011 + 9 | 100001 | 101011 +(4 rows) + +--Testcase 281: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 011101 + 7 | 111001 | 010010 + 8 | 110000 | 011011 + 9 | 100001 | 001010 +(4 rows) + +--Testcase 282: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 283: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 284: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 285: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 286: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 287: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 288: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` & 43) IS NOT NULL)) +(3 rows) + +--Testcase 289: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` | 43) IS NOT NULL)) +(3 rows) + +--Testcase 290: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 291: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` >> 1) IS NOT NULL)) +(3 rows) + +--Testcase 292: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` << 2) IS NOT NULL)) +(3 rows) + +--Testcase 293: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((~ `b`) IS NOT NULL)) +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; NOTICE: drop cascades to 47 other objects diff --git a/expected/14.8/type.out b/expected/14.8/type.out index 10eb1cd8..6ec76ba6 100644 --- a/expected/14.8/type.out +++ b/expected/14.8/type.out @@ -499,82 +499,6 @@ SELECT * FROM "type_DOUBLE"; -- OK --Testcase 107: ALTER FOREIGN TABLE "type_DOUBLE" ALTER COLUMN col TYPE float8; ---Testcase 178: -DROP FOREIGN TABLE IF EXISTS "type_BIT"; ---Testcase 179: -CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT'); ---Testcase 180: -DROP FOREIGN TABLE IF EXISTS "type_BIT+"; -NOTICE: foreign table "type_BIT+" does not exist, skipping ---Testcase 181: -CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 182: -INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); -ERROR: column "b" is of type bit but expression is of type integer -LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); - ^ -HINT: You will need to rewrite or cast the expression. ---Testcase 183: -INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); -ERROR: column "b" is of type bit but expression is of type integer -LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); - ^ -HINT: You will need to rewrite or cast the expression. ---Testcase 184: -INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); -ERROR: bit string length 1 does not match type bit(6) ---Testcase 185: -INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); -ERROR: bit string length 2 does not match type bit(6) ---Testcase 186: -INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); -ERROR: bit string length 3 does not match type bit(6) ---Testcase 187: -INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); ---Testcase 188: -INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); ---Testcase 189: -INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); ---Testcase 190: -INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 191: -INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); -ERROR: column "b" is of type bit but expression is of type integer -LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); - ^ -HINT: You will need to rewrite or cast the expression. ---Testcase 192: -SELECT * FROM "type_BIT+"; - i | b | t | l | bi ----+--------+---------+---+---- - 6 | 110110 | integer | 2 | 54 - 7 | 111001 | integer | 2 | 57 - 8 | 110000 | integer | 2 | 48 - 9 | 100001 | integer | 2 | 33 -(4 rows) - ---Testcase 193: -SELECT * FROM "type_BIT" WHERE b < '110110'; - i | b ----+-------- - 8 | 110000 - 9 | 100001 -(2 rows) - ---Testcase 194: -SELECT * FROM "type_BIT" WHERE b > '110110'; - i | b ----+-------- - 7 | 111001 -(1 row) - ---Testcase 195: -SELECT * FROM "type_BIT" WHERE b = '110110'; - i | b ----+-------- - 6 | 110110 -(1 row) - --Testcase 199: DROP FOREIGN TABLE IF EXISTS "type_BIT"; --Testcase 200: @@ -584,25 +508,25 @@ DROP FOREIGN TABLE IF EXISTS "type_BIT+"; NOTICE: foreign table "type_BIT+" does not exist, skipping --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 203: +--Testcase 203: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 204: +--Testcase 204: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 205: +--Testcase 205: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ERROR: bit string length 1 does not match type bit(6) ---Testcase 206: +--Testcase 206: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ERROR: bit string length 2 does not match type bit(6) ---Testcase 207: +--Testcase 207: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); ERROR: bit string length 3 does not match type bit(6) --Testcase 208: @@ -613,7 +537,7 @@ INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); --Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 212: +--Testcase 212: type mismatch with proper data length INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); @@ -1069,6 +993,284 @@ SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" (3 rows) +--Testcase 264: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 100010 + 7 | 111001 | 101001 + 8 | 110000 | 100000 + 9 | 100001 | 100001 +(4 rows) + +--Testcase 265: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 111111 + 7 | 111001 | 111011 + 8 | 110000 | 111011 + 9 | 100001 | 101011 +(4 rows) + +--Testcase 266: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 011101 + 7 | 111001 | 010010 + 8 | 110000 | 011011 + 9 | 100001 | 001010 +(4 rows) + +--Testcase 267: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 268: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 269: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 270: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 271: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 272: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 273: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` & 43) IS NOT NULL)) +(3 rows) + +--Testcase 274: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` | 43) IS NOT NULL)) +(3 rows) + +--Testcase 275: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 276: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` >> 1) IS NOT NULL)) +(3 rows) + +--Testcase 277: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` << 2) IS NOT NULL)) +(3 rows) + +--Testcase 278: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((~ `b`) IS NOT NULL)) +(3 rows) + +--Testcase 279: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 100010 + 7 | 111001 | 101001 + 8 | 110000 | 100000 + 9 | 100001 | 100001 +(4 rows) + +--Testcase 280: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 111111 + 7 | 111001 | 111011 + 8 | 110000 | 111011 + 9 | 100001 | 101011 +(4 rows) + +--Testcase 281: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 011101 + 7 | 111001 | 010010 + 8 | 110000 | 011011 + 9 | 100001 | 001010 +(4 rows) + +--Testcase 282: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 283: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 284: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 285: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 286: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 287: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 288: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` & 43) IS NOT NULL)) +(3 rows) + +--Testcase 289: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` | 43) IS NOT NULL)) +(3 rows) + +--Testcase 290: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 291: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` >> 1) IS NOT NULL)) +(3 rows) + +--Testcase 292: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` << 2) IS NOT NULL)) +(3 rows) + +--Testcase 293: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((~ `b`) IS NOT NULL)) +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; NOTICE: drop cascades to 47 other objects diff --git a/expected/15.3/type.out b/expected/15.3/type.out index 3929e822..6ec76ba6 100644 --- a/expected/15.3/type.out +++ b/expected/15.3/type.out @@ -508,25 +508,25 @@ DROP FOREIGN TABLE IF EXISTS "type_BIT+"; NOTICE: foreign table "type_BIT+" does not exist, skipping --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 203: +--Testcase 203: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 204: +--Testcase 204: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 205: +--Testcase 205: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ERROR: bit string length 1 does not match type bit(6) ---Testcase 206: +--Testcase 206: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ERROR: bit string length 2 does not match type bit(6) ---Testcase 207: +--Testcase 207: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); ERROR: bit string length 3 does not match type bit(6) --Testcase 208: @@ -537,7 +537,7 @@ INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); --Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 212: +--Testcase 212: type mismatch with proper data length INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); @@ -993,6 +993,284 @@ SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" (3 rows) +--Testcase 264: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 100010 + 7 | 111001 | 101001 + 8 | 110000 | 100000 + 9 | 100001 | 100001 +(4 rows) + +--Testcase 265: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 111111 + 7 | 111001 | 111011 + 8 | 110000 | 111011 + 9 | 100001 | 101011 +(4 rows) + +--Testcase 266: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 011101 + 7 | 111001 | 010010 + 8 | 110000 | 011011 + 9 | 100001 | 001010 +(4 rows) + +--Testcase 267: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 268: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 269: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 270: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 271: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 272: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 273: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` & 43) IS NOT NULL)) +(3 rows) + +--Testcase 274: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` | 43) IS NOT NULL)) +(3 rows) + +--Testcase 275: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 276: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` >> 1) IS NOT NULL)) +(3 rows) + +--Testcase 277: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` << 2) IS NOT NULL)) +(3 rows) + +--Testcase 278: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((~ `b`) IS NOT NULL)) +(3 rows) + +--Testcase 279: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 100010 + 7 | 111001 | 101001 + 8 | 110000 | 100000 + 9 | 100001 | 100001 +(4 rows) + +--Testcase 280: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 111111 + 7 | 111001 | 111011 + 8 | 110000 | 111011 + 9 | 100001 | 101011 +(4 rows) + +--Testcase 281: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 011101 + 7 | 111001 | 010010 + 8 | 110000 | 011011 + 9 | 100001 | 001010 +(4 rows) + +--Testcase 282: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 283: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 284: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 285: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 286: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 287: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 288: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` & 43) IS NOT NULL)) +(3 rows) + +--Testcase 289: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` | 43) IS NOT NULL)) +(3 rows) + +--Testcase 290: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 291: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` >> 1) IS NOT NULL)) +(3 rows) + +--Testcase 292: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` << 2) IS NOT NULL)) +(3 rows) + +--Testcase 293: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((~ `b`) IS NOT NULL)) +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; NOTICE: drop cascades to 47 other objects diff --git a/expected/16.0/type.out b/expected/16.0/type.out index 60425acf..363ed213 100644 --- a/expected/16.0/type.out +++ b/expected/16.0/type.out @@ -1006,25 +1006,25 @@ DROP FOREIGN TABLE IF EXISTS "type_BIT+"; NOTICE: foreign table "type_BIT+" does not exist, skipping --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 203: +--Testcase 203: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 204: +--Testcase 204: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ^ HINT: You will need to rewrite or cast the expression. ---Testcase 205: +--Testcase 205: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ERROR: bit string length 1 does not match type bit(6) ---Testcase 206: +--Testcase 206: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ERROR: bit string length 2 does not match type bit(6) ---Testcase 207: +--Testcase 207: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); ERROR: bit string length 3 does not match type bit(6) --Testcase 208: @@ -1035,7 +1035,7 @@ INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); --Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 212: +--Testcase 212: type mismatch with proper data length INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); ERROR: column "b" is of type bit but expression is of type integer LINE 1: INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); @@ -1491,6 +1491,284 @@ SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; SQLite query: SELECT `i`, `b` FROM main."type_VARBIT" (3 rows) +--Testcase 264: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 100010 + 7 | 111001 | 101001 + 8 | 110000 | 100000 + 9 | 100001 | 100001 +(4 rows) + +--Testcase 265: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 111111 + 7 | 111001 | 111011 + 8 | 110000 | 111011 + 9 | 100001 | 101011 +(4 rows) + +--Testcase 266: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 011101 + 7 | 111001 | 010010 + 8 | 110000 | 011011 + 9 | 100001 | 001010 +(4 rows) + +--Testcase 267: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 268: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 269: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 270: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 271: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 272: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 273: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` & 43) IS NOT NULL)) +(3 rows) + +--Testcase 274: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` | 43) IS NOT NULL)) +(3 rows) + +--Testcase 275: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 276: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` >> 1) IS NOT NULL)) +(3 rows) + +--Testcase 277: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` << 2) IS NOT NULL)) +(3 rows) + +--Testcase 278: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((~ `b`) IS NOT NULL)) +(3 rows) + +--Testcase 279: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 100010 + 7 | 111001 | 101001 + 8 | 110000 | 100000 + 9 | 100001 | 100001 +(4 rows) + +--Testcase 280: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 111111 + 7 | 111001 | 111011 + 8 | 110000 | 111011 + 9 | 100001 | 101011 +(4 rows) + +--Testcase 281: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; + i | b | res +---+--------+-------- + 6 | 110110 | 011101 + 7 | 111001 | 010010 + 8 | 110000 | 011011 + 9 | 100001 | 001010 +(4 rows) + +--Testcase 282: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 283: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 284: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 285: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 286: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 287: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + +--Testcase 288: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` & 43) IS NOT NULL)) +(3 rows) + +--Testcase 289: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` | 43) IS NOT NULL)) +(3 rows) + +--Testcase 290: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +ERROR: SQL operator is not supported +HINT: operator name: # +--Testcase 291: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` >> 1) IS NOT NULL)) +(3 rows) + +--Testcase 292: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((`b` << 2) IS NOT NULL)) +(3 rows) + +--Testcase 293: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + SQLite query: SELECT `i`, `b` FROM main."type_BIT" WHERE (((~ `b`) IS NOT NULL)) +(3 rows) + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; NOTICE: drop cascades to 48 other objects diff --git a/sql/12.15/type.sql b/sql/12.15/type.sql index 8740f3f4..0be2fcfd 100644 --- a/sql/12.15/type.sql +++ b/sql/12.15/type.sql @@ -476,15 +476,15 @@ CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVE DROP FOREIGN TABLE IF EXISTS "type_BIT+"; --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 203: +--Testcase 203: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ---Testcase 204: +--Testcase 204: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ---Testcase 205: +--Testcase 205: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ---Testcase 206: +--Testcase 206: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ---Testcase 207: +--Testcase 207: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); --Testcase 208: INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); @@ -494,7 +494,7 @@ INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); --Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 212: +--Testcase 212: type mismatch with proper data length INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); --Testcase 213: SELECT * FROM "type_BIT+"; @@ -555,11 +555,11 @@ INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '010010010101100101001010100011 SELECT * FROM "type_VARBIT+" WHERE "i" > 10; --Testcase 240: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); --Testcase 241: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); --Testcase 242: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); --Testcase 243: SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; --Testcase 244: @@ -568,13 +568,13 @@ SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; --Testcase 246: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); --Testcase 247: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); --Testcase 248: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_BIT" b1 INNER JOIN "type_BIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); --Testcase 249: EXPLAIN VERBOSE SELECT "i", "b", "b" >> 2 "res" FROM "type_BIT"; @@ -585,12 +585,12 @@ SELECT "i", "b", "b" << 3 "res" FROM "type_BIT"; EXPLAIN VERBOSE SELECT "i", "b", ~ "b" "res" FROM "type_BIT"; ---Testcase 252: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; ---Testcase 253: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; ---Testcase 254: -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +--Testcase 252: bit strings of different sizes +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); +--Testcase 253: bit strings of different sizes +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); +--Testcase 254: bit strings of different sizes +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); --Testcase 255: SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; --Testcase 256: @@ -599,13 +599,13 @@ SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; --Testcase 258: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" | b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); --Testcase 259: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" & b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); --Testcase 260: EXPLAIN VERBOSE -SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true; +SELECT b1."i" "i₁", b1."b" "b₁", b2."i" "i₂", b2."b" "b₂", b1."b" # b2."b" "res" FROM "type_VARBIT" b1 INNER JOIN "type_VARBIT" b2 ON true WHERE (b1."b" >> 2) < (b1."b" & b2."b"); --Testcase 261: EXPLAIN VERBOSE SELECT "i", "b", "b" >> 2 "res" FROM "type_VARBIT"; @@ -616,5 +616,79 @@ SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; EXPLAIN VERBOSE SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; +--Testcase 264: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; +--Testcase 265: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; +--Testcase 266: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; +--Testcase 267: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 268: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 269: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 270: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 271: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 272: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; +--Testcase 273: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 274: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 275: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 276: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 277: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 278: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + +--Testcase 279: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; +--Testcase 280: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; +--Testcase 281: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; +--Testcase 282: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 283: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 284: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 285: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 286: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 287: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; +--Testcase 288: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 289: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 290: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 291: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 292: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 293: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/13.11/type.sql b/sql/13.11/type.sql index 5f638cb1..c1310ab5 100644 --- a/sql/13.11/type.sql +++ b/sql/13.11/type.sql @@ -274,15 +274,15 @@ CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVE DROP FOREIGN TABLE IF EXISTS "type_BIT+"; --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 203: +--Testcase 203: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ---Testcase 204: +--Testcase 204: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ---Testcase 205: +--Testcase 205: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ---Testcase 206: +--Testcase 206: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ---Testcase 207: +--Testcase 207: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); --Testcase 208: INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); @@ -292,7 +292,7 @@ INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); --Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 212: +--Testcase 212: type mismatch with proper data length INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); --Testcase 213: SELECT * FROM "type_BIT+"; @@ -414,5 +414,79 @@ SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; EXPLAIN VERBOSE SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; +--Testcase 264: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; +--Testcase 265: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; +--Testcase 266: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; +--Testcase 267: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 268: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 269: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 270: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 271: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 272: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; +--Testcase 273: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 274: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 275: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 276: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 277: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 278: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + +--Testcase 279: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; +--Testcase 280: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; +--Testcase 281: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; +--Testcase 282: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 283: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 284: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 285: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 286: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 287: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; +--Testcase 288: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 289: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 290: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 291: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 292: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 293: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/14.8/type.sql b/sql/14.8/type.sql index 5f638cb1..c1310ab5 100644 --- a/sql/14.8/type.sql +++ b/sql/14.8/type.sql @@ -274,15 +274,15 @@ CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVE DROP FOREIGN TABLE IF EXISTS "type_BIT+"; --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 203: +--Testcase 203: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ---Testcase 204: +--Testcase 204: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ---Testcase 205: +--Testcase 205: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ---Testcase 206: +--Testcase 206: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ---Testcase 207: +--Testcase 207: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); --Testcase 208: INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); @@ -292,7 +292,7 @@ INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); --Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 212: +--Testcase 212: type mismatch with proper data length INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); --Testcase 213: SELECT * FROM "type_BIT+"; @@ -414,5 +414,79 @@ SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; EXPLAIN VERBOSE SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; +--Testcase 264: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; +--Testcase 265: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; +--Testcase 266: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; +--Testcase 267: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 268: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 269: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 270: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 271: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 272: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; +--Testcase 273: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 274: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 275: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 276: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 277: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 278: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + +--Testcase 279: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; +--Testcase 280: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; +--Testcase 281: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; +--Testcase 282: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 283: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 284: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 285: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 286: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 287: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; +--Testcase 288: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 289: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 290: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 291: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 292: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 293: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/15.3/type.sql b/sql/15.3/type.sql index 5f638cb1..c1310ab5 100644 --- a/sql/15.3/type.sql +++ b/sql/15.3/type.sql @@ -274,15 +274,15 @@ CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVE DROP FOREIGN TABLE IF EXISTS "type_BIT+"; --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 203: +--Testcase 203: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ---Testcase 204: +--Testcase 204: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ---Testcase 205: +--Testcase 205: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ---Testcase 206: +--Testcase 206: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ---Testcase 207: +--Testcase 207: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); --Testcase 208: INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); @@ -292,7 +292,7 @@ INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); --Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 212: +--Testcase 212: type mismatch with proper data length INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); --Testcase 213: SELECT * FROM "type_BIT+"; @@ -414,5 +414,79 @@ SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; EXPLAIN VERBOSE SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; +--Testcase 264: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; +--Testcase 265: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; +--Testcase 266: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; +--Testcase 267: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 268: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 269: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 270: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 271: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 272: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; +--Testcase 273: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 274: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 275: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 276: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 277: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 278: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + +--Testcase 279: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; +--Testcase 280: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; +--Testcase 281: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; +--Testcase 282: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 283: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 284: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 285: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 286: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 287: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; +--Testcase 288: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 289: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 290: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 291: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 292: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 293: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sql/16.0/type.sql b/sql/16.0/type.sql index 8740f3f4..bf6d2c48 100644 --- a/sql/16.0/type.sql +++ b/sql/16.0/type.sql @@ -476,15 +476,15 @@ CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVE DROP FOREIGN TABLE IF EXISTS "type_BIT+"; --Testcase 202: CREATE FOREIGN TABLE "type_BIT+"( "i" int OPTIONS (key 'true'), "b" bit(6), "t" text, "l" smallint, "bi" bigint OPTIONS (column_name 'b')) SERVER sqlite_svr OPTIONS (table 'type_BIT+'); ---Testcase 203: +--Testcase 203: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (1, 1); ---Testcase 204: +--Testcase 204: type mismatch INSERT INTO "type_BIT" ("i", "b") VALUES (2, 2); ---Testcase 205: +--Testcase 205: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (3, '1'); ---Testcase 206: +--Testcase 206: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (4, '10'); ---Testcase 207: +--Testcase 207: improper data length INSERT INTO "type_BIT" ("i", "b") VALUES (5, '101'); --Testcase 208: INSERT INTO "type_BIT" ("i", "b") VALUES (6, '110110'); @@ -494,7 +494,7 @@ INSERT INTO "type_BIT" ("i", "b") VALUES (7, '111001'); INSERT INTO "type_BIT" ("i", "b") VALUES (8, '110000'); --Testcase 211: INSERT INTO "type_BIT" ("i", "b") VALUES (9, '100001'); ---Testcase 212: +--Testcase 212: type mismatch with proper data length INSERT INTO "type_BIT" ("i", "b") VALUES (10, 53); --Testcase 213: SELECT * FROM "type_BIT+"; @@ -616,5 +616,79 @@ SELECT "i", "b", "b" << 3 "res" FROM "type_VARBIT"; EXPLAIN VERBOSE SELECT "i", "b", ~ "b" "res" FROM "type_VARBIT"; +--Testcase 264: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; +--Testcase 265: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; +--Testcase 266: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; +--Testcase 267: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 268: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 269: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 270: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 271: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 272: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; +--Testcase 273: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 274: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 275: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 276: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 277: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 278: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + +--Testcase 279: +SELECT "i", "b", "b" & B'101011' "res" FROM "type_BIT"; +--Testcase 280: +SELECT "i", "b", "b" | B'101011' "res" FROM "type_BIT"; +--Testcase 281: +SELECT "i", "b", "b" # B'101011' "res" FROM "type_BIT"; +--Testcase 282: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 283: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 284: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 285: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 286: +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 287: +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; +--Testcase 288: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" & B'101011') IS NOT NULL; +--Testcase 289: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; +--Testcase 290: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; +--Testcase 291: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; +--Testcase 292: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE ("b" << 2) IS NOT NULL; +--Testcase 293: +EXPLAIN VERBOSE +SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL; + --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; diff --git a/sqlite_query.c b/sqlite_query.c index 40a4e53b..fd677f28 100644 --- a/sqlite_query.c +++ b/sqlite_query.c @@ -379,8 +379,8 @@ sqlite_convert_to_pg(Form_pg_attribute att, sqlite3_stmt * stmt, int stmt_colid, case BITOID: { char * buffer = (char *) palloc0(SQLITE_FDW_BIT_DATATYPE_BUF_SIZE); - sqlite3_int64 sqlti = sqlite3_column_int64(stmt, stmt_colid); + buffer = int642binstr(sqlti, buffer, SQLITE_FDW_BIT_DATATYPE_BUF_SIZE); valstr = buffer; elog(DEBUG4, "sqlite_fdw : BIT buf l=%ld v = %s", SQLITE_FDW_BIT_DATATYPE_BUF_SIZE, buffer); @@ -774,4 +774,3 @@ binstr2int64(const char *s) } return rc; } - From d2c8e3b18c240128db35f3ccede33b93bf24e874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 7 Nov 2023 09:02:19 +0300 Subject: [PATCH 09/14] Fix `~` and `#` operators --- README.md | 3 ++- deparse.c | 21 +++++++++++---------- expected/12.15/type.out | 40 ++++++++++++++++++++++++++++++++-------- expected/13.11/type.out | 40 ++++++++++++++++++++++++++++++++-------- expected/14.8/type.out | 40 ++++++++++++++++++++++++++++++++-------- expected/15.3/type.out | 40 ++++++++++++++++++++++++++++++++-------- expected/16.0/type.out | 40 ++++++++++++++++++++++++++++++++-------- 7 files changed, 173 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index a4b0b60f..dbf8d9e3 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Features - `mod()` is pushdowned. In PostgreSQL gives [argument-dependend data type](https://www.postgresql.org/docs/current/functions-math.html), but result from SQLite always [have `real` affinity](https://www.sqlite.org/lang_mathfunc.html#mod). - `upper`, `lower` and other character case functions are **not** pushed down because they does not work with UNICODE character in SQLite. - `WITH TIES` option is **not** pushed down. +- Bit string `#` (XOR) operator is **not** pushed down becasuse there is no equal SQLite operator. ### Notes about pushdowning @@ -524,7 +525,7 @@ for `INSERT` and `UPDATE` commands. ### bit and varbit support - `sqlite_fdw` PostgreSQL `bit`/`varbit` values support based on `int` SQLite data affinity, because there is no per bit operations for SQLite `blob` affinity data. Maximum SQLite `int` affinity value is 8 bytes length, hence maximum `bit`/`varbit` values length is 64 bits. -- `sqlite_fdw` doesn't support `#` (XOR) operator becasuse there is no equal SQLite operator. +- `sqlite_fdw` doesn't pushdown `#` (XOR) operator becasuse there is no equal SQLite operator. Tests ----- diff --git a/deparse.c b/deparse.c index 288bd36a..3466e9d5 100644 --- a/deparse.c +++ b/deparse.c @@ -675,17 +675,17 @@ sqlite_foreign_expr_walker(Node *node, ReleaseSysCache(tuple); /* - * Factorial (!) and Bitwise XOR (^) cannot be pushed down to - * SQLite + * Factorial (!) and Bitwise XOR (^), (#) + * cannot be pushed down to SQLite + * Full list see in https://www.postgresql.org/docs/current/functions-bitstring.html + * ILIKE cannot be pushed down to SQLite + * Full list see in https://www.postgresql.org/docs/current/functions-matching.html */ if (strcmp(cur_opname, "!") == 0 - || strcmp(cur_opname, "^") == 0) - { - return false; - } - - /* ILIKE cannot be pushed down to SQLite */ - if (strcmp(cur_opname, "~~*") == 0 || strcmp(cur_opname, "!~~*") == 0) + || strcmp(cur_opname, "^") == 0 + || strcmp(cur_opname, "#") == 0 + || strcmp(cur_opname, "~~*") == 0 + || strcmp(cur_opname, "!~~*") == 0) { return false; } @@ -2888,7 +2888,8 @@ sqlite_deparse_operator_name(StringInfo buf, Form_pg_operator opform) } else if (strcmp(cur_opname, "~~*") == 0 || strcmp(cur_opname, "!~~*") == 0 || - strcmp(cur_opname, "#") == 0 || + /* ~ operator are both one of text RegEx operators and bit string NOT */ + (strcmp(cur_opname, "~") == 0 && opform->oprresult != VARBITOID && opform->oprresult != BITOID) || strcmp(cur_opname, "!~") == 0 || strcmp(cur_opname, "~*") == 0 || strcmp(cur_opname, "!~*") == 0) diff --git a/expected/12.15/type.out b/expected/12.15/type.out index 27daa2df..43a377a2 100644 --- a/expected/12.15/type.out +++ b/expected/12.15/type.out @@ -1499,8 +1499,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 269: SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + --Testcase 270: SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; i | b @@ -1554,8 +1560,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 275: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + Filter: (("type_BIT".b # '101011'::"bit") IS NOT NULL) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(4 rows) + --Testcase 276: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; @@ -1638,8 +1650,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 284: SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + --Testcase 285: SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; i | b @@ -1693,8 +1711,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 290: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + Filter: (("type_BIT".b # '101011'::"bit") IS NOT NULL) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(4 rows) + --Testcase 291: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; diff --git a/expected/13.11/type.out b/expected/13.11/type.out index 6ec76ba6..cb41214b 100644 --- a/expected/13.11/type.out +++ b/expected/13.11/type.out @@ -1045,8 +1045,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 269: SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + --Testcase 270: SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; i | b @@ -1100,8 +1106,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 275: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + Filter: (("type_BIT".b # '101011'::"bit") IS NOT NULL) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(4 rows) + --Testcase 276: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; @@ -1184,8 +1196,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 284: SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + --Testcase 285: SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; i | b @@ -1239,8 +1257,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 290: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + Filter: (("type_BIT".b # '101011'::"bit") IS NOT NULL) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(4 rows) + --Testcase 291: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; diff --git a/expected/14.8/type.out b/expected/14.8/type.out index 6ec76ba6..cb41214b 100644 --- a/expected/14.8/type.out +++ b/expected/14.8/type.out @@ -1045,8 +1045,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 269: SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + --Testcase 270: SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; i | b @@ -1100,8 +1106,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 275: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + Filter: (("type_BIT".b # '101011'::"bit") IS NOT NULL) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(4 rows) + --Testcase 276: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; @@ -1184,8 +1196,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 284: SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + --Testcase 285: SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; i | b @@ -1239,8 +1257,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 290: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + Filter: (("type_BIT".b # '101011'::"bit") IS NOT NULL) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(4 rows) + --Testcase 291: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; diff --git a/expected/15.3/type.out b/expected/15.3/type.out index 6ec76ba6..cb41214b 100644 --- a/expected/15.3/type.out +++ b/expected/15.3/type.out @@ -1045,8 +1045,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 269: SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + --Testcase 270: SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; i | b @@ -1100,8 +1106,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 275: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + Filter: (("type_BIT".b # '101011'::"bit") IS NOT NULL) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(4 rows) + --Testcase 276: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; @@ -1184,8 +1196,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 284: SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + --Testcase 285: SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; i | b @@ -1239,8 +1257,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 290: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + Filter: (("type_BIT".b # '101011'::"bit") IS NOT NULL) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(4 rows) + --Testcase 291: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; diff --git a/expected/16.0/type.out b/expected/16.0/type.out index 363ed213..7f23289d 100644 --- a/expected/16.0/type.out +++ b/expected/16.0/type.out @@ -1543,8 +1543,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 269: SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + --Testcase 270: SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; i | b @@ -1598,8 +1604,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 275: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + Filter: (("type_BIT".b # '101011'::"bit") IS NOT NULL) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(4 rows) + --Testcase 276: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; @@ -1682,8 +1694,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 284: SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + i | b +---+-------- + 6 | 110110 + 7 | 111001 + 8 | 110000 + 9 | 100001 +(4 rows) + --Testcase 285: SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; i | b @@ -1737,8 +1755,14 @@ SELECT "i", "b" FROM "type_BIT" WHERE ("b" | B'101011') IS NOT NULL; --Testcase 290: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" # B'101011') IS NOT NULL; -ERROR: SQL operator is not supported -HINT: operator name: # + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public."type_BIT" (cost=10.00..2203.00 rows=2203 width=13) + Output: i, b + Filter: (("type_BIT".b # '101011'::"bit") IS NOT NULL) + SQLite query: SELECT `i`, `b` FROM main."type_BIT" +(4 rows) + --Testcase 291: EXPLAIN VERBOSE SELECT "i", "b" FROM "type_BIT" WHERE ("b" >> 1) IS NOT NULL; From 6f7134d864e53134264ade9bca06789949b09f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 7 Nov 2023 09:11:59 +0300 Subject: [PATCH 10/14] Fix spelling and code style --- deparse.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/deparse.c b/deparse.c index 3466e9d5..34d2befb 100644 --- a/deparse.c +++ b/deparse.c @@ -2888,7 +2888,7 @@ sqlite_deparse_operator_name(StringInfo buf, Form_pg_operator opform) } else if (strcmp(cur_opname, "~~*") == 0 || strcmp(cur_opname, "!~~*") == 0 || - /* ~ operator are both one of text RegEx operators and bit string NOT */ + /* ~ operator is both one of text RegEx operators and bit string NOT */ (strcmp(cur_opname, "~") == 0 && opform->oprresult != VARBITOID && opform->oprresult != BITOID) || strcmp(cur_opname, "!~") == 0 || strcmp(cur_opname, "~*") == 0 || @@ -2898,7 +2898,6 @@ sqlite_deparse_operator_name(StringInfo buf, Form_pg_operator opform) errmsg("SQL operator is not supported"), errhint("operator name: %s", cur_opname))); } - else { appendStringInfoString(buf, cur_opname); From 0c648eacc689fdbf65b7c74a0b1ec8336161bf8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 7 Nov 2023 14:06:27 +0300 Subject: [PATCH 11/14] Fix parsing error processing --- sqlite_query.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sqlite_query.c b/sqlite_query.c index fd677f28..b3b0d489 100644 --- a/sqlite_query.c +++ b/sqlite_query.c @@ -768,8 +768,9 @@ binstr2int64(const char *s) } else { - errno = EINVAL; - return -1; + ereport(ERROR, (errcode(ERRCODE_FDW_INVALID_DATA_TYPE), + errmsg("Not 0 or 1 in bit string"), + errhint("value: %s", s))); } } return rc; From 54f4a429d431dfe65fd412a9ad233caad37518b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 7 Nov 2023 14:16:05 +0300 Subject: [PATCH 12/14] Fix variable block in sample code in README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index dbf8d9e3..34d89b42 100644 --- a/README.md +++ b/README.md @@ -580,6 +580,9 @@ Preferred code style see in PostgreSQL source codes. For example type funct_name (type arg ...) { + t1 var1 = value1; + t2 var2 = value2; + for (;;) { } From 4ca6adce5c3c4fac28e93c4c7aa16790f8473107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Tue, 7 Nov 2023 14:21:19 +0300 Subject: [PATCH 13/14] Fix typo --- sqlite_query.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlite_query.c b/sqlite_query.c index b3b0d489..fe1e0218 100644 --- a/sqlite_query.c +++ b/sqlite_query.c @@ -608,7 +608,7 @@ sqlite_bind_sql_var(Form_pg_attribute att, int attnum, Datum value, sqlite3_stmt { ereport(ERROR, (errcode(ERRCODE_FDW_INVALID_DATA_TYPE), errmsg("SQLite FDW dosens't support very long bit/varbit data"), - errhint("bit length %ld, maxmum %ld", strlen(outputString), SQLITE_FDW_BIT_DATATYPE_BUF_SIZE - 1))); + errhint("bit length %ld, maximum %ld", strlen(outputString), SQLITE_FDW_BIT_DATATYPE_BUF_SIZE - 1))); } dat = binstr2int64(outputString); ret = sqlite3_bind_int64(stmt, attnum, dat); From d5e1fea83aea010ee8b79dc5b3cab214ad4f1b42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Thu, 9 Nov 2023 07:52:33 +0300 Subject: [PATCH 14/14] Fix spelling in tests --- expected/12.15/type.out | 2 +- expected/13.11/type.out | 2 +- expected/14.8/type.out | 2 +- expected/15.3/type.out | 2 +- expected/16.0/type.out | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/expected/12.15/type.out b/expected/12.15/type.out index 43a377a2..cd7dc5d6 100644 --- a/expected/12.15/type.out +++ b/expected/12.15/type.out @@ -1155,7 +1155,7 @@ INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '010010010101100101001010100011 --Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ERROR: SQLite FDW dosens't support very long bit/varbit data -HINT: bit length 65, maxmum 64 +HINT: bit length 65, maximum 64 --Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; i | b | t | l diff --git a/expected/13.11/type.out b/expected/13.11/type.out index cb41214b..3de91088 100644 --- a/expected/13.11/type.out +++ b/expected/13.11/type.out @@ -659,7 +659,7 @@ INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '010010010101100101001010100011 --Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ERROR: SQLite FDW dosens't support very long bit/varbit data -HINT: bit length 65, maxmum 64 +HINT: bit length 65, maximum 64 --Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; i | b | t | l diff --git a/expected/14.8/type.out b/expected/14.8/type.out index cb41214b..3de91088 100644 --- a/expected/14.8/type.out +++ b/expected/14.8/type.out @@ -659,7 +659,7 @@ INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '010010010101100101001010100011 --Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ERROR: SQLite FDW dosens't support very long bit/varbit data -HINT: bit length 65, maxmum 64 +HINT: bit length 65, maximum 64 --Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; i | b | t | l diff --git a/expected/15.3/type.out b/expected/15.3/type.out index cb41214b..3de91088 100644 --- a/expected/15.3/type.out +++ b/expected/15.3/type.out @@ -659,7 +659,7 @@ INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '010010010101100101001010100011 --Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ERROR: SQLite FDW dosens't support very long bit/varbit data -HINT: bit length 65, maxmum 64 +HINT: bit length 65, maximum 64 --Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; i | b | t | l diff --git a/expected/16.0/type.out b/expected/16.0/type.out index 7f23289d..aedd1ec1 100644 --- a/expected/16.0/type.out +++ b/expected/16.0/type.out @@ -1157,7 +1157,7 @@ INSERT INTO "type_VARBIT" ("i", "b") VALUES (13, '010010010101100101001010100011 --Testcase 238: very long bit string, expected ERROR, 65 bits INSERT INTO "type_VARBIT" ("i", "b") VALUES (14, '01001001010110010100101010001111101101011011011110110001010101010'); ERROR: SQLite FDW dosens't support very long bit/varbit data -HINT: bit length 65, maxmum 64 +HINT: bit length 65, maximum 64 --Testcase 239: SELECT * FROM "type_VARBIT+" WHERE "i" > 10; i | b | t | l