Skip to content

Commit 84ca5a4

Browse files
committed
Prepare rebase to auto import test PR
1 parent 60729e8 commit 84ca5a4

File tree

147 files changed

+14287
-8624
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+14287
-8624
lines changed

Makefile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@ DATA = sqlite_fdw--1.0.sql sqlite_fdw--1.0--1.1.sql
1717

1818
ifdef ENABLE_GIS
1919
PG_CFLAGS += -DSQLITE_FDW_GIS_ENABLE
20-
GISTEST = postgis
21-
GISPREF = ok
20+
GIS_DEP_TESTS_DIR = with_gis_support
21+
GIS_TEST = postgis
22+
$(info There is PostGIS support for SQLite FDW)
2223
else
23-
GISTEST = nogis
24-
GISPREF = no
24+
GIS_DEP_TESTS_DIR = without_gis_support
25+
GIS_TEST = nogis
26+
$(info There is NO PostGIS support for SQLite FDW)
2527
endif
2628

2729
# Tests for PostgreSQL data types support
28-
TYPETESTS = types/bitstring types/bool types/float4 types/float8 types/int4 types/int8 types/numeric types/$(GISTEST) types/macaddr types/macaddr8 types/out_of_range types/timestamp types/uuid
30+
DATA_TYPE_TESTS = types/bitstring types/bool types/float4 types/float8 types/int4 types/int8 types/numeric types/macaddr types/macaddr8 types/out_of_range types/timestamp types/uuid
2931
# Tests with different versions with GIS support and without GIS support
30-
GISDEPTESTS = gis_$(GISPREF)/type gis_$(GISPREF)/auto_import
32+
GIS_DEP_TESTS = $(GIS_DEP_TESTS_DIR)/type $(GIS_DEP_TESTS_DIR)/auto_import $(GIS_DEP_TESTS_DIR)/$(GIS_TEST)
3133

3234
ifndef REGRESS
3335
# System tests, full default sequence
34-
REGRESS = libsqlite extra/sqlite_fdw_post $(TYPETESTS) extra/join extra/limit extra/aggregates extra/prepare extra/select_having extra/select extra/insert extra/update extra/encodings sqlite_fdw aggregate selectfunc $(GISDEPTESTS)
36+
REGRESS = libsqlite extra/sqlite_fdw_post $(DATA_TYPE_TESTS) extra/join extra/limit extra/aggregates extra/prepare extra/select_having extra/select extra/insert extra/update extra/encodings sqlite_fdw aggregate selectfunc $(GIS_DEP_TESTS)
3537
endif
3638

3739
# Other encodings also are tested. Client encoding should be UTF-8-
@@ -82,7 +84,7 @@ endif
8284
REGRESS := $(addprefix $(REGRESS_PREFIX_SUB)/,$(REGRESS))
8385
$(shell mkdir -p results/$(REGRESS_PREFIX_SUB)/extra)
8486
$(shell mkdir -p results/$(REGRESS_PREFIX_SUB)/types)
85-
$(shell mkdir -p results/$(REGRESS_PREFIX_SUB)/gis_$(GISPREF))
87+
$(shell mkdir -p results/$(REGRESS_PREFIX_SUB)/$(GIS_DEP_TESTS_DIR))
8688

8789
# $(info ENABLE_GIS is $(ENABLE_GIS))
8890
$(info SHLIB_LINK is $(SHLIB_LINK))

connection.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ sqlite_open_db(const char *dbpath, int flags)
199199
ereport(ERROR,
200200
(errcode(ERRCODE_FDW_UNABLE_TO_ESTABLISH_CONNECTION),
201201
errmsg("Failed to open SQLite DB, file '%s', result code %d", dbpath, rc)));
202-
sqlite3_extended_result_codes(conn, true);
203202
/* make 'LIKE' of SQLite case sensitive like PostgreSQL */
204203
rc = sqlite3_exec(conn, "pragma case_sensitive_like=1",
205204
NULL, NULL, &err);
@@ -392,13 +391,14 @@ sqlite_begin_remote_xact(ConnCacheEntry *entry)
392391

393392

394393
/*
395-
* Report an sqlite execution error
394+
* Report an SQLite execution error.
396395
*/
397396
void
398397
sqlitefdw_report_error(int elevel, sqlite3_stmt * stmt, sqlite3 * conn,
399398
const char *sql, int rc)
400399
{
401400
const char *message = sqlite3_errmsg(conn);
401+
int erc = sqlite3_extended_errcode(conn);
402402
int sqlstate = ERRCODE_FDW_ERROR;
403403

404404
/* copy sql before callling another SQLite API */
@@ -415,11 +415,10 @@ sqlitefdw_report_error(int elevel, sqlite3_stmt * stmt, sqlite3 * conn,
415415
(errcode(sqlstate),
416416
errmsg("Failed to execute remote SQL"),
417417
errcontext("SQL query: %s", sql ? sql : ""),
418-
errhint("SQLite error '%s', SQLite result code %d", message ? message : "", rc)
418+
errhint("SQLite error '%s', SQLite primary result code %d, extended result code %d", message ? message : "", rc, erc)
419419
));
420420
}
421421

422-
423422
/*
424423
* sqlitefdw_xact_callback --- cleanup at main-transaction end.
425424
*/

expected/13.15/extra/insert.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CREATE FOREIGN TABLE inserttest01 (col1 int4, col2 int4 NOT NULL, col3 text defa
1111
--Testcase 1:
1212
insert into inserttest01 (col1, col2, col3) values (DEFAULT, DEFAULT, DEFAULT);
1313
ERROR: Failed to execute remote SQL
14-
HINT: SQLite error 'NOT NULL constraint failed: inserttest01.col2', SQLite result code 1299
14+
HINT: SQLite error 'NOT NULL constraint failed: inserttest01.col2', SQLite primary result code 19, extended result code 1299
1515
CONTEXT: SQL query: INSERT INTO main."inserttest01"(`col1`, `col2`, `col3`) VALUES (?, ?, ?)
1616
--Testcase 2:
1717
insert into inserttest01 (col2, col3) values (3, DEFAULT);

expected/13.15/extra/sqlite_fdw_post.out

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6437,7 +6437,7 @@ ALTER FOREIGN TABLE ft1_constraint RENAME TO ft1;
64376437
--Testcase 319:
64386438
INSERT INTO ft1(c1, c2) VALUES(11, 12); -- duplicate key
64396439
ERROR: Failed to execute remote SQL
6440-
HINT: SQLite error 'UNIQUE constraint failed: t1_constraint.c1', SQLite result code 1555
6440+
HINT: SQLite error 'UNIQUE constraint failed: t1_constraint.c1', SQLite primary result code 19, extended result code 1555
64416441
CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
64426442
--Testcase 320:
64436443
INSERT INTO ft1(c1, c2) VALUES(11, 12) ON CONFLICT (c1, c2) DO NOTHING; -- unsupported
@@ -6448,12 +6448,12 @@ ERROR: there is no unique or exclusion constraint matching the ON CONFLICT spec
64486448
--Testcase 743:
64496449
INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive
64506450
ERROR: Failed to execute remote SQL
6451-
HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 275
6451+
HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite primary result code 19, extended result code 275
64526452
CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
64536453
--Testcase 744:
64546454
UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive
64556455
ERROR: Failed to execute remote SQL
6456-
HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 275
6456+
HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite primary result code 19, extended result code 275
64576457
CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1))
64586458
--Testcase 750:
64596459
ALTER FOREIGN TABLE ft1 RENAME TO ft1_constraint;
@@ -6856,12 +6856,12 @@ RESET constraint_exclusion;
68566856
--Testcase 745:
68576857
INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive
68586858
ERROR: Failed to execute remote SQL
6859-
HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 275
6859+
HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite primary result code 19, extended result code 275
68606860
CONTEXT: SQL query: INSERT INTO main."t1_constraint"(`c1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8`) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
68616861
--Testcase 746:
68626862
UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive
68636863
ERROR: Failed to execute remote SQL
6864-
HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite result code 275
6864+
HINT: SQLite error 'CHECK constraint failed: c2 >= 0', SQLite primary result code 19, extended result code 275
68656865
CONTEXT: SQL query: UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1))
68666866
ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2positive;
68676867
-- But inconsistent check constraints provide inconsistent results

expected/13.15/sqlite_fdw.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ SELECT * from numbers;
576576
--Testcase 68:
577577
INSERT INTO numbers VALUES(1, 'One');
578578
ERROR: Failed to execute remote SQL
579-
HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 2067
579+
HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite primary result code 19, extended result code 2067
580580
CONTEXT: SQL query: INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?)
581581
--Testcase 69:
582582
DELETE from numbers;
@@ -590,7 +590,7 @@ COMMIT;
590590
--Testcase 72:
591591
UPDATE numbers SET b='Two' WHERE a = 1;
592592
ERROR: Failed to execute remote SQL
593-
HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite result code 2067
593+
HINT: SQLite error 'UNIQUE constraint failed: numbers.b', SQLite primary result code 19, extended result code 2067
594594
CONTEXT: SQL query: UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1))
595595
--Testcase 73:
596596
SELECT * from numbers;

expected/13.15/types/bitstring.out

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ CREATE EXTENSION sqlite_fdw;
55
--Testcase 002:
66
CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw
77
OPTIONS (database '/tmp/sqlite_fdw_test/common.db');
8-
--Testcase 003:
9-
CREATE SERVER sqlite2 FOREIGN DATA WRAPPER sqlite_fdw;
108
--Testcase 02:
119
CREATE FOREIGN TABLE "type_BIT"( "i" int OPTIONS (key 'true'), "b" bit(6)) SERVER sqlite_svr OPTIONS (table 'type_BIT');
1210
--Testcase 03:
@@ -801,10 +799,9 @@ SELECT "i", "b" FROM "type_BIT" WHERE (~ "b") IS NOT NULL;
801799

802800
--Testcase 005:
803801
DROP EXTENSION sqlite_fdw CASCADE;
804-
NOTICE: drop cascades to 6 other objects
802+
NOTICE: drop cascades to 5 other objects
805803
DETAIL: drop cascades to server sqlite_svr
806804
drop cascades to foreign table "type_BIT"
807805
drop cascades to foreign table "type_BIT+"
808806
drop cascades to foreign table "type_VARBIT"
809807
drop cascades to foreign table "type_VARBIT+"
810-
drop cascades to server sqlite2

expected/13.15/types/bool.out

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ CREATE EXTENSION sqlite_fdw;
55
--Testcase 001:
66
CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw
77
OPTIONS (database '/tmp/sqlite_fdw_test/common.db');
8-
--Testcase 002:
9-
CREATE SERVER sqlite2 FOREIGN DATA WRAPPER sqlite_fdw;
108
--Testcase 01:
119
CREATE FOREIGN TABLE "type_BOOLEAN" (i int OPTIONS (key 'true'), b bool) SERVER sqlite_svr;
1210
--Testcase 02:
@@ -239,7 +237,7 @@ INSERT INTO "type_BOOLEANpk" VALUES (FALSE);
239237
--Testcase 44: ERR - primary key
240238
INSERT INTO "type_BOOLEANpk" VALUES (TRUE);
241239
ERROR: Failed to execute remote SQL
242-
HINT: SQLite error 'UNIQUE constraint failed: type_BOOLEANpk.col', SQLite result code 1555
240+
HINT: SQLite error 'UNIQUE constraint failed: type_BOOLEANpk.col', SQLite primary result code 19, extended result code 1555
243241
CONTEXT: SQL query: INSERT INTO main."type_BOOLEANpk"(`col`) VALUES (?)
244242
--Testcase 45:
245243
DELETE FROM "type_BOOLEANpk";
@@ -1267,10 +1265,9 @@ SELECT DISTINCT b1, b2 FROM "type_BOOLEAN_oper";
12671265
DELETE FROM "type_BOOLEAN";
12681266
--Testcase 003:
12691267
DROP EXTENSION sqlite_fdw CASCADE;
1270-
NOTICE: drop cascades to 6 other objects
1268+
NOTICE: drop cascades to 5 other objects
12711269
DETAIL: drop cascades to server sqlite_svr
12721270
drop cascades to foreign table "type_BOOLEAN"
12731271
drop cascades to foreign table "type_BOOLEAN+"
12741272
drop cascades to foreign table "type_BOOLEANpk"
12751273
drop cascades to foreign table "type_BOOLEAN_oper"
1276-
drop cascades to server sqlite2

expected/13.15/types/macaddr.out

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ CREATE EXTENSION sqlite_fdw;
55
--Testcase 002:
66
CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw
77
OPTIONS (database '/tmp/sqlite_fdw_test/common.db');
8-
--Testcase 003:
9-
CREATE SERVER sqlite2 FOREIGN DATA WRAPPER sqlite_fdw;
108
--Testcase 009:
119
CREATE FOREIGN TABLE "type_MACADDR"( "i" int OPTIONS (key 'true'), "m" macaddr) SERVER sqlite_svr OPTIONS (table 'type_MACADDR');
1210
--Testcase 010:
@@ -840,7 +838,7 @@ ALTER FOREIGN TABLE "type_MACADDRpk" ALTER COLUMN col OPTIONS (SET column_type '
840838
--Testcase 158: ERR - primary key
841839
INSERT INTO "type_MACADDRpk" VALUES ('01-02-03-04-05-06');
842840
ERROR: Failed to execute remote SQL
843-
HINT: SQLite error 'UNIQUE constraint failed: type_MACADDRpk.col', SQLite result code 1555
841+
HINT: SQLite error 'UNIQUE constraint failed: type_MACADDRpk.col', SQLite primary result code 19, extended result code 1555
844842
CONTEXT: SQL query: INSERT INTO main."type_MACADDRpk"(`col`) VALUES (?)
845843
--Testcase 159:
846844
SELECT * FROM "type_MACADDRpk";
@@ -946,9 +944,8 @@ SELECT "m" != '01:02:03:04:05:06' FROM "type_MACADDR";
946944

947945
--Testcase 200:
948946
DROP EXTENSION sqlite_fdw CASCADE;
949-
NOTICE: drop cascades to 5 other objects
947+
NOTICE: drop cascades to 4 other objects
950948
DETAIL: drop cascades to server sqlite_svr
951949
drop cascades to foreign table "type_MACADDR"
952950
drop cascades to foreign table "type_MACADDR+"
953951
drop cascades to foreign table "type_MACADDRpk"
954-
drop cascades to server sqlite2

expected/13.15/types/macaddr8.out

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ CREATE EXTENSION sqlite_fdw;
55
--Testcase 002:
66
CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw
77
OPTIONS (database '/tmp/sqlite_fdw_test/common.db');
8-
--Testcase 003:
9-
CREATE SERVER sqlite2 FOREIGN DATA WRAPPER sqlite_fdw;
108
--Testcase 009:
119
CREATE FOREIGN TABLE "type_MACADDR8"( "i" int OPTIONS (key 'true'), "m" macaddr8) SERVER sqlite_svr OPTIONS (table 'type_MACADDR8');
1210
--Testcase 010:
@@ -841,7 +839,7 @@ ERROR: option "column_type" provided more than once
841839
--Testcase 158: ERR - primary key
842840
INSERT INTO "type_MACADDR8pk" VALUES ('01-02-03-04-05-06-07-08');
843841
ERROR: Failed to execute remote SQL
844-
HINT: SQLite error 'UNIQUE constraint failed: type_MACADDR8pk.col', SQLite result code 1555
842+
HINT: SQLite error 'UNIQUE constraint failed: type_MACADDR8pk.col', SQLite primary result code 19, extended result code 1555
845843
CONTEXT: SQL query: INSERT INTO main."type_MACADDR8pk"(`col`) VALUES (?)
846844
--Testcase 159:
847845
SELECT * FROM "type_MACADDR8pk";
@@ -947,9 +945,8 @@ SELECT "m" != '01:02:03:04:05:06:07:08' FROM "type_MACADDR8";
947945

948946
--Testcase 200:
949947
DROP EXTENSION sqlite_fdw CASCADE;
950-
NOTICE: drop cascades to 5 other objects
948+
NOTICE: drop cascades to 4 other objects
951949
DETAIL: drop cascades to server sqlite_svr
952950
drop cascades to foreign table "type_MACADDR8"
953951
drop cascades to foreign table "type_MACADDR8+"
954952
drop cascades to foreign table "type_MACADDR8pk"
955-
drop cascades to server sqlite2

expected/13.15/types/uuid.out

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ CREATE EXTENSION sqlite_fdw;
55
--Testcase 002:
66
CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw
77
OPTIONS (database '/tmp/sqlite_fdw_test/common.db');
8-
--Testcase 003:
9-
CREATE SERVER sqlite2 FOREIGN DATA WRAPPER sqlite_fdw;
108
--Testcase 009:
119
CREATE FOREIGN TABLE "type_UUID"( "i" int OPTIONS (key 'true'), "u" uuid) SERVER sqlite_svr OPTIONS (table 'type_UUID');
1210
--Testcase 010:
@@ -522,7 +520,7 @@ SELECT * FROM "type_UUIDpk";
522520
--Testcase 105: ERR - primary key
523521
INSERT INTO "type_UUIDpk" VALUES ('{b0eebc99-9c0b4ef8-bb6d6bb9-bd380a12}');
524522
ERROR: Failed to execute remote SQL
525-
HINT: SQLite error 'UNIQUE constraint failed: type_UUIDpk.col', SQLite result code 1555
523+
HINT: SQLite error 'UNIQUE constraint failed: type_UUIDpk.col', SQLite primary result code 19, extended result code 1555
526524
CONTEXT: SQL query: INSERT INTO main."type_UUIDpk"(`col`) VALUES (?)
527525
--Testcase 106:
528526
ALTER FOREIGN TABLE "type_UUIDpk" ALTER COLUMN col OPTIONS (SET column_type 'BLOB');
@@ -541,9 +539,8 @@ SELECT * FROM "type_UUIDpk";
541539
DELETE FROM "type_UUIDpk";
542540
--Testcase 200:
543541
DROP EXTENSION sqlite_fdw CASCADE;
544-
NOTICE: drop cascades to 5 other objects
542+
NOTICE: drop cascades to 4 other objects
545543
DETAIL: drop cascades to server sqlite_svr
546544
drop cascades to foreign table "type_UUID"
547545
drop cascades to foreign table "type_UUID+"
548546
drop cascades to foreign table "type_UUIDpk"
549-
drop cascades to server sqlite2

0 commit comments

Comments
 (0)