From f14eed32a50f57f58d61a9b8503db8b3266d00a9 Mon Sep 17 00:00:00 2001 From: Nam Nguyen Date: Tue, 21 Dec 2021 15:33:45 +0700 Subject: [PATCH] Release version 2.1.1 --- META.json | 4 +- README.md | 2 + connection.c | 85 ++- deparse.c | 115 +++- expected/{10.17 => 10.18}/aggregate.out | 0 .../{10.17 => 10.18}/extra/aggregates.out | 0 expected/{10.17 => 10.18}/extra/float4.out | 0 expected/{10.17 => 10.18}/extra/float8.out | 0 expected/{10.17 => 10.18}/extra/insert.out | 0 expected/{10.17 => 10.18}/extra/int4.out | 0 expected/{10.17 => 10.18}/extra/int8.out | 0 expected/{10.17 => 10.18}/extra/join.out | 0 expected/{10.17 => 10.18}/extra/limit.out | 0 expected/{10.17 => 10.18}/extra/numeric.out | 0 expected/{10.17 => 10.18}/extra/prepare.out | 0 expected/{10.17 => 10.18}/extra/select.out | 0 .../{10.17 => 10.18}/extra/select_having.out | 0 .../extra/sqlite_fdw_post.out | 33 +- expected/{10.17 => 10.18}/extra/timestamp.out | 0 expected/{10.17 => 10.18}/extra/update.out | 0 expected/{10.17 => 10.18}/selectfunc.out | 0 expected/{10.17 => 10.18}/sqlite_fdw.out | 23 +- expected/{11.12 => 10.18}/type.out | 10 +- expected/{11.12 => 11.13}/aggregate.out | 0 .../{11.12 => 11.13}/extra/aggregates.out | 0 expected/{11.12 => 11.13}/extra/float4.out | 0 expected/{11.12 => 11.13}/extra/float8.out | 0 expected/{11.12 => 11.13}/extra/insert.out | 0 expected/{11.12 => 11.13}/extra/int4.out | 0 expected/{11.12 => 11.13}/extra/int8.out | 0 expected/{11.12 => 11.13}/extra/join.out | 0 expected/{11.12 => 11.13}/extra/limit.out | 0 expected/{11.12 => 11.13}/extra/numeric.out | 0 expected/{11.12 => 11.13}/extra/prepare.out | 0 expected/{11.12 => 11.13}/extra/select.out | 0 .../{11.12 => 11.13}/extra/select_having.out | 0 .../extra/sqlite_fdw_post.out | 33 +- expected/{11.12 => 11.13}/extra/timestamp.out | 0 expected/{11.12 => 11.13}/extra/update.out | 0 expected/{11.12 => 11.13}/selectfunc.out | 0 expected/{11.12 => 11.13}/sqlite_fdw.out | 23 +- expected/{12.7 => 11.13}/type.out | 10 +- expected/{12.7 => 12.8}/aggregate.out | 0 expected/{12.7 => 12.8}/extra/aggregates.out | 0 expected/{12.7 => 12.8}/extra/float4.out | 0 expected/{12.7 => 12.8}/extra/float8.out | 0 expected/{12.7 => 12.8}/extra/insert.out | 0 expected/{12.7 => 12.8}/extra/int4.out | 0 expected/{12.7 => 12.8}/extra/int8.out | 0 expected/{12.7 => 12.8}/extra/join.out | 0 expected/{12.7 => 12.8}/extra/limit.out | 0 expected/{12.7 => 12.8}/extra/numeric.out | 0 expected/{12.7 => 12.8}/extra/prepare.out | 0 expected/{12.7 => 12.8}/extra/select.out | 0 .../{12.7 => 12.8}/extra/select_having.out | 0 .../{12.7 => 12.8}/extra/sqlite_fdw_post.out | 33 +- expected/{12.7 => 12.8}/extra/timestamp.out | 0 expected/{12.7 => 12.8}/extra/update.out | 0 expected/{12.7 => 12.8}/selectfunc.out | 0 expected/{12.7 => 12.8}/sqlite_fdw.out | 23 +- expected/{10.17 => 12.8}/type.out | 10 +- expected/{13.3 => 13.4}/aggregate.out | 0 expected/{13.3 => 13.4}/extra/aggregates.out | 0 expected/{13.3 => 13.4}/extra/float4.out | 0 expected/{13.3 => 13.4}/extra/float8.out | 0 expected/{13.3 => 13.4}/extra/insert.out | 0 expected/{13.3 => 13.4}/extra/int4.out | 0 expected/{13.3 => 13.4}/extra/int8.out | 0 expected/{13.3 => 13.4}/extra/join.out | 0 expected/{13.3 => 13.4}/extra/limit.out | 0 expected/{13.3 => 13.4}/extra/numeric.out | 0 expected/{13.3 => 13.4}/extra/prepare.out | 0 expected/{13.3 => 13.4}/extra/select.out | 0 .../{13.3 => 13.4}/extra/select_having.out | 0 .../{13.3 => 13.4}/extra/sqlite_fdw_post.out | 33 +- expected/{13.3 => 13.4}/extra/timestamp.out | 0 expected/{13.3 => 13.4}/extra/update.out | 0 expected/{13.3 => 13.4}/selectfunc.out | 0 expected/{13.3 => 13.4}/sqlite_fdw.out | 23 +- expected/{13.3 => 13.4}/type.out | 10 +- expected/{14beta2 => 14.0}/aggregate.out | 0 .../{14beta2 => 14.0}/extra/aggregates.out | 40 +- expected/{14beta2 => 14.0}/extra/float4.out | 0 expected/{14beta2 => 14.0}/extra/float8.out | 0 expected/{14beta2 => 14.0}/extra/insert.out | 0 expected/{14beta2 => 14.0}/extra/int4.out | 0 expected/{14beta2 => 14.0}/extra/int8.out | 0 expected/{14beta2 => 14.0}/extra/join.out | 31 +- expected/{14beta2 => 14.0}/extra/limit.out | 0 expected/{14beta2 => 14.0}/extra/numeric.out | 271 +++++++- expected/{14beta2 => 14.0}/extra/prepare.out | 0 expected/{14beta2 => 14.0}/extra/select.out | 0 .../{14beta2 => 14.0}/extra/select_having.out | 0 .../extra/sqlite_fdw_post.out | 357 ++++++++++- .../{14beta2 => 14.0}/extra/timestamp.out | 0 expected/{14beta2 => 14.0}/extra/update.out | 0 expected/{14beta2 => 14.0}/selectfunc.out | 0 expected/{14beta2 => 14.0}/sqlite_fdw.out | 59 +- expected/14.0/type.out | 351 ++++++++++ expected/14beta2/type.out | 343 ---------- option.c | 21 +- sql/{10.17 => 10.18}/aggregate.sql | 0 sql/{10.17 => 10.18}/extra/aggregates.sql | 0 sql/{10.17 => 10.18}/extra/float4.sql | 0 sql/{10.17 => 10.18}/extra/float8.sql | 0 sql/{10.17 => 10.18}/extra/insert.sql | 0 sql/{10.17 => 10.18}/extra/int4.sql | 0 sql/{10.17 => 10.18}/extra/int8.sql | 0 sql/{10.17 => 10.18}/extra/join.sql | 0 sql/{10.17 => 10.18}/extra/limit.sql | 0 sql/{10.17 => 10.18}/extra/numeric.sql | 0 sql/{10.17 => 10.18}/extra/prepare.sql | 0 sql/{10.17 => 10.18}/extra/select.sql | 0 sql/{10.17 => 10.18}/extra/select_having.sql | 0 .../extra/sqlite_fdw_post.sql | 0 sql/{10.17 => 10.18}/extra/timestamp.sql | 0 sql/{10.17 => 10.18}/extra/update.sql | 0 sql/{10.17 => 10.18}/selectfunc.sql | 0 sql/{10.17 => 10.18}/sqlite_fdw.sql | 18 + sql/{10.17 => 10.18}/type.sql | 0 sql/{11.12 => 11.13}/aggregate.sql | 0 sql/{11.12 => 11.13}/extra/aggregates.sql | 0 sql/{11.12 => 11.13}/extra/float4.sql | 0 sql/{11.12 => 11.13}/extra/float8.sql | 0 sql/{11.12 => 11.13}/extra/insert.sql | 0 sql/{11.12 => 11.13}/extra/int4.sql | 0 sql/{11.12 => 11.13}/extra/int8.sql | 0 sql/{11.12 => 11.13}/extra/join.sql | 0 sql/{11.12 => 11.13}/extra/limit.sql | 0 sql/{11.12 => 11.13}/extra/numeric.sql | 0 sql/{11.12 => 11.13}/extra/prepare.sql | 0 sql/{11.12 => 11.13}/extra/select.sql | 0 sql/{11.12 => 11.13}/extra/select_having.sql | 0 .../extra/sqlite_fdw_post.sql | 0 sql/{11.12 => 11.13}/extra/timestamp.sql | 0 sql/{11.12 => 11.13}/extra/update.sql | 0 sql/{11.12 => 11.13}/selectfunc.sql | 0 sql/{11.12 => 11.13}/sqlite_fdw.sql | 18 + sql/{11.12 => 11.13}/type.sql | 0 sql/{12.7 => 12.8}/aggregate.sql | 0 sql/{12.7 => 12.8}/extra/aggregates.sql | 0 sql/{12.7 => 12.8}/extra/float4.sql | 0 sql/{12.7 => 12.8}/extra/float8.sql | 0 sql/{12.7 => 12.8}/extra/insert.sql | 0 sql/{12.7 => 12.8}/extra/int4.sql | 0 sql/{12.7 => 12.8}/extra/int8.sql | 0 sql/{12.7 => 12.8}/extra/join.sql | 0 sql/{12.7 => 12.8}/extra/limit.sql | 0 sql/{12.7 => 12.8}/extra/numeric.sql | 0 sql/{12.7 => 12.8}/extra/prepare.sql | 0 sql/{12.7 => 12.8}/extra/select.sql | 0 sql/{12.7 => 12.8}/extra/select_having.sql | 0 sql/{12.7 => 12.8}/extra/sqlite_fdw_post.sql | 0 sql/{12.7 => 12.8}/extra/timestamp.sql | 0 sql/{12.7 => 12.8}/extra/update.sql | 0 sql/{12.7 => 12.8}/selectfunc.sql | 0 sql/{12.7 => 12.8}/sqlite_fdw.sql | 18 + sql/{12.7 => 12.8}/type.sql | 0 sql/{13.3 => 13.4}/aggregate.sql | 0 sql/{13.3 => 13.4}/extra/aggregates.sql | 0 sql/{13.3 => 13.4}/extra/float4.sql | 0 sql/{13.3 => 13.4}/extra/float8.sql | 0 sql/{13.3 => 13.4}/extra/insert.sql | 0 sql/{13.3 => 13.4}/extra/int4.sql | 0 sql/{13.3 => 13.4}/extra/int8.sql | 0 sql/{13.3 => 13.4}/extra/join.sql | 0 sql/{13.3 => 13.4}/extra/limit.sql | 0 sql/{13.3 => 13.4}/extra/numeric.sql | 0 sql/{13.3 => 13.4}/extra/prepare.sql | 0 sql/{13.3 => 13.4}/extra/select.sql | 0 sql/{13.3 => 13.4}/extra/select_having.sql | 0 sql/{13.3 => 13.4}/extra/sqlite_fdw_post.sql | 0 sql/{13.3 => 13.4}/extra/timestamp.sql | 0 sql/{13.3 => 13.4}/extra/update.sql | 0 sql/{13.3 => 13.4}/selectfunc.sql | 0 sql/{13.3 => 13.4}/sqlite_fdw.sql | 18 + sql/{13.3 => 13.4}/type.sql | 0 sql/{14beta2 => 14.0}/aggregate.sql | 0 sql/{14beta2 => 14.0}/extra/aggregates.sql | 20 +- sql/{14beta2 => 14.0}/extra/float4.sql | 0 sql/{14beta2 => 14.0}/extra/float8.sql | 0 sql/{14beta2 => 14.0}/extra/insert.sql | 0 sql/{14beta2 => 14.0}/extra/int4.sql | 0 sql/{14beta2 => 14.0}/extra/int8.sql | 0 sql/{14beta2 => 14.0}/extra/join.sql | 25 +- sql/{14beta2 => 14.0}/extra/limit.sql | 0 sql/{14beta2 => 14.0}/extra/numeric.sql | 192 +++++- sql/{14beta2 => 14.0}/extra/prepare.sql | 0 sql/{14beta2 => 14.0}/extra/select.sql | 0 sql/{14beta2 => 14.0}/extra/select_having.sql | 0 .../extra/sqlite_fdw_post.sql | 284 ++++++++- sql/{14beta2 => 14.0}/extra/timestamp.sql | 0 sql/{14beta2 => 14.0}/extra/update.sql | 0 sql/{14beta2 => 14.0}/selectfunc.sql | 0 sql/14.0/sqlite_fdw.sql | 602 ++++++++++++++++++ sql/{14beta2 => 14.0}/type.sql | 0 sql/14beta2/sqlite_fdw.sql | 555 ---------------- sql/init_data/init.sql | 8 + sql/init_data/init_post.sql | 2 + sqlite_fdw.c | 80 ++- sqlite_fdw.h | 6 +- 201 files changed, 2703 insertions(+), 1086 deletions(-) rename expected/{10.17 => 10.18}/aggregate.out (100%) rename expected/{10.17 => 10.18}/extra/aggregates.out (100%) rename expected/{10.17 => 10.18}/extra/float4.out (100%) rename expected/{10.17 => 10.18}/extra/float8.out (100%) rename expected/{10.17 => 10.18}/extra/insert.out (100%) rename expected/{10.17 => 10.18}/extra/int4.out (100%) rename expected/{10.17 => 10.18}/extra/int8.out (100%) rename expected/{10.17 => 10.18}/extra/join.out (100%) rename expected/{10.17 => 10.18}/extra/limit.out (100%) rename expected/{10.17 => 10.18}/extra/numeric.out (100%) rename expected/{10.17 => 10.18}/extra/prepare.out (100%) rename expected/{10.17 => 10.18}/extra/select.out (100%) rename expected/{10.17 => 10.18}/extra/select_having.out (100%) rename expected/{10.17 => 10.18}/extra/sqlite_fdw_post.out (99%) rename expected/{10.17 => 10.18}/extra/timestamp.out (100%) rename expected/{10.17 => 10.18}/extra/update.out (100%) rename expected/{10.17 => 10.18}/selectfunc.out (100%) rename expected/{10.17 => 10.18}/sqlite_fdw.out (98%) rename expected/{11.12 => 10.18}/type.out (96%) rename expected/{11.12 => 11.13}/aggregate.out (100%) rename expected/{11.12 => 11.13}/extra/aggregates.out (100%) rename expected/{11.12 => 11.13}/extra/float4.out (100%) rename expected/{11.12 => 11.13}/extra/float8.out (100%) rename expected/{11.12 => 11.13}/extra/insert.out (100%) rename expected/{11.12 => 11.13}/extra/int4.out (100%) rename expected/{11.12 => 11.13}/extra/int8.out (100%) rename expected/{11.12 => 11.13}/extra/join.out (100%) rename expected/{11.12 => 11.13}/extra/limit.out (100%) rename expected/{11.12 => 11.13}/extra/numeric.out (100%) rename expected/{11.12 => 11.13}/extra/prepare.out (100%) rename expected/{11.12 => 11.13}/extra/select.out (100%) rename expected/{11.12 => 11.13}/extra/select_having.out (100%) rename expected/{11.12 => 11.13}/extra/sqlite_fdw_post.out (99%) rename expected/{11.12 => 11.13}/extra/timestamp.out (100%) rename expected/{11.12 => 11.13}/extra/update.out (100%) rename expected/{11.12 => 11.13}/selectfunc.out (100%) rename expected/{11.12 => 11.13}/sqlite_fdw.out (98%) rename expected/{12.7 => 11.13}/type.out (96%) rename expected/{12.7 => 12.8}/aggregate.out (100%) rename expected/{12.7 => 12.8}/extra/aggregates.out (100%) rename expected/{12.7 => 12.8}/extra/float4.out (100%) rename expected/{12.7 => 12.8}/extra/float8.out (100%) rename expected/{12.7 => 12.8}/extra/insert.out (100%) rename expected/{12.7 => 12.8}/extra/int4.out (100%) rename expected/{12.7 => 12.8}/extra/int8.out (100%) rename expected/{12.7 => 12.8}/extra/join.out (100%) rename expected/{12.7 => 12.8}/extra/limit.out (100%) rename expected/{12.7 => 12.8}/extra/numeric.out (100%) rename expected/{12.7 => 12.8}/extra/prepare.out (100%) rename expected/{12.7 => 12.8}/extra/select.out (100%) rename expected/{12.7 => 12.8}/extra/select_having.out (100%) rename expected/{12.7 => 12.8}/extra/sqlite_fdw_post.out (99%) rename expected/{12.7 => 12.8}/extra/timestamp.out (100%) rename expected/{12.7 => 12.8}/extra/update.out (100%) rename expected/{12.7 => 12.8}/selectfunc.out (100%) rename expected/{12.7 => 12.8}/sqlite_fdw.out (98%) rename expected/{10.17 => 12.8}/type.out (96%) rename expected/{13.3 => 13.4}/aggregate.out (100%) rename expected/{13.3 => 13.4}/extra/aggregates.out (100%) rename expected/{13.3 => 13.4}/extra/float4.out (100%) rename expected/{13.3 => 13.4}/extra/float8.out (100%) rename expected/{13.3 => 13.4}/extra/insert.out (100%) rename expected/{13.3 => 13.4}/extra/int4.out (100%) rename expected/{13.3 => 13.4}/extra/int8.out (100%) rename expected/{13.3 => 13.4}/extra/join.out (100%) rename expected/{13.3 => 13.4}/extra/limit.out (100%) rename expected/{13.3 => 13.4}/extra/numeric.out (100%) rename expected/{13.3 => 13.4}/extra/prepare.out (100%) rename expected/{13.3 => 13.4}/extra/select.out (100%) rename expected/{13.3 => 13.4}/extra/select_having.out (100%) rename expected/{13.3 => 13.4}/extra/sqlite_fdw_post.out (99%) rename expected/{13.3 => 13.4}/extra/timestamp.out (100%) rename expected/{13.3 => 13.4}/extra/update.out (100%) rename expected/{13.3 => 13.4}/selectfunc.out (100%) rename expected/{13.3 => 13.4}/sqlite_fdw.out (98%) rename expected/{13.3 => 13.4}/type.out (96%) rename expected/{14beta2 => 14.0}/aggregate.out (100%) rename expected/{14beta2 => 14.0}/extra/aggregates.out (98%) rename expected/{14beta2 => 14.0}/extra/float4.out (100%) rename expected/{14beta2 => 14.0}/extra/float8.out (100%) rename expected/{14beta2 => 14.0}/extra/insert.out (100%) rename expected/{14beta2 => 14.0}/extra/int4.out (100%) rename expected/{14beta2 => 14.0}/extra/int8.out (100%) rename expected/{14beta2 => 14.0}/extra/join.out (99%) rename expected/{14beta2 => 14.0}/extra/limit.out (100%) rename expected/{14beta2 => 14.0}/extra/numeric.out (95%) rename expected/{14beta2 => 14.0}/extra/prepare.out (100%) rename expected/{14beta2 => 14.0}/extra/select.out (100%) rename expected/{14beta2 => 14.0}/extra/select_having.out (100%) rename expected/{14beta2 => 14.0}/extra/sqlite_fdw_post.out (98%) rename expected/{14beta2 => 14.0}/extra/timestamp.out (100%) rename expected/{14beta2 => 14.0}/extra/update.out (100%) rename expected/{14beta2 => 14.0}/selectfunc.out (100%) rename expected/{14beta2 => 14.0}/sqlite_fdw.out (96%) create mode 100644 expected/14.0/type.out delete mode 100644 expected/14beta2/type.out rename sql/{10.17 => 10.18}/aggregate.sql (100%) rename sql/{10.17 => 10.18}/extra/aggregates.sql (100%) rename sql/{10.17 => 10.18}/extra/float4.sql (100%) rename sql/{10.17 => 10.18}/extra/float8.sql (100%) rename sql/{10.17 => 10.18}/extra/insert.sql (100%) rename sql/{10.17 => 10.18}/extra/int4.sql (100%) rename sql/{10.17 => 10.18}/extra/int8.sql (100%) rename sql/{10.17 => 10.18}/extra/join.sql (100%) rename sql/{10.17 => 10.18}/extra/limit.sql (100%) rename sql/{10.17 => 10.18}/extra/numeric.sql (100%) rename sql/{10.17 => 10.18}/extra/prepare.sql (100%) rename sql/{10.17 => 10.18}/extra/select.sql (100%) rename sql/{10.17 => 10.18}/extra/select_having.sql (100%) rename sql/{10.17 => 10.18}/extra/sqlite_fdw_post.sql (100%) rename sql/{10.17 => 10.18}/extra/timestamp.sql (100%) rename sql/{10.17 => 10.18}/extra/update.sql (100%) rename sql/{10.17 => 10.18}/selectfunc.sql (100%) rename sql/{10.17 => 10.18}/sqlite_fdw.sql (97%) rename sql/{10.17 => 10.18}/type.sql (100%) rename sql/{11.12 => 11.13}/aggregate.sql (100%) rename sql/{11.12 => 11.13}/extra/aggregates.sql (100%) rename sql/{11.12 => 11.13}/extra/float4.sql (100%) rename sql/{11.12 => 11.13}/extra/float8.sql (100%) rename sql/{11.12 => 11.13}/extra/insert.sql (100%) rename sql/{11.12 => 11.13}/extra/int4.sql (100%) rename sql/{11.12 => 11.13}/extra/int8.sql (100%) rename sql/{11.12 => 11.13}/extra/join.sql (100%) rename sql/{11.12 => 11.13}/extra/limit.sql (100%) rename sql/{11.12 => 11.13}/extra/numeric.sql (100%) rename sql/{11.12 => 11.13}/extra/prepare.sql (100%) rename sql/{11.12 => 11.13}/extra/select.sql (100%) rename sql/{11.12 => 11.13}/extra/select_having.sql (100%) rename sql/{11.12 => 11.13}/extra/sqlite_fdw_post.sql (100%) rename sql/{11.12 => 11.13}/extra/timestamp.sql (100%) rename sql/{11.12 => 11.13}/extra/update.sql (100%) rename sql/{11.12 => 11.13}/selectfunc.sql (100%) rename sql/{11.12 => 11.13}/sqlite_fdw.sql (97%) rename sql/{11.12 => 11.13}/type.sql (100%) rename sql/{12.7 => 12.8}/aggregate.sql (100%) rename sql/{12.7 => 12.8}/extra/aggregates.sql (100%) rename sql/{12.7 => 12.8}/extra/float4.sql (100%) rename sql/{12.7 => 12.8}/extra/float8.sql (100%) rename sql/{12.7 => 12.8}/extra/insert.sql (100%) rename sql/{12.7 => 12.8}/extra/int4.sql (100%) rename sql/{12.7 => 12.8}/extra/int8.sql (100%) rename sql/{12.7 => 12.8}/extra/join.sql (100%) rename sql/{12.7 => 12.8}/extra/limit.sql (100%) rename sql/{12.7 => 12.8}/extra/numeric.sql (100%) rename sql/{12.7 => 12.8}/extra/prepare.sql (100%) rename sql/{12.7 => 12.8}/extra/select.sql (100%) rename sql/{12.7 => 12.8}/extra/select_having.sql (100%) rename sql/{12.7 => 12.8}/extra/sqlite_fdw_post.sql (100%) rename sql/{12.7 => 12.8}/extra/timestamp.sql (100%) rename sql/{12.7 => 12.8}/extra/update.sql (100%) rename sql/{12.7 => 12.8}/selectfunc.sql (100%) rename sql/{12.7 => 12.8}/sqlite_fdw.sql (97%) rename sql/{12.7 => 12.8}/type.sql (100%) rename sql/{13.3 => 13.4}/aggregate.sql (100%) rename sql/{13.3 => 13.4}/extra/aggregates.sql (100%) rename sql/{13.3 => 13.4}/extra/float4.sql (100%) rename sql/{13.3 => 13.4}/extra/float8.sql (100%) rename sql/{13.3 => 13.4}/extra/insert.sql (100%) rename sql/{13.3 => 13.4}/extra/int4.sql (100%) rename sql/{13.3 => 13.4}/extra/int8.sql (100%) rename sql/{13.3 => 13.4}/extra/join.sql (100%) rename sql/{13.3 => 13.4}/extra/limit.sql (100%) rename sql/{13.3 => 13.4}/extra/numeric.sql (100%) rename sql/{13.3 => 13.4}/extra/prepare.sql (100%) rename sql/{13.3 => 13.4}/extra/select.sql (100%) rename sql/{13.3 => 13.4}/extra/select_having.sql (100%) rename sql/{13.3 => 13.4}/extra/sqlite_fdw_post.sql (100%) rename sql/{13.3 => 13.4}/extra/timestamp.sql (100%) rename sql/{13.3 => 13.4}/extra/update.sql (100%) rename sql/{13.3 => 13.4}/selectfunc.sql (100%) rename sql/{13.3 => 13.4}/sqlite_fdw.sql (97%) rename sql/{13.3 => 13.4}/type.sql (100%) rename sql/{14beta2 => 14.0}/aggregate.sql (100%) rename sql/{14beta2 => 14.0}/extra/aggregates.sql (98%) rename sql/{14beta2 => 14.0}/extra/float4.sql (100%) rename sql/{14beta2 => 14.0}/extra/float8.sql (100%) rename sql/{14beta2 => 14.0}/extra/insert.sql (100%) rename sql/{14beta2 => 14.0}/extra/int4.sql (100%) rename sql/{14beta2 => 14.0}/extra/int8.sql (100%) rename sql/{14beta2 => 14.0}/extra/join.sql (98%) rename sql/{14beta2 => 14.0}/extra/limit.sql (100%) rename sql/{14beta2 => 14.0}/extra/numeric.sql (95%) rename sql/{14beta2 => 14.0}/extra/prepare.sql (100%) rename sql/{14beta2 => 14.0}/extra/select.sql (100%) rename sql/{14beta2 => 14.0}/extra/select_having.sql (100%) rename sql/{14beta2 => 14.0}/extra/sqlite_fdw_post.sql (96%) rename sql/{14beta2 => 14.0}/extra/timestamp.sql (100%) rename sql/{14beta2 => 14.0}/extra/update.sql (100%) rename sql/{14beta2 => 14.0}/selectfunc.sql (100%) create mode 100644 sql/14.0/sqlite_fdw.sql rename sql/{14beta2 => 14.0}/type.sql (100%) delete mode 100644 sql/14beta2/sqlite_fdw.sql diff --git a/META.json b/META.json index 9b6d4404..2f3d8924 100644 --- a/META.json +++ b/META.json @@ -2,7 +2,7 @@ "name": "sqlite_fdw", "abstract": "Foreign Data Wrapper for SQLite databases", "description": "PostgreSQL extension which implements a Foreign Data Wrapper (FDW) for SQLite databases.", - "version": "2.1.0", + "version": "2.1.1", "maintainer": "pgspider", "license": "postgresql", "provides": { @@ -10,7 +10,7 @@ "abstract": "Foreign Data Wrapper for SQLite databases", "file": "sqlite_fdw.c", "docfile": "README.md", - "version": "2.1.0" + "version": "2.1.1" } }, "prereqs": { diff --git a/README.md b/README.md index 678241ee..dcd8a654 100644 --- a/README.md +++ b/README.md @@ -79,9 +79,11 @@ SELECT * FROM t1; - Support list cached connections to foreign servers by using function sqlite_fdw_get_connections() - Support discard cached connections to foreign servers by using function sqlite_fdw_disconnect(), sqlite_fdw_disconnect_all(). - Support Bulk Insert by using batch_size option +- Support Insert/Update with generated column ## Limitations - `COPY` command for foreign tables is not supported +- IMPORT of generated column is not supported - Insert into a partitioned table which has foreign partitions is not supported - TRUNCATE in sqlite_fdw always delete data of both parent and child tables (no matter user inputs `TRUNCATE table CASCADE` or `TRUNCATE table RESTRICT`) if there are foreign-keys references with "ON DELETE CASCADE" clause. ## Contributing diff --git a/connection.c b/connection.c index e758f7c7..b2693ce3 100644 --- a/connection.c +++ b/connection.c @@ -48,6 +48,7 @@ typedef struct ConnCacheEntry bool truncatable; /* check table can truncate or not */ bool invalidated; /* true if reconnect is pending */ Oid serverid; /* foreign server OID used to get server name */ + List *stmtList; /* list stmt associated with conn */ uint32 server_hashvalue; /* hash value of foreign server OID */ uint32 mapping_hashvalue; /* hash value of user mapping OID */ } ConnCacheEntry; @@ -76,6 +77,8 @@ static void sqlitefdw_inval_callback(Datum arg, int cacheid, uint32 hashvalue); #if PG_VERSION_NUM >= 140000 static bool sqlite_disconnect_cached_connections(Oid serverid); #endif +static void sqlite_finalize_list_stmt(List **list); +static List *sqlite_append_stmt_to_list(List *list, sqlite3_stmt * stmt); /* * sqlite_get_connection: @@ -187,6 +190,7 @@ sqlite_make_new_connection(ConnCacheEntry *entry, ForeignServer *server) entry->serverid = server->serverid; entry->xact_depth = 0; entry->invalidated = false; + entry->stmtList = NULL; entry->keep_connections = true; entry->server_hashvalue = GetSysCacheHashValue1(FOREIGNSERVEROID, @@ -240,16 +244,11 @@ sqlite_cleanup_connection(void) hash_seq_init(&scan, ConnectionHash); while ((entry = (ConnCacheEntry *) hash_seq_search(&scan))) { - sqlite3_stmt *cur = NULL; - if (entry->conn == NULL) continue; - while ((cur = sqlite3_next_stmt(entry->conn, cur)) != NULL) - { - elog(DEBUG1, "finalize %s", sqlite3_sql(cur)); - sqlite3_finalize(cur); - } + sqlite_finalize_list_stmt(&entry->stmtList); + elog(DEBUG1, "disconnecting sqlite_fdw connection %p", entry->conn); rc = sqlite3_close(entry->conn); entry->conn = NULL; @@ -359,10 +358,6 @@ sqlitefdw_report_error(int elevel, sqlite3_stmt * stmt, sqlite3 * conn, if (sql) sql = pstrdup(sqlite3_sql(stmt)); } - - if (stmt) - sqlite3_finalize(stmt); - ereport(ERROR, (errcode(sqlstate), errmsg("failed to execute remote SQL: rc=%d %s \n sql=%s", @@ -412,6 +407,8 @@ sqlitefdw_xact_callback(XactEvent event, void *arg) /* Commit all remote transactions during pre-commit */ if (!sqlite3_get_autocommit(entry->conn)) sqlite_do_sql_command(entry->conn, "COMMIT", ERROR); + /* Finalize all prepared statements */ + sqlite_finalize_list_stmt(&entry->stmtList); break; case XACT_EVENT_PRE_PREPARE: @@ -437,15 +434,10 @@ sqlitefdw_xact_callback(XactEvent event, void *arg) case XACT_EVENT_PARALLEL_ABORT: case XACT_EVENT_ABORT: { - sqlite3_stmt *cur = NULL; - elog(DEBUG3, "abort transaction"); /* Finalize all prepared statements */ - while ((cur = sqlite3_next_stmt(entry->conn, NULL)) != NULL) - { - sqlite3_finalize(cur); - } + sqlite_finalize_list_stmt(&entry->stmtList); /* * rollback if in transaction because SQLite may @@ -880,6 +872,7 @@ sqlite_disconnect_cached_connections(Oid serverid) else { elog(DEBUG3, "discarding sqlite_fdw connection %p", entry->conn); + sqlite_finalize_list_stmt(&entry->stmtList); sqlite3_close(entry->conn); entry->conn = NULL; result = true; @@ -889,3 +882,61 @@ sqlite_disconnect_cached_connections(Oid serverid) return result; } #endif + +/* + * cache sqlite3 statement to finalize at the end of transaction + */ +void +sqlite_cache_stmt(ForeignServer *server, sqlite3_stmt * *stmt) +{ + bool found; + ConnCacheEntry *entry; + ConnCacheKey key = server->serverid; + + /* + * Find cached entry for requested connection. + */ + entry = hash_search(ConnectionHash, &key, HASH_ENTER, &found); + + /* We must always have found the entry */ + Assert(found); + + entry->stmtList = sqlite_append_stmt_to_list(entry->stmtList, *stmt); +} + +/* + * finalize all sqlite statement + */ +static void +sqlite_finalize_list_stmt(List **list) +{ + ListCell *lc; + + foreach(lc, *list) + { + sqlite3_stmt *stmt = (sqlite3_stmt *) lfirst(lc); + + elog(DEBUG1, "sqlite_fdw: finalize %s", sqlite3_sql(stmt)); + sqlite3_finalize(stmt); + } + + list_free(*list); + *list = NULL; +} + +/* + * append sqlite3 stmt to the head of linked list + */ +static List * +sqlite_append_stmt_to_list(List *list, sqlite3_stmt * stmt) +{ + /* + * CurrentMemoryContext is released before cleanup transaction (when the + * list is called), so, use TopMemoryContext instead. + */ + MemoryContext oldcontext = MemoryContextSwitchTo(TopMemoryContext); + + list = lappend(list, stmt); + MemoryContextSwitchTo(oldcontext); + return list; +} diff --git a/deparse.c b/deparse.c index 978c0d40..c4f27b92 100644 --- a/deparse.c +++ b/deparse.c @@ -1545,6 +1545,10 @@ sqlite_deparse_insert(StringInfo buf, PlannerInfo *root, List *targetAttrs, bool doNothing, int *values_end_len) { +#if PG_VERSION_NUM >= 140000 + TupleDesc tupdesc = RelationGetDescr(rel); + bool all_columns_generated = true; +#endif AttrNumber pindex; bool first; ListCell *lc; @@ -1552,7 +1556,34 @@ sqlite_deparse_insert(StringInfo buf, PlannerInfo *root, appendStringInfo(buf, "INSERT %sINTO ", doNothing ? "OR IGNORE " : ""); sqlite_deparse_relation(buf, rel); +#if PG_VERSION_NUM >= 140000 + + /* + * Check all columns in table that they are all generated column or not. + * If true, we will skip all columns and just add 'DEFAULT VALUES'. If + * not, we still push down other columns which are not generated column. + */ if (targetAttrs) + { + foreach(lc, targetAttrs) + { + int attnum = linitial_int(targetAttrs); + Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1); + + if (!attr->attgenerated) + { + all_columns_generated = false; + break; + } + } + } +#endif + +#if (PG_VERSION_NUM >= 140000) + if (targetAttrs && !all_columns_generated) +#else + if (targetAttrs) +#endif { appendStringInfoChar(buf, '('); @@ -1560,12 +1591,20 @@ sqlite_deparse_insert(StringInfo buf, PlannerInfo *root, foreach(lc, targetAttrs) { int attnum = lfirst_int(lc); +#if PG_VERSION_NUM >= 140000 + Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1); - if (!first) - appendStringInfoString(buf, ", "); - first = false; + if (!attr->attgenerated) + { +#endif + if (!first) + appendStringInfoString(buf, ", "); + first = false; - sqlite_deparse_column_ref(buf, rtindex, attnum, root, false); + sqlite_deparse_column_ref(buf, rtindex, attnum, root, false); +#if PG_VERSION_NUM >= 140000 + } +#endif } appendStringInfoString(buf, ") VALUES ("); @@ -1574,12 +1613,21 @@ sqlite_deparse_insert(StringInfo buf, PlannerInfo *root, first = true; foreach(lc, targetAttrs) { - if (!first) - appendStringInfoString(buf, ", "); - first = false; +#if PG_VERSION_NUM >= 140000 + int attnum = lfirst_int(lc); + Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1); - appendStringInfo(buf, "?"); - pindex++; + if (!attr->attgenerated) + { +#endif + if (!first) + appendStringInfoString(buf, ", "); + first = false; + appendStringInfo(buf, "?"); + pindex++; +#if PG_VERSION_NUM >= 140000 + } +#endif } appendStringInfoChar(buf, ')'); @@ -1597,13 +1645,14 @@ sqlite_deparse_insert(StringInfo buf, PlannerInfo *root, * right number of parameters. */ void -sqlite_rebuild_insert(StringInfo buf, char *orig_query, - int values_end_len, int num_cols, +sqlite_rebuild_insert(StringInfo buf, Relation rel, char *orig_query, + List *target_attrs, int values_end_len, int num_params, int num_rows) { - int i, - j; + TupleDesc tupdesc = RelationGetDescr(rel); + int i; bool first; + ListCell *lc; /* Make sure the values_end_len is sensible */ Assert((values_end_len > 0) && (values_end_len <= strlen(orig_query))); @@ -1620,13 +1669,19 @@ sqlite_rebuild_insert(StringInfo buf, char *orig_query, appendStringInfoString(buf, ", ("); first = true; - for (j = 0; j < num_cols; j++) + foreach(lc, target_attrs) { - if (!first) - appendStringInfoString(buf, ", "); - first = false; + int attnum = lfirst_int(lc); + Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1); + + if (!attr->attgenerated) + { + if (!first) + appendStringInfoString(buf, ", "); + first = false; - appendStringInfo(buf, "?"); + appendStringInfo(buf, "?"); + } } appendStringInfoChar(buf, ')'); @@ -2028,6 +2083,9 @@ sqlite_deparse_update(StringInfo buf, PlannerInfo *root, Index rtindex, Relation rel, List *targetAttrs, List *attnums) { +#if PG_VERSION_NUM >= 140000 + TupleDesc tupdesc = RelationGetDescr(rel); +#endif AttrNumber pindex; bool first; ListCell *lc; @@ -2042,14 +2100,21 @@ sqlite_deparse_update(StringInfo buf, PlannerInfo *root, foreach(lc, targetAttrs) { int attnum = lfirst_int(lc); +#if PG_VERSION_NUM >= 140000 + Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1); - if (!first) - appendStringInfoString(buf, ", "); - first = false; - - sqlite_deparse_column_ref(buf, rtindex, attnum, root, false); - appendStringInfo(buf, " = ?"); - pindex++; + if (!attr->attgenerated) + { +#endif + if (!first) + appendStringInfoString(buf, ", "); + first = false; + sqlite_deparse_column_ref(buf, rtindex, attnum, root, false); + appendStringInfo(buf, " = ?"); + pindex++; +#if PG_VERSION_NUM >= 140000 + } +#endif } i = 0; foreach(lc, attnums) diff --git a/expected/10.17/aggregate.out b/expected/10.18/aggregate.out similarity index 100% rename from expected/10.17/aggregate.out rename to expected/10.18/aggregate.out diff --git a/expected/10.17/extra/aggregates.out b/expected/10.18/extra/aggregates.out similarity index 100% rename from expected/10.17/extra/aggregates.out rename to expected/10.18/extra/aggregates.out diff --git a/expected/10.17/extra/float4.out b/expected/10.18/extra/float4.out similarity index 100% rename from expected/10.17/extra/float4.out rename to expected/10.18/extra/float4.out diff --git a/expected/10.17/extra/float8.out b/expected/10.18/extra/float8.out similarity index 100% rename from expected/10.17/extra/float8.out rename to expected/10.18/extra/float8.out diff --git a/expected/10.17/extra/insert.out b/expected/10.18/extra/insert.out similarity index 100% rename from expected/10.17/extra/insert.out rename to expected/10.18/extra/insert.out diff --git a/expected/10.17/extra/int4.out b/expected/10.18/extra/int4.out similarity index 100% rename from expected/10.17/extra/int4.out rename to expected/10.18/extra/int4.out diff --git a/expected/10.17/extra/int8.out b/expected/10.18/extra/int8.out similarity index 100% rename from expected/10.17/extra/int8.out rename to expected/10.18/extra/int8.out diff --git a/expected/10.17/extra/join.out b/expected/10.18/extra/join.out similarity index 100% rename from expected/10.17/extra/join.out rename to expected/10.18/extra/join.out diff --git a/expected/10.17/extra/limit.out b/expected/10.18/extra/limit.out similarity index 100% rename from expected/10.17/extra/limit.out rename to expected/10.18/extra/limit.out diff --git a/expected/10.17/extra/numeric.out b/expected/10.18/extra/numeric.out similarity index 100% rename from expected/10.17/extra/numeric.out rename to expected/10.18/extra/numeric.out diff --git a/expected/10.17/extra/prepare.out b/expected/10.18/extra/prepare.out similarity index 100% rename from expected/10.17/extra/prepare.out rename to expected/10.18/extra/prepare.out diff --git a/expected/10.17/extra/select.out b/expected/10.18/extra/select.out similarity index 100% rename from expected/10.17/extra/select.out rename to expected/10.18/extra/select.out diff --git a/expected/10.17/extra/select_having.out b/expected/10.18/extra/select_having.out similarity index 100% rename from expected/10.17/extra/select_having.out rename to expected/10.18/extra/select_having.out diff --git a/expected/10.17/extra/sqlite_fdw_post.out b/expected/10.18/extra/sqlite_fdw_post.out similarity index 99% rename from expected/10.17/extra/sqlite_fdw_post.out rename to expected/10.18/extra/sqlite_fdw_post.out index b68268f5..12ed846b 100644 --- a/expected/10.17/extra/sqlite_fdw_post.out +++ b/expected/10.18/extra/sqlite_fdw_post.out @@ -8887,6 +8887,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest1; import_dest1 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest1 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest1 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest1 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest1 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest1 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest1 | loct | sqlite_svr | ("table" 'loct') | @@ -8905,7 +8906,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest1; import_dest1 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest1 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest1 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) --Testcase 478: \d import_dest1.* @@ -9003,6 +9004,13 @@ FDW options: ("table" 'ft3') Server: sqlite_svr FDW options: ("table" 'grem1') + Foreign table "import_dest1.grem1_post14" + Column | Type | Collation | Nullable | Default | FDW options +--------+--------+-----------+----------+---------+-------------- + a | bigint | | | | (key 'true') +Server: sqlite_svr +FDW options: ("table" 'grem1_post14') + Foreign table "import_dest1.loc1" Column | Type | Collation | Nullable | Default | FDW options --------+--------+-----------+----------+---------+-------------- @@ -9173,6 +9181,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest2 import_dest2 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest2 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest2 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest2 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest2 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest2 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest2 | loct | sqlite_svr | ("table" 'loct') | @@ -9191,7 +9200,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest2 import_dest2 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest2 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest2 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) --Testcase 480: \d import_dest2.* @@ -9289,6 +9298,13 @@ FDW options: ("table" 'ft3') Server: sqlite_svr FDW options: ("table" 'grem1') + Foreign table "import_dest2.grem1_post14" + Column | Type | Collation | Nullable | Default | FDW options +--------+--------+-----------+----------+---------+-------------- + a | bigint | | | | (key 'true') +Server: sqlite_svr +FDW options: ("table" 'grem1_post14') + Foreign table "import_dest2.loc1" Column | Type | Collation | Nullable | Default | FDW options --------+--------+-----------+----------+---------+-------------- @@ -9470,6 +9486,7 @@ IMPORT FOREIGN SCHEMA public EXCEPT ("T 1", loct6, nonesuch) import_dest3 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest3 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest3 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest3 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest3 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest3 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest3 | loct | sqlite_svr | ("table" 'loct') | @@ -9488,7 +9505,7 @@ IMPORT FOREIGN SCHEMA public EXCEPT ("T 1", loct6, nonesuch) import_dest3 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest3 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest3 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) -- Assorted error cases IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest3; @@ -9798,7 +9815,7 @@ DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr; DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr2; --Testcase 735: DROP SERVER sqlite_svr CASCADE; -NOTICE: drop cascades to 120 other objects +NOTICE: drop cascades to 124 other objects DETAIL: drop cascades to foreign table "S 1"."T 0" drop cascades to foreign table "S 1"."T 1" drop cascades to foreign table "S 1"."T 2" @@ -9819,6 +9836,7 @@ drop cascades to foreign table "S 1".local_tbl drop cascades to foreign table "S 1".ft3 drop cascades to foreign table "S 1".foreign_tbl drop cascades to foreign table "S 1".grem1 +drop cascades to foreign table "S 1".grem1_post14 drop cascades to foreign table "S 1".t1_constraint drop cascades to foreign table "S 1".tru_rtable0 drop cascades to foreign table "S 1".tru_pk_table @@ -9855,6 +9873,7 @@ drop cascades to foreign table import_dest1.local_tbl drop cascades to foreign table import_dest1.ft3 drop cascades to foreign table import_dest1.foreign_tbl drop cascades to foreign table import_dest1.grem1 +drop cascades to foreign table import_dest1.grem1_post14 drop cascades to foreign table import_dest1.t1_constraint drop cascades to foreign table import_dest1.tru_rtable0 drop cascades to foreign table import_dest1.tru_pk_table @@ -9883,6 +9902,7 @@ drop cascades to foreign table import_dest2.local_tbl drop cascades to foreign table import_dest2.ft3 drop cascades to foreign table import_dest2.foreign_tbl drop cascades to foreign table import_dest2.grem1 +drop cascades to foreign table import_dest2.grem1_post14 drop cascades to foreign table import_dest2.t1_constraint drop cascades to foreign table import_dest2.tru_rtable0 drop cascades to foreign table import_dest2.tru_pk_table @@ -9896,10 +9916,7 @@ drop cascades to foreign table import_dest3.loct6 drop cascades to foreign table import_dest3."T 0" drop cascades to foreign table import_dest3."T 2" drop cascades to foreign table import_dest3."T 3" -drop cascades to foreign table import_dest3."T 4" -drop cascades to foreign table import_dest3.base_tbl -drop cascades to foreign table import_dest3.loc1 -and 20 other objects (see server log for list) +and 24 other objects (see server log for list) --Testcase 736: DROP SERVER sqlite_svr2 CASCADE; NOTICE: drop cascades to foreign table ft6 diff --git a/expected/10.17/extra/timestamp.out b/expected/10.18/extra/timestamp.out similarity index 100% rename from expected/10.17/extra/timestamp.out rename to expected/10.18/extra/timestamp.out diff --git a/expected/10.17/extra/update.out b/expected/10.18/extra/update.out similarity index 100% rename from expected/10.17/extra/update.out rename to expected/10.18/extra/update.out diff --git a/expected/10.17/selectfunc.out b/expected/10.18/selectfunc.out similarity index 100% rename from expected/10.17/selectfunc.out rename to expected/10.18/selectfunc.out diff --git a/expected/10.17/sqlite_fdw.out b/expected/10.18/sqlite_fdw.out similarity index 98% rename from expected/10.17/sqlite_fdw.out rename to expected/10.18/sqlite_fdw.out index a6860477..ccef52b6 100644 --- a/expected/10.17/sqlite_fdw.out +++ b/expected/10.18/sqlite_fdw.out @@ -1473,16 +1473,33 @@ SELECT * FROM noprimary; SELECT * FROM public.sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20100 + 20101 (1 row) --Testcase 155: SELECT sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20100 + 20101 (1 row) +-- issue #44 github +--Testcase 156: +CREATE FOREIGN TABLE fts_table (name text, description text) SERVER sqlite_svr; +--Testcase 157: +INSERT INTO fts_table VALUES ('this is name', 'this is description'); +--Testcase 158: +SELECT * FROM fts_table; -- should work + name | description +--------------+--------------------- + this is name | this is description +(1 row) + +--Testcase 159: +ALTER TABLE fts_table ALTER COLUMN name TYPE int; +--Testcase 160: +SELECT * FROM fts_table; -- should fail +ERROR: invalid input syntax for type =1, column type =3 --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -1501,6 +1518,8 @@ DROP FOREIGN TABLE multiprimary2; DROP FOREIGN TABLE columntest; --Testcase 150: DROP FOREIGN TABLE noprimary; +--Testcase 161: +DROP FOREIGN TABLE fts_table; --Testcase 151: DROP SERVER sqlite_svr; --Testcase 152: diff --git a/expected/11.12/type.out b/expected/10.18/type.out similarity index 96% rename from expected/11.12/type.out rename to expected/10.18/type.out index f0cbbbb5..d1c05b99 100644 --- a/expected/11.12/type.out +++ b/expected/10.18/type.out @@ -309,7 +309,7 @@ SELECT * FROM type_JSON; DELETE FROM type_JSON; --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 31 other objects +NOTICE: drop cascades to 39 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -320,6 +320,8 @@ 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 "type_STRING" drop cascades to foreign table "type_BOOLEAN" drop cascades to foreign table "type_BYTE" @@ -339,5 +341,11 @@ 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 type_json drop cascades to server sqlite2 diff --git a/expected/11.12/aggregate.out b/expected/11.13/aggregate.out similarity index 100% rename from expected/11.12/aggregate.out rename to expected/11.13/aggregate.out diff --git a/expected/11.12/extra/aggregates.out b/expected/11.13/extra/aggregates.out similarity index 100% rename from expected/11.12/extra/aggregates.out rename to expected/11.13/extra/aggregates.out diff --git a/expected/11.12/extra/float4.out b/expected/11.13/extra/float4.out similarity index 100% rename from expected/11.12/extra/float4.out rename to expected/11.13/extra/float4.out diff --git a/expected/11.12/extra/float8.out b/expected/11.13/extra/float8.out similarity index 100% rename from expected/11.12/extra/float8.out rename to expected/11.13/extra/float8.out diff --git a/expected/11.12/extra/insert.out b/expected/11.13/extra/insert.out similarity index 100% rename from expected/11.12/extra/insert.out rename to expected/11.13/extra/insert.out diff --git a/expected/11.12/extra/int4.out b/expected/11.13/extra/int4.out similarity index 100% rename from expected/11.12/extra/int4.out rename to expected/11.13/extra/int4.out diff --git a/expected/11.12/extra/int8.out b/expected/11.13/extra/int8.out similarity index 100% rename from expected/11.12/extra/int8.out rename to expected/11.13/extra/int8.out diff --git a/expected/11.12/extra/join.out b/expected/11.13/extra/join.out similarity index 100% rename from expected/11.12/extra/join.out rename to expected/11.13/extra/join.out diff --git a/expected/11.12/extra/limit.out b/expected/11.13/extra/limit.out similarity index 100% rename from expected/11.12/extra/limit.out rename to expected/11.13/extra/limit.out diff --git a/expected/11.12/extra/numeric.out b/expected/11.13/extra/numeric.out similarity index 100% rename from expected/11.12/extra/numeric.out rename to expected/11.13/extra/numeric.out diff --git a/expected/11.12/extra/prepare.out b/expected/11.13/extra/prepare.out similarity index 100% rename from expected/11.12/extra/prepare.out rename to expected/11.13/extra/prepare.out diff --git a/expected/11.12/extra/select.out b/expected/11.13/extra/select.out similarity index 100% rename from expected/11.12/extra/select.out rename to expected/11.13/extra/select.out diff --git a/expected/11.12/extra/select_having.out b/expected/11.13/extra/select_having.out similarity index 100% rename from expected/11.12/extra/select_having.out rename to expected/11.13/extra/select_having.out diff --git a/expected/11.12/extra/sqlite_fdw_post.out b/expected/11.13/extra/sqlite_fdw_post.out similarity index 99% rename from expected/11.12/extra/sqlite_fdw_post.out rename to expected/11.13/extra/sqlite_fdw_post.out index a2fa9e6b..220209b8 100644 --- a/expected/11.12/extra/sqlite_fdw_post.out +++ b/expected/11.13/extra/sqlite_fdw_post.out @@ -8887,6 +8887,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest1; import_dest1 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest1 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest1 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest1 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest1 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest1 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest1 | loct | sqlite_svr | ("table" 'loct') | @@ -8905,7 +8906,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest1; import_dest1 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest1 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest1 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) --Testcase 478: \d import_dest1.* @@ -9003,6 +9004,13 @@ FDW options: ("table" 'ft3') Server: sqlite_svr FDW options: ("table" 'grem1') + Foreign table "import_dest1.grem1_post14" + Column | Type | Collation | Nullable | Default | FDW options +--------+--------+-----------+----------+---------+-------------- + a | bigint | | | | (key 'true') +Server: sqlite_svr +FDW options: ("table" 'grem1_post14') + Foreign table "import_dest1.loc1" Column | Type | Collation | Nullable | Default | FDW options --------+--------+-----------+----------+---------+-------------- @@ -9173,6 +9181,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest2 import_dest2 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest2 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest2 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest2 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest2 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest2 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest2 | loct | sqlite_svr | ("table" 'loct') | @@ -9191,7 +9200,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest2 import_dest2 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest2 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest2 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) --Testcase 480: \d import_dest2.* @@ -9289,6 +9298,13 @@ FDW options: ("table" 'ft3') Server: sqlite_svr FDW options: ("table" 'grem1') + Foreign table "import_dest2.grem1_post14" + Column | Type | Collation | Nullable | Default | FDW options +--------+--------+-----------+----------+---------+-------------- + a | bigint | | | | (key 'true') +Server: sqlite_svr +FDW options: ("table" 'grem1_post14') + Foreign table "import_dest2.loc1" Column | Type | Collation | Nullable | Default | FDW options --------+--------+-----------+----------+---------+-------------- @@ -9470,6 +9486,7 @@ IMPORT FOREIGN SCHEMA public EXCEPT ("T 1", loct6, nonesuch) import_dest3 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest3 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest3 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest3 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest3 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest3 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest3 | loct | sqlite_svr | ("table" 'loct') | @@ -9488,7 +9505,7 @@ IMPORT FOREIGN SCHEMA public EXCEPT ("T 1", loct6, nonesuch) import_dest3 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest3 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest3 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) -- Assorted error cases IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest3; @@ -9798,7 +9815,7 @@ DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr; DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr2; --Testcase 735: DROP SERVER sqlite_svr CASCADE; -NOTICE: drop cascades to 120 other objects +NOTICE: drop cascades to 124 other objects DETAIL: drop cascades to foreign table "S 1"."T 0" drop cascades to foreign table "S 1"."T 1" drop cascades to foreign table "S 1"."T 2" @@ -9819,6 +9836,7 @@ drop cascades to foreign table "S 1".local_tbl drop cascades to foreign table "S 1".ft3 drop cascades to foreign table "S 1".foreign_tbl drop cascades to foreign table "S 1".grem1 +drop cascades to foreign table "S 1".grem1_post14 drop cascades to foreign table "S 1".t1_constraint drop cascades to foreign table "S 1".tru_rtable0 drop cascades to foreign table "S 1".tru_pk_table @@ -9855,6 +9873,7 @@ drop cascades to foreign table import_dest1.local_tbl drop cascades to foreign table import_dest1.ft3 drop cascades to foreign table import_dest1.foreign_tbl drop cascades to foreign table import_dest1.grem1 +drop cascades to foreign table import_dest1.grem1_post14 drop cascades to foreign table import_dest1.t1_constraint drop cascades to foreign table import_dest1.tru_rtable0 drop cascades to foreign table import_dest1.tru_pk_table @@ -9883,6 +9902,7 @@ drop cascades to foreign table import_dest2.local_tbl drop cascades to foreign table import_dest2.ft3 drop cascades to foreign table import_dest2.foreign_tbl drop cascades to foreign table import_dest2.grem1 +drop cascades to foreign table import_dest2.grem1_post14 drop cascades to foreign table import_dest2.t1_constraint drop cascades to foreign table import_dest2.tru_rtable0 drop cascades to foreign table import_dest2.tru_pk_table @@ -9896,10 +9916,7 @@ drop cascades to foreign table import_dest3.loct6 drop cascades to foreign table import_dest3."T 0" drop cascades to foreign table import_dest3."T 2" drop cascades to foreign table import_dest3."T 3" -drop cascades to foreign table import_dest3."T 4" -drop cascades to foreign table import_dest3.base_tbl -drop cascades to foreign table import_dest3.loc1 -and 20 other objects (see server log for list) +and 24 other objects (see server log for list) --Testcase 736: DROP SERVER sqlite_svr2 CASCADE; NOTICE: drop cascades to foreign table ft6 diff --git a/expected/11.12/extra/timestamp.out b/expected/11.13/extra/timestamp.out similarity index 100% rename from expected/11.12/extra/timestamp.out rename to expected/11.13/extra/timestamp.out diff --git a/expected/11.12/extra/update.out b/expected/11.13/extra/update.out similarity index 100% rename from expected/11.12/extra/update.out rename to expected/11.13/extra/update.out diff --git a/expected/11.12/selectfunc.out b/expected/11.13/selectfunc.out similarity index 100% rename from expected/11.12/selectfunc.out rename to expected/11.13/selectfunc.out diff --git a/expected/11.12/sqlite_fdw.out b/expected/11.13/sqlite_fdw.out similarity index 98% rename from expected/11.12/sqlite_fdw.out rename to expected/11.13/sqlite_fdw.out index 56173817..0e09767b 100644 --- a/expected/11.12/sqlite_fdw.out +++ b/expected/11.13/sqlite_fdw.out @@ -1473,16 +1473,33 @@ SELECT * FROM noprimary; SELECT * FROM public.sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20100 + 20101 (1 row) --Testcase 155: SELECT sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20100 + 20101 (1 row) +-- issue #44 github +--Testcase 156: +CREATE FOREIGN TABLE fts_table (name text, description text) SERVER sqlite_svr; +--Testcase 157: +INSERT INTO fts_table VALUES ('this is name', 'this is description'); +--Testcase 158: +SELECT * FROM fts_table; -- should work + name | description +--------------+--------------------- + this is name | this is description +(1 row) + +--Testcase 159: +ALTER TABLE fts_table ALTER COLUMN name TYPE int; +--Testcase 160: +SELECT * FROM fts_table; -- should fail +ERROR: invalid input syntax for type =1, column type =3 --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -1501,6 +1518,8 @@ DROP FOREIGN TABLE multiprimary2; DROP FOREIGN TABLE columntest; --Testcase 150: DROP FOREIGN TABLE noprimary; +--Testcase 161: +DROP FOREIGN TABLE fts_table; --Testcase 151: DROP SERVER sqlite_svr; --Testcase 152: diff --git a/expected/12.7/type.out b/expected/11.13/type.out similarity index 96% rename from expected/12.7/type.out rename to expected/11.13/type.out index f0cbbbb5..d1c05b99 100644 --- a/expected/12.7/type.out +++ b/expected/11.13/type.out @@ -309,7 +309,7 @@ SELECT * FROM type_JSON; DELETE FROM type_JSON; --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 31 other objects +NOTICE: drop cascades to 39 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -320,6 +320,8 @@ 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 "type_STRING" drop cascades to foreign table "type_BOOLEAN" drop cascades to foreign table "type_BYTE" @@ -339,5 +341,11 @@ 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 type_json drop cascades to server sqlite2 diff --git a/expected/12.7/aggregate.out b/expected/12.8/aggregate.out similarity index 100% rename from expected/12.7/aggregate.out rename to expected/12.8/aggregate.out diff --git a/expected/12.7/extra/aggregates.out b/expected/12.8/extra/aggregates.out similarity index 100% rename from expected/12.7/extra/aggregates.out rename to expected/12.8/extra/aggregates.out diff --git a/expected/12.7/extra/float4.out b/expected/12.8/extra/float4.out similarity index 100% rename from expected/12.7/extra/float4.out rename to expected/12.8/extra/float4.out diff --git a/expected/12.7/extra/float8.out b/expected/12.8/extra/float8.out similarity index 100% rename from expected/12.7/extra/float8.out rename to expected/12.8/extra/float8.out diff --git a/expected/12.7/extra/insert.out b/expected/12.8/extra/insert.out similarity index 100% rename from expected/12.7/extra/insert.out rename to expected/12.8/extra/insert.out diff --git a/expected/12.7/extra/int4.out b/expected/12.8/extra/int4.out similarity index 100% rename from expected/12.7/extra/int4.out rename to expected/12.8/extra/int4.out diff --git a/expected/12.7/extra/int8.out b/expected/12.8/extra/int8.out similarity index 100% rename from expected/12.7/extra/int8.out rename to expected/12.8/extra/int8.out diff --git a/expected/12.7/extra/join.out b/expected/12.8/extra/join.out similarity index 100% rename from expected/12.7/extra/join.out rename to expected/12.8/extra/join.out diff --git a/expected/12.7/extra/limit.out b/expected/12.8/extra/limit.out similarity index 100% rename from expected/12.7/extra/limit.out rename to expected/12.8/extra/limit.out diff --git a/expected/12.7/extra/numeric.out b/expected/12.8/extra/numeric.out similarity index 100% rename from expected/12.7/extra/numeric.out rename to expected/12.8/extra/numeric.out diff --git a/expected/12.7/extra/prepare.out b/expected/12.8/extra/prepare.out similarity index 100% rename from expected/12.7/extra/prepare.out rename to expected/12.8/extra/prepare.out diff --git a/expected/12.7/extra/select.out b/expected/12.8/extra/select.out similarity index 100% rename from expected/12.7/extra/select.out rename to expected/12.8/extra/select.out diff --git a/expected/12.7/extra/select_having.out b/expected/12.8/extra/select_having.out similarity index 100% rename from expected/12.7/extra/select_having.out rename to expected/12.8/extra/select_having.out diff --git a/expected/12.7/extra/sqlite_fdw_post.out b/expected/12.8/extra/sqlite_fdw_post.out similarity index 99% rename from expected/12.7/extra/sqlite_fdw_post.out rename to expected/12.8/extra/sqlite_fdw_post.out index 151c1144..610f4505 100644 --- a/expected/12.7/extra/sqlite_fdw_post.out +++ b/expected/12.8/extra/sqlite_fdw_post.out @@ -8922,6 +8922,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest1; import_dest1 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest1 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest1 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest1 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest1 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest1 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest1 | loct | sqlite_svr | ("table" 'loct') | @@ -8940,7 +8941,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest1; import_dest1 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest1 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest1 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) --Testcase 478: \d import_dest1.* @@ -9038,6 +9039,13 @@ FDW options: ("table" 'ft3') Server: sqlite_svr FDW options: ("table" 'grem1') + Foreign table "import_dest1.grem1_post14" + Column | Type | Collation | Nullable | Default | FDW options +--------+--------+-----------+----------+---------+-------------- + a | bigint | | | | (key 'true') +Server: sqlite_svr +FDW options: ("table" 'grem1_post14') + Foreign table "import_dest1.loc1" Column | Type | Collation | Nullable | Default | FDW options --------+--------+-----------+----------+---------+-------------- @@ -9208,6 +9216,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest2 import_dest2 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest2 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest2 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest2 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest2 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest2 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest2 | loct | sqlite_svr | ("table" 'loct') | @@ -9226,7 +9235,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest2 import_dest2 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest2 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest2 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) --Testcase 480: \d import_dest2.* @@ -9324,6 +9333,13 @@ FDW options: ("table" 'ft3') Server: sqlite_svr FDW options: ("table" 'grem1') + Foreign table "import_dest2.grem1_post14" + Column | Type | Collation | Nullable | Default | FDW options +--------+--------+-----------+----------+---------+-------------- + a | bigint | | | | (key 'true') +Server: sqlite_svr +FDW options: ("table" 'grem1_post14') + Foreign table "import_dest2.loc1" Column | Type | Collation | Nullable | Default | FDW options --------+--------+-----------+----------+---------+-------------- @@ -9505,6 +9521,7 @@ IMPORT FOREIGN SCHEMA public EXCEPT ("T 1", loct6, nonesuch) import_dest3 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest3 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest3 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest3 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest3 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest3 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest3 | loct | sqlite_svr | ("table" 'loct') | @@ -9523,7 +9540,7 @@ IMPORT FOREIGN SCHEMA public EXCEPT ("T 1", loct6, nonesuch) import_dest3 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest3 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest3 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) -- Assorted error cases IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest3; @@ -9833,7 +9850,7 @@ DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr; DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr2; --Testcase 735: DROP SERVER sqlite_svr CASCADE; -NOTICE: drop cascades to 121 other objects +NOTICE: drop cascades to 125 other objects DETAIL: drop cascades to foreign table "S 1"."T 0" drop cascades to foreign table "S 1"."T 1" drop cascades to foreign table "S 1"."T 2" @@ -9854,6 +9871,7 @@ drop cascades to foreign table "S 1".local_tbl drop cascades to foreign table "S 1".ft3 drop cascades to foreign table "S 1".foreign_tbl drop cascades to foreign table "S 1".grem1 +drop cascades to foreign table "S 1".grem1_post14 drop cascades to foreign table "S 1".t1_constraint drop cascades to foreign table "S 1".tru_rtable0 drop cascades to foreign table "S 1".tru_pk_table @@ -9891,6 +9909,7 @@ drop cascades to foreign table import_dest1.local_tbl drop cascades to foreign table import_dest1.ft3 drop cascades to foreign table import_dest1.foreign_tbl drop cascades to foreign table import_dest1.grem1 +drop cascades to foreign table import_dest1.grem1_post14 drop cascades to foreign table import_dest1.t1_constraint drop cascades to foreign table import_dest1.tru_rtable0 drop cascades to foreign table import_dest1.tru_pk_table @@ -9919,6 +9938,7 @@ drop cascades to foreign table import_dest2.local_tbl drop cascades to foreign table import_dest2.ft3 drop cascades to foreign table import_dest2.foreign_tbl drop cascades to foreign table import_dest2.grem1 +drop cascades to foreign table import_dest2.grem1_post14 drop cascades to foreign table import_dest2.t1_constraint drop cascades to foreign table import_dest2.tru_rtable0 drop cascades to foreign table import_dest2.tru_pk_table @@ -9931,10 +9951,7 @@ drop cascades to foreign table import_dest3."T 1" drop cascades to foreign table import_dest3.loct6 drop cascades to foreign table import_dest3."T 0" drop cascades to foreign table import_dest3."T 2" -drop cascades to foreign table import_dest3."T 3" -drop cascades to foreign table import_dest3."T 4" -drop cascades to foreign table import_dest3.base_tbl -and 21 other objects (see server log for list) +and 25 other objects (see server log for list) --Testcase 736: DROP SERVER sqlite_svr2 CASCADE; NOTICE: drop cascades to foreign table ft6 diff --git a/expected/12.7/extra/timestamp.out b/expected/12.8/extra/timestamp.out similarity index 100% rename from expected/12.7/extra/timestamp.out rename to expected/12.8/extra/timestamp.out diff --git a/expected/12.7/extra/update.out b/expected/12.8/extra/update.out similarity index 100% rename from expected/12.7/extra/update.out rename to expected/12.8/extra/update.out diff --git a/expected/12.7/selectfunc.out b/expected/12.8/selectfunc.out similarity index 100% rename from expected/12.7/selectfunc.out rename to expected/12.8/selectfunc.out diff --git a/expected/12.7/sqlite_fdw.out b/expected/12.8/sqlite_fdw.out similarity index 98% rename from expected/12.7/sqlite_fdw.out rename to expected/12.8/sqlite_fdw.out index 56173817..0e09767b 100644 --- a/expected/12.7/sqlite_fdw.out +++ b/expected/12.8/sqlite_fdw.out @@ -1473,16 +1473,33 @@ SELECT * FROM noprimary; SELECT * FROM public.sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20100 + 20101 (1 row) --Testcase 155: SELECT sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20100 + 20101 (1 row) +-- issue #44 github +--Testcase 156: +CREATE FOREIGN TABLE fts_table (name text, description text) SERVER sqlite_svr; +--Testcase 157: +INSERT INTO fts_table VALUES ('this is name', 'this is description'); +--Testcase 158: +SELECT * FROM fts_table; -- should work + name | description +--------------+--------------------- + this is name | this is description +(1 row) + +--Testcase 159: +ALTER TABLE fts_table ALTER COLUMN name TYPE int; +--Testcase 160: +SELECT * FROM fts_table; -- should fail +ERROR: invalid input syntax for type =1, column type =3 --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -1501,6 +1518,8 @@ DROP FOREIGN TABLE multiprimary2; DROP FOREIGN TABLE columntest; --Testcase 150: DROP FOREIGN TABLE noprimary; +--Testcase 161: +DROP FOREIGN TABLE fts_table; --Testcase 151: DROP SERVER sqlite_svr; --Testcase 152: diff --git a/expected/10.17/type.out b/expected/12.8/type.out similarity index 96% rename from expected/10.17/type.out rename to expected/12.8/type.out index f0cbbbb5..d1c05b99 100644 --- a/expected/10.17/type.out +++ b/expected/12.8/type.out @@ -309,7 +309,7 @@ SELECT * FROM type_JSON; DELETE FROM type_JSON; --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 31 other objects +NOTICE: drop cascades to 39 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -320,6 +320,8 @@ 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 "type_STRING" drop cascades to foreign table "type_BOOLEAN" drop cascades to foreign table "type_BYTE" @@ -339,5 +341,11 @@ 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 type_json drop cascades to server sqlite2 diff --git a/expected/13.3/aggregate.out b/expected/13.4/aggregate.out similarity index 100% rename from expected/13.3/aggregate.out rename to expected/13.4/aggregate.out diff --git a/expected/13.3/extra/aggregates.out b/expected/13.4/extra/aggregates.out similarity index 100% rename from expected/13.3/extra/aggregates.out rename to expected/13.4/extra/aggregates.out diff --git a/expected/13.3/extra/float4.out b/expected/13.4/extra/float4.out similarity index 100% rename from expected/13.3/extra/float4.out rename to expected/13.4/extra/float4.out diff --git a/expected/13.3/extra/float8.out b/expected/13.4/extra/float8.out similarity index 100% rename from expected/13.3/extra/float8.out rename to expected/13.4/extra/float8.out diff --git a/expected/13.3/extra/insert.out b/expected/13.4/extra/insert.out similarity index 100% rename from expected/13.3/extra/insert.out rename to expected/13.4/extra/insert.out diff --git a/expected/13.3/extra/int4.out b/expected/13.4/extra/int4.out similarity index 100% rename from expected/13.3/extra/int4.out rename to expected/13.4/extra/int4.out diff --git a/expected/13.3/extra/int8.out b/expected/13.4/extra/int8.out similarity index 100% rename from expected/13.3/extra/int8.out rename to expected/13.4/extra/int8.out diff --git a/expected/13.3/extra/join.out b/expected/13.4/extra/join.out similarity index 100% rename from expected/13.3/extra/join.out rename to expected/13.4/extra/join.out diff --git a/expected/13.3/extra/limit.out b/expected/13.4/extra/limit.out similarity index 100% rename from expected/13.3/extra/limit.out rename to expected/13.4/extra/limit.out diff --git a/expected/13.3/extra/numeric.out b/expected/13.4/extra/numeric.out similarity index 100% rename from expected/13.3/extra/numeric.out rename to expected/13.4/extra/numeric.out diff --git a/expected/13.3/extra/prepare.out b/expected/13.4/extra/prepare.out similarity index 100% rename from expected/13.3/extra/prepare.out rename to expected/13.4/extra/prepare.out diff --git a/expected/13.3/extra/select.out b/expected/13.4/extra/select.out similarity index 100% rename from expected/13.3/extra/select.out rename to expected/13.4/extra/select.out diff --git a/expected/13.3/extra/select_having.out b/expected/13.4/extra/select_having.out similarity index 100% rename from expected/13.3/extra/select_having.out rename to expected/13.4/extra/select_having.out diff --git a/expected/13.3/extra/sqlite_fdw_post.out b/expected/13.4/extra/sqlite_fdw_post.out similarity index 99% rename from expected/13.3/extra/sqlite_fdw_post.out rename to expected/13.4/extra/sqlite_fdw_post.out index f13b7547..a736380f 100644 --- a/expected/13.3/extra/sqlite_fdw_post.out +++ b/expected/13.4/extra/sqlite_fdw_post.out @@ -8924,6 +8924,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest1; import_dest1 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest1 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest1 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest1 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest1 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest1 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest1 | loct | sqlite_svr | ("table" 'loct') | @@ -8942,7 +8943,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest1; import_dest1 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest1 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest1 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) --Testcase 478: \d import_dest1.* @@ -9040,6 +9041,13 @@ FDW options: ("table" 'ft3') Server: sqlite_svr FDW options: ("table" 'grem1') + Foreign table "import_dest1.grem1_post14" + Column | Type | Collation | Nullable | Default | FDW options +--------+--------+-----------+----------+---------+-------------- + a | bigint | | | | (key 'true') +Server: sqlite_svr +FDW options: ("table" 'grem1_post14') + Foreign table "import_dest1.loc1" Column | Type | Collation | Nullable | Default | FDW options --------+--------+-----------+----------+---------+-------------- @@ -9210,6 +9218,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest2 import_dest2 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest2 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest2 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest2 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest2 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest2 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest2 | loct | sqlite_svr | ("table" 'loct') | @@ -9228,7 +9237,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest2 import_dest2 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest2 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest2 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) --Testcase 480: \d import_dest2.* @@ -9326,6 +9335,13 @@ FDW options: ("table" 'ft3') Server: sqlite_svr FDW options: ("table" 'grem1') + Foreign table "import_dest2.grem1_post14" + Column | Type | Collation | Nullable | Default | FDW options +--------+--------+-----------+----------+---------+-------------- + a | bigint | | | | (key 'true') +Server: sqlite_svr +FDW options: ("table" 'grem1_post14') + Foreign table "import_dest2.loc1" Column | Type | Collation | Nullable | Default | FDW options --------+--------+-----------+----------+---------+-------------- @@ -9507,6 +9523,7 @@ IMPORT FOREIGN SCHEMA public EXCEPT ("T 1", loct6, nonesuch) import_dest3 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest3 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest3 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest3 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest3 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest3 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest3 | loct | sqlite_svr | ("table" 'loct') | @@ -9525,7 +9542,7 @@ IMPORT FOREIGN SCHEMA public EXCEPT ("T 1", loct6, nonesuch) import_dest3 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest3 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest3 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) -- Assorted error cases IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest3; @@ -9835,7 +9852,7 @@ DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr; DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr2; --Testcase 735: DROP SERVER sqlite_svr CASCADE; -NOTICE: drop cascades to 121 other objects +NOTICE: drop cascades to 125 other objects DETAIL: drop cascades to foreign table "S 1"."T 0" drop cascades to foreign table "S 1"."T 1" drop cascades to foreign table "S 1"."T 2" @@ -9856,6 +9873,7 @@ drop cascades to foreign table "S 1".local_tbl drop cascades to foreign table "S 1".ft3 drop cascades to foreign table "S 1".foreign_tbl drop cascades to foreign table "S 1".grem1 +drop cascades to foreign table "S 1".grem1_post14 drop cascades to foreign table "S 1".t1_constraint drop cascades to foreign table "S 1".tru_rtable0 drop cascades to foreign table "S 1".tru_pk_table @@ -9893,6 +9911,7 @@ drop cascades to foreign table import_dest1.local_tbl drop cascades to foreign table import_dest1.ft3 drop cascades to foreign table import_dest1.foreign_tbl drop cascades to foreign table import_dest1.grem1 +drop cascades to foreign table import_dest1.grem1_post14 drop cascades to foreign table import_dest1.t1_constraint drop cascades to foreign table import_dest1.tru_rtable0 drop cascades to foreign table import_dest1.tru_pk_table @@ -9921,6 +9940,7 @@ drop cascades to foreign table import_dest2.local_tbl drop cascades to foreign table import_dest2.ft3 drop cascades to foreign table import_dest2.foreign_tbl drop cascades to foreign table import_dest2.grem1 +drop cascades to foreign table import_dest2.grem1_post14 drop cascades to foreign table import_dest2.t1_constraint drop cascades to foreign table import_dest2.tru_rtable0 drop cascades to foreign table import_dest2.tru_pk_table @@ -9933,10 +9953,7 @@ drop cascades to foreign table import_dest3."T 1" drop cascades to foreign table import_dest3.loct6 drop cascades to foreign table import_dest3."T 0" drop cascades to foreign table import_dest3."T 2" -drop cascades to foreign table import_dest3."T 3" -drop cascades to foreign table import_dest3."T 4" -drop cascades to foreign table import_dest3.base_tbl -and 21 other objects (see server log for list) +and 25 other objects (see server log for list) --Testcase 736: DROP SERVER sqlite_svr2 CASCADE; NOTICE: drop cascades to foreign table ft6 diff --git a/expected/13.3/extra/timestamp.out b/expected/13.4/extra/timestamp.out similarity index 100% rename from expected/13.3/extra/timestamp.out rename to expected/13.4/extra/timestamp.out diff --git a/expected/13.3/extra/update.out b/expected/13.4/extra/update.out similarity index 100% rename from expected/13.3/extra/update.out rename to expected/13.4/extra/update.out diff --git a/expected/13.3/selectfunc.out b/expected/13.4/selectfunc.out similarity index 100% rename from expected/13.3/selectfunc.out rename to expected/13.4/selectfunc.out diff --git a/expected/13.3/sqlite_fdw.out b/expected/13.4/sqlite_fdw.out similarity index 98% rename from expected/13.3/sqlite_fdw.out rename to expected/13.4/sqlite_fdw.out index 56173817..0e09767b 100644 --- a/expected/13.3/sqlite_fdw.out +++ b/expected/13.4/sqlite_fdw.out @@ -1473,16 +1473,33 @@ SELECT * FROM noprimary; SELECT * FROM public.sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20100 + 20101 (1 row) --Testcase 155: SELECT sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20100 + 20101 (1 row) +-- issue #44 github +--Testcase 156: +CREATE FOREIGN TABLE fts_table (name text, description text) SERVER sqlite_svr; +--Testcase 157: +INSERT INTO fts_table VALUES ('this is name', 'this is description'); +--Testcase 158: +SELECT * FROM fts_table; -- should work + name | description +--------------+--------------------- + this is name | this is description +(1 row) + +--Testcase 159: +ALTER TABLE fts_table ALTER COLUMN name TYPE int; +--Testcase 160: +SELECT * FROM fts_table; -- should fail +ERROR: invalid input syntax for type =1, column type =3 --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -1501,6 +1518,8 @@ DROP FOREIGN TABLE multiprimary2; DROP FOREIGN TABLE columntest; --Testcase 150: DROP FOREIGN TABLE noprimary; +--Testcase 161: +DROP FOREIGN TABLE fts_table; --Testcase 151: DROP SERVER sqlite_svr; --Testcase 152: diff --git a/expected/13.3/type.out b/expected/13.4/type.out similarity index 96% rename from expected/13.3/type.out rename to expected/13.4/type.out index f0cbbbb5..d1c05b99 100644 --- a/expected/13.3/type.out +++ b/expected/13.4/type.out @@ -309,7 +309,7 @@ SELECT * FROM type_JSON; DELETE FROM type_JSON; --Testcase 47: DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 31 other objects +NOTICE: drop cascades to 39 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -320,6 +320,8 @@ 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 "type_STRING" drop cascades to foreign table "type_BOOLEAN" drop cascades to foreign table "type_BYTE" @@ -339,5 +341,11 @@ 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 type_json drop cascades to server sqlite2 diff --git a/expected/14beta2/aggregate.out b/expected/14.0/aggregate.out similarity index 100% rename from expected/14beta2/aggregate.out rename to expected/14.0/aggregate.out diff --git a/expected/14beta2/extra/aggregates.out b/expected/14.0/extra/aggregates.out similarity index 98% rename from expected/14beta2/extra/aggregates.out rename to expected/14.0/extra/aggregates.out index d913055e..f891bb61 100644 --- a/expected/14beta2/extra/aggregates.out +++ b/expected/14.0/extra/aggregates.out @@ -2338,6 +2338,42 @@ select aggfns(distinct a,b,c order by a,c using ~<~,b) filter (where a > 1) from (1 row) rollback; +-- check handling of bare boolean Var in FILTER +--Testcase 672: +select max(0) filter (where b1) from bool_test; + max +----- + 0 +(1 row) + +--Testcase 673: +select (select max(0) filter (where b1)) from bool_test; + max +----- + 0 +(1 row) + +-- check for correct detection of nested-aggregate errors in FILTER +--Testcase 674: +select max(unique1) filter (where sum(ten) > 0) from tenk1; +ERROR: aggregate functions are not allowed in FILTER +LINE 1: select max(unique1) filter (where sum(ten) > 0) from tenk1; + ^ +--Testcase 675: +select (select max(unique1) filter (where sum(ten) > 0) from int8_tbl) from tenk1; +ERROR: aggregate function calls cannot be nested +LINE 1: select (select max(unique1) filter (where sum(ten) > 0) from... + ^ +--Testcase 676: +select max(unique1) filter (where bool_or(ten > 0)) from tenk1; +ERROR: aggregate functions are not allowed in FILTER +LINE 1: select max(unique1) filter (where bool_or(ten > 0)) from ten... + ^ +--Testcase 677: +select (select max(unique1) filter (where bool_or(ten > 0)) from int8_tbl) from tenk1; +ERROR: aggregate function calls cannot be nested +LINE 1: select (select max(unique1) filter (where bool_or(ten > 0)) ... + ^ -- ordered-set aggregates begin; --Testcase 167: @@ -3325,7 +3361,7 @@ rollback; -- does not lead to array overflow due to unexpected duplicate hash keys -- see CAFeeJoKKu0u+A_A9R9316djW-YW3-+Gtgvy3ju655qRHR3jtdA@mail.gmail.com --Testcase 641: -set enable_resultcache to off; +set enable_memoize to off; --Testcase 558: explain (costs off) select 1 from tenk1 @@ -3342,7 +3378,7 @@ explain (costs off) (7 rows) --Testcase 642: -reset enable_resultcache; +reset enable_memoize; -- -- Hash Aggregation Spill tests -- diff --git a/expected/14beta2/extra/float4.out b/expected/14.0/extra/float4.out similarity index 100% rename from expected/14beta2/extra/float4.out rename to expected/14.0/extra/float4.out diff --git a/expected/14beta2/extra/float8.out b/expected/14.0/extra/float8.out similarity index 100% rename from expected/14beta2/extra/float8.out rename to expected/14.0/extra/float8.out diff --git a/expected/14beta2/extra/insert.out b/expected/14.0/extra/insert.out similarity index 100% rename from expected/14beta2/extra/insert.out rename to expected/14.0/extra/insert.out diff --git a/expected/14beta2/extra/int4.out b/expected/14.0/extra/int4.out similarity index 100% rename from expected/14beta2/extra/int4.out rename to expected/14.0/extra/int4.out diff --git a/expected/14beta2/extra/int8.out b/expected/14.0/extra/int8.out similarity index 100% rename from expected/14beta2/extra/int8.out rename to expected/14.0/extra/int8.out diff --git a/expected/14beta2/extra/join.out b/expected/14.0/extra/join.out similarity index 99% rename from expected/14beta2/extra/join.out rename to expected/14.0/extra/join.out index 7bd97683..455f87b8 100644 --- a/expected/14beta2/extra/join.out +++ b/expected/14.0/extra/join.out @@ -2716,6 +2716,7 @@ ERROR: column t12.x does not exist LINE 1: select t12.x from t12 join t32 on (t12.a = t32.x); ^ HINT: Perhaps you meant to reference the column "t32.x". +--Testcase 536: drop table t2a; -- -- regression test for 8.1 merge right join bug @@ -2767,7 +2768,7 @@ set work_mem to '64kB'; --Testcase 506: set enable_mergejoin to off; --Testcase 507: -set enable_resultcache to off; +set enable_memoize to off; --Testcase 127: explain (costs off) select count(*) from tenk1 a, tenk1 b @@ -2790,7 +2791,7 @@ reset work_mem; --Testcase 509: reset enable_mergejoin; --Testcase 510: -reset enable_resultcache; +reset enable_memoize; -- -- regression test for 8.2 bug with improper re-ordering of left joins -- @@ -2955,6 +2956,7 @@ where f2 = 53; 53 | | | (1 row) +--Testcase 537: drop view zv1; -- -- regression test for improper extraction of OR indexqual conditions @@ -3776,6 +3778,15 @@ select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1; Foreign Scan on tenk1 (1 row) +--Testcase 538: +explain (costs off) +select unique1 from tenk1, lateral f_immutable_int4(1) x where x in (select 17); + QUERY PLAN +-------------------------- + Result + One-Time Filter: false +(2 rows) + --Testcase 428: explain (costs off) select unique1, x from tenk1 join f_immutable_int4(1) x on unique1 = x; @@ -4618,7 +4629,7 @@ where t1.f1 = ss2.f1; -> Foreign Scan on public.text_tbl t2 Output: i8.q1, t2.f1 SQLite query: SELECT `f1` FROM main."text_tbl" LIMIT 1 - -> Result Cache + -> Memoize Output: ((i8.q1)), (t2.f1) Cache Key: (i8.q1), t2.f1 -> Foreign Scan on public.text_tbl t3 @@ -5344,6 +5355,20 @@ where q2 = 456; 123 | 456 | | (1 row) +-- -- and check a related issue where we miscompute required relids for +-- -- a PHV that's been translated to a child rel +-- create temp table parttbl (a integer primary key) partition by range (a); +-- create temp table parttbl1 partition of parttbl for values from (1) to (100); +-- insert into parttbl values (11), (12); +-- explain (costs off) +-- select * from +-- (select *, 12 as phv from parttbl) as ss +-- right join int4_tbl on true +-- where ss.a = ss.phv and f1 = 0; +-- select * from +-- (select *, 12 as phv from parttbl) as ss +-- right join int4_tbl on true +-- where ss.a = ss.phv and f1 = 0; -- bug #8444: we've historically allowed duplicate aliases within aliased JOINs --Testcase 267: select * from diff --git a/expected/14beta2/extra/limit.out b/expected/14.0/extra/limit.out similarity index 100% rename from expected/14beta2/extra/limit.out rename to expected/14.0/extra/limit.out diff --git a/expected/14beta2/extra/numeric.out b/expected/14.0/extra/numeric.out similarity index 95% rename from expected/14beta2/extra/numeric.out rename to expected/14.0/extra/numeric.out index 1faa4818..8acc67b3 100644 --- a/expected/14beta2/extra/numeric.out +++ b/expected/14.0/extra/numeric.out @@ -1971,6 +1971,117 @@ SELECT * FROM fract_only; --Testcase 580: DROP FOREIGN TABLE fract_only; +-- Check conversion to integers +-- SQLite promises to preserve the first 15 significant decimal digits of the floating point value. +-- However, it makes no guarantees about the accuracy of computations on floating point values, as no such guarantees are possible. +-- A floating-point value as written in an SQL statement may not be the same as the value represented internally. +-- Actual result is different from expected result. +--Testcase 1485: +CREATE FOREIGN TABLE num_tmp (n1 numeric, n2 numeric, id int options (key 'true')) SERVER sqlite_svr; +--Testcase 1486: +DELETE FROM num_tmp; +--Testcase 1487: +INSERT INTO num_tmp(n1) VALUES (-9223372036854775808.5); +--Testcase 1488: +SELECT n1::int8 FROM num_tmp; -- should fail +ERROR: bigint out of range +--Testcase 1489: +DELETE FROM num_tmp; +--Testcase 1490: +INSERT INTO num_tmp(n1) VALUES (-9223372036854775808.4); +--Testcase 1491: +SELECT n1::int8 FROM num_tmp; -- should fail +ERROR: bigint out of range +--Testcase 1492: +DELETE FROM num_tmp; +--Testcase 1493: +INSERT INTO num_tmp(n1) VALUES (9223372036854775807.4); +--Testcase 1494: +SELECT n1::int8 FROM num_tmp; -- should fail +ERROR: bigint out of range +--Testcase 1495: +DELETE FROM num_tmp; +--Testcase 1496: +INSERT INTO num_tmp(n1) VALUES (9223372036854775807.5); +--Testcase 1497: +SELECT n1::int8 FROM num_tmp; -- should fail +ERROR: bigint out of range +--Testcase 1498: +DELETE FROM num_tmp; +--Testcase 1499: +INSERT INTO num_tmp(n1) VALUES (-2147483648.5); +--Testcase 1500: +SELECT n1::int4 FROM num_tmp; -- should fail +ERROR: integer out of range +--Testcase 1501: +DELETE FROM num_tmp; +--Testcase 1502: +INSERT INTO num_tmp(n1) VALUES (-2147483648.4); +--Testcase 1503: +SELECT n1::int4 FROM num_tmp; -- ok + n1 +------------- + -2147483648 +(1 row) + +--Testcase 1504: +DELETE FROM num_tmp; +--Testcase 1505: +INSERT INTO num_tmp(n1) VALUES (2147483647.4); +--Testcase 1506: +SELECT n1::int4 FROM num_tmp; -- ok + n1 +------------ + 2147483647 +(1 row) + +--Testcase 1507: +DELETE FROM num_tmp; +--Testcase 1508: +INSERT INTO num_tmp(n1) VALUES (2147483647.5); +--Testcase 1509: +SELECT n1::int4 FROM num_tmp; -- should fail +ERROR: integer out of range +--Testcase 1510: +DELETE FROM num_tmp; +--Testcase 1511: +INSERT INTO num_tmp(n1) VALUES (-32768.5); +--Testcase 1512: +SELECT n1::int2 FROM num_tmp; -- should fail +ERROR: smallint out of range +--Testcase 1513: +DELETE FROM num_tmp; +--Testcase 1514: +INSERT INTO num_tmp(n1) VALUES (-32768.4); +--Testcase 1515: +SELECT n1::int2 FROM num_tmp; -- ok + n1 +-------- + -32768 +(1 row) + +--Testcase 1516: +DELETE FROM num_tmp; +--Testcase 1517: +INSERT INTO num_tmp(n1) VALUES (32767.4); +--Testcase 1518: +SELECT n1::int2 FROM num_tmp; -- ok + n1 +------- + 32767 +(1 row) + +--Testcase 1519: +DELETE FROM num_tmp; +--Testcase 1520: +INSERT INTO num_tmp(n1) VALUES (32767.5); +--Testcase 1521: +SELECT n1::int2 FROM num_tmp; -- should fail +ERROR: smallint out of range +--Testcase 1555: +DELETE FROM num_tmp; +--Testcase 1555: +DROP FOREIGN TABLE num_tmp; -- Check inf/nan conversion behavior --Testcase 581: CREATE FOREIGN TABLE FLOAT8_TMP(f1 float8, f2 float8, id int OPTIONS (key 'true')) SERVER sqlite_svr; @@ -2911,6 +3022,41 @@ FROM v; | | | (7 rows) +--Testcase 1522: +DELETE FROM v; +--Testcase 1523: +INSERT INTO v(x) VALUES (-16379),(-16378),(-1234),(-789),(-45),(-5),(-4),(-3),(-2),(-1),(0), + (1),(2),(3),(4),(5),(38),(275),(2345),(45678),(131070),(131071); +--Testcase 1524: +SELECT x, + to_char(('1.2345e'||x)::numeric, '9.999EEEE') as numeric +FROM v; + x | numeric +--------+---------------- + -16379 | 1.235e-16379 + -16378 | 1.235e-16378 + -1234 | 1.235e-1234 + -789 | 1.235e-789 + -45 | 1.235e-45 + -5 | 1.235e-05 + -4 | 1.235e-04 + -3 | 1.235e-03 + -2 | 1.235e-02 + -1 | 1.235e-01 + 0 | 1.235e+00 + 1 | 1.235e+01 + 2 | 1.235e+02 + 3 | 1.235e+03 + 4 | 1.235e+04 + 5 | 1.235e+05 + 38 | 1.235e+38 + 275 | 1.235e+275 + 2345 | 1.235e+2345 + 45678 | 1.235e+45678 + 131070 | 1.235e+131070 + 131071 | 1.235e+131071 +(22 rows) + --Testcase 1479: DELETE FROM v; --Testcase 1480: @@ -3443,6 +3589,17 @@ SELECT n1 * n2 FROM num_tmp; 47700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 (1 row) +--Testcase 1525: +DELETE FROM num_tmp; +--Testcase 1526: +INSERT INTO num_tmp VALUES ((0.1 - 2e-16383), (0.1 - 3e-16383)); +--Testcase 1527: +SELECT trim_scale(n1 * n2) FROM num_tmp; + trim_scale +------------ + 0.01 +(1 row) + -- -- Test some corner cases for division -- @@ -3693,7 +3850,7 @@ DELETE FROM num_tmp; --Testcase 777: INSERT INTO num_tmp VALUES (3.789, 21); --Testcase 778: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; ?column? -------------------------------- 1409343026052.8716016316022141 @@ -3704,7 +3861,7 @@ DELETE FROM num_tmp; --Testcase 780: INSERT INTO num_tmp VALUES (3.789, 35); --Testcase 781: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; ?column? ---------------------------------------- 177158169650516670809.3820586142670135 @@ -3715,7 +3872,7 @@ DELETE FROM num_tmp; --Testcase 783: INSERT INTO num_tmp VALUES (1.2, 345); --Testcase 784: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; ?column? ----------------------------------------------- 2077446682327378559843444695.5827049735727869 @@ -3726,7 +3883,7 @@ DELETE FROM num_tmp; --Testcase 786: INSERT INTO num_tmp VALUES (0.12, (-20)); --Testcase 787: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; ?column? -------------------------------------- 2608405330458882702.5529619561355838 @@ -3737,19 +3894,30 @@ DELETE FROM num_tmp; --Testcase 1221: INSERT INTO num_tmp VALUES (1.000000000123, (-2147483648)); --Testcase 1222: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; ?column? -------------------- 0.7678656556403084 (1 row) +--Testcase 1528: +DELETE FROM num_tmp; +--Testcase 1529: +INSERT INTO num_tmp VALUES (0.9999999999, 23300000000000); +--Testcase 1530: +SELECT coalesce(nullif(n1 ^ n2, 0), 0) FROM num_tmp; + coalesce +---------- + 0 +(1 row) + -- cases that used to error out --Testcase 788: DELETE FROM num_tmp; --Testcase 789: INSERT INTO num_tmp VALUES (0.12, (-25)); --Testcase 790: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; ?column? ------------------------------------------- 104825960103961013959336.4983657883169110 @@ -3760,12 +3928,79 @@ DELETE FROM num_tmp; --Testcase 792: INSERT INTO num_tmp VALUES (0.5678, (-85)); --Testcase 793: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; ?column? ---------------------------------------- 782333637740774446257.7719390061997396 (1 row) +--Testcase 1531: +DELETE FROM num_tmp; +--Testcase 1532: +INSERT INTO num_tmp VALUES (0.9999999999, 70000000000000); +--Testcase 1533: +SELECT coalesce(nullif(n1 ^ n2, 0), 0) FROM num_tmp; + coalesce +---------- + 0 +(1 row) + +-- negative base to integer powers +--Testcase 1534: +DELETE FROM num_tmp; +--Testcase 1535: +INSERT INTO num_tmp VALUES ((-1.0), 2147483646); +--Testcase 1536: +SELECT n1 ^ n2 FROM num_tmp; + ?column? +-------------------- + 1.0000000000000000 +(1 row) + +--Testcase 1537: +DELETE FROM num_tmp; +--Testcase 1538: +INSERT INTO num_tmp VALUES ((-1.0), 2147483647); +--Testcase 1539: +SELECT n1 ^ n2 FROM num_tmp; + ?column? +--------------------- + -1.0000000000000000 +(1 row) + +--Testcase 1540: +DELETE FROM num_tmp; +--Testcase 1541: +INSERT INTO num_tmp VALUES ((-1.0), 2147483648); +--Testcase 1542: +SELECT n1 ^ n2 FROM num_tmp; + ?column? +-------------------- + 1.0000000000000000 +(1 row) + +--Testcase 1543: +DELETE FROM num_tmp; +--Testcase 1544: +INSERT INTO num_tmp VALUES ((-1.0), 1000000000000000); +--Testcase 1545: +SELECT n1 ^ n2 FROM num_tmp; + ?column? +-------------------- + 1.0000000000000000 +(1 row) + +--Testcase 1546: +DELETE FROM num_tmp; +--Testcase 1547: +INSERT INTO num_tmp VALUES ((-1.0), 1000000000000001); +--Testcase 1548: +SELECT n1 ^ n2 FROM num_tmp; + ?column? +--------------------- + -1.0000000000000000 +(1 row) + -- -- Tests for raising to non-integer powers -- @@ -4012,6 +4247,28 @@ select exp(n1) from num_tmp; 0 (1 row) +--Testcase 1549: +DELETE FROM num_tmp; +--Testcase 1550: +INSERT INTO num_tmp VALUES ('-5000'::numeric); +--Testcase 1551: +select coalesce(nullif(exp(n1), 0), 0) from num_tmp; + coalesce +---------- + 0 +(1 row) + +--Testcase 1552: +DELETE FROM num_tmp; +--Testcase 1553: +INSERT INTO num_tmp VALUES ('-10000'::numeric); +--Testcase 1554: +select coalesce(nullif(exp(n1), 0), 0) from num_tmp; + coalesce +---------- + 0 +(1 row) + -- cases that used to generate inaccurate results --Testcase 851: DELETE FROM num_tmp; diff --git a/expected/14beta2/extra/prepare.out b/expected/14.0/extra/prepare.out similarity index 100% rename from expected/14beta2/extra/prepare.out rename to expected/14.0/extra/prepare.out diff --git a/expected/14beta2/extra/select.out b/expected/14.0/extra/select.out similarity index 100% rename from expected/14beta2/extra/select.out rename to expected/14.0/extra/select.out diff --git a/expected/14beta2/extra/select_having.out b/expected/14.0/extra/select_having.out similarity index 100% rename from expected/14beta2/extra/select_having.out rename to expected/14.0/extra/select_having.out diff --git a/expected/14beta2/extra/sqlite_fdw_post.out b/expected/14.0/extra/sqlite_fdw_post.out similarity index 98% rename from expected/14beta2/extra/sqlite_fdw_post.out rename to expected/14.0/extra/sqlite_fdw_post.out index e92f3643..3a9af81c 100644 --- a/expected/14beta2/extra/sqlite_fdw_post.out +++ b/expected/14.0/extra/sqlite_fdw_post.out @@ -17,6 +17,7 @@ $d$; CREATE USER MAPPING FOR CURRENT_USER SERVER sqlite_svr; --Testcase 485: CREATE USER MAPPING FOR CURRENT_USER SERVER sqlite_svr2; +--Testcase 756: CREATE USER MAPPING FOR public SERVER sqlite_svr3; -- =================================================================== -- create objects used through FDW sqlite server @@ -75,6 +76,7 @@ CREATE FOREIGN TABLE ft1 ( c7 char(10) default 'ft1', c8 text ) SERVER sqlite_svr; +--Testcase 757: ALTER FOREIGN TABLE ft1 DROP COLUMN c0; --Testcase 490: CREATE FOREIGN TABLE ft2 ( @@ -88,6 +90,7 @@ CREATE FOREIGN TABLE ft2 ( c7 char(10) default 'ft2', c8 text ) SERVER sqlite_svr; +--Testcase 758: ALTER FOREIGN TABLE ft2 DROP COLUMN cx; --Testcase 491: CREATE FOREIGN TABLE ft4 ( @@ -107,14 +110,19 @@ CREATE FOREIGN TABLE ft6 ( c2 int NOT NULL, c3 text ) SERVER sqlite_svr2 OPTIONS (table 'T 4'); +--Testcase 759: CREATE FOREIGN TABLE ft7 ( c1 int NOT NULL, c2 int NOT NULL, c3 text ) SERVER sqlite_svr3 OPTIONS (table 'T 4'); +--Testcase 760: ALTER FOREIGN TABLE ft1 OPTIONS (table 'T 1'); +--Testcase 761: ALTER FOREIGN TABLE ft2 OPTIONS (table 'T 1'); +--Testcase 762: ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 OPTIONS (column_name 'C 1'); +--Testcase 763: ALTER FOREIGN TABLE ft2 ALTER COLUMN c1 OPTIONS (column_name 'C 1'); --Testcase 5: \det+ @@ -139,6 +147,7 @@ SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work 00001 | Fri Jan 02 00:00:00 1970 PST (1 row) +--Testcase 764: ALTER SERVER sqlite_svr OPTIONS (SET database 'no such database'); --Testcase 7: SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should fail @@ -366,7 +375,9 @@ SELECT 'fixed', NULL FROM ft1 t1 WHERE c1 = 1; (1 row) -- Test forcing the remote server to produce sorted data for a merge join. +--Testcase 765: SET enable_hashjoin TO false; +--Testcase 766: SET enable_nestloop TO false; -- inner join; expressions in the clauses appear in the equivalence class list --Testcase 27: @@ -533,18 +544,24 @@ SELECT t1."C 1", t2.c1, t3.c1 FROM "S 1"."T 1" t1 full join ft1 t2 full join ft2 110 | 110 | 110 (10 rows) +--Testcase 767: RESET enable_hashjoin; +--Testcase 768: RESET enable_nestloop; -- Test executing assertion in estimate_path_cost_size() that makes sure that -- retrieved_rows for foreign rel re-used to cost pre-sorted foreign paths is -- a sensible value even when the rel has tuples=0 -- CREATE TABLE loct_empty (c1 int NOT NULL, c2 text); +--Testcase 769: CREATE FOREIGN TABLE ft_empty (c1 int NOT NULL, c2 text) SERVER sqlite_svr OPTIONS (table 'loct_empty'); +--Testcase 770: INSERT INTO "S 1".loct_empty SELECT id, 'AAA' || to_char(id, 'FM000') FROM generate_series(1, 100) id; +--Testcase 771: DELETE FROM "S 1".loct_empty; -- ANALYZE ft_empty; +--Testcase 772: EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft_empty ORDER BY c1; QUERY PLAN --------------------------------------------------------------------------------------- @@ -956,7 +973,9 @@ SELECT * FROM ft1 t1 WHERE t1.c1 === t1.c2 order by t1.c2 limit 1; (1 row) -- but let's put them in an extension ... +--Testcase 773: ALTER EXTENSION sqlite_fdw ADD FUNCTION sqlite_fdw_abs(int); +--Testcase 774: ALTER EXTENSION sqlite_fdw ADD OPERATOR === (int, int); --ALTER SERVER sqlite_svr2 OPTIONS (ADD extensions 'sqlite_fdw'); -- ... now they can be shipped @@ -1747,7 +1766,8 @@ SELECT t1.c1, t2.c2, t3.c3 FROM ft2 t1 LEFT JOIN ft2 t2 ON (t1.c1 = t2.c1) FULL 20 | 0 | AAA020 (10 rows) -SET enable_resultcache TO off; +--Testcase 775: +SET enable_memoize TO off; -- right outer join + left outer join --Testcase 105: EXPLAIN (VERBOSE, COSTS OFF) @@ -1775,7 +1795,8 @@ SELECT t1.c1, t2.c2, t3.c3 FROM ft2 t1 RIGHT JOIN ft2 t2 ON (t1.c1 = t2.c1) LEFT 20 | 0 | AAA020 (10 rows) -RESET enable_resultcache; +--Testcase 776: +RESET enable_memoize; -- left outer join + right outer join --Testcase 107: EXPLAIN (VERBOSE, COSTS OFF) @@ -1893,6 +1914,7 @@ SELECT t1.c1, t2.c2, t1.c3 FROM ft1 t1 FULL JOIN ft2 t2 ON (t1.c1 = t2.c1) WHERE SQLite query: SELECT `C 1`, `c3` FROM main."T 1" (14 rows) +--Testcase 777: ALTER SERVER loopback OPTIONS (ADD extensions 'postgres_fdw'); ERROR: server "loopback" does not exist -- join two tables with FOR UPDATE clause @@ -2543,7 +2565,9 @@ CREATE TABLE local_tbl (c1 int NOT NULL, c2 int NOT NULL, c3 text, CONSTRAINT lo --Testcase 507: INSERT INTO local_tbl SELECT id, id % 10, to_char(id, 'FM0000') FROM generate_series(1, 1000) id; ANALYZE local_tbl; +--Testcase 778: SET enable_nestloop TO false; +--Testcase 779: SET enable_hashjoin TO false; --Testcase 147: EXPLAIN (VERBOSE, COSTS OFF) @@ -2622,7 +2646,9 @@ SELECT * FROM ft1, ft2, ft4, ft5, local_tbl WHERE ft1.c1 = ft2.c1 AND ft1.c2 = f 96 | 6 | 00096 | Tue Apr 07 00:00:00 1970 PST | Tue Apr 07 00:00:00 1970 | 6 | 6 | foo | 96 | 6 | 00096 | Tue Apr 07 00:00:00 1970 PST | Tue Apr 07 00:00:00 1970 | 6 | 6 | foo | 6 | 7 | AAA006 | 6 | 7 | AAA006 | 6 | 6 | 0006 (10 rows) +--Testcase 780: RESET enable_nestloop; +--Testcase 781: RESET enable_hashjoin; --DROP TABLE local_tbl; -- check join pushdown in situations where multiple userids are involved @@ -2636,6 +2662,7 @@ GRANT SELECT ON ft5 TO regress_view_owner; CREATE VIEW v4 AS SELECT * FROM ft4; --Testcase 511: CREATE VIEW v5 AS SELECT * FROM ft5; +--Testcase 782: ALTER VIEW v5 OWNER TO regress_view_owner; --Testcase 149: EXPLAIN (VERBOSE, COSTS OFF) @@ -2681,6 +2708,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1 40 | (10 rows) +--Testcase 783: ALTER VIEW v4 OWNER TO regress_view_owner; --Testcase 151: EXPLAIN (VERBOSE, COSTS OFF) @@ -2752,6 +2780,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c 40 | (10 rows) +--Testcase 784: ALTER VIEW v4 OWNER TO CURRENT_USER; --Testcase 155: EXPLAIN (VERBOSE, COSTS OFF) @@ -2779,6 +2808,7 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c 40 | (10 rows) +--Testcase 785: ALTER VIEW v4 OWNER TO regress_view_owner; -- cleanup --Testcase 512: @@ -3516,6 +3546,7 @@ create aggregate least_agg(variadic items anyarray) ( stype = anyelement, sfunc = least_accum ); -- Disable hash aggregation for plan stability. +--Testcase 786: set enable_hashagg to false; -- Not pushed down due to user defined aggregate --Testcase 524: @@ -3584,6 +3615,7 @@ select c2, least_agg(c1) from ft1 group by c2 order by c2; (6 rows) -- Cleanup +--Testcase 787: reset enable_hashagg; --Testcase 528: drop aggregate least_agg(variadic items anyarray); @@ -3641,11 +3673,17 @@ select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 -- Update local stats on ft2 --ANALYZE ft2; -- Add into extension +--Testcase 788: alter extension sqlite_fdw add operator class my_op_class using btree; +--Testcase 789: alter extension sqlite_fdw add function my_op_cmp(a int, b int); +--Testcase 790: alter extension sqlite_fdw add operator family my_op_family using btree; +--Testcase 791: alter extension sqlite_fdw add operator public.<^(int, int); +--Testcase 792: alter extension sqlite_fdw add operator public.=^(int, int); +--Testcase 793: alter extension sqlite_fdw add operator public.>^(int, int); --alter server loopback options (set extensions 'postgres_fdw'); -- Now this will be pushed as sort operator is part of the extension. @@ -3670,11 +3708,17 @@ select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 (1 row) -- Remove from extension +--Testcase 794: alter extension sqlite_fdw drop operator class my_op_class using btree; +--Testcase 795: alter extension sqlite_fdw drop function my_op_cmp(a int, b int); +--Testcase 796: alter extension sqlite_fdw drop operator family my_op_family using btree; +--Testcase 797: alter extension sqlite_fdw drop operator public.<^(int, int); +--Testcase 798: alter extension sqlite_fdw drop operator public.=^(int, int); +--Testcase 799: alter extension sqlite_fdw drop operator public.>^(int, int); --alter server loopback options (set extensions 'postgres_fdw'); -- This will not be pushed as sort operator is now removed from the extension. @@ -3860,6 +3904,7 @@ select sum(c2) * (random() <= 1)::int as sum from ft1 order by 1; (1 row) -- LATERAL join, with parameterization +--Testcase 800: set enable_hashagg to false; --Testcase 210: explain (verbose, costs off) @@ -3887,6 +3932,7 @@ select c2, sum from "S 1"."T 1" t1, lateral (select sum(t2.c1 + t1."C 1") sum fr 2 | 4 (2 rows) +--Testcase 801: reset enable_hashagg; -- bug #15613: bad plan for foreign table scan with lateral reference --Testcase 546: @@ -4464,6 +4510,7 @@ EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st7; --Testcase 548: INSERT INTO "S 1"."T 0" SELECT * FROM "S 1"."T 1"; +--Testcase 802: ALTER FOREIGN TABLE ft1 OPTIONS (SET table 'T 0'); --Testcase 261: EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st6; @@ -4499,6 +4546,7 @@ EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st7; Output: NULL::integer, 1001, 101, 'foo'::text, NULL::timestamp with time zone, NULL::timestamp without time zone, NULL::character varying, 'ft1 '::character(10), NULL::text (4 rows) +--Testcase 803: ALTER FOREIGN TABLE ft1 OPTIONS (SET table 'T 1'); --Testcase 549: PREPARE st8 AS SELECT count(c3) FROM ft1 t1 WHERE t1.c1 === t1.c2; @@ -4643,39 +4691,47 @@ DROP FUNCTION f_test(int); -- REINDEX -- =================================================================== -- remote table is not created here +--Testcase 804: CREATE FOREIGN TABLE reindex_foreign (c1 int, c2 int) SERVER sqlite_svr2 OPTIONS (table 'reindex_local'); REINDEX TABLE reindex_foreign; -- error ERROR: "reindex_foreign" is not a table or materialized view REINDEX TABLE CONCURRENTLY reindex_foreign; -- error ERROR: "reindex_foreign" is not a table or materialized view +--Testcase 805: DROP FOREIGN TABLE reindex_foreign; -- partitions and foreign tables +--Testcase 806: CREATE TABLE reind_fdw_parent (c1 int) PARTITION BY RANGE (c1); +--Testcase 807: CREATE TABLE reind_fdw_0_10 PARTITION OF reind_fdw_parent FOR VALUES FROM (0) TO (10); +--Testcase 808: CREATE FOREIGN TABLE reind_fdw_10_20 PARTITION OF reind_fdw_parent FOR VALUES FROM (10) TO (20) SERVER sqlite_svr OPTIONS (table 'reind_local_10_20'); REINDEX TABLE reind_fdw_parent; -- ok REINDEX TABLE CONCURRENTLY reind_fdw_parent; -- ok +--Testcase 809: DROP TABLE reind_fdw_parent; -- =================================================================== -- conversion error -- =================================================================== +--Testcase 810: ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE int; --Testcase 273: -SELECT * FROM ft1 WHERE c1 = 1; +SELECT * FROM ft1 ftx(x1,x2,x3,x4,x5,x6,x7,x8) WHERE x1 = 1; ERROR: invalid input syntax for type =1, column type =3 --Testcase 274: -SELECT ft1.c1, ft2.c2, ft1.c8 FROM ft1, ft2 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = 1; +SELECT ftx.x1, ft2.c2, ftx.x8 FROM ft1 ftx(x1,x2,x3,x4,x5,x6,x7,x8), ft2 WHERE ftx.x1 = ft2.c1 AND ftx.x1 = 1; ERROR: invalid input syntax for type =1, column type =3 --Testcase 275: -SELECT ft1.c1, ft2.c2, ft1 FROM ft1, ft2 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = 1; +SELECT ftx.x1, ft2.c2, ftx FROM ft1 ftx(x1,x2,x3,x4,x5,x6,x7,x8), ft2 WHERE ftx.x1 = ft2.c1 AND ftx.x1 = 1; ERROR: invalid input syntax for type =1, column type =3 --Testcase 276: SELECT sum(c2), array_agg(c8) FROM ft1 GROUP BY c8; ERROR: invalid input syntax for type =1, column type =3 +--Testcase 811: ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE text; -- =================================================================== -- subtransaction @@ -6173,6 +6229,7 @@ UPDATE ft2 AS target SET (c2) = ( ) WHERE c1 > 1100; -- Test UPDATE involving a join that can be pushed down, -- but a SET clause that can't be +--Testcase 812: EXPLAIN (VERBOSE, COSTS OFF) UPDATE ft2 d SET c2 = CASE WHEN random() >= 0 THEN d.c2 ELSE 0 END FROM ft2 AS t WHERE d.c1 = t.c1 AND d.c1 > 1000; @@ -6195,6 +6252,7 @@ UPDATE ft2 d SET c2 = CASE WHEN random() >= 0 THEN d.c2 ELSE 0 END SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" (15 rows) +--Testcase 813: UPDATE ft2 d SET c2 = CASE WHEN random() >= 0 THEN d.c2 ELSE 0 END FROM ft2 AS t WHERE d.c1 = t.c1 AND d.c1 > 1000; -- Test UPDATE/DELETE with WHERE or JOIN/ON conditions containing @@ -6865,6 +6923,7 @@ ALTER FOREIGN TABLE ft1 RENAME TO ft1_org; --Testcase 753: ALTER FOREIGN TABLE ft1_constraint RENAME TO ft1; -- Consistent check constraints provide consistent results +--Testcase 814: ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c2positive CHECK (c2 >= 0); --Testcase 587: EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 WHERE c2 < 0; @@ -6882,6 +6941,7 @@ SELECT count(*) FROM ft1 WHERE c2 < 0; 0 (1 row) +--Testcase 815: SET constraint_exclusion = 'on'; --Testcase 589: EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 WHERE c2 < 0; @@ -6900,6 +6960,7 @@ SELECT count(*) FROM ft1 WHERE c2 < 0; 0 (1 row) +--Testcase 816: RESET constraint_exclusion; -- check constraint is enforced on the remote side, not locally --Testcase 745: @@ -6910,8 +6971,10 @@ ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive ERROR: failed to execute remote SQL: rc=19 CHECK constraint failed: c2 >= 0 sql=UPDATE main."t1_constraint" SET `c2` = (- `c2`) WHERE ((`c1` = 1)) +--Testcase 817: ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2positive; -- But inconsistent check constraints provide inconsistent results +--Testcase 818: ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c2negative CHECK (c2 < 0); --Testcase 591: EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 WHERE c2 >= 0; @@ -6929,6 +6992,7 @@ SELECT count(*) FROM ft1 WHERE c2 >= 0; 821 (1 row) +--Testcase 819: SET constraint_exclusion = 'on'; --Testcase 593: EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 WHERE c2 >= 0; @@ -6947,12 +7011,14 @@ SELECT count(*) FROM ft1 WHERE c2 >= 0; 0 (1 row) +--Testcase 820: RESET constraint_exclusion; -- local check constraint is not actually enforced --Testcase 595: INSERT INTO ft1(c1, c2) VALUES(1111, 2); --Testcase 596: UPDATE ft1 SET c2 = c2 + 1 WHERE c1 = 1; +--Testcase 821: ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2negative; -- =================================================================== -- test WITH CHECK OPTION constraints @@ -7065,6 +7131,7 @@ CREATE FOREIGN TABLE foreign_tbl (a int OPTIONS (key 'true'), b int) CREATE TRIGGER row_before_insupd_trigger BEFORE INSERT OR UPDATE ON foreign_tbl FOR EACH ROW EXECUTE PROCEDURE row_before_insupd_trigfunc(); --Testcase 615: CREATE TABLE parent_tbl (a int, b int) PARTITION BY RANGE(a); +--Testcase 822: ALTER TABLE parent_tbl ATTACH PARTITION foreign_tbl FOR VALUES FROM (0) TO (100); --Testcase 616: CREATE VIEW rw_view AS SELECT * FROM parent_tbl @@ -7211,10 +7278,32 @@ select f1, f2 from rem1; create foreign table grem1 ( a int options (key 'true'), b int generated always as (a * 2) stored) - server sqlite_svr; + server sqlite_svr options(table 'grem1_post14'); --Testcase 638: +explain (verbose, costs off) +insert into grem1 (a) values (1), (2); + QUERY PLAN +--------------------------------------------------- + Insert on public.grem1 + Batch Size: 1 + -> Values Scan on "*VALUES*" + Output: "*VALUES*".column1, NULL::integer +(4 rows) + +--Testcase 823: insert into grem1 (a) values (1), (2); --Testcase 639: +explain (verbose, costs off) +update grem1 set a = 22 where a = 2; + QUERY PLAN +---------------------------------------------------------------------------------- + Update on public.grem1 + -> Foreign Scan on public.grem1 + Output: 22, a, grem1.* + SQLite query: SELECT `a`, `b` FROM main."grem1_post14" WHERE ((`a` = 2)) +(4 rows) + +--Testcase 824: update grem1 set a = 22 where a = 2; --Testcase 640: select * from grem1; @@ -7224,6 +7313,43 @@ select * from grem1; 22 | 44 (2 rows) +--Testcase 825: +delete from grem1; +-- -- test copy from +-- copy grem1 from stdin; +-- 1 +-- 2 +-- \. +-- select * from grem1; +-- delete from grem1; +-- test batch insert +--Testcase 826: +alter server sqlite_svr options (add batch_size '10'); +--Testcase 827: +explain (verbose, costs off) +insert into grem1 (a) values (1), (2); + QUERY PLAN +--------------------------------------------------- + Insert on public.grem1 + Batch Size: 10 + -> Values Scan on "*VALUES*" + Output: "*VALUES*".column1, NULL::integer +(4 rows) + +--Testcase 828: +insert into grem1 (a) values (1), (2); +--Testcase 829: +select * from grem1; + a | b +---+--- + 1 | 2 + 2 | 4 +(2 rows) + +--Testcase 830: +delete from grem1; +--Testcase 831: +alter server sqlite_svr options (drop batch_size); -- =================================================================== -- test local triggers -- =================================================================== @@ -7651,6 +7777,27 @@ DROP TRIGGER trig_row_after ON rem1; --Testcase 686: DROP TRIGGER trig_local_before ON rem1; -- Test direct foreign table modification functionality +--Testcase 832: +EXPLAIN (verbose, costs off) +DELETE FROM rem1; -- can be pushed down + QUERY PLAN +----------------------------------------------- + Delete on public.rem1 + -> Foreign Delete on public.rem1 + SQLite query: DELETE FROM main."loc1" +(3 rows) + +--Testcase 833: +EXPLAIN (verbose, costs off) +DELETE FROM rem1 WHERE false; -- currently can't be pushed down + QUERY PLAN +-------------------------------- + Delete on public.rem1 + -> Result + Output: id + One-Time Filter: false +(4 rows) + -- Test with statement-level triggers --Testcase 687: CREATE TRIGGER trig_stmt_before @@ -7872,6 +8019,7 @@ DROP TRIGGER trig_row_after_delete ON rem1; -- =================================================================== --Testcase 703: CREATE TABLE a (aa TEXT); +--Testcase 834: ALTER TABLE a SET (autovacuum_enabled = 'false'); --Testcase 704: CREATE FOREIGN TABLE b (aa TEXT OPTIONS (key 'true'), bb TEXT) INHERITS (a) @@ -8049,7 +8197,9 @@ create table bar (f1 int, f2 int); --Testcase 709: create foreign table bar2 (f3 int OPTIONS (key 'true')) inherits (bar) server sqlite_svr options (table 'loct2'); +--Testcase 835: alter table foo set (autovacuum_enabled = 'false'); +--Testcase 836: alter table bar set (autovacuum_enabled = 'false'); --Testcase 437: insert into foo values(1,1); @@ -8153,10 +8303,12 @@ select * from bar where f1 in (select f1 from foo) for share; -- Now check SELECT FOR UPDATE/SHARE with an inherited source table, -- where the parent is itself a foreign table +--Testcase 837: create foreign table foo2child (f3 int) inherits (foo2) server sqlite_svr options (table 'loct4_2'); NOTICE: moving and merging column "f3" with inherited definition DETAIL: User-specified column moved to the position of the inherited column. +--Testcase 838: explain (verbose, costs off) select * from bar where f1 in (select f1 from foo2) for share; QUERY PLAN @@ -8187,6 +8339,7 @@ select * from bar where f1 in (select f1 from foo2) for share; SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct4_2" (24 rows) +--Testcase 839: select * from bar where f1 in (select f1 from foo2) for share; f1 | f2 ----+---- @@ -8194,11 +8347,14 @@ select * from bar where f1 in (select f1 from foo2) for share; 4 | 44 (2 rows) +--Testcase 840: drop foreign table foo2child; -- And with a local child relation of the foreign table parent +--Testcase 841: create table foo2child (f3 int) inherits (foo2); NOTICE: moving and merging column "f3" with inherited definition DETAIL: User-specified column moved to the position of the inherited column. +--Testcase 842: explain (verbose, costs off) select * from bar where f1 in (select f1 from foo2) for share; QUERY PLAN @@ -8228,6 +8384,7 @@ select * from bar where f1 in (select f1 from foo2) for share; Output: foo2_2.*, foo2_2.f1, foo2_2.ctid, foo2_2.tableoid (23 rows) +--Testcase 843: select * from bar where f1 in (select f1 from foo2) for share; f1 | f2 ----+---- @@ -8235,6 +8392,7 @@ select * from bar where f1 in (select f1 from foo2) for share; 4 | 44 (2 rows) +--Testcase 844: drop table foo2child; -- Check UPDATE with inherited target and an inherited source table --Testcase 451: @@ -8350,7 +8508,9 @@ truncate table only foo; insert into foo2 select generate_series(0, :num_rows_foo, 2), generate_series(0, :num_rows_foo, 2), generate_series(0, :num_rows_foo, 2); --Testcase 712: insert into foo select generate_series(1, :num_rows_foo, 2), generate_series(1, :num_rows_foo, 2); +--Testcase 845: SET enable_hashjoin to false; +--Testcase 846: SET enable_nestloop to false; --alter foreign table foo2 options (use_remote_estimate 'true'); --create index i_loct1_f1 on loct1(f1); @@ -8453,7 +8613,9 @@ select foo.f1, foo2.f1 from foo left join foo2 on (foo.f1 = foo2.f1) order by fo 19 | (10 rows) +--Testcase 847: RESET enable_hashjoin; +--Testcase 848: RESET enable_nestloop; -- Test that WHERE CURRENT OF is not supported begin; @@ -8598,6 +8760,7 @@ create foreign table remt1 (a int OPTIONS (key 'true'), b text) --Testcase 724: create foreign table remt2 (a int OPTIONS (key 'true'), b text) server sqlite_svr options (table 'loct4'); +--Testcase 849: alter foreign table remt1 inherit parent; --Testcase 468: insert into remt1 values (1, 'foo'); @@ -9028,8 +9191,10 @@ drop table loc3; -- =================================================================== -- test for TRUNCATE -- =================================================================== +--Testcase 850: CREATE FOREIGN TABLE tru_ftable (id int) SERVER sqlite_svr OPTIONS (table 'tru_rtable0'); +--Testcase 851: INSERT INTO "S 1".tru_rtable0 (SELECT x FROM generate_series(1,10) x); -- CREATE TABLE tru_ptable (id int) PARTITION BY HASH(id); -- CREATE TABLE tru_ptable__p0 PARTITION OF tru_ptable @@ -9038,17 +9203,25 @@ INSERT INTO "S 1".tru_rtable0 (SELECT x FROM generate_series(1,10) x); -- CREATE FOREIGN TABLE tru_ftable__p1 (id int) -- SERVER sqlite_svr OPTIONS (table 'tru_ptable'); -- INSERT INTO tru_ptable (SELECT x FROM generate_series(11,20) x); +--Testcase 852: INSERT INTO "S 1".tru_pk_table (SELECT x FROM generate_series(1,10) x); +--Testcase 853: INSERT INTO "S 1".tru_fk_table(fkey) (SELECT x % 10 + 1 FROM generate_series(5,25) x); +--Testcase 854: CREATE FOREIGN TABLE tru_pk_ftable (id int) SERVER sqlite_svr OPTIONS (table 'tru_pk_table'); +--Testcase 855: CREATE FOREIGN TABLE tru_ftable_parent (id int) SERVER sqlite_svr OPTIONS (table 'tru_rtable_parent'); +--Testcase 856: CREATE FOREIGN TABLE tru_ftable_child () INHERITS (tru_ftable_parent) SERVER sqlite_svr OPTIONS (table 'tru_rtable_child'); +--Testcase 857: INSERT INTO "S 1".tru_rtable_parent (SELECT x FROM generate_series(1,8) x); +--Testcase 858: INSERT INTO "S 1".tru_rtable_child (SELECT x FROM generate_series(10, 18) x); -- normal truncate +--Testcase 859: SELECT sum(id) FROM tru_ftable; -- 55 sum ----- @@ -9056,12 +9229,14 @@ SELECT sum(id) FROM tru_ftable; -- 55 (1 row) TRUNCATE tru_ftable; +--Testcase 860: SELECT count(*) FROM "S 1".tru_rtable0; -- 0 count ------- 0 (1 row) +--Testcase 861: SELECT count(*) FROM tru_ftable; -- 0 count ------- @@ -9069,18 +9244,24 @@ SELECT count(*) FROM tru_ftable; -- 0 (1 row) -- 'truncatable' option +--Testcase 862: ALTER SERVER sqlite_svr OPTIONS (ADD truncatable 'false'); TRUNCATE tru_ftable; -- error ERROR: foreign table "tru_ftable" does not allow truncates +--Testcase 863: ALTER FOREIGN TABLE tru_ftable OPTIONS (ADD truncatable 'true'); TRUNCATE tru_ftable; -- accepted +--Testcase 864: ALTER FOREIGN TABLE tru_ftable OPTIONS (SET truncatable 'false'); TRUNCATE tru_ftable; -- error ERROR: foreign table "tru_ftable" does not allow truncates +--Testcase 865: ALTER SERVER sqlite_svr OPTIONS (DROP truncatable); +--Testcase 866: ALTER FOREIGN TABLE tru_ftable OPTIONS (SET truncatable 'false'); TRUNCATE tru_ftable; -- error ERROR: foreign table "tru_ftable" does not allow truncates +--Testcase 867: ALTER FOREIGN TABLE tru_ftable OPTIONS (SET truncatable 'true'); TRUNCATE tru_ftable; -- accepted -- -- partitioned table with both local and foreign tables as partitions @@ -9091,6 +9272,7 @@ TRUNCATE tru_ftable; -- accepted -- SELECT count(*) FROM tru_ftable__p1; -- 0 -- SELECT count(*) FROM tru_rtable1; -- 0 -- 'CASCADE' option +--Testcase 868: SELECT sum(id) FROM tru_pk_ftable; -- 55 sum ----- @@ -9102,12 +9284,14 @@ SELECT sum(id) FROM tru_pk_ftable; -- 55 -- SQLite FDW executes "PRAGMA foreign_keys = ON" before executing DELETE statement. TRUNCATE tru_pk_ftable; -- success TRUNCATE tru_pk_ftable CASCADE; -- success +--Testcase 869: SELECT count(*) FROM tru_pk_ftable; -- 0 count ------- 0 (1 row) +--Testcase 870: SELECT count(*) FROM "S 1".tru_fk_table; -- also truncated,0 count ------- @@ -9115,14 +9299,18 @@ SELECT count(*) FROM "S 1".tru_fk_table; -- also truncated,0 (1 row) -- truncate two tables at a command +--Testcase 871: INSERT INTO tru_ftable (SELECT x FROM generate_series(1,8) x); +--Testcase 872: INSERT INTO tru_pk_ftable (SELECT x FROM generate_series(3,10) x); +--Testcase 873: SELECT count(*) from tru_ftable; -- 8 count ------- 8 (1 row) +--Testcase 874: SELECT count(*) from tru_pk_ftable; -- 8 count ------- @@ -9130,12 +9318,14 @@ SELECT count(*) from tru_pk_ftable; -- 8 (1 row) TRUNCATE tru_ftable, tru_pk_ftable; +--Testcase 875: SELECT count(*) from tru_ftable; -- 0 count ------- 0 (1 row) +--Testcase 876: SELECT count(*) from tru_pk_ftable; -- 0 count ------- @@ -9146,6 +9336,7 @@ SELECT count(*) from tru_pk_ftable; -- 0 -- Since ONLY is specified, the table tru_ftable_child that inherits -- tru_ftable_parent locally is not truncated. TRUNCATE ONLY tru_ftable_parent; +--Testcase 877: SELECT sum(id) FROM tru_ftable_parent; -- 126 sum ----- @@ -9153,6 +9344,7 @@ SELECT sum(id) FROM tru_ftable_parent; -- 126 (1 row) TRUNCATE tru_ftable_parent; +--Testcase 878: SELECT count(*) FROM tru_ftable_parent; -- 0 count ------- @@ -9175,6 +9367,7 @@ SELECT count(*) FROM tru_ftable_parent; -- 0 -- TRUNCATE tru_ftable; -- truncate both of parent and child -- SELECT count(*) FROM tru_ftable; -- 0 -- cleanup +--Testcase 879: DROP FOREIGN TABLE tru_ftable_parent, tru_ftable_child, tru_pk_ftable,tru_ftable; -- DROP TABLE tru_rtable0, tru_rtable1, tru_ptable, tru_ptable__p0, tru_pk_table, tru_fk_table, -- tru_rtable_parent,tru_rtable_child, tru_rtable0_child; @@ -9199,6 +9392,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest1; import_dest1 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest1 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest1 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest1 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest1 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest1 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest1 | loct | sqlite_svr | ("table" 'loct') | @@ -9217,7 +9411,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest1; import_dest1 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest1 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest1 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) --Testcase 478: \d import_dest1.* @@ -9315,6 +9509,13 @@ FDW options: ("table" 'ft3') Server: sqlite_svr FDW options: ("table" 'grem1') + Foreign table "import_dest1.grem1_post14" + Column | Type | Collation | Nullable | Default | FDW options +--------+--------+-----------+----------+---------+-------------- + a | bigint | | | | (key 'true') +Server: sqlite_svr +FDW options: ("table" 'grem1_post14') + Foreign table "import_dest1.loc1" Column | Type | Collation | Nullable | Default | FDW options --------+--------+-----------+----------+---------+-------------- @@ -9485,6 +9686,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest2 import_dest2 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest2 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest2 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest2 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest2 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest2 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest2 | loct | sqlite_svr | ("table" 'loct') | @@ -9503,7 +9705,7 @@ IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest2 import_dest2 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest2 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest2 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) --Testcase 480: \d import_dest2.* @@ -9601,6 +9803,13 @@ FDW options: ("table" 'ft3') Server: sqlite_svr FDW options: ("table" 'grem1') + Foreign table "import_dest2.grem1_post14" + Column | Type | Collation | Nullable | Default | FDW options +--------+--------+-----------+----------+---------+-------------- + a | bigint | | | | (key 'true') +Server: sqlite_svr +FDW options: ("table" 'grem1_post14') + Foreign table "import_dest2.loc1" Column | Type | Collation | Nullable | Default | FDW options --------+--------+-----------+----------+---------+-------------- @@ -9782,6 +9991,7 @@ IMPORT FOREIGN SCHEMA public EXCEPT ("T 1", loct6, nonesuch) import_dest3 | foreign_tbl | sqlite_svr | ("table" 'foreign_tbl') | import_dest3 | ft3 | sqlite_svr | ("table" 'ft3') | import_dest3 | grem1 | sqlite_svr | ("table" 'grem1') | + import_dest3 | grem1_post14 | sqlite_svr | ("table" 'grem1_post14') | import_dest3 | loc1 | sqlite_svr | ("table" 'loc1') | import_dest3 | local_tbl | sqlite_svr | ("table" 'local_tbl') | import_dest3 | loct | sqlite_svr | ("table" 'loct') | @@ -9800,7 +10010,7 @@ IMPORT FOREIGN SCHEMA public EXCEPT ("T 1", loct6, nonesuch) import_dest3 | tru_rtable0 | sqlite_svr | ("table" 'tru_rtable0') | import_dest3 | tru_rtable_child | sqlite_svr | ("table" 'tru_rtable_child') | import_dest3 | tru_rtable_parent | sqlite_svr | ("table" 'tru_rtable_parent') | -(28 rows) +(29 rows) -- Assorted error cases IMPORT FOREIGN SCHEMA public FROM SERVER sqlite_svr INTO import_dest3; @@ -10024,7 +10234,7 @@ CREATE FOREIGN TABLE ft1_nopw ( ALTER FOREIGN TABLE ft1_nopw OPTIONS (table 'T 1'); ALTER FOREIGN TABLE ft1_nopw ALTER COLUMN c1 OPTIONS (column_name 'C 1'); -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; -- If we add a password to the connstr it'll fail, because we don't allow passwords -- in connstrs only in user mappings. @@ -10042,13 +10252,13 @@ $d$; ALTER USER MAPPING FOR CURRENT_USER SERVER sqlite_nopw OPTIONS (ADD password 'dummypw'); -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; -- Unpriv user cannot make the mapping passwordless ALTER USER MAPPING FOR CURRENT_USER SERVER sqlite_nopw OPTIONS (ADD password_required 'false'); -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; RESET ROLE; @@ -10058,7 +10268,7 @@ ALTER USER MAPPING FOR regress_nosuper SERVER sqlite_nopw OPTIONS (ADD password_ SET ROLE regress_nosuper; -- Should finally work now -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; -- unpriv user also cannot set sslcert / sslkey on the user mapping -- first set password_required so we see the right error messages @@ -10072,13 +10282,13 @@ DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_nopw; -- This will fail again as it'll resolve the user mapping for public, which -- lacks password_required=false -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; RESET ROLE; -- The user mapping for public is passwordless and lacks the password_required=false -- mapping option, but will work because the current user is a superuser. -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; -- cleanup DROP USER MAPPING FOR public SERVER sqlite_nopw; @@ -10111,11 +10321,11 @@ WARNING: there is no transaction in progress -- -- Change application_name of remote connection to special one -- -- so that we can easily terminate the connection later. -- ALTER SERVER sqlite_svr OPTIONS (application_name 'fdw_retry_check'); --- -- If debug_invalidate_system_caches_always is active, it results in +-- -- If debug_discard_caches is active, it results in -- -- dropping remote connections after every transaction, making it -- -- impossible to test termination meaningfully. So turn that off -- -- for this test. --- SET debug_invalidate_system_caches_always = 0; +-- SET debug_discard_caches = 0; -- -- Make sure we have a remote connection. -- SELECT 1 FROM ft1 LIMIT 1; -- -- Terminate the remote connection and wait for the termination to complete. @@ -10136,11 +10346,12 @@ WARNING: there is no transaction in progress -- SELECT 1 FROM ft1 LIMIT 1; -- should fail -- \set VERBOSITY default -- COMMIT; --- RESET debug_invalidate_system_caches_always; +-- RESET debug_discard_caches; -- ============================================================================= -- test connection invalidation cases and sqlite_fdw_get_connections function -- ============================================================================= -- Let's ensure to close all the existing cached connections. +--Testcase 880: SELECT 1 FROM sqlite_fdw_disconnect_all(); ?column? ---------- @@ -10148,6 +10359,7 @@ SELECT 1 FROM sqlite_fdw_disconnect_all(); (1 row) -- No cached connections, so no records should be output. +--Testcase 881: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; server_name ------------- @@ -10156,12 +10368,14 @@ SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- This test case is for closing the connection in sqlitefdw_xact_callback BEGIN; -- Connection xact depth becomes 1 i.e. the connection is in midst of the xact. +--Testcase 882: SELECT 1 FROM ft1 LIMIT 1; ?column? ---------- 1 (1 row) +--Testcase 883: SELECT 1 FROM ft7 LIMIT 1; ?column? ---------- @@ -10170,6 +10384,7 @@ SELECT 1 FROM ft7 LIMIT 1; -- List all the existing cached connections. sqlite_svr and sqlite_svr3 should be -- output. +--Testcase 884: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; server_name ------------- @@ -10180,7 +10395,9 @@ SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- Connections are not closed at the end of the alter and drop statements. -- That's because the connections are in midst of this xact, -- they are just marked as invalid in sqlitefdw_inval_callback. +--Testcase 885: ALTER SERVER sqlite_svr OPTIONS (ADD keep_connections 'off'); +--Testcase 886: DROP SERVER sqlite_svr3 CASCADE; NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to user mapping for public on server sqlite_svr3 @@ -10188,6 +10405,7 @@ drop cascades to foreign table ft7 -- List all the existing cached connections. sqlite_svr and sqlite_svr3 -- should be output as invalid connections. Also the server name for -- sqlite_svr3 should be NULL because the server was dropped. +--Testcase 887: SELECT * FROM sqlite_fdw_get_connections() ORDER BY 1; server_name | valid -------------+------- @@ -10197,9 +10415,11 @@ SELECT * FROM sqlite_fdw_get_connections() ORDER BY 1; -- The invalid connections get closed in sqlitefdw_xact_callback during commit. COMMIT; +--Testcase 888: ALTER SERVER sqlite_svr OPTIONS (DROP keep_connections); -- All cached connections were closed while committing above xact, so no -- records should be output. +--Testcase 889: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; server_name ------------- @@ -10210,6 +10430,7 @@ SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- ======================================================================= BEGIN; -- Ensure to cache loopback connection. +--Testcase 890: SELECT 1 FROM ft1 LIMIT 1; ?column? ---------- @@ -10217,6 +10438,7 @@ SELECT 1 FROM ft1 LIMIT 1; (1 row) -- Ensure to cache loopback2 connection. +--Testcase 891: SELECT 1 FROM ft6 LIMIT 1; ?column? ---------- @@ -10225,6 +10447,7 @@ SELECT 1 FROM ft6 LIMIT 1; -- List all the existing cached connections. sqlite_svr and sqlite_svr2 should be -- output. +--Testcase 892: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; server_name ------------- @@ -10234,6 +10457,7 @@ SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- Issue a warning and return false as sqlite_svr connection is still in use and -- can not be closed. +--Testcase 893: SELECT sqlite_fdw_disconnect('sqlite_svr'); WARNING: cannot close connection for server "sqlite_svr" because it is still in use sqlite_fdw_disconnect @@ -10243,6 +10467,7 @@ WARNING: cannot close connection for server "sqlite_svr" because it is still in -- List all the existing cached connections. sqlite_svr and sqlite_svr2 should be -- output. +--Testcase 894: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; server_name ------------- @@ -10252,28 +10477,34 @@ SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- Return false as connections are still in use, warnings are issued. -- But disable warnings temporarily because the order of them is not stable. +--Testcase 895: SET client_min_messages = 'ERROR'; +--Testcase 896: SELECT sqlite_fdw_disconnect_all(); sqlite_fdw_disconnect_all --------------------------- f (1 row) +--Testcase 897: RESET client_min_messages; COMMIT; -- Ensure that sqlite_svr2 connection is closed. +--Testcase 898: SELECT 1 FROM sqlite_fdw_disconnect('sqlite_svr2'); ?column? ---------- 1 (1 row) +--Testcase 899: SELECT server_name FROM sqlite_fdw_get_connections() WHERE server_name = 'sqlite_svr2'; server_name ------------- (0 rows) -- Return false as sqlite_svr2 connection is closed already. +--Testcase 900: SELECT sqlite_fdw_disconnect('sqlite_svr2'); sqlite_fdw_disconnect ----------------------- @@ -10281,9 +10512,11 @@ SELECT sqlite_fdw_disconnect('sqlite_svr2'); (1 row) -- Return an error as there is no foreign server with given name. +--Testcase 901: SELECT sqlite_fdw_disconnect('unknownserver'); ERROR: server "unknownserver" does not exist -- Let's ensure to close all the existing cached connections. +--Testcase 902: SELECT 1 FROM sqlite_fdw_disconnect_all(); ?column? ---------- @@ -10291,6 +10524,7 @@ SELECT 1 FROM sqlite_fdw_disconnect_all(); (1 row) -- No cached connections, so no records should be output. +--Testcase 903: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; server_name ------------- @@ -10299,30 +10533,41 @@ SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- ============================================================================= -- test case for having multiple cached connections for a foreign server -- ============================================================================= +--Testcase 904: CREATE ROLE regress_multi_conn_user1 SUPERUSER; +--Testcase 905: CREATE ROLE regress_multi_conn_user2 SUPERUSER; +--Testcase 906: CREATE USER MAPPING FOR regress_multi_conn_user1 SERVER sqlite_svr; +--Testcase 907: CREATE USER MAPPING FOR regress_multi_conn_user2 SERVER sqlite_svr; BEGIN; -- Will cache sqlite_svr connection with user mapping for regress_multi_conn_user1 +--Testcase 908: SET ROLE regress_multi_conn_user1; +--Testcase 909: SELECT 1 FROM ft1 LIMIT 1; ?column? ---------- 1 (1 row) +--Testcase 910: RESET ROLE; -- Will cache sqlite_svr connection with user mapping for regress_multi_conn_user2 +--Testcase 911: SET ROLE regress_multi_conn_user2; +--Testcase 912: SELECT 1 FROM ft1 LIMIT 1; ?column? ---------- 1 (1 row) +--Testcase 913: RESET ROLE; -- Should output two connections for sqlite_svr server +--Testcase 914: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; server_name ------------- @@ -10331,6 +10576,7 @@ SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; COMMIT; -- Let's ensure to close all the existing cached connections. +--Testcase 915: SELECT 1 FROM sqlite_fdw_disconnect_all(); ?column? ---------- @@ -10338,24 +10584,31 @@ SELECT 1 FROM sqlite_fdw_disconnect_all(); (1 row) -- No cached connections, so no records should be output. +--Testcase 916: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; server_name ------------- (0 rows) -- Clean up +--Testcase 917: DROP USER MAPPING FOR regress_multi_conn_user1 SERVER sqlite_svr; +--Testcase 918: DROP USER MAPPING FOR regress_multi_conn_user2 SERVER sqlite_svr; +--Testcase 919: DROP ROLE regress_multi_conn_user1; +--Testcase 920: DROP ROLE regress_multi_conn_user2; -- =================================================================== -- Test foreign server level option keep_connections -- =================================================================== -- By default, the connections associated with foreign server are cached i.e. -- keep_connections option is on. Set it to off. +--Testcase 921: ALTER SERVER sqlite_svr OPTIONS (keep_connections 'off'); -- connection to sqlite_svr server is closed at the end of xact -- as keep_connections was set to off. +--Testcase 922: SELECT 1 FROM ft1 LIMIT 1; ?column? ---------- @@ -10363,17 +10616,21 @@ SELECT 1 FROM ft1 LIMIT 1; (1 row) -- No cached connections, so no records should be output. +--Testcase 923: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; server_name ------------- (0 rows) +--Testcase 924: ALTER SERVER sqlite_svr OPTIONS (SET keep_connections 'on'); -- =================================================================== -- batch insert -- =================================================================== BEGIN; +--Testcase 925: CREATE SERVER batch10 FOREIGN DATA WRAPPER sqlite_fdw OPTIONS( batch_size '10' ); +--Testcase 926: SELECT count(*) FROM pg_foreign_server WHERE srvname = 'batch10' @@ -10383,7 +10640,9 @@ AND srvoptions @> array['batch_size=10']; 1 (1 row) +--Testcase 927: ALTER SERVER batch10 OPTIONS( SET batch_size '20' ); +--Testcase 928: SELECT count(*) FROM pg_foreign_server WHERE srvname = 'batch10' @@ -10393,6 +10652,7 @@ AND srvoptions @> array['batch_size=10']; 0 (1 row) +--Testcase 929: SELECT count(*) FROM pg_foreign_server WHERE srvname = 'batch10' @@ -10402,7 +10662,9 @@ AND srvoptions @> array['batch_size=20']; 1 (1 row) +--Testcase 930: CREATE FOREIGN TABLE table30 ( x int ) SERVER batch10 OPTIONS ( batch_size '30' ); +--Testcase 931: SELECT COUNT(*) FROM pg_foreign_table WHERE ftrelid = 'table30'::regclass @@ -10412,7 +10674,9 @@ AND ftoptions @> array['batch_size=30']; 1 (1 row) +--Testcase 932: ALTER FOREIGN TABLE table30 OPTIONS ( SET batch_size '40'); +--Testcase 933: SELECT COUNT(*) FROM pg_foreign_table WHERE ftrelid = 'table30'::regclass @@ -10422,6 +10686,7 @@ AND ftoptions @> array['batch_size=30']; 0 (1 row) +--Testcase 934: SELECT COUNT(*) FROM pg_foreign_table WHERE ftrelid = 'table30'::regclass @@ -10432,7 +10697,9 @@ AND ftoptions @> array['batch_size=40']; (1 row) ROLLBACK; +--Testcase 935: CREATE FOREIGN TABLE ftable ( x int OPTIONS (key 'true') ) SERVER sqlite_svr OPTIONS ( table 'batch_table', batch_size '10' ); +--Testcase 936: EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO ftable SELECT * FROM generate_series(1, 10) i; QUERY PLAN ----------------------------------------------------- @@ -10443,31 +10710,45 @@ EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO ftable SELECT * FROM generate_series(1, Function Call: generate_series(1, 10) (5 rows) +--Testcase 937: INSERT INTO ftable SELECT * FROM generate_series(1, 10) i; +--Testcase 938: INSERT INTO ftable SELECT * FROM generate_series(11, 31) i; +--Testcase 939: INSERT INTO ftable VALUES (32); +--Testcase 940: INSERT INTO ftable VALUES (33), (34); +--Testcase 941: SELECT COUNT(*) FROM ftable; count ------- 34 (1 row) +--Testcase 942: DELETE FROM ftable; +--Testcase 943: DROP FOREIGN TABLE ftable; -- try if large batches exceed max number of bind parameters +--Testcase 944: CREATE FOREIGN TABLE ftable ( x int OPTIONS (key 'true') ) SERVER sqlite_svr OPTIONS ( table 'batch_table', batch_size '100000' ); +--Testcase 945: INSERT INTO ftable SELECT * FROM generate_series(1, 70000) i; +--Testcase 946: SELECT COUNT(*) FROM ftable; count ------- 70000 (1 row) +--Testcase 947: DELETE FROM ftable; +--Testcase 948: DROP FOREIGN TABLE ftable; -- Disable batch insert +--Testcase 949: CREATE FOREIGN TABLE ftable ( x int ) SERVER sqlite_svr OPTIONS ( table 'batch_table', batch_size '1' ); +--Testcase 950: EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO ftable VALUES (1), (2); QUERY PLAN ------------------------------------ @@ -10477,13 +10758,16 @@ EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO ftable VALUES (1), (2); Output: "*VALUES*".column1 (4 rows) +--Testcase 951: INSERT INTO ftable VALUES (1), (2); +--Testcase 952: SELECT COUNT(*) FROM ftable; count ------- 2 (1 row) +--Testcase 953: DROP FOREIGN TABLE ftable; -- DROP TABLE batch_table; -- -- Use partitioning @@ -10658,14 +10942,20 @@ DROP FOREIGN TABLE ftable; -- EXPLAIN (VERBOSE, COSTS OFF) -- SELECT * FROM async_pt t1, async_p2 t2 WHERE t1.a = t2.a AND t1.b === 505; -- SELECT * FROM async_pt t1, async_p2 t2 WHERE t1.a = t2.a AND t1.b === 505; +-- CREATE TABLE local_tbl (a int, b int, c text); +-- INSERT INTO local_tbl VALUES (1505, 505, 'foo'); +-- ANALYZE local_tbl; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM local_tbl t1 LEFT JOIN (SELECT *, (SELECT count(*) FROM async_pt WHERE a < 3000) FROM async_pt WHERE a < 3000) t2 ON t1.a = t2.a; +-- EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +-- SELECT * FROM local_tbl t1 LEFT JOIN (SELECT *, (SELECT count(*) FROM async_pt WHERE a < 3000) FROM async_pt WHERE a < 3000) t2 ON t1.a = t2.a; +-- SELECT * FROM local_tbl t1 LEFT JOIN (SELECT *, (SELECT count(*) FROM async_pt WHERE a < 3000) FROM async_pt WHERE a < 3000) t2 ON t1.a = t2.a; -- EXPLAIN (VERBOSE, COSTS OFF) -- SELECT * FROM async_pt t1 WHERE t1.b === 505 LIMIT 1; -- EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) -- SELECT * FROM async_pt t1 WHERE t1.b === 505 LIMIT 1; -- SELECT * FROM async_pt t1 WHERE t1.b === 505 LIMIT 1; -- -- Check with foreign modify --- CREATE TABLE local_tbl (a int, b int, c text); --- INSERT INTO local_tbl VALUES (1505, 505, 'foo'); -- CREATE TABLE base_tbl3 (a int, b int, c text); -- CREATE FOREIGN TABLE remote_tbl (a int, b int, c text) -- SERVER loopback OPTIONS (table_name 'base_tbl3'); @@ -10713,6 +11003,23 @@ DROP FOREIGN TABLE ftable; -- DROP TABLE join_tbl; -- ALTER SERVER loopback OPTIONS (DROP async_capable); -- ALTER SERVER loopback2 OPTIONS (DROP async_capable); +-- =================================================================== +-- test invalid server and foreign table options +-- =================================================================== +-- -- Invalid fdw_startup_cost option +-- CREATE SERVER inv_scst FOREIGN DATA WRAPPER postgres_fdw +-- OPTIONS(fdw_startup_cost '100$%$#$#'); +-- -- Invalid fdw_tuple_cost option +-- CREATE SERVER inv_scst FOREIGN DATA WRAPPER postgres_fdw +-- OPTIONS(fdw_tuple_cost '100$%$#$#'); +-- -- Invalid fetch_size option +-- CREATE FOREIGN TABLE inv_fsz (c1 int ) +-- SERVER loopback OPTIONS (fetch_size '100$%$#$#'); +-- Invalid batch_size option +--Testcase 954: +CREATE FOREIGN TABLE inv_bsz (c1 int ) + SERVER sqlite_svr OPTIONS (batch_size '100$%$#$#'); +ERROR: invalid value for integer option "batch_size": 100$%$#$# -- Clean-up --Testcase 733: DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr; @@ -10720,7 +11027,7 @@ DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr; DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr2; --Testcase 735: DROP SERVER sqlite_svr CASCADE; -NOTICE: drop cascades to 122 other objects +NOTICE: drop cascades to 126 other objects DETAIL: drop cascades to foreign table "S 1"."T 0" drop cascades to foreign table "S 1"."T 1" drop cascades to foreign table "S 1"."T 2" @@ -10741,6 +11048,7 @@ drop cascades to foreign table "S 1".local_tbl drop cascades to foreign table "S 1".ft3 drop cascades to foreign table "S 1".foreign_tbl drop cascades to foreign table "S 1".grem1 +drop cascades to foreign table "S 1".grem1_post14 drop cascades to foreign table "S 1".t1_constraint drop cascades to foreign table "S 1".tru_rtable0 drop cascades to foreign table "S 1".tru_pk_table @@ -10779,6 +11087,7 @@ drop cascades to foreign table import_dest1.local_tbl drop cascades to foreign table import_dest1.ft3 drop cascades to foreign table import_dest1.foreign_tbl drop cascades to foreign table import_dest1.grem1 +drop cascades to foreign table import_dest1.grem1_post14 drop cascades to foreign table import_dest1.t1_constraint drop cascades to foreign table import_dest1.tru_rtable0 drop cascades to foreign table import_dest1.tru_pk_table @@ -10807,6 +11116,7 @@ drop cascades to foreign table import_dest2.local_tbl drop cascades to foreign table import_dest2.ft3 drop cascades to foreign table import_dest2.foreign_tbl drop cascades to foreign table import_dest2.grem1 +drop cascades to foreign table import_dest2.grem1_post14 drop cascades to foreign table import_dest2.t1_constraint drop cascades to foreign table import_dest2.tru_rtable0 drop cascades to foreign table import_dest2.tru_pk_table @@ -10818,10 +11128,7 @@ drop cascades to foreign table import_dest2.batch_table drop cascades to foreign table import_dest3."T 1" drop cascades to foreign table import_dest3.loct6 drop cascades to foreign table import_dest3."T 0" -drop cascades to foreign table import_dest3."T 2" -drop cascades to foreign table import_dest3."T 3" -drop cascades to foreign table import_dest3."T 4" -and 22 other objects (see server log for list) +and 26 other objects (see server log for list) --Testcase 736: DROP SERVER sqlite_svr2 CASCADE; NOTICE: drop cascades to foreign table ft6 diff --git a/expected/14beta2/extra/timestamp.out b/expected/14.0/extra/timestamp.out similarity index 100% rename from expected/14beta2/extra/timestamp.out rename to expected/14.0/extra/timestamp.out diff --git a/expected/14beta2/extra/update.out b/expected/14.0/extra/update.out similarity index 100% rename from expected/14beta2/extra/update.out rename to expected/14.0/extra/update.out diff --git a/expected/14beta2/selectfunc.out b/expected/14.0/selectfunc.out similarity index 100% rename from expected/14beta2/selectfunc.out rename to expected/14.0/selectfunc.out diff --git a/expected/14beta2/sqlite_fdw.out b/expected/14.0/sqlite_fdw.out similarity index 96% rename from expected/14beta2/sqlite_fdw.out rename to expected/14.0/sqlite_fdw.out index d67d1fe3..dfb0e0d3 100644 --- a/expected/14beta2/sqlite_fdw.out +++ b/expected/14.0/sqlite_fdw.out @@ -1373,6 +1373,7 @@ SELECT * FROM multiprimary2; | 99 | 99 (5 rows) +--Testcase 214: ALTER FOREIGN TABLE multiprimary2 ALTER COLUMN a OPTIONS(ADD column_name 'b'); --Testcase 118: SELECT * FROM multiprimary2; @@ -1385,6 +1386,7 @@ SELECT * FROM multiprimary2; 99 | 99 | 99 (5 rows) +--Testcase 215: ALTER FOREIGN TABLE multiprimary2 ALTER COLUMN b OPTIONS (column_name 'nosuch column'); --Testcase 119: SELECT * FROM multiprimary2; @@ -1453,14 +1455,61 @@ SELECT * FROM noprimary; SELECT * FROM public.sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20100 + 20101 (1 row) --Testcase 155: SELECT sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20100 + 20101 +(1 row) + +-- issue #44 github +--Testcase 156: +CREATE FOREIGN TABLE fts_table (name text, description text) SERVER sqlite_svr; +--Testcase 157: +INSERT INTO fts_table VALUES ('this is name', 'this is description'); +--Testcase 158: +SELECT * FROM fts_table; -- should work + name | description +--------------+--------------------- + this is name | this is description +(1 row) + +--Testcase 159: +ALTER TABLE fts_table ALTER COLUMN name TYPE int; +--Testcase 160: +SELECT * FROM fts_table; -- should fail +ERROR: invalid input syntax for type =1, column type =3 +-- INSERT/UPDATE whole row with generated column +--Testcase 216: +CREATE FOREIGN TABLE grem1_1 ( + a int generated always as (0) stored) + SERVER sqlite_svr OPTIONS(table 'grem1_1'); +--Testcase 217: +INSERT INTO grem1_1 DEFAULT VALUES; +--Testcase 218: +SELECT * FROM grem1_1; + a +--- + +(1 row) + +--Testcase 219: +CREATE FOREIGN TABLE grem1_2 ( + a int generated always as (0) stored, + b int generated always as (1) stored, + c int generated always as (2) stored, + d int generated always as (3) stored) + SERVER sqlite_svr OPTIONS(table 'grem1_2'); +--Testcase 220: +INSERT INTO grem1_2 DEFAULT VALUES; +--Testcase 221: +SELECT * FROM grem1_2; + a | b | c | d +---+---+---+--- + | | | (1 row) --Testcase 142: @@ -1481,6 +1530,12 @@ DROP FOREIGN TABLE multiprimary2; DROP FOREIGN TABLE columntest; --Testcase 150: DROP FOREIGN TABLE noprimary; +--Testcase 161: +DROP FOREIGN TABLE fts_table; +--Testcase 222: +DROP FOREIGN TABLE grem1_1; +--Testcase 223: +DROP FOREIGN TABLE grem1_2; --Testcase 151: DROP SERVER sqlite_svr; --Testcase 152: diff --git a/expected/14.0/type.out b/expected/14.0/type.out new file mode 100644 index 00000000..d1c05b99 --- /dev/null +++ b/expected/14.0/type.out @@ -0,0 +1,351 @@ +--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; +--Testcase 47: +DROP EXTENSION sqlite_fdw CASCADE; +NOTICE: drop cascades to 39 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 "type_STRING" +drop cascades to foreign table "type_BOOLEAN" +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 "BitT" +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 type_json +drop cascades to server sqlite2 diff --git a/expected/14beta2/type.out b/expected/14beta2/type.out deleted file mode 100644 index f0cbbbb5..00000000 --- a/expected/14beta2/type.out +++ /dev/null @@ -1,343 +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; ---Testcase 47: -DROP EXTENSION sqlite_fdw CASCADE; -NOTICE: drop cascades to 31 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 "type_STRING" -drop cascades to foreign table "type_BOOLEAN" -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 "BitT" -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 type_json -drop cascades to server sqlite2 diff --git a/option.c b/option.c index 9f3f2c49..e47b1a80 100644 --- a/option.c +++ b/option.c @@ -33,6 +33,7 @@ #include "storage/fd.h" #include "utils/array.h" #include "utils/builtins.h" +#include "utils/guc.h" #include "utils/rel.h" #include "utils/lsyscache.h" #include "optimizer/cost.h" @@ -130,13 +131,23 @@ sqlite_fdw_validator(PG_FUNCTION_ARGS) } else if (strcmp(def->defname, "batch_size") == 0) { - int batch_size; + char *value; + int int_val; + bool is_parsed; - batch_size = strtol(defGetString(def), NULL, 10); - if (batch_size <= 0) + value = defGetString(def); + is_parsed = parse_int(value, &int_val, 0, NULL); + + if (!is_parsed) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("invalid value for integer option \"%s\": %s", + def->defname, value))); + + if (int_val <= 0) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("%s requires a positive integer value", + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("\"%s\" must be an integer value greater than zero", def->defname))); } } diff --git a/sql/10.17/aggregate.sql b/sql/10.18/aggregate.sql similarity index 100% rename from sql/10.17/aggregate.sql rename to sql/10.18/aggregate.sql diff --git a/sql/10.17/extra/aggregates.sql b/sql/10.18/extra/aggregates.sql similarity index 100% rename from sql/10.17/extra/aggregates.sql rename to sql/10.18/extra/aggregates.sql diff --git a/sql/10.17/extra/float4.sql b/sql/10.18/extra/float4.sql similarity index 100% rename from sql/10.17/extra/float4.sql rename to sql/10.18/extra/float4.sql diff --git a/sql/10.17/extra/float8.sql b/sql/10.18/extra/float8.sql similarity index 100% rename from sql/10.17/extra/float8.sql rename to sql/10.18/extra/float8.sql diff --git a/sql/10.17/extra/insert.sql b/sql/10.18/extra/insert.sql similarity index 100% rename from sql/10.17/extra/insert.sql rename to sql/10.18/extra/insert.sql diff --git a/sql/10.17/extra/int4.sql b/sql/10.18/extra/int4.sql similarity index 100% rename from sql/10.17/extra/int4.sql rename to sql/10.18/extra/int4.sql diff --git a/sql/10.17/extra/int8.sql b/sql/10.18/extra/int8.sql similarity index 100% rename from sql/10.17/extra/int8.sql rename to sql/10.18/extra/int8.sql diff --git a/sql/10.17/extra/join.sql b/sql/10.18/extra/join.sql similarity index 100% rename from sql/10.17/extra/join.sql rename to sql/10.18/extra/join.sql diff --git a/sql/10.17/extra/limit.sql b/sql/10.18/extra/limit.sql similarity index 100% rename from sql/10.17/extra/limit.sql rename to sql/10.18/extra/limit.sql diff --git a/sql/10.17/extra/numeric.sql b/sql/10.18/extra/numeric.sql similarity index 100% rename from sql/10.17/extra/numeric.sql rename to sql/10.18/extra/numeric.sql diff --git a/sql/10.17/extra/prepare.sql b/sql/10.18/extra/prepare.sql similarity index 100% rename from sql/10.17/extra/prepare.sql rename to sql/10.18/extra/prepare.sql diff --git a/sql/10.17/extra/select.sql b/sql/10.18/extra/select.sql similarity index 100% rename from sql/10.17/extra/select.sql rename to sql/10.18/extra/select.sql diff --git a/sql/10.17/extra/select_having.sql b/sql/10.18/extra/select_having.sql similarity index 100% rename from sql/10.17/extra/select_having.sql rename to sql/10.18/extra/select_having.sql diff --git a/sql/10.17/extra/sqlite_fdw_post.sql b/sql/10.18/extra/sqlite_fdw_post.sql similarity index 100% rename from sql/10.17/extra/sqlite_fdw_post.sql rename to sql/10.18/extra/sqlite_fdw_post.sql diff --git a/sql/10.17/extra/timestamp.sql b/sql/10.18/extra/timestamp.sql similarity index 100% rename from sql/10.17/extra/timestamp.sql rename to sql/10.18/extra/timestamp.sql diff --git a/sql/10.17/extra/update.sql b/sql/10.18/extra/update.sql similarity index 100% rename from sql/10.17/extra/update.sql rename to sql/10.18/extra/update.sql diff --git a/sql/10.17/selectfunc.sql b/sql/10.18/selectfunc.sql similarity index 100% rename from sql/10.17/selectfunc.sql rename to sql/10.18/selectfunc.sql diff --git a/sql/10.17/sqlite_fdw.sql b/sql/10.18/sqlite_fdw.sql similarity index 97% rename from sql/10.17/sqlite_fdw.sql rename to sql/10.18/sqlite_fdw.sql index ebc6aef0..9c18231a 100644 --- a/sql/10.17/sqlite_fdw.sql +++ b/sql/10.18/sqlite_fdw.sql @@ -535,6 +535,22 @@ SELECT * FROM public.sqlite_fdw_version(); --Testcase 155: SELECT sqlite_fdw_version(); +-- issue #44 github +--Testcase 156: +CREATE FOREIGN TABLE fts_table (name text, description text) SERVER sqlite_svr; + +--Testcase 157: +INSERT INTO fts_table VALUES ('this is name', 'this is description'); + +--Testcase 158: +SELECT * FROM fts_table; -- should work + +--Testcase 159: +ALTER TABLE fts_table ALTER COLUMN name TYPE int; + +--Testcase 160: +SELECT * FROM fts_table; -- should fail + --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -553,6 +569,8 @@ DROP FOREIGN TABLE multiprimary2; DROP FOREIGN TABLE columntest; --Testcase 150: DROP FOREIGN TABLE noprimary; +--Testcase 161: +DROP FOREIGN TABLE fts_table; --Testcase 151: DROP SERVER sqlite_svr; diff --git a/sql/10.17/type.sql b/sql/10.18/type.sql similarity index 100% rename from sql/10.17/type.sql rename to sql/10.18/type.sql diff --git a/sql/11.12/aggregate.sql b/sql/11.13/aggregate.sql similarity index 100% rename from sql/11.12/aggregate.sql rename to sql/11.13/aggregate.sql diff --git a/sql/11.12/extra/aggregates.sql b/sql/11.13/extra/aggregates.sql similarity index 100% rename from sql/11.12/extra/aggregates.sql rename to sql/11.13/extra/aggregates.sql diff --git a/sql/11.12/extra/float4.sql b/sql/11.13/extra/float4.sql similarity index 100% rename from sql/11.12/extra/float4.sql rename to sql/11.13/extra/float4.sql diff --git a/sql/11.12/extra/float8.sql b/sql/11.13/extra/float8.sql similarity index 100% rename from sql/11.12/extra/float8.sql rename to sql/11.13/extra/float8.sql diff --git a/sql/11.12/extra/insert.sql b/sql/11.13/extra/insert.sql similarity index 100% rename from sql/11.12/extra/insert.sql rename to sql/11.13/extra/insert.sql diff --git a/sql/11.12/extra/int4.sql b/sql/11.13/extra/int4.sql similarity index 100% rename from sql/11.12/extra/int4.sql rename to sql/11.13/extra/int4.sql diff --git a/sql/11.12/extra/int8.sql b/sql/11.13/extra/int8.sql similarity index 100% rename from sql/11.12/extra/int8.sql rename to sql/11.13/extra/int8.sql diff --git a/sql/11.12/extra/join.sql b/sql/11.13/extra/join.sql similarity index 100% rename from sql/11.12/extra/join.sql rename to sql/11.13/extra/join.sql diff --git a/sql/11.12/extra/limit.sql b/sql/11.13/extra/limit.sql similarity index 100% rename from sql/11.12/extra/limit.sql rename to sql/11.13/extra/limit.sql diff --git a/sql/11.12/extra/numeric.sql b/sql/11.13/extra/numeric.sql similarity index 100% rename from sql/11.12/extra/numeric.sql rename to sql/11.13/extra/numeric.sql diff --git a/sql/11.12/extra/prepare.sql b/sql/11.13/extra/prepare.sql similarity index 100% rename from sql/11.12/extra/prepare.sql rename to sql/11.13/extra/prepare.sql diff --git a/sql/11.12/extra/select.sql b/sql/11.13/extra/select.sql similarity index 100% rename from sql/11.12/extra/select.sql rename to sql/11.13/extra/select.sql diff --git a/sql/11.12/extra/select_having.sql b/sql/11.13/extra/select_having.sql similarity index 100% rename from sql/11.12/extra/select_having.sql rename to sql/11.13/extra/select_having.sql diff --git a/sql/11.12/extra/sqlite_fdw_post.sql b/sql/11.13/extra/sqlite_fdw_post.sql similarity index 100% rename from sql/11.12/extra/sqlite_fdw_post.sql rename to sql/11.13/extra/sqlite_fdw_post.sql diff --git a/sql/11.12/extra/timestamp.sql b/sql/11.13/extra/timestamp.sql similarity index 100% rename from sql/11.12/extra/timestamp.sql rename to sql/11.13/extra/timestamp.sql diff --git a/sql/11.12/extra/update.sql b/sql/11.13/extra/update.sql similarity index 100% rename from sql/11.12/extra/update.sql rename to sql/11.13/extra/update.sql diff --git a/sql/11.12/selectfunc.sql b/sql/11.13/selectfunc.sql similarity index 100% rename from sql/11.12/selectfunc.sql rename to sql/11.13/selectfunc.sql diff --git a/sql/11.12/sqlite_fdw.sql b/sql/11.13/sqlite_fdw.sql similarity index 97% rename from sql/11.12/sqlite_fdw.sql rename to sql/11.13/sqlite_fdw.sql index ebc6aef0..9c18231a 100644 --- a/sql/11.12/sqlite_fdw.sql +++ b/sql/11.13/sqlite_fdw.sql @@ -535,6 +535,22 @@ SELECT * FROM public.sqlite_fdw_version(); --Testcase 155: SELECT sqlite_fdw_version(); +-- issue #44 github +--Testcase 156: +CREATE FOREIGN TABLE fts_table (name text, description text) SERVER sqlite_svr; + +--Testcase 157: +INSERT INTO fts_table VALUES ('this is name', 'this is description'); + +--Testcase 158: +SELECT * FROM fts_table; -- should work + +--Testcase 159: +ALTER TABLE fts_table ALTER COLUMN name TYPE int; + +--Testcase 160: +SELECT * FROM fts_table; -- should fail + --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -553,6 +569,8 @@ DROP FOREIGN TABLE multiprimary2; DROP FOREIGN TABLE columntest; --Testcase 150: DROP FOREIGN TABLE noprimary; +--Testcase 161: +DROP FOREIGN TABLE fts_table; --Testcase 151: DROP SERVER sqlite_svr; diff --git a/sql/11.12/type.sql b/sql/11.13/type.sql similarity index 100% rename from sql/11.12/type.sql rename to sql/11.13/type.sql diff --git a/sql/12.7/aggregate.sql b/sql/12.8/aggregate.sql similarity index 100% rename from sql/12.7/aggregate.sql rename to sql/12.8/aggregate.sql diff --git a/sql/12.7/extra/aggregates.sql b/sql/12.8/extra/aggregates.sql similarity index 100% rename from sql/12.7/extra/aggregates.sql rename to sql/12.8/extra/aggregates.sql diff --git a/sql/12.7/extra/float4.sql b/sql/12.8/extra/float4.sql similarity index 100% rename from sql/12.7/extra/float4.sql rename to sql/12.8/extra/float4.sql diff --git a/sql/12.7/extra/float8.sql b/sql/12.8/extra/float8.sql similarity index 100% rename from sql/12.7/extra/float8.sql rename to sql/12.8/extra/float8.sql diff --git a/sql/12.7/extra/insert.sql b/sql/12.8/extra/insert.sql similarity index 100% rename from sql/12.7/extra/insert.sql rename to sql/12.8/extra/insert.sql diff --git a/sql/12.7/extra/int4.sql b/sql/12.8/extra/int4.sql similarity index 100% rename from sql/12.7/extra/int4.sql rename to sql/12.8/extra/int4.sql diff --git a/sql/12.7/extra/int8.sql b/sql/12.8/extra/int8.sql similarity index 100% rename from sql/12.7/extra/int8.sql rename to sql/12.8/extra/int8.sql diff --git a/sql/12.7/extra/join.sql b/sql/12.8/extra/join.sql similarity index 100% rename from sql/12.7/extra/join.sql rename to sql/12.8/extra/join.sql diff --git a/sql/12.7/extra/limit.sql b/sql/12.8/extra/limit.sql similarity index 100% rename from sql/12.7/extra/limit.sql rename to sql/12.8/extra/limit.sql diff --git a/sql/12.7/extra/numeric.sql b/sql/12.8/extra/numeric.sql similarity index 100% rename from sql/12.7/extra/numeric.sql rename to sql/12.8/extra/numeric.sql diff --git a/sql/12.7/extra/prepare.sql b/sql/12.8/extra/prepare.sql similarity index 100% rename from sql/12.7/extra/prepare.sql rename to sql/12.8/extra/prepare.sql diff --git a/sql/12.7/extra/select.sql b/sql/12.8/extra/select.sql similarity index 100% rename from sql/12.7/extra/select.sql rename to sql/12.8/extra/select.sql diff --git a/sql/12.7/extra/select_having.sql b/sql/12.8/extra/select_having.sql similarity index 100% rename from sql/12.7/extra/select_having.sql rename to sql/12.8/extra/select_having.sql diff --git a/sql/12.7/extra/sqlite_fdw_post.sql b/sql/12.8/extra/sqlite_fdw_post.sql similarity index 100% rename from sql/12.7/extra/sqlite_fdw_post.sql rename to sql/12.8/extra/sqlite_fdw_post.sql diff --git a/sql/12.7/extra/timestamp.sql b/sql/12.8/extra/timestamp.sql similarity index 100% rename from sql/12.7/extra/timestamp.sql rename to sql/12.8/extra/timestamp.sql diff --git a/sql/12.7/extra/update.sql b/sql/12.8/extra/update.sql similarity index 100% rename from sql/12.7/extra/update.sql rename to sql/12.8/extra/update.sql diff --git a/sql/12.7/selectfunc.sql b/sql/12.8/selectfunc.sql similarity index 100% rename from sql/12.7/selectfunc.sql rename to sql/12.8/selectfunc.sql diff --git a/sql/12.7/sqlite_fdw.sql b/sql/12.8/sqlite_fdw.sql similarity index 97% rename from sql/12.7/sqlite_fdw.sql rename to sql/12.8/sqlite_fdw.sql index ebc6aef0..9c18231a 100644 --- a/sql/12.7/sqlite_fdw.sql +++ b/sql/12.8/sqlite_fdw.sql @@ -535,6 +535,22 @@ SELECT * FROM public.sqlite_fdw_version(); --Testcase 155: SELECT sqlite_fdw_version(); +-- issue #44 github +--Testcase 156: +CREATE FOREIGN TABLE fts_table (name text, description text) SERVER sqlite_svr; + +--Testcase 157: +INSERT INTO fts_table VALUES ('this is name', 'this is description'); + +--Testcase 158: +SELECT * FROM fts_table; -- should work + +--Testcase 159: +ALTER TABLE fts_table ALTER COLUMN name TYPE int; + +--Testcase 160: +SELECT * FROM fts_table; -- should fail + --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -553,6 +569,8 @@ DROP FOREIGN TABLE multiprimary2; DROP FOREIGN TABLE columntest; --Testcase 150: DROP FOREIGN TABLE noprimary; +--Testcase 161: +DROP FOREIGN TABLE fts_table; --Testcase 151: DROP SERVER sqlite_svr; diff --git a/sql/12.7/type.sql b/sql/12.8/type.sql similarity index 100% rename from sql/12.7/type.sql rename to sql/12.8/type.sql diff --git a/sql/13.3/aggregate.sql b/sql/13.4/aggregate.sql similarity index 100% rename from sql/13.3/aggregate.sql rename to sql/13.4/aggregate.sql diff --git a/sql/13.3/extra/aggregates.sql b/sql/13.4/extra/aggregates.sql similarity index 100% rename from sql/13.3/extra/aggregates.sql rename to sql/13.4/extra/aggregates.sql diff --git a/sql/13.3/extra/float4.sql b/sql/13.4/extra/float4.sql similarity index 100% rename from sql/13.3/extra/float4.sql rename to sql/13.4/extra/float4.sql diff --git a/sql/13.3/extra/float8.sql b/sql/13.4/extra/float8.sql similarity index 100% rename from sql/13.3/extra/float8.sql rename to sql/13.4/extra/float8.sql diff --git a/sql/13.3/extra/insert.sql b/sql/13.4/extra/insert.sql similarity index 100% rename from sql/13.3/extra/insert.sql rename to sql/13.4/extra/insert.sql diff --git a/sql/13.3/extra/int4.sql b/sql/13.4/extra/int4.sql similarity index 100% rename from sql/13.3/extra/int4.sql rename to sql/13.4/extra/int4.sql diff --git a/sql/13.3/extra/int8.sql b/sql/13.4/extra/int8.sql similarity index 100% rename from sql/13.3/extra/int8.sql rename to sql/13.4/extra/int8.sql diff --git a/sql/13.3/extra/join.sql b/sql/13.4/extra/join.sql similarity index 100% rename from sql/13.3/extra/join.sql rename to sql/13.4/extra/join.sql diff --git a/sql/13.3/extra/limit.sql b/sql/13.4/extra/limit.sql similarity index 100% rename from sql/13.3/extra/limit.sql rename to sql/13.4/extra/limit.sql diff --git a/sql/13.3/extra/numeric.sql b/sql/13.4/extra/numeric.sql similarity index 100% rename from sql/13.3/extra/numeric.sql rename to sql/13.4/extra/numeric.sql diff --git a/sql/13.3/extra/prepare.sql b/sql/13.4/extra/prepare.sql similarity index 100% rename from sql/13.3/extra/prepare.sql rename to sql/13.4/extra/prepare.sql diff --git a/sql/13.3/extra/select.sql b/sql/13.4/extra/select.sql similarity index 100% rename from sql/13.3/extra/select.sql rename to sql/13.4/extra/select.sql diff --git a/sql/13.3/extra/select_having.sql b/sql/13.4/extra/select_having.sql similarity index 100% rename from sql/13.3/extra/select_having.sql rename to sql/13.4/extra/select_having.sql diff --git a/sql/13.3/extra/sqlite_fdw_post.sql b/sql/13.4/extra/sqlite_fdw_post.sql similarity index 100% rename from sql/13.3/extra/sqlite_fdw_post.sql rename to sql/13.4/extra/sqlite_fdw_post.sql diff --git a/sql/13.3/extra/timestamp.sql b/sql/13.4/extra/timestamp.sql similarity index 100% rename from sql/13.3/extra/timestamp.sql rename to sql/13.4/extra/timestamp.sql diff --git a/sql/13.3/extra/update.sql b/sql/13.4/extra/update.sql similarity index 100% rename from sql/13.3/extra/update.sql rename to sql/13.4/extra/update.sql diff --git a/sql/13.3/selectfunc.sql b/sql/13.4/selectfunc.sql similarity index 100% rename from sql/13.3/selectfunc.sql rename to sql/13.4/selectfunc.sql diff --git a/sql/13.3/sqlite_fdw.sql b/sql/13.4/sqlite_fdw.sql similarity index 97% rename from sql/13.3/sqlite_fdw.sql rename to sql/13.4/sqlite_fdw.sql index ebc6aef0..9c18231a 100644 --- a/sql/13.3/sqlite_fdw.sql +++ b/sql/13.4/sqlite_fdw.sql @@ -535,6 +535,22 @@ SELECT * FROM public.sqlite_fdw_version(); --Testcase 155: SELECT sqlite_fdw_version(); +-- issue #44 github +--Testcase 156: +CREATE FOREIGN TABLE fts_table (name text, description text) SERVER sqlite_svr; + +--Testcase 157: +INSERT INTO fts_table VALUES ('this is name', 'this is description'); + +--Testcase 158: +SELECT * FROM fts_table; -- should work + +--Testcase 159: +ALTER TABLE fts_table ALTER COLUMN name TYPE int; + +--Testcase 160: +SELECT * FROM fts_table; -- should fail + --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -553,6 +569,8 @@ DROP FOREIGN TABLE multiprimary2; DROP FOREIGN TABLE columntest; --Testcase 150: DROP FOREIGN TABLE noprimary; +--Testcase 161: +DROP FOREIGN TABLE fts_table; --Testcase 151: DROP SERVER sqlite_svr; diff --git a/sql/13.3/type.sql b/sql/13.4/type.sql similarity index 100% rename from sql/13.3/type.sql rename to sql/13.4/type.sql diff --git a/sql/14beta2/aggregate.sql b/sql/14.0/aggregate.sql similarity index 100% rename from sql/14beta2/aggregate.sql rename to sql/14.0/aggregate.sql diff --git a/sql/14beta2/extra/aggregates.sql b/sql/14.0/extra/aggregates.sql similarity index 98% rename from sql/14beta2/extra/aggregates.sql rename to sql/14.0/extra/aggregates.sql index 344dfe14..98fe5c0f 100644 --- a/sql/14beta2/extra/aggregates.sql +++ b/sql/14.0/extra/aggregates.sql @@ -1310,6 +1310,22 @@ insert into multi_arg_agg values (1,3,'foo'),(0,null,null),(2,2,'bar'),(3,1,'baz select aggfns(distinct a,b,c order by a,c using ~<~,b) filter (where a > 1) from multi_arg_agg, generate_series(1,2) i; rollback; +-- check handling of bare boolean Var in FILTER +--Testcase 672: +select max(0) filter (where b1) from bool_test; +--Testcase 673: +select (select max(0) filter (where b1)) from bool_test; + +-- check for correct detection of nested-aggregate errors in FILTER +--Testcase 674: +select max(unique1) filter (where sum(ten) > 0) from tenk1; +--Testcase 675: +select (select max(unique1) filter (where sum(ten) > 0) from int8_tbl) from tenk1; +--Testcase 676: +select max(unique1) filter (where bool_or(ten > 0)) from tenk1; +--Testcase 677: +select (select max(unique1) filter (where bool_or(ten > 0)) from int8_tbl) from tenk1; + -- ordered-set aggregates begin; @@ -2006,13 +2022,13 @@ rollback; -- does not lead to array overflow due to unexpected duplicate hash keys -- see CAFeeJoKKu0u+A_A9R9316djW-YW3-+Gtgvy3ju655qRHR3jtdA@mail.gmail.com --Testcase 641: -set enable_resultcache to off; +set enable_memoize to off; --Testcase 558: explain (costs off) select 1 from tenk1 where (hundred, thousand) in (select twothousand, twothousand from onek); --Testcase 642: -reset enable_resultcache; +reset enable_memoize; -- -- Hash Aggregation Spill tests diff --git a/sql/14beta2/extra/float4.sql b/sql/14.0/extra/float4.sql similarity index 100% rename from sql/14beta2/extra/float4.sql rename to sql/14.0/extra/float4.sql diff --git a/sql/14beta2/extra/float8.sql b/sql/14.0/extra/float8.sql similarity index 100% rename from sql/14beta2/extra/float8.sql rename to sql/14.0/extra/float8.sql diff --git a/sql/14beta2/extra/insert.sql b/sql/14.0/extra/insert.sql similarity index 100% rename from sql/14beta2/extra/insert.sql rename to sql/14.0/extra/insert.sql diff --git a/sql/14beta2/extra/int4.sql b/sql/14.0/extra/int4.sql similarity index 100% rename from sql/14beta2/extra/int4.sql rename to sql/14.0/extra/int4.sql diff --git a/sql/14beta2/extra/int8.sql b/sql/14.0/extra/int8.sql similarity index 100% rename from sql/14beta2/extra/int8.sql rename to sql/14.0/extra/int8.sql diff --git a/sql/14beta2/extra/join.sql b/sql/14.0/extra/join.sql similarity index 98% rename from sql/14beta2/extra/join.sql rename to sql/14.0/extra/join.sql index 3ee2ea85..c1db4357 100644 --- a/sql/14beta2/extra/join.sql +++ b/sql/14.0/extra/join.sql @@ -741,6 +741,7 @@ select * from t12 left join t22 on (t12.a = t22.a); --Testcase 120: select t12.x from t12 join t32 on (t12.a = t32.x); +--Testcase 536: drop table t2a; -- @@ -788,7 +789,7 @@ set work_mem to '64kB'; --Testcase 506: set enable_mergejoin to off; --Testcase 507: -set enable_resultcache to off; +set enable_memoize to off; --Testcase 127: explain (costs off) @@ -803,7 +804,7 @@ reset work_mem; --Testcase 509: reset enable_mergejoin; --Testcase 510: -reset enable_resultcache; +reset enable_memoize; -- -- regression test for 8.2 bug with improper re-ordering of left joins @@ -934,6 +935,7 @@ select * from left join zv1 on (f3 = f1) where f2 = 53; +--Testcase 537: drop view zv1; -- @@ -1455,6 +1457,10 @@ select unique1 from tenk1, f_immutable_int4(1) x where x = unique1; explain (costs off) select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1; +--Testcase 538: +explain (costs off) +select unique1 from tenk1, lateral f_immutable_int4(1) x where x in (select 17); + --Testcase 428: explain (costs off) select unique1, x from tenk1 join f_immutable_int4(1) x on unique1 = x; @@ -2177,6 +2183,21 @@ select i8.*, ss.v, t.unique2 left join tenk1 t on t.unique2 = ss.v where q2 = 456; +-- -- and check a related issue where we miscompute required relids for +-- -- a PHV that's been translated to a child rel +-- create temp table parttbl (a integer primary key) partition by range (a); +-- create temp table parttbl1 partition of parttbl for values from (1) to (100); +-- insert into parttbl values (11), (12); +-- explain (costs off) +-- select * from +-- (select *, 12 as phv from parttbl) as ss +-- right join int4_tbl on true +-- where ss.a = ss.phv and f1 = 0; +-- select * from +-- (select *, 12 as phv from parttbl) as ss +-- right join int4_tbl on true +-- where ss.a = ss.phv and f1 = 0; + -- bug #8444: we've historically allowed duplicate aliases within aliased JOINs --Testcase 267: diff --git a/sql/14beta2/extra/limit.sql b/sql/14.0/extra/limit.sql similarity index 100% rename from sql/14beta2/extra/limit.sql rename to sql/14.0/extra/limit.sql diff --git a/sql/14beta2/extra/numeric.sql b/sql/14.0/extra/numeric.sql similarity index 95% rename from sql/14beta2/extra/numeric.sql rename to sql/14.0/extra/numeric.sql index c99ace56..ad9c0925 100644 --- a/sql/14beta2/extra/numeric.sql +++ b/sql/14.0/extra/numeric.sql @@ -1571,6 +1571,103 @@ SELECT * FROM fract_only; --Testcase 580: DROP FOREIGN TABLE fract_only; +-- Check conversion to integers +-- SQLite promises to preserve the first 15 significant decimal digits of the floating point value. +-- However, it makes no guarantees about the accuracy of computations on floating point values, as no such guarantees are possible. +-- A floating-point value as written in an SQL statement may not be the same as the value represented internally. +-- Actual result is different from expected result. +--Testcase 1485: +CREATE FOREIGN TABLE num_tmp (n1 numeric, n2 numeric, id int options (key 'true')) SERVER sqlite_svr; + +--Testcase 1486: +DELETE FROM num_tmp; +--Testcase 1487: +INSERT INTO num_tmp(n1) VALUES (-9223372036854775808.5); +--Testcase 1488: +SELECT n1::int8 FROM num_tmp; -- should fail + +--Testcase 1489: +DELETE FROM num_tmp; +--Testcase 1490: +INSERT INTO num_tmp(n1) VALUES (-9223372036854775808.4); +--Testcase 1491: +SELECT n1::int8 FROM num_tmp; -- should fail + +--Testcase 1492: +DELETE FROM num_tmp; +--Testcase 1493: +INSERT INTO num_tmp(n1) VALUES (9223372036854775807.4); +--Testcase 1494: +SELECT n1::int8 FROM num_tmp; -- should fail + +--Testcase 1495: +DELETE FROM num_tmp; +--Testcase 1496: +INSERT INTO num_tmp(n1) VALUES (9223372036854775807.5); +--Testcase 1497: +SELECT n1::int8 FROM num_tmp; -- should fail + +--Testcase 1498: +DELETE FROM num_tmp; +--Testcase 1499: +INSERT INTO num_tmp(n1) VALUES (-2147483648.5); +--Testcase 1500: +SELECT n1::int4 FROM num_tmp; -- should fail + +--Testcase 1501: +DELETE FROM num_tmp; +--Testcase 1502: +INSERT INTO num_tmp(n1) VALUES (-2147483648.4); +--Testcase 1503: +SELECT n1::int4 FROM num_tmp; -- ok + +--Testcase 1504: +DELETE FROM num_tmp; +--Testcase 1505: +INSERT INTO num_tmp(n1) VALUES (2147483647.4); +--Testcase 1506: +SELECT n1::int4 FROM num_tmp; -- ok + +--Testcase 1507: +DELETE FROM num_tmp; +--Testcase 1508: +INSERT INTO num_tmp(n1) VALUES (2147483647.5); +--Testcase 1509: +SELECT n1::int4 FROM num_tmp; -- should fail + +--Testcase 1510: +DELETE FROM num_tmp; +--Testcase 1511: +INSERT INTO num_tmp(n1) VALUES (-32768.5); +--Testcase 1512: +SELECT n1::int2 FROM num_tmp; -- should fail + +--Testcase 1513: +DELETE FROM num_tmp; +--Testcase 1514: +INSERT INTO num_tmp(n1) VALUES (-32768.4); +--Testcase 1515: +SELECT n1::int2 FROM num_tmp; -- ok + +--Testcase 1516: +DELETE FROM num_tmp; +--Testcase 1517: +INSERT INTO num_tmp(n1) VALUES (32767.4); +--Testcase 1518: +SELECT n1::int2 FROM num_tmp; -- ok + +--Testcase 1519: +DELETE FROM num_tmp; +--Testcase 1520: +INSERT INTO num_tmp(n1) VALUES (32767.5); +--Testcase 1521: +SELECT n1::int2 FROM num_tmp; -- should fail + +--Testcase 1555: +DELETE FROM num_tmp; +--Testcase 1555: +DROP FOREIGN TABLE num_tmp; + -- Check inf/nan conversion behavior --Testcase 581: CREATE FOREIGN TABLE FLOAT8_TMP(f1 float8, f2 float8, id int OPTIONS (key 'true')) SERVER sqlite_svr; @@ -2028,6 +2125,16 @@ SELECT x, to_char(x::float4, '9.999EEEE') as float4 FROM v; +--Testcase 1522: +DELETE FROM v; +--Testcase 1523: +INSERT INTO v(x) VALUES (-16379),(-16378),(-1234),(-789),(-45),(-5),(-4),(-3),(-2),(-1),(0), + (1),(2),(3),(4),(5),(38),(275),(2345),(45678),(131070),(131071); +--Testcase 1524: +SELECT x, + to_char(('1.2345e'||x)::numeric, '9.999EEEE') as numeric +FROM v; + --Testcase 1479: DELETE FROM v; --Testcase 1480: @@ -2334,6 +2441,13 @@ INSERT INTO num_tmp VALUES (4769999999999999999999999999999999999999999999999999 --Testcase 718: SELECT n1 * n2 FROM num_tmp; +--Testcase 1525: +DELETE FROM num_tmp; +--Testcase 1526: +INSERT INTO num_tmp VALUES ((0.1 - 2e-16383), (0.1 - 3e-16383)); +--Testcase 1527: +SELECT trim_scale(n1 * n2) FROM num_tmp; + -- -- Test some corner cases for division -- @@ -2480,35 +2594,42 @@ DELETE FROM num_tmp; --Testcase 777: INSERT INTO num_tmp VALUES (3.789, 21); --Testcase 778: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; --Testcase 779: DELETE FROM num_tmp; --Testcase 780: INSERT INTO num_tmp VALUES (3.789, 35); --Testcase 781: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; --Testcase 782: DELETE FROM num_tmp; --Testcase 783: INSERT INTO num_tmp VALUES (1.2, 345); --Testcase 784: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; --Testcase 785: DELETE FROM num_tmp; --Testcase 786: INSERT INTO num_tmp VALUES (0.12, (-20)); --Testcase 787: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; --Testcase 1220: DELETE FROM num_tmp; --Testcase 1221: INSERT INTO num_tmp VALUES (1.000000000123, (-2147483648)); --Testcase 1222: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; + +--Testcase 1528: +DELETE FROM num_tmp; +--Testcase 1529: +INSERT INTO num_tmp VALUES (0.9999999999, 23300000000000); +--Testcase 1530: +SELECT coalesce(nullif(n1 ^ n2, 0), 0) FROM num_tmp; -- cases that used to error out --Testcase 788: @@ -2516,14 +2637,57 @@ DELETE FROM num_tmp; --Testcase 789: INSERT INTO num_tmp VALUES (0.12, (-25)); --Testcase 790: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; --Testcase 791: DELETE FROM num_tmp; --Testcase 792: INSERT INTO num_tmp VALUES (0.5678, (-85)); --Testcase 793: -select n1 ^ n2 FROM num_tmp; +SELECT n1 ^ n2 FROM num_tmp; + +--Testcase 1531: +DELETE FROM num_tmp; +--Testcase 1532: +INSERT INTO num_tmp VALUES (0.9999999999, 70000000000000); +--Testcase 1533: +SELECT coalesce(nullif(n1 ^ n2, 0), 0) FROM num_tmp; + +-- negative base to integer powers +--Testcase 1534: +DELETE FROM num_tmp; +--Testcase 1535: +INSERT INTO num_tmp VALUES ((-1.0), 2147483646); +--Testcase 1536: +SELECT n1 ^ n2 FROM num_tmp; + +--Testcase 1537: +DELETE FROM num_tmp; +--Testcase 1538: +INSERT INTO num_tmp VALUES ((-1.0), 2147483647); +--Testcase 1539: +SELECT n1 ^ n2 FROM num_tmp; + +--Testcase 1540: +DELETE FROM num_tmp; +--Testcase 1541: +INSERT INTO num_tmp VALUES ((-1.0), 2147483648); +--Testcase 1542: +SELECT n1 ^ n2 FROM num_tmp; + +--Testcase 1543: +DELETE FROM num_tmp; +--Testcase 1544: +INSERT INTO num_tmp VALUES ((-1.0), 1000000000000000); +--Testcase 1545: +SELECT n1 ^ n2 FROM num_tmp; + +--Testcase 1546: +DELETE FROM num_tmp; +--Testcase 1547: +INSERT INTO num_tmp VALUES ((-1.0), 1000000000000001); +--Testcase 1548: +SELECT n1 ^ n2 FROM num_tmp; -- -- Tests for raising to non-integer powers @@ -2693,6 +2857,20 @@ INSERT INTO num_tmp VALUES ('-inf'::numeric); --Testcase 1231: select exp(n1) from num_tmp; +--Testcase 1549: +DELETE FROM num_tmp; +--Testcase 1550: +INSERT INTO num_tmp VALUES ('-5000'::numeric); +--Testcase 1551: +select coalesce(nullif(exp(n1), 0), 0) from num_tmp; + +--Testcase 1552: +DELETE FROM num_tmp; +--Testcase 1553: +INSERT INTO num_tmp VALUES ('-10000'::numeric); +--Testcase 1554: +select coalesce(nullif(exp(n1), 0), 0) from num_tmp; + -- cases that used to generate inaccurate results --Testcase 851: DELETE FROM num_tmp; diff --git a/sql/14beta2/extra/prepare.sql b/sql/14.0/extra/prepare.sql similarity index 100% rename from sql/14beta2/extra/prepare.sql rename to sql/14.0/extra/prepare.sql diff --git a/sql/14beta2/extra/select.sql b/sql/14.0/extra/select.sql similarity index 100% rename from sql/14beta2/extra/select.sql rename to sql/14.0/extra/select.sql diff --git a/sql/14beta2/extra/select_having.sql b/sql/14.0/extra/select_having.sql similarity index 100% rename from sql/14beta2/extra/select_having.sql rename to sql/14.0/extra/select_having.sql diff --git a/sql/14beta2/extra/sqlite_fdw_post.sql b/sql/14.0/extra/sqlite_fdw_post.sql similarity index 96% rename from sql/14beta2/extra/sqlite_fdw_post.sql rename to sql/14.0/extra/sqlite_fdw_post.sql index 747e7ad9..2967a26b 100644 --- a/sql/14beta2/extra/sqlite_fdw_post.sql +++ b/sql/14.0/extra/sqlite_fdw_post.sql @@ -20,6 +20,7 @@ $d$; CREATE USER MAPPING FOR CURRENT_USER SERVER sqlite_svr; --Testcase 485: CREATE USER MAPPING FOR CURRENT_USER SERVER sqlite_svr2; +--Testcase 756: CREATE USER MAPPING FOR public SERVER sqlite_svr3; -- =================================================================== -- create objects used through FDW sqlite server @@ -81,6 +82,7 @@ CREATE FOREIGN TABLE ft1 ( c7 char(10) default 'ft1', c8 text ) SERVER sqlite_svr; +--Testcase 757: ALTER FOREIGN TABLE ft1 DROP COLUMN c0; --Testcase 490: @@ -95,6 +97,7 @@ CREATE FOREIGN TABLE ft2 ( c7 char(10) default 'ft2', c8 text ) SERVER sqlite_svr; +--Testcase 758: ALTER FOREIGN TABLE ft2 DROP COLUMN cx; --Testcase 491: @@ -118,15 +121,20 @@ CREATE FOREIGN TABLE ft6 ( c3 text ) SERVER sqlite_svr2 OPTIONS (table 'T 4'); +--Testcase 759: CREATE FOREIGN TABLE ft7 ( c1 int NOT NULL, c2 int NOT NULL, c3 text ) SERVER sqlite_svr3 OPTIONS (table 'T 4'); +--Testcase 760: ALTER FOREIGN TABLE ft1 OPTIONS (table 'T 1'); +--Testcase 761: ALTER FOREIGN TABLE ft2 OPTIONS (table 'T 1'); +--Testcase 762: ALTER FOREIGN TABLE ft1 ALTER COLUMN c1 OPTIONS (column_name 'C 1'); +--Testcase 763: ALTER FOREIGN TABLE ft2 ALTER COLUMN c1 OPTIONS (column_name 'C 1'); --Testcase 5: \det+ @@ -136,6 +144,7 @@ ALTER FOREIGN TABLE ft2 ALTER COLUMN c1 OPTIONS (column_name 'C 1'); \set VERBOSITY terse --Testcase 6: SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work +--Testcase 764: ALTER SERVER sqlite_svr OPTIONS (SET database 'no such database'); --Testcase 7: SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should fail @@ -206,7 +215,9 @@ WITH t1 AS (SELECT * FROM ft1 WHERE c1 <= 10) SELECT t2.c1, t2.c2, t2.c3, t2.c4 --Testcase 26: SELECT 'fixed', NULL FROM ft1 t1 WHERE c1 = 1; -- Test forcing the remote server to produce sorted data for a merge join. +--Testcase 765: SET enable_hashjoin TO false; +--Testcase 766: SET enable_nestloop TO false; -- inner join; expressions in the clauses appear in the equivalence class list --Testcase 27: @@ -242,19 +253,25 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT t1."C 1", t2.c1, t3.c1 FROM "S 1"."T 1" t1 full join ft1 t2 full join ft2 t3 on (t2.c1 = t3.c1) on (t3.c1 = t1."C 1") OFFSET 100 LIMIT 10; --Testcase 36: SELECT t1."C 1", t2.c1, t3.c1 FROM "S 1"."T 1" t1 full join ft1 t2 full join ft2 t3 on (t2.c1 = t3.c1) on (t3.c1 = t1."C 1") OFFSET 100 LIMIT 10; +--Testcase 767: RESET enable_hashjoin; +--Testcase 768: RESET enable_nestloop; -- Test executing assertion in estimate_path_cost_size() that makes sure that -- retrieved_rows for foreign rel re-used to cost pre-sorted foreign paths is -- a sensible value even when the rel has tuples=0 -- CREATE TABLE loct_empty (c1 int NOT NULL, c2 text); +--Testcase 769: CREATE FOREIGN TABLE ft_empty (c1 int NOT NULL, c2 text) SERVER sqlite_svr OPTIONS (table 'loct_empty'); +--Testcase 770: INSERT INTO "S 1".loct_empty SELECT id, 'AAA' || to_char(id, 'FM000') FROM generate_series(1, 100) id; +--Testcase 771: DELETE FROM "S 1".loct_empty; -- ANALYZE ft_empty; +--Testcase 772: EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft_empty ORDER BY c1; -- =================================================================== @@ -358,7 +375,9 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE t1.c1 === t1.c2 order by t1.c2 limit 1; -- but let's put them in an extension ... +--Testcase 773: ALTER EXTENSION sqlite_fdw ADD FUNCTION sqlite_fdw_abs(int); +--Testcase 774: ALTER EXTENSION sqlite_fdw ADD OPERATOR === (int, int); --ALTER SERVER sqlite_svr2 OPTIONS (ADD extensions 'sqlite_fdw'); @@ -515,14 +534,16 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.c1, t2.c2, t3.c3 FROM ft2 t1 LEFT JOIN ft2 t2 ON (t1.c1 = t2.c1) FULL JOIN ft4 t3 ON (t2.c1 = t3.c1) OFFSET 10 LIMIT 10; --Testcase 104: SELECT t1.c1, t2.c2, t3.c3 FROM ft2 t1 LEFT JOIN ft2 t2 ON (t1.c1 = t2.c1) FULL JOIN ft4 t3 ON (t2.c1 = t3.c1) ORDER BY t1.c1 OFFSET 10 LIMIT 10; -SET enable_resultcache TO off; +--Testcase 775: +SET enable_memoize TO off; -- right outer join + left outer join --Testcase 105: EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.c1, t2.c2, t3.c3 FROM ft2 t1 RIGHT JOIN ft2 t2 ON (t1.c1 = t2.c1) LEFT JOIN ft4 t3 ON (t2.c1 = t3.c1) OFFSET 10 LIMIT 10; --Testcase 106: SELECT t1.c1, t2.c2, t3.c3 FROM ft2 t1 RIGHT JOIN ft2 t2 ON (t1.c1 = t2.c1) LEFT JOIN ft4 t3 ON (t2.c1 = t3.c1) OFFSET 10 LIMIT 10; -RESET enable_resultcache; +--Testcase 776: +RESET enable_memoize; -- left outer join + right outer join --Testcase 107: EXPLAIN (VERBOSE, COSTS OFF) @@ -544,6 +565,7 @@ SELECT t1.c1, t2.c2, t1.c3 FROM ft1 t1 FULL JOIN ft2 t2 ON (t1.c1 = t2.c1) WHERE --Testcase 505: EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.c1, t2.c2, t1.c3 FROM ft1 t1 FULL JOIN ft2 t2 ON (t1.c1 = t2.c1) WHERE sqlite_fdw_abs(t1.c1) > 0 OFFSET 10 LIMIT 10; +--Testcase 777: ALTER SERVER loopback OPTIONS (ADD extensions 'postgres_fdw'); -- join two tables with FOR UPDATE clause -- tests whole-row reference for row marks @@ -669,7 +691,9 @@ CREATE TABLE local_tbl (c1 int NOT NULL, c2 int NOT NULL, c3 text, CONSTRAINT lo --Testcase 507: INSERT INTO local_tbl SELECT id, id % 10, to_char(id, 'FM0000') FROM generate_series(1, 1000) id; ANALYZE local_tbl; +--Testcase 778: SET enable_nestloop TO false; +--Testcase 779: SET enable_hashjoin TO false; --Testcase 147: EXPLAIN (VERBOSE, COSTS OFF) @@ -678,7 +702,9 @@ SELECT * FROM ft1, ft2, ft4, ft5, local_tbl WHERE ft1.c1 = ft2.c1 AND ft1.c2 = f --Testcase 148: SELECT * FROM ft1, ft2, ft4, ft5, local_tbl WHERE ft1.c1 = ft2.c1 AND ft1.c2 = ft4.c1 AND ft1.c2 = ft5.c1 AND ft1.c2 = local_tbl.c1 AND ft1.c1 < 100 AND ft2.c1 < 100 ORDER BY ft1.c1 FOR UPDATE; +--Testcase 780: RESET enable_nestloop; +--Testcase 781: RESET enable_hashjoin; --DROP TABLE local_tbl; @@ -694,12 +720,14 @@ GRANT SELECT ON ft5 TO regress_view_owner; CREATE VIEW v4 AS SELECT * FROM ft4; --Testcase 511: CREATE VIEW v5 AS SELECT * FROM ft5; +--Testcase 782: ALTER VIEW v5 OWNER TO regress_view_owner; --Testcase 149: EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10; -- can't be pushed down, different view owners --Testcase 150: SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10; +--Testcase 783: ALTER VIEW v4 OWNER TO regress_view_owner; --Testcase 151: EXPLAIN (VERBOSE, COSTS OFF) @@ -712,12 +740,14 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10; -- can't be pushed down, view owner not current user --Testcase 154: SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10; +--Testcase 784: ALTER VIEW v4 OWNER TO CURRENT_USER; --Testcase 155: EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10; -- can be pushed down --Testcase 156: SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1, t2.c1 OFFSET 10 LIMIT 10; +--Testcase 785: ALTER VIEW v4 OWNER TO regress_view_owner; -- cleanup @@ -932,6 +962,7 @@ create aggregate least_agg(variadic items anyarray) ( ); -- Disable hash aggregation for plan stability. +--Testcase 786: set enable_hashagg to false; -- Not pushed down due to user defined aggregate @@ -962,6 +993,7 @@ explain (verbose, costs off) select c2, least_agg(c1) from ft1 group by c2 order by c2; -- Cleanup +--Testcase 787: reset enable_hashagg; --Testcase 528: drop aggregate least_agg(variadic items anyarray); @@ -1019,11 +1051,17 @@ select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 --ANALYZE ft2; -- Add into extension +--Testcase 788: alter extension sqlite_fdw add operator class my_op_class using btree; +--Testcase 789: alter extension sqlite_fdw add function my_op_cmp(a int, b int); +--Testcase 790: alter extension sqlite_fdw add operator family my_op_family using btree; +--Testcase 791: alter extension sqlite_fdw add operator public.<^(int, int); +--Testcase 792: alter extension sqlite_fdw add operator public.=^(int, int); +--Testcase 793: alter extension sqlite_fdw add operator public.>^(int, int); --alter server loopback options (set extensions 'postgres_fdw'); @@ -1035,11 +1073,17 @@ select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 and c1 < 100 group by c2; -- Remove from extension +--Testcase 794: alter extension sqlite_fdw drop operator class my_op_class using btree; +--Testcase 795: alter extension sqlite_fdw drop function my_op_cmp(a int, b int); +--Testcase 796: alter extension sqlite_fdw drop operator family my_op_family using btree; +--Testcase 797: alter extension sqlite_fdw drop operator public.<^(int, int); +--Testcase 798: alter extension sqlite_fdw drop operator public.=^(int, int); +--Testcase 799: alter extension sqlite_fdw drop operator public.>^(int, int); --alter server loopback options (set extensions 'postgres_fdw'); @@ -1099,12 +1143,14 @@ select sum(c2) * (random() <= 1)::int as sum from ft1 order by 1; select sum(c2) * (random() <= 1)::int as sum from ft1 order by 1; -- LATERAL join, with parameterization +--Testcase 800: set enable_hashagg to false; --Testcase 210: explain (verbose, costs off) select c2, sum from "S 1"."T 1" t1, lateral (select sum(t2.c1 + t1."C 1") sum from ft2 t2 group by t2.c1) qry where t1.c2 * 2 = qry.sum and t1.c2 < 3 and t1."C 1" < 100 order by 1; --Testcase 211: select c2, sum from "S 1"."T 1" t1, lateral (select sum(t2.c1 + t1."C 1") sum from ft2 t2 group by t2.c1) qry where t1.c2 * 2 = qry.sum and t1.c2 < 3 and t1."C 1" < 100 order by 1; +--Testcase 801: reset enable_hashagg; -- bug #15613: bad plan for foreign table scan with lateral reference @@ -1266,6 +1312,7 @@ PREPARE st7 AS INSERT INTO ft1 (c1,c2,c3) VALUES (1001,101,'foo'); EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st7; --Testcase 548: INSERT INTO "S 1"."T 0" SELECT * FROM "S 1"."T 1"; +--Testcase 802: ALTER FOREIGN TABLE ft1 OPTIONS (SET table 'T 0'); --Testcase 261: EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st6; @@ -1273,6 +1320,7 @@ EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st6; EXECUTE st6; --Testcase 263: EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st7; +--Testcase 803: ALTER FOREIGN TABLE ft1 OPTIONS (SET table 'T 1'); --Testcase 549: @@ -1340,34 +1388,42 @@ DROP FUNCTION f_test(int); -- REINDEX -- =================================================================== -- remote table is not created here +--Testcase 804: CREATE FOREIGN TABLE reindex_foreign (c1 int, c2 int) SERVER sqlite_svr2 OPTIONS (table 'reindex_local'); REINDEX TABLE reindex_foreign; -- error REINDEX TABLE CONCURRENTLY reindex_foreign; -- error +--Testcase 805: DROP FOREIGN TABLE reindex_foreign; -- partitions and foreign tables +--Testcase 806: CREATE TABLE reind_fdw_parent (c1 int) PARTITION BY RANGE (c1); +--Testcase 807: CREATE TABLE reind_fdw_0_10 PARTITION OF reind_fdw_parent FOR VALUES FROM (0) TO (10); +--Testcase 808: CREATE FOREIGN TABLE reind_fdw_10_20 PARTITION OF reind_fdw_parent FOR VALUES FROM (10) TO (20) SERVER sqlite_svr OPTIONS (table 'reind_local_10_20'); REINDEX TABLE reind_fdw_parent; -- ok REINDEX TABLE CONCURRENTLY reind_fdw_parent; -- ok +--Testcase 809: DROP TABLE reind_fdw_parent; -- =================================================================== -- conversion error -- =================================================================== +--Testcase 810: ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE int; --Testcase 273: -SELECT * FROM ft1 WHERE c1 = 1; +SELECT * FROM ft1 ftx(x1,x2,x3,x4,x5,x6,x7,x8) WHERE x1 = 1; --Testcase 274: -SELECT ft1.c1, ft2.c2, ft1.c8 FROM ft1, ft2 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = 1; +SELECT ftx.x1, ft2.c2, ftx.x8 FROM ft1 ftx(x1,x2,x3,x4,x5,x6,x7,x8), ft2 WHERE ftx.x1 = ft2.c1 AND ftx.x1 = 1; --Testcase 275: -SELECT ft1.c1, ft2.c2, ft1 FROM ft1, ft2 WHERE ft1.c1 = ft2.c1 AND ft1.c1 = 1; +SELECT ftx.x1, ft2.c2, ftx FROM ft1 ftx(x1,x2,x3,x4,x5,x6,x7,x8), ft2 WHERE ftx.x1 = ft2.c1 AND ftx.x1 = 1; --Testcase 276: SELECT sum(c2), array_agg(c8) FROM ft1 GROUP BY c8; +--Testcase 811: ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE text; -- =================================================================== @@ -1545,9 +1601,11 @@ UPDATE ft2 AS target SET (c2) = ( -- Test UPDATE involving a join that can be pushed down, -- but a SET clause that can't be +--Testcase 812: EXPLAIN (VERBOSE, COSTS OFF) UPDATE ft2 d SET c2 = CASE WHEN random() >= 0 THEN d.c2 ELSE 0 END FROM ft2 AS t WHERE d.c1 = t.c1 AND d.c1 > 1000; +--Testcase 813: UPDATE ft2 d SET c2 = CASE WHEN random() >= 0 THEN d.c2 ELSE 0 END FROM ft2 AS t WHERE d.c1 = t.c1 AND d.c1 > 1000; @@ -1737,41 +1795,49 @@ ALTER FOREIGN TABLE ft1 RENAME TO ft1_org; --Testcase 753: ALTER FOREIGN TABLE ft1_constraint RENAME TO ft1; -- Consistent check constraints provide consistent results +--Testcase 814: ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c2positive CHECK (c2 >= 0); --Testcase 587: EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 WHERE c2 < 0; --Testcase 588: SELECT count(*) FROM ft1 WHERE c2 < 0; +--Testcase 815: SET constraint_exclusion = 'on'; --Testcase 589: EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 WHERE c2 < 0; --Testcase 590: SELECT count(*) FROM ft1 WHERE c2 < 0; +--Testcase 816: RESET constraint_exclusion; -- check constraint is enforced on the remote side, not locally --Testcase 745: INSERT INTO ft1(c1, c2) VALUES(1111, -2); -- c2positive --Testcase 746: UPDATE ft1 SET c2 = -c2 WHERE c1 = 1; -- c2positive +--Testcase 817: ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2positive; -- But inconsistent check constraints provide inconsistent results +--Testcase 818: ALTER FOREIGN TABLE ft1 ADD CONSTRAINT ft1_c2negative CHECK (c2 < 0); --Testcase 591: EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 WHERE c2 >= 0; --Testcase 592: SELECT count(*) FROM ft1 WHERE c2 >= 0; +--Testcase 819: SET constraint_exclusion = 'on'; --Testcase 593: EXPLAIN (VERBOSE, COSTS OFF) SELECT count(*) FROM ft1 WHERE c2 >= 0; --Testcase 594: SELECT count(*) FROM ft1 WHERE c2 >= 0; +--Testcase 820: RESET constraint_exclusion; -- local check constraint is not actually enforced --Testcase 595: INSERT INTO ft1(c1, c2) VALUES(1111, 2); --Testcase 596: UPDATE ft1 SET c2 = c2 + 1 WHERE c1 = 1; +--Testcase 821: ALTER FOREIGN TABLE ft1 DROP CONSTRAINT ft1_c2negative; -- =================================================================== @@ -1832,6 +1898,7 @@ CREATE TRIGGER row_before_insupd_trigger BEFORE INSERT OR UPDATE ON foreign_tbl --Testcase 615: CREATE TABLE parent_tbl (a int, b int) PARTITION BY RANGE(a); +--Testcase 822: ALTER TABLE parent_tbl ATTACH PARTITION foreign_tbl FOR VALUES FROM (0) TO (100); --Testcase 616: @@ -1907,13 +1974,44 @@ select f1, f2 from rem1; create foreign table grem1 ( a int options (key 'true'), b int generated always as (a * 2) stored) - server sqlite_svr; + server sqlite_svr options(table 'grem1_post14'); --Testcase 638: +explain (verbose, costs off) +insert into grem1 (a) values (1), (2); +--Testcase 823: insert into grem1 (a) values (1), (2); --Testcase 639: +explain (verbose, costs off) +update grem1 set a = 22 where a = 2; +--Testcase 824: update grem1 set a = 22 where a = 2; --Testcase 640: select * from grem1; +--Testcase 825: +delete from grem1; + +-- -- test copy from +-- copy grem1 from stdin; +-- 1 +-- 2 +-- \. +-- select * from grem1; +-- delete from grem1; + +-- test batch insert +--Testcase 826: +alter server sqlite_svr options (add batch_size '10'); +--Testcase 827: +explain (verbose, costs off) +insert into grem1 (a) values (1), (2); +--Testcase 828: +insert into grem1 (a) values (1), (2); +--Testcase 829: +select * from grem1; +--Testcase 830: +delete from grem1; +--Testcase 831: +alter server sqlite_svr options (drop batch_size); -- =================================================================== -- test local triggers @@ -2242,6 +2340,12 @@ DROP TRIGGER trig_local_before ON rem1; -- Test direct foreign table modification functionality +--Testcase 832: +EXPLAIN (verbose, costs off) +DELETE FROM rem1; -- can be pushed down +--Testcase 833: +EXPLAIN (verbose, costs off) +DELETE FROM rem1 WHERE false; -- currently can't be pushed down -- Test with statement-level triggers --Testcase 687: @@ -2357,6 +2461,7 @@ DROP TRIGGER trig_row_after_delete ON rem1; --Testcase 703: CREATE TABLE a (aa TEXT); +--Testcase 834: ALTER TABLE a SET (autovacuum_enabled = 'false'); --Testcase 704: CREATE FOREIGN TABLE b (aa TEXT OPTIONS (key 'true'), bb TEXT) INHERITS (a) @@ -2439,7 +2544,9 @@ create table bar (f1 int, f2 int); create foreign table bar2 (f3 int OPTIONS (key 'true')) inherits (bar) server sqlite_svr options (table 'loct2'); +--Testcase 835: alter table foo set (autovacuum_enabled = 'false'); +--Testcase 836: alter table bar set (autovacuum_enabled = 'false'); --Testcase 437: @@ -2477,22 +2584,30 @@ select * from bar where f1 in (select f1 from foo) for share; -- Now check SELECT FOR UPDATE/SHARE with an inherited source table, -- where the parent is itself a foreign table +--Testcase 837: create foreign table foo2child (f3 int) inherits (foo2) server sqlite_svr options (table 'loct4_2'); +--Testcase 838: explain (verbose, costs off) select * from bar where f1 in (select f1 from foo2) for share; +--Testcase 839: select * from bar where f1 in (select f1 from foo2) for share; +--Testcase 840: drop foreign table foo2child; -- And with a local child relation of the foreign table parent +--Testcase 841: create table foo2child (f3 int) inherits (foo2); +--Testcase 842: explain (verbose, costs off) select * from bar where f1 in (select f1 from foo2) for share; +--Testcase 843: select * from bar where f1 in (select f1 from foo2) for share; +--Testcase 844: drop table foo2child; -- Check UPDATE with inherited target and an inherited source table @@ -2532,7 +2647,9 @@ truncate table only foo; insert into foo2 select generate_series(0, :num_rows_foo, 2), generate_series(0, :num_rows_foo, 2), generate_series(0, :num_rows_foo, 2); --Testcase 712: insert into foo select generate_series(1, :num_rows_foo, 2), generate_series(1, :num_rows_foo, 2); +--Testcase 845: SET enable_hashjoin to false; +--Testcase 846: SET enable_nestloop to false; --alter foreign table foo2 options (use_remote_estimate 'true'); --create index i_loct1_f1 on loct1(f1); @@ -2553,7 +2670,9 @@ explain (verbose, costs off) select foo.f1, foo2.f1 from foo left join foo2 on (foo.f1 = foo2.f1) order by foo.f2 offset 10 limit 10; --Testcase 717: select foo.f1, foo2.f1 from foo left join foo2 on (foo.f1 = foo2.f1) order by foo.f2 offset 10 limit 10; +--Testcase 847: RESET enable_hashjoin; +--Testcase 848: RESET enable_nestloop; -- Test that WHERE CURRENT OF is not supported @@ -2616,6 +2735,7 @@ create foreign table remt1 (a int OPTIONS (key 'true'), b text) --Testcase 724: create foreign table remt2 (a int OPTIONS (key 'true'), b text) server sqlite_svr options (table 'loct4'); +--Testcase 849: alter foreign table remt1 inherit parent; --Testcase 468: @@ -2999,8 +3119,10 @@ drop table loc3; -- =================================================================== -- test for TRUNCATE -- =================================================================== +--Testcase 850: CREATE FOREIGN TABLE tru_ftable (id int) SERVER sqlite_svr OPTIONS (table 'tru_rtable0'); +--Testcase 851: INSERT INTO "S 1".tru_rtable0 (SELECT x FROM generate_series(1,10) x); -- CREATE TABLE tru_ptable (id int) PARTITION BY HASH(id); @@ -3011,34 +3133,50 @@ INSERT INTO "S 1".tru_rtable0 (SELECT x FROM generate_series(1,10) x); -- SERVER sqlite_svr OPTIONS (table 'tru_ptable'); -- INSERT INTO tru_ptable (SELECT x FROM generate_series(11,20) x); +--Testcase 852: INSERT INTO "S 1".tru_pk_table (SELECT x FROM generate_series(1,10) x); +--Testcase 853: INSERT INTO "S 1".tru_fk_table(fkey) (SELECT x % 10 + 1 FROM generate_series(5,25) x); +--Testcase 854: CREATE FOREIGN TABLE tru_pk_ftable (id int) SERVER sqlite_svr OPTIONS (table 'tru_pk_table'); +--Testcase 855: CREATE FOREIGN TABLE tru_ftable_parent (id int) SERVER sqlite_svr OPTIONS (table 'tru_rtable_parent'); +--Testcase 856: CREATE FOREIGN TABLE tru_ftable_child () INHERITS (tru_ftable_parent) SERVER sqlite_svr OPTIONS (table 'tru_rtable_child'); +--Testcase 857: INSERT INTO "S 1".tru_rtable_parent (SELECT x FROM generate_series(1,8) x); +--Testcase 858: INSERT INTO "S 1".tru_rtable_child (SELECT x FROM generate_series(10, 18) x); -- normal truncate +--Testcase 859: SELECT sum(id) FROM tru_ftable; -- 55 TRUNCATE tru_ftable; +--Testcase 860: SELECT count(*) FROM "S 1".tru_rtable0; -- 0 +--Testcase 861: SELECT count(*) FROM tru_ftable; -- 0 -- 'truncatable' option +--Testcase 862: ALTER SERVER sqlite_svr OPTIONS (ADD truncatable 'false'); TRUNCATE tru_ftable; -- error +--Testcase 863: ALTER FOREIGN TABLE tru_ftable OPTIONS (ADD truncatable 'true'); TRUNCATE tru_ftable; -- accepted +--Testcase 864: ALTER FOREIGN TABLE tru_ftable OPTIONS (SET truncatable 'false'); TRUNCATE tru_ftable; -- error +--Testcase 865: ALTER SERVER sqlite_svr OPTIONS (DROP truncatable); +--Testcase 866: ALTER FOREIGN TABLE tru_ftable OPTIONS (SET truncatable 'false'); TRUNCATE tru_ftable; -- error +--Testcase 867: ALTER FOREIGN TABLE tru_ftable OPTIONS (SET truncatable 'true'); TRUNCATE tru_ftable; -- accepted @@ -3051,30 +3189,41 @@ TRUNCATE tru_ftable; -- accepted -- SELECT count(*) FROM tru_rtable1; -- 0 -- 'CASCADE' option +--Testcase 868: SELECT sum(id) FROM tru_pk_ftable; -- 55 -- SQLite FDW support TRUNCATE command by executing DELETE statement without WHERE clause. -- In order to delete records in parent and child table subsequently, -- SQLite FDW executes "PRAGMA foreign_keys = ON" before executing DELETE statement. TRUNCATE tru_pk_ftable; -- success TRUNCATE tru_pk_ftable CASCADE; -- success +--Testcase 869: SELECT count(*) FROM tru_pk_ftable; -- 0 +--Testcase 870: SELECT count(*) FROM "S 1".tru_fk_table; -- also truncated,0 -- truncate two tables at a command +--Testcase 871: INSERT INTO tru_ftable (SELECT x FROM generate_series(1,8) x); +--Testcase 872: INSERT INTO tru_pk_ftable (SELECT x FROM generate_series(3,10) x); +--Testcase 873: SELECT count(*) from tru_ftable; -- 8 +--Testcase 874: SELECT count(*) from tru_pk_ftable; -- 8 TRUNCATE tru_ftable, tru_pk_ftable; +--Testcase 875: SELECT count(*) from tru_ftable; -- 0 +--Testcase 876: SELECT count(*) from tru_pk_ftable; -- 0 -- truncate with ONLY clause -- Since ONLY is specified, the table tru_ftable_child that inherits -- tru_ftable_parent locally is not truncated. TRUNCATE ONLY tru_ftable_parent; +--Testcase 877: SELECT sum(id) FROM tru_ftable_parent; -- 126 TRUNCATE tru_ftable_parent; +--Testcase 878: SELECT count(*) FROM tru_ftable_parent; -- 0 -- -- in case when remote table has inherited children @@ -3096,6 +3245,7 @@ SELECT count(*) FROM tru_ftable_parent; -- 0 -- SELECT count(*) FROM tru_ftable; -- 0 -- cleanup +--Testcase 879: DROP FOREIGN TABLE tru_ftable_parent, tru_ftable_child, tru_pk_ftable,tru_ftable; -- DROP TABLE tru_rtable0, tru_rtable1, tru_ptable, tru_ptable__p0, tru_pk_table, tru_fk_table, -- tru_rtable_parent,tru_rtable_child, tru_rtable0_child; @@ -3354,7 +3504,7 @@ CREATE FOREIGN TABLE ft1_nopw ( ALTER FOREIGN TABLE ft1_nopw OPTIONS (table 'T 1'); ALTER FOREIGN TABLE ft1_nopw ALTER COLUMN c1 OPTIONS (column_name 'C 1'); -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; -- If we add a password to the connstr it'll fail, because we don't allow passwords -- in connstrs only in user mappings. @@ -3372,13 +3522,13 @@ $d$; ALTER USER MAPPING FOR CURRENT_USER SERVER sqlite_nopw OPTIONS (ADD password 'dummypw'); -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; -- Unpriv user cannot make the mapping passwordless ALTER USER MAPPING FOR CURRENT_USER SERVER sqlite_nopw OPTIONS (ADD password_required 'false'); -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; RESET ROLE; @@ -3388,7 +3538,7 @@ ALTER USER MAPPING FOR regress_nosuper SERVER sqlite_nopw OPTIONS (ADD password_ SET ROLE regress_nosuper; -- Should finally work now -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; -- unpriv user also cannot set sslcert / sslkey on the user mapping -- first set password_required so we see the right error messages @@ -3402,13 +3552,13 @@ DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_nopw; -- This will fail again as it'll resolve the user mapping for public, which -- lacks password_required=false -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; RESET ROLE; -- The user mapping for public is passwordless and lacks the password_required=false -- mapping option, but will work because the current user is a superuser. -SELECT * FROM ft1_nopw LIMIT 1; +SELECT 1 FROM ft1_nopw LIMIT 1; -- cleanup DROP USER MAPPING FOR public SERVER sqlite_nopw; @@ -3435,11 +3585,11 @@ ROLLBACK; -- -- Change application_name of remote connection to special one -- -- so that we can easily terminate the connection later. -- ALTER SERVER sqlite_svr OPTIONS (application_name 'fdw_retry_check'); --- -- If debug_invalidate_system_caches_always is active, it results in +-- -- If debug_discard_caches is active, it results in -- -- dropping remote connections after every transaction, making it -- -- impossible to test termination meaningfully. So turn that off -- -- for this test. --- SET debug_invalidate_system_caches_always = 0; +-- SET debug_discard_caches = 0; -- -- Make sure we have a remote connection. -- SELECT 1 FROM ft1 LIMIT 1; -- -- Terminate the remote connection and wait for the termination to complete. @@ -3461,37 +3611,47 @@ ROLLBACK; -- \set VERBOSITY default -- COMMIT; --- RESET debug_invalidate_system_caches_always; +-- RESET debug_discard_caches; -- ============================================================================= -- test connection invalidation cases and sqlite_fdw_get_connections function -- ============================================================================= -- Let's ensure to close all the existing cached connections. +--Testcase 880: SELECT 1 FROM sqlite_fdw_disconnect_all(); -- No cached connections, so no records should be output. +--Testcase 881: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- This test case is for closing the connection in sqlitefdw_xact_callback BEGIN; -- Connection xact depth becomes 1 i.e. the connection is in midst of the xact. +--Testcase 882: SELECT 1 FROM ft1 LIMIT 1; +--Testcase 883: SELECT 1 FROM ft7 LIMIT 1; -- List all the existing cached connections. sqlite_svr and sqlite_svr3 should be -- output. +--Testcase 884: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- Connections are not closed at the end of the alter and drop statements. -- That's because the connections are in midst of this xact, -- they are just marked as invalid in sqlitefdw_inval_callback. +--Testcase 885: ALTER SERVER sqlite_svr OPTIONS (ADD keep_connections 'off'); +--Testcase 886: DROP SERVER sqlite_svr3 CASCADE; -- List all the existing cached connections. sqlite_svr and sqlite_svr3 -- should be output as invalid connections. Also the server name for -- sqlite_svr3 should be NULL because the server was dropped. +--Testcase 887: SELECT * FROM sqlite_fdw_get_connections() ORDER BY 1; -- The invalid connections get closed in sqlitefdw_xact_callback during commit. COMMIT; +--Testcase 888: ALTER SERVER sqlite_svr OPTIONS (DROP keep_connections); -- All cached connections were closed while committing above xact, so no -- records should be output. +--Testcase 889: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- ======================================================================= @@ -3499,67 +3659,98 @@ SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- ======================================================================= BEGIN; -- Ensure to cache loopback connection. +--Testcase 890: SELECT 1 FROM ft1 LIMIT 1; -- Ensure to cache loopback2 connection. +--Testcase 891: SELECT 1 FROM ft6 LIMIT 1; -- List all the existing cached connections. sqlite_svr and sqlite_svr2 should be -- output. +--Testcase 892: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- Issue a warning and return false as sqlite_svr connection is still in use and -- can not be closed. +--Testcase 893: SELECT sqlite_fdw_disconnect('sqlite_svr'); -- List all the existing cached connections. sqlite_svr and sqlite_svr2 should be -- output. +--Testcase 894: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- Return false as connections are still in use, warnings are issued. -- But disable warnings temporarily because the order of them is not stable. +--Testcase 895: SET client_min_messages = 'ERROR'; +--Testcase 896: SELECT sqlite_fdw_disconnect_all(); +--Testcase 897: RESET client_min_messages; COMMIT; -- Ensure that sqlite_svr2 connection is closed. +--Testcase 898: SELECT 1 FROM sqlite_fdw_disconnect('sqlite_svr2'); +--Testcase 899: SELECT server_name FROM sqlite_fdw_get_connections() WHERE server_name = 'sqlite_svr2'; -- Return false as sqlite_svr2 connection is closed already. +--Testcase 900: SELECT sqlite_fdw_disconnect('sqlite_svr2'); -- Return an error as there is no foreign server with given name. +--Testcase 901: SELECT sqlite_fdw_disconnect('unknownserver'); -- Let's ensure to close all the existing cached connections. +--Testcase 902: SELECT 1 FROM sqlite_fdw_disconnect_all(); -- No cached connections, so no records should be output. +--Testcase 903: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- ============================================================================= -- test case for having multiple cached connections for a foreign server -- ============================================================================= +--Testcase 904: CREATE ROLE regress_multi_conn_user1 SUPERUSER; +--Testcase 905: CREATE ROLE regress_multi_conn_user2 SUPERUSER; +--Testcase 906: CREATE USER MAPPING FOR regress_multi_conn_user1 SERVER sqlite_svr; +--Testcase 907: CREATE USER MAPPING FOR regress_multi_conn_user2 SERVER sqlite_svr; BEGIN; -- Will cache sqlite_svr connection with user mapping for regress_multi_conn_user1 +--Testcase 908: SET ROLE regress_multi_conn_user1; +--Testcase 909: SELECT 1 FROM ft1 LIMIT 1; +--Testcase 910: RESET ROLE; -- Will cache sqlite_svr connection with user mapping for regress_multi_conn_user2 +--Testcase 911: SET ROLE regress_multi_conn_user2; +--Testcase 912: SELECT 1 FROM ft1 LIMIT 1; +--Testcase 913: RESET ROLE; -- Should output two connections for sqlite_svr server +--Testcase 914: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; COMMIT; -- Let's ensure to close all the existing cached connections. +--Testcase 915: SELECT 1 FROM sqlite_fdw_disconnect_all(); -- No cached connections, so no records should be output. +--Testcase 916: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; -- Clean up +--Testcase 917: DROP USER MAPPING FOR regress_multi_conn_user1 SERVER sqlite_svr; +--Testcase 918: DROP USER MAPPING FOR regress_multi_conn_user2 SERVER sqlite_svr; +--Testcase 919: DROP ROLE regress_multi_conn_user1; +--Testcase 920: DROP ROLE regress_multi_conn_user2; -- =================================================================== @@ -3567,12 +3758,16 @@ DROP ROLE regress_multi_conn_user2; -- =================================================================== -- By default, the connections associated with foreign server are cached i.e. -- keep_connections option is on. Set it to off. +--Testcase 921: ALTER SERVER sqlite_svr OPTIONS (keep_connections 'off'); -- connection to sqlite_svr server is closed at the end of xact -- as keep_connections was set to off. +--Testcase 922: SELECT 1 FROM ft1 LIMIT 1; -- No cached connections, so no records should be output. +--Testcase 923: SELECT server_name FROM sqlite_fdw_get_connections() ORDER BY 1; +--Testcase 924: ALTER SERVER sqlite_svr OPTIONS (SET keep_connections 'on'); -- =================================================================== @@ -3581,39 +3776,49 @@ ALTER SERVER sqlite_svr OPTIONS (SET keep_connections 'on'); BEGIN; +--Testcase 925: CREATE SERVER batch10 FOREIGN DATA WRAPPER sqlite_fdw OPTIONS( batch_size '10' ); +--Testcase 926: SELECT count(*) FROM pg_foreign_server WHERE srvname = 'batch10' AND srvoptions @> array['batch_size=10']; +--Testcase 927: ALTER SERVER batch10 OPTIONS( SET batch_size '20' ); +--Testcase 928: SELECT count(*) FROM pg_foreign_server WHERE srvname = 'batch10' AND srvoptions @> array['batch_size=10']; +--Testcase 929: SELECT count(*) FROM pg_foreign_server WHERE srvname = 'batch10' AND srvoptions @> array['batch_size=20']; +--Testcase 930: CREATE FOREIGN TABLE table30 ( x int ) SERVER batch10 OPTIONS ( batch_size '30' ); +--Testcase 931: SELECT COUNT(*) FROM pg_foreign_table WHERE ftrelid = 'table30'::regclass AND ftoptions @> array['batch_size=30']; +--Testcase 932: ALTER FOREIGN TABLE table30 OPTIONS ( SET batch_size '40'); +--Testcase 933: SELECT COUNT(*) FROM pg_foreign_table WHERE ftrelid = 'table30'::regclass AND ftoptions @> array['batch_size=30']; +--Testcase 934: SELECT COUNT(*) FROM pg_foreign_table WHERE ftrelid = 'table30'::regclass @@ -3621,28 +3826,47 @@ AND ftoptions @> array['batch_size=40']; ROLLBACK; +--Testcase 935: CREATE FOREIGN TABLE ftable ( x int OPTIONS (key 'true') ) SERVER sqlite_svr OPTIONS ( table 'batch_table', batch_size '10' ); +--Testcase 936: EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO ftable SELECT * FROM generate_series(1, 10) i; +--Testcase 937: INSERT INTO ftable SELECT * FROM generate_series(1, 10) i; +--Testcase 938: INSERT INTO ftable SELECT * FROM generate_series(11, 31) i; +--Testcase 939: INSERT INTO ftable VALUES (32); +--Testcase 940: INSERT INTO ftable VALUES (33), (34); +--Testcase 941: SELECT COUNT(*) FROM ftable; +--Testcase 942: DELETE FROM ftable; +--Testcase 943: DROP FOREIGN TABLE ftable; -- try if large batches exceed max number of bind parameters +--Testcase 944: CREATE FOREIGN TABLE ftable ( x int OPTIONS (key 'true') ) SERVER sqlite_svr OPTIONS ( table 'batch_table', batch_size '100000' ); +--Testcase 945: INSERT INTO ftable SELECT * FROM generate_series(1, 70000) i; +--Testcase 946: SELECT COUNT(*) FROM ftable; +--Testcase 947: DELETE FROM ftable; +--Testcase 948: DROP FOREIGN TABLE ftable; -- Disable batch insert +--Testcase 949: CREATE FOREIGN TABLE ftable ( x int ) SERVER sqlite_svr OPTIONS ( table 'batch_table', batch_size '1' ); +--Testcase 950: EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO ftable VALUES (1), (2); +--Testcase 951: INSERT INTO ftable VALUES (1), (2); +--Testcase 952: SELECT COUNT(*) FROM ftable; +--Testcase 953: DROP FOREIGN TABLE ftable; -- DROP TABLE batch_table; @@ -3873,6 +4097,16 @@ DROP FOREIGN TABLE ftable; -- SELECT * FROM async_pt t1, async_p2 t2 WHERE t1.a = t2.a AND t1.b === 505; -- SELECT * FROM async_pt t1, async_p2 t2 WHERE t1.a = t2.a AND t1.b === 505; +-- CREATE TABLE local_tbl (a int, b int, c text); +-- INSERT INTO local_tbl VALUES (1505, 505, 'foo'); +-- ANALYZE local_tbl; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM local_tbl t1 LEFT JOIN (SELECT *, (SELECT count(*) FROM async_pt WHERE a < 3000) FROM async_pt WHERE a < 3000) t2 ON t1.a = t2.a; +-- EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +-- SELECT * FROM local_tbl t1 LEFT JOIN (SELECT *, (SELECT count(*) FROM async_pt WHERE a < 3000) FROM async_pt WHERE a < 3000) t2 ON t1.a = t2.a; +-- SELECT * FROM local_tbl t1 LEFT JOIN (SELECT *, (SELECT count(*) FROM async_pt WHERE a < 3000) FROM async_pt WHERE a < 3000) t2 ON t1.a = t2.a; + -- EXPLAIN (VERBOSE, COSTS OFF) -- SELECT * FROM async_pt t1 WHERE t1.b === 505 LIMIT 1; -- EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) @@ -3880,9 +4114,6 @@ DROP FOREIGN TABLE ftable; -- SELECT * FROM async_pt t1 WHERE t1.b === 505 LIMIT 1; -- -- Check with foreign modify --- CREATE TABLE local_tbl (a int, b int, c text); --- INSERT INTO local_tbl VALUES (1505, 505, 'foo'); - -- CREATE TABLE base_tbl3 (a int, b int, c text); -- CREATE FOREIGN TABLE remote_tbl (a int, b int, c text) -- SERVER loopback OPTIONS (table_name 'base_tbl3'); @@ -3943,6 +4174,23 @@ DROP FOREIGN TABLE ftable; -- ALTER SERVER loopback OPTIONS (DROP async_capable); -- ALTER SERVER loopback2 OPTIONS (DROP async_capable); +-- =================================================================== +-- test invalid server and foreign table options +-- =================================================================== +-- -- Invalid fdw_startup_cost option +-- CREATE SERVER inv_scst FOREIGN DATA WRAPPER postgres_fdw +-- OPTIONS(fdw_startup_cost '100$%$#$#'); +-- -- Invalid fdw_tuple_cost option +-- CREATE SERVER inv_scst FOREIGN DATA WRAPPER postgres_fdw +-- OPTIONS(fdw_tuple_cost '100$%$#$#'); +-- -- Invalid fetch_size option +-- CREATE FOREIGN TABLE inv_fsz (c1 int ) +-- SERVER loopback OPTIONS (fetch_size '100$%$#$#'); +-- Invalid batch_size option +--Testcase 954: +CREATE FOREIGN TABLE inv_bsz (c1 int ) + SERVER sqlite_svr OPTIONS (batch_size '100$%$#$#'); + -- Clean-up --Testcase 733: DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr; diff --git a/sql/14beta2/extra/timestamp.sql b/sql/14.0/extra/timestamp.sql similarity index 100% rename from sql/14beta2/extra/timestamp.sql rename to sql/14.0/extra/timestamp.sql diff --git a/sql/14beta2/extra/update.sql b/sql/14.0/extra/update.sql similarity index 100% rename from sql/14beta2/extra/update.sql rename to sql/14.0/extra/update.sql diff --git a/sql/14beta2/selectfunc.sql b/sql/14.0/selectfunc.sql similarity index 100% rename from sql/14beta2/selectfunc.sql rename to sql/14.0/selectfunc.sql diff --git a/sql/14.0/sqlite_fdw.sql b/sql/14.0/sqlite_fdw.sql new file mode 100644 index 00000000..04ffce90 --- /dev/null +++ b/sql/14.0/sqlite_fdw.sql @@ -0,0 +1,602 @@ +--SET log_min_messages TO DEBUG1; +--SET client_min_messages TO DEBUG1; +--Testcase 129: +CREATE EXTENSION sqlite_fdw; +--Testcase 130: +CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw +OPTIONS (database '/tmp/sqlitefdw_test.db'); +--Testcase 131: +CREATE FOREIGN TABLE department(department_id int OPTIONS (key 'true'), department_name text) SERVER sqlite_svr; +--Testcase 132: +CREATE FOREIGN TABLE employee(emp_id int OPTIONS (key 'true'), emp_name text, emp_dept_id int) SERVER sqlite_svr; +--Testcase 133: +CREATE FOREIGN TABLE empdata(emp_id int OPTIONS (key 'true'), emp_dat bytea) SERVER sqlite_svr; +--Testcase 134: +CREATE FOREIGN TABLE numbers(a int OPTIONS (key 'true'), b varchar(255)) SERVER sqlite_svr; +--Testcase 135: +CREATE FOREIGN TABLE multiprimary(a int, b int OPTIONS (key 'true'), c int OPTIONS(key 'true')) SERVER sqlite_svr; +--Testcase 136: +CREATE FOREIGN TABLE noprimary(a int, b text) SERVER sqlite_svr; + +--Testcase 1: +SELECT * FROM department LIMIT 10; +--Testcase 2: +SELECT * FROM employee LIMIT 10; +--Testcase 3: +SELECT * FROM empdata LIMIT 10; + +--Testcase 4: +INSERT INTO department VALUES(generate_series(1,100), 'dept - ' || generate_series(1,100)); +--Testcase 5: +INSERT INTO employee VALUES(generate_series(1,100), 'emp - ' || generate_series(1,100), generate_series(1,100)); +--Testcase 6: +INSERT INTO empdata VALUES(1, decode ('01234567', 'hex')); + +--Testcase 7: +INSERT INTO numbers VALUES(1, 'One'); +--Testcase 8: +INSERT INTO numbers VALUES(2, 'Two'); +--Testcase 9: +INSERT INTO numbers VALUES(3, 'Three'); +--Testcase 10: +INSERT INTO numbers VALUES(4, 'Four'); +--Testcase 11: +INSERT INTO numbers VALUES(5, 'Five'); +--Testcase 12: +INSERT INTO numbers VALUES(6, 'Six'); +--Testcase 13: +INSERT INTO numbers VALUES(7, 'Seven'); +--Testcase 14: +INSERT INTO numbers VALUES(8, 'Eight'); +--Testcase 15: +INSERT INTO numbers VALUES(9, 'Nine'); + +--Testcase 16: +SELECT count(*) FROM department; +--Testcase 17: +SELECT count(*) FROM employee; +--Testcase 18: +SELECT count(*) FROM empdata; + +--Testcase 19: +EXPLAIN (COSTS FALSE) SELECT * FROM department d, employee e WHERE d.department_id = e.emp_dept_id LIMIT 10; + +--Testcase 20: +EXPLAIN (COSTS FALSE) SELECT * FROM department d, employee e WHERE d.department_id IN (SELECT department_id FROM department) LIMIT 10; + +--Testcase 21: +SELECT * FROM department d, employee e WHERE d.department_id = e.emp_dept_id LIMIT 10; +--Testcase 22: +SELECT * FROM department d, employee e WHERE d.department_id IN (SELECT department_id FROM department) ORDER BY d.department_id LIMIT 10; +--Testcase 23: +SELECT * FROM empdata; + +--Testcase 24: +DELETE FROM employee WHERE emp_id = 10; + +--Testcase 25: +SELECT COUNT(*) FROM department LIMIT 10; +--Testcase 26: +SELECT COUNT(*) FROM employee WHERE emp_id = 10; + +--Testcase 27: +UPDATE employee SET emp_name = 'UPDATEd emp' WHERE emp_id = 20; +--Testcase 28: +SELECT emp_id, emp_name FROM employee WHERE emp_name like 'UPDATEd emp'; + +--Testcase 29: +UPDATE empdata SET emp_dat = decode ('0123', 'hex'); +--Testcase 30: +SELECT * FROM empdata; + +--Testcase 31: +SELECT * FROM employee LIMIT 10; +--Testcase 32: +SELECT * FROM employee WHERE emp_id IN (1); +--Testcase 33: +SELECT * FROM employee WHERE emp_id IN (1,3,4,5); +--Testcase 34: +SELECT * FROM employee WHERE emp_id IN (10000,1000); + +--Testcase 35: +SELECT * FROM employee WHERE emp_id NOT IN (1) LIMIT 5; +--Testcase 36: +SELECT * FROM employee WHERE emp_id NOT IN (1,3,4,5) LIMIT 5; +--Testcase 37: +SELECT * FROM employee WHERE emp_id NOT IN (10000,1000) LIMIT 5; + +--Testcase 38: +SELECT * FROM employee WHERE emp_id NOT IN (SELECT emp_id FROM employee WHERE emp_id IN (1,10)); +--Testcase 39: +SELECT * FROM employee WHERE emp_name NOT IN ('emp - 1', 'emp - 2') LIMIT 5; +--Testcase 40: +SELECT * FROM employee WHERE emp_name NOT IN ('emp - 10') LIMIT 5; + +--Testcase 41: +SELECT * FROM numbers WHERE (CASE WHEN a % 2 = 0 THEN 1 WHEN a % 5 = 0 THEN 1 ELSE 0 END) = 1; +--Testcase 42: +SELECT * FROM numbers WHERE (CASE b WHEN 'Two' THEN 1 WHEN 'Six' THEN 1 ELSE 0 END) = 1; + +--Testcase 152: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE (round(abs(a)) = 1); +--Testcase 153: +SELECT * FROM numbers WHERE (round(abs(a)) = 1); + +--Testcase 137: +create or replace function test_param_WHERE() returns void as $$ +DECLARE + n varchar; +BEGIN + FOR x IN 1..9 LOOP +--Testcase 138: + SELECT b INTO n from numbers WHERE a=x; + raise notice 'Found number %', n; + end loop; + return; +END +$$ LANGUAGE plpgsql; +--Testcase 43: +SELECT test_param_WHERE(); + +--Testcase 44: +SELECT b from numbers WHERE a=1; +--Testcase 45: +EXPLAIN(COSTS OFF) SELECT b from numbers WHERE a=1; + +--Testcase 46: +SELECT a FROM numbers WHERE b = (SELECT NULL::text); + + +--Testcase 47: +PREPARE stmt1 (int, int) AS + SELECT * FROM numbers WHERE a=$1 or a=$2; +--Testcase 48: +EXECUTE stmt1(1,2); +--Testcase 49: +EXECUTE stmt1(2,2); +--Testcase 50: +EXECUTE stmt1(3,2); +--Testcase 51: +EXECUTE stmt1(4,2); +-- generic plan +--Testcase 52: +EXECUTE stmt1(5,2); +--Testcase 53: +EXECUTE stmt1(6,2); +--Testcase 54: +EXECUTE stmt1(7,2); + +--Testcase 55: +DELETE FROM employee; +--Testcase 56: +DELETE FROM department; +--Testcase 57: +DELETE FROM empdata; +--Testcase 58: +DELETE FROM numbers; + +BEGIN; +--Testcase 59: +INSERT INTO numbers VALUES(1, 'One'); +--Testcase 60: +INSERT INTO numbers VALUES(2, 'Two'); +COMMIT; + +--Testcase 61: +SELECT * from numbers; + +BEGIN; +--Testcase 62: +INSERT INTO numbers VALUES(3, 'Three'); +ROLLBACK; +--Testcase 63: +SELECT * from numbers; + +BEGIN; +--Testcase 64: +INSERT INTO numbers VALUES(4, 'Four'); +SAVEPOINT my_savepoint; +--Testcase 65: +INSERT INTO numbers VALUES(5, 'Five'); +ROLLBACK TO SAVEPOINT my_savepoint; +--Testcase 66: +INSERT INTO numbers VALUES(6, 'Six'); +COMMIT; + +--Testcase 67: +SELECT * from numbers; + +-- duplicate key +--Testcase 68: +INSERT INTO numbers VALUES(1, 'One'); +--Testcase 69: +DELETE from numbers; + +BEGIN; +--Testcase 70: +INSERT INTO numbers VALUES(1, 'One'); +--Testcase 71: +INSERT INTO numbers VALUES(2, 'Two'); +COMMIT; +-- violate unique constraint +--Testcase 72: +UPDATE numbers SET b='Two' WHERE a = 1; +--Testcase 73: +SELECT * from numbers; + +-- push down +--Testcase 74: +explain (verbose, costs off) SELECT * from numbers WHERE a = any(ARRAY[2,3,4,5]::int[]); +-- (1,2,3) is pushed down +--Testcase 75: +explain (verbose, costs off) SELECT * from numbers WHERE a in (1,2,3) AND (1,2) < (a,5); + +--Testcase 76: +explain (verbose, costs off) SELECT * from numbers WHERE a in (a+2*a,5); + +--Testcase 77: +explain (verbose, costs off) SELECT * from numbers WHERE a = any(ARRAY[1,2,a]::int[]); + +--Testcase 78: +SELECT * from numbers WHERE a = any(ARRAY[2,3,4,5]::int[]); +--Testcase 79: +SELECT * from numbers WHERE a = any(ARRAY[1,2,a]::int[]); + +-- ANY with ARRAY expression +--Testcase 154: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY(ARRAY[1, a + 1]); +--Testcase 155: +SELECT * FROM numbers WHERE a = ANY(ARRAY[1, a + 1]); + +--Testcase 156: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, a + 1]); +--Testcase 157: +SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, a + 1]); + +--Testcase 158: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, a + 1]); +--Testcase 159: +SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, a + 1]); + +--Testcase 160: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, a + 1]); +--Testcase 161: +SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, a + 1]); + +--Testcase 162: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ANY(ARRAY[1, a + 1]); +--Testcase 163: +SELECT * FROM numbers WHERE a > ANY(ARRAY[1, a + 1]); + +--Testcase 164: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ANY(ARRAY[1, a + 1]); +--Testcase 165: +SELECT * FROM numbers WHERE a < ANY(ARRAY[1, a + 1]); + +-- ANY with ARRAY const +--Testcase 166: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY(ARRAY[1, 2]); +--Testcase 167: +SELECT * FROM numbers WHERE a = ANY(ARRAY[1, 2]); + +--Testcase 168: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, 2]); +--Testcase 169: +SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, 2]); + +--Testcase 170: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, 2]); +--Testcase 171: +SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, 2]); + +--Testcase 172: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, 2]); +--Testcase 173: +SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, 2]); + +--Testcase 174: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ANY(ARRAY[1, 2]); +--Testcase 175: +SELECT * FROM numbers WHERE a > ANY(ARRAY[1, 2]); + +--Testcase 176: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ANY(ARRAY[1, 2]); +--Testcase 177: +SELECT * FROM numbers WHERE a < ANY(ARRAY[1, 2]); + +--Testcase 210: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY('{1, 2, 3}'); +--Testcase 211: +SELECT * FROM numbers WHERE a = ANY('{1, 2, 3}'); + +--Testcase 212: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY('{1, 2, 3}'); +--Testcase 213: +SELECT * FROM numbers WHERE a <> ANY('{1, 2, 3}'); + +-- ALL with ARRAY expression +--Testcase 178: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ALL(ARRAY[1, a * 1]); +--Testcase 179: +SELECT * FROM numbers WHERE a = ALL(ARRAY[1, a * 1]); + +--Testcase 180: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, a + 1]); +--Testcase 181: +SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, a + 1]); + +--Testcase 182: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, a / 1]); +--Testcase 183: +SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, a / 1]); + +--Testcase 184: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, a + 1]); +--Testcase 185: +SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, a + 1]); + +--Testcase 186: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ALL(ARRAY[1, a - 1]); +--Testcase 187: +SELECT * FROM numbers WHERE a > ALL(ARRAY[1, a - 1]); + +--Testcase 188: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ALL(ARRAY[2, a + 1]); +--Testcase 189: +SELECT * FROM numbers WHERE a < ALL(ARRAY[2, a + 1]); + +-- ALL with ARRAY const +--Testcase 190: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ALL(ARRAY[1, 1]); +--Testcase 191: +SELECT * FROM numbers WHERE a = ALL(ARRAY[1, 1]); + +--Testcase 192: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, 3]); +--Testcase 193: +SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, 3]); + +--Testcase 194: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, 2]); +--Testcase 195: +SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, 2]); + +--Testcase 196: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, 2]); +--Testcase 197: +SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, 2]); + +--Testcase 198: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ALL(ARRAY[0, 1]); +--Testcase 199: +SELECT * FROM numbers WHERE a > ALL(ARRAY[0, 1]); + +--Testcase 200: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ALL(ARRAY[2, 3]); +--Testcase 201: +SELECT * FROM numbers WHERE a < ALL(ARRAY[2, 3]); + +-- ANY/ALL with TEXT ARRAY const +--Testcase 202: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE b = ANY(ARRAY['One', 'Two']); +--Testcase 203: +SELECT * FROM numbers WHERE b = ANY(ARRAY['One', 'Two']); + +--Testcase 204: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE b <> ALL(ARRAY['One', 'Four']); +--Testcase 205: +SELECT * FROM numbers WHERE b <> ALL(ARRAY['One', 'Four']); + +--Testcase 206: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE b > ANY(ARRAY['One', 'Two']); +--Testcase 207: +SELECT * FROM numbers WHERE b > ANY(ARRAY['One', 'Two']); + +--Testcase 208: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE b > ALL(ARRAY['Four', 'Five']); +--Testcase 209: +SELECT * FROM numbers WHERE b > ALL(ARRAY['Four', 'Five']); + +--Testcase 80: +INSERT INTO multiprimary VALUES(1,2,3); +--Testcase 81: +INSERT INTO multiprimary VALUES(1,2,4); +--Testcase 82: +UPDATE multiprimary SET b = 10 WHERE c = 3; +--Testcase 83: +SELECT * from multiprimary; +--Testcase 84: +UPDATE multiprimary SET a = 10 WHERE a = 1; +--Testcase 85: +SELECT * from multiprimary; +--Testcase 86: +UPDATE multiprimary SET a = 100, b=200, c=300 WHERE a=10 AND b=10; +--Testcase 87: +SELECT * from multiprimary; +--Testcase 88: +UPDATE multiprimary SET a = 1234; +--Testcase 89: +SELECT * from multiprimary; +--Testcase 90: +UPDATE multiprimary SET a = a+1, b=b+1 WHERE b=200 AND c=300; + +--Testcase 91: +SELECT * from multiprimary; +--Testcase 92: +DELETE from multiprimary WHERE a = 1235; +--Testcase 93: +SELECT * from multiprimary; +--Testcase 94: +DELETE from multiprimary WHERE b = 2; +--Testcase 95: +SELECT * from multiprimary; + +--Testcase 96: +INSERT INTO multiprimary VALUES(1,2,3); +--Testcase 97: +INSERT INTO multiprimary VALUES(1,2,4); +--Testcase 98: +INSERT INTO multiprimary VALUES(1,10,20); +--Testcase 99: +INSERT INTO multiprimary VALUES(2,20,40); + + + +--Testcase 100: +SELECT count(distinct a) from multiprimary; +--Testcase 101: +SELECT sum(b),max(b), min(b) from multiprimary; +--Testcase 102: +SELECT sum(b+5)+2 from multiprimary group by b/2 order by b/2; +--Testcase 103: +SELECT sum(a) from multiprimary group by b having sum(a) > 0 order by sum(a); +--Testcase 104: +SELECT sum(a) A from multiprimary group by b having avg(abs(a)) > 0 AND sum(a) > 0 order by A; +--Testcase 105: +SELECT count(nullif(a, 1)) FROM multiprimary; +--Testcase 106: +SELECT a,a FROM multiprimary group by 1,2; +--Testcase 107: +SELECT * from multiprimary, numbers WHERE multiprimary.a=numbers.a; + +--Testcase 108: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT sum(a) FROM multiprimary HAVING sum(a) > 0; +--Testcase 109: +SELECT sum(a) FROM multiprimary HAVING sum(a) > 0; + +--Testcase 110: +INSERT INTO numbers VALUES(4, 'Four'); + +-- All where clauses are pushed down +--Testcase 111: +SELECT * FROM numbers WHERE abs(a) = 4 AND upper(b) = 'FOUR' AND lower(b) = 'four'; +--Testcase 112: +EXPLAIN (verbose, costs off) SELECT b, length(b) FROM numbers WHERE abs(a) = 4 AND upper(b) = 'FOUR' AND lower(b) = 'four'; + +-- Only "length(b) = 4" are pushed down +--Testcase 113: +SELECT b, length(b) FROM numbers WHERE length(b) = 4 AND power(1, a) != 0 AND length(reverse(b)) = 4; +--Testcase 114: +EXPLAIN (verbose, costs off) SELECT b, length(b) FROM numbers WHERE length(b) = 4 AND power(1, a) != 0 AND length(reverse(b)) = 4; + +--Testcase 115: +INSERT INTO multiprimary (b,c) VALUES (99, 100); +--Testcase 116: +SELECT c FROM multiprimary WHERE COALESCE(a,b,c) = 99; + + +--Testcase 139: +CREATE FOREIGN TABLE multiprimary2(a int, b int, c int OPTIONS(column_name 'b')) SERVER sqlite_svr OPTIONS (table 'multiprimary'); +--Testcase 117: +SELECT * FROM multiprimary2; +--Testcase 214: +ALTER FOREIGN TABLE multiprimary2 ALTER COLUMN a OPTIONS(ADD column_name 'b'); +--Testcase 118: +SELECT * FROM multiprimary2; +--Testcase 215: +ALTER FOREIGN TABLE multiprimary2 ALTER COLUMN b OPTIONS (column_name 'nosuch column'); +--Testcase 119: +SELECT * FROM multiprimary2; +--Testcase 140: +EXPLAIN (VERBOSE) SELECT * FROM multiprimary2; +--Testcase 120: +SELECT a FROM multiprimary2 WHERE b = 1; + + +--Testcase 141: +CREATE FOREIGN TABLE columntest(a int OPTIONS(column_name 'a a', key 'true'), "b b" int OPTIONS(key 'true'), c int OPTIONS(column_name 'c c')) SERVER sqlite_svr; +--Testcase 121: +INSERT INTO columntest VALUES(1,2,3); +--Testcase 122: +UPDATE columntest SET c=10 WHERE a = 1; +--Testcase 123: +SELECT * FROM columntest; +--Testcase 124: +UPDATE columntest SET a=100 WHERE c = 10; +--Testcase 125: +SELECT * FROM columntest; +--Testcase 126: +INSERT INTO noprimary VALUES(1,'2'); +--Testcase 127: +INSERT INTO noprimary SELECT * FROM noprimary; +--Testcase 128: +SELECT * FROM noprimary; + +--get version +--Testcase 153: +\df sqlite* +--Testcase 154: +SELECT * FROM public.sqlite_fdw_version(); +--Testcase 155: +SELECT sqlite_fdw_version(); + +-- issue #44 github +--Testcase 156: +CREATE FOREIGN TABLE fts_table (name text, description text) SERVER sqlite_svr; + +--Testcase 157: +INSERT INTO fts_table VALUES ('this is name', 'this is description'); + +--Testcase 158: +SELECT * FROM fts_table; -- should work + +--Testcase 159: +ALTER TABLE fts_table ALTER COLUMN name TYPE int; + +--Testcase 160: +SELECT * FROM fts_table; -- should fail + +-- INSERT/UPDATE whole row with generated column +--Testcase 216: +CREATE FOREIGN TABLE grem1_1 ( + a int generated always as (0) stored) + SERVER sqlite_svr OPTIONS(table 'grem1_1'); + +--Testcase 217: +INSERT INTO grem1_1 DEFAULT VALUES; +--Testcase 218: +SELECT * FROM grem1_1; + +--Testcase 219: +CREATE FOREIGN TABLE grem1_2 ( + a int generated always as (0) stored, + b int generated always as (1) stored, + c int generated always as (2) stored, + d int generated always as (3) stored) + SERVER sqlite_svr OPTIONS(table 'grem1_2'); +--Testcase 220: +INSERT INTO grem1_2 DEFAULT VALUES; +--Testcase 221: +SELECT * FROM grem1_2; + +--Testcase 142: +DROP FUNCTION test_param_WHERE(); +--Testcase 143: +DROP FOREIGN TABLE numbers; +--Testcase 144: +DROP FOREIGN TABLE department; +--Testcase 145: +DROP FOREIGN TABLE employee; +--Testcase 146: +DROP FOREIGN TABLE empdata; +--Testcase 147: +DROP FOREIGN TABLE multiprimary; +--Testcase 148: +DROP FOREIGN TABLE multiprimary2; +--Testcase 149: +DROP FOREIGN TABLE columntest; +--Testcase 150: +DROP FOREIGN TABLE noprimary; +--Testcase 161: +DROP FOREIGN TABLE fts_table; +--Testcase 222: +DROP FOREIGN TABLE grem1_1; +--Testcase 223: +DROP FOREIGN TABLE grem1_2; + +--Testcase 151: +DROP SERVER sqlite_svr; +--Testcase 152: +DROP EXTENSION sqlite_fdw CASCADE; + diff --git a/sql/14beta2/type.sql b/sql/14.0/type.sql similarity index 100% rename from sql/14beta2/type.sql rename to sql/14.0/type.sql diff --git a/sql/14beta2/sqlite_fdw.sql b/sql/14beta2/sqlite_fdw.sql deleted file mode 100644 index 6b8e0f44..00000000 --- a/sql/14beta2/sqlite_fdw.sql +++ /dev/null @@ -1,555 +0,0 @@ ---SET log_min_messages TO DEBUG1; ---SET client_min_messages TO DEBUG1; ---Testcase 129: -CREATE EXTENSION sqlite_fdw; ---Testcase 130: -CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw -OPTIONS (database '/tmp/sqlitefdw_test.db'); ---Testcase 131: -CREATE FOREIGN TABLE department(department_id int OPTIONS (key 'true'), department_name text) SERVER sqlite_svr; ---Testcase 132: -CREATE FOREIGN TABLE employee(emp_id int OPTIONS (key 'true'), emp_name text, emp_dept_id int) SERVER sqlite_svr; ---Testcase 133: -CREATE FOREIGN TABLE empdata(emp_id int OPTIONS (key 'true'), emp_dat bytea) SERVER sqlite_svr; ---Testcase 134: -CREATE FOREIGN TABLE numbers(a int OPTIONS (key 'true'), b varchar(255)) SERVER sqlite_svr; ---Testcase 135: -CREATE FOREIGN TABLE multiprimary(a int, b int OPTIONS (key 'true'), c int OPTIONS(key 'true')) SERVER sqlite_svr; ---Testcase 136: -CREATE FOREIGN TABLE noprimary(a int, b text) SERVER sqlite_svr; - ---Testcase 1: -SELECT * FROM department LIMIT 10; ---Testcase 2: -SELECT * FROM employee LIMIT 10; ---Testcase 3: -SELECT * FROM empdata LIMIT 10; - ---Testcase 4: -INSERT INTO department VALUES(generate_series(1,100), 'dept - ' || generate_series(1,100)); ---Testcase 5: -INSERT INTO employee VALUES(generate_series(1,100), 'emp - ' || generate_series(1,100), generate_series(1,100)); ---Testcase 6: -INSERT INTO empdata VALUES(1, decode ('01234567', 'hex')); - ---Testcase 7: -INSERT INTO numbers VALUES(1, 'One'); ---Testcase 8: -INSERT INTO numbers VALUES(2, 'Two'); ---Testcase 9: -INSERT INTO numbers VALUES(3, 'Three'); ---Testcase 10: -INSERT INTO numbers VALUES(4, 'Four'); ---Testcase 11: -INSERT INTO numbers VALUES(5, 'Five'); ---Testcase 12: -INSERT INTO numbers VALUES(6, 'Six'); ---Testcase 13: -INSERT INTO numbers VALUES(7, 'Seven'); ---Testcase 14: -INSERT INTO numbers VALUES(8, 'Eight'); ---Testcase 15: -INSERT INTO numbers VALUES(9, 'Nine'); - ---Testcase 16: -SELECT count(*) FROM department; ---Testcase 17: -SELECT count(*) FROM employee; ---Testcase 18: -SELECT count(*) FROM empdata; - ---Testcase 19: -EXPLAIN (COSTS FALSE) SELECT * FROM department d, employee e WHERE d.department_id = e.emp_dept_id LIMIT 10; - ---Testcase 20: -EXPLAIN (COSTS FALSE) SELECT * FROM department d, employee e WHERE d.department_id IN (SELECT department_id FROM department) LIMIT 10; - ---Testcase 21: -SELECT * FROM department d, employee e WHERE d.department_id = e.emp_dept_id LIMIT 10; ---Testcase 22: -SELECT * FROM department d, employee e WHERE d.department_id IN (SELECT department_id FROM department) ORDER BY d.department_id LIMIT 10; ---Testcase 23: -SELECT * FROM empdata; - ---Testcase 24: -DELETE FROM employee WHERE emp_id = 10; - ---Testcase 25: -SELECT COUNT(*) FROM department LIMIT 10; ---Testcase 26: -SELECT COUNT(*) FROM employee WHERE emp_id = 10; - ---Testcase 27: -UPDATE employee SET emp_name = 'UPDATEd emp' WHERE emp_id = 20; ---Testcase 28: -SELECT emp_id, emp_name FROM employee WHERE emp_name like 'UPDATEd emp'; - ---Testcase 29: -UPDATE empdata SET emp_dat = decode ('0123', 'hex'); ---Testcase 30: -SELECT * FROM empdata; - ---Testcase 31: -SELECT * FROM employee LIMIT 10; ---Testcase 32: -SELECT * FROM employee WHERE emp_id IN (1); ---Testcase 33: -SELECT * FROM employee WHERE emp_id IN (1,3,4,5); ---Testcase 34: -SELECT * FROM employee WHERE emp_id IN (10000,1000); - ---Testcase 35: -SELECT * FROM employee WHERE emp_id NOT IN (1) LIMIT 5; ---Testcase 36: -SELECT * FROM employee WHERE emp_id NOT IN (1,3,4,5) LIMIT 5; ---Testcase 37: -SELECT * FROM employee WHERE emp_id NOT IN (10000,1000) LIMIT 5; - ---Testcase 38: -SELECT * FROM employee WHERE emp_id NOT IN (SELECT emp_id FROM employee WHERE emp_id IN (1,10)); ---Testcase 39: -SELECT * FROM employee WHERE emp_name NOT IN ('emp - 1', 'emp - 2') LIMIT 5; ---Testcase 40: -SELECT * FROM employee WHERE emp_name NOT IN ('emp - 10') LIMIT 5; - ---Testcase 41: -SELECT * FROM numbers WHERE (CASE WHEN a % 2 = 0 THEN 1 WHEN a % 5 = 0 THEN 1 ELSE 0 END) = 1; ---Testcase 42: -SELECT * FROM numbers WHERE (CASE b WHEN 'Two' THEN 1 WHEN 'Six' THEN 1 ELSE 0 END) = 1; - ---Testcase 152: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE (round(abs(a)) = 1); ---Testcase 153: -SELECT * FROM numbers WHERE (round(abs(a)) = 1); - ---Testcase 137: -create or replace function test_param_WHERE() returns void as $$ -DECLARE - n varchar; -BEGIN - FOR x IN 1..9 LOOP ---Testcase 138: - SELECT b INTO n from numbers WHERE a=x; - raise notice 'Found number %', n; - end loop; - return; -END -$$ LANGUAGE plpgsql; ---Testcase 43: -SELECT test_param_WHERE(); - ---Testcase 44: -SELECT b from numbers WHERE a=1; ---Testcase 45: -EXPLAIN(COSTS OFF) SELECT b from numbers WHERE a=1; - ---Testcase 46: -SELECT a FROM numbers WHERE b = (SELECT NULL::text); - - ---Testcase 47: -PREPARE stmt1 (int, int) AS - SELECT * FROM numbers WHERE a=$1 or a=$2; ---Testcase 48: -EXECUTE stmt1(1,2); ---Testcase 49: -EXECUTE stmt1(2,2); ---Testcase 50: -EXECUTE stmt1(3,2); ---Testcase 51: -EXECUTE stmt1(4,2); --- generic plan ---Testcase 52: -EXECUTE stmt1(5,2); ---Testcase 53: -EXECUTE stmt1(6,2); ---Testcase 54: -EXECUTE stmt1(7,2); - ---Testcase 55: -DELETE FROM employee; ---Testcase 56: -DELETE FROM department; ---Testcase 57: -DELETE FROM empdata; ---Testcase 58: -DELETE FROM numbers; - -BEGIN; ---Testcase 59: -INSERT INTO numbers VALUES(1, 'One'); ---Testcase 60: -INSERT INTO numbers VALUES(2, 'Two'); -COMMIT; - ---Testcase 61: -SELECT * from numbers; - -BEGIN; ---Testcase 62: -INSERT INTO numbers VALUES(3, 'Three'); -ROLLBACK; ---Testcase 63: -SELECT * from numbers; - -BEGIN; ---Testcase 64: -INSERT INTO numbers VALUES(4, 'Four'); -SAVEPOINT my_savepoint; ---Testcase 65: -INSERT INTO numbers VALUES(5, 'Five'); -ROLLBACK TO SAVEPOINT my_savepoint; ---Testcase 66: -INSERT INTO numbers VALUES(6, 'Six'); -COMMIT; - ---Testcase 67: -SELECT * from numbers; - --- duplicate key ---Testcase 68: -INSERT INTO numbers VALUES(1, 'One'); ---Testcase 69: -DELETE from numbers; - -BEGIN; ---Testcase 70: -INSERT INTO numbers VALUES(1, 'One'); ---Testcase 71: -INSERT INTO numbers VALUES(2, 'Two'); -COMMIT; --- violate unique constraint ---Testcase 72: -UPDATE numbers SET b='Two' WHERE a = 1; ---Testcase 73: -SELECT * from numbers; - --- push down ---Testcase 74: -explain (verbose, costs off) SELECT * from numbers WHERE a = any(ARRAY[2,3,4,5]::int[]); --- (1,2,3) is pushed down ---Testcase 75: -explain (verbose, costs off) SELECT * from numbers WHERE a in (1,2,3) AND (1,2) < (a,5); - ---Testcase 76: -explain (verbose, costs off) SELECT * from numbers WHERE a in (a+2*a,5); - ---Testcase 77: -explain (verbose, costs off) SELECT * from numbers WHERE a = any(ARRAY[1,2,a]::int[]); - ---Testcase 78: -SELECT * from numbers WHERE a = any(ARRAY[2,3,4,5]::int[]); ---Testcase 79: -SELECT * from numbers WHERE a = any(ARRAY[1,2,a]::int[]); - --- ANY with ARRAY expression ---Testcase 154: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY(ARRAY[1, a + 1]); ---Testcase 155: -SELECT * FROM numbers WHERE a = ANY(ARRAY[1, a + 1]); - ---Testcase 156: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, a + 1]); ---Testcase 157: -SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, a + 1]); - ---Testcase 158: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, a + 1]); ---Testcase 159: -SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, a + 1]); - ---Testcase 160: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, a + 1]); ---Testcase 161: -SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, a + 1]); - ---Testcase 162: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ANY(ARRAY[1, a + 1]); ---Testcase 163: -SELECT * FROM numbers WHERE a > ANY(ARRAY[1, a + 1]); - ---Testcase 164: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ANY(ARRAY[1, a + 1]); ---Testcase 165: -SELECT * FROM numbers WHERE a < ANY(ARRAY[1, a + 1]); - --- ANY with ARRAY const ---Testcase 166: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY(ARRAY[1, 2]); ---Testcase 167: -SELECT * FROM numbers WHERE a = ANY(ARRAY[1, 2]); - ---Testcase 168: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, 2]); ---Testcase 169: -SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, 2]); - ---Testcase 170: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, 2]); ---Testcase 171: -SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, 2]); - ---Testcase 172: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, 2]); ---Testcase 173: -SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, 2]); - ---Testcase 174: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ANY(ARRAY[1, 2]); ---Testcase 175: -SELECT * FROM numbers WHERE a > ANY(ARRAY[1, 2]); - ---Testcase 176: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ANY(ARRAY[1, 2]); ---Testcase 177: -SELECT * FROM numbers WHERE a < ANY(ARRAY[1, 2]); - ---Testcase 210: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY('{1, 2, 3}'); ---Testcase 211: -SELECT * FROM numbers WHERE a = ANY('{1, 2, 3}'); - ---Testcase 212: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY('{1, 2, 3}'); ---Testcase 213: -SELECT * FROM numbers WHERE a <> ANY('{1, 2, 3}'); - --- ALL with ARRAY expression ---Testcase 178: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ALL(ARRAY[1, a * 1]); ---Testcase 179: -SELECT * FROM numbers WHERE a = ALL(ARRAY[1, a * 1]); - ---Testcase 180: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, a + 1]); ---Testcase 181: -SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, a + 1]); - ---Testcase 182: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, a / 1]); ---Testcase 183: -SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, a / 1]); - ---Testcase 184: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, a + 1]); ---Testcase 185: -SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, a + 1]); - ---Testcase 186: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ALL(ARRAY[1, a - 1]); ---Testcase 187: -SELECT * FROM numbers WHERE a > ALL(ARRAY[1, a - 1]); - ---Testcase 188: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ALL(ARRAY[2, a + 1]); ---Testcase 189: -SELECT * FROM numbers WHERE a < ALL(ARRAY[2, a + 1]); - --- ALL with ARRAY const ---Testcase 190: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ALL(ARRAY[1, 1]); ---Testcase 191: -SELECT * FROM numbers WHERE a = ALL(ARRAY[1, 1]); - ---Testcase 192: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, 3]); ---Testcase 193: -SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, 3]); - ---Testcase 194: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, 2]); ---Testcase 195: -SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, 2]); - ---Testcase 196: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, 2]); ---Testcase 197: -SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, 2]); - ---Testcase 198: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ALL(ARRAY[0, 1]); ---Testcase 199: -SELECT * FROM numbers WHERE a > ALL(ARRAY[0, 1]); - ---Testcase 200: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ALL(ARRAY[2, 3]); ---Testcase 201: -SELECT * FROM numbers WHERE a < ALL(ARRAY[2, 3]); - --- ANY/ALL with TEXT ARRAY const ---Testcase 202: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE b = ANY(ARRAY['One', 'Two']); ---Testcase 203: -SELECT * FROM numbers WHERE b = ANY(ARRAY['One', 'Two']); - ---Testcase 204: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE b <> ALL(ARRAY['One', 'Four']); ---Testcase 205: -SELECT * FROM numbers WHERE b <> ALL(ARRAY['One', 'Four']); - ---Testcase 206: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE b > ANY(ARRAY['One', 'Two']); ---Testcase 207: -SELECT * FROM numbers WHERE b > ANY(ARRAY['One', 'Two']); - ---Testcase 208: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE b > ALL(ARRAY['Four', 'Five']); ---Testcase 209: -SELECT * FROM numbers WHERE b > ALL(ARRAY['Four', 'Five']); - ---Testcase 80: -INSERT INTO multiprimary VALUES(1,2,3); ---Testcase 81: -INSERT INTO multiprimary VALUES(1,2,4); ---Testcase 82: -UPDATE multiprimary SET b = 10 WHERE c = 3; ---Testcase 83: -SELECT * from multiprimary; ---Testcase 84: -UPDATE multiprimary SET a = 10 WHERE a = 1; ---Testcase 85: -SELECT * from multiprimary; ---Testcase 86: -UPDATE multiprimary SET a = 100, b=200, c=300 WHERE a=10 AND b=10; ---Testcase 87: -SELECT * from multiprimary; ---Testcase 88: -UPDATE multiprimary SET a = 1234; ---Testcase 89: -SELECT * from multiprimary; ---Testcase 90: -UPDATE multiprimary SET a = a+1, b=b+1 WHERE b=200 AND c=300; - ---Testcase 91: -SELECT * from multiprimary; ---Testcase 92: -DELETE from multiprimary WHERE a = 1235; ---Testcase 93: -SELECT * from multiprimary; ---Testcase 94: -DELETE from multiprimary WHERE b = 2; ---Testcase 95: -SELECT * from multiprimary; - ---Testcase 96: -INSERT INTO multiprimary VALUES(1,2,3); ---Testcase 97: -INSERT INTO multiprimary VALUES(1,2,4); ---Testcase 98: -INSERT INTO multiprimary VALUES(1,10,20); ---Testcase 99: -INSERT INTO multiprimary VALUES(2,20,40); - - - ---Testcase 100: -SELECT count(distinct a) from multiprimary; ---Testcase 101: -SELECT sum(b),max(b), min(b) from multiprimary; ---Testcase 102: -SELECT sum(b+5)+2 from multiprimary group by b/2 order by b/2; ---Testcase 103: -SELECT sum(a) from multiprimary group by b having sum(a) > 0 order by sum(a); ---Testcase 104: -SELECT sum(a) A from multiprimary group by b having avg(abs(a)) > 0 AND sum(a) > 0 order by A; ---Testcase 105: -SELECT count(nullif(a, 1)) FROM multiprimary; ---Testcase 106: -SELECT a,a FROM multiprimary group by 1,2; ---Testcase 107: -SELECT * from multiprimary, numbers WHERE multiprimary.a=numbers.a; - ---Testcase 108: -EXPLAIN (VERBOSE, COSTS OFF) -SELECT sum(a) FROM multiprimary HAVING sum(a) > 0; ---Testcase 109: -SELECT sum(a) FROM multiprimary HAVING sum(a) > 0; - ---Testcase 110: -INSERT INTO numbers VALUES(4, 'Four'); - --- All where clauses are pushed down ---Testcase 111: -SELECT * FROM numbers WHERE abs(a) = 4 AND upper(b) = 'FOUR' AND lower(b) = 'four'; ---Testcase 112: -EXPLAIN (verbose, costs off) SELECT b, length(b) FROM numbers WHERE abs(a) = 4 AND upper(b) = 'FOUR' AND lower(b) = 'four'; - --- Only "length(b) = 4" are pushed down ---Testcase 113: -SELECT b, length(b) FROM numbers WHERE length(b) = 4 AND power(1, a) != 0 AND length(reverse(b)) = 4; ---Testcase 114: -EXPLAIN (verbose, costs off) SELECT b, length(b) FROM numbers WHERE length(b) = 4 AND power(1, a) != 0 AND length(reverse(b)) = 4; - ---Testcase 115: -INSERT INTO multiprimary (b,c) VALUES (99, 100); ---Testcase 116: -SELECT c FROM multiprimary WHERE COALESCE(a,b,c) = 99; - - ---Testcase 139: -CREATE FOREIGN TABLE multiprimary2(a int, b int, c int OPTIONS(column_name 'b')) SERVER sqlite_svr OPTIONS (table 'multiprimary'); ---Testcase 117: -SELECT * FROM multiprimary2; -ALTER FOREIGN TABLE multiprimary2 ALTER COLUMN a OPTIONS(ADD column_name 'b'); ---Testcase 118: -SELECT * FROM multiprimary2; -ALTER FOREIGN TABLE multiprimary2 ALTER COLUMN b OPTIONS (column_name 'nosuch column'); ---Testcase 119: -SELECT * FROM multiprimary2; ---Testcase 140: -EXPLAIN (VERBOSE) SELECT * FROM multiprimary2; ---Testcase 120: -SELECT a FROM multiprimary2 WHERE b = 1; - - ---Testcase 141: -CREATE FOREIGN TABLE columntest(a int OPTIONS(column_name 'a a', key 'true'), "b b" int OPTIONS(key 'true'), c int OPTIONS(column_name 'c c')) SERVER sqlite_svr; ---Testcase 121: -INSERT INTO columntest VALUES(1,2,3); ---Testcase 122: -UPDATE columntest SET c=10 WHERE a = 1; ---Testcase 123: -SELECT * FROM columntest; ---Testcase 124: -UPDATE columntest SET a=100 WHERE c = 10; ---Testcase 125: -SELECT * FROM columntest; ---Testcase 126: -INSERT INTO noprimary VALUES(1,'2'); ---Testcase 127: -INSERT INTO noprimary SELECT * FROM noprimary; ---Testcase 128: -SELECT * FROM noprimary; - ---get version ---Testcase 153: -\df sqlite* ---Testcase 154: -SELECT * FROM public.sqlite_fdw_version(); ---Testcase 155: -SELECT sqlite_fdw_version(); - ---Testcase 142: -DROP FUNCTION test_param_WHERE(); ---Testcase 143: -DROP FOREIGN TABLE numbers; ---Testcase 144: -DROP FOREIGN TABLE department; ---Testcase 145: -DROP FOREIGN TABLE employee; ---Testcase 146: -DROP FOREIGN TABLE empdata; ---Testcase 147: -DROP FOREIGN TABLE multiprimary; ---Testcase 148: -DROP FOREIGN TABLE multiprimary2; ---Testcase 149: -DROP FOREIGN TABLE columntest; ---Testcase 150: -DROP FOREIGN TABLE noprimary; - ---Testcase 151: -DROP SERVER sqlite_svr; ---Testcase 152: -DROP EXTENSION sqlite_fdw CASCADE; - diff --git a/sql/init_data/init.sql b/sql/init_data/init.sql index 7ffb639c..3f969840 100644 --- a/sql/init_data/init.sql +++ b/sql/init_data/init.sql @@ -4,6 +4,9 @@ DROP TABLE IF EXISTS employee; DROP TABLE IF EXISTS empdata; DROP TABLE IF EXISTS numbers; DROP TABLE IF EXISTS limittest; +DROP TABLE IF EXISTS grem1_1; +DROP TABLE IF EXISTS grem1_2; + CREATE TABLE department(department_id int primary key, department_name text); CREATE TABLE employee(emp_id int primary key, emp_name text, emp_dept_id int); CREATE TABLE empdata(emp_id int primary key, emp_dat bytea); @@ -13,6 +16,8 @@ CREATE TABLE multiprimary(a integer, b integer, c integer, primary key(b,c)); CREATE TABLE columntest("a a" integer, "b b" integer,"c c" integer, primary key("a a","b b") ); CREATE TABLE noprimary(a integer, b text); CREATE TABLE limittest(id int primary key, x integer, y text); +create table grem1_1 (a int primary key, b int generated always as (a * 2) stored); +create table grem1_2 (a int primary key, b int generated always as (a * 2) stored, c int generated always as (a * 3) stored, d int generated always as (a * 4) stored); CREATE TABLE "type_STRING" (col text primary key); CREATE TABLE "type_BOOLEAN" (col boolean primary key); @@ -41,4 +46,7 @@ CREATE TABLE shorty ( CREATE TABLE "A a" (col int primary key); +-- test for issue #44 github +CREATE VIRTUAL TABLE fts_table USING fts5(name, description, tokenize = porter); + analyze; diff --git a/sql/init_data/init_post.sql b/sql/init_data/init_post.sql index 9b96a685..8825ca7c 100644 --- a/sql/init_data/init_post.sql +++ b/sql/init_data/init_post.sql @@ -8,6 +8,7 @@ DROP TABLE IF EXISTS local_tbl; DROP TABLE IF EXISTS ft3; DROP TABLE IF EXISTS foreign_tbl; DROP TABLE IF EXISTS grem1; +DROP TABLE IF EXISTS grem1_post14; DROP TABLE IF EXISTS loc1; DROP TABLE IF EXISTS loct; DROP TABLE IF EXISTS loct1; @@ -83,6 +84,7 @@ create table ft3 (f1 text, f2 text, f3 text, primary key (f1, f2, f3)); create table foreign_tbl (a int primary key, b int); create table grem1 (a int primary key, b int); +create table grem1_post14 (a int primary key, b int generated always as (a * 2) stored); CREATE TABLE t1_constraint ( c1 int primary key, diff --git a/sqlite_fdw.c b/sqlite_fdw.c index d98c5ae6..bbfe1ed0 100644 --- a/sqlite_fdw.c +++ b/sqlite_fdw.c @@ -304,7 +304,11 @@ static void #endif ); -static void sqlite_prepare_wrapper(sqlite3 * db, char *query, sqlite3_stmt * *result, const char **pzTail); +static void sqlite_prepare_wrapper(ForeignServer *server, + sqlite3 * db, char *query, + sqlite3_stmt * *result, + const char **pzTail, + bool is_cache); static void sqlite_to_pg_type(StringInfo str, char *typname); static TupleTableSlot **sqlite_execute_insert(EState *estate, @@ -484,8 +488,8 @@ sqlite_fdw_version(PG_FUNCTION_ARGS) /* Wrapper for sqlite3_prepare */ static void -sqlite_prepare_wrapper(sqlite3 * db, char *query, sqlite3_stmt * *stmt, - const char **pzTail) +sqlite_prepare_wrapper(ForeignServer *server, sqlite3 * db, char *query, sqlite3_stmt * *stmt, + const char **pzTail, bool is_cache) { int rc; @@ -498,6 +502,9 @@ sqlite_prepare_wrapper(sqlite3 * db, char *query, sqlite3_stmt * *stmt, errmsg("SQL error during prepare: %s %s", sqlite3_errmsg(db), query) )); } + /* cache stmt to finalize at last */ + if (is_cache) + sqlite_cache_stmt(server, stmt); } @@ -1451,12 +1458,6 @@ sqliteBeginForeignScan(ForeignScanState *node, int eflags) festate->conn = conn; festate->cursor_exists = false; - festate->temp_cxt = AllocSetContextCreate(estate->es_query_cxt, - "sqlite_fdw temporary data", - ALLOCSET_SMALL_MINSIZE, - ALLOCSET_SMALL_INITSIZE, - ALLOCSET_SMALL_MAXSIZE); - /* * Get info we'll need for converting data fetched from the foreign server * into local representation and error reporting during that process. @@ -1482,7 +1483,7 @@ sqliteBeginForeignScan(ForeignScanState *node, int eflags) festate->stmt = NULL; /* Prepare Sqlite statement */ - sqlite_prepare_wrapper(festate->conn, festate->query, &festate->stmt, NULL); + sqlite_prepare_wrapper(server, festate->conn, festate->query, &festate->stmt, NULL, true); /* Prepare for output conversion of parameters used in remote query. */ numParams = list_length(fsplan->fdw_exprs); @@ -1660,7 +1661,6 @@ sqliteEndForeignScan(ForeignScanState *node) if (festate->stmt) { - sqlite3_finalize(festate->stmt); festate->stmt = NULL; } } @@ -1944,6 +1944,7 @@ sqliteBeginForeignModify(ModifyTableState *mtstate, fmstate->conn = sqlite_get_connection(server, false); fmstate->query = strVal(list_nth(fdw_private, FdwModifyPrivateUpdateSql)); + fmstate->target_attrs = (List *) list_nth(fdw_private, FdwModifyPrivateTargetAttnums); fmstate->retrieved_attrs = (List *) list_nth(fdw_private, FdwModifyPrivateTargetAttnums); fmstate->values_end = intVal(list_nth(fdw_private, FdwModifyPrivateLen)); fmstate->orig_query = pstrdup(fmstate->query); @@ -1964,7 +1965,15 @@ sqliteBeginForeignModify(ModifyTableState *mtstate, Form_pg_attribute attr = TupleDescAttr(RelationGetDescr(rel), attnum - 1); Assert(!attr->attisdropped); - +#if PG_VERSION_NUM >= 140000 + /* Ignore generated columns; */ + if (attr->attgenerated) + { + if (list_length(fmstate->retrieved_attrs) >= 1) + fmstate->p_nums = 1; + continue; + } +#endif getTypeOutputInfo(attr->atttypid, &typefnoid, &isvarlena); fmgr_info(typefnoid, &fmstate->p_flinfo[fmstate->p_nums]); fmstate->p_nums++; @@ -1982,7 +1991,8 @@ sqliteBeginForeignModify(ModifyTableState *mtstate, fmstate->num_slots = 1; /* Prepare sqlite statment */ - sqlite_prepare_wrapper(fmstate->conn, fmstate->query, &fmstate->stmt, NULL); + sqlite_prepare_wrapper(server, fmstate->conn, fmstate->query, &fmstate->stmt, NULL, true); + resultRelInfo->ri_FdwState = fmstate; fmstate->junk_idx = palloc0(RelationGetDescr(rel)->natts * sizeof(AttrNumber)); @@ -2155,7 +2165,9 @@ sqlite_find_modifytable_subplan(PlannerInfo *root, if (subplan_index < list_length(appendplan->appendplans)) subplan = (Plan *) list_nth(appendplan->appendplans, subplan_index); } - else if (IsA(subplan, Result) && IsA(outerPlan(subplan), Append)) + else if (IsA(subplan, Result) && + outerPlan(subplan) != NULL && + IsA(outerPlan(subplan), Append)) { Append *appendplan = (Append *) outerPlan(subplan); @@ -2505,7 +2517,7 @@ sqliteBeginDirectModify(ForeignScanState *node, int eflags) dmstate->stmt = NULL; /* Prepare Sqlite statement */ - sqlite_prepare_wrapper(dmstate->conn, dmstate->query, &dmstate->stmt, NULL); + sqlite_prepare_wrapper(server, dmstate->conn, dmstate->query, &dmstate->stmt, NULL, true); /* * Prepare for processing of parameters used in remote query, if any. @@ -2572,7 +2584,6 @@ sqliteEndDirectModify(ForeignScanState *node) if (dmstate->stmt) { - sqlite3_finalize(dmstate->stmt); dmstate->stmt = NULL; } } @@ -2769,7 +2780,14 @@ sqliteExecForeignUpdate(EState *estate, Oid type; bool is_null; Datum value = 0; +#if PG_VERSION_NUM >= 140000 + TupleDesc tupdesc = RelationGetDescr(fmstate->rel); + Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum - 1); + /* Ignore generated columns and skip bind value */ + if (attr->attgenerated) + continue; +#endif /* first attribute cannot be in target list attribute */ type = TupleDescAttr(slot->tts_tupleDescriptor, attnum - 1)->atttypid; @@ -2832,7 +2850,6 @@ sqliteEndForeignModify(EState *estate, elog(DEBUG1, "sqlite_fdw : %s", __func__); if (fmstate && fmstate->stmt) { - sqlite3_finalize(fmstate->stmt); fmstate->stmt = NULL; } } @@ -2957,7 +2974,7 @@ sqliteImportForeignSchema(ImportForeignSchemaStmt *stmt, appendStringInfoChar(&buf, ')'); } - sqlite_prepare_wrapper(db, buf.data, (sqlite3_stmt * *) & sql_stmt, NULL); + sqlite_prepare_wrapper(server, db, buf.data, (sqlite3_stmt * *) & sql_stmt, NULL, false); /* Scan all rows for this table */ for (;;) @@ -2987,7 +3004,7 @@ sqliteImportForeignSchema(ImportForeignSchemaStmt *stmt, query = palloc0(strlen(table) + 30); sprintf(query, "PRAGMA table_info(%s)", quote_identifier(table)); - sqlite_prepare_wrapper(db, query, (sqlite3_stmt * *) & pragma_stmt, NULL); + sqlite_prepare_wrapper(server, db, query, (sqlite3_stmt * *) & pragma_stmt, NULL, false); for (;;) { @@ -5043,7 +5060,8 @@ sqlite_execute_insert(EState *estate, Datum value = 0; MemoryContext oldcontext; #if PG_VERSION_NUM >= 140000 - StringInfoData sql; + Relation rel = resultRelInfo->ri_RelationDesc; + TupleDesc tupdesc = RelationGetDescr(rel); #endif int rc = SQLITE_OK; int nestlevel; @@ -5061,17 +5079,22 @@ sqlite_execute_insert(EState *estate, #if PG_VERSION_NUM >= 140000 if (fmstate->num_slots != *numSlots) { - sqlite3_finalize(fmstate->stmt); + StringInfoData sql; + ForeignTable *table; + ForeignServer *server; + + table = GetForeignTable(RelationGetRelid(fmstate->rel)); + server = GetForeignServer(table->serverid); fmstate->stmt = NULL; initStringInfo(&sql); - sqlite_rebuild_insert(&sql, fmstate->orig_query, - fmstate->values_end, + sqlite_rebuild_insert(&sql, fmstate->rel, fmstate->orig_query, + fmstate->target_attrs, fmstate->values_end, fmstate->p_nums, *numSlots - 1); fmstate->query = sql.data; fmstate->num_slots = *numSlots; - sqlite_prepare_wrapper(fmstate->conn, fmstate->query, &fmstate->stmt, NULL); + sqlite_prepare_wrapper(server, fmstate->conn, fmstate->query, &fmstate->stmt, NULL, true); } #endif @@ -5082,6 +5105,13 @@ sqlite_execute_insert(EState *estate, int attnum = lfirst_int(lc) - 1; Oid type = TupleDescAttr(slots[i]->tts_tupleDescriptor, attnum)->atttypid; bool isnull; +#if PG_VERSION_NUM >= 140000 + Form_pg_attribute attr = TupleDescAttr(tupdesc, attnum); + + /* Ignore generated columns and skip bind value */ + if (attr->attgenerated) + continue; +#endif value = slot_getattr(slots[i], attnum + 1, &isnull); sqlite_bind_sql_var(type, bindnum, value, fmstate->stmt, &isnull); @@ -5415,7 +5445,7 @@ sqlite_get_batch_size_option(Relation rel) if (strcmp(def->defname, "batch_size") == 0) { - batch_size = strtol(defGetString(def), NULL, 10); + (void) parse_int(defGetString(def), &batch_size, 0, NULL); break; } } diff --git a/sqlite_fdw.h b/sqlite_fdw.h index a4cd5738..b0abf47e 100644 --- a/sqlite_fdw.h +++ b/sqlite_fdw.h @@ -50,7 +50,7 @@ #endif /* Code version is updated at new release. */ -#define CODE_VERSION 20100 +#define CODE_VERSION 20101 #if (PG_VERSION_NUM < 100000) /* @@ -136,6 +136,7 @@ typedef struct SQLiteFdwExecState int num_slots; /* number of slots to insert */ char *orig_query; /* original text of INSERT command */ + List *target_attrs; /* list of target attribute numbers */ int values_end; /* length up to the end of VALUES */ sqlite_opt *sqliteFdwOptions; /* SQLite FDW options */ @@ -311,7 +312,7 @@ extern void sqlite_deparse_select_stmt_for_rel(StringInfo buf, PlannerInfo *root List **retrieved_attrs, List **params_list); extern void sqlite_deparse_insert(StringInfo buf, PlannerInfo *root, Index rtindex, Relation rel, List *targetAttrs, bool doNothing, int *values_end_len); #if PG_VERSION_NUM >= 140000 -extern void sqlite_rebuild_insert(StringInfo buf, char *orig_query, int values_end_len, int num_cols, int num_rows); +extern void sqlite_rebuild_insert(StringInfo buf, Relation rel, char *orig_query, List *target_attrs, int values_end_len, int num_params, int num_rows); extern void sqlite_deparse_truncate(StringInfo buf, List *rels); #endif extern void sqlite_deparse_update(StringInfo buf, PlannerInfo *root, Index rtindex, Relation rel, List *targetAttrs, List *attname); @@ -353,6 +354,7 @@ sqlite3 *sqlite_connect(char *svr_address, char *svr_username, char *svr_pass void sqlite_cleanup_connection(void); void sqlite_rel_connection(sqlite3 * conn); void sqlitefdw_report_error(int elevel, sqlite3_stmt * stmt, sqlite3 * conn, const char *sql, int rc); +void sqlite_cache_stmt(ForeignServer *server, sqlite3_stmt * *stmt); Datum sqlite_convert_to_pg(Oid pgtyp, int pgtypmod, sqlite3_stmt * stmt, int attnum, AttInMetadata *attinmeta);