From fc708d7fecacd03aa2fd79dd24e127507d58cccd Mon Sep 17 00:00:00 2001 From: Nguyen Ngoc Son Date: Mon, 26 Sep 2022 16:51:03 +0700 Subject: [PATCH] RELEASE v2.2.0 --- License | 4 +- META.json | 4 +- Makefile | 8 +- README.md | 42 +- connection.c | 110 +- deparse.c | 353 +- expected/10.18/extra/numeric.out | 3822 ------------ expected/10.18/selectfunc.out | 454 -- expected/10.18/sqlite_fdw.out | 1526 ----- expected/11.13/extra/float8.out | 1411 ----- expected/{10.18 => 11.16}/aggregate.out | 0 .../{11.13 => 11.16}/extra/aggregates.out | 0 expected/{10.18 => 11.16}/extra/float4.out | 0 expected/{10.18 => 11.16}/extra/float8.out | 0 expected/{10.18 => 11.16}/extra/insert.out | 0 expected/{10.18 => 11.16}/extra/int4.out | 0 expected/{11.13 => 11.16}/extra/int8.out | 0 expected/{11.13 => 11.16}/extra/join.out | 0 expected/{10.18 => 11.16}/extra/limit.out | 0 expected/{11.13 => 11.16}/extra/numeric.out | 0 expected/{10.18 => 11.16}/extra/prepare.out | 0 expected/{10.18 => 11.16}/extra/select.out | 0 .../{10.18 => 11.16}/extra/select_having.out | 0 .../extra/sqlite_fdw_post.out | 0 expected/{10.18 => 11.16}/extra/timestamp.out | 0 expected/{10.18 => 11.16}/extra/update.out | 0 expected/{11.13 => 11.16}/selectfunc.out | 326 + expected/{13.4 => 11.16}/sqlite_fdw.out | 122 +- expected/{10.18 => 11.16}/type.out | 3 +- expected/{11.13 => 12.11}/aggregate.out | 0 expected/{12.8 => 12.11}/extra/aggregates.out | 0 expected/{12.8 => 12.11}/extra/float4.out | 0 expected/{12.8 => 12.11}/extra/float8.out | 0 expected/{11.13 => 12.11}/extra/insert.out | 0 expected/{12.8 => 12.11}/extra/int4.out | 0 expected/{12.8 => 12.11}/extra/int8.out | 0 expected/{12.8 => 12.11}/extra/join.out | 0 expected/{11.13 => 12.11}/extra/limit.out | 0 expected/{12.8 => 12.11}/extra/numeric.out | 0 expected/{11.13 => 12.11}/extra/prepare.out | 0 expected/{12.8 => 12.11}/extra/select.out | 0 .../{11.13 => 12.11}/extra/select_having.out | 0 .../{12.8 => 12.11}/extra/sqlite_fdw_post.out | 0 expected/{11.13 => 12.11}/extra/timestamp.out | 0 expected/{11.13 => 12.11}/extra/update.out | 0 expected/{12.8 => 12.11}/selectfunc.out | 326 + expected/{11.13 => 12.11}/sqlite_fdw.out | 122 +- expected/{11.13 => 12.11}/type.out | 3 +- expected/{13.4 => 13.7}/aggregate.out | 0 expected/{13.4 => 13.7}/extra/aggregates.out | 0 expected/{13.4 => 13.7}/extra/float4.out | 0 expected/{13.4 => 13.7}/extra/float8.out | 0 expected/{12.8 => 13.7}/extra/insert.out | 0 expected/{13.4 => 13.7}/extra/int4.out | 0 expected/{13.4 => 13.7}/extra/int8.out | 0 expected/{13.4 => 13.7}/extra/join.out | 0 expected/{13.4 => 13.7}/extra/limit.out | 0 expected/{13.4 => 13.7}/extra/numeric.out | 0 expected/{13.4 => 13.7}/extra/prepare.out | 0 expected/{13.4 => 13.7}/extra/select.out | 0 .../{12.8 => 13.7}/extra/select_having.out | 0 .../{13.4 => 13.7}/extra/sqlite_fdw_post.out | 0 expected/{12.8 => 13.7}/extra/timestamp.out | 0 expected/{12.8 => 13.7}/extra/update.out | 0 expected/{13.4 => 13.7}/selectfunc.out | 326 + expected/{12.8 => 13.7}/sqlite_fdw.out | 122 +- expected/{13.4 => 13.7}/type.out | 3 +- expected/14.0/type.out | 351 -- expected/{14.0 => 14.4}/aggregate.out | 0 expected/{14.0 => 14.4}/extra/aggregates.out | 0 expected/{14.0 => 14.4}/extra/float4.out | 0 expected/{14.0 => 14.4}/extra/float8.out | 0 expected/{14.0 => 14.4}/extra/insert.out | 0 expected/{14.0 => 14.4}/extra/int4.out | 0 expected/{14.0 => 14.4}/extra/int8.out | 0 expected/{14.0 => 14.4}/extra/join.out | 3 +- expected/{14.0 => 14.4}/extra/limit.out | 0 expected/{14.0 => 14.4}/extra/numeric.out | 0 expected/{14.0 => 14.4}/extra/prepare.out | 0 expected/{14.0 => 14.4}/extra/select.out | 0 .../{13.4 => 14.4}/extra/select_having.out | 0 .../{14.0 => 14.4}/extra/sqlite_fdw_post.out | 0 expected/{13.4 => 14.4}/extra/timestamp.out | 0 expected/{14.0 => 14.4}/extra/update.out | 0 expected/{14.0 => 14.4}/selectfunc.out | 326 + expected/{14.0 => 14.4}/sqlite_fdw.out | 122 +- expected/{12.8 => 14.4}/type.out | 3 +- expected/{12.8 => 15beta2}/aggregate.out | 66 +- .../{10.18 => 15beta2}/extra/aggregates.out | 600 +- expected/{11.13 => 15beta2}/extra/float4.out | 748 +-- expected/15beta2/extra/float8.out | 1963 ++++++ expected/{13.4 => 15beta2}/extra/insert.out | 48 +- expected/{11.13 => 15beta2}/extra/int4.out | 377 +- expected/{10.18 => 15beta2}/extra/int8.out | 490 +- expected/{10.18 => 15beta2}/extra/join.out | 4095 ++++++------ expected/{12.8 => 15beta2}/extra/limit.out | 178 +- expected/15beta2/extra/numeric.out | 5543 +++++++++++++++++ expected/{12.8 => 15beta2}/extra/prepare.out | 2 + expected/{11.13 => 15beta2}/extra/select.out | 74 +- .../{14.0 => 15beta2}/extra/select_having.out | 0 .../extra/sqlite_fdw_post.out | 2323 +++++-- .../{14.0 => 15beta2}/extra/timestamp.out | 0 expected/{13.4 => 15beta2}/extra/update.out | 66 +- expected/15beta2/selectfunc.out | 780 +++ expected/15beta2/sqlite_fdw.out | 1660 +++++ expected/15beta2/type.out | 352 ++ option.c | 7 +- sql/{10.18 => 11.16}/aggregate.sql | 0 sql/{10.18 => 11.16}/extra/aggregates.sql | 0 sql/{10.18 => 11.16}/extra/float4.sql | 0 sql/{10.18 => 11.16}/extra/float8.sql | 0 sql/{10.18 => 11.16}/extra/insert.sql | 0 sql/{10.18 => 11.16}/extra/int4.sql | 0 sql/{10.18 => 11.16}/extra/int8.sql | 0 sql/{10.18 => 11.16}/extra/join.sql | 0 sql/{10.18 => 11.16}/extra/limit.sql | 0 sql/{10.18 => 11.16}/extra/numeric.sql | 0 sql/{10.18 => 11.16}/extra/prepare.sql | 0 sql/{10.18 => 11.16}/extra/select.sql | 0 sql/{10.18 => 11.16}/extra/select_having.sql | 0 .../extra/sqlite_fdw_post.sql | 0 sql/{10.18 => 11.16}/extra/timestamp.sql | 0 sql/{10.18 => 11.16}/extra/update.sql | 0 sql/{10.18 => 11.16}/selectfunc.sql | 123 + sql/{10.18 => 11.16}/sqlite_fdw.sql | 42 + sql/{10.18 => 11.16}/type.sql | 0 sql/{11.13 => 12.11}/aggregate.sql | 0 sql/{11.13 => 12.11}/extra/aggregates.sql | 0 sql/{11.13 => 12.11}/extra/float4.sql | 0 sql/{11.13 => 12.11}/extra/float8.sql | 0 sql/{11.13 => 12.11}/extra/insert.sql | 0 sql/{11.13 => 12.11}/extra/int4.sql | 0 sql/{11.13 => 12.11}/extra/int8.sql | 0 sql/{11.13 => 12.11}/extra/join.sql | 0 sql/{11.13 => 12.11}/extra/limit.sql | 0 sql/{11.13 => 12.11}/extra/numeric.sql | 0 sql/{11.13 => 12.11}/extra/prepare.sql | 0 sql/{11.13 => 12.11}/extra/select.sql | 0 sql/{11.13 => 12.11}/extra/select_having.sql | 0 .../extra/sqlite_fdw_post.sql | 0 sql/{11.13 => 12.11}/extra/timestamp.sql | 0 sql/{11.13 => 12.11}/extra/update.sql | 0 sql/{11.13 => 12.11}/selectfunc.sql | 123 + sql/{13.4 => 12.11}/sqlite_fdw.sql | 42 + sql/{11.13 => 12.11}/type.sql | 0 sql/{12.8 => 13.7}/aggregate.sql | 0 sql/{12.8 => 13.7}/extra/aggregates.sql | 0 sql/{12.8 => 13.7}/extra/float4.sql | 0 sql/{12.8 => 13.7}/extra/float8.sql | 0 sql/{12.8 => 13.7}/extra/insert.sql | 0 sql/{12.8 => 13.7}/extra/int4.sql | 0 sql/{12.8 => 13.7}/extra/int8.sql | 0 sql/{12.8 => 13.7}/extra/join.sql | 0 sql/{12.8 => 13.7}/extra/limit.sql | 0 sql/{12.8 => 13.7}/extra/numeric.sql | 0 sql/{12.8 => 13.7}/extra/prepare.sql | 0 sql/{12.8 => 13.7}/extra/select.sql | 0 sql/{12.8 => 13.7}/extra/select_having.sql | 0 sql/{12.8 => 13.7}/extra/sqlite_fdw_post.sql | 0 sql/{12.8 => 13.7}/extra/timestamp.sql | 0 sql/{12.8 => 13.7}/extra/update.sql | 0 sql/{13.4 => 13.7}/selectfunc.sql | 123 + sql/{11.13 => 13.7}/sqlite_fdw.sql | 42 + sql/{12.8 => 13.7}/type.sql | 0 sql/14.0/selectfunc.sql | 292 - sql/{13.4 => 14.4}/aggregate.sql | 0 sql/{14.0 => 14.4}/extra/aggregates.sql | 0 sql/{14.0 => 14.4}/extra/float4.sql | 0 sql/{14.0 => 14.4}/extra/float8.sql | 0 sql/{14.0 => 14.4}/extra/insert.sql | 0 sql/{14.0 => 14.4}/extra/int4.sql | 0 sql/{14.0 => 14.4}/extra/int8.sql | 0 sql/{14.0 => 14.4}/extra/join.sql | 0 sql/{13.4 => 14.4}/extra/limit.sql | 0 sql/{14.0 => 14.4}/extra/numeric.sql | 0 sql/{13.4 => 14.4}/extra/prepare.sql | 0 sql/{13.4 => 14.4}/extra/select.sql | 0 sql/{13.4 => 14.4}/extra/select_having.sql | 0 sql/{14.0 => 14.4}/extra/sqlite_fdw_post.sql | 0 sql/{13.4 => 14.4}/extra/timestamp.sql | 0 sql/{14.0 => 14.4}/extra/update.sql | 0 sql/{12.8 => 14.4}/selectfunc.sql | 123 + sql/{14.0 => 14.4}/sqlite_fdw.sql | 42 + sql/{13.4 => 14.4}/type.sql | 0 sql/{14.0 => 15beta2}/aggregate.sql | 0 sql/{13.4 => 15beta2}/extra/aggregates.sql | 246 +- sql/{13.4 => 15beta2}/extra/float4.sql | 34 +- sql/{13.4 => 15beta2}/extra/float8.sql | 241 +- sql/{13.4 => 15beta2}/extra/insert.sql | 54 +- sql/{13.4 => 15beta2}/extra/int4.sql | 72 +- sql/{13.4 => 15beta2}/extra/int8.sql | 54 +- sql/{13.4 => 15beta2}/extra/join.sql | 250 +- sql/{14.0 => 15beta2}/extra/limit.sql | 6 + sql/{13.4 => 15beta2}/extra/numeric.sql | 1188 +++- sql/{14.0 => 15beta2}/extra/prepare.sql | 0 sql/{14.0 => 15beta2}/extra/select.sql | 10 +- sql/{14.0 => 15beta2}/extra/select_having.sql | 0 .../extra/sqlite_fdw_post.sql | 1236 +++- sql/{14.0 => 15beta2}/extra/timestamp.sql | 0 sql/{13.4 => 15beta2}/extra/update.sql | 60 +- sql/15beta2/selectfunc.sql | 415 ++ sql/{12.8 => 15beta2}/sqlite_fdw.sql | 79 +- sql/{14.0 => 15beta2}/type.sql | 0 sql/init_data/init.sql | 2 + sql/init_data/init_core.sql | 12 + sqlite_fdw.c | 193 +- sqlite_fdw.h | 15 +- test.sh | 4 +- 208 files changed, 22707 insertions(+), 11680 deletions(-) delete mode 100644 expected/10.18/extra/numeric.out delete mode 100644 expected/10.18/selectfunc.out delete mode 100644 expected/10.18/sqlite_fdw.out delete mode 100644 expected/11.13/extra/float8.out rename expected/{10.18 => 11.16}/aggregate.out (100%) rename expected/{11.13 => 11.16}/extra/aggregates.out (100%) rename expected/{10.18 => 11.16}/extra/float4.out (100%) rename expected/{10.18 => 11.16}/extra/float8.out (100%) rename expected/{10.18 => 11.16}/extra/insert.out (100%) rename expected/{10.18 => 11.16}/extra/int4.out (100%) rename expected/{11.13 => 11.16}/extra/int8.out (100%) rename expected/{11.13 => 11.16}/extra/join.out (100%) rename expected/{10.18 => 11.16}/extra/limit.out (100%) rename expected/{11.13 => 11.16}/extra/numeric.out (100%) rename expected/{10.18 => 11.16}/extra/prepare.out (100%) rename expected/{10.18 => 11.16}/extra/select.out (100%) rename expected/{10.18 => 11.16}/extra/select_having.out (100%) rename expected/{11.13 => 11.16}/extra/sqlite_fdw_post.out (100%) rename expected/{10.18 => 11.16}/extra/timestamp.out (100%) rename expected/{10.18 => 11.16}/extra/update.out (100%) rename expected/{11.13 => 11.16}/selectfunc.out (65%) rename expected/{13.4 => 11.16}/sqlite_fdw.out (92%) rename expected/{10.18 => 11.16}/type.out (99%) rename expected/{11.13 => 12.11}/aggregate.out (100%) rename expected/{12.8 => 12.11}/extra/aggregates.out (100%) rename expected/{12.8 => 12.11}/extra/float4.out (100%) rename expected/{12.8 => 12.11}/extra/float8.out (100%) rename expected/{11.13 => 12.11}/extra/insert.out (100%) rename expected/{12.8 => 12.11}/extra/int4.out (100%) rename expected/{12.8 => 12.11}/extra/int8.out (100%) rename expected/{12.8 => 12.11}/extra/join.out (100%) rename expected/{11.13 => 12.11}/extra/limit.out (100%) rename expected/{12.8 => 12.11}/extra/numeric.out (100%) rename expected/{11.13 => 12.11}/extra/prepare.out (100%) rename expected/{12.8 => 12.11}/extra/select.out (100%) rename expected/{11.13 => 12.11}/extra/select_having.out (100%) rename expected/{12.8 => 12.11}/extra/sqlite_fdw_post.out (100%) rename expected/{11.13 => 12.11}/extra/timestamp.out (100%) rename expected/{11.13 => 12.11}/extra/update.out (100%) rename expected/{12.8 => 12.11}/selectfunc.out (66%) rename expected/{11.13 => 12.11}/sqlite_fdw.out (92%) rename expected/{11.13 => 12.11}/type.out (99%) rename expected/{13.4 => 13.7}/aggregate.out (100%) rename expected/{13.4 => 13.7}/extra/aggregates.out (100%) rename expected/{13.4 => 13.7}/extra/float4.out (100%) rename expected/{13.4 => 13.7}/extra/float8.out (100%) rename expected/{12.8 => 13.7}/extra/insert.out (100%) rename expected/{13.4 => 13.7}/extra/int4.out (100%) rename expected/{13.4 => 13.7}/extra/int8.out (100%) rename expected/{13.4 => 13.7}/extra/join.out (100%) rename expected/{13.4 => 13.7}/extra/limit.out (100%) rename expected/{13.4 => 13.7}/extra/numeric.out (100%) rename expected/{13.4 => 13.7}/extra/prepare.out (100%) rename expected/{13.4 => 13.7}/extra/select.out (100%) rename expected/{12.8 => 13.7}/extra/select_having.out (100%) rename expected/{13.4 => 13.7}/extra/sqlite_fdw_post.out (100%) rename expected/{12.8 => 13.7}/extra/timestamp.out (100%) rename expected/{12.8 => 13.7}/extra/update.out (100%) rename expected/{13.4 => 13.7}/selectfunc.out (66%) rename expected/{12.8 => 13.7}/sqlite_fdw.out (92%) rename expected/{13.4 => 13.7}/type.out (99%) delete mode 100644 expected/14.0/type.out rename expected/{14.0 => 14.4}/aggregate.out (100%) rename expected/{14.0 => 14.4}/extra/aggregates.out (100%) rename expected/{14.0 => 14.4}/extra/float4.out (100%) rename expected/{14.0 => 14.4}/extra/float8.out (100%) rename expected/{14.0 => 14.4}/extra/insert.out (100%) rename expected/{14.0 => 14.4}/extra/int4.out (100%) rename expected/{14.0 => 14.4}/extra/int8.out (100%) rename expected/{14.0 => 14.4}/extra/join.out (99%) rename expected/{14.0 => 14.4}/extra/limit.out (100%) rename expected/{14.0 => 14.4}/extra/numeric.out (100%) rename expected/{14.0 => 14.4}/extra/prepare.out (100%) rename expected/{14.0 => 14.4}/extra/select.out (100%) rename expected/{13.4 => 14.4}/extra/select_having.out (100%) rename expected/{14.0 => 14.4}/extra/sqlite_fdw_post.out (100%) rename expected/{13.4 => 14.4}/extra/timestamp.out (100%) rename expected/{14.0 => 14.4}/extra/update.out (100%) rename expected/{14.0 => 14.4}/selectfunc.out (66%) rename expected/{14.0 => 14.4}/sqlite_fdw.out (92%) rename expected/{12.8 => 14.4}/type.out (99%) rename expected/{12.8 => 15beta2}/aggregate.out (79%) rename expected/{10.18 => 15beta2}/extra/aggregates.out (87%) rename expected/{11.13 => 15beta2}/extra/float4.out (53%) create mode 100644 expected/15beta2/extra/float8.out rename expected/{13.4 => 15beta2}/extra/insert.out (96%) rename expected/{11.13 => 15beta2}/extra/int4.out (59%) rename expected/{10.18 => 15beta2}/extra/int8.out (70%) rename expected/{10.18 => 15beta2}/extra/join.out (74%) rename expected/{12.8 => 15beta2}/extra/limit.out (88%) create mode 100644 expected/15beta2/extra/numeric.out rename expected/{12.8 => 15beta2}/extra/prepare.out (99%) rename expected/{11.13 => 15beta2}/extra/select.out (94%) rename expected/{14.0 => 15beta2}/extra/select_having.out (100%) rename expected/{10.18 => 15beta2}/extra/sqlite_fdw_post.out (84%) rename expected/{14.0 => 15beta2}/extra/timestamp.out (100%) rename expected/{13.4 => 15beta2}/extra/update.out (91%) create mode 100644 expected/15beta2/selectfunc.out create mode 100644 expected/15beta2/sqlite_fdw.out create mode 100644 expected/15beta2/type.out rename sql/{10.18 => 11.16}/aggregate.sql (100%) rename sql/{10.18 => 11.16}/extra/aggregates.sql (100%) rename sql/{10.18 => 11.16}/extra/float4.sql (100%) rename sql/{10.18 => 11.16}/extra/float8.sql (100%) rename sql/{10.18 => 11.16}/extra/insert.sql (100%) rename sql/{10.18 => 11.16}/extra/int4.sql (100%) rename sql/{10.18 => 11.16}/extra/int8.sql (100%) rename sql/{10.18 => 11.16}/extra/join.sql (100%) rename sql/{10.18 => 11.16}/extra/limit.sql (100%) rename sql/{10.18 => 11.16}/extra/numeric.sql (100%) rename sql/{10.18 => 11.16}/extra/prepare.sql (100%) rename sql/{10.18 => 11.16}/extra/select.sql (100%) rename sql/{10.18 => 11.16}/extra/select_having.sql (100%) rename sql/{10.18 => 11.16}/extra/sqlite_fdw_post.sql (100%) rename sql/{10.18 => 11.16}/extra/timestamp.sql (100%) rename sql/{10.18 => 11.16}/extra/update.sql (100%) rename sql/{10.18 => 11.16}/selectfunc.sql (72%) rename sql/{10.18 => 11.16}/sqlite_fdw.sql (92%) rename sql/{10.18 => 11.16}/type.sql (100%) rename sql/{11.13 => 12.11}/aggregate.sql (100%) rename sql/{11.13 => 12.11}/extra/aggregates.sql (100%) rename sql/{11.13 => 12.11}/extra/float4.sql (100%) rename sql/{11.13 => 12.11}/extra/float8.sql (100%) rename sql/{11.13 => 12.11}/extra/insert.sql (100%) rename sql/{11.13 => 12.11}/extra/int4.sql (100%) rename sql/{11.13 => 12.11}/extra/int8.sql (100%) rename sql/{11.13 => 12.11}/extra/join.sql (100%) rename sql/{11.13 => 12.11}/extra/limit.sql (100%) rename sql/{11.13 => 12.11}/extra/numeric.sql (100%) rename sql/{11.13 => 12.11}/extra/prepare.sql (100%) rename sql/{11.13 => 12.11}/extra/select.sql (100%) rename sql/{11.13 => 12.11}/extra/select_having.sql (100%) rename sql/{11.13 => 12.11}/extra/sqlite_fdw_post.sql (100%) rename sql/{11.13 => 12.11}/extra/timestamp.sql (100%) rename sql/{11.13 => 12.11}/extra/update.sql (100%) rename sql/{11.13 => 12.11}/selectfunc.sql (72%) rename sql/{13.4 => 12.11}/sqlite_fdw.sql (92%) rename sql/{11.13 => 12.11}/type.sql (100%) rename sql/{12.8 => 13.7}/aggregate.sql (100%) rename sql/{12.8 => 13.7}/extra/aggregates.sql (100%) rename sql/{12.8 => 13.7}/extra/float4.sql (100%) rename sql/{12.8 => 13.7}/extra/float8.sql (100%) rename sql/{12.8 => 13.7}/extra/insert.sql (100%) rename sql/{12.8 => 13.7}/extra/int4.sql (100%) rename sql/{12.8 => 13.7}/extra/int8.sql (100%) rename sql/{12.8 => 13.7}/extra/join.sql (100%) rename sql/{12.8 => 13.7}/extra/limit.sql (100%) rename sql/{12.8 => 13.7}/extra/numeric.sql (100%) rename sql/{12.8 => 13.7}/extra/prepare.sql (100%) rename sql/{12.8 => 13.7}/extra/select.sql (100%) rename sql/{12.8 => 13.7}/extra/select_having.sql (100%) rename sql/{12.8 => 13.7}/extra/sqlite_fdw_post.sql (100%) rename sql/{12.8 => 13.7}/extra/timestamp.sql (100%) rename sql/{12.8 => 13.7}/extra/update.sql (100%) rename sql/{13.4 => 13.7}/selectfunc.sql (72%) rename sql/{11.13 => 13.7}/sqlite_fdw.sql (92%) rename sql/{12.8 => 13.7}/type.sql (100%) delete mode 100644 sql/14.0/selectfunc.sql rename sql/{13.4 => 14.4}/aggregate.sql (100%) rename sql/{14.0 => 14.4}/extra/aggregates.sql (100%) rename sql/{14.0 => 14.4}/extra/float4.sql (100%) rename sql/{14.0 => 14.4}/extra/float8.sql (100%) rename sql/{14.0 => 14.4}/extra/insert.sql (100%) rename sql/{14.0 => 14.4}/extra/int4.sql (100%) rename sql/{14.0 => 14.4}/extra/int8.sql (100%) rename sql/{14.0 => 14.4}/extra/join.sql (100%) rename sql/{13.4 => 14.4}/extra/limit.sql (100%) rename sql/{14.0 => 14.4}/extra/numeric.sql (100%) rename sql/{13.4 => 14.4}/extra/prepare.sql (100%) rename sql/{13.4 => 14.4}/extra/select.sql (100%) rename sql/{13.4 => 14.4}/extra/select_having.sql (100%) rename sql/{14.0 => 14.4}/extra/sqlite_fdw_post.sql (100%) rename sql/{13.4 => 14.4}/extra/timestamp.sql (100%) rename sql/{14.0 => 14.4}/extra/update.sql (100%) rename sql/{12.8 => 14.4}/selectfunc.sql (72%) rename sql/{14.0 => 14.4}/sqlite_fdw.sql (92%) rename sql/{13.4 => 14.4}/type.sql (100%) rename sql/{14.0 => 15beta2}/aggregate.sql (100%) rename sql/{13.4 => 15beta2}/extra/aggregates.sql (91%) rename sql/{13.4 => 15beta2}/extra/float4.sql (95%) rename sql/{13.4 => 15beta2}/extra/float8.sql (78%) rename sql/{13.4 => 15beta2}/extra/insert.sql (96%) rename sql/{13.4 => 15beta2}/extra/int4.sql (78%) rename sql/{13.4 => 15beta2}/extra/int8.sql (88%) rename sql/{13.4 => 15beta2}/extra/join.sql (93%) rename sql/{14.0 => 15beta2}/extra/limit.sql (98%) rename sql/{13.4 => 15beta2}/extra/numeric.sql (70%) rename sql/{14.0 => 15beta2}/extra/prepare.sql (100%) rename sql/{14.0 => 15beta2}/extra/select.sql (98%) rename sql/{14.0 => 15beta2}/extra/select_having.sql (100%) rename sql/{13.4 => 15beta2}/extra/sqlite_fdw_post.sql (73%) rename sql/{14.0 => 15beta2}/extra/timestamp.sql (100%) rename sql/{13.4 => 15beta2}/extra/update.sql (91%) create mode 100644 sql/15beta2/selectfunc.sql rename sql/{12.8 => 15beta2}/sqlite_fdw.sql (89%) rename sql/{14.0 => 15beta2}/type.sql (100%) diff --git a/License b/License index fe5e981e..89fdb39a 100644 --- a/License +++ b/License @@ -1,6 +1,6 @@ SQLite Foreign Data Wrapper for PostgreSQL -Copyright (c) 2017 - 2021, TOSHIBA Corporation +Copyright (c) 2018, TOSHIBA CORPORATION Copyright (c) 2011 - 2016, EnterpriseDB Corporation Permission to use, copy, modify, and distribute this software and its @@ -17,4 +17,4 @@ TOSHIBA CORPORATION SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND TOSHIBA CORPORATION HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, -UPDATES, ENHANCEMENTS, OR MODIFICATIONS. \ No newline at end of file +UPDATES, ENHANCEMENTS, OR MODIFICATIONS. diff --git a/META.json b/META.json index 2f3d8924..9e429738 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.1", + "version": "2.2.0", "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.1" + "version": "2.2.0" } }, "prereqs": { diff --git a/Makefile b/Makefile index d616308a..3827fab3 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # # SQLite Foreign Data Wrapper for PostgreSQL # -# Portions Copyright (c) 2021, TOSHIBA CORPORATION +# Portions Copyright (c) 2018, TOSHIBA CORPORATION # # IDENTIFICATION # Makefile @@ -36,8 +36,8 @@ include $(PGXS) ifndef MAJORVERSION MAJORVERSION := $(basename $(VERSION)) endif -ifeq (,$(findstring $(MAJORVERSION), 10 11 12 13 14)) -$(error PostgreSQL 10, 11, 12, 13 or 14 is required to compile this extension) +ifeq (,$(findstring $(MAJORVERSION), 11 12 13 14 15)) +$(error PostgreSQL 11, 12, 13, 14 or 15 is required to compile this extension) endif else @@ -54,4 +54,4 @@ REGRESS_PREFIX_SUB = $(VERSION) endif REGRESS := $(addprefix $(REGRESS_PREFIX_SUB)/,$(REGRESS)) -$(shell mkdir -p results/$(REGRESS_PREFIX_SUB)/extra) \ No newline at end of file +$(shell mkdir -p results/$(REGRESS_PREFIX_SUB)/extra) diff --git a/README.md b/README.md index dcd8a654..8f6f31ae 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # SQLite Foreign Data Wrapper for PostgreSQL This PostgreSQL extension is a Foreign Data Wrapper for [SQLite][1]. -The current version can work with PostgreSQL 10, 11, 12, 13 and 14. +The current version can work with PostgreSQL 11, 12, 13, 14 and 15. ## Installation ### 1. Install SQLite library @@ -28,6 +28,18 @@ make install ## Usage + +### FDW options + +| **No** | Option name | Context | Required | Description | +|--------|-------------|---------|----------|-------------| +| 1 | database | SERVER | Required | SQLite database path. | +| 2 | table | FOREIGN TABLE | Required | SQLite table name. | +| 3 | key | ATTRIBUTE | Optional | Primary key or unique key of SQLite table. | +| 4 | column_type | ATTRIBUTE | Optional | Option to convert INT SQLite column (epoch Unix Time) to be treated/visualized as TIMESTAMP in PostgreSQL. | +| 5 | column_name | ATTRIBUTE | Optional | This option gives the column name to use for the column on the remote server. | +| 6 | truncatable | SERVER,
FOREIGN TABLE | Optional | This option controls whether sqlite_fdw allows foreign tables to be truncated using the TRUNCATE command. | + ### Load extension
 CREATE EXTENSION sqlite_fdw;
@@ -67,11 +79,12 @@ SELECT * FROM t1;
 
## Features -- Support update to foreign table +- Support INSERT/UPDATE/DELETE (both Direct modification and Foreign modification). - WHERE clauses are pushdowned - Aggregate function are pushdowned - Order By is pushdowned -- Joins (left/right/inner) are pushdowned +- Joins (left/right/inner/cross) are pushdowned +- CASE expressions are pushdowned. - Limit and Offset are pushdowned (*when all tables queried are fdw) - Transactions - Support TRUNCATE by deparsing into DELETE statement without WHERE clause @@ -80,17 +93,34 @@ SELECT * FROM t1; - 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 - +- Support GROUP BY, HAVING push-down. +- Support ON CONFLICT DO NOTHING. ## 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 +- Insert into a partitioned table which has foreign partitions is not supported. Error "Not support partition insert" will display. - 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. +- RETURNING is not supported. + +## Notes +- SQLite evaluates division by zero as NULL. It is different from PostgreSQL, which will display "Division by zero" error. +- The data type of column of foreign table should match with data type of column in SQLite to avoid wrong result. For example, if the column of SQLite is float (which will be stored as float8), the column of foreign table should be float8, too. If the column of foreign table is float4, it may cause wrong result when select. +- For 'key' option, user needs to specify the primary key column of SQLite table corresponding with the 'key' option. If not, wrong result may occur when update or delete. +- When Sum of data in table is out of range, SQLite FDW will display "Infinity" value. It is different from PostgreSQL FDW, which will display "ERROR: value out of range: overflow" error. +- For push-down case, the number after floating point may be different from the result of PostgreSQL. +- For numeric type, SQLite FDW use sqlite3_column_double to get value, while SQLite shell uses sqlite3_column_text to get value. Those 2 APIs may return different numeric value. Therefore, for numeric type, the value returned from SQLite FDW may different from the value returned from SQLite shell. +- SQLite FDW can return implementation-dependent order for column if the column is not specified in ORDER BY clause. +- WITH TIES option is not pushed down. +- upper, lower functions are not pushed down because they does not work with UNICODE character in SQLite. +- When the column type is varchar array, if the string is shorter than the declared length, values of type character will be space-padded; values of type character varying will simply store the shorter string. +- SQLite FDW only supports ARRAY const, for example, ANY (ARRAY[1, 2, 3]) or ANY ('{1, 2 ,3}'). SQlite FDW does not support ARRAY expression, for example, ANY (ARRAY[c1, 1, c1+0]). For ANY(ARRAY) clause, SQLite FDW deparses it using IN operator. +- For sum function of SQLite, output of sum(bigint) is integer value. If input values are big, the overflow error may occurs on SQLite because it overflow within the range of signed 64bit. For PostgreSQL, it can calculate as over the precision of bigint, so overflow does not occur. +- SQLite promises to preserve the 15 most significant digits of a floating point value. The big value which exceed 15 most significant digits may become different value after inserted. ## Contributing Opening issues and pull requests on GitHub are welcome. ## License -Copyright (c) 2017 - 2021, TOSHIBA Corporation +Copyright (c) 2018, TOSHIBA CORPORATION Copyright (c) 2011 - 2016, EnterpriseDB Corporation Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies. diff --git a/connection.c b/connection.c index b2693ce3..9177ed2c 100644 --- a/connection.c +++ b/connection.c @@ -2,7 +2,7 @@ * * SQLite Foreign Data Wrapper for PostgreSQL * - * Portions Copyright (c) 2021, TOSHIBA CORPORATION + * Portions Copyright (c) 2018, TOSHIBA CORPORATION * * IDENTIFICATION * connection.c @@ -59,7 +59,7 @@ typedef struct ConnCacheEntry static HTAB *ConnectionHash = NULL; /* tracks whether any work is needed in callback functions */ -static bool xact_got_connection = false; +static volatile bool xact_got_connection = false; PG_FUNCTION_INFO_V1(sqlite_fdw_get_connections); PG_FUNCTION_INFO_V1(sqlite_fdw_disconnect); @@ -69,11 +69,13 @@ static void sqlite_make_new_connection(ConnCacheEntry *entry, ForeignServer *ser void sqlite_do_sql_command(sqlite3 * conn, const char *sql, int level); static void sqlite_begin_remote_xact(ConnCacheEntry *entry); static void sqlitefdw_xact_callback(XactEvent event, void *arg); +static void sqlitefdw_reset_xact_state(ConnCacheEntry *entry, bool toplevel); static void sqlitefdw_subxact_callback(SubXactEvent event, SubTransactionId mySubid, SubTransactionId parentSubid, void *arg); static void sqlitefdw_inval_callback(Datum arg, int cacheid, uint32 hashvalue); +static void sqlitefdw_abort_cleanup(ConnCacheEntry *entry, bool toplevel); #if PG_VERSION_NUM >= 140000 static bool sqlite_disconnect_cached_connections(Oid serverid); #endif @@ -434,23 +436,30 @@ sqlitefdw_xact_callback(XactEvent event, void *arg) case XACT_EVENT_PARALLEL_ABORT: case XACT_EVENT_ABORT: { - elog(DEBUG3, "abort transaction"); - - /* Finalize all prepared statements */ - sqlite_finalize_list_stmt(&entry->stmtList); - - /* - * rollback if in transaction because SQLite may - * already rollback - */ - if (!sqlite3_get_autocommit(entry->conn)) - sqlite_do_sql_command(entry->conn, "ROLLBACK", WARNING); - + sqlitefdw_abort_cleanup(entry, true); break; } } } + /* Reset state to show we're out of a transaction */ + sqlitefdw_reset_xact_state(entry, true); + } + + /* + * Regardless of the event type, we can now mark ourselves as out of the + * transaction. (Note: if we are here during PRE_COMMIT or PRE_PREPARE, + * this saves a useless scan of the hashtable during COMMIT or PREPARE.) + */ + xact_got_connection = false; +} + +/* + * sqlitefdw_reset_xact_state --- Reset state to show we're out of a (sub)transaction + */ +static void +sqlitefdw_reset_xact_state(ConnCacheEntry *entry, bool toplevel) { + if (toplevel) { /* Reset state to show we're out of a transaction */ entry->xact_depth = 0; @@ -467,16 +476,11 @@ sqlitefdw_xact_callback(XactEvent event, void *arg) sqlite3_close(entry->conn); entry->conn = NULL; } + } else { + /* Reset state to show we're out of a subtransaction */ + entry->xact_depth--; } - - /* - * Regardless of the event type, we can now mark ourselves as out of the - * transaction. (Note: if we are here during PRE_COMMIT or PRE_PREPARE, - * this saves a useless scan of the hashtable during COMMIT or PREPARE.) - */ - xact_got_connection = false; } - /* * sqlitefdw_subxact_callback --- cleanup at subtransaction end. */ @@ -538,15 +542,11 @@ sqlitefdw_subxact_callback(SubXactEvent event, SubTransactionId mySubid, else { /* Rollback all remote subtransactions during abort */ - snprintf(sql, sizeof(sql), - "ROLLBACK TO SAVEPOINT s%d; RELEASE SAVEPOINT s%d", - curlevel, curlevel); - if (!sqlite3_get_autocommit(entry->conn)) - sqlite_do_sql_command(entry->conn, sql, ERROR); + sqlitefdw_abort_cleanup(entry, false); } /* OK, we're outta that level of subtransaction */ - entry->xact_depth--; + sqlitefdw_reset_xact_state(entry, false); } } @@ -628,13 +628,18 @@ sqlite_fdw_get_connections(PG_FUNCTION_ARGS) #else #define SQLITE_FDW_GET_CONNECTIONS_COLS 2 ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; + HASH_SEQ_STATUS scan; + ConnCacheEntry *entry; +#if PG_VERSION_NUM < 150000 TupleDesc tupdesc; Tuplestorestate *tupstore; MemoryContext per_query_ctx; MemoryContext oldcontext; - HASH_SEQ_STATUS scan; - ConnCacheEntry *entry; +#endif +#if PG_VERSION_NUM >= 150000 + SetSingleFuncCall(fcinfo, 0); +#else /* check to see if caller supports us returning a tuplestore */ if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo)) ereport(ERROR, @@ -659,12 +664,15 @@ sqlite_fdw_get_connections(PG_FUNCTION_ARGS) rsinfo->setDesc = tupdesc; MemoryContextSwitchTo(oldcontext); +#endif /* If cache doesn't exist, we return no records */ if (!ConnectionHash) { +#if PG_VERSION_NUM < 150000 /* clean up and return the tuplestore */ tuplestore_donestoring(tupstore); +#endif PG_RETURN_VOID(); } @@ -728,12 +736,17 @@ sqlite_fdw_get_connections(PG_FUNCTION_ARGS) values[0] = CStringGetTextDatum(server->servername); values[1] = BoolGetDatum(!entry->invalidated); - +#if PG_VERSION_NUM >= 150000 + tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, values, nulls); +#else tuplestore_putvalues(tupstore, tupdesc, values, nulls); +#endif } +#if PG_VERSION_NUM < 150000 /* clean up and return the tuplestore */ tuplestore_donestoring(tupstore); +#endif PG_RETURN_VOID(); #endif @@ -792,6 +805,41 @@ sqlite_fdw_disconnect_all(PG_FUNCTION_ARGS) #endif } +/* + * Abort remote transaction or subtransaction. + * + * "toplevel" should be set to true if toplevel (main) transaction is + * rollbacked, false otherwise. + */ +static void +sqlitefdw_abort_cleanup(ConnCacheEntry *entry, bool toplevel) +{ + if (toplevel) + { + elog(DEBUG3, "abort transaction"); + + /* Finalize all prepared statements */ + sqlite_finalize_list_stmt(&entry->stmtList); + + /* + * rollback if in transaction because SQLite may + * already rollback + */ + if (!sqlite3_get_autocommit(entry->conn)) + sqlite_do_sql_command(entry->conn, "ROLLBACK", WARNING); + } + else + { + char sql[100]; + int curlevel = GetCurrentTransactionNestLevel(); + snprintf(sql, sizeof(sql), + "ROLLBACK TO SAVEPOINT s%d; RELEASE SAVEPOINT s%d", + curlevel, curlevel); + if (!sqlite3_get_autocommit(entry->conn)) + sqlite_do_sql_command(entry->conn, sql, ERROR); + } +} + #if PG_VERSION_NUM >= 140000 /* * Workhorse to disconnect cached connections. diff --git a/deparse.c b/deparse.c index c4f27b92..57209fbe 100644 --- a/deparse.c +++ b/deparse.c @@ -2,7 +2,7 @@ * * SQLite Foreign Data Wrapper for PostgreSQL * - * Portions Copyright (c) 2021, TOSHIBA CORPORATION + * Portions Copyright (c) 2018, TOSHIBA CORPORATION * * IDENTIFICATION * deparse.c @@ -22,6 +22,7 @@ #include "catalog/pg_collation.h" #include "catalog/pg_namespace.h" #include "catalog/pg_operator.h" +#include "catalog/pg_opfamily.h" #include "catalog/pg_proc.h" #include "catalog/pg_type.h" #include "commands/defrem.h" @@ -100,7 +101,8 @@ typedef struct deparse_expr_cxt */ static bool sqlite_foreign_expr_walker(Node *node, foreign_glob_cxt *glob_cxt, - foreign_loc_cxt *outer_cxt); + foreign_loc_cxt *outer_cxt, + foreign_loc_cxt *case_arg_cxt); /* * Functions to construct string representation of a node tree. @@ -118,6 +120,7 @@ static void sqlite_deparse_scalar_array_op_expr(ScalarArrayOpExpr *node, static void sqlite_deparse_relabel_type(RelabelType *node, deparse_expr_cxt *context); static void sqlite_deparse_bool_expr(BoolExpr *node, deparse_expr_cxt *context); static void sqlite_deparse_null_test(NullTest *node, deparse_expr_cxt *context); +static void sqlite_deparse_case_expr(CaseExpr *node, deparse_expr_cxt *context); static void sqlite_deparse_array_expr(ArrayExpr *node, deparse_expr_cxt *context); static void sqlite_print_remote_param(int paramindex, Oid paramtype, int32 paramtypmod, deparse_expr_cxt *context); @@ -145,6 +148,8 @@ static void sqlite_append_group_by_clause(List *tlist, deparse_expr_cxt *context static void sqlite_append_agg_order_by(List *orderList, List *targetList, deparse_expr_cxt *context); static void sqlite_append_order_by_clause(List *pathkeys, bool has_final_sort, deparse_expr_cxt *context); +static void sqlite_append_order_by_suffix(Oid sortop, Oid sortcoltype, bool nulls_first, + deparse_expr_cxt *context); static void sqlite_append_function_name(Oid funcid, deparse_expr_cxt *context); const char *sqlite_get_jointype_name(JoinType jointype); static Node *sqlite_deparse_sort_group_clause(Index ref, List *tlist, bool force_colno, @@ -162,7 +167,6 @@ static void sqlite_get_relation_column_alias_ids(Var *node, RelOptInfo *foreignr static char *sqlite_quote_identifier(const char *s, char q); static bool sqlite_contain_immutable_functions_walker(Node *node, void *context); static bool sqlite_is_valid_type(Oid type); -static bool sqlite_is_builtin(Oid objectId); /* * Append remote name of specified foreign table to buf. @@ -246,7 +250,7 @@ sqlite_is_foreign_expr(PlannerInfo *root, glob_cxt.relids = baserel->relids; loc_cxt.collation = InvalidOid; loc_cxt.state = FDW_COLLATE_NONE; - if (!sqlite_foreign_expr_walker((Node *) expr, &glob_cxt, &loc_cxt)) + if (!sqlite_foreign_expr_walker((Node *) expr, &glob_cxt, &loc_cxt, NULL)) return false; /* @@ -341,6 +345,32 @@ sqlite_is_valid_type(Oid type) return false; } +/* + * Returns true if it's safe to push down the sort expression described by + * 'pathkey' to the foreign server. + */ +bool +sqlite_is_foreign_pathkey(PlannerInfo *root, + RelOptInfo *baserel, + PathKey *pathkey) +{ + EquivalenceClass *pathkey_ec = pathkey->pk_eclass; + + /* + * is_foreign_expr would detect volatile expressions as well, but checking + * ec_has_volatile here saves some cycles. + */ + if (pathkey_ec->ec_has_volatile) + return false; + + /* can't push down the sort if the pathkey's opfamily is not built-in */ + if (!sqlite_is_builtin(pathkey->pk_opfamily)) + return false; + + /* can push if a suitable EC member exists */ + return (sqlite_find_em_for_rel(root, pathkey_ec, baserel) != NULL); +} + /* * Check if expression is safe to execute remotely, and return true if so. * @@ -356,7 +386,8 @@ sqlite_is_valid_type(Oid type) static bool sqlite_foreign_expr_walker(Node *node, foreign_glob_cxt *glob_cxt, - foreign_loc_cxt *outer_cxt) + foreign_loc_cxt *outer_cxt, + foreign_loc_cxt *case_arg_cxt) { bool check_type = true; foreign_loc_cxt inner_cxt; @@ -453,18 +484,25 @@ sqlite_foreign_expr_walker(Node *node, { CaseTestExpr *c = (CaseTestExpr *) node; - /* - * If the expr has nondefault collation, either it's of a - * non-builtin type, or it reflects folding of a CollateExpr; - * either way, it's unsafe to send to the remote. - */ - if (c->collation != InvalidOid && - c->collation != DEFAULT_COLLATION_OID) + /* Punt if we seem not to be inside a CASE arg WHEN. */ + if (!case_arg_cxt) return false; - /* Otherwise, we can consider that it doesn't set collation */ - collation = InvalidOid; - state = FDW_COLLATE_NONE; + /* + * Otherwise, any nondefault collation attached to the + * CaseTestExpr node must be derived from foreign Var(s) in + * the CASE arg. + */ + collation = c->collation; + if (collation == InvalidOid) + state = FDW_COLLATE_NONE; + else if (case_arg_cxt->state == FDW_COLLATE_SAFE && + collation == case_arg_cxt->collation) + state = FDW_COLLATE_SAFE; + else if (collation == DEFAULT_COLLATION_OID) + state = FDW_COLLATE_NONE; + else + state = FDW_COLLATE_UNSAFE; } break; case T_Param: @@ -541,13 +579,14 @@ sqlite_foreign_expr_walker(Node *node, || strcmp(opername, "replace") == 0 || strcmp(opername, "round") == 0 || strcmp(opername, "rtrim") == 0 - || strcmp(opername, "substr") == 0)) + || strcmp(opername, "substr") == 0 + || strcmp(opername, "mod") == 0)) { return false; } if (!sqlite_foreign_expr_walker((Node *) func->args, - glob_cxt, &inner_cxt)) + glob_cxt, &inner_cxt, case_arg_cxt)) return false; @@ -622,7 +661,7 @@ sqlite_foreign_expr_walker(Node *node, * Recurse to input subexpressions. */ if (!sqlite_foreign_expr_walker((Node *) oe->args, - glob_cxt, &inner_cxt)) + glob_cxt, &inner_cxt, case_arg_cxt)) return false; /* @@ -660,7 +699,7 @@ sqlite_foreign_expr_walker(Node *node, * Recurse to input subexpressions. */ if (!sqlite_foreign_expr_walker((Node *) oe->args, - glob_cxt, &inner_cxt)) + glob_cxt, &inner_cxt, case_arg_cxt)) return false; /* @@ -686,7 +725,7 @@ sqlite_foreign_expr_walker(Node *node, * Recurse to input subexpression. */ if (!sqlite_foreign_expr_walker((Node *) r->arg, - glob_cxt, &inner_cxt)) + glob_cxt, &inner_cxt, case_arg_cxt)) return false; /* @@ -711,7 +750,7 @@ sqlite_foreign_expr_walker(Node *node, * Recurse to input subexpressions. */ if (!sqlite_foreign_expr_walker((Node *) b->args, - glob_cxt, &inner_cxt)) + glob_cxt, &inner_cxt, case_arg_cxt)) return false; /* Output is always boolean and so noncollatable. */ @@ -727,7 +766,7 @@ sqlite_foreign_expr_walker(Node *node, * Recurse to input subexpressions. */ if (!sqlite_foreign_expr_walker((Node *) nt->arg, - glob_cxt, &inner_cxt)) + glob_cxt, &inner_cxt, case_arg_cxt)) return false; /* Output is always boolean and so noncollatable. */ @@ -746,7 +785,7 @@ sqlite_foreign_expr_walker(Node *node, foreach(lc, l) { if (!sqlite_foreign_expr_walker((Node *) lfirst(lc), - glob_cxt, &inner_cxt)) + glob_cxt, &inner_cxt, case_arg_cxt)) return false; } @@ -773,38 +812,103 @@ sqlite_foreign_expr_walker(Node *node, foreach(lc, coalesce->args) { if (!sqlite_foreign_expr_walker((Node *) lfirst(lc), - glob_cxt, &inner_cxt)) + glob_cxt, &inner_cxt, case_arg_cxt)) return false; } } break; case T_CaseExpr: { + CaseExpr *ce = (CaseExpr *) node; + foreign_loc_cxt arg_cxt; + foreign_loc_cxt tmp_cxt; ListCell *lc; - /* Recurse to condition subexpressions. */ - foreach(lc, ((CaseExpr *) node)->args) + /* + * Recurse to CASE's arg expression, if any. Its collation + * has to be saved aside for use while examining CaseTestExprs + * within the WHEN expressions. + */ + arg_cxt.collation = InvalidOid; + arg_cxt.state = FDW_COLLATE_NONE; + if (ce->arg) { - if (!sqlite_foreign_expr_walker((Node *) lfirst(lc), - glob_cxt, &inner_cxt)) + if (!sqlite_foreign_expr_walker((Node *) ce->arg, + glob_cxt, &arg_cxt, case_arg_cxt)) return false; } - } - break; - case T_CaseWhen: - { - CaseWhen *whenExpr = (CaseWhen *) node; - /* Recurse to condition expression. */ - if (!sqlite_foreign_expr_walker((Node *) whenExpr->expr, - glob_cxt, &inner_cxt)) - return false; - /* Recurse to result expression. */ - if (!sqlite_foreign_expr_walker((Node *) whenExpr->result, - glob_cxt, &inner_cxt)) + /* Examine the CaseWhen subexpressions. */ + foreach(lc, ce->args) + { + CaseWhen *cw = lfirst_node(CaseWhen, lc); + + if (ce->arg) + { + /* + * In a CASE-with-arg, the parser should have produced + * WHEN clauses of the form "CaseTestExpr = RHS", + * possibly with an implicit coercion inserted above + * the CaseTestExpr. However in an expression that's + * been through the optimizer, the WHEN clause could + * be almost anything (since the equality operator + * could have been expanded into an inline function). + * In such cases forbid pushdown, because + * deparseCaseExpr can't handle it. + */ + Node *whenExpr = (Node *) cw->expr; + List *opArgs; + + if (!IsA(whenExpr, OpExpr)) + return false; + + opArgs = ((OpExpr *) whenExpr)->args; + if (list_length(opArgs) != 2 || + !IsA(strip_implicit_coercions(linitial(opArgs)), + CaseTestExpr)) + return false; + } + + /* + * Recurse to WHEN expression, passing down the arg info. + * Its collation doesn't affect the result (really, it + * should be boolean and thus not have a collation). + */ + tmp_cxt.collation = InvalidOid; + tmp_cxt.state = FDW_COLLATE_NONE; + if (!sqlite_foreign_expr_walker((Node *) cw->expr, + glob_cxt, &tmp_cxt, &arg_cxt)) + return false; + + /* Recurse to THEN expression. */ + if (!sqlite_foreign_expr_walker((Node *) cw->result, + glob_cxt, &inner_cxt, case_arg_cxt)) + return false; + } + + /* Recurse to ELSE expression. */ + if (!sqlite_foreign_expr_walker((Node *) ce->defresult, + glob_cxt, &inner_cxt, case_arg_cxt)) return false; - /* Don't apply exprType() to the case when expr. */ - check_type = false; + + /* + * Detect whether node is introducing a collation not derived + * from a foreign Var. (If so, we just mark it unsafe for now + * rather than immediately returning false, since the parent + * node might not care.) This is the same as for function + * nodes, except that the input collation is derived from only + * the THEN and ELSE subexpressions. + */ + collation = ce->casecollid; + if (collation == InvalidOid) + state = FDW_COLLATE_NONE; + else if (inner_cxt.state == FDW_COLLATE_SAFE && + collation == inner_cxt.collation) + state = FDW_COLLATE_SAFE; + else if (collation == DEFAULT_COLLATION_OID) + state = FDW_COLLATE_NONE; + else + state = FDW_COLLATE_UNSAFE; } break; case T_Aggref: @@ -864,7 +968,7 @@ sqlite_foreign_expr_walker(Node *node, n = (Node *) tle->expr; } - if (!sqlite_foreign_expr_walker(n, glob_cxt, &inner_cxt)) + if (!sqlite_foreign_expr_walker(n, glob_cxt, &inner_cxt, case_arg_cxt)) return false; } @@ -909,7 +1013,7 @@ sqlite_foreign_expr_walker(Node *node, * Recurse to input subexpressions. */ if (!sqlite_foreign_expr_walker((Node *) a->elements, - glob_cxt, &inner_cxt)) + glob_cxt, &inner_cxt, case_arg_cxt)) return false; /* @@ -2990,7 +3094,7 @@ sqlite_deparse_array_expr(ArrayExpr *node, deparse_expr_cxt *context) } /* - * Deparse given CASE expression + * Deparse CASE expression */ static void sqlite_deparse_case_expr(CaseExpr *node, deparse_expr_cxt *context) @@ -3000,11 +3104,11 @@ sqlite_deparse_case_expr(CaseExpr *node, deparse_expr_cxt *context) appendStringInfoString(buf, "CASE "); - /* If CASE arg WHEN then appen arg before continuing */ + /* If this is a CASE arg WHEN then emit the arg expression */ if (node->arg != NULL) sqlite_deparse_expr(node->arg, context); - /* Add individual cases */ + /* Add each condition/result of the CASE clause */ foreach(lc, node->args) { CaseWhen *whenclause = (CaseWhen *) lfirst(lc); @@ -3014,14 +3118,18 @@ sqlite_deparse_case_expr(CaseExpr *node, deparse_expr_cxt *context) if (node->arg == NULL) /* CASE WHEN */ sqlite_deparse_expr(whenclause->expr, context); else /* CASE arg WHEN */ - sqlite_deparse_expr(lsecond(((OpExpr *) whenclause->expr)->args), context); + { + /* Ignore the CaseTestExpr and equality operator. */ + sqlite_deparse_expr(lsecond(castNode(OpExpr, whenclause->expr)->args), + context); + } /* THEN */ appendStringInfoString(buf, " THEN "); sqlite_deparse_expr(whenclause->result, context); } - /* add ELSE if needed */ + /* add ELSE if present */ if (node->defresult != NULL) { appendStringInfoString(buf, " ELSE "); @@ -3113,10 +3221,14 @@ sqlite_print_remote_placeholder(Oid paramtype, int32 paramtypmod, * be known to the remote server, if it's of an older version. But keeping * track of that would be a huge exercise. */ -static bool +bool sqlite_is_builtin(Oid oid) { +#if PG_VERSION_NUM >= 120000 + return (oid < FirstGenbkiObjectId); +#else return (oid < FirstBootstrapObjectId); +#endif } /* @@ -3265,58 +3377,34 @@ sqlite_append_agg_order_by(List *orderList, List *targetList, deparse_expr_cxt * { SortGroupClause *srt = (SortGroupClause *) lfirst(lc); Node *sortexpr; - Oid sortcoltype; - TypeCacheEntry *typentry; if (!first) appendStringInfoString(buf, ", "); first = false; + /* Deparse the sort expression proper. */ sortexpr = sqlite_deparse_sort_group_clause(srt->tleSortGroupRef, targetList, false, context); - sortcoltype = exprType(sortexpr); - /* See whether operator is default < or > for datatype */ - typentry = lookup_type_cache(sortcoltype, - TYPECACHE_LT_OPR | TYPECACHE_GT_OPR); - if (srt->sortop == typentry->lt_opr) - appendStringInfoString(buf, " ASC"); - else if (srt->sortop == typentry->gt_opr) - appendStringInfoString(buf, " DESC"); - else - { - HeapTuple opertup; - Form_pg_operator operform; - - appendStringInfoString(buf, " USING "); - - /* Append operator name. */ - opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(srt->sortop)); - if (!HeapTupleIsValid(opertup)) - elog(ERROR, "cache lookup failed for operator %u", srt->sortop); - operform = (Form_pg_operator) GETSTRUCT(opertup); - sqlite_deparse_operator_name(buf, operform); - ReleaseSysCache(opertup); - } - - if (srt->nulls_first) - appendStringInfoString(buf, " NULLS FIRST"); - else - appendStringInfoString(buf, " NULLS LAST"); + /* Add decoration as needed. */ + sqlite_append_order_by_suffix(srt->sortop, exprType(sortexpr), srt->nulls_first, context); } } /* - * Deparse ORDER BY clause according to the given pathkeys for given base - * relation. From given pathkeys expressions belonging entirely to the given - * base relation are obtained and deparsed. + * Deparse ORDER BY clause defined by the given pathkeys. + * + * The clause should use Vars from context->scanrel if !has_final_sort, + * or from context->foreignrel's targetlist if has_final_sort. + * + * We find a suitable pathkey expression (some earlier step + * should have verified that there is one) and deparse it. */ static void sqlite_append_order_by_clause(List *pathkeys, bool has_final_sort, deparse_expr_cxt *context) { ListCell *lcell; int nestlevel; - char *delim = " "; - RelOptInfo *baserel = context->scanrel; + const char *delim = " "; StringInfo buf = context->buf; /* Make sure any constants in the exprs are printed portably */ @@ -3329,28 +3417,52 @@ sqlite_append_order_by_clause(List *pathkeys, bool has_final_sort, deparse_expr_ Expr *em_expr; int sqliteVersion = sqlite3_libversion_number(); + EquivalenceMember *em; + Oid oprid; if (has_final_sort) { /* * By construction, context->foreignrel is the input relation to * the final sort. */ - em_expr = sqlite_find_em_expr_for_input_target(context->root, + em = sqlite_find_em_for_rel_target(context->root, pathkey->pk_eclass, - context->foreignrel->reltarget, - baserel); + context->foreignrel); } else - em_expr = sqlite_find_em_expr_for_rel(pathkey->pk_eclass, baserel); + em = sqlite_find_em_for_rel(context->root, pathkey->pk_eclass, context->scanrel); + /* + * We don't expect any error here; it would mean that shippability + * wasn't verified earlier. For the same reason, we don't recheck + * shippability of the sort operator. + */ + if (em == NULL) + elog(ERROR, "could not find pathkey item to sort"); + + em_expr = em->em_expr; - Assert(em_expr != NULL); + /* + * Lookup the operator corresponding to the strategy in the opclass. + * The datatype used by the opfamily is not necessarily the same as + * the expression type (for array types for example). + */ + oprid = get_opfamily_member(pathkey->pk_opfamily, + em->em_datatype, + em->em_datatype, + pathkey->pk_strategy); + if (!OidIsValid(oprid)) + elog(ERROR, "missing operator %d(%u,%u) in opfamily %u", + pathkey->pk_strategy, em->em_datatype, em->em_datatype, + pathkey->pk_opfamily); appendStringInfoString(buf, delim); sqlite_deparse_expr(em_expr, context); - if (pathkey->pk_strategy == BTLessStrategyNumber) - appendStringInfoString(buf, " ASC"); - else - appendStringInfoString(buf, " DESC"); + /* + * Here we need to use the expression's actual type to discover + * whether the desired operator will be the default or not. + */ + sqlite_append_order_by_suffix(oprid, exprType((Node *) em_expr), + pathkey->pk_nulls_first, context); /* * In SQLITE3 Release v3.30.0 (2019-10-04) NULLS FIRST/LAST is @@ -3358,14 +3470,7 @@ sqlite_append_order_by_clause(List *pathkeys, bool has_final_sort, deparse_expr_ * https://www.sqlite.org/changes.html * https://www.sqlite.org/lang_select.html#orderby */ - if (sqliteVersion >= 3030000) - { - if (pathkey->pk_nulls_first) - appendStringInfoString(buf, " NULLS FIRST"); - else - appendStringInfoString(buf, " NULLS LAST"); - } - else + if (sqliteVersion < 3030000) { /* * If we need a different behaviour than SQLite default...we show @@ -3377,12 +3482,52 @@ sqlite_append_order_by_clause(List *pathkeys, bool has_final_sort, deparse_expr_ else if (pathkey->pk_nulls_first && pathkey->pk_strategy != BTLessStrategyNumber) elog(WARNING, "Current Sqlite Version (%d) does not support NULLS FIRST for ORDER BY DESC, degraded emitted query to ORDER BY DESC NULLS LAST (default sqlite behaviour).", sqliteVersion); } - delim = ", "; } sqlite_reset_transmission_modes(nestlevel); } +/* + * Append the ASC, DESC, USING and NULLS FIRST / NULLS LAST parts + * of an ORDER BY clause. + */ +static void sqlite_append_order_by_suffix(Oid sortop, Oid sortcoltype, + bool nulls_first, + deparse_expr_cxt *context) +{ + StringInfo buf = context->buf; + TypeCacheEntry *typentry; + + /* See whether operator is default < or > for sort expr's datatype. */ + typentry = lookup_type_cache(sortcoltype, + TYPECACHE_LT_OPR | TYPECACHE_GT_OPR); + + if (sortop == typentry->lt_opr) + appendStringInfoString(buf, " ASC"); + else if (sortop == typentry->gt_opr) + appendStringInfoString(buf, " DESC"); + else + { + HeapTuple opertup; + Form_pg_operator operform; + + appendStringInfoString(buf, " USING "); + + /* Append operator name. */ + opertup = SearchSysCache1(OPEROID, ObjectIdGetDatum(sortop)); + if (!HeapTupleIsValid(opertup)) + elog(ERROR, "cache lookup failed for operator %u", sortop); + operform = (Form_pg_operator) GETSTRUCT(opertup); + sqlite_deparse_operator_name(buf, operform); + ReleaseSysCache(opertup); + } + + if (nulls_first) + appendStringInfoString(buf, " NULLS FIRST"); + else + appendStringInfoString(buf, " NULLS LAST"); +} + /* * Deparse LIMIT/OFFSET clause. */ @@ -3698,7 +3843,7 @@ sqlite_is_foreign_function_tlist(PlannerInfo *root, loc_cxt.collation = InvalidOid; loc_cxt.state = FDW_COLLATE_NONE; - if (!sqlite_foreign_expr_walker((Node *) tle->expr, &glob_cxt, &loc_cxt)) + if (!sqlite_foreign_expr_walker((Node *) tle->expr, &glob_cxt, &loc_cxt, NULL)) return false; /* diff --git a/expected/10.18/extra/numeric.out b/expected/10.18/extra/numeric.out deleted file mode 100644 index 113f7dd0..00000000 --- a/expected/10.18/extra/numeric.out +++ /dev/null @@ -1,3822 +0,0 @@ --- --- NUMERIC --- ---Testcase 567: -CREATE EXTENSION sqlite_fdw; ---Testcase 568: -CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw -OPTIONS (database '/tmp/sqlitefdw_test_core.db'); ---Testcase 569: -CREATE FOREIGN TABLE num_data (id int4 OPTIONS (key 'true'), val numeric(210,10)) SERVER sqlite_svr; ---Testcase 570: -CREATE FOREIGN TABLE num_exp_add (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; ---Testcase 571: -CREATE FOREIGN TABLE num_exp_sub (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; ---Testcase 572: -CREATE FOREIGN TABLE num_exp_div (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; ---Testcase 573: -CREATE FOREIGN TABLE num_exp_mul (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; ---Testcase 574: -CREATE FOREIGN TABLE num_exp_sqrt (id int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; ---Testcase 575: -CREATE FOREIGN TABLE num_exp_ln (id int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; ---Testcase 576: -CREATE FOREIGN TABLE num_exp_log10 (id int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; ---Testcase 577: -CREATE FOREIGN TABLE num_exp_power_10_ln (id int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; ---Testcase 578: -CREATE FOREIGN TABLE num_result (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), result numeric(210,10)) SERVER sqlite_svr; --- ****************************** --- * The following EXPECTED results are computed by bc(1) --- * with a scale of 200 --- ****************************** -BEGIN TRANSACTION; ---Testcase 1: -INSERT INTO num_exp_add VALUES (0,0,'0'); ---Testcase 2: -INSERT INTO num_exp_sub VALUES (0,0,'0'); ---Testcase 3: -INSERT INTO num_exp_mul VALUES (0,0,'0'); ---Testcase 4: -INSERT INTO num_exp_div VALUES (0,0,'NaN'); ---Testcase 5: -INSERT INTO num_exp_add VALUES (0,1,'0'); ---Testcase 6: -INSERT INTO num_exp_sub VALUES (0,1,'0'); ---Testcase 7: -INSERT INTO num_exp_mul VALUES (0,1,'0'); ---Testcase 8: -INSERT INTO num_exp_div VALUES (0,1,'NaN'); ---Testcase 9: -INSERT INTO num_exp_add VALUES (0,2,'-34338492.215397047'); ---Testcase 10: -INSERT INTO num_exp_sub VALUES (0,2,'34338492.215397047'); ---Testcase 11: -INSERT INTO num_exp_mul VALUES (0,2,'0'); ---Testcase 12: -INSERT INTO num_exp_div VALUES (0,2,'0'); ---Testcase 13: -INSERT INTO num_exp_add VALUES (0,3,'4.31'); ---Testcase 14: -INSERT INTO num_exp_sub VALUES (0,3,'-4.31'); ---Testcase 15: -INSERT INTO num_exp_mul VALUES (0,3,'0'); ---Testcase 16: -INSERT INTO num_exp_div VALUES (0,3,'0'); ---Testcase 17: -INSERT INTO num_exp_add VALUES (0,4,'7799461.4119'); ---Testcase 18: -INSERT INTO num_exp_sub VALUES (0,4,'-7799461.4119'); ---Testcase 19: -INSERT INTO num_exp_mul VALUES (0,4,'0'); ---Testcase 20: -INSERT INTO num_exp_div VALUES (0,4,'0'); ---Testcase 21: -INSERT INTO num_exp_add VALUES (0,5,'16397.038491'); ---Testcase 22: -INSERT INTO num_exp_sub VALUES (0,5,'-16397.038491'); ---Testcase 23: -INSERT INTO num_exp_mul VALUES (0,5,'0'); ---Testcase 24: -INSERT INTO num_exp_div VALUES (0,5,'0'); ---Testcase 25: -INSERT INTO num_exp_add VALUES (0,6,'93901.57763026'); ---Testcase 26: -INSERT INTO num_exp_sub VALUES (0,6,'-93901.57763026'); ---Testcase 27: -INSERT INTO num_exp_mul VALUES (0,6,'0'); ---Testcase 28: -INSERT INTO num_exp_div VALUES (0,6,'0'); ---Testcase 29: -INSERT INTO num_exp_add VALUES (0,7,'-83028485'); ---Testcase 30: -INSERT INTO num_exp_sub VALUES (0,7,'83028485'); ---Testcase 31: -INSERT INTO num_exp_mul VALUES (0,7,'0'); ---Testcase 32: -INSERT INTO num_exp_div VALUES (0,7,'0'); ---Testcase 33: -INSERT INTO num_exp_add VALUES (0,8,'74881'); ---Testcase 34: -INSERT INTO num_exp_sub VALUES (0,8,'-74881'); ---Testcase 35: -INSERT INTO num_exp_mul VALUES (0,8,'0'); ---Testcase 36: -INSERT INTO num_exp_div VALUES (0,8,'0'); ---Testcase 37: -INSERT INTO num_exp_add VALUES (0,9,'-24926804.045047420'); ---Testcase 38: -INSERT INTO num_exp_sub VALUES (0,9,'24926804.045047420'); ---Testcase 39: -INSERT INTO num_exp_mul VALUES (0,9,'0'); ---Testcase 40: -INSERT INTO num_exp_div VALUES (0,9,'0'); ---Testcase 41: -INSERT INTO num_exp_add VALUES (1,0,'0'); ---Testcase 42: -INSERT INTO num_exp_sub VALUES (1,0,'0'); ---Testcase 43: -INSERT INTO num_exp_mul VALUES (1,0,'0'); ---Testcase 44: -INSERT INTO num_exp_div VALUES (1,0,'NaN'); ---Testcase 45: -INSERT INTO num_exp_add VALUES (1,1,'0'); ---Testcase 46: -INSERT INTO num_exp_sub VALUES (1,1,'0'); ---Testcase 47: -INSERT INTO num_exp_mul VALUES (1,1,'0'); ---Testcase 48: -INSERT INTO num_exp_div VALUES (1,1,'NaN'); ---Testcase 49: -INSERT INTO num_exp_add VALUES (1,2,'-34338492.215397047'); ---Testcase 50: -INSERT INTO num_exp_sub VALUES (1,2,'34338492.215397047'); ---Testcase 51: -INSERT INTO num_exp_mul VALUES (1,2,'0'); ---Testcase 52: -INSERT INTO num_exp_div VALUES (1,2,'0'); ---Testcase 53: -INSERT INTO num_exp_add VALUES (1,3,'4.31'); ---Testcase 54: -INSERT INTO num_exp_sub VALUES (1,3,'-4.31'); ---Testcase 55: -INSERT INTO num_exp_mul VALUES (1,3,'0'); ---Testcase 56: -INSERT INTO num_exp_div VALUES (1,3,'0'); ---Testcase 57: -INSERT INTO num_exp_add VALUES (1,4,'7799461.4119'); ---Testcase 58: -INSERT INTO num_exp_sub VALUES (1,4,'-7799461.4119'); ---Testcase 59: -INSERT INTO num_exp_mul VALUES (1,4,'0'); ---Testcase 60: -INSERT INTO num_exp_div VALUES (1,4,'0'); ---Testcase 61: -INSERT INTO num_exp_add VALUES (1,5,'16397.038491'); ---Testcase 62: -INSERT INTO num_exp_sub VALUES (1,5,'-16397.038491'); ---Testcase 63: -INSERT INTO num_exp_mul VALUES (1,5,'0'); ---Testcase 64: -INSERT INTO num_exp_div VALUES (1,5,'0'); ---Testcase 65: -INSERT INTO num_exp_add VALUES (1,6,'93901.57763026'); ---Testcase 66: -INSERT INTO num_exp_sub VALUES (1,6,'-93901.57763026'); ---Testcase 67: -INSERT INTO num_exp_mul VALUES (1,6,'0'); ---Testcase 68: -INSERT INTO num_exp_div VALUES (1,6,'0'); ---Testcase 69: -INSERT INTO num_exp_add VALUES (1,7,'-83028485'); ---Testcase 70: -INSERT INTO num_exp_sub VALUES (1,7,'83028485'); ---Testcase 71: -INSERT INTO num_exp_mul VALUES (1,7,'0'); ---Testcase 72: -INSERT INTO num_exp_div VALUES (1,7,'0'); ---Testcase 73: -INSERT INTO num_exp_add VALUES (1,8,'74881'); ---Testcase 74: -INSERT INTO num_exp_sub VALUES (1,8,'-74881'); ---Testcase 75: -INSERT INTO num_exp_mul VALUES (1,8,'0'); ---Testcase 76: -INSERT INTO num_exp_div VALUES (1,8,'0'); ---Testcase 77: -INSERT INTO num_exp_add VALUES (1,9,'-24926804.045047420'); ---Testcase 78: -INSERT INTO num_exp_sub VALUES (1,9,'24926804.045047420'); ---Testcase 79: -INSERT INTO num_exp_mul VALUES (1,9,'0'); ---Testcase 80: -INSERT INTO num_exp_div VALUES (1,9,'0'); ---Testcase 81: -INSERT INTO num_exp_add VALUES (2,0,'-34338492.215397047'); ---Testcase 82: -INSERT INTO num_exp_sub VALUES (2,0,'-34338492.215397047'); ---Testcase 83: -INSERT INTO num_exp_mul VALUES (2,0,'0'); ---Testcase 84: -INSERT INTO num_exp_div VALUES (2,0,'NaN'); ---Testcase 85: -INSERT INTO num_exp_add VALUES (2,1,'-34338492.215397047'); ---Testcase 86: -INSERT INTO num_exp_sub VALUES (2,1,'-34338492.215397047'); ---Testcase 87: -INSERT INTO num_exp_mul VALUES (2,1,'0'); ---Testcase 88: -INSERT INTO num_exp_div VALUES (2,1,'NaN'); ---Testcase 89: -INSERT INTO num_exp_add VALUES (2,2,'-68676984.430794094'); ---Testcase 90: -INSERT INTO num_exp_sub VALUES (2,2,'0'); ---Testcase 91: -INSERT INTO num_exp_mul VALUES (2,2,'1179132047626883.596862135856320209'); ---Testcase 92: -INSERT INTO num_exp_div VALUES (2,2,'1.00000000000000000000'); ---Testcase 93: -INSERT INTO num_exp_add VALUES (2,3,'-34338487.905397047'); ---Testcase 94: -INSERT INTO num_exp_sub VALUES (2,3,'-34338496.525397047'); ---Testcase 95: -INSERT INTO num_exp_mul VALUES (2,3,'-147998901.44836127257'); ---Testcase 96: -INSERT INTO num_exp_div VALUES (2,3,'-7967167.56737750510440835266'); ---Testcase 97: -INSERT INTO num_exp_add VALUES (2,4,'-26539030.803497047'); ---Testcase 98: -INSERT INTO num_exp_sub VALUES (2,4,'-42137953.627297047'); ---Testcase 99: -INSERT INTO num_exp_mul VALUES (2,4,'-267821744976817.8111137106593'); ---Testcase 100: -INSERT INTO num_exp_div VALUES (2,4,'-4.40267480046830116685'); ---Testcase 101: -INSERT INTO num_exp_add VALUES (2,5,'-34322095.176906047'); ---Testcase 102: -INSERT INTO num_exp_sub VALUES (2,5,'-34354889.253888047'); ---Testcase 103: -INSERT INTO num_exp_mul VALUES (2,5,'-563049578578.769242506736077'); ---Testcase 104: -INSERT INTO num_exp_div VALUES (2,5,'-2094.18866914563535496429'); ---Testcase 105: -INSERT INTO num_exp_add VALUES (2,6,'-34244590.637766787'); ---Testcase 106: -INSERT INTO num_exp_sub VALUES (2,6,'-34432393.793027307'); ---Testcase 107: -INSERT INTO num_exp_mul VALUES (2,6,'-3224438592470.18449811926184222'); ---Testcase 108: -INSERT INTO num_exp_div VALUES (2,6,'-365.68599891479766440940'); ---Testcase 109: -INSERT INTO num_exp_add VALUES (2,7,'-117366977.215397047'); ---Testcase 110: -INSERT INTO num_exp_sub VALUES (2,7,'48689992.784602953'); ---Testcase 111: -INSERT INTO num_exp_mul VALUES (2,7,'2851072985828710.485883795'); ---Testcase 112: -INSERT INTO num_exp_div VALUES (2,7,'.41357483778485235518'); ---Testcase 113: -INSERT INTO num_exp_add VALUES (2,8,'-34263611.215397047'); ---Testcase 114: -INSERT INTO num_exp_sub VALUES (2,8,'-34413373.215397047'); ---Testcase 115: -INSERT INTO num_exp_mul VALUES (2,8,'-2571300635581.146276407'); ---Testcase 116: -INSERT INTO num_exp_div VALUES (2,8,'-458.57416721727870888476'); ---Testcase 117: -INSERT INTO num_exp_add VALUES (2,9,'-59265296.260444467'); ---Testcase 118: -INSERT INTO num_exp_sub VALUES (2,9,'-9411688.170349627'); ---Testcase 119: -INSERT INTO num_exp_mul VALUES (2,9,'855948866655588.453741509242968740'); ---Testcase 120: -INSERT INTO num_exp_div VALUES (2,9,'1.37757299946438931811'); ---Testcase 121: -INSERT INTO num_exp_add VALUES (3,0,'4.31'); ---Testcase 122: -INSERT INTO num_exp_sub VALUES (3,0,'4.31'); ---Testcase 123: -INSERT INTO num_exp_mul VALUES (3,0,'0'); ---Testcase 124: -INSERT INTO num_exp_div VALUES (3,0,'NaN'); ---Testcase 125: -INSERT INTO num_exp_add VALUES (3,1,'4.31'); ---Testcase 126: -INSERT INTO num_exp_sub VALUES (3,1,'4.31'); ---Testcase 127: -INSERT INTO num_exp_mul VALUES (3,1,'0'); ---Testcase 128: -INSERT INTO num_exp_div VALUES (3,1,'NaN'); ---Testcase 129: -INSERT INTO num_exp_add VALUES (3,2,'-34338487.905397047'); ---Testcase 130: -INSERT INTO num_exp_sub VALUES (3,2,'34338496.525397047'); ---Testcase 131: -INSERT INTO num_exp_mul VALUES (3,2,'-147998901.44836127257'); ---Testcase 132: -INSERT INTO num_exp_div VALUES (3,2,'-.00000012551512084352'); ---Testcase 133: -INSERT INTO num_exp_add VALUES (3,3,'8.62'); ---Testcase 134: -INSERT INTO num_exp_sub VALUES (3,3,'0'); ---Testcase 135: -INSERT INTO num_exp_mul VALUES (3,3,'18.5761'); ---Testcase 136: -INSERT INTO num_exp_div VALUES (3,3,'1.00000000000000000000'); ---Testcase 137: -INSERT INTO num_exp_add VALUES (3,4,'7799465.7219'); ---Testcase 138: -INSERT INTO num_exp_sub VALUES (3,4,'-7799457.1019'); ---Testcase 139: -INSERT INTO num_exp_mul VALUES (3,4,'33615678.685289'); ---Testcase 140: -INSERT INTO num_exp_div VALUES (3,4,'.00000055260225961552'); ---Testcase 141: -INSERT INTO num_exp_add VALUES (3,5,'16401.348491'); ---Testcase 142: -INSERT INTO num_exp_sub VALUES (3,5,'-16392.728491'); ---Testcase 143: -INSERT INTO num_exp_mul VALUES (3,5,'70671.23589621'); ---Testcase 144: -INSERT INTO num_exp_div VALUES (3,5,'.00026285234387695504'); ---Testcase 145: -INSERT INTO num_exp_add VALUES (3,6,'93905.88763026'); ---Testcase 146: -INSERT INTO num_exp_sub VALUES (3,6,'-93897.26763026'); ---Testcase 147: -INSERT INTO num_exp_mul VALUES (3,6,'404715.7995864206'); ---Testcase 148: -INSERT INTO num_exp_div VALUES (3,6,'.00004589912234457595'); ---Testcase 149: -INSERT INTO num_exp_add VALUES (3,7,'-83028480.69'); ---Testcase 150: -INSERT INTO num_exp_sub VALUES (3,7,'83028489.31'); ---Testcase 151: -INSERT INTO num_exp_mul VALUES (3,7,'-357852770.35'); ---Testcase 152: -INSERT INTO num_exp_div VALUES (3,7,'-.00000005190989574240'); ---Testcase 153: -INSERT INTO num_exp_add VALUES (3,8,'74885.31'); ---Testcase 154: -INSERT INTO num_exp_sub VALUES (3,8,'-74876.69'); ---Testcase 155: -INSERT INTO num_exp_mul VALUES (3,8,'322737.11'); ---Testcase 156: -INSERT INTO num_exp_div VALUES (3,8,'.00005755799201399553'); ---Testcase 157: -INSERT INTO num_exp_add VALUES (3,9,'-24926799.735047420'); ---Testcase 158: -INSERT INTO num_exp_sub VALUES (3,9,'24926808.355047420'); ---Testcase 159: -INSERT INTO num_exp_mul VALUES (3,9,'-107434525.43415438020'); ---Testcase 160: -INSERT INTO num_exp_div VALUES (3,9,'-.00000017290624149854'); ---Testcase 161: -INSERT INTO num_exp_add VALUES (4,0,'7799461.4119'); ---Testcase 162: -INSERT INTO num_exp_sub VALUES (4,0,'7799461.4119'); ---Testcase 163: -INSERT INTO num_exp_mul VALUES (4,0,'0'); ---Testcase 164: -INSERT INTO num_exp_div VALUES (4,0,'NaN'); ---Testcase 165: -INSERT INTO num_exp_add VALUES (4,1,'7799461.4119'); ---Testcase 166: -INSERT INTO num_exp_sub VALUES (4,1,'7799461.4119'); ---Testcase 167: -INSERT INTO num_exp_mul VALUES (4,1,'0'); ---Testcase 168: -INSERT INTO num_exp_div VALUES (4,1,'NaN'); ---Testcase 169: -INSERT INTO num_exp_add VALUES (4,2,'-26539030.803497047'); ---Testcase 170: -INSERT INTO num_exp_sub VALUES (4,2,'42137953.627297047'); ---Testcase 171: -INSERT INTO num_exp_mul VALUES (4,2,'-267821744976817.8111137106593'); ---Testcase 172: -INSERT INTO num_exp_div VALUES (4,2,'-.22713465002993920385'); ---Testcase 173: -INSERT INTO num_exp_add VALUES (4,3,'7799465.7219'); ---Testcase 174: -INSERT INTO num_exp_sub VALUES (4,3,'7799457.1019'); ---Testcase 175: -INSERT INTO num_exp_mul VALUES (4,3,'33615678.685289'); ---Testcase 176: -INSERT INTO num_exp_div VALUES (4,3,'1809619.81714617169373549883'); ---Testcase 177: -INSERT INTO num_exp_add VALUES (4,4,'15598922.8238'); ---Testcase 178: -INSERT INTO num_exp_sub VALUES (4,4,'0'); ---Testcase 179: -INSERT INTO num_exp_mul VALUES (4,4,'60831598315717.14146161'); ---Testcase 180: -INSERT INTO num_exp_div VALUES (4,4,'1.00000000000000000000'); ---Testcase 181: -INSERT INTO num_exp_add VALUES (4,5,'7815858.450391'); ---Testcase 182: -INSERT INTO num_exp_sub VALUES (4,5,'7783064.373409'); ---Testcase 183: -INSERT INTO num_exp_mul VALUES (4,5,'127888068979.9935054429'); ---Testcase 184: -INSERT INTO num_exp_div VALUES (4,5,'475.66281046305802686061'); ---Testcase 185: -INSERT INTO num_exp_add VALUES (4,6,'7893362.98953026'); ---Testcase 186: -INSERT INTO num_exp_sub VALUES (4,6,'7705559.83426974'); ---Testcase 187: -INSERT INTO num_exp_mul VALUES (4,6,'732381731243.745115764094'); ---Testcase 188: -INSERT INTO num_exp_div VALUES (4,6,'83.05996138436129499606'); ---Testcase 189: -INSERT INTO num_exp_add VALUES (4,7,'-75229023.5881'); ---Testcase 190: -INSERT INTO num_exp_sub VALUES (4,7,'90827946.4119'); ---Testcase 191: -INSERT INTO num_exp_mul VALUES (4,7,'-647577464846017.9715'); ---Testcase 192: -INSERT INTO num_exp_div VALUES (4,7,'-.09393717604145131637'); ---Testcase 193: -INSERT INTO num_exp_add VALUES (4,8,'7874342.4119'); ---Testcase 194: -INSERT INTO num_exp_sub VALUES (4,8,'7724580.4119'); ---Testcase 195: -INSERT INTO num_exp_mul VALUES (4,8,'584031469984.4839'); ---Testcase 196: -INSERT INTO num_exp_div VALUES (4,8,'104.15808298366741897143'); ---Testcase 197: -INSERT INTO num_exp_add VALUES (4,9,'-17127342.633147420'); ---Testcase 198: -INSERT INTO num_exp_sub VALUES (4,9,'32726265.456947420'); ---Testcase 199: -INSERT INTO num_exp_mul VALUES (4,9,'-194415646271340.1815956522980'); ---Testcase 200: -INSERT INTO num_exp_div VALUES (4,9,'-.31289456112403769409'); ---Testcase 201: -INSERT INTO num_exp_add VALUES (5,0,'16397.038491'); ---Testcase 202: -INSERT INTO num_exp_sub VALUES (5,0,'16397.038491'); ---Testcase 203: -INSERT INTO num_exp_mul VALUES (5,0,'0'); ---Testcase 204: -INSERT INTO num_exp_div VALUES (5,0,'NaN'); ---Testcase 205: -INSERT INTO num_exp_add VALUES (5,1,'16397.038491'); ---Testcase 206: -INSERT INTO num_exp_sub VALUES (5,1,'16397.038491'); ---Testcase 207: -INSERT INTO num_exp_mul VALUES (5,1,'0'); ---Testcase 208: -INSERT INTO num_exp_div VALUES (5,1,'NaN'); ---Testcase 209: -INSERT INTO num_exp_add VALUES (5,2,'-34322095.176906047'); ---Testcase 210: -INSERT INTO num_exp_sub VALUES (5,2,'34354889.253888047'); ---Testcase 211: -INSERT INTO num_exp_mul VALUES (5,2,'-563049578578.769242506736077'); ---Testcase 212: -INSERT INTO num_exp_div VALUES (5,2,'-.00047751189505192446'); ---Testcase 213: -INSERT INTO num_exp_add VALUES (5,3,'16401.348491'); ---Testcase 214: -INSERT INTO num_exp_sub VALUES (5,3,'16392.728491'); ---Testcase 215: -INSERT INTO num_exp_mul VALUES (5,3,'70671.23589621'); ---Testcase 216: -INSERT INTO num_exp_div VALUES (5,3,'3804.41728329466357308584'); ---Testcase 217: -INSERT INTO num_exp_add VALUES (5,4,'7815858.450391'); ---Testcase 218: -INSERT INTO num_exp_sub VALUES (5,4,'-7783064.373409'); ---Testcase 219: -INSERT INTO num_exp_mul VALUES (5,4,'127888068979.9935054429'); ---Testcase 220: -INSERT INTO num_exp_div VALUES (5,4,'.00210232958726897192'); ---Testcase 221: -INSERT INTO num_exp_add VALUES (5,5,'32794.076982'); ---Testcase 222: -INSERT INTO num_exp_sub VALUES (5,5,'0'); ---Testcase 223: -INSERT INTO num_exp_mul VALUES (5,5,'268862871.275335557081'); ---Testcase 224: -INSERT INTO num_exp_div VALUES (5,5,'1.00000000000000000000'); ---Testcase 225: -INSERT INTO num_exp_add VALUES (5,6,'110298.61612126'); ---Testcase 226: -INSERT INTO num_exp_sub VALUES (5,6,'-77504.53913926'); ---Testcase 227: -INSERT INTO num_exp_mul VALUES (5,6,'1539707782.76899778633766'); ---Testcase 228: -INSERT INTO num_exp_div VALUES (5,6,'.17461941433576102689'); ---Testcase 229: -INSERT INTO num_exp_add VALUES (5,7,'-83012087.961509'); ---Testcase 230: -INSERT INTO num_exp_sub VALUES (5,7,'83044882.038491'); ---Testcase 231: -INSERT INTO num_exp_mul VALUES (5,7,'-1361421264394.416135'); ---Testcase 232: -INSERT INTO num_exp_div VALUES (5,7,'-.00019748690453643710'); ---Testcase 233: -INSERT INTO num_exp_add VALUES (5,8,'91278.038491'); ---Testcase 234: -INSERT INTO num_exp_sub VALUES (5,8,'-58483.961509'); ---Testcase 235: -INSERT INTO num_exp_mul VALUES (5,8,'1227826639.244571'); ---Testcase 236: -INSERT INTO num_exp_div VALUES (5,8,'.21897461960978085228'); ---Testcase 237: -INSERT INTO num_exp_add VALUES (5,9,'-24910407.006556420'); ---Testcase 238: -INSERT INTO num_exp_sub VALUES (5,9,'24943201.083538420'); ---Testcase 239: -INSERT INTO num_exp_mul VALUES (5,9,'-408725765384.257043660243220'); ---Testcase 240: -INSERT INTO num_exp_div VALUES (5,9,'-.00065780749354660427'); ---Testcase 241: -INSERT INTO num_exp_add VALUES (6,0,'93901.57763026'); ---Testcase 242: -INSERT INTO num_exp_sub VALUES (6,0,'93901.57763026'); ---Testcase 243: -INSERT INTO num_exp_mul VALUES (6,0,'0'); ---Testcase 244: -INSERT INTO num_exp_div VALUES (6,0,'NaN'); ---Testcase 245: -INSERT INTO num_exp_add VALUES (6,1,'93901.57763026'); ---Testcase 246: -INSERT INTO num_exp_sub VALUES (6,1,'93901.57763026'); ---Testcase 247: -INSERT INTO num_exp_mul VALUES (6,1,'0'); ---Testcase 248: -INSERT INTO num_exp_div VALUES (6,1,'NaN'); ---Testcase 249: -INSERT INTO num_exp_add VALUES (6,2,'-34244590.637766787'); ---Testcase 250: -INSERT INTO num_exp_sub VALUES (6,2,'34432393.793027307'); ---Testcase 251: -INSERT INTO num_exp_mul VALUES (6,2,'-3224438592470.18449811926184222'); ---Testcase 252: -INSERT INTO num_exp_div VALUES (6,2,'-.00273458651128995823'); ---Testcase 253: -INSERT INTO num_exp_add VALUES (6,3,'93905.88763026'); ---Testcase 254: -INSERT INTO num_exp_sub VALUES (6,3,'93897.26763026'); ---Testcase 255: -INSERT INTO num_exp_mul VALUES (6,3,'404715.7995864206'); ---Testcase 256: -INSERT INTO num_exp_div VALUES (6,3,'21786.90896293735498839907'); ---Testcase 257: -INSERT INTO num_exp_add VALUES (6,4,'7893362.98953026'); ---Testcase 258: -INSERT INTO num_exp_sub VALUES (6,4,'-7705559.83426974'); ---Testcase 259: -INSERT INTO num_exp_mul VALUES (6,4,'732381731243.745115764094'); ---Testcase 260: -INSERT INTO num_exp_div VALUES (6,4,'.01203949512295682469'); ---Testcase 261: -INSERT INTO num_exp_add VALUES (6,5,'110298.61612126'); ---Testcase 262: -INSERT INTO num_exp_sub VALUES (6,5,'77504.53913926'); ---Testcase 263: -INSERT INTO num_exp_mul VALUES (6,5,'1539707782.76899778633766'); ---Testcase 264: -INSERT INTO num_exp_div VALUES (6,5,'5.72674008674192359679'); ---Testcase 265: -INSERT INTO num_exp_add VALUES (6,6,'187803.15526052'); ---Testcase 266: -INSERT INTO num_exp_sub VALUES (6,6,'0'); ---Testcase 267: -INSERT INTO num_exp_mul VALUES (6,6,'8817506281.4517452372676676'); ---Testcase 268: -INSERT INTO num_exp_div VALUES (6,6,'1.00000000000000000000'); ---Testcase 269: -INSERT INTO num_exp_add VALUES (6,7,'-82934583.42236974'); ---Testcase 270: -INSERT INTO num_exp_sub VALUES (6,7,'83122386.57763026'); ---Testcase 271: -INSERT INTO num_exp_mul VALUES (6,7,'-7796505729750.37795610'); ---Testcase 272: -INSERT INTO num_exp_div VALUES (6,7,'-.00113095617281538980'); ---Testcase 273: -INSERT INTO num_exp_add VALUES (6,8,'168782.57763026'); ---Testcase 274: -INSERT INTO num_exp_sub VALUES (6,8,'19020.57763026'); ---Testcase 275: -INSERT INTO num_exp_mul VALUES (6,8,'7031444034.53149906'); ---Testcase 276: -INSERT INTO num_exp_div VALUES (6,8,'1.25401073209839612184'); ---Testcase 277: -INSERT INTO num_exp_add VALUES (6,9,'-24832902.467417160'); ---Testcase 278: -INSERT INTO num_exp_sub VALUES (6,9,'25020705.622677680'); ---Testcase 279: -INSERT INTO num_exp_mul VALUES (6,9,'-2340666225110.29929521292692920'); ---Testcase 280: -INSERT INTO num_exp_div VALUES (6,9,'-.00376709254265256789'); ---Testcase 281: -INSERT INTO num_exp_add VALUES (7,0,'-83028485'); ---Testcase 282: -INSERT INTO num_exp_sub VALUES (7,0,'-83028485'); ---Testcase 283: -INSERT INTO num_exp_mul VALUES (7,0,'0'); ---Testcase 284: -INSERT INTO num_exp_div VALUES (7,0,'NaN'); ---Testcase 285: -INSERT INTO num_exp_add VALUES (7,1,'-83028485'); ---Testcase 286: -INSERT INTO num_exp_sub VALUES (7,1,'-83028485'); ---Testcase 287: -INSERT INTO num_exp_mul VALUES (7,1,'0'); ---Testcase 288: -INSERT INTO num_exp_div VALUES (7,1,'NaN'); ---Testcase 289: -INSERT INTO num_exp_add VALUES (7,2,'-117366977.215397047'); ---Testcase 290: -INSERT INTO num_exp_sub VALUES (7,2,'-48689992.784602953'); ---Testcase 291: -INSERT INTO num_exp_mul VALUES (7,2,'2851072985828710.485883795'); ---Testcase 292: -INSERT INTO num_exp_div VALUES (7,2,'2.41794207151503385700'); ---Testcase 293: -INSERT INTO num_exp_add VALUES (7,3,'-83028480.69'); ---Testcase 294: -INSERT INTO num_exp_sub VALUES (7,3,'-83028489.31'); ---Testcase 295: -INSERT INTO num_exp_mul VALUES (7,3,'-357852770.35'); ---Testcase 296: -INSERT INTO num_exp_div VALUES (7,3,'-19264149.65197215777262180974'); ---Testcase 297: -INSERT INTO num_exp_add VALUES (7,4,'-75229023.5881'); ---Testcase 298: -INSERT INTO num_exp_sub VALUES (7,4,'-90827946.4119'); ---Testcase 299: -INSERT INTO num_exp_mul VALUES (7,4,'-647577464846017.9715'); ---Testcase 300: -INSERT INTO num_exp_div VALUES (7,4,'-10.64541262725136247686'); ---Testcase 301: -INSERT INTO num_exp_add VALUES (7,5,'-83012087.961509'); ---Testcase 302: -INSERT INTO num_exp_sub VALUES (7,5,'-83044882.038491'); ---Testcase 303: -INSERT INTO num_exp_mul VALUES (7,5,'-1361421264394.416135'); ---Testcase 304: -INSERT INTO num_exp_div VALUES (7,5,'-5063.62688881730941836574'); ---Testcase 305: -INSERT INTO num_exp_add VALUES (7,6,'-82934583.42236974'); ---Testcase 306: -INSERT INTO num_exp_sub VALUES (7,6,'-83122386.57763026'); ---Testcase 307: -INSERT INTO num_exp_mul VALUES (7,6,'-7796505729750.37795610'); ---Testcase 308: -INSERT INTO num_exp_div VALUES (7,6,'-884.20756174009028770294'); ---Testcase 309: -INSERT INTO num_exp_add VALUES (7,7,'-166056970'); ---Testcase 310: -INSERT INTO num_exp_sub VALUES (7,7,'0'); ---Testcase 311: -INSERT INTO num_exp_mul VALUES (7,7,'6893729321395225'); ---Testcase 312: -INSERT INTO num_exp_div VALUES (7,7,'1.00000000000000000000'); ---Testcase 313: -INSERT INTO num_exp_add VALUES (7,8,'-82953604'); ---Testcase 314: -INSERT INTO num_exp_sub VALUES (7,8,'-83103366'); ---Testcase 315: -INSERT INTO num_exp_mul VALUES (7,8,'-6217255985285'); ---Testcase 316: -INSERT INTO num_exp_div VALUES (7,8,'-1108.80577182462841041118'); ---Testcase 317: -INSERT INTO num_exp_add VALUES (7,9,'-107955289.045047420'); ---Testcase 318: -INSERT INTO num_exp_sub VALUES (7,9,'-58101680.954952580'); ---Testcase 319: -INSERT INTO num_exp_mul VALUES (7,9,'2069634775752159.035758700'); ---Testcase 320: -INSERT INTO num_exp_div VALUES (7,9,'3.33089171198810413382'); ---Testcase 321: -INSERT INTO num_exp_add VALUES (8,0,'74881'); ---Testcase 322: -INSERT INTO num_exp_sub VALUES (8,0,'74881'); ---Testcase 323: -INSERT INTO num_exp_mul VALUES (8,0,'0'); ---Testcase 324: -INSERT INTO num_exp_div VALUES (8,0,'NaN'); ---Testcase 325: -INSERT INTO num_exp_add VALUES (8,1,'74881'); ---Testcase 326: -INSERT INTO num_exp_sub VALUES (8,1,'74881'); ---Testcase 327: -INSERT INTO num_exp_mul VALUES (8,1,'0'); ---Testcase 328: -INSERT INTO num_exp_div VALUES (8,1,'NaN'); ---Testcase 329: -INSERT INTO num_exp_add VALUES (8,2,'-34263611.215397047'); ---Testcase 330: -INSERT INTO num_exp_sub VALUES (8,2,'34413373.215397047'); ---Testcase 331: -INSERT INTO num_exp_mul VALUES (8,2,'-2571300635581.146276407'); ---Testcase 332: -INSERT INTO num_exp_div VALUES (8,2,'-.00218067233500788615'); ---Testcase 333: -INSERT INTO num_exp_add VALUES (8,3,'74885.31'); ---Testcase 334: -INSERT INTO num_exp_sub VALUES (8,3,'74876.69'); ---Testcase 335: -INSERT INTO num_exp_mul VALUES (8,3,'322737.11'); ---Testcase 336: -INSERT INTO num_exp_div VALUES (8,3,'17373.78190255220417633410'); ---Testcase 337: -INSERT INTO num_exp_add VALUES (8,4,'7874342.4119'); ---Testcase 338: -INSERT INTO num_exp_sub VALUES (8,4,'-7724580.4119'); ---Testcase 339: -INSERT INTO num_exp_mul VALUES (8,4,'584031469984.4839'); ---Testcase 340: -INSERT INTO num_exp_div VALUES (8,4,'.00960079113741758956'); ---Testcase 341: -INSERT INTO num_exp_add VALUES (8,5,'91278.038491'); ---Testcase 342: -INSERT INTO num_exp_sub VALUES (8,5,'58483.961509'); ---Testcase 343: -INSERT INTO num_exp_mul VALUES (8,5,'1227826639.244571'); ---Testcase 344: -INSERT INTO num_exp_div VALUES (8,5,'4.56673929509287019456'); ---Testcase 345: -INSERT INTO num_exp_add VALUES (8,6,'168782.57763026'); ---Testcase 346: -INSERT INTO num_exp_sub VALUES (8,6,'-19020.57763026'); ---Testcase 347: -INSERT INTO num_exp_mul VALUES (8,6,'7031444034.53149906'); ---Testcase 348: -INSERT INTO num_exp_div VALUES (8,6,'.79744134113322314424'); ---Testcase 349: -INSERT INTO num_exp_add VALUES (8,7,'-82953604'); ---Testcase 350: -INSERT INTO num_exp_sub VALUES (8,7,'83103366'); ---Testcase 351: -INSERT INTO num_exp_mul VALUES (8,7,'-6217255985285'); ---Testcase 352: -INSERT INTO num_exp_div VALUES (8,7,'-.00090187120721280172'); ---Testcase 353: -INSERT INTO num_exp_add VALUES (8,8,'149762'); ---Testcase 354: -INSERT INTO num_exp_sub VALUES (8,8,'0'); ---Testcase 355: -INSERT INTO num_exp_mul VALUES (8,8,'5607164161'); ---Testcase 356: -INSERT INTO num_exp_div VALUES (8,8,'1.00000000000000000000'); ---Testcase 357: -INSERT INTO num_exp_add VALUES (8,9,'-24851923.045047420'); ---Testcase 358: -INSERT INTO num_exp_sub VALUES (8,9,'25001685.045047420'); ---Testcase 359: -INSERT INTO num_exp_mul VALUES (8,9,'-1866544013697.195857020'); ---Testcase 360: -INSERT INTO num_exp_div VALUES (8,9,'-.00300403532938582735'); ---Testcase 361: -INSERT INTO num_exp_add VALUES (9,0,'-24926804.045047420'); ---Testcase 362: -INSERT INTO num_exp_sub VALUES (9,0,'-24926804.045047420'); ---Testcase 363: -INSERT INTO num_exp_mul VALUES (9,0,'0'); ---Testcase 364: -INSERT INTO num_exp_div VALUES (9,0,'NaN'); ---Testcase 365: -INSERT INTO num_exp_add VALUES (9,1,'-24926804.045047420'); ---Testcase 366: -INSERT INTO num_exp_sub VALUES (9,1,'-24926804.045047420'); ---Testcase 367: -INSERT INTO num_exp_mul VALUES (9,1,'0'); ---Testcase 368: -INSERT INTO num_exp_div VALUES (9,1,'NaN'); ---Testcase 369: -INSERT INTO num_exp_add VALUES (9,2,'-59265296.260444467'); ---Testcase 370: -INSERT INTO num_exp_sub VALUES (9,2,'9411688.170349627'); ---Testcase 371: -INSERT INTO num_exp_mul VALUES (9,2,'855948866655588.453741509242968740'); ---Testcase 372: -INSERT INTO num_exp_div VALUES (9,2,'.72591434384152961526'); ---Testcase 373: -INSERT INTO num_exp_add VALUES (9,3,'-24926799.735047420'); ---Testcase 374: -INSERT INTO num_exp_sub VALUES (9,3,'-24926808.355047420'); ---Testcase 375: -INSERT INTO num_exp_mul VALUES (9,3,'-107434525.43415438020'); ---Testcase 376: -INSERT INTO num_exp_div VALUES (9,3,'-5783481.21694835730858468677'); ---Testcase 377: -INSERT INTO num_exp_add VALUES (9,4,'-17127342.633147420'); ---Testcase 378: -INSERT INTO num_exp_sub VALUES (9,4,'-32726265.456947420'); ---Testcase 379: -INSERT INTO num_exp_mul VALUES (9,4,'-194415646271340.1815956522980'); ---Testcase 380: -INSERT INTO num_exp_div VALUES (9,4,'-3.19596478892958416484'); ---Testcase 381: -INSERT INTO num_exp_add VALUES (9,5,'-24910407.006556420'); ---Testcase 382: -INSERT INTO num_exp_sub VALUES (9,5,'-24943201.083538420'); ---Testcase 383: -INSERT INTO num_exp_mul VALUES (9,5,'-408725765384.257043660243220'); ---Testcase 384: -INSERT INTO num_exp_div VALUES (9,5,'-1520.20159364322004505807'); ---Testcase 385: -INSERT INTO num_exp_add VALUES (9,6,'-24832902.467417160'); ---Testcase 386: -INSERT INTO num_exp_sub VALUES (9,6,'-25020705.622677680'); ---Testcase 387: -INSERT INTO num_exp_mul VALUES (9,6,'-2340666225110.29929521292692920'); ---Testcase 388: -INSERT INTO num_exp_div VALUES (9,6,'-265.45671195426965751280'); ---Testcase 389: -INSERT INTO num_exp_add VALUES (9,7,'-107955289.045047420'); ---Testcase 390: -INSERT INTO num_exp_sub VALUES (9,7,'58101680.954952580'); ---Testcase 391: -INSERT INTO num_exp_mul VALUES (9,7,'2069634775752159.035758700'); ---Testcase 392: -INSERT INTO num_exp_div VALUES (9,7,'.30021990699995814689'); ---Testcase 393: -INSERT INTO num_exp_add VALUES (9,8,'-24851923.045047420'); ---Testcase 394: -INSERT INTO num_exp_sub VALUES (9,8,'-25001685.045047420'); ---Testcase 395: -INSERT INTO num_exp_mul VALUES (9,8,'-1866544013697.195857020'); ---Testcase 396: -INSERT INTO num_exp_div VALUES (9,8,'-332.88556569820675471748'); ---Testcase 397: -INSERT INTO num_exp_add VALUES (9,9,'-49853608.090094840'); ---Testcase 398: -INSERT INTO num_exp_sub VALUES (9,9,'0'); ---Testcase 399: -INSERT INTO num_exp_mul VALUES (9,9,'621345559900192.420120630048656400'); ---Testcase 400: -INSERT INTO num_exp_div VALUES (9,9,'1.00000000000000000000'); -COMMIT TRANSACTION; -BEGIN TRANSACTION; ---Testcase 401: -INSERT INTO num_exp_sqrt VALUES (0,'0'); ---Testcase 402: -INSERT INTO num_exp_sqrt VALUES (1,'0'); ---Testcase 403: -INSERT INTO num_exp_sqrt VALUES (2,'5859.90547836712524903505'); ---Testcase 404: -INSERT INTO num_exp_sqrt VALUES (3,'2.07605394920266944396'); ---Testcase 405: -INSERT INTO num_exp_sqrt VALUES (4,'2792.75158435189147418923'); ---Testcase 406: -INSERT INTO num_exp_sqrt VALUES (5,'128.05092147657509145473'); ---Testcase 407: -INSERT INTO num_exp_sqrt VALUES (6,'306.43364311096782703406'); ---Testcase 408: -INSERT INTO num_exp_sqrt VALUES (7,'9111.99676251039939975230'); ---Testcase 409: -INSERT INTO num_exp_sqrt VALUES (8,'273.64392922189960397542'); ---Testcase 410: -INSERT INTO num_exp_sqrt VALUES (9,'4992.67503899937593364766'); -COMMIT TRANSACTION; -BEGIN TRANSACTION; ---Testcase 411: -INSERT INTO num_exp_ln VALUES (0,'NaN'); ---Testcase 412: -INSERT INTO num_exp_ln VALUES (1,'NaN'); ---Testcase 413: -INSERT INTO num_exp_ln VALUES (2,'17.35177750493897715514'); ---Testcase 414: -INSERT INTO num_exp_ln VALUES (3,'1.46093790411565641971'); ---Testcase 415: -INSERT INTO num_exp_ln VALUES (4,'15.86956523951936572464'); ---Testcase 416: -INSERT INTO num_exp_ln VALUES (5,'9.70485601768871834038'); ---Testcase 417: -INSERT INTO num_exp_ln VALUES (6,'11.45000246622944403127'); ---Testcase 418: -INSERT INTO num_exp_ln VALUES (7,'18.23469429965478772991'); ---Testcase 419: -INSERT INTO num_exp_ln VALUES (8,'11.22365546576315513668'); ---Testcase 420: -INSERT INTO num_exp_ln VALUES (9,'17.03145425013166006962'); -COMMIT TRANSACTION; -BEGIN TRANSACTION; ---Testcase 421: -INSERT INTO num_exp_log10 VALUES (0,'NaN'); ---Testcase 422: -INSERT INTO num_exp_log10 VALUES (1,'NaN'); ---Testcase 423: -INSERT INTO num_exp_log10 VALUES (2,'7.53578122160797276459'); ---Testcase 424: -INSERT INTO num_exp_log10 VALUES (3,'.63447727016073160075'); ---Testcase 425: -INSERT INTO num_exp_log10 VALUES (4,'6.89206461372691743345'); ---Testcase 426: -INSERT INTO num_exp_log10 VALUES (5,'4.21476541614777768626'); ---Testcase 427: -INSERT INTO num_exp_log10 VALUES (6,'4.97267288886207207671'); ---Testcase 428: -INSERT INTO num_exp_log10 VALUES (7,'7.91922711353275546914'); ---Testcase 429: -INSERT INTO num_exp_log10 VALUES (8,'4.87437163556421004138'); ---Testcase 430: -INSERT INTO num_exp_log10 VALUES (9,'7.39666659961986567059'); -COMMIT TRANSACTION; -BEGIN TRANSACTION; ---Testcase 431: -INSERT INTO num_exp_power_10_ln VALUES (0,'NaN'); ---Testcase 432: -INSERT INTO num_exp_power_10_ln VALUES (1,'NaN'); ---Testcase 433: -INSERT INTO num_exp_power_10_ln VALUES (2,'224790267919917955.13261618583642653184'); ---Testcase 434: -INSERT INTO num_exp_power_10_ln VALUES (3,'28.90266599445155957393'); ---Testcase 435: -INSERT INTO num_exp_power_10_ln VALUES (4,'7405685069594999.07733999469386277636'); ---Testcase 436: -INSERT INTO num_exp_power_10_ln VALUES (5,'5068226527.32127265408584640098'); ---Testcase 437: -INSERT INTO num_exp_power_10_ln VALUES (6,'281839893606.99372343357047819067'); ---Testcase 438: -INSERT INTO num_exp_power_10_ln VALUES (7,'1716699575118597095.42330819910640247627'); ---Testcase 439: -INSERT INTO num_exp_power_10_ln VALUES (8,'167361463828.07491320069016125952'); ---Testcase 440: -INSERT INTO num_exp_power_10_ln VALUES (9,'107511333880052007.04141124673540337457'); -COMMIT TRANSACTION; -BEGIN TRANSACTION; ---Testcase 441: -INSERT INTO num_data VALUES (0, '0'); ---Testcase 442: -INSERT INTO num_data VALUES (1, '0'); ---Testcase 443: -INSERT INTO num_data VALUES (2, '-34338492.215397047'); ---Testcase 444: -INSERT INTO num_data VALUES (3, '4.31'); ---Testcase 445: -INSERT INTO num_data VALUES (4, '7799461.4119'); ---Testcase 446: -INSERT INTO num_data VALUES (5, '16397.038491'); ---Testcase 447: -INSERT INTO num_data VALUES (6, '93901.57763026'); ---Testcase 448: -INSERT INTO num_data VALUES (7, '-83028485'); ---Testcase 449: -INSERT INTO num_data VALUES (8, '74881'); ---Testcase 450: -INSERT INTO num_data VALUES (9, '-24926804.045047420'); -COMMIT TRANSACTION; --- ****************************** --- * Create indices for faster checks --- ****************************** --- Skip these setting, creating foreign table with primary key already covered. ---CREATE UNIQUE INDEX num_exp_add_idx ON num_exp_add (id1, id2); ---CREATE UNIQUE INDEX num_exp_sub_idx ON num_exp_sub (id1, id2); ---CREATE UNIQUE INDEX num_exp_div_idx ON num_exp_div (id1, id2); ---CREATE UNIQUE INDEX num_exp_mul_idx ON num_exp_mul (id1, id2); ---CREATE UNIQUE INDEX num_exp_sqrt_idx ON num_exp_sqrt (id); ---CREATE UNIQUE INDEX num_exp_ln_idx ON num_exp_ln (id); ---CREATE UNIQUE INDEX num_exp_log10_idx ON num_exp_log10 (id); ---CREATE UNIQUE INDEX num_exp_power_10_ln_idx ON num_exp_power_10_ln (id); ---VACUUM ANALYZE num_exp_add; ---VACUUM ANALYZE num_exp_sub; ---VACUUM ANALYZE num_exp_div; ---VACUUM ANALYZE num_exp_mul; ---VACUUM ANALYZE num_exp_sqrt; ---VACUUM ANALYZE num_exp_ln; ---VACUUM ANALYZE num_exp_log10; ---VACUUM ANALYZE num_exp_power_10_ln; --- ****************************** --- * Now check the behaviour of the NUMERIC type --- ****************************** --- ****************************** --- * Addition check --- ****************************** ---Testcase 451: -DELETE FROM num_result; ---Testcase 452: -INSERT INTO num_result SELECT t1.id, t2.id, t1.val + t2.val - FROM num_data t1, num_data t2; ---Testcase 453: -SELECT t1.id1, t1.id2, t1.result, t2.expected - FROM num_result t1, num_exp_add t2 - WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 - AND t1.result != t2.expected; - id1 | id2 | result | expected ------+-----+-------------------+------------------- - 2 | 2 | -68676984.430794 | -68676984.4307941 - 2 | 3 | -34338487.905397 | -34338487.9053971 - 2 | 6 | -34244590.6377667 | -34244590.6377668 - 2 | 9 | -59265296.2604444 | -59265296.2604445 - 3 | 2 | -34338487.905397 | -34338487.9053971 - 6 | 2 | -34244590.6377667 | -34244590.6377668 - 6 | 9 | -24832902.4674171 | -24832902.4674172 - 9 | 2 | -59265296.2604444 | -59265296.2604445 - 9 | 6 | -24832902.4674171 | -24832902.4674172 -(9 rows) - ---Testcase 454: -DELETE FROM num_result; ---Testcase 455: -INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val + t2.val, 10) - FROM num_data t1, num_data t2; ---Testcase 456: -SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 10) as expected - FROM num_result t1, num_exp_add t2 - WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 - AND t1.result != round(t2.expected, 10); - id1 | id2 | result | expected ------+-----+-------------------+---------------------- - 2 | 2 | -68676984.430794 | -68676984.4307941000 - 2 | 3 | -34338487.905397 | -34338487.9053971000 - 2 | 6 | -34244590.6377667 | -34244590.6377668000 - 2 | 9 | -59265296.2604444 | -59265296.2604445000 - 3 | 2 | -34338487.905397 | -34338487.9053971000 - 6 | 2 | -34244590.6377667 | -34244590.6377668000 - 6 | 9 | -24832902.4674171 | -24832902.4674172000 - 9 | 2 | -59265296.2604444 | -59265296.2604445000 - 9 | 6 | -24832902.4674171 | -24832902.4674172000 -(9 rows) - --- ****************************** --- * Subtraction check --- ****************************** ---Testcase 457: -DELETE FROM num_result; ---Testcase 458: -INSERT INTO num_result SELECT t1.id, t2.id, t1.val - t2.val - FROM num_data t1, num_data t2; ---Testcase 459: -SELECT t1.id1, t1.id2, t1.result, t2.expected - FROM num_result t1, num_exp_sub t2 - WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 - AND t1.result != t2.expected; - id1 | id2 | result | expected ------+-----+------------------+------------------- - 2 | 9 | -9411688.1703496 | -9411688.17034963 - 9 | 2 | 9411688.1703496 | 9411688.17034963 -(2 rows) - ---Testcase 460: -DELETE FROM num_result; ---Testcase 461: -INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val - t2.val, 40) - FROM num_data t1, num_data t2; ---Testcase 462: -SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 40) - FROM num_result t1, num_exp_sub t2 - WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 - AND t1.result != round(t2.expected, 40); - id1 | id2 | result | round ------+-----+------------------+--------------------------------------------------- - 2 | 9 | -9411688.1703496 | -9411688.1703496300000000000000000000000000000000 - 9 | 2 | 9411688.1703496 | 9411688.1703496300000000000000000000000000000000 -(2 rows) - --- ****************************** --- * Multiply check --- ****************************** ---Testcase 463: -DELETE FROM num_result; ---Testcase 464: -INSERT INTO num_result SELECT t1.id, t2.id, t1.val * t2.val - FROM num_data t1, num_data t2; ---Testcase 465: -SELECT t1.id1, t1.id2, t1.result, t2.expected - FROM num_result t1, num_exp_mul t2 - WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 - AND t1.result != t2.expected; - id1 | id2 | result | expected ------+-----+-------------------+------------------- - 2 | 4 | -267821744976817 | -267821744976818 - 2 | 5 | -563049578578.768 | -563049578578.769 - 2 | 8 | -2571300635581.14 | -2571300635581.15 - 2 | 9 | 855948866655587 | 855948866655588 - 4 | 2 | -267821744976817 | -267821744976818 - 5 | 2 | -563049578578.768 | -563049578578.769 - 8 | 2 | -2571300635581.14 | -2571300635581.15 - 8 | 9 | -1866544013697.19 | -1866544013697.2 - 9 | 2 | 855948866655587 | 855948866655588 - 9 | 8 | -1866544013697.19 | -1866544013697.2 - 9 | 9 | 621345559900191 | 621345559900192 -(11 rows) - ---Testcase 466: -DELETE FROM num_result; ---Testcase 467: -INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val * t2.val, 30) - FROM num_data t1, num_data t2; ---Testcase 468: -SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 30) as expected - FROM num_result t1, num_exp_mul t2 - WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 - AND t1.result != round(t2.expected, 30); - id1 | id2 | result | expected ------+-----+-------------------+------------------------------------------------- - 2 | 4 | -267821744976817 | -267821744976818.000000000000000000000000000000 - 2 | 5 | -563049578578.768 | -563049578578.769000000000000000000000000000 - 2 | 8 | -2571300635581.14 | -2571300635581.150000000000000000000000000000 - 2 | 9 | 855948866655587 | 855948866655588.000000000000000000000000000000 - 4 | 2 | -267821744976817 | -267821744976818.000000000000000000000000000000 - 5 | 2 | -563049578578.768 | -563049578578.769000000000000000000000000000 - 8 | 2 | -2571300635581.14 | -2571300635581.150000000000000000000000000000 - 8 | 9 | -1866544013697.19 | -1866544013697.200000000000000000000000000000 - 9 | 2 | 855948866655587 | 855948866655588.000000000000000000000000000000 - 9 | 8 | -1866544013697.19 | -1866544013697.200000000000000000000000000000 - 9 | 9 | 621345559900191 | 621345559900192.000000000000000000000000000000 -(11 rows) - --- ****************************** --- * Division check --- ****************************** ---Testcase 469: -DELETE FROM num_result; ---Testcase 470: -INSERT INTO num_result SELECT t1.id, t2.id, t1.val / t2.val - FROM num_data t1, num_data t2 - WHERE t2.val != '0.0'; ---Testcase 471: -SELECT t1.id1, t1.id2, t1.result, t2.expected - FROM num_result t1, num_exp_div t2 - WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 - AND t1.result != t2.expected; - id1 | id2 | result | expected ------+-----+-------------------+------------------- - 2 | 3 | -7967167.56737749 | -7967167.5673775 - 9 | 3 | -5783481.21694835 | -5783481.21694836 -(2 rows) - ---Testcase 472: -DELETE FROM num_result; ---Testcase 473: -INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val / t2.val, 80) - FROM num_data t1, num_data t2 - WHERE t2.val != '0.0'; ---Testcase 474: -SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 80) as expected - FROM num_result t1, num_exp_div t2 - WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 - AND t1.result != round(t2.expected, 80); - id1 | id2 | result | expected ------+-----+-------------------+------------------------------------------------------------------------------------------- - 2 | 3 | -7967167.56737749 | -7967167.56737750000000000000000000000000000000000000000000000000000000000000000000000000 - 9 | 3 | -5783481.21694835 | -5783481.21694836000000000000000000000000000000000000000000000000000000000000000000000000 -(2 rows) - --- ****************************** --- * Square root check --- ****************************** ---Testcase 475: -DELETE FROM num_result; ---Testcase 476: -INSERT INTO num_result SELECT id, 0, SQRT(ABS(val)) - FROM num_data; ---Testcase 477: -SELECT t1.id1, t1.result, t2.expected - FROM num_result t1, num_exp_sqrt t2 - WHERE t1.id1 = t2.id - AND t1.result != t2.expected; - id1 | result | expected ------+--------+---------- -(0 rows) - --- ****************************** --- * Natural logarithm check --- ****************************** ---Testcase 478: -DELETE FROM num_result; ---Testcase 479: -INSERT INTO num_result SELECT id, 0, LN(ABS(val)) - FROM num_data - WHERE val != '0.0'; ---Testcase 480: -SELECT t1.id1, t1.result, t2.expected - FROM num_result t1, num_exp_ln t2 - WHERE t1.id1 = t2.id - AND t1.result != t2.expected; - id1 | result | expected ------+--------+---------- -(0 rows) - --- ****************************** --- * Logarithm base 10 check --- ****************************** ---Testcase 481: -DELETE FROM num_result; ---Testcase 482: -INSERT INTO num_result SELECT id, 0, LOG(numeric '10', ABS(val)) - FROM num_data - WHERE val != '0.0'; ---Testcase 483: -SELECT t1.id1, t1.result, t2.expected - FROM num_result t1, num_exp_log10 t2 - WHERE t1.id1 = t2.id - AND t1.result != t2.expected; - id1 | result | expected ------+--------+---------- -(0 rows) - --- ****************************** --- * POWER(10, LN(value)) check --- ****************************** ---Testcase 484: -DELETE FROM num_result; ---Testcase 485: -INSERT INTO num_result SELECT id, 0, POWER(numeric '10', LN(ABS(round(val,200)))) - FROM num_data - WHERE val != '0.0'; ---Testcase 486: -SELECT t1.id1, t1.result, t2.expected - FROM num_result t1, num_exp_power_10_ln t2 - WHERE t1.id1 = t2.id - AND t1.result != t2.expected; - id1 | result | expected ------+--------------------+-------------------- - 2 | 224790267919917000 | 224790267919918000 -(1 row) - --- ****************************** --- * miscellaneous checks for things that have been broken in the past... --- ****************************** --- numeric AVG used to fail on some platforms ---Testcase 487: -SELECT AVG(val) FROM num_data; - avg -------------------- - -13430913.5922423 -(1 row) - ---Testcase 488: -SELECT STDDEV(val) FROM num_data; - stddev ---------------------------- - 27791203.2875883484501033 -(1 row) - ---Testcase 489: -SELECT VARIANCE(val) FROM num_data; - variance ----------------------------------- - 772350980172061.4271301683648535 -(1 row) - --- Check for appropriate rounding and overflow ---Testcase 579: -CREATE FOREIGN TABLE fract_only (id int, val numeric(4,4)) SERVER sqlite_svr; ---Testcase 490: -INSERT INTO fract_only VALUES (1, '0.0'); ---Testcase 491: -INSERT INTO fract_only VALUES (2, '0.1'); ---Testcase 492: -INSERT INTO fract_only VALUES (3, '1.0'); -- should fail -ERROR: numeric field overflow -DETAIL: A field with precision 4, scale 4 must round to an absolute value less than 1. ---Testcase 493: -INSERT INTO fract_only VALUES (4, '-0.9999'); ---Testcase 494: -INSERT INTO fract_only VALUES (5, '0.99994'); ---Testcase 495: -INSERT INTO fract_only VALUES (6, '0.99995'); -- should fail -ERROR: numeric field overflow -DETAIL: A field with precision 4, scale 4 must round to an absolute value less than 1. ---Testcase 496: -INSERT INTO fract_only VALUES (7, '0.00001'); ---Testcase 497: -INSERT INTO fract_only VALUES (8, '0.00017'); ---Testcase 498: -SELECT * FROM fract_only; - id | val -----+--------- - 1 | 0 - 2 | 0.1 - 4 | -0.9999 - 5 | 0.9999 - 7 | 0 - 8 | 0.0002 -(6 rows) - ---Testcase 580: -DROP FOREIGN TABLE fract_only; --- Check inf/nan conversion behavior ---Testcase 581: -CREATE FOREIGN TABLE FLOAT8_TMP(f1 float8, f2 float8, id int OPTIONS (key 'true')) SERVER sqlite_svr; ---Testcase 582: -DELETE FROM FLOAT8_TMP; ---Testcase 583: -INSERT INTO FLOAT8_TMP VALUES ('NaN'); ---Testcase 584: -SELECT f1::numeric FROM FLOAT8_TMP; - f1 ----- - -(1 row) - ---Testcase 585: -DELETE FROM FLOAT8_TMP; ---Testcase 586: -INSERT INTO FLOAT8_TMP VALUES ('Infinity'); ---Testcase 587: -SELECT f1::numeric FROM FLOAT8_TMP; -ERROR: cannot convert infinity to numeric ---Testcase 588: -DELETE FROM FLOAT8_TMP; ---Testcase 589: -INSERT INTO FLOAT8_TMP VALUES ('-Infinity'); ---Testcase 590: -SELECT f1::numeric FROM FLOAT8_TMP; -ERROR: cannot convert infinity to numeric ---Testcase 591: -CREATE FOREIGN TABLE FLOAT4_TMP(f1 float4, id int OPTIONS (key 'true')) SERVER sqlite_svr; ---Testcase 592: -DELETE FROM FLOAT4_TMP; ---Testcase 593: -INSERT INTO FLOAT4_TMP VALUES ('NaN'); ---Testcase 594: -SELECT f1::numeric FROM FLOAT4_TMP; - f1 ----- - -(1 row) - ---Testcase 595: -DELETE FROM FLOAT4_TMP; ---Testcase 596: -INSERT INTO FLOAT4_TMP VALUES ('Infinity'); ---Testcase 597: -SELECT f1::numeric FROM FLOAT4_TMP; -ERROR: cannot convert infinity to numeric ---Testcase 598: -DELETE FROM FLOAT4_TMP; ---Testcase 599: -INSERT INTO FLOAT4_TMP VALUES ('-Infinity'); ---Testcase 600: -SELECT f1::numeric FROM FLOAT4_TMP; -ERROR: cannot convert infinity to numeric --- Simple check that ceil(), floor(), and round() work correctly ---Testcase 601: -CREATE FOREIGN TABLE ceil_floor_round (a numeric OPTIONS (key 'true')) SERVER sqlite_svr; ---Testcase 499: -INSERT INTO ceil_floor_round VALUES ('-5.5'); ---Testcase 500: -INSERT INTO ceil_floor_round VALUES ('-5.499999'); ---Testcase 501: -INSERT INTO ceil_floor_round VALUES ('9.5'); ---Testcase 502: -INSERT INTO ceil_floor_round VALUES ('9.4999999'); ---Testcase 503: -INSERT INTO ceil_floor_round VALUES ('0.0'); ---Testcase 504: -INSERT INTO ceil_floor_round VALUES ('0.0000001'); ---Testcase 505: -INSERT INTO ceil_floor_round VALUES ('-0.000001'); ---Testcase 506: -SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round ORDER BY a; - a | ceil | ceiling | floor | round ------------+------+---------+-------+------- - -5.5 | -5 | -5 | -6 | -6 - -5.499999 | -5 | -5 | -6 | -5 - -0.000001 | 0 | 0 | -1 | 0 - 0 | 0 | 0 | 0 | 0 - 0.0000001 | 1 | 1 | 0 | 0 - 9.4999999 | 10 | 10 | 9 | 9 - 9.5 | 10 | 10 | 9 | 10 -(7 rows) - --- Check rounding, it should round ties away from zero. ---Testcase 602: -CREATE FOREIGN TABLE INT4_TMP(f1 int4, f2 int4, id int OPTIONS (key 'true')) SERVER sqlite_svr; ---Testcase 603: -DELETE FROM INT4_TMP; ---Testcase 604: -INSERT INTO INT4_TMP SELECT a FROM generate_series(-5,5) a; ---Testcase 605: -SELECT f1 as pow, - round((-2.5 * 10 ^ f1)::numeric, -f1), - round((-1.5 * 10 ^ f1)::numeric, -f1), - round((-0.5 * 10 ^ f1)::numeric, -f1), - round((0.5 * 10 ^ f1)::numeric, -f1), - round((1.5 * 10 ^ f1)::numeric, -f1), - round((2.5 * 10 ^ f1)::numeric, -f1) -FROM INT4_TMP; - pow | round | round | round | round | round | round ------+----------+----------+----------+---------+---------+--------- - -5 | -0.00003 | -0.00002 | -0.00001 | 0.00001 | 0.00002 | 0.00003 - -4 | -0.0003 | -0.0002 | -0.0001 | 0.0001 | 0.0002 | 0.0003 - -3 | -0.003 | -0.002 | -0.001 | 0.001 | 0.002 | 0.003 - -2 | -0.03 | -0.02 | -0.01 | 0.01 | 0.02 | 0.03 - -1 | -0.3 | -0.2 | -0.1 | 0.1 | 0.2 | 0.3 - 0 | -3 | -2 | -1 | 1 | 2 | 3 - 1 | -30 | -20 | -10 | 10 | 20 | 30 - 2 | -300 | -200 | -100 | 100 | 200 | 300 - 3 | -3000 | -2000 | -1000 | 1000 | 2000 | 3000 - 4 | -30000 | -20000 | -10000 | 10000 | 20000 | 30000 - 5 | -300000 | -200000 | -100000 | 100000 | 200000 | 300000 -(11 rows) - --- Testing for width_bucket(). For convenience, we test both the --- numeric and float8 versions of the function in this file. --- errors ---Testcase 606: -CREATE FOREIGN TABLE width_bucket_tbl ( - id1 numeric, - id2 numeric, - id3 numeric, - id4 int, - id int OPTIONS (key 'true') -) SERVER sqlite_svr; ---Testcase 607: -DELETE FROM width_bucket_tbl; ---Testcase 608: -INSERT INTO width_bucket_tbl VALUES (5.0, 3.0, 4.0, 0); ---Testcase 609: -SELECT width_bucket(id1, id2, id3, id4) FROM width_bucket_tbl; -ERROR: count must be greater than zero ---Testcase 610: -DELETE FROM width_bucket_tbl; ---Testcase 611: -INSERT INTO width_bucket_tbl VALUES (5.0, 3.0, 4.0, -5); ---Testcase 612: -SELECT width_bucket(id1, id2, id3, id4) FROM width_bucket_tbl; -ERROR: count must be greater than zero ---Testcase 613: -DELETE FROM width_bucket_tbl; ---Testcase 614: -INSERT INTO width_bucket_tbl VALUES (3.5, 3.0, 3.0, 888); ---Testcase 615: -SELECT width_bucket(id1, id2, id3, id4) FROM width_bucket_tbl; -ERROR: lower bound cannot equal upper bound ---Testcase 616: -DELETE FROM width_bucket_tbl; ---Testcase 617: -INSERT INTO width_bucket_tbl VALUES (5.0, 3.0, 4.0, 0); ---Testcase 618: -SELECT width_bucket(id1::float8, id2::float8, id3::float8, id4) FROM width_bucket_tbl; -ERROR: count must be greater than zero ---Testcase 619: -DELETE FROM width_bucket_tbl; ---Testcase 620: -INSERT INTO width_bucket_tbl VALUES (5.0, 3.0, 4.0, -5); ---Testcase 621: -SELECT width_bucket(id1::float8, id2::float8, id3::float8, id4) FROM width_bucket_tbl; -ERROR: count must be greater than zero ---Testcase 622: -DELETE FROM width_bucket_tbl; ---Testcase 623: -INSERT INTO width_bucket_tbl VALUES (3.5, 3.0, 3.0, 888); ---Testcase 624: -SELECT width_bucket(id1::float8, id2::float8, id3::float8, id4) FROM width_bucket_tbl; -ERROR: lower bound cannot equal upper bound ---Testcase 625: -DELETE FROM width_bucket_tbl; ---Testcase 626: -INSERT INTO width_bucket_tbl VALUES ('NaN'::numeric, 3.0, 4.0, 888); ---Testcase 627: -SELECT width_bucket(id1, id2, id3, id4) FROM width_bucket_tbl; - width_bucket --------------- - -(1 row) - ---Testcase 628: -DELETE FROM width_bucket_tbl; ---Testcase 629: -INSERT INTO width_bucket_tbl VALUES (0, 'NaN'::numeric, 4.0, 888); ---Testcase 630: -SELECT width_bucket(id1::float8, id2, id3::float8, id4) FROM width_bucket_tbl; - width_bucket --------------- - -(1 row) - --- normal operation ---Testcase 631: -CREATE FOREIGN TABLE width_bucket_test ( - operand_num numeric OPTIONS (key 'true'), - operand_f8 float8 -) SERVER sqlite_svr; ---COPY width_bucket_test (operand_num) FROM stdin; ---Testcase 507: -INSERT INTO width_bucket_test (operand_num) VALUES -(-5.2), -(-0.0000000001), -(0.000000000001), -(1), -(1.99999999999999), -(2), -(2.00000000000001), -(3), -(4), -(4.5), -(5), -(5.5), -(6), -(7), -(8), -(9), -(9.99999999999999), -(10), -(10.0000000000001); ---Testcase 508: -UPDATE width_bucket_test SET operand_f8 = operand_num::float8; ---Testcase 509: -SELECT - operand_num, - width_bucket(operand_num, 0, 10, 5) AS wb_1, - width_bucket(operand_f8, 0, 10, 5) AS wb_1f, - width_bucket(operand_num, 10, 0, 5) AS wb_2, - width_bucket(operand_f8, 10, 0, 5) AS wb_2f, - width_bucket(operand_num, 2, 8, 4) AS wb_3, - width_bucket(operand_f8, 2, 8, 4) AS wb_3f, - width_bucket(operand_num, 5.0, 5.5, 20) AS wb_4, - width_bucket(operand_f8, 5.0, 5.5, 20) AS wb_4f, - width_bucket(operand_num, -25, 25, 10) AS wb_5, - width_bucket(operand_f8, -25, 25, 10) AS wb_5f - FROM width_bucket_test; - operand_num | wb_1 | wb_1f | wb_2 | wb_2f | wb_3 | wb_3f | wb_4 | wb_4f | wb_5 | wb_5f -------------------+------+-------+------+-------+------+-------+------+-------+------+------- - -5.2 | 0 | 0 | 6 | 6 | 0 | 0 | 0 | 0 | 4 | 4 - -0.0000000001 | 0 | 0 | 6 | 6 | 0 | 0 | 0 | 0 | 5 | 5 - 0.000000000001 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 - 1 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 - 1.99999999999999 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 - 2 | 2 | 2 | 5 | 5 | 1 | 1 | 0 | 0 | 6 | 6 - 2.00000000000001 | 2 | 2 | 4 | 4 | 1 | 1 | 0 | 0 | 6 | 6 - 3 | 2 | 2 | 4 | 4 | 1 | 1 | 0 | 0 | 6 | 6 - 4 | 3 | 3 | 4 | 4 | 2 | 2 | 0 | 0 | 6 | 6 - 4.5 | 3 | 3 | 3 | 3 | 2 | 2 | 0 | 0 | 6 | 6 - 5 | 3 | 3 | 3 | 3 | 3 | 3 | 1 | 1 | 7 | 7 - 5.5 | 3 | 3 | 3 | 3 | 3 | 3 | 21 | 21 | 7 | 7 - 6 | 4 | 4 | 3 | 3 | 3 | 3 | 21 | 21 | 7 | 7 - 7 | 4 | 4 | 2 | 2 | 4 | 4 | 21 | 21 | 7 | 7 - 8 | 5 | 5 | 2 | 2 | 5 | 5 | 21 | 21 | 7 | 7 - 9 | 5 | 5 | 1 | 1 | 5 | 5 | 21 | 21 | 7 | 7 - 9.99999999999999 | 5 | 5 | 1 | 1 | 5 | 5 | 21 | 21 | 7 | 7 - 10 | 6 | 6 | 1 | 1 | 5 | 5 | 21 | 21 | 8 | 8 - 10.0000000000001 | 6 | 6 | 0 | 0 | 5 | 5 | 21 | 21 | 8 | 8 -(19 rows) - --- for float8 only, check positive and negative infinity: we require --- finite bucket bounds, but allow an infinite operand ---Testcase 510: -DELETE FROM width_bucket_tbl; --- postgres does not support insert 'Infinity' and '-Infinity' as numeric. ---Testcase 632: -INSERT INTO width_bucket_tbl VALUES (0.0, 0.0, 5, 10); ---Testcase 633: -SELECT width_bucket(id1::float8, 'Infinity'::float8, id3, id4) FROM width_bucket_tbl; -- error -ERROR: lower and upper bounds must be finite ---Testcase 511: -DELETE FROM width_bucket_tbl; ---Testcase 634: -INSERT INTO width_bucket_tbl VALUES (0.0, 5, 0.0, 20); ---Testcase 635: -SELECT width_bucket(id1::float8, id2, 'Infinity'::float8, id4) FROM width_bucket_tbl; -- error -ERROR: lower and upper bounds must be finite ---Testcase 512: -DELETE FROM width_bucket_tbl; ---Testcase 636: -INSERT INTO width_bucket_tbl VALUES (0.0, 1, 10, 10); ---Testcase 637: -SELECT width_bucket('Infinity'::float8, id2, id3, id4), width_bucket('-Infinity'::float8, id2, id3, id4) FROM width_bucket_tbl; - width_bucket | width_bucket ---------------+-------------- - 11 | 0 -(1 row) - ---Testcase 638: -DROP FOREIGN TABLE width_bucket_test; --- TO_CHAR() --- ---Testcase 513: -SELECT '' AS to_char_1, to_char(val, '9G999G999G999G999G999') - FROM num_data; - to_char_1 | to_char ------------+------------------------ - | 0 - | 0 - | -34,338,492 - | 4 - | 7,799,461 - | 16,397 - | 93,902 - | -83,028,485 - | 74,881 - | -24,926,804 -(10 rows) - ---Testcase 514: -SELECT '' AS to_char_2, to_char(val, '9G999G999G999G999G999D999G999G999G999G999') - FROM num_data; - to_char_2 | to_char ------------+-------------------------------------------- - | .000,000,000,000,000 - | .000,000,000,000,000 - | -34,338,492.215,397,000,000,000 - | 4.310,000,000,000,000 - | 7,799,461.411,900,000,000,000 - | 16,397.038,491,000,000,000 - | 93,901.577,630,260,000,000 - | -83,028,485.000,000,000,000,000 - | 74,881.000,000,000,000,000 - | -24,926,804.045,047,400,000,000 -(10 rows) - ---Testcase 515: -SELECT '' AS to_char_3, to_char(val, '9999999999999999.999999999999999PR') - FROM num_data; - to_char_3 | to_char ------------+------------------------------------ - | .000000000000000 - | .000000000000000 - | <34338492.215397000000000> - | 4.310000000000000 - | 7799461.411900000000000 - | 16397.038491000000000 - | 93901.577630260000000 - | <83028485.000000000000000> - | 74881.000000000000000 - | <24926804.045047400000000> -(10 rows) - ---Testcase 516: -SELECT '' AS to_char_4, to_char(val, '9999999999999999.999999999999999S') - FROM num_data; - to_char_4 | to_char ------------+----------------------------------- - | .000000000000000+ - | .000000000000000+ - | 34338492.215397000000000- - | 4.310000000000000+ - | 7799461.411900000000000+ - | 16397.038491000000000+ - | 93901.577630260000000+ - | 83028485.000000000000000- - | 74881.000000000000000+ - | 24926804.045047400000000- -(10 rows) - ---Testcase 517: -SELECT '' AS to_char_5, to_char(val, 'MI9999999999999999.999999999999999') FROM num_data; - to_char_5 | to_char ------------+----------------------------------- - | .000000000000000 - | .000000000000000 - | - 34338492.215397000000000 - | 4.310000000000000 - | 7799461.411900000000000 - | 16397.038491000000000 - | 93901.577630260000000 - | - 83028485.000000000000000 - | 74881.000000000000000 - | - 24926804.045047400000000 -(10 rows) - ---Testcase 518: -SELECT '' AS to_char_6, to_char(val, 'FMS9999999999999999.999999999999999') FROM num_data; - to_char_6 | to_char ------------+------------------- - | +0. - | +0. - | -34338492.215397 - | +4.31 - | +7799461.4119 - | +16397.038491 - | +93901.57763026 - | -83028485. - | +74881. - | -24926804.0450474 -(10 rows) - ---Testcase 519: -SELECT '' AS to_char_7, to_char(val, 'FM9999999999999999.999999999999999THPR') FROM num_data; - to_char_7 | to_char ------------+-------------------- - | 0. - | 0. - | <34338492.215397> - | 4.31 - | 7799461.4119 - | 16397.038491 - | 93901.57763026 - | <83028485.> - | 74881. - | <24926804.0450474> -(10 rows) - ---Testcase 520: -SELECT '' AS to_char_8, to_char(val, 'SG9999999999999999.999999999999999th') FROM num_data; - to_char_8 | to_char ------------+----------------------------------- - | + .000000000000000 - | + .000000000000000 - | - 34338492.215397000000000 - | + 4.310000000000000 - | + 7799461.411900000000000 - | + 16397.038491000000000 - | + 93901.577630260000000 - | - 83028485.000000000000000 - | + 74881.000000000000000 - | - 24926804.045047400000000 -(10 rows) - ---Testcase 521: -SELECT '' AS to_char_9, to_char(val, '0999999999999999.999999999999999') FROM num_data; - to_char_9 | to_char ------------+----------------------------------- - | 0000000000000000.000000000000000 - | 0000000000000000.000000000000000 - | -0000000034338492.215397000000000 - | 0000000000000004.310000000000000 - | 0000000007799461.411900000000000 - | 0000000000016397.038491000000000 - | 0000000000093901.577630260000000 - | -0000000083028485.000000000000000 - | 0000000000074881.000000000000000 - | -0000000024926804.045047400000000 -(10 rows) - ---Testcase 522: -SELECT '' AS to_char_10, to_char(val, 'S0999999999999999.999999999999999') FROM num_data; - to_char_10 | to_char -------------+----------------------------------- - | +0000000000000000.000000000000000 - | +0000000000000000.000000000000000 - | -0000000034338492.215397000000000 - | +0000000000000004.310000000000000 - | +0000000007799461.411900000000000 - | +0000000000016397.038491000000000 - | +0000000000093901.577630260000000 - | -0000000083028485.000000000000000 - | +0000000000074881.000000000000000 - | -0000000024926804.045047400000000 -(10 rows) - ---Testcase 523: -SELECT '' AS to_char_11, to_char(val, 'FM0999999999999999.999999999999999') FROM num_data; - to_char_11 | to_char -------------+--------------------------- - | 0000000000000000. - | 0000000000000000. - | -0000000034338492.215397 - | 0000000000000004.31 - | 0000000007799461.4119 - | 0000000000016397.038491 - | 0000000000093901.57763026 - | -0000000083028485. - | 0000000000074881. - | -0000000024926804.0450474 -(10 rows) - ---Testcase 524: -SELECT '' AS to_char_12, to_char(val, 'FM9999999999999999.099999999999999') FROM num_data; - to_char_12 | to_char -------------+------------------- - | .0 - | .0 - | -34338492.215397 - | 4.31 - | 7799461.4119 - | 16397.038491 - | 93901.57763026 - | -83028485.0 - | 74881.0 - | -24926804.0450474 -(10 rows) - ---Testcase 525: -SELECT '' AS to_char_13, to_char(val, 'FM9999999999990999.990999999999999') FROM num_data; - to_char_13 | to_char -------------+------------------- - | 0000.000 - | 0000.000 - | -34338492.215397 - | 0004.310 - | 7799461.4119 - | 16397.038491 - | 93901.57763026 - | -83028485.000 - | 74881.000 - | -24926804.0450474 -(10 rows) - ---Testcase 526: -SELECT '' AS to_char_14, to_char(val, 'FM0999999999999999.999909999999999') FROM num_data; - to_char_14 | to_char -------------+--------------------------- - | 0000000000000000.00000 - | 0000000000000000.00000 - | -0000000034338492.215397 - | 0000000000000004.31000 - | 0000000007799461.41190 - | 0000000000016397.038491 - | 0000000000093901.57763026 - | -0000000083028485.00000 - | 0000000000074881.00000 - | -0000000024926804.0450474 -(10 rows) - ---Testcase 527: -SELECT '' AS to_char_15, to_char(val, 'FM9999999990999999.099999999999999') FROM num_data; - to_char_15 | to_char -------------+------------------- - | 0000000.0 - | 0000000.0 - | -34338492.215397 - | 0000004.31 - | 7799461.4119 - | 0016397.038491 - | 0093901.57763026 - | -83028485.0 - | 0074881.0 - | -24926804.0450474 -(10 rows) - ---Testcase 528: -SELECT '' AS to_char_16, to_char(val, 'L9999999999999999.099999999999999') FROM num_data; - to_char_16 | to_char -------------+------------------------------------ - | .000000000000000 - | .000000000000000 - | -34338492.215397000000000 - | 4.310000000000000 - | 7799461.411900000000000 - | 16397.038491000000000 - | 93901.577630260000000 - | -83028485.000000000000000 - | 74881.000000000000000 - | -24926804.045047400000000 -(10 rows) - ---Testcase 529: -SELECT '' AS to_char_17, to_char(val, 'FM9999999999999999.99999999999999') FROM num_data; - to_char_17 | to_char -------------+------------------- - | 0. - | 0. - | -34338492.215397 - | 4.31 - | 7799461.4119 - | 16397.038491 - | 93901.57763026 - | -83028485. - | 74881. - | -24926804.0450474 -(10 rows) - ---Testcase 530: -SELECT '' AS to_char_18, to_char(val, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data; - to_char_18 | to_char -------------+----------------------------------------------------------------------- - | +. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - | +. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - | -3 4 3 3 8 4 9 2 . 2 1 5 3 9 7 0 0 0 0 0 0 0 0 0 0 0 - | +4 . 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - | +7 7 9 9 4 6 1 . 4 1 1 9 0 0 0 0 0 0 0 0 0 0 0 0 0 - | +1 6 3 9 7 . 0 3 8 4 9 1 0 0 0 0 0 0 0 0 0 0 0 - | +9 3 9 0 1 . 5 7 7 6 3 0 2 6 0 0 0 0 0 0 0 0 0 - | -8 3 0 2 8 4 8 5 . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - | +7 4 8 8 1 . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - | -2 4 9 2 6 8 0 4 . 0 4 5 0 4 7 4 0 0 0 0 0 0 0 0 0 0 -(10 rows) - ---Testcase 531: -SELECT '' AS to_char_19, to_char(val, 'FMS 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data; - to_char_19 | to_char -------------+----------------------------------------------------- - | +0 . - | +0 . - | -3 4 3 3 8 4 9 2 . 2 1 5 3 9 7 - | +4 . 3 1 - | +7 7 9 9 4 6 1 . 4 1 1 9 - | +1 6 3 9 7 . 0 3 8 4 9 1 - | +9 3 9 0 1 . 5 7 7 6 3 0 2 6 - | -8 3 0 2 8 4 8 5 . - | +7 4 8 8 1 . - | -2 4 9 2 6 8 0 4 . 0 4 5 0 4 7 4 -(10 rows) - ---Testcase 532: -SELECT '' AS to_char_20, to_char(val, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM num_data; - to_char_20 | to_char -------------+----------------------------------------------------------- - | text 9999 "text between quote marks" 0 - | text 9999 "text between quote marks" 0 - | text -3 9999 433 "text between quote marks" 8492 - | text 9999 "text between quote marks" 4 - | text 9999 779 "text between quote marks" 9461 - | text 9999 1 "text between quote marks" 6397 - | text 9999 9 "text between quote marks" 3902 - | text -8 9999 302 "text between quote marks" 8485 - | text 9999 7 "text between quote marks" 4881 - | text -2 9999 492 "text between quote marks" 6804 -(10 rows) - ---Testcase 533: -SELECT '' AS to_char_21, to_char(val, '999999SG9999999999') FROM num_data; - to_char_21 | to_char -------------+------------------- - | + 0 - | + 0 - | - 34338492 - | + 4 - | + 7799461 - | + 16397 - | + 93902 - | - 83028485 - | + 74881 - | - 24926804 -(10 rows) - ---Testcase 534: -SELECT '' AS to_char_22, to_char(val, 'FM9999999999999999.999999999999999') FROM num_data; - to_char_22 | to_char -------------+------------------- - | 0. - | 0. - | -34338492.215397 - | 4.31 - | 7799461.4119 - | 16397.038491 - | 93901.57763026 - | -83028485. - | 74881. - | -24926804.0450474 -(10 rows) - ---Testcase 535: -SELECT '' AS to_char_23, to_char(val, '9.999EEEE') FROM num_data; - to_char_23 | to_char -------------+------------ - | 0.000e+00 - | 0.000e+00 - | -3.434e+07 - | 4.310e+00 - | 7.799e+06 - | 1.640e+04 - | 9.390e+04 - | -8.303e+07 - | 7.488e+04 - | -2.493e+07 -(10 rows) - ---Testcase 536: -DELETE FROM ceil_floor_round; ---Testcase 537: -INSERT INTO ceil_floor_round VALUES ('100'::numeric); ---Testcase 538: -SELECT '' AS to_char_24, to_char(a, 'FM999.9') FROM ceil_floor_round; - to_char_24 | to_char -------------+--------- - | 100. -(1 row) - ---Testcase 539: -SELECT '' AS to_char_25, to_char(a, 'FM999.') FROM ceil_floor_round; - to_char_25 | to_char -------------+--------- - | 100 -(1 row) - ---Testcase 540: -SELECT '' AS to_char_26, to_char(a, 'FM999') FROM ceil_floor_round; - to_char_26 | to_char -------------+--------- - | 100 -(1 row) - --- Check parsing of literal text in a format string ---Testcase 541: -SELECT '' AS to_char_27, to_char(a, 'foo999') FROM ceil_floor_round; - to_char_27 | to_char -------------+--------- - | foo 100 -(1 row) - ---Testcase 542: -SELECT '' AS to_char_28, to_char(a, 'f\oo999') FROM ceil_floor_round; - to_char_28 | to_char -------------+---------- - | f\oo 100 -(1 row) - ---Testcase 543: -SELECT '' AS to_char_29, to_char(a, 'f\\oo999') FROM ceil_floor_round; - to_char_29 | to_char -------------+----------- - | f\\oo 100 -(1 row) - ---Testcase 544: -SELECT '' AS to_char_30, to_char(a, 'f\"oo999') FROM ceil_floor_round; - to_char_30 | to_char -------------+---------- - | f"oo 100 -(1 row) - ---Testcase 545: -SELECT '' AS to_char_31, to_char(a, 'f\\"oo999') FROM ceil_floor_round; - to_char_31 | to_char -------------+----------- - | f\"oo 100 -(1 row) - ---Testcase 546: -SELECT '' AS to_char_32, to_char(a, 'f"ool"999') FROM ceil_floor_round; - to_char_32 | to_char -------------+---------- - | fool 100 -(1 row) - ---Testcase 547: -SELECT '' AS to_char_33, to_char(a, 'f"\ool"999') FROM ceil_floor_round; - to_char_33 | to_char -------------+---------- - | fool 100 -(1 row) - ---Testcase 548: -SELECT '' AS to_char_34, to_char(a, 'f"\\ool"999') FROM ceil_floor_round; - to_char_34 | to_char -------------+----------- - | f\ool 100 -(1 row) - ---Testcase 549: -SELECT '' AS to_char_35, to_char(a, 'f"ool\"999') FROM ceil_floor_round; - to_char_35 | to_char -------------+---------- - | fool"999 -(1 row) - ---Testcase 550: -SELECT '' AS to_char_36, to_char(a, 'f"ool\\"999') FROM ceil_floor_round; - to_char_36 | to_char -------------+----------- - | fool\"999 -(1 row) - --- TO_NUMBER() --- ---Testcase 639: -create foreign table to_number_tbl (a text, id int options (key 'true')) server sqlite_svr; -SET lc_numeric = 'C'; ---Testcase 640: -DELETE FROM to_number_tbl; ---Testcase 641: -INSERT INTO to_number_tbl VALUES ('-34,338,492'); ---Testcase 642: -SELECT '' AS to_number_1, to_number(a, '99G999G999') FROM to_number_tbl; - to_number_1 | to_number --------------+----------- - | -34338492 -(1 row) - ---Testcase 643: -DELETE FROM to_number_tbl; ---Testcase 644: -INSERT INTO to_number_tbl VALUES ('-34,338,492.654,878'); ---Testcase 645: -SELECT '' AS to_number_2, to_number(a, '99G999G999D999G999') FROM to_number_tbl; - to_number_2 | to_number --------------+------------------ - | -34338492.654878 -(1 row) - ---Testcase 646: -DELETE FROM to_number_tbl; ---Testcase 647: -INSERT INTO to_number_tbl VALUES ('<564646.654564>'); ---Testcase 648: -SELECT '' AS to_number_3, to_number(a, '999999.999999PR') FROM to_number_tbl; - to_number_3 | to_number --------------+---------------- - | -564646.654564 -(1 row) - ---Testcase 649: -DELETE FROM to_number_tbl; ---Testcase 650: -INSERT INTO to_number_tbl VALUES ('0.00001-'); ---Testcase 651: -SELECT '' AS to_number_4, to_number(a, '9.999999S') FROM to_number_tbl; - to_number_4 | to_number --------------+----------- - | -0.00001 -(1 row) - ---Testcase 652: -DELETE FROM to_number_tbl; ---Testcase 653: -INSERT INTO to_number_tbl VALUES ('5.01-'); ---Testcase 654: -SELECT '' AS to_number_5, to_number(a, 'FM9.999999S') FROM to_number_tbl; - to_number_5 | to_number --------------+----------- - | -5.01 -(1 row) - ---Testcase 655: -DELETE FROM to_number_tbl; ---Testcase 656: -INSERT INTO to_number_tbl VALUES ('5.01-'); ---Testcase 657: -SELECT '' AS to_number_5, to_number(a, 'FM9.999999MI') FROM to_number_tbl; - to_number_5 | to_number --------------+----------- - | -5.01 -(1 row) - ---Testcase 658: -DELETE FROM to_number_tbl; ---Testcase 659: -INSERT INTO to_number_tbl VALUES ('5 4 4 4 4 8 . 7 8'); ---Testcase 660: -SELECT '' AS to_number_7, to_number(a, '9 9 9 9 9 9 . 9 9') FROM to_number_tbl; - to_number_7 | to_number --------------+----------- - | 544448.78 -(1 row) - ---Testcase 661: -DELETE FROM to_number_tbl; ---Testcase 662: -INSERT INTO to_number_tbl VALUES ('.01'); ---Testcase 663: -SELECT '' AS to_number_8, to_number(a, 'FM9.99') FROM to_number_tbl; - to_number_8 | to_number --------------+----------- - | 0.01 -(1 row) - ---Testcase 664: -DELETE FROM to_number_tbl; ---Testcase 665: -INSERT INTO to_number_tbl VALUES ('.0'); ---Testcase 666: -SELECT '' AS to_number_9, to_number(a, '99999999.99999999') FROM to_number_tbl; - to_number_9 | to_number --------------+----------- - | 0.0 -(1 row) - ---Testcase 667: -DELETE FROM to_number_tbl; ---Testcase 668: -INSERT INTO to_number_tbl VALUES ('0'); ---Testcase 669: -SELECT '' AS to_number_10, to_number(a, '99.99') FROM to_number_tbl; - to_number_10 | to_number ---------------+----------- - | 0 -(1 row) - ---Testcase 670: -DELETE FROM to_number_tbl; ---Testcase 671: -INSERT INTO to_number_tbl VALUES ('.-01'); ---Testcase 672: -SELECT '' AS to_number_11, to_number(a, 'S99.99') FROM to_number_tbl; - to_number_11 | to_number ---------------+----------- - | -0.01 -(1 row) - ---Testcase 673: -DELETE FROM to_number_tbl; ---Testcase 674: -INSERT INTO to_number_tbl VALUES ('.01-'); ---Testcase 675: -SELECT '' AS to_number_12, to_number(a, '99.99S') FROM to_number_tbl; - to_number_12 | to_number ---------------+----------- - | -0.01 -(1 row) - ---Testcase 676: -DELETE FROM to_number_tbl; ---Testcase 677: -INSERT INTO to_number_tbl VALUES (' . 0 1-'); ---Testcase 678: -SELECT '' AS to_number_13, to_number(a, ' 9 9 . 9 9 S') FROM to_number_tbl; - to_number_13 | to_number ---------------+----------- - | -0.01 -(1 row) - ---Testcase 679: -DELETE FROM to_number_tbl; ---Testcase 680: -INSERT INTO to_number_tbl VALUES ('34,50'); ---Testcase 681: -SELECT '' AS to_number_14, to_number(a,'999,99') FROM to_number_tbl; - to_number_14 | to_number ---------------+----------- - | 340 -(1 row) - ---Testcase 682: -DELETE FROM to_number_tbl; ---Testcase 683: -INSERT INTO to_number_tbl VALUES ('123,000'); ---Testcase 684: -SELECT '' AS to_number_15, to_number(a,'999G') FROM to_number_tbl; - to_number_15 | to_number ---------------+----------- - | 123 -(1 row) - ---Testcase 685: -DELETE FROM to_number_tbl; ---Testcase 686: -INSERT INTO to_number_tbl VALUES ('123456'); ---Testcase 687: -SELECT '' AS to_number_16, to_number(a,'999G999') FROM to_number_tbl; - to_number_16 | to_number ---------------+----------- - | 12356 -(1 row) - ---Testcase 688: -DELETE FROM to_number_tbl; ---Testcase 689: -INSERT INTO to_number_tbl VALUES ('$1234.56'); ---Testcase 690: -SELECT '' AS to_number_17, to_number(a,'L9,999.99') FROM to_number_tbl; - to_number_17 | to_number ---------------+----------- - | 134.56 -(1 row) - ---Testcase 691: -DELETE FROM to_number_tbl; ---Testcase 692: -INSERT INTO to_number_tbl VALUES ('$1234.56'); ---Testcase 693: -SELECT '' AS to_number_18, to_number(a,'L99,999.99') FROM to_number_tbl; - to_number_18 | to_number ---------------+----------- - | 124.56 -(1 row) - ---Testcase 694: -DELETE FROM to_number_tbl; ---Testcase 695: -INSERT INTO to_number_tbl VALUES ('$1,234.56'); ---Testcase 696: -SELECT '' AS to_number_19, to_number(a,'L99,999.99') FROM to_number_tbl; - to_number_19 | to_number ---------------+----------- - | 134.56 -(1 row) - ---Testcase 697: -DELETE FROM to_number_tbl; ---Testcase 698: -INSERT INTO to_number_tbl VALUES ('1234.56'); ---Testcase 699: -SELECT '' AS to_number_20, to_number(a,'L99,999.99') FROM to_number_tbl; - to_number_20 | to_number ---------------+----------- - | 23.56 -(1 row) - ---Testcase 700: -DELETE FROM to_number_tbl; ---Testcase 701: -INSERT INTO to_number_tbl VALUES ('1,234.56'); ---Testcase 702: -SELECT '' AS to_number_21, to_number(a,'L99,999.99') FROM to_number_tbl; - to_number_21 | to_number ---------------+----------- - | 24.56 -(1 row) - ---Testcase 703: -DELETE FROM to_number_tbl; ---Testcase 704: -INSERT INTO to_number_tbl VALUES ('42nd'); ---Testcase 705: -SELECT '' AS to_number_22, to_number(a, '99th') FROM to_number_tbl; - to_number_22 | to_number ---------------+----------- - | 42 -(1 row) - -RESET lc_numeric; --- --- Input syntax --- ---Testcase 706: -CREATE FOREIGN TABLE num_input_test (n1 numeric) SERVER sqlite_svr; --- good inputs ---Testcase 551: -INSERT INTO num_input_test(n1) VALUES (' 123'); ---Testcase 552: -INSERT INTO num_input_test(n1) VALUES (' 3245874 '); ---Testcase 553: -INSERT INTO num_input_test(n1) VALUES (' -93853'); ---Testcase 554: -INSERT INTO num_input_test(n1) VALUES ('555.50'); ---Testcase 555: -INSERT INTO num_input_test(n1) VALUES ('-555.50'); ---Testcase 556: -INSERT INTO num_input_test(n1) VALUES ('NaN '); ---Testcase 557: -INSERT INTO num_input_test(n1) VALUES (' nan'); --- bad inputs ---Testcase 558: -INSERT INTO num_input_test(n1) VALUES (' '); -ERROR: invalid input syntax for type numeric: " " -LINE 1: INSERT INTO num_input_test(n1) VALUES (' '); - ^ ---Testcase 559: -INSERT INTO num_input_test(n1) VALUES (' 1234 %'); -ERROR: invalid input syntax for type numeric: " 1234 %" -LINE 1: INSERT INTO num_input_test(n1) VALUES (' 1234 %'); - ^ ---Testcase 560: -INSERT INTO num_input_test(n1) VALUES ('xyz'); -ERROR: invalid input syntax for type numeric: "xyz" -LINE 1: INSERT INTO num_input_test(n1) VALUES ('xyz'); - ^ ---Testcase 561: -INSERT INTO num_input_test(n1) VALUES ('- 1234'); -ERROR: invalid input syntax for type numeric: "- 1234" -LINE 1: INSERT INTO num_input_test(n1) VALUES ('- 1234'); - ^ ---Testcase 562: -INSERT INTO num_input_test(n1) VALUES ('5 . 0'); -ERROR: invalid input syntax for type numeric: "5 . 0" -LINE 1: INSERT INTO num_input_test(n1) VALUES ('5 . 0'); - ^ ---Testcase 563: -INSERT INTO num_input_test(n1) VALUES ('5. 0 '); -ERROR: invalid input syntax for type numeric: "5. 0 " -LINE 1: INSERT INTO num_input_test(n1) VALUES ('5. 0 '); - ^ ---Testcase 564: -INSERT INTO num_input_test(n1) VALUES (''); -ERROR: invalid input syntax for type numeric: "" -LINE 1: INSERT INTO num_input_test(n1) VALUES (''); - ^ ---Testcase 565: -INSERT INTO num_input_test(n1) VALUES (' N aN '); -ERROR: invalid input syntax for type numeric: " N aN " -LINE 1: INSERT INTO num_input_test(n1) VALUES (' N aN '); - ^ ---Testcase 566: -SELECT * FROM num_input_test; - n1 ---------- - 123 - 3245874 - -93853 - 555.5 - -555.5 - - -(7 rows) - --- --- Test some corner cases for multiplication --- ---Testcase 707: -CREATE FOREIGN TABLE num_tmp (n1 numeric, n2 numeric, id int options (key 'true')) SERVER sqlite_svr; ---Testcase 708: -INSERT INTO num_tmp VALUES (4790999999999999999999999999999999999999999999999999999999999999999999999999999999999999, 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); ---Testcase 709: -SELECT n1 * n2 FROM num_tmp; - ?column? ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 47910000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -(1 row) - ---Testcase 710: -DELETE FROM num_tmp; ---Testcase 711: -INSERT INTO num_tmp VALUES (4789999999999999999999999999999999999999999999999999999999999999999999999999999999999999, 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); ---Testcase 712: -SELECT n1 * n2 FROM num_tmp; - ?column? ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 47900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -(1 row) - ---Testcase 713: -DELETE FROM num_tmp; ---Testcase 714: -INSERT INTO num_tmp VALUES (4770999999999999999999999999999999999999999999999999999999999999999999999999999999999999, 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); ---Testcase 715: -SELECT n1 * n2 FROM num_tmp; - ?column? ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 47710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -(1 row) - ---Testcase 716: -DELETE FROM num_tmp; ---Testcase 717: -INSERT INTO num_tmp VALUES (4769999999999999999999999999999999999999999999999999999999999999999999999999999999999999, 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); ---Testcase 718: -SELECT n1 * n2 FROM num_tmp; - ?column? ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 47700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -(1 row) - --- --- Test some corner cases for division --- ---Testcase 719: -DELETE FROM num_tmp; ---Testcase 720: -INSERT INTO num_tmp VALUES (999999999999999999999, 1000000000000000000000); ---Testcase 721: -SELECT n1::numeric / n2 FROM num_tmp; - ?column? ------------------------- - 1.00000000000000000000 -(1 row) - ---Testcase 722: -DELETE FROM num_tmp; ---Testcase 723: -INSERT INTO num_tmp VALUES (999999999999999999999, 1000000000000000000000); ---Testcase 724: -SELECT div(n1::numeric, n2) FROM num_tmp; - div ------ - 1 -(1 row) - ---Testcase 725: -SELECT mod(n1::numeric, n2) FROM num_tmp; - mod ------ - 0 -(1 row) - ---Testcase 726: -SELECT div(-n1::numeric, n2) FROM num_tmp; - div ------ - -1 -(1 row) - ---Testcase 727: -SELECT mod(-n1::numeric, n2) FROM num_tmp; - mod ------ - 0 -(1 row) - ---Testcase 728: -select div(-n1::numeric,n2)*n2 + mod(-n1::numeric,n2) FROM num_tmp; - ?column? -------------------------- - -1000000000000000000000 -(1 row) - ---Testcase 729: -DELETE FROM num_tmp; ---Testcase 730: -INSERT INTO num_tmp VALUES (70.0,70); ---Testcase 731: -select mod (n1, n2) FROM num_tmp; - mod ------ - 0 -(1 row) - ---Testcase 732: -select div (n1, n2) FROM num_tmp; - div ------ - 1 -(1 row) - ---Testcase 733: -select n1 / n2 FROM num_tmp; - ?column? ------------------------- - 1.00000000000000000000 -(1 row) - ---Testcase 734: -DELETE FROM num_tmp; ---Testcase 735: -INSERT INTO num_tmp VALUES (12345678901234567890, 123); ---Testcase 736: -select n1 % n2 FROM num_tmp; - ?column? ----------- - 85 -(1 row) - ---Testcase 737: -select n1 / n2 FROM num_tmp; - ?column? --------------------- - 100371373180769106 -(1 row) - ---Testcase 738: -select div(n1, n2) FROM num_tmp; - div --------------------- - 100371373180769105 -(1 row) - ---Testcase 739: -select div(n1, n2) * n2 + n1 % n2 FROM num_tmp; - ?column? ----------------------- - 12345678901234600000 -(1 row) - --- --- Test some corner cases for square root --- ---Testcase 740: -DELETE FROM num_tmp; ---Testcase 741: -INSERT INTO num_tmp VALUES (1.000000000000003::numeric); ---Testcase 742: -SELECT sqrt(n1) FROM num_tmp; - sqrt -------------------- - 1.000000000000000 -(1 row) - ---Testcase 743: -DELETE FROM num_tmp; ---Testcase 744: -INSERT INTO num_tmp VALUES (1.000000000000004::numeric); ---Testcase 745: -SELECT sqrt(n1) FROM num_tmp; - sqrt -------------------- - 1.000000000000000 -(1 row) - ---Testcase 746: -DELETE FROM num_tmp; ---Testcase 747: -INSERT INTO num_tmp VALUES (96627521408608.56340355805::numeric); ---Testcase 748: -SELECT sqrt(n1) FROM num_tmp; - sqrt -------------------- - 9829929.878112488 -(1 row) - ---Testcase 749: -DELETE FROM num_tmp; ---Testcase 750: -INSERT INTO num_tmp VALUES (96627521408608.56340355806::numeric); ---Testcase 751: -SELECT sqrt(n1) FROM num_tmp; - sqrt -------------------- - 9829929.878112488 -(1 row) - ---Testcase 752: -DELETE FROM num_tmp; ---Testcase 753: -INSERT INTO num_tmp VALUES (515549506212297735.073688290367::numeric); ---Testcase 754: -SELECT sqrt(n1) FROM num_tmp; - sqrt -------------------- - 718017761.7665861 -(1 row) - ---Testcase 755: -DELETE FROM num_tmp; ---Testcase 756: -INSERT INTO num_tmp VALUES (515549506212297735.073688290368::numeric); ---Testcase 757: -SELECT sqrt(n1) FROM num_tmp; - sqrt -------------------- - 718017761.7665861 -(1 row) - ---Testcase 758: -DELETE FROM num_tmp; ---Testcase 759: -INSERT INTO num_tmp VALUES (8015491789940783531003294973900306::numeric); ---Testcase 760: -SELECT sqrt(n1) FROM num_tmp; - sqrt -------------------- - 89529278953539998 -(1 row) - ---Testcase 761: -DELETE FROM num_tmp; ---Testcase 762: -INSERT INTO num_tmp VALUES (8015491789940783531003294973900307::numeric); ---Testcase 763: -SELECT sqrt(n1) FROM num_tmp; - sqrt -------------------- - 89529278953539998 -(1 row) - --- --- Test code path for raising to integer powers --- ---Testcase 764: -DELETE FROM num_tmp; ---Testcase 765: -INSERT INTO num_tmp VALUES (10.0, -2147483648); ---Testcase 766: -SELECT n1 ^ n2 as rounds_to_zero FROM num_tmp; - rounds_to_zero --------------------- - 0.0000000000000000 -(1 row) - ---Testcase 767: -DELETE FROM num_tmp; ---Testcase 768: -INSERT INTO num_tmp VALUES (10.0, -2147483647); ---Testcase 769: -SELECT n1 ^ n2 as rounds_to_zero FROM num_tmp; - rounds_to_zero --------------------- - 0.0000000000000000 -(1 row) - ---Testcase 770: -DELETE FROM num_tmp; ---Testcase 771: -INSERT INTO num_tmp VALUES (10.0, 2147483647); ---Testcase 772: -SELECT n1 ^ n2 as overflows FROM num_tmp; -ERROR: value overflows numeric format ---Testcase 773: -DELETE FROM num_tmp; ---Testcase 774: -INSERT INTO num_tmp VALUES (117743296169.0, -1000000000); ---Testcase 775: -SELECT n1 ^ n2 as overflows FROM num_tmp; - overflows --------------------- - 0.0000000000000000 -(1 row) - --- cases that used to return inaccurate results ---Testcase 776: -DELETE FROM num_tmp; ---Testcase 777: -INSERT INTO num_tmp VALUES (3.789, 21); ---Testcase 778: -select n1 ^ n2 FROM num_tmp; - ?column? --------------------------------- - 1409343026052.8716016316022141 -(1 row) - ---Testcase 779: -DELETE FROM num_tmp; ---Testcase 780: -INSERT INTO num_tmp VALUES (3.789, 35); ---Testcase 781: -select n1 ^ n2 FROM num_tmp; - ?column? ----------------------------------------- - 177158169650516670809.3820586142670135 -(1 row) - ---Testcase 782: -DELETE FROM num_tmp; ---Testcase 783: -INSERT INTO num_tmp VALUES (1.2, 345); ---Testcase 784: -select n1 ^ n2 FROM num_tmp; - ?column? ------------------------------------------------ - 2077446682327378559843444695.5827049735727869 -(1 row) - ---Testcase 785: -DELETE FROM num_tmp; ---Testcase 786: -INSERT INTO num_tmp VALUES (0.12, (-20)); ---Testcase 787: -select n1 ^ n2 FROM num_tmp; - ?column? --------------------------------------- - 2608405330458882702.5529619561355838 -(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; - ?column? -------------------------------------------- - 104825960103961013959336.4983657883169110 -(1 row) - ---Testcase 791: -DELETE FROM num_tmp; ---Testcase 792: -INSERT INTO num_tmp VALUES (0.5678, (-85)); ---Testcase 793: -select n1 ^ n2 FROM num_tmp; - ?column? ----------------------------------------- - 782333637740774446257.7719390061997396 -(1 row) - --- --- Tests for raising to non-integer powers --- --- special cases ---Testcase 794: -DELETE FROM num_tmp; ---Testcase 795: -INSERT INTO num_tmp VALUES (0.0, 0.0); ---Testcase 796: -select n1 ^ n2 FROM num_tmp; - ?column? --------------------- - 1.0000000000000000 -(1 row) - ---Testcase 797: -DELETE FROM num_tmp; ---Testcase 798: -INSERT INTO num_tmp VALUES ((-12.34), 0.0); ---Testcase 799: -select n1 ^ n2 FROM num_tmp; - ?column? --------------------- - 1.0000000000000000 -(1 row) - ---Testcase 800: -DELETE FROM num_tmp; ---Testcase 801: -INSERT INTO num_tmp VALUES (12.34, 0.0); ---Testcase 802: -select n1 ^ n2 FROM num_tmp; - ?column? --------------------- - 1.0000000000000000 -(1 row) - ---Testcase 803: -DELETE FROM num_tmp; ---Testcase 804: -INSERT INTO num_tmp VALUES (0.0, 12.34); ---Testcase 805: -select n1 ^ n2 FROM num_tmp; - ?column? --------------------- - 0.0000000000000000 -(1 row) - --- NaNs ---Testcase 806: -DELETE FROM num_tmp; ---Testcase 807: -INSERT INTO num_tmp VALUES ('NaN'::numeric, 'NaN'::numeric); ---Testcase 808: -select n1 ^ n2 FROM num_tmp; - ?column? ----------- - -(1 row) - ---Testcase 809: -DELETE FROM num_tmp; ---Testcase 810: -INSERT INTO num_tmp VALUES ('NaN'::numeric, 0); ---Testcase 811: -select n1 ^ n2 FROM num_tmp; - ?column? ----------- - -(1 row) - ---Testcase 812: -DELETE FROM num_tmp; ---Testcase 813: -INSERT INTO num_tmp VALUES ('NaN'::numeric, 1); ---Testcase 814: -select n1 ^ n2 FROM num_tmp; - ?column? ----------- - -(1 row) - ---Testcase 815: -DELETE FROM num_tmp; ---Testcase 816: -INSERT INTO num_tmp VALUES (0, 'NaN'::numeric); ---Testcase 817: -select n1 ^ n2 FROM num_tmp; - ?column? ----------- - -(1 row) - ---Testcase 818: -DELETE FROM num_tmp; ---Testcase 819: -INSERT INTO num_tmp VALUES (1, 'NaN'::numeric); ---Testcase 820: -select n1 ^ n2 FROM num_tmp; - ?column? ----------- - -(1 row) - --- invalid inputs ---Testcase 821: -DELETE FROM num_tmp; ---Testcase 822: -INSERT INTO num_tmp VALUES (0.0, (-12.34)); ---Testcase 823: -select n1 ^ n2 FROM num_tmp; -ERROR: zero raised to a negative power is undefined ---Testcase 824: -DELETE FROM num_tmp; ---Testcase 825: -INSERT INTO num_tmp VALUES ((-12.34), 1.2); ---Testcase 826: -select n1 ^ n2 FROM num_tmp; -ERROR: a negative number raised to a non-integer power yields a complex result --- cases that used to generate inaccurate results ---Testcase 827: -DELETE FROM num_tmp; ---Testcase 828: -INSERT INTO num_tmp VALUES (32.1, 9.8); ---Testcase 829: -select n1 ^ n2 FROM num_tmp; - ?column? --------------------- - 580429286790711.10 -(1 row) - ---Testcase 830: -DELETE FROM num_tmp; ---Testcase 831: -INSERT INTO num_tmp VALUES (32.1, (-9.8)); ---Testcase 832: -select n1 ^ n2 FROM num_tmp; - ?column? ----------------------------------- - 0.000000000000001722862754788209 -(1 row) - ---Testcase 833: -DELETE FROM num_tmp; ---Testcase 834: -INSERT INTO num_tmp VALUES (12.3, 45.6); ---Testcase 835: -select n1 ^ n2 FROM num_tmp; - ?column? ------------------------------------------------------- - 50081010321492803393171165777624533697036806969694.9 -(1 row) - ---Testcase 836: -DELETE FROM num_tmp; ---Testcase 837: -INSERT INTO num_tmp VALUES (12.3, (-45.6)); ---Testcase 838: -select n1 ^ n2 FROM num_tmp; - ?column? ---------------------------------------------------------------------- - 0.00000000000000000000000000000000000000000000000001996764828785491 -(1 row) - --- big test ---Testcase 839: -DELETE FROM num_tmp; ---Testcase 840: -INSERT INTO num_tmp VALUES (1.234, 5678); ---Testcase 841: -select n1 ^ n2 FROM num_tmp; - ?column? ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 307239295662090741644584872593956173493568238595074141254349565406661439636598896798876823220904084953233015553994854875890890858118656468658643918169805277399402542281777901029346337707622181574346585989613344285010764501017625366742865066948856161360224801370482171458030533346309750557140549621313515752078638620714732831815297168231790779296290266207315344008883935010274044001522606235576584215999260117523114297033944018699691024106823438431754073086813382242140602291215149759520833200152654884259619588924545324.5973362312547382 -(1 row) - --- --- Tests for EXP() --- --- special cases ---Testcase 842: -DELETE FROM num_tmp; ---Testcase 843: -INSERT INTO num_tmp VALUES (0.0); ---Testcase 844: -select exp(n1) from num_tmp; - exp --------------------- - 1.0000000000000000 -(1 row) - ---Testcase 845: -DELETE FROM num_tmp; ---Testcase 846: -INSERT INTO num_tmp VALUES (1.0); ---Testcase 847: -select exp(n1) from num_tmp; - exp --------------------- - 2.7182818284590452 -(1 row) - ---Testcase 848: -DELETE FROM num_tmp; ---Testcase 849: -INSERT INTO num_tmp VALUES (1.0::numeric(71,70)); ---Testcase 850: -select exp(n1) from num_tmp; - exp --------------------- - 2.7182818284590452 -(1 row) - --- cases that used to generate inaccurate results ---Testcase 851: -DELETE FROM num_tmp; ---Testcase 852: -INSERT INTO num_tmp VALUES (32.999); ---Testcase 853: -select exp(n1) from num_tmp; - exp ---------------------- - 214429043492155.053 -(1 row) - ---Testcase 854: -DELETE FROM num_tmp; ---Testcase 855: -INSERT INTO num_tmp VALUES (-32.999); ---Testcase 856: -select exp(n1) from num_tmp; - exp ----------------------------------- - 0.000000000000004663547361468248 -(1 row) - ---Testcase 857: -DELETE FROM num_tmp; ---Testcase 858: -INSERT INTO num_tmp VALUES (123.456); ---Testcase 859: -select exp(n1) from num_tmp; - exp ------------------------------------------------------------- - 413294435277809344957685441227343146614594393746575438.725 -(1 row) - ---Testcase 860: -DELETE FROM num_tmp; ---Testcase 861: -INSERT INTO num_tmp VALUES (-123.456); ---Testcase 862: -select exp(n1) from num_tmp; - exp -------------------------------------------------------------------------- - 0.000000000000000000000000000000000000000000000000000002419582541264601 -(1 row) - --- big test ---Testcase 863: -DELETE FROM num_tmp; ---Testcase 864: -INSERT INTO num_tmp VALUES (1234.5678); ---Testcase 865: -select exp(n1) from num_tmp; - exp ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - 146549072930959479983482138503979804217622199675223653966270157446954995433819741094410764947112047906012815540251009949604426069672532417736057033099274204598385314594846509975629046864798765888104789074984927709616261452461385220475510438783429612447831614003668421849727379202555580791042606170523016207262965336641214601082882495255771621327088265411334088968112458492660609809762865582162764292604697957813514621259353683899630997077707406305730694385703091201347848855199354307506425820147289848677003277208302716466011827836279231.9667 -(1 row) - --- --- Tests for generate_series --- ---Testcase 866: -DELETE FROM num_tmp; ---Testcase 867: -INSERT INTO num_tmp select * from generate_series(0.0::numeric, 4.0::numeric); ---Testcase 868: -SELECT n1 FROM num_tmp; - n1 ----- - 0 - 1 - 2 - 3 - 4 -(5 rows) - ---Testcase 869: -DELETE FROM num_tmp; ---Testcase 870: -INSERT INTO num_tmp select * from generate_series(0.1::numeric, 4.0::numeric, 1.3::numeric); ---Testcase 871: -SELECT n1 FROM num_tmp; - n1 ------ - 0.1 - 1.4 - 2.7 - 4 -(4 rows) - ---Testcase 872: -DELETE FROM num_tmp; ---Testcase 873: -INSERT INTO num_tmp select * from generate_series(4.0::numeric, -1.5::numeric, -2.2::numeric); ---Testcase 874: -SELECT n1 FROM num_tmp; - n1 ------- - 4 - 1.8 - -0.4 -(3 rows) - --- Trigger errors ---Testcase 875: -DELETE FROM num_tmp; ---Testcase 876: -INSERT INTO num_tmp select * from generate_series(-100::numeric, 100::numeric, 0::numeric); -ERROR: step size cannot equal zero ---Testcase 877: -SELECT n1 FROM num_tmp; - n1 ----- -(0 rows) - ---Testcase 878: -DELETE FROM num_tmp; ---Testcase 879: -INSERT INTO num_tmp select * from generate_series(-100::numeric, 100::numeric, 'nan'::numeric); -ERROR: step size cannot be NaN ---Testcase 880: -SELECT n1 FROM num_tmp; - n1 ----- -(0 rows) - ---Testcase 881: -DELETE FROM num_tmp; ---Testcase 882: -INSERT INTO num_tmp select * from generate_series('nan'::numeric, 100::numeric, 10::numeric); -ERROR: start value cannot be NaN ---Testcase 883: -SELECT n1 FROM num_tmp; - n1 ----- -(0 rows) - ---Testcase 884: -DELETE FROM num_tmp; ---Testcase 885: -INSERT INTO num_tmp select * from generate_series(0::numeric, 'nan'::numeric, 10::numeric); -ERROR: stop value cannot be NaN ---Testcase 886: -SELECT n2 FROM num_tmp; - n2 ----- -(0 rows) - --- Checks maximum, output is truncated ---Testcase 887: -DELETE FROM num_tmp; ---Testcase 888: -INSERT INTO num_tmp select (i / (10::numeric ^ 131071))::numeric(1,0) - from generate_series(6 * (10::numeric ^ 131071), - 9 * (10::numeric ^ 131071), - 10::numeric ^ 131071) i; ---Testcase 889: -SELECT n1 FROM num_tmp; - n1 ----- - 6 - 7 - 8 - 9 -(4 rows) - - --- Check usage with variables ---Testcase 890: -DELETE FROM num_tmp; ---Testcase 891: -INSERT INTO num_tmp select * from generate_series(1::numeric, 3::numeric) i, generate_series(i,3) j; ---Testcase 892: -SELECT n1, n2 FROM num_tmp; - n1 | n2 -----+---- - 1 | 1 - 1 | 2 - 1 | 3 - 2 | 2 - 2 | 3 - 3 | 3 -(6 rows) - ---Testcase 893: -DELETE FROM num_tmp; ---Testcase 894: -INSERT INTO num_tmp select * from generate_series(1::numeric, 3::numeric) i, generate_series(1,i) j; ---Testcase 895: -SELECT n1, n2 FROM num_tmp; - n1 | n2 -----+---- - 1 | 1 - 2 | 1 - 2 | 2 - 3 | 1 - 3 | 2 - 3 | 3 -(6 rows) - ---Testcase 896: -DELETE FROM num_tmp; ---Testcase 897: -INSERT INTO num_tmp select * from generate_series(1::numeric, 3::numeric) i, generate_series(1,5,i) j; ---Testcase 898: -SELECT n1, n2 FROM num_tmp; - n1 | n2 -----+---- - 1 | 1 - 1 | 2 - 1 | 3 - 1 | 4 - 1 | 5 - 2 | 1 - 2 | 3 - 2 | 5 - 3 | 1 - 3 | 4 -(10 rows) - --- --- Tests for LN() --- --- Invalid inputs ---Testcase 899: -DELETE FROM num_tmp; ---Testcase 900: -INSERT INTO num_tmp VALUES (-12.34); ---Testcase 901: -select ln(n1) from num_tmp; -ERROR: cannot take logarithm of a negative number ---Testcase 902: -DELETE FROM num_tmp; ---Testcase 903: -INSERT INTO num_tmp VALUES (0.0); ---Testcase 904: -select ln(n1) from num_tmp; -ERROR: cannot take logarithm of zero --- Some random tests ---Testcase 905: -DELETE FROM num_tmp; ---Testcase 906: -INSERT INTO num_tmp VALUES (1.2345678e-28); ---Testcase 907: -select ln(n1) from num_tmp; - ln ------------------------------------------ - -64.26166165451762991204894255882820859 -(1 row) - ---Testcase 908: -DELETE FROM num_tmp; ---Testcase 909: -INSERT INTO num_tmp VALUES (0.0456789); ---Testcase 910: -select ln(n1) from num_tmp; - ln ---------------------- - -3.0861187944847439 -(1 row) - ---Testcase 911: -DELETE FROM num_tmp; ---Testcase 912: -INSERT INTO num_tmp VALUES (0.349873948359354029493948309745709580730482050975); ---Testcase 913: -select ln(n1) from num_tmp; - ln ---------------------- - -1.0501823369120829 -(1 row) - ---Testcase 914: -DELETE FROM num_tmp; ---Testcase 915: -INSERT INTO num_tmp VALUES (0.99949452); ---Testcase 916: -select ln(n1) from num_tmp; - ln -------------------------- - -0.00050560779808326467 -(1 row) - ---Testcase 917: -DELETE FROM num_tmp; ---Testcase 918: -INSERT INTO num_tmp VALUES (1.00049687395); ---Testcase 919: -select ln(n1) from num_tmp; - ln ------------------------- - 0.00049675054901370394 -(1 row) - ---Testcase 920: -DELETE FROM num_tmp; ---Testcase 921: -INSERT INTO num_tmp VALUES (1234.567890123456789); ---Testcase 922: -select ln(n1) from num_tmp; - ln --------------------- - 7.1184763012977922 -(1 row) - ---Testcase 923: -DELETE FROM num_tmp; ---Testcase 924: -INSERT INTO num_tmp VALUES (5.80397490724e5); ---Testcase 925: -select ln(n1) from num_tmp; - ln --------------------- - 13.271468476626518 -(1 row) - ---Testcase 926: -DELETE FROM num_tmp; ---Testcase 927: -INSERT INTO num_tmp VALUES (9.342536355e34); ---Testcase 928: -select ln(n1) from num_tmp; - ln --------------------- - 80.522470935524187 -(1 row) - --- --- Tests for LOG() (base 10) --- --- invalid inputs ---Testcase 929: -DELETE FROM num_tmp; ---Testcase 930: -INSERT INTO num_tmp VALUES (-12.34); ---Testcase 931: -select log(n1) from num_tmp; -ERROR: cannot take logarithm of a negative number ---Testcase 932: -DELETE FROM num_tmp; ---Testcase 933: -INSERT INTO num_tmp VALUES (0.0); ---Testcase 934: -select log(n1) from num_tmp; -ERROR: cannot take logarithm of zero --- some random tests ---Testcase 935: -DELETE FROM num_tmp; ---Testcase 936: -INSERT INTO num_tmp VALUES (1.234567e-89); ---Testcase 937: -select log(n1) from num_tmp; - log ------------------------------------------------------------------------------------------------------ - -88.90848533591373725637496492944925187293052336306443143312825869985819779294142441287021741054275 -(1 row) - ---Testcase 938: -DELETE FROM num_tmp; ---Testcase 939: -INSERT INTO num_tmp VALUES (3.4634998359873254962349856073435545); ---Testcase 940: -select log(n1) from num_tmp; - log --------------------- - 0.5395151714070140 -(1 row) - ---Testcase 941: -DELETE FROM num_tmp; ---Testcase 942: -INSERT INTO num_tmp VALUES (9.999999999999999999); ---Testcase 943: -select log(n1) from num_tmp; - log --------------------- - 1.0000000000000000 -(1 row) - ---Testcase 944: -DELETE FROM num_tmp; ---Testcase 945: -INSERT INTO num_tmp VALUES (10.00000000000000000); ---Testcase 946: -select log(n1) from num_tmp; - log --------------------- - 1.0000000000000000 -(1 row) - ---Testcase 947: -DELETE FROM num_tmp; ---Testcase 948: -INSERT INTO num_tmp VALUES (10.00000000000000001); ---Testcase 949: -select log(n1) from num_tmp; - log --------------------- - 1.0000000000000000 -(1 row) - ---Testcase 950: -DELETE FROM num_tmp; ---Testcase 951: -INSERT INTO num_tmp VALUES (590489.45235237); ---Testcase 952: -select log(n1) from num_tmp; - log -------------------- - 5.771212144411727 -(1 row) - --- --- Tests for LOG() (arbitrary base) --- --- invalid inputs ---Testcase 953: -DELETE FROM num_tmp; ---Testcase 954: -INSERT INTO num_tmp VALUES (-12.34, 56.78); ---Testcase 955: -select log(n1, n2) from num_tmp; -ERROR: cannot take logarithm of a negative number ---Testcase 956: -DELETE FROM num_tmp; ---Testcase 957: -INSERT INTO num_tmp VALUES (-12.34, -56.78); ---Testcase 958: -select log(n1, n2) from num_tmp; -ERROR: cannot take logarithm of a negative number ---Testcase 959: -DELETE FROM num_tmp; ---Testcase 960: -INSERT INTO num_tmp VALUES (12.34, -56.78); ---Testcase 961: -select log(n1, n2) from num_tmp; -ERROR: cannot take logarithm of a negative number ---Testcase 962: -DELETE FROM num_tmp; ---Testcase 963: -INSERT INTO num_tmp VALUES (0.0, 12.34); ---Testcase 964: -select log(n1, n2) from num_tmp; -ERROR: cannot take logarithm of zero ---Testcase 965: -DELETE FROM num_tmp; ---Testcase 966: -INSERT INTO num_tmp VALUES (12.34, 0.0); ---Testcase 967: -select log(n1, n2) from num_tmp; -ERROR: cannot take logarithm of zero ---Testcase 968: -DELETE FROM num_tmp; ---Testcase 969: -INSERT INTO num_tmp VALUES (.0, 12.34); ---Testcase 970: -select log(n1, n2) from num_tmp; -ERROR: cannot take logarithm of zero --- some random tests ---Testcase 971: -DELETE FROM num_tmp; ---Testcase 972: -INSERT INTO num_tmp VALUES (1.23e-89, 6.4689e45); ---Testcase 973: -select log(n1, n2) from num_tmp; - log ------------------------------------------------------------------------------------------------- - -0.5152489207781856983977054971756484879653568168479201885425588841094788842469115325262329756 -(1 row) - ---Testcase 974: -DELETE FROM num_tmp; ---Testcase 975: -INSERT INTO num_tmp VALUES (0.99923, 4.58934e34); ---Testcase 976: -select log(n1, n2) from num_tmp; - log ---------------------- - -103611.55579544132 -(1 row) - ---Testcase 977: -DELETE FROM num_tmp; ---Testcase 978: -INSERT INTO num_tmp VALUES (1.000016, 8.452010e18); ---Testcase 979: -select log(n1, n2) from num_tmp; - log --------------------- - 2723830.2877097365 -(1 row) - ---Testcase 980: -DELETE FROM num_tmp; ---Testcase 981: -INSERT INTO num_tmp VALUES (3.1954752e47, 9.4792021e-73); ---Testcase 982: -select log(n1, n2) from num_tmp; - log -------------------------------------------------------------------------------------- - -1.51613372350688302142917386143459361608600157692779164475351842333265418126982165 -(1 row) - --- --- Tests for scale() --- ---Testcase 983: -DELETE FROM num_tmp; ---Testcase 984: -INSERT INTO num_tmp VALUES (numeric 'NaN'); ---Testcase 985: -select scale(n1) from num_tmp; - scale -------- - -(1 row) - ---Testcase 986: -DELETE FROM num_tmp; ---Testcase 987: -INSERT INTO num_tmp VALUES (NULL::numeric); ---Testcase 988: -select scale(n1) from num_tmp; - scale -------- - -(1 row) - ---Testcase 989: -DELETE FROM num_tmp; ---Testcase 990: -INSERT INTO num_tmp VALUES (1.12); ---Testcase 991: -select scale(n1) from num_tmp; - scale -------- - 2 -(1 row) - ---Testcase 992: -DELETE FROM num_tmp; ---Testcase 993: -INSERT INTO num_tmp VALUES (0); ---Testcase 994: -select scale(n1) from num_tmp; - scale -------- - 0 -(1 row) - ---Testcase 995: -DELETE FROM num_tmp; ---Testcase 996: -INSERT INTO num_tmp VALUES (0.00); ---Testcase 997: -select scale(n1) from num_tmp; - scale -------- - 0 -(1 row) - ---Testcase 998: -DELETE FROM num_tmp; ---Testcase 999: -INSERT INTO num_tmp VALUES (1.12345); ---Testcase 1000: -select scale(n1) from num_tmp; - scale -------- - 5 -(1 row) - ---Testcase 1001: -DELETE FROM num_tmp; ---Testcase 1002: -INSERT INTO num_tmp VALUES (110123.12475871856128); ---Testcase 1003: -select scale(n1) from num_tmp; - scale -------- - 9 -(1 row) - ---Testcase 1004: -DELETE FROM num_tmp; ---Testcase 1005: -INSERT INTO num_tmp VALUES (-1123.12471856128); ---Testcase 1006: -select scale(n1) from num_tmp; - scale -------- - 11 -(1 row) - ---Testcase 1007: -DELETE FROM num_tmp; ---Testcase 1008: -INSERT INTO num_tmp VALUES (-13.000000000000000); ---Testcase 1009: -select scale(n1) from num_tmp; - scale -------- - 0 -(1 row) - --- --- Tests for min_scale() --- ---Testcase 1010: -DELETE FROM num_tmp; ---Testcase 1011: -INSERT INTO num_tmp VALUES (numeric 'NaN'); ---Testcase 1012: -select min_scale(n1) is NULL from num_tmp; -- should be true -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) is NULL from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1013: -DELETE FROM num_tmp; ---Testcase 1014: -INSERT INTO num_tmp VALUES (0); ---Testcase 1015: -select min_scale(n1) from num_tmp; -- no digits -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1016: -DELETE FROM num_tmp; ---Testcase 1017: -INSERT INTO num_tmp VALUES (0.00); ---Testcase 1018: -select min_scale(n1) from num_tmp; -- no digits again -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1019: -DELETE FROM num_tmp; ---Testcase 1020: -INSERT INTO num_tmp VALUES (1.0); ---Testcase 1021: -select min_scale(n1) from num_tmp; -- no scale -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1022: -DELETE FROM num_tmp; ---Testcase 1023: -INSERT INTO num_tmp VALUES (1.1); ---Testcase 1024: -select min_scale(n1) from num_tmp; -- scale 1 -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1025: -DELETE FROM num_tmp; ---Testcase 1026: -INSERT INTO num_tmp VALUES (1.12); ---Testcase 1027: -select min_scale(n1) from num_tmp; -- scale 2 -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1028: -DELETE FROM num_tmp; ---Testcase 1029: -INSERT INTO num_tmp VALUES (1.123); ---Testcase 1030: -select min_scale(n1) from num_tmp; -- scale 3 -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1031: -DELETE FROM num_tmp; ---Testcase 1032: -INSERT INTO num_tmp VALUES (1.1234); ---Testcase 1033: -select min_scale(n1) from num_tmp; -- scale 4, filled digit -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1034: -DELETE FROM num_tmp; ---Testcase 1035: -INSERT INTO num_tmp VALUES (1.12345); ---Testcase 1036: -select min_scale(n1) from num_tmp; -- scale 5, 2 NDIGITS -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1037: -DELETE FROM num_tmp; ---Testcase 1038: -INSERT INTO num_tmp VALUES (1.1000); ---Testcase 1039: -select min_scale(n1) from num_tmp; -- 1 pos in NDIGITS -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1040: -DELETE FROM num_tmp; ---Testcase 1041: -INSERT INTO num_tmp VALUES (1e100); ---Testcase 1042: -select min_scale(n1) from num_tmp; -- very big number -ERROR: function min_scale(numeric) does not exist -LINE 1: select min_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. --- --- Tests for trim_scale() --- ---Testcase 1043: -DELETE FROM num_tmp; ---Testcase 1044: -INSERT INTO num_tmp VALUES (numeric 'NaN'); ---Testcase 1045: -select trim_scale(n1) from num_tmp; -ERROR: function trim_scale(numeric) does not exist -LINE 1: select trim_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1046: -DELETE FROM num_tmp; ---Testcase 1047: -INSERT INTO num_tmp VALUES (1.120); ---Testcase 1048: -select trim_scale(n1) from num_tmp; -ERROR: function trim_scale(numeric) does not exist -LINE 1: select trim_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1049: -DELETE FROM num_tmp; ---Testcase 1050: -INSERT INTO num_tmp VALUES (0); ---Testcase 1051: -select trim_scale(n1) from num_tmp; -ERROR: function trim_scale(numeric) does not exist -LINE 1: select trim_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1052: -DELETE FROM num_tmp; ---Testcase 1053: -INSERT INTO num_tmp VALUES (0.00); ---Testcase 1054: -select trim_scale(n1) from num_tmp; -ERROR: function trim_scale(numeric) does not exist -LINE 1: select trim_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1055: -DELETE FROM num_tmp; ---Testcase 1056: -INSERT INTO num_tmp VALUES (1.1234500); ---Testcase 1057: -select trim_scale(n1) from num_tmp; -ERROR: function trim_scale(numeric) does not exist -LINE 1: select trim_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1058: -DELETE FROM num_tmp; ---Testcase 1059: -INSERT INTO num_tmp VALUES (110123.12475871856128000); ---Testcase 1060: -select trim_scale(n1) from num_tmp; -ERROR: function trim_scale(numeric) does not exist -LINE 1: select trim_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1061: -DELETE FROM num_tmp; ---Testcase 1062: -INSERT INTO num_tmp VALUES (-123.124718561280000000); ---Testcase 1063: -select trim_scale(n1) from num_tmp; -ERROR: function trim_scale(numeric) does not exist -LINE 1: select trim_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1064: -DELETE FROM num_tmp; ---Testcase 1065: -INSERT INTO num_tmp VALUES (-13.00000000000000000000); ---Testcase 1066: -select trim_scale(n1) from num_tmp; -ERROR: function trim_scale(numeric) does not exist -LINE 1: select trim_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1067: -DELETE FROM num_tmp; ---Testcase 1068: -INSERT INTO num_tmp VALUES (1e100); ---Testcase 1069: -select trim_scale(n1) from num_tmp; -ERROR: function trim_scale(numeric) does not exist -LINE 1: select trim_scale(n1) from num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. --- --- Tests for SUM() --- --- cases that need carry propagation ---Testcase 1070: -DELETE FROM num_tmp; ---Testcase 1071: -INSERT INTO num_tmp SELECT * FROM generate_series(1, 100000); ---Testcase 1072: -SELECT SUM(9999::numeric) FROM num_tmp; - sum ------------ - 999900000 -(1 row) - ---Testcase 1073: -SELECT SUM((-9999)::numeric) FROM num_tmp; - sum ------------- - -999900000 -(1 row) - --- --- Tests for GCD() --- ---Testcase 1074: -DELETE FROM num_tmp; ---Testcase 1075: -INSERT INTO num_tmp VALUES - (0::numeric, 0::numeric), - (0::numeric, numeric 'NaN'), - (0::numeric, 46375::numeric), - (433125::numeric, 46375::numeric), - (43312.5::numeric, 4637.5::numeric), - (4331.250::numeric, 463.75000::numeric); ---Testcase 1076: -SELECT n1 as a, n2 as b, gcd(n1, n2), gcd(n1, -n2), gcd(-n2, n1), gcd(-n2, -n1) FROM num_tmp; -ERROR: function gcd(numeric, numeric) does not exist -LINE 1: SELECT n1 as a, n2 as b, gcd(n1, n2), gcd(n1, -n2), gcd(-n2,... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. --- --- Tests for LCM() --- ---Testcase 1077: -DELETE FROM num_tmp; ---Testcase 1078: -INSERT INTO num_tmp VALUES - (0::numeric, 0::numeric), - (0::numeric, numeric 'NaN'), - (0::numeric, 13272::numeric), - (13272::numeric, 13272::numeric), - (423282::numeric, 13272::numeric), - (42328.2::numeric, 1327.2::numeric), - (4232.820::numeric, 132.72000::numeric); ---Testcase 1079: -SELECT n1 as a, n2 as b, lcm(n1, n2), lcm(n1, -n2), lcm(-n2, n1), lcm(-n2, -n1) FROM num_tmp; -ERROR: function lcm(numeric, numeric) does not exist -LINE 1: SELECT n1 as a, n2 as b, lcm(n1, n2), lcm(n1, -n2), lcm(-n2,... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 1080: -DELETE FROM num_tmp; ---Testcase 1081: -INSERT INTO num_tmp VALUES (10::numeric, 131068); ---Testcase 1082: -SELECT lcm(9999 * (n1)^n2 + (n1^n2 - 1), 2) FROM num_tmp; -- overflow -ERROR: function lcm(numeric, integer) does not exist -LINE 1: SELECT lcm(9999 * (n1)^n2 + (n1^n2 - 1), 2) FROM num_tmp; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. -DO $d$ -declare - l_rec record; -begin - for l_rec in (select foreign_table_schema, foreign_table_name - from information_schema.foreign_tables) loop - execute format('drop foreign table %I.%I cascade;', l_rec.foreign_table_schema, l_rec.foreign_table_name); - end loop; -end; -$d$; ---Testcase 1083: -DROP SERVER sqlite_svr; ---Testcase 1084: -DROP EXTENSION sqlite_fdw CASCADE; diff --git a/expected/10.18/selectfunc.out b/expected/10.18/selectfunc.out deleted file mode 100644 index b11b6b80..00000000 --- a/expected/10.18/selectfunc.out +++ /dev/null @@ -1,454 +0,0 @@ -SET datestyle=ISO; -SET timezone='Japan'; ---Testcase 1: -CREATE EXTENSION sqlite_fdw; ---Testcase 2: -CREATE SERVER server1 FOREIGN DATA WRAPPER sqlite_fdw -OPTIONS (database '/tmp/sqlitefdw_test_selectfunc.db'); ---CREATE USER MAPPING FOR CURRENT_USER SERVER server1 OPTIONS(user 'user', password 'pass'); ---IMPORT FOREIGN SCHEMA public FROM SERVER server1 INTO public OPTIONS(import_time_text 'false'); ---Testcase 3: -CREATE FOREIGN TABLE s3(id text OPTIONS (key 'true'), time timestamp, tag1 text, value1 float, value2 int, value3 float, value4 int, str1 text, str2 text) SERVER server1; --- s3 (value1 as float8, value2 as bigint) ---Testcase 4: -\d s3; - Foreign table "public.s3" - Column | Type | Collation | Nullable | Default | FDW options ---------+-----------------------------+-----------+----------+---------+-------------- - id | text | | | | (key 'true') - time | timestamp without time zone | | | | - tag1 | text | | | | - value1 | double precision | | | | - value2 | integer | | | | - value3 | double precision | | | | - value4 | integer | | | | - str1 | text | | | | - str2 | text | | | | -Server: server1 - ---Testcase 5: -SELECT * FROM s3; - id | time | tag1 | value1 | value2 | value3 | value4 | str1 | str2 -----+---------------------+------+--------+--------+--------+--------+-----------+----------- - 0 | 1970-01-01 00:00:00 | a | 0.1 | 100 | -0.1 | -100 | ---XYZ--- | XYZ - 1 | 1970-01-01 00:00:01 | a | 0.2 | 100 | -0.2 | -100 | ---XYZ--- | XYZ - 2 | 1970-01-01 00:00:02 | a | 0.3 | 100 | -0.3 | -100 | ---XYZ--- | XYZ - 3 | 1970-01-01 00:00:03 | b | 1.1 | 200 | -1.1 | -200 | ---XYZ--- | XYZ - 4 | 1970-01-01 00:00:04 | b | 2.2 | 200 | -2.2 | -200 | ---XYZ--- | XYZ - 5 | 1970-01-01 00:00:05 | b | 3.3 | 200 | -3.3 | -200 | ---XYZ--- | XYZ -(6 rows) - --- select float8() (not pushdown, remove float8, explain) --- EXPLAIN VERBOSE --- SELECT float8(value1), float8(value2), float8(value3), float8(value4) FROM s3; --- sqlite fdw does not support --- select float8() (not pushdown, remove float8, result) --- SELECT float8(value1), float8(value2), float8(value3), float8(value4) FROM s3; --- sqlite fdw does not support --- select sqrt (builtin function, explain) --- EXPLAIN VERBOSE --- SELECT sqrt(value1), sqrt(value2) FROM s3; --- sqlite fdw does not have sqrt() --- select sqrt (buitin function, result) --- SELECT sqrt(value1), sqrt(value2) FROM s3; --- sqlite fdw does not have sqrt() --- select sqrt (builtin function,, not pushdown constraints, explain) --- EXPLAIN VERBOSE --- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE to_hex(value2) != '64'; --- sqlite fdw does not have sqrt() --- select sqrt (builtin function, not pushdown constraints, result) --- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE to_hex(value2) != '64'; --- sqlite fdw does not have sqrt() --- select sqrt (builtin function, pushdown constraints, explain) --- EXPLAIN VERBOSE --- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE value2 != 200; --- sqlite fdw does not have sqrt() --- select sqrt (builtin function, pushdown constraints, result) --- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE value2 != 200; --- sqlite fdw does not have sqrt() --- select abs (builtin function, explain) ---Testcase 6: -EXPLAIN VERBOSE -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3; - QUERY PLAN --------------------------------------------------------------------------------------------------- - Foreign Scan (cost=10.00..1723.06 rows=1706 width=24) - Output: (abs(value1)), (abs(value2)), (abs(value3)), (abs(value4)) - SQLite query: SELECT abs(`value1`), abs(`value2`), abs(`value3`), abs(`value4`) FROM main."s3" -(3 rows) - --- select abs (buitin function, result) ---Testcase 7: -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3; - abs | abs | abs | abs ------+-----+-----+----- - 0.1 | 100 | 0.1 | 100 - 0.2 | 100 | 0.2 | 100 - 0.3 | 100 | 0.3 | 100 - 1.1 | 200 | 1.1 | 200 - 2.2 | 200 | 2.2 | 200 - 3.3 | 200 | 3.3 | 200 -(6 rows) - --- select abs (builtin function, not pushdown constraints, explain) ---Testcase 8: -EXPLAIN VERBOSE -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE to_hex(value2) != '64'; - QUERY PLAN ------------------------------------------------------------------------------------------------------------- - Foreign Scan (cost=10.00..1713.97 rows=1697 width=24) - Output: (abs(value1)), (abs(value2)), (abs(value3)), (abs(value4)) - Filter: (to_hex(s3.value2) <> '64'::text) - SQLite query: SELECT abs(`value1`), abs(`value2`), abs(`value3`), abs(`value4`), `value2` FROM main."s3" -(4 rows) - --- select abs (builtin function, not pushdown constraints, result) ---Testcase 9: -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE to_hex(value2) != '64'; - abs | abs | abs | abs ------+-----+-----+----- - 1.1 | 200 | 1.1 | 200 - 2.2 | 200 | 2.2 | 200 - 3.3 | 200 | 3.3 | 200 -(3 rows) - --- select abs (builtin function, pushdown constraints, explain) ---Testcase 10: -EXPLAIN VERBOSE -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE value2 != 200; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------- - Foreign Scan (cost=10.00..1713.97 rows=1697 width=24) - Output: (abs(value1)), (abs(value2)), (abs(value3)), (abs(value4)) - SQLite query: SELECT abs(`value1`), abs(`value2`), abs(`value3`), abs(`value4`) FROM main."s3" WHERE ((`value2` <> 200)) -(3 rows) - --- select abs (builtin function, pushdown constraints, result) ---Testcase 11: -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE value2 != 200; - abs | abs | abs | abs ------+-----+-----+----- - 0.1 | 100 | 0.1 | 100 - 0.2 | 100 | 0.2 | 100 - 0.3 | 100 | 0.3 | 100 -(3 rows) - --- select log (builtin function, need to swap arguments, numeric cast, explain) --- log_(v) : postgresql (base, v), sqlite (v, base) --- EXPLAIN VERBOSE --- SELECT log(value1::numeric, value2::numeric) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() --- select log (builtin function, need to swap arguments, numeric cast, result) --- SELECT log(value1::numeric, value2::numeric) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() --- select log (stub function, need to swap arguments, float8, explain) --- EXPLAIN VERBOSE --- SELECT log(value1, 0.1) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() --- select log (stub function, need to swap arguments, float8, result) --- SELECT log(value1, 0.1) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() --- select log (stub function, need to swap arguments, bigint, explain) --- EXPLAIN VERBOSE --- SELECT log(value2, 3) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() --- select log (stub function, need to swap arguments, bigint, result) --- SELECT log(value2, 3) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() --- select log (stub function, need to swap arguments, mix type, explain) --- EXPLAIN VERBOSE --- SELECT log(value1, value2) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() --- select log (stub function, need to swap arguments, mix type, result) --- SELECT log(value1, value2) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() --- select log2 (stub function, explain) --- EXPLAIN VERBOSE --- SELECT log2(value1),log2(value2) FROM s3; --- sqlite fdw does not have log2() --- select log2 (stub function, result) --- SELECT log2(value1),log2(value2) FROM s3; --- sqlite fdw does not have log2() --- select spread (stub agg function, explain) --- EXPLAIN VERBOSE --- SELECT spread(value1),spread(value2),spread(value3),spread(value4) FROM s3; --- sqlite fdw does not have spread() --- select spread (stub agg function, result) --- SELECT spread(value1),spread(value2),spread(value3),spread(value4) FROM s3; --- sqlite fdw does not have spread() --- select spread (stub agg function, raise exception if not expected type) --- SELECT spread(value1::numeric),spread(value2::numeric),spread(value3::numeric),spread(value4::numeric) FROM s3; --- sqlite fdw does not have spread() --- select abs as nest function with agg (pushdown, explain) ---Testcase 12: -EXPLAIN VERBOSE -SELECT sum(value3),abs(sum(value3)) FROM s3; - QUERY PLAN -------------------------------------------------------------------------- - Foreign Scan (cost=1.00..1.00 rows=1 width=16) - Output: (sum(value3)), (abs(sum(value3))) - SQLite query: SELECT sum(`value3`), abs(sum(`value3`)) FROM main."s3" -(3 rows) - --- select abs as nest function with agg (pushdown, result) ---Testcase 13: -SELECT sum(value3),abs(sum(value3)) FROM s3; - sum | abs -------+----- - -7.2 | 7.2 -(1 row) - --- select abs as nest with log2 (pushdown, explain) --- EXPLAIN VERBOSE --- SELECT abs(log2(value1)),abs(log2(1/value1)) FROM s3; --- sqlite fdw does not have log2() --- select abs as nest with log2 (pushdown, result) --- SELECT abs(log2(value1)),abs(log2(1/value1)) FROM s3; --- sqlite fdw does not have log2() --- select abs with non pushdown func and explicit constant (explain) ---Testcase 14: -EXPLAIN VERBOSE -SELECT abs(value3), pi(), 4.1 FROM s3; - QUERY PLAN --------------------------------------------------------------------- - Foreign Scan (cost=10.00..2566.40 rows=2560 width=48) - Output: (abs(value3)), '3.14159265358979'::double precision, 4.1 - SQLite query: SELECT abs(`value3`) FROM main."s3" -(3 rows) - --- select abs with non pushdown func and explicit constant (result) ---Testcase 15: -SELECT abs(value3), pi(), 4.1 FROM s3; - abs | pi | ?column? ------+------------------+---------- - 0.1 | 3.14159265358979 | 4.1 - 0.2 | 3.14159265358979 | 4.1 - 0.3 | 3.14159265358979 | 4.1 - 1.1 | 3.14159265358979 | 4.1 - 2.2 | 3.14159265358979 | 4.1 - 3.3 | 3.14159265358979 | 4.1 -(6 rows) - --- select sqrt as nest function with agg and explicit constant (pushdown, explain) --- EXPLAIN VERBOSE --- SELECT sqrt(count(value1)), pi(), 4.1 FROM s3; --- sqlite fdw does not have sqrt() --- select sqrt as nest function with agg and explicit constant (pushdown, result) --- SELECT sqrt(count(value1)), pi(), 4.1 FROM s3; --- sqlite fdw does not have sqrt() --- select sqrt as nest function with agg and explicit constant and tag (error, explain) --- EXPLAIN VERBOSE --- SELECT sqrt(count(value1)), pi(), 4.1, tag1 FROM s3; --- sqlite fdw does not have sqrt() --- select spread (stub agg function and group by influx_time() and tag) (explain) --- EXPLAIN VERBOSE --- SELECT spread("value1"),influx_time(time, interval '1s'),tag1 FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY influx_time(time, interval '1s'), tag1; --- sqlite fdw does not have spread() and influx_time() --- select spread (stub agg function and group by influx_time() and tag) (result) --- SELECT spread("value1"),influx_time(time, interval '1s'),tag1 FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY influx_time(time, interval '1s'), tag1; --- sqlite fdw does not have spread() and influx_time() --- select spread (stub agg function and group by tag only) (result) --- SELECT tag1,spread("value1") FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY tag1; --- sqlite fdw does not have spread() --- select spread (stub agg function and other aggs) (result) --- SELECT sum("value1"),spread("value1"),count("value1") FROM s3; --- sqlite fdw does not have spread() --- select abs with order by (explain) ---Testcase 16: -EXPLAIN VERBOSE -SELECT value1, abs(1-value1) FROM s3 order by abs(1-value1); - QUERY PLAN ------------------------------------------------------------------------------------------------------------------ - Foreign Scan (cost=10.00..10.05 rows=10 width=16) - Output: value1, (abs(('1'::double precision - value1))) - SQLite query: SELECT `value1`, abs((1 - `value1`)) FROM main."s3" ORDER BY abs((1 - `value1`)) ASC NULLS LAST -(3 rows) - --- select abs with order by (result) ---Testcase 17: -SELECT value1, abs(1-value1) FROM s3 order by abs(1-value1); - value1 | abs ---------+----- - 1.1 | 0.1 - 0.3 | 0.7 - 0.2 | 0.8 - 0.1 | 0.9 - 2.2 | 1.2 - 3.3 | 2.3 -(6 rows) - --- select abs with order by index (result) ---Testcase 18: -SELECT value1, abs(1-value1) FROM s3 order by 2,1; - value1 | abs ---------+----- - 1.1 | 0.1 - 0.3 | 0.7 - 0.2 | 0.8 - 0.1 | 0.9 - 2.2 | 1.2 - 3.3 | 2.3 -(6 rows) - --- select abs with order by index (result) ---Testcase 19: -SELECT value1, abs(1-value1) FROM s3 order by 1,2; - value1 | abs ---------+----- - 0.1 | 0.9 - 0.2 | 0.8 - 0.3 | 0.7 - 1.1 | 0.1 - 2.2 | 1.2 - 3.3 | 2.3 -(6 rows) - --- select abs and as ---Testcase 20: -SELECT abs(value3) as abs1 FROM s3; - abs1 ------- - 0.1 - 0.2 - 0.3 - 1.1 - 2.2 - 3.3 -(6 rows) - --- select spread over join query (explain) --- EXPLAIN VERBOSE --- SELECT spread(t1.value1), spread(t2.value1) FROM s3 t1 INNER JOIN s3 t2 ON (t1.value1 = t2.value1) where t1.value1 = 0.1; --- sqlite fdw does not have spread() --- select spread over join query (result, stub call error) --- SELECT spread(t1.value1), spread(t2.value1) FROM s3 t1 INNER JOIN s3 t2 ON (t1.value1 = t2.value1) where t1.value1 = 0.1; --- sqlite fdw does not have spread() --- select spread with having (explain) --- EXPLAIN VERBOSE --- SELECT spread(value1) FROM s3 HAVING spread(value1) > 100; --- sqlite fdw does not have spread() --- select spread with having (explain, cannot pushdown, stub call error) --- SELECT spread(value1) FROM s3 HAVING spread(value1) > 100; --- sqlite fdw does not have spread() --- select abs with arithmetic and tag in the middle (explain) ---Testcase 21: -EXPLAIN VERBOSE -SELECT abs(value1) + 1, value2, tag1, sqrt(value2) FROM s3; - QUERY PLAN -------------------------------------------------------------------------------------------------- - Foreign Scan on public.s3 (cost=10.00..1216.04 rows=1204 width=52) - Output: (abs(value1) + '1'::double precision), value2, tag1, sqrt((value2)::double precision) - SQLite query: SELECT `tag1`, `value1`, `value2` FROM main."s3" -(3 rows) - --- select abs with arithmetic and tag in the middle (result) ---Testcase 22: -SELECT abs(value1) + 1, value2, tag1, sqrt(value2) FROM s3; - ?column? | value2 | tag1 | sqrt -----------+--------+------+----------------- - 1.1 | 100 | a | 10 - 1.2 | 100 | a | 10 - 1.3 | 100 | a | 10 - 2.1 | 200 | b | 14.142135623731 - 3.2 | 200 | b | 14.142135623731 - 4.3 | 200 | b | 14.142135623731 -(6 rows) - --- select with order by limit (explain) ---Testcase 23: -EXPLAIN VERBOSE -SELECT abs(value1), abs(value3), sqrt(value2) FROM s3 ORDER BY abs(value3) LIMIT 1; - QUERY PLAN ------------------------------------------------------------------------------------------------------------------- - Foreign Scan on public.s3 (cost=1.00..1.00 rows=1 width=24) - Output: abs(value1), abs(value3), sqrt((value2)::double precision) - SQLite query: SELECT `value1`, `value2`, `value3` FROM main."s3" ORDER BY abs(`value3`) ASC NULLS LAST LIMIT 1 -(3 rows) - --- select with order by limit (explain) ---Testcase 24: -SELECT abs(value1), abs(value3), sqrt(value2) FROM s3 ORDER BY abs(value3) LIMIT 1; - abs | abs | sqrt ------+-----+------ - 0.1 | 0.1 | 10 -(1 row) - --- select mixing with non pushdown func (all not pushdown, explain) ---Testcase 25: -EXPLAIN VERBOSE -SELECT abs(value1), sqrt(value2), upper(tag1) FROM s3; - QUERY PLAN ----------------------------------------------------------------------- - Foreign Scan on public.s3 (cost=10.00..1216.04 rows=1204 width=48) - Output: abs(value1), sqrt((value2)::double precision), upper(tag1) - SQLite query: SELECT `tag1`, `value1`, `value2` FROM main."s3" -(3 rows) - --- select mixing with non pushdown func (result) ---Testcase 26: -SELECT abs(value1), sqrt(value2), upper(tag1) FROM s3; - abs | sqrt | upper ------+-----------------+------- - 0.1 | 10 | A - 0.2 | 10 | A - 0.3 | 10 | A - 1.1 | 14.142135623731 | B - 2.2 | 14.142135623731 | B - 3.3 | 14.142135623731 | B -(6 rows) - --- sqlite data prep --- sqlite pushdown supported functions (explain) ---Testcase 27: -EXPLAIN VERBOSE -SELECT abs(value3), length(tag1), lower(str1), ltrim(str2), ltrim(str1, '-'), replace(str1, 'XYZ', 'ABC'), round(value3), rtrim(str1, '-'), rtrim(str2), substr(str1, 4), substr(str1, 4, 3) FROM s3; - QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - Foreign Scan on public.s3 (cost=10.00..657.60 rows=640 width=276) - Output: abs(value3), length(tag1), lower(str1), ltrim(str2), ltrim(str1, '-'::text), replace(str1, 'XYZ'::text, 'ABC'::text), round(value3), rtrim(str1, '-'::text), rtrim(str2), substr(str1, 4), substr(str1, 4, 3) - SQLite query: SELECT `tag1`, `value3`, `str1`, `str2` FROM main."s3" -(3 rows) - --- sqlite pushdown supported functions (result) ---Testcase 28: -SELECT abs(value3), length(tag1), lower(str1), ltrim(str2), ltrim(str1, '-'), replace(str1, 'XYZ', 'ABC'), round(value3), rtrim(str1, '-'), rtrim(str2), substr(str1, 4), substr(str1, 4, 3) FROM s3; - abs | length | lower | ltrim | ltrim | replace | round | rtrim | rtrim | substr | substr ------+--------+-----------+--------+--------+-----------+-------+--------+--------+--------+-------- - 0.1 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -0 | ---XYZ | XYZ | XYZ--- | XYZ - 0.2 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -0 | ---XYZ | XYZ | XYZ--- | XYZ - 0.3 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -0 | ---XYZ | XYZ | XYZ--- | XYZ - 1.1 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -1 | ---XYZ | XYZ | XYZ--- | XYZ - 2.2 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -2 | ---XYZ | XYZ | XYZ--- | XYZ - 3.3 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -3 | ---XYZ | XYZ | XYZ--- | XYZ -(6 rows) - --- sqlite pushdown nest functions (explain) ---Testcase 32: -EXPLAIN VERBOSE -SELECT round(abs(value2), 0) FROM s3; - QUERY PLAN ---------------------------------------------------------------- - Foreign Scan (cost=10.00..2946.94 rows=2925 width=32) - Output: (round((abs(value2))::numeric, 0)) - SQLite query: SELECT round(abs(`value2`), 0) FROM main."s3" -(3 rows) - --- sqlite pushdown nest functions (result) ---Testcase 33: -SELECT round(abs(value2), 0) FROM s3; - round -------- - 100 - 100 - 100 - 200 - 200 - 200 -(6 rows) - ---Testcase 29: -DROP FOREIGN TABLE s3; ---Testcase 30: -DROP SERVER server1; ---Testcase 31: -DROP EXTENSION sqlite_fdw; diff --git a/expected/10.18/sqlite_fdw.out b/expected/10.18/sqlite_fdw.out deleted file mode 100644 index ccef52b6..00000000 --- a/expected/10.18/sqlite_fdw.out +++ /dev/null @@ -1,1526 +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; - department_id | department_name ----------------+----------------- -(0 rows) - ---Testcase 2: -SELECT * FROM employee LIMIT 10; - emp_id | emp_name | emp_dept_id ---------+----------+------------- -(0 rows) - ---Testcase 3: -SELECT * FROM empdata LIMIT 10; - emp_id | emp_dat ---------+--------- -(0 rows) - ---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; - count -------- - 100 -(1 row) - ---Testcase 17: -SELECT count(*) FROM employee; - count -------- - 100 -(1 row) - ---Testcase 18: -SELECT count(*) FROM empdata; - count -------- - 1 -(1 row) - ---Testcase 19: -EXPLAIN (COSTS FALSE) SELECT * FROM department d, employee e WHERE d.department_id = e.emp_dept_id LIMIT 10; - QUERY PLAN --------------- - Foreign Scan -(1 row) - ---Testcase 20: -EXPLAIN (COSTS FALSE) SELECT * FROM department d, employee e WHERE d.department_id IN (SELECT department_id FROM department) LIMIT 10; - QUERY PLAN -------------------------------------------------------------------------- - Limit - -> Nested Loop - -> Nested Loop Semi Join - Join Filter: (d.department_id = department.department_id) - -> Foreign Scan on department d - -> Materialize - -> Foreign Scan on department - -> Materialize - -> Foreign Scan on employee e -(9 rows) - ---Testcase 21: -SELECT * FROM department d, employee e WHERE d.department_id = e.emp_dept_id LIMIT 10; - department_id | department_name | emp_id | emp_name | emp_dept_id ----------------+-----------------+--------+----------+------------- - 1 | dept - 1 | 1 | emp - 1 | 1 - 2 | dept - 2 | 2 | emp - 2 | 2 - 3 | dept - 3 | 3 | emp - 3 | 3 - 4 | dept - 4 | 4 | emp - 4 | 4 - 5 | dept - 5 | 5 | emp - 5 | 5 - 6 | dept - 6 | 6 | emp - 6 | 6 - 7 | dept - 7 | 7 | emp - 7 | 7 - 8 | dept - 8 | 8 | emp - 8 | 8 - 9 | dept - 9 | 9 | emp - 9 | 9 - 10 | dept - 10 | 10 | emp - 10 | 10 -(10 rows) - ---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; - department_id | department_name | emp_id | emp_name | emp_dept_id ----------------+-----------------+--------+----------+------------- - 1 | dept - 1 | 1 | emp - 1 | 1 - 1 | dept - 1 | 2 | emp - 2 | 2 - 1 | dept - 1 | 3 | emp - 3 | 3 - 1 | dept - 1 | 4 | emp - 4 | 4 - 1 | dept - 1 | 5 | emp - 5 | 5 - 1 | dept - 1 | 6 | emp - 6 | 6 - 1 | dept - 1 | 7 | emp - 7 | 7 - 1 | dept - 1 | 8 | emp - 8 | 8 - 1 | dept - 1 | 9 | emp - 9 | 9 - 1 | dept - 1 | 10 | emp - 10 | 10 -(10 rows) - ---Testcase 23: -SELECT * FROM empdata; - emp_id | emp_dat ---------+------------ - 1 | \x01234567 -(1 row) - ---Testcase 24: -DELETE FROM employee WHERE emp_id = 10; ---Testcase 25: -SELECT COUNT(*) FROM department LIMIT 10; - count -------- - 100 -(1 row) - ---Testcase 26: -SELECT COUNT(*) FROM employee WHERE emp_id = 10; - count -------- - 0 -(1 row) - ---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'; - emp_id | emp_name ---------+------------- - 20 | UPDATEd emp -(1 row) - ---Testcase 29: -UPDATE empdata SET emp_dat = decode ('0123', 'hex'); ---Testcase 30: -SELECT * FROM empdata; - emp_id | emp_dat ---------+--------- - 1 | \x0123 -(1 row) - ---Testcase 31: -SELECT * FROM employee LIMIT 10; - emp_id | emp_name | emp_dept_id ---------+----------+------------- - 1 | emp - 1 | 1 - 2 | emp - 2 | 2 - 3 | emp - 3 | 3 - 4 | emp - 4 | 4 - 5 | emp - 5 | 5 - 6 | emp - 6 | 6 - 7 | emp - 7 | 7 - 8 | emp - 8 | 8 - 9 | emp - 9 | 9 - 11 | emp - 11 | 11 -(10 rows) - ---Testcase 32: -SELECT * FROM employee WHERE emp_id IN (1); - emp_id | emp_name | emp_dept_id ---------+----------+------------- - 1 | emp - 1 | 1 -(1 row) - ---Testcase 33: -SELECT * FROM employee WHERE emp_id IN (1,3,4,5); - emp_id | emp_name | emp_dept_id ---------+----------+------------- - 1 | emp - 1 | 1 - 3 | emp - 3 | 3 - 4 | emp - 4 | 4 - 5 | emp - 5 | 5 -(4 rows) - ---Testcase 34: -SELECT * FROM employee WHERE emp_id IN (10000,1000); - emp_id | emp_name | emp_dept_id ---------+----------+------------- -(0 rows) - ---Testcase 35: -SELECT * FROM employee WHERE emp_id NOT IN (1) LIMIT 5; - emp_id | emp_name | emp_dept_id ---------+----------+------------- - 2 | emp - 2 | 2 - 3 | emp - 3 | 3 - 4 | emp - 4 | 4 - 5 | emp - 5 | 5 - 6 | emp - 6 | 6 -(5 rows) - ---Testcase 36: -SELECT * FROM employee WHERE emp_id NOT IN (1,3,4,5) LIMIT 5; - emp_id | emp_name | emp_dept_id ---------+----------+------------- - 2 | emp - 2 | 2 - 6 | emp - 6 | 6 - 7 | emp - 7 | 7 - 8 | emp - 8 | 8 - 9 | emp - 9 | 9 -(5 rows) - ---Testcase 37: -SELECT * FROM employee WHERE emp_id NOT IN (10000,1000) LIMIT 5; - emp_id | emp_name | emp_dept_id ---------+----------+------------- - 1 | emp - 1 | 1 - 2 | emp - 2 | 2 - 3 | emp - 3 | 3 - 4 | emp - 4 | 4 - 5 | emp - 5 | 5 -(5 rows) - ---Testcase 38: -SELECT * FROM employee WHERE emp_id NOT IN (SELECT emp_id FROM employee WHERE emp_id IN (1,10)); - emp_id | emp_name | emp_dept_id ---------+-------------+------------- - 2 | emp - 2 | 2 - 3 | emp - 3 | 3 - 4 | emp - 4 | 4 - 5 | emp - 5 | 5 - 6 | emp - 6 | 6 - 7 | emp - 7 | 7 - 8 | emp - 8 | 8 - 9 | emp - 9 | 9 - 11 | emp - 11 | 11 - 12 | emp - 12 | 12 - 13 | emp - 13 | 13 - 14 | emp - 14 | 14 - 15 | emp - 15 | 15 - 16 | emp - 16 | 16 - 17 | emp - 17 | 17 - 18 | emp - 18 | 18 - 19 | emp - 19 | 19 - 20 | UPDATEd emp | 20 - 21 | emp - 21 | 21 - 22 | emp - 22 | 22 - 23 | emp - 23 | 23 - 24 | emp - 24 | 24 - 25 | emp - 25 | 25 - 26 | emp - 26 | 26 - 27 | emp - 27 | 27 - 28 | emp - 28 | 28 - 29 | emp - 29 | 29 - 30 | emp - 30 | 30 - 31 | emp - 31 | 31 - 32 | emp - 32 | 32 - 33 | emp - 33 | 33 - 34 | emp - 34 | 34 - 35 | emp - 35 | 35 - 36 | emp - 36 | 36 - 37 | emp - 37 | 37 - 38 | emp - 38 | 38 - 39 | emp - 39 | 39 - 40 | emp - 40 | 40 - 41 | emp - 41 | 41 - 42 | emp - 42 | 42 - 43 | emp - 43 | 43 - 44 | emp - 44 | 44 - 45 | emp - 45 | 45 - 46 | emp - 46 | 46 - 47 | emp - 47 | 47 - 48 | emp - 48 | 48 - 49 | emp - 49 | 49 - 50 | emp - 50 | 50 - 51 | emp - 51 | 51 - 52 | emp - 52 | 52 - 53 | emp - 53 | 53 - 54 | emp - 54 | 54 - 55 | emp - 55 | 55 - 56 | emp - 56 | 56 - 57 | emp - 57 | 57 - 58 | emp - 58 | 58 - 59 | emp - 59 | 59 - 60 | emp - 60 | 60 - 61 | emp - 61 | 61 - 62 | emp - 62 | 62 - 63 | emp - 63 | 63 - 64 | emp - 64 | 64 - 65 | emp - 65 | 65 - 66 | emp - 66 | 66 - 67 | emp - 67 | 67 - 68 | emp - 68 | 68 - 69 | emp - 69 | 69 - 70 | emp - 70 | 70 - 71 | emp - 71 | 71 - 72 | emp - 72 | 72 - 73 | emp - 73 | 73 - 74 | emp - 74 | 74 - 75 | emp - 75 | 75 - 76 | emp - 76 | 76 - 77 | emp - 77 | 77 - 78 | emp - 78 | 78 - 79 | emp - 79 | 79 - 80 | emp - 80 | 80 - 81 | emp - 81 | 81 - 82 | emp - 82 | 82 - 83 | emp - 83 | 83 - 84 | emp - 84 | 84 - 85 | emp - 85 | 85 - 86 | emp - 86 | 86 - 87 | emp - 87 | 87 - 88 | emp - 88 | 88 - 89 | emp - 89 | 89 - 90 | emp - 90 | 90 - 91 | emp - 91 | 91 - 92 | emp - 92 | 92 - 93 | emp - 93 | 93 - 94 | emp - 94 | 94 - 95 | emp - 95 | 95 - 96 | emp - 96 | 96 - 97 | emp - 97 | 97 - 98 | emp - 98 | 98 - 99 | emp - 99 | 99 - 100 | emp - 100 | 100 -(98 rows) - ---Testcase 39: -SELECT * FROM employee WHERE emp_name NOT IN ('emp - 1', 'emp - 2') LIMIT 5; - emp_id | emp_name | emp_dept_id ---------+----------+------------- - 3 | emp - 3 | 3 - 4 | emp - 4 | 4 - 5 | emp - 5 | 5 - 6 | emp - 6 | 6 - 7 | emp - 7 | 7 -(5 rows) - ---Testcase 40: -SELECT * FROM employee WHERE emp_name NOT IN ('emp - 10') LIMIT 5; - emp_id | emp_name | emp_dept_id ---------+----------+------------- - 1 | emp - 1 | 1 - 2 | emp - 2 | 2 - 3 | emp - 3 | 3 - 4 | emp - 4 | 4 - 5 | emp - 5 | 5 -(5 rows) - ---Testcase 41: -SELECT * FROM numbers WHERE (CASE WHEN a % 2 = 0 THEN 1 WHEN a % 5 = 0 THEN 1 ELSE 0 END) = 1; - a | b ----+------- - 2 | Two - 4 | Four - 5 | Five - 6 | Six - 8 | Eight -(5 rows) - ---Testcase 42: -SELECT * FROM numbers WHERE (CASE b WHEN 'Two' THEN 1 WHEN 'Six' THEN 1 ELSE 0 END) = 1; - a | b ----+----- - 2 | Two - 6 | Six -(2 rows) - ---Testcase 152: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE (round(abs(a)) = 1); - QUERY PLAN ------------------------------------------------------------------------------------ - Foreign Scan on public.numbers (cost=10.00..1.00 rows=1 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((round(abs(`a`)) = 1)) -(3 rows) - ---Testcase 153: -SELECT * FROM numbers WHERE (round(abs(a)) = 1); - a | b ----+----- - 1 | One -(1 row) - ---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(); -NOTICE: Found number One -NOTICE: Found number Two -NOTICE: Found number Three -NOTICE: Found number Four -NOTICE: Found number Five -NOTICE: Found number Six -NOTICE: Found number Seven -NOTICE: Found number Eight -NOTICE: Found number Nine - test_param_where ------------------- - -(1 row) - ---Testcase 44: -SELECT b from numbers WHERE a=1; - b ------ - One -(1 row) - ---Testcase 45: -EXPLAIN(COSTS OFF) SELECT b from numbers WHERE a=1; - QUERY PLAN -------------------------- - Foreign Scan on numbers -(1 row) - ---Testcase 46: -SELECT a FROM numbers WHERE b = (SELECT NULL::text); - a ---- -(0 rows) - ---Testcase 47: -PREPARE stmt1 (int, int) AS - SELECT * FROM numbers WHERE a=$1 or a=$2; ---Testcase 48: -EXECUTE stmt1(1,2); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 49: -EXECUTE stmt1(2,2); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 50: -EXECUTE stmt1(3,2); - a | b ----+------- - 2 | Two - 3 | Three -(2 rows) - ---Testcase 51: -EXECUTE stmt1(4,2); - a | b ----+------ - 2 | Two - 4 | Four -(2 rows) - --- generic plan ---Testcase 52: -EXECUTE stmt1(5,2); - a | b ----+------ - 2 | Two - 5 | Five -(2 rows) - ---Testcase 53: -EXECUTE stmt1(6,2); - a | b ----+----- - 2 | Two - 6 | Six -(2 rows) - ---Testcase 54: -EXECUTE stmt1(7,2); - a | b ----+------- - 2 | Two - 7 | Seven -(2 rows) - ---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; - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - -BEGIN; ---Testcase 62: -INSERT INTO numbers VALUES(3, 'Three'); -ROLLBACK; ---Testcase 63: -SELECT * from numbers; - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - -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; - a | b ----+------ - 1 | One - 2 | Two - 4 | Four - 6 | Six -(4 rows) - --- duplicate key ---Testcase 68: -INSERT INTO numbers VALUES(1, 'One'); -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) ---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; -ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b - sql=UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) ---Testcase 73: -SELECT * from numbers; - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - --- push down ---Testcase 74: -explain (verbose, costs off) SELECT * from numbers WHERE a = any(ARRAY[2,3,4,5]::int[]); - QUERY PLAN ---------------------------------------------------------------------------------- - Foreign Scan on public.numbers - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (2, 3, 4, 5)) -(3 rows) - --- (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); - QUERY PLAN ------------------------------------------------------------------------------- - Foreign Scan on public.numbers - Output: a, b - Filter: (ROW(1, 2) < ROW(numbers.a, 5)) - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (1, 2, 3)) -(4 rows) - ---Testcase 76: -explain (verbose, costs off) SELECT * from numbers WHERE a in (a+2*a,5); - QUERY PLAN ------------------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (((`a` = (`a` + (2 * `a`))) OR (`a` = 5))) -(3 rows) - ---Testcase 77: -explain (verbose, costs off) SELECT * from numbers WHERE a = any(ARRAY[1,2,a]::int[]); - QUERY PLAN --------------------------------------------------------------------------------- - Foreign Scan on public.numbers - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (1, 2, `a`)) -(3 rows) - ---Testcase 78: -SELECT * from numbers WHERE a = any(ARRAY[2,3,4,5]::int[]); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 79: -SELECT * from numbers WHERE a = any(ARRAY[1,2,a]::int[]); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - --- ANY with ARRAY expression ---Testcase 154: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY(ARRAY[1, a + 1]); - QUERY PLAN ------------------------------------------------------------------------------------ - Foreign Scan on public.numbers (cost=10.00..2.00 rows=2 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (1, (`a` + 1))) -(3 rows) - ---Testcase 155: -SELECT * FROM numbers WHERE a = ANY(ARRAY[1, a + 1]); - a | b ----+----- - 1 | One -(1 row) - ---Testcase 156: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, a + 1]); - QUERY PLAN ----------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..150.00 rows=150 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` <> 1) OR (`a` <> (`a` + 1))) -(3 rows) - ---Testcase 157: -SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, a + 1]); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 158: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, a + 1]); - QUERY PLAN ----------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` >= 1) OR (`a` >= (`a` + 1))) -(3 rows) - ---Testcase 159: -SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, a + 1]); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 160: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, a + 1]); - QUERY PLAN ----------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` <= 1) OR (`a` <= (`a` + 1))) -(3 rows) - ---Testcase 161: -SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, a + 1]); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 162: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ANY(ARRAY[1, a + 1]); - QUERY PLAN --------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` > 1) OR (`a` > (`a` + 1))) -(3 rows) - ---Testcase 163: -SELECT * FROM numbers WHERE a > ANY(ARRAY[1, a + 1]); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 164: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ANY(ARRAY[1, a + 1]); - QUERY PLAN --------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` < 1) OR (`a` < (`a` + 1))) -(3 rows) - ---Testcase 165: -SELECT * FROM numbers WHERE a < ANY(ARRAY[1, a + 1]); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - --- ANY with ARRAY const ---Testcase 166: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY(ARRAY[1, 2]); - QUERY PLAN ---------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..2.00 rows=2 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (1, 2)) -(3 rows) - ---Testcase 167: -SELECT * FROM numbers WHERE a = ANY(ARRAY[1, 2]); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 168: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, 2]); - QUERY PLAN ----------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..150.00 rows=150 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` <> 1 OR `a` <> 2) -(3 rows) - ---Testcase 169: -SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, 2]); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 170: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, 2]); - QUERY PLAN ----------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` >= 1 OR `a` >= 2) -(3 rows) - ---Testcase 171: -SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, 2]); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 172: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, 2]); - QUERY PLAN ----------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` <= 1 OR `a` <= 2) -(3 rows) - ---Testcase 173: -SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, 2]); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 174: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ANY(ARRAY[1, 2]); - QUERY PLAN --------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` > 1 OR `a` > 2) -(3 rows) - ---Testcase 175: -SELECT * FROM numbers WHERE a > ANY(ARRAY[1, 2]); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 176: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ANY(ARRAY[1, 2]); - QUERY PLAN --------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` < 1 OR `a` < 2) -(3 rows) - ---Testcase 177: -SELECT * FROM numbers WHERE a < ANY(ARRAY[1, 2]); - a | b ----+----- - 1 | One -(1 row) - ---Testcase 210: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY('{1, 2, 3}'); - QUERY PLAN ------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..3.00 rows=3 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (1, 2, 3)) -(3 rows) - ---Testcase 211: -SELECT * FROM numbers WHERE a = ANY('{1, 2, 3}'); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 212: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY('{1, 2, 3}'); - QUERY PLAN ----------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..150.00 rows=150 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` <> 1 OR `a` <> 2 OR `a` <> 3) -(3 rows) - ---Testcase 213: -SELECT * FROM numbers WHERE a <> ANY('{1, 2, 3}'); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - --- ALL with ARRAY expression ---Testcase 178: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ALL(ARRAY[1, a * 1]); - QUERY PLAN ---------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..1.00 rows=1 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` = 1) AND (`a` = (`a` * 1))) -(3 rows) - ---Testcase 179: -SELECT * FROM numbers WHERE a = ALL(ARRAY[1, a * 1]); - a | b ----+----- - 1 | One -(1 row) - ---Testcase 180: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, a + 1]); - QUERY PLAN ---------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..148.00 rows=148 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` NOT IN (1, (`a` + 1))) -(3 rows) - ---Testcase 181: -SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, a + 1]); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 182: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, a / 1]); - QUERY PLAN ------------------------------------------------------------------------------------------------ - Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` >= 1) AND (`a` >= (`a` / 1))) -(3 rows) - ---Testcase 183: -SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, a / 1]); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 184: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, a + 1]); - QUERY PLAN ------------------------------------------------------------------------------------------------ - Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` <= 1) AND (`a` <= (`a` + 1))) -(3 rows) - ---Testcase 185: -SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, a + 1]); - a | b ----+----- - 1 | One -(1 row) - ---Testcase 186: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ALL(ARRAY[1, a - 1]); - QUERY PLAN ---------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` > 1) AND (`a` > (`a` - 1))) -(3 rows) - ---Testcase 187: -SELECT * FROM numbers WHERE a > ALL(ARRAY[1, a - 1]); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 188: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ALL(ARRAY[2, a + 1]); - QUERY PLAN ---------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` < 2) AND (`a` < (`a` + 1))) -(3 rows) - ---Testcase 189: -SELECT * FROM numbers WHERE a < ALL(ARRAY[2, a + 1]); - a | b ----+----- - 1 | One -(1 row) - --- ALL with ARRAY const ---Testcase 190: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ALL(ARRAY[1, 1]); - QUERY PLAN ---------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..1.00 rows=1 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` = 1 AND `a` = 1) -(3 rows) - ---Testcase 191: -SELECT * FROM numbers WHERE a = ALL(ARRAY[1, 1]); - a | b ----+----- - 1 | One -(1 row) - ---Testcase 192: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, 3]); - QUERY PLAN -------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..148.00 rows=148 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` NOT IN (1, 3)) -(3 rows) - ---Testcase 193: -SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, 3]); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 194: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, 2]); - QUERY PLAN ------------------------------------------------------------------------------------ - Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` >= 1 AND `a` >= 2) -(3 rows) - ---Testcase 195: -SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, 2]); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 196: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, 2]); - QUERY PLAN ------------------------------------------------------------------------------------ - Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` <= 1 AND `a` <= 2) -(3 rows) - ---Testcase 197: -SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, 2]); - a | b ----+----- - 1 | One -(1 row) - ---Testcase 198: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ALL(ARRAY[0, 1]); - QUERY PLAN ---------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` > 0 AND `a` > 1) -(3 rows) - ---Testcase 199: -SELECT * FROM numbers WHERE a > ALL(ARRAY[0, 1]); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 200: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ALL(ARRAY[2, 3]); - QUERY PLAN ---------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` < 2 AND `a` < 3) -(3 rows) - ---Testcase 201: -SELECT * FROM numbers WHERE a < ALL(ARRAY[2, 3]); - a | b ----+----- - 1 | One -(1 row) - --- ANY/ALL with TEXT ARRAY const ---Testcase 202: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE b = ANY(ARRAY['One', 'Two']); - QUERY PLAN ------------------------------------------------------------------------------------ - Foreign Scan on public.numbers (cost=10.00..2.00 rows=2 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`b` IN ('One', 'Two')) -(3 rows) - ---Testcase 203: -SELECT * FROM numbers WHERE b = ANY(ARRAY['One', 'Two']); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---Testcase 204: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE b <> ALL(ARRAY['One', 'Four']); - QUERY PLAN ----------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..148.00 rows=148 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`b` NOT IN ('One', 'Four')) -(3 rows) - ---Testcase 205: -SELECT * FROM numbers WHERE b <> ALL(ARRAY['One', 'Four']); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 206: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE b > ANY(ARRAY['One', 'Two']); - QUERY PLAN ----------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`b` > 'One' OR `b` > 'Two') -(3 rows) - ---Testcase 207: -SELECT * FROM numbers WHERE b > ANY(ARRAY['One', 'Two']); - a | b ----+----- - 2 | Two -(1 row) - ---Testcase 208: -EXPLAIN VERBOSE SELECT * FROM numbers WHERE b > ALL(ARRAY['Four', 'Five']); - QUERY PLAN -------------------------------------------------------------------------------------------- - Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) - Output: a, b - SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`b` > 'Four' AND `b` > 'Five') -(3 rows) - ---Testcase 209: -SELECT * FROM numbers WHERE b > ALL(ARRAY['Four', 'Five']); - a | b ----+----- - 1 | One - 2 | Two -(2 rows) - ---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; - a | b | c ----+----+--- - 1 | 10 | 3 - 1 | 2 | 4 -(2 rows) - ---Testcase 84: -UPDATE multiprimary SET a = 10 WHERE a = 1; ---Testcase 85: -SELECT * from multiprimary; - a | b | c -----+----+--- - 10 | 10 | 3 - 10 | 2 | 4 -(2 rows) - ---Testcase 86: -UPDATE multiprimary SET a = 100, b=200, c=300 WHERE a=10 AND b=10; ---Testcase 87: -SELECT * from multiprimary; - a | b | c ------+-----+----- - 100 | 200 | 300 - 10 | 2 | 4 -(2 rows) - ---Testcase 88: -UPDATE multiprimary SET a = 1234; ---Testcase 89: -SELECT * from multiprimary; - a | b | c -------+-----+----- - 1234 | 200 | 300 - 1234 | 2 | 4 -(2 rows) - ---Testcase 90: -UPDATE multiprimary SET a = a+1, b=b+1 WHERE b=200 AND c=300; ---Testcase 91: -SELECT * from multiprimary; - a | b | c -------+-----+----- - 1235 | 201 | 300 - 1234 | 2 | 4 -(2 rows) - ---Testcase 92: -DELETE from multiprimary WHERE a = 1235; ---Testcase 93: -SELECT * from multiprimary; - a | b | c -------+---+--- - 1234 | 2 | 4 -(1 row) - ---Testcase 94: -DELETE from multiprimary WHERE b = 2; ---Testcase 95: -SELECT * from multiprimary; - a | b | c ----+---+--- -(0 rows) - ---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; - count -------- - 2 -(1 row) - ---Testcase 101: -SELECT sum(b),max(b), min(b) from multiprimary; - sum | max | min ------+-----+----- - 34 | 20 | 2 -(1 row) - ---Testcase 102: -SELECT sum(b+5)+2 from multiprimary group by b/2 order by b/2; - ?column? ----------- - 16 - 17 - 27 -(3 rows) - ---Testcase 103: -SELECT sum(a) from multiprimary group by b having sum(a) > 0 order by sum(a); - sum ------ - 1 - 2 - 2 -(3 rows) - ---Testcase 104: -SELECT sum(a) A from multiprimary group by b having avg(abs(a)) > 0 AND sum(a) > 0 order by A; - a ---- - 1 - 2 - 2 -(3 rows) - ---Testcase 105: -SELECT count(nullif(a, 1)) FROM multiprimary; - count -------- - 1 -(1 row) - ---Testcase 106: -SELECT a,a FROM multiprimary group by 1,2; - a | a ----+--- - 1 | 1 - 2 | 2 -(2 rows) - ---Testcase 107: -SELECT * from multiprimary, numbers WHERE multiprimary.a=numbers.a; - a | b | c | a | b ----+----+----+---+----- - 1 | 2 | 3 | 1 | One - 1 | 2 | 4 | 1 | One - 1 | 10 | 20 | 1 | One - 2 | 20 | 40 | 2 | Two -(4 rows) - ---Testcase 108: -EXPLAIN (VERBOSE, COSTS OFF) -SELECT sum(a) FROM multiprimary HAVING sum(a) > 0; - QUERY PLAN ------------------------------------------------------------ - Aggregate - Output: sum(a) - Filter: (sum(multiprimary.a) > 0) - -> Foreign Scan on public.multiprimary - Output: a, b, c - SQLite query: SELECT `a` FROM main."multiprimary" -(6 rows) - ---Testcase 109: -SELECT sum(a) FROM multiprimary HAVING sum(a) > 0; - sum ------ - 5 -(1 row) - ---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'; - a | b ----+------ - 4 | Four -(1 row) - ---Testcase 112: -EXPLAIN (verbose, costs off) SELECT b, length(b) FROM numbers WHERE abs(a) = 4 AND upper(b) = 'FOUR' AND lower(b) = 'four'; - QUERY PLAN ------------------------------------------------------------------------------------------------------ - Foreign Scan - Output: b, (length((b)::text)) - Filter: ((upper((numbers.b)::text) = 'FOUR'::text) AND (lower((numbers.b)::text) = 'four'::text)) - SQLite query: SELECT `b`, length(`b`) FROM main."numbers" WHERE ((abs(`a`) = 4)) -(4 rows) - --- 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; - b | length -------+-------- - Four | 4 -(1 row) - ---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; - QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------- - Foreign Scan - Output: b, (length((b)::text)) - Filter: ((power('1'::double precision, (numbers.a)::double precision) <> '0'::double precision) AND (length(reverse((numbers.b)::text)) = 4)) - SQLite query: SELECT `b`, length(`b`), `a` FROM main."numbers" WHERE ((length(`b`) = 4)) -(4 rows) - --- Aggregates in subquery are pushed down. ---Testcase 214: -explain (verbose, costs off) -select count(x.a), sum(x.a) from (select a a, sum(a) b from numbers group by a, abs(a) order by 1, 2) x; - QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------- - Aggregate - Output: count(numbers.a), sum(numbers.a) - -> Foreign Scan - Output: numbers.a, (sum(numbers.a)), (abs(numbers.a)) - SQLite query: SELECT `a`, sum(`a`), abs(`a`) FROM main."numbers" GROUP BY 1, 3 ORDER BY `a` ASC NULLS LAST, sum(`a`) ASC NULLS LAST -(5 rows) - ---Testcase 215: -select count(x.a), sum(x.a) from (select a a, sum(a) b from numbers group by a, abs(a) order by 1, 2) x; - count | sum --------+----- - 3 | 7 -(1 row) - ---Testcase 115: -INSERT INTO multiprimary (b,c) VALUES (99, 100); ---Testcase 116: -SELECT c FROM multiprimary WHERE COALESCE(a,b,c) = 99; - c ------ - 100 -(1 row) - ---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; - a | b | c ----+----+---- - 1 | 2 | 2 - 1 | 2 | 2 - 1 | 10 | 10 - 2 | 20 | 20 - | 99 | 99 -(5 rows) - -ALTER FOREIGN TABLE multiprimary2 ALTER COLUMN a OPTIONS(ADD column_name 'b'); ---Testcase 118: -SELECT * FROM multiprimary2; - a | b | c -----+----+---- - 2 | 2 | 2 - 2 | 2 | 2 - 10 | 10 | 10 - 20 | 20 | 20 - 99 | 99 | 99 -(5 rows) - -ALTER FOREIGN TABLE multiprimary2 ALTER COLUMN b OPTIONS (column_name 'nosuch column'); ---Testcase 119: -SELECT * FROM multiprimary2; -ERROR: SQL error during prepare: no such column: nosuch column SELECT `b`, `nosuch column`, `b` FROM main."multiprimary" ---Testcase 140: -EXPLAIN (VERBOSE) SELECT * FROM multiprimary2; - QUERY PLAN --------------------------------------------------------------------------------- - Foreign Scan on public.multiprimary2 (cost=10.00..2275.00 rows=2275 width=12) - Output: a, b, c - SQLite query: SELECT `b`, `nosuch column`, `b` FROM main."multiprimary" -(3 rows) - ---Testcase 120: -SELECT a FROM multiprimary2 WHERE b = 1; -ERROR: SQL error during prepare: no such column: nosuch column SELECT `b` FROM main."multiprimary" WHERE ((`nosuch column` = 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; - a | b b | c ----+-----+---- - 1 | 2 | 10 -(1 row) - ---Testcase 124: -UPDATE columntest SET a=100 WHERE c = 10; ---Testcase 125: -SELECT * FROM columntest; - a | b b | c ------+-----+---- - 100 | 2 | 10 -(1 row) - ---Testcase 126: -INSERT INTO noprimary VALUES(1,'2'); ---Testcase 127: -INSERT INTO noprimary SELECT * FROM noprimary; ---Testcase 128: -SELECT * FROM noprimary; - a | b ----+--- - 1 | 2 - 1 | 2 -(2 rows) - ---get version ---Testcase 153: -\df sqlite* - List of functions - Schema | Name | Result data type | Argument data types | Type ---------+----------------------------+------------------+-----------------------------------------+-------- - public | sqlite_fdw_disconnect | boolean | text | normal - public | sqlite_fdw_disconnect_all | boolean | | normal - public | sqlite_fdw_get_connections | SETOF record | OUT server_name text, OUT valid boolean | normal - public | sqlite_fdw_handler | fdw_handler | | normal - public | sqlite_fdw_validator | void | text[], oid | normal - public | sqlite_fdw_version | integer | | normal -(6 rows) - ---Testcase 154: -SELECT * FROM public.sqlite_fdw_version(); - sqlite_fdw_version --------------------- - 20101 -(1 row) - ---Testcase 155: -SELECT sqlite_fdw_version(); - sqlite_fdw_version --------------------- - 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: -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 151: -DROP SERVER sqlite_svr; ---Testcase 152: -DROP EXTENSION sqlite_fdw CASCADE; diff --git a/expected/11.13/extra/float8.out b/expected/11.13/extra/float8.out deleted file mode 100644 index b3fea10d..00000000 --- a/expected/11.13/extra/float8.out +++ /dev/null @@ -1,1411 +0,0 @@ --- --- FLOAT8 --- ---Testcase 113: -CREATE EXTENSION sqlite_fdw; ---Testcase 114: -CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw -OPTIONS (database '/tmp/sqlitefdw_test_core.db'); ---Testcase 115: -CREATE FOREIGN TABLE FLOAT8_TBL(f1 float8 OPTIONS (key 'true')) SERVER sqlite_svr; ---Testcase 116: -CREATE FOREIGN TABLE FLOAT8_TMP(f1 float8, f2 float8, id int OPTIONS (key 'true')) SERVER sqlite_svr; ---Testcase 1: -INSERT INTO FLOAT8_TBL(f1) VALUES (' 0.0 '); ---Testcase 2: -INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30 '); ---Testcase 3: -INSERT INTO FLOAT8_TBL(f1) VALUES (' -34.84'); ---Testcase 4: -INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200'); ---Testcase 5: -INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200'); --- test for underflow and overflow handling ---Testcase 6: -INSERT INTO FLOAT8_TMP(f1) VALUES ('10e400'::float8); -ERROR: "10e400" is out of range for type double precision -LINE 1: INSERT INTO FLOAT8_TMP(f1) VALUES ('10e400'::float8); - ^ ---Testcase 7: -INSERT INTO FLOAT8_TMP(f1) VALUES ('-10e400'::float8); -ERROR: "-10e400" is out of range for type double precision -LINE 1: INSERT INTO FLOAT8_TMP(f1) VALUES ('-10e400'::float8); - ^ ---Testcase 8: -INSERT INTO FLOAT8_TMP(f1) VALUES ('10e-400'::float8); -ERROR: "10e-400" is out of range for type double precision -LINE 1: INSERT INTO FLOAT8_TMP(f1) VALUES ('10e-400'::float8); - ^ ---Testcase 9: -INSERT INTO FLOAT8_TMP(f1) VALUES ('-10e-400'::float8); -ERROR: "-10e-400" is out of range for type double precision -LINE 1: INSERT INTO FLOAT8_TMP(f1) VALUES ('-10e-400'::float8); - ^ --- test smallest normalized input ---Testcase 117: -INSERT INTO FLOAT8_TMP(f1) VALUES ('2.2250738585072014E-308'::float8); ---Testcase 118: -SELECT float8send(f1) FROM FLOAT8_TMP; - float8send --------------------- - \x0010000000000000 -(1 row) - --- bad input ---Testcase 10: -INSERT INTO FLOAT8_TBL(f1) VALUES (''); -ERROR: invalid input syntax for type double precision: "" -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES (''); - ^ ---Testcase 11: -INSERT INTO FLOAT8_TBL(f1) VALUES (' '); -ERROR: invalid input syntax for type double precision: " " -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES (' '); - ^ ---Testcase 12: -INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz'); -ERROR: invalid input syntax for type double precision: "xyz" -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz'); - ^ ---Testcase 13: -INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0'); -ERROR: invalid input syntax for type double precision: "5.0.0" -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0'); - ^ ---Testcase 14: -INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0'); -ERROR: invalid input syntax for type double precision: "5 . 0" -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0'); - ^ ---Testcase 15: -INSERT INTO FLOAT8_TBL(f1) VALUES ('5. 0'); -ERROR: invalid input syntax for type double precision: "5. 0" -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('5. 0'); - ^ ---Testcase 16: -INSERT INTO FLOAT8_TBL(f1) VALUES (' - 3'); -ERROR: invalid input syntax for type double precision: " - 3" -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES (' - 3'); - ^ ---Testcase 17: -INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5'); -ERROR: invalid input syntax for type double precision: "123 5" -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5'); - ^ --- special inputs ---Testcase 19: -DELETE FROM FLOAT8_TMP; ---Testcase 119: -INSERT INTO FLOAT8_TMP VALUES ('NaN'::float8); ---Testcase 120: -SELECT f1 FROM FLOAT8_TMP; - f1 ----- - -(1 row) - ---Testcase 20: -DELETE FROM FLOAT8_TMP; ---Testcase 121: -INSERT INTO FLOAT8_TMP VALUES ('nan'::float8); ---Testcase 122: -SELECT f1 FROM FLOAT8_TMP; - f1 ----- - -(1 row) - ---Testcase 21: -DELETE FROM FLOAT8_TMP; ---Testcase 123: -INSERT INTO FLOAT8_TMP VALUES (' NAN '::float8); ---Testcase 124: -SELECT f1 FROM FLOAT8_TMP; - f1 ----- - -(1 row) - ---Testcase 22: -DELETE FROM FLOAT8_TMP; ---Testcase 125: -INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8); ---Testcase 126: -SELECT f1 FROM FLOAT8_TMP; - f1 ----------- - Infinity -(1 row) - ---Testcase 23: -DELETE FROM FLOAT8_TMP; ---Testcase 127: -INSERT INTO FLOAT8_TMP VALUES (' -INFINiTY '::float8); ---Testcase 128: -SELECT f1 FROM FLOAT8_TMP; - f1 ------------ - -Infinity -(1 row) - --- bad special inputs ---Testcase 25: -DELETE FROM FLOAT8_TMP; ---Testcase 129: -INSERT INTO FLOAT8_TMP VALUES ('N A N'::float8); -ERROR: invalid input syntax for type double precision: "N A N" -LINE 1: INSERT INTO FLOAT8_TMP VALUES ('N A N'::float8); - ^ ---Testcase 130: -SELECT f1 FROM FLOAT8_TMP; - f1 ----- -(0 rows) - ---Testcase 26: -DELETE FROM FLOAT8_TMP; ---Testcase 131: -INSERT INTO FLOAT8_TMP VALUES ('NaN x'::float8); -ERROR: invalid input syntax for type double precision: "NaN x" -LINE 1: INSERT INTO FLOAT8_TMP VALUES ('NaN x'::float8); - ^ ---Testcase 132: -SELECT f1 FROM FLOAT8_TMP; - f1 ----- -(0 rows) - ---Testcase 27: -DELETE FROM FLOAT8_TMP; ---Testcase 133: -INSERT INTO FLOAT8_TMP VALUES (' INFINITY x'::float8); -ERROR: invalid input syntax for type double precision: " INFINITY x" -LINE 1: INSERT INTO FLOAT8_TMP VALUES (' INFINITY x'::float8); - ^ ---Testcase 134: -SELECT f1 FROM FLOAT8_TMP; - f1 ----- -(0 rows) - ---Testcase 28: -DELETE FROM FLOAT8_TMP; ---Testcase 135: -INSERT INTO FLOAT8_TMP VALUES ('Infinity'::float8 + 100.0); ---Testcase 136: -SELECT f1 FROM FLOAT8_TMP; - f1 ----------- - Infinity -(1 row) - ---Testcase 30: -DELETE FROM FLOAT8_TMP; ---Testcase 137: -INSERT INTO FLOAT8_TMP VALUES ('Infinity'::float8 / 'Infinity'::float8); ---Testcase 138: -SELECT f1 FROM FLOAT8_TMP; - f1 ----- - -(1 row) - ---Testcase 31: -DELETE FROM FLOAT8_TMP; ---Testcase 139: -INSERT INTO FLOAT8_TMP VALUES ('nan'::float8 / 'nan'::float8); ---Testcase 140: -SELECT f1 FROM FLOAT8_TMP; - f1 ----- - -(1 row) - ---Testcase 32: -DELETE FROM FLOAT8_TMP; ---Testcase 141: -INSERT INTO FLOAT8_TMP VALUES ('nan'::numeric::float8); ---Testcase 142: -SELECT f1 FROM FLOAT8_TMP; - f1 ----- - -(1 row) - ---Testcase 34: -SELECT '' AS five, * FROM FLOAT8_TBL; - five | f1 -------+---------------------- - | 0 - | 1004.3 - | -34.84 - | 1.2345678901234e+200 - | 1.2345678901234e-200 -(5 rows) - ---Testcase 35: -SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3'; - four | f1 -------+---------------------- - | 0 - | -34.84 - | 1.2345678901234e+200 - | 1.2345678901234e-200 -(4 rows) - ---Testcase 36: -SELECT '' AS one, f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3'; - one | f1 ------+-------- - | 1004.3 -(1 row) - ---Testcase 37: -SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1; - three | f1 --------+---------------------- - | 0 - | -34.84 - | 1.2345678901234e-200 -(3 rows) - ---Testcase 38: -SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE f.f1 < '1004.3'; - three | f1 --------+---------------------- - | 0 - | -34.84 - | 1.2345678901234e-200 -(3 rows) - ---Testcase 39: -SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1; - four | f1 -------+---------------------- - | 0 - | 1004.3 - | -34.84 - | 1.2345678901234e-200 -(4 rows) - ---Testcase 40: -SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3'; - four | f1 -------+---------------------- - | 0 - | 1004.3 - | -34.84 - | 1.2345678901234e-200 -(4 rows) - ---Testcase 41: -SELECT '' AS three, f.f1, f.f1 * '-10' AS x - FROM FLOAT8_TBL f - WHERE f.f1 > '0.0'; - three | f1 | x --------+----------------------+----------------------- - | 1004.3 | -10043 - | 1.2345678901234e+200 | -1.2345678901234e+201 - | 1.2345678901234e-200 | -1.2345678901234e-199 -(3 rows) - ---Testcase 42: -SELECT '' AS three, f.f1, f.f1 + '-10' AS x - FROM FLOAT8_TBL f - WHERE f.f1 > '0.0'; - three | f1 | x --------+----------------------+---------------------- - | 1004.3 | 994.3 - | 1.2345678901234e+200 | 1.2345678901234e+200 - | 1.2345678901234e-200 | -10 -(3 rows) - ---Testcase 43: -SELECT '' AS three, f.f1, f.f1 / '-10' AS x - FROM FLOAT8_TBL f - WHERE f.f1 > '0.0'; - three | f1 | x --------+----------------------+----------------------- - | 1004.3 | -100.43 - | 1.2345678901234e+200 | -1.2345678901234e+199 - | 1.2345678901234e-200 | -1.2345678901234e-201 -(3 rows) - ---Testcase 44: -SELECT '' AS three, f.f1, f.f1 - '-10' AS x - FROM FLOAT8_TBL f - WHERE f.f1 > '0.0'; - three | f1 | x --------+----------------------+---------------------- - | 1004.3 | 1014.3 - | 1.2345678901234e+200 | 1.2345678901234e+200 - | 1.2345678901234e-200 | 10 -(3 rows) - ---Testcase 45: -SELECT '' AS one, f.f1 ^ '2.0' AS square_f1 - FROM FLOAT8_TBL f where f.f1 = '1004.3'; - one | square_f1 ------+------------ - | 1008618.49 -(1 row) - --- absolute value ---Testcase 46: -SELECT '' AS five, f.f1, @f.f1 AS abs_f1 - FROM FLOAT8_TBL f; - five | f1 | abs_f1 -------+----------------------+---------------------- - | 0 | 0 - | 1004.3 | 1004.3 - | -34.84 | 34.84 - | 1.2345678901234e+200 | 1.2345678901234e+200 - | 1.2345678901234e-200 | 1.2345678901234e-200 -(5 rows) - --- truncate ---Testcase 47: -SELECT '' AS five, f.f1, trunc(f.f1) AS trunc_f1 - FROM FLOAT8_TBL f; - five | f1 | trunc_f1 -------+----------------------+---------------------- - | 0 | 0 - | 1004.3 | 1004 - | -34.84 | -34 - | 1.2345678901234e+200 | 1.2345678901234e+200 - | 1.2345678901234e-200 | 0 -(5 rows) - --- round ---Testcase 48: -SELECT '' AS five, f.f1, round(f.f1) AS round_f1 - FROM FLOAT8_TBL f; - five | f1 | round_f1 -------+----------------------+---------------------- - | 0 | 0 - | 1004.3 | 1004 - | -34.84 | -35 - | 1.2345678901234e+200 | 1.2345678901234e+200 - | 1.2345678901234e-200 | 0 -(5 rows) - --- ceil / ceiling ---Testcase 49: -select ceil(f1) as ceil_f1 from float8_tbl f; - ceil_f1 ----------------------- - 0 - 1005 - -34 - 1.2345678901234e+200 - 1 -(5 rows) - ---Testcase 50: -select ceiling(f1) as ceiling_f1 from float8_tbl f; - ceiling_f1 ----------------------- - 0 - 1005 - -34 - 1.2345678901234e+200 - 1 -(5 rows) - --- floor ---Testcase 51: -select floor(f1) as floor_f1 from float8_tbl f; - floor_f1 ----------------------- - 0 - 1004 - -35 - 1.2345678901234e+200 - 0 -(5 rows) - --- sign ---Testcase 52: -select sign(f1) as sign_f1 from float8_tbl f; - sign_f1 ---------- - 0 - 1 - -1 - 1 - 1 -(5 rows) - --- avoid bit-exact output here because operations may not be bit-exact. -SET extra_float_digits = 0; --- square root -BEGIN; ---Testcase 53: -DELETE FROM FLOAT8_TBL; ---Testcase 54: -INSERT INTO FLOAT8_TBL VALUES ('64'::float8); ---Testcase 55: -SELECT sqrt(f1) as eight FROM FLOAT8_TBL; - eight -------- - 8 -(1 row) - ---Testcase 56: -SELECT |/f1 as eight FROM FLOAT8_TBL; - eight -------- - 8 -(1 row) - -ROLLBACK; ---Testcase 57: -SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1 - FROM FLOAT8_TBL f - WHERE f.f1 > '0.0'; - three | f1 | sqrt_f1 --------+----------------------+----------------------- - | 1004.3 | 31.6906926399535 - | 1.2345678901234e+200 | 1.11111110611109e+100 - | 1.2345678901234e-200 | 1.11111110611109e-100 -(3 rows) - --- power ---Testcase 58: -DELETE FROM FLOAT8_TMP; ---Testcase 143: -INSERT INTO FLOAT8_TMP VALUES ('144'::float8, '0.5'::float8); ---Testcase 144: -SELECT power(f1, f2) FROM FLOAT8_TMP; - power -------- - 12 -(1 row) - ---Testcase 60: -DELETE FROM FLOAT8_TMP; ---Testcase 145: -INSERT INTO FLOAT8_TMP VALUES ('NaN'::float8, '0.5'::float8); ---Testcase 146: -SELECT power(f1, f2) FROM FLOAT8_TMP; - power -------- - -(1 row) - ---Testcase 61: -DELETE FROM FLOAT8_TMP; ---Testcase 147: -INSERT INTO FLOAT8_TMP VALUES ('144'::float8, 'NaN'::float8); ---Testcase 148: -SELECT power(f1, f2) FROM FLOAT8_TMP; - power -------- - -(1 row) - ---Testcase 62: -DELETE FROM FLOAT8_TMP; ---Testcase 149: -INSERT INTO FLOAT8_TMP VALUES ('NaN'::float8, 'NaN'::float8); ---Testcase 150: -SELECT power(f1, f2) FROM FLOAT8_TMP; - power -------- - -(1 row) - ---Testcase 63: -DELETE FROM FLOAT8_TMP; ---Testcase 151: -INSERT INTO FLOAT8_TMP VALUES ('-1'::float8, 'NaN'::float8); ---Testcase 152: -SELECT power(f1, f2) FROM FLOAT8_TMP; - power -------- - -(1 row) - ---Testcase 64: -DELETE FROM FLOAT8_TMP; ---Testcase 153: -INSERT INTO FLOAT8_TMP VALUES ('1'::float8, 'NaN'::float8); ---Testcase 154: -SELECT power(f1, f2) FROM FLOAT8_TMP; - power -------- - -(1 row) - ---Testcase 65: -DELETE FROM FLOAT8_TMP; ---Testcase 155: -INSERT INTO FLOAT8_TMP VALUES ('NaN'::float8 , '0'::float8); ---Testcase 156: -SELECT power(f1, f2) FROM FLOAT8_TMP; - power -------- - -(1 row) - --- take exp of ln(f.f1) ---Testcase 67: -SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1 - FROM FLOAT8_TBL f - WHERE f.f1 > '0.0'; - three | f1 | exp_ln_f1 --------+----------------------+----------------------- - | 1004.3 | 1004.3 - | 1.2345678901234e+200 | 1.23456789012338e+200 - | 1.2345678901234e-200 | 1.23456789012339e-200 -(3 rows) - --- cube root -BEGIN; ---Testcase 68: -DELETE FROM FLOAT8_TBL; ---Testcase 69: -INSERT INTO FLOAT8_TBL VALUES ('27'::float8); ---Testcase 70: -SELECT ||/f1 as three FROM FLOAT8_TBL; - three -------- - 3 -(1 row) - -ROLLBACK; ---Testcase 71: -SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f; - five | f1 | cbrt_f1 -------+----------------------+---------------------- - | 0 | 0 - | 1004.3 | 10.014312837827 - | -34.84 | -3.26607421344208 - | 1.2345678901234e+200 | 4.97933859234765e+66 - | 1.2345678901234e-200 | 2.3112042409018e-67 -(5 rows) - ---Testcase 72: -SELECT '' AS five, * FROM FLOAT8_TBL; - five | f1 -------+---------------------- - | 0 - | 1004.3 - | -34.84 - | 1.2345678901234e+200 - | 1.2345678901234e-200 -(5 rows) - ---Testcase 73: -UPDATE FLOAT8_TBL - SET f1 = FLOAT8_TBL.f1 * '-1' - WHERE FLOAT8_TBL.f1 > '0.0'; ---Testcase 74: -SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f; -ERROR: value out of range: overflow ---Testcase 75: -SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f; -ERROR: value out of range: overflow -BEGIN; ---Testcase 76: -DELETE FROM FLOAT8_TBL; ---Testcase 77: -INSERT INTO FLOAT8_TBL VALUES (0 ^ 0 + 0 ^ 1 + 0 ^ 0.0 + 0 ^ 0.5); ---Testcase 78: -SELECT * FROM FLOAT8_TBL; - f1 ----- - 2 -(1 row) - -ROLLBACK; ---Testcase 79: -SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ; -ERROR: cannot take logarithm of zero ---Testcase 80: -SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ; -ERROR: cannot take logarithm of a negative number ---Testcase 81: -SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f; -ERROR: value out of range: underflow ---Testcase 82: -SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f; -ERROR: division by zero ---Testcase 83: -SELECT '' AS five, * FROM FLOAT8_TBL; - five | f1 -------+----------------------- - | 0 - | -1004.3 - | -34.84 - | -1.2345678901234e+200 - | -1.2345678901234e-200 -(5 rows) - --- hyperbolic functions --- we run these with extra_float_digits = 0 too, since different platforms --- tend to produce results that vary in the last place. ---Testcase 157: -DELETE FROM FLOAT8_TMP; ---Testcase 158: -INSERT INTO FLOAT8_TMP(f1) VALUES (1); ---Testcase 159: -SELECT sinh(f1) FROM FLOAT8_TMP; -ERROR: function sinh(double precision) does not exist -LINE 1: SELECT sinh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 160: -SELECT cosh(f1) FROM FLOAT8_TMP; -ERROR: function cosh(double precision) does not exist -LINE 1: SELECT cosh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 161: -SELECT tanh(f1) FROM FLOAT8_TMP; -ERROR: function tanh(double precision) does not exist -LINE 1: SELECT tanh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 162: -SELECT asinh(f1) FROM FLOAT8_TMP; -ERROR: function asinh(double precision) does not exist -LINE 1: SELECT asinh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 163: -DELETE FROM FLOAT8_TMP; ---Testcase 164: -INSERT INTO FLOAT8_TMP(f1) VALUES (2); ---Testcase 165: -SELECT acosh(f1) FROM FLOAT8_TMP; -ERROR: function acosh(double precision) does not exist -LINE 1: SELECT acosh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 166: -DELETE FROM FLOAT8_TMP; ---Testcase 167: -INSERT INTO FLOAT8_TMP(f1) VALUES (0.5); ---Testcase 168: -SELECT atanh(f1) FROM FLOAT8_TMP; -ERROR: function atanh(double precision) does not exist -LINE 1: SELECT atanh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. --- test Inf/NaN cases for hyperbolic functions ---Testcase 169: -DELETE FROM FLOAT8_TMP; ---Testcase 170: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'infinity'); ---Testcase 171: -SELECT sinh(f1) FROM FLOAT8_TMP; -ERROR: function sinh(double precision) does not exist -LINE 1: SELECT sinh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 172: -DELETE FROM FLOAT8_TMP; ---Testcase 173: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 '-infinity'); ---Testcase 174: -SELECT sinh(f1) FROM FLOAT8_TMP; -ERROR: function sinh(double precision) does not exist -LINE 1: SELECT sinh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 175: -DELETE FROM FLOAT8_TMP; ---Testcase 176: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'nan'); ---Testcase 177: -SELECT sinh(f1) FROM FLOAT8_TMP; -ERROR: function sinh(double precision) does not exist -LINE 1: SELECT sinh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 178: -DELETE FROM FLOAT8_TMP; ---Testcase 179: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'infinity'); ---Testcase 180: -SELECT cosh(f1) FROM FLOAT8_TMP; -ERROR: function cosh(double precision) does not exist -LINE 1: SELECT cosh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 181: -DELETE FROM FLOAT8_TMP; ---Testcase 182: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 '-infinity'); ---Testcase 183: -SELECT cosh(f1) FROM FLOAT8_TMP; -ERROR: function cosh(double precision) does not exist -LINE 1: SELECT cosh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 184: -DELETE FROM FLOAT8_TMP; ---Testcase 185: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'nan'); ---Testcase 186: -SELECT cosh(f1) FROM FLOAT8_TMP; -ERROR: function cosh(double precision) does not exist -LINE 1: SELECT cosh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 187: -DELETE FROM FLOAT8_TMP; ---Testcase 188: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'infinity'); ---Testcase 189: -SELECT tanh(f1) FROM FLOAT8_TMP; -ERROR: function tanh(double precision) does not exist -LINE 1: SELECT tanh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 190: -DELETE FROM FLOAT8_TMP; ---Testcase 191: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 '-infinity'); ---Testcase 192: -SELECT tanh(f1) FROM FLOAT8_TMP; -ERROR: function tanh(double precision) does not exist -LINE 1: SELECT tanh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 193: -DELETE FROM FLOAT8_TMP; ---Testcase 194: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'nan'); ---Testcase 195: -SELECT tanh(f1) FROM FLOAT8_TMP; -ERROR: function tanh(double precision) does not exist -LINE 1: SELECT tanh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 196: -DELETE FROM FLOAT8_TMP; ---Testcase 197: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'infinity'); ---Testcase 198: -SELECT asinh(f1) FROM FLOAT8_TMP; -ERROR: function asinh(double precision) does not exist -LINE 1: SELECT asinh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 199: -DELETE FROM FLOAT8_TMP; ---Testcase 200: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 '-infinity'); ---Testcase 201: -SELECT asinh(f1) FROM FLOAT8_TMP; -ERROR: function asinh(double precision) does not exist -LINE 1: SELECT asinh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 202: -DELETE FROM FLOAT8_TMP; ---Testcase 203: -INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'nan'); ---Testcase 204: -SELECT asinh(f1) FROM FLOAT8_TMP; -ERROR: function asinh(double precision) does not exist -LINE 1: SELECT asinh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. --- acosh(Inf) should be Inf, but some mingw versions produce NaN, so skip test --- SELECT acosh(float8 'infinity'); ---Testcase 205: -DELETE FROM FLOAT8_TMP; ---Testcase 206: -INSERT INTO FLOAT8_TMP VALUES (float8 '-infinity'); ---Testcase 207: -SELECT acosh(f1) FROM FLOAT8_TMP; -ERROR: function acosh(double precision) does not exist -LINE 1: SELECT acosh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 208: -DELETE FROM FLOAT8_TMP; ---Testcase 209: -INSERT INTO FLOAT8_TMP VALUES ((float8 'nan')); ---Testcase 210: -SELECT acosh(f1) FROM FLOAT8_TMP; -ERROR: function acosh(double precision) does not exist -LINE 1: SELECT acosh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 211: -DELETE FROM FLOAT8_TMP; ---Testcase 212: -INSERT INTO FLOAT8_TMP VALUES ((float8 'infinity')); ---Testcase 213: -SELECT atanh(f1) FROM FLOAT8_TMP; -ERROR: function atanh(double precision) does not exist -LINE 1: SELECT atanh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 214: -DELETE FROM FLOAT8_TMP; ---Testcase 215: -INSERT INTO FLOAT8_TMP VALUES ((float8 '-infinity')); ---Testcase 216: -SELECT atanh(f1) FROM FLOAT8_TMP; -ERROR: function atanh(double precision) does not exist -LINE 1: SELECT atanh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. ---Testcase 217: -DELETE FROM FLOAT8_TMP; ---Testcase 218: -INSERT INTO FLOAT8_TMP VALUES ((float8 'nan')); ---Testcase 219: -SELECT atanh(f1) FROM FLOAT8_TMP; -ERROR: function atanh(double precision) does not exist -LINE 1: SELECT atanh(f1) FROM FLOAT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. -RESET extra_float_digits; --- test for over- and underflow ---Testcase 84: -INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400'); -ERROR: "10e400" is out of range for type double precision -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400'); - ^ ---Testcase 85: -INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400'); -ERROR: "-10e400" is out of range for type double precision -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400'); - ^ ---Testcase 86: -INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400'); -ERROR: "10e-400" is out of range for type double precision -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400'); - ^ ---Testcase 87: -INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400'); -ERROR: "-10e-400" is out of range for type double precision -LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400'); - ^ --- maintain external table consistency across platforms --- delete all values and reinsert well-behaved ones ---Testcase 88: -DELETE FROM FLOAT8_TBL; ---Testcase 89: -INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0'); ---Testcase 90: -INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84'); ---Testcase 91: -INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30'); ---Testcase 92: -INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200'); ---Testcase 93: -INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200'); ---Testcase 94: -SELECT '' AS five, * FROM FLOAT8_TBL; - five | f1 -------+----------------------- - | 0 - | -34.84 - | -1004.3 - | -1.2345678901234e+200 - | -1.2345678901234e-200 -(5 rows) - --- test edge-case coercions to integer ---Testcase 220: -DELETE FROM FLOAT8_TMP; ---Testcase 221: -INSERT INTO FLOAT8_TMP VALUES ('32767.4'::float8); ---Testcase 222: -SELECT f1::int2 FROM FLOAT8_TMP; - f1 -------- - 32767 -(1 row) - ---Testcase 223: -DELETE FROM FLOAT8_TMP; ---Testcase 224: -INSERT INTO FLOAT8_TMP VALUES ('32767.6'::float8); ---Testcase 225: -SELECT f1::int2 FROM FLOAT8_TMP; -ERROR: smallint out of range ---Testcase 226: -DELETE FROM FLOAT8_TMP; ---Testcase 227: -INSERT INTO FLOAT8_TMP VALUES ('-32768.4'::float8); ---Testcase 228: -SELECT f1::int2 FROM FLOAT8_TMP; - f1 --------- - -32768 -(1 row) - ---Testcase 229: -DELETE FROM FLOAT8_TMP; ---Testcase 230: -INSERT INTO FLOAT8_TMP VALUES ('-32768.6'::float8); ---Testcase 231: -SELECT f1::int2 FROM FLOAT8_TMP; -ERROR: smallint out of range ---Testcase 232: -DELETE FROM FLOAT8_TMP; ---Testcase 233: -INSERT INTO FLOAT8_TMP VALUES ('2147483647.4'::float8); ---Testcase 234: -SELECT f1::int4 FROM FLOAT8_TMP; - f1 ------------- - 2147483647 -(1 row) - ---Testcase 235: -DELETE FROM FLOAT8_TMP; ---Testcase 236: -INSERT INTO FLOAT8_TMP VALUES ('2147483647.6'::float8); ---Testcase 237: -SELECT f1::int4 FROM FLOAT8_TMP; -ERROR: integer out of range ---Testcase 238: -DELETE FROM FLOAT8_TMP; ---Testcase 239: -INSERT INTO FLOAT8_TMP VALUES ('-2147483648.4'::float8); ---Testcase 240: -SELECT f1::int4 FROM FLOAT8_TMP; - f1 -------------- - -2147483648 -(1 row) - ---Testcase 241: -DELETE FROM FLOAT8_TMP; ---Testcase 242: -INSERT INTO FLOAT8_TMP VALUES ('-2147483648.6'::float8); ---Testcase 243: -SELECT f1::int4 FROM FLOAT8_TMP; -ERROR: integer out of range ---Testcase 244: -DELETE FROM FLOAT8_TMP; ---Testcase 245: -INSERT INTO FLOAT8_TMP VALUES ('9223372036854773760'::float8); ---Testcase 246: -SELECT f1::int8 FROM FLOAT8_TMP; - f1 ---------------------- - 9223372036854773760 -(1 row) - ---Testcase 247: -DELETE FROM FLOAT8_TMP; ---Testcase 248: -INSERT INTO FLOAT8_TMP VALUES ('9223372036854775807'::float8); ---Testcase 249: -SELECT f1::int8 FROM FLOAT8_TMP; -ERROR: bigint out of range ---Testcase 250: -DELETE FROM FLOAT8_TMP; ---Testcase 251: -INSERT INTO FLOAT8_TMP VALUES ('-9223372036854775808.5'::float8); ---Testcase 252: -SELECT f1::int8 FROM FLOAT8_TMP; - f1 ----------------------- - -9223372036854775808 -(1 row) - ---Testcase 253: -DELETE FROM FLOAT8_TMP; ---Testcase 254: -INSERT INTO FLOAT8_TMP VALUES ('-9223372036854780000'::float8); ---Testcase 255: -SELECT f1::int8 FROM FLOAT8_TMP; -ERROR: bigint out of range --- test exact cases for trigonometric functions in degrees -BEGIN; ---Testcase 95: -DELETE FROM FLOAT8_TBL; ---Testcase 96: -INSERT INTO FLOAT8_TBL VALUES (0), (30), (90), (150), (180), - (210), (270), (330), (360); ---Testcase 97: -SELECT f1, - sind(f1), - sind(f1) IN (-1,-0.5,0,0.5,1) AS sind_exact - FROM FLOAT8_TBL; - f1 | sind | sind_exact ------+------+------------ - 0 | 0 | t - 30 | 0.5 | t - 90 | 1 | t - 150 | 0.5 | t - 180 | 0 | t - 210 | -0.5 | t - 270 | -1 | t - 330 | -0.5 | t - 360 | 0 | t -(9 rows) - ---Testcase 98: -DELETE FROM FLOAT8_TBL; ---Testcase 99: -INSERT INTO FLOAT8_TBL VALUES (0), (60), (90), (120), (180), - (240), (270), (300), (360); ---Testcase 100: -SELECT f1, - cosd(f1), - cosd(f1) IN (-1,-0.5,0,0.5,1) AS cosd_exact - FROM FLOAT8_TBL; - f1 | cosd | cosd_exact ------+------+------------ - 0 | 1 | t - 60 | 0.5 | t - 90 | 0 | t - 120 | -0.5 | t - 180 | -1 | t - 240 | -0.5 | t - 270 | 0 | t - 300 | 0.5 | t - 360 | 1 | t -(9 rows) - ---Testcase 101: -DELETE FROM FLOAT8_TBL; ---Testcase 102: -INSERT INTO FLOAT8_TBL VALUES (0), (45), (90), (135), (180), - (225), (270), (315), (360); ---Testcase 103: -SELECT f1, - tand(f1), - tand(f1) IN ('-Infinity'::float8,-1,0, - 1,'Infinity'::float8) AS tand_exact, - cotd(f1), - cotd(f1) IN ('-Infinity'::float8,-1,0, - 1,'Infinity'::float8) AS cotd_exact - FROM FLOAT8_TBL; - f1 | tand | tand_exact | cotd | cotd_exact ------+-----------+------------+-----------+------------ - 0 | 0 | t | Infinity | t - 45 | 1 | t | 1 | t - 90 | Infinity | t | 0 | t - 135 | -1 | t | -1 | t - 180 | 0 | t | -Infinity | t - 225 | 1 | t | 1 | t - 270 | -Infinity | t | 0 | t - 315 | -1 | t | -1 | t - 360 | 0 | t | Infinity | t -(9 rows) - ---Testcase 104: -DELETE FROM FLOAT8_TBL; ---Testcase 105: -INSERT INTO FLOAT8_TBL VALUES (-1), (-0.5), (0), (0.5), (1); ---Testcase 106: -SELECT f1, - asind(f1), - asind(f1) IN (-90,-30,0,30,90) AS asind_exact, - acosd(f1), - acosd(f1) IN (0,60,90,120,180) AS acosd_exact - FROM FLOAT8_TBL; - f1 | asind | asind_exact | acosd | acosd_exact -------+-------+-------------+-------+------------- - -1 | -90 | t | 180 | t - -0.5 | -30 | t | 120 | t - 0 | 0 | t | 90 | t - 0.5 | 30 | t | 60 | t - 1 | 90 | t | 0 | t -(5 rows) - ---Testcase 107: -DELETE FROM FLOAT8_TBL; ---Testcase 108: -INSERT INTO FLOAT8_TBL VALUES ('-Infinity'::float8), (-1), (0), (1), - ('Infinity'::float8); ---Testcase 109: -SELECT f1, - atand(f1), - atand(f1) IN (-90,-45,0,45,90) AS atand_exact - FROM FLOAT8_TBL; - f1 | atand | atand_exact ------------+-------+------------- - -Infinity | -90 | t - -1 | -45 | t - 0 | 0 | t - 1 | 45 | t - Infinity | 90 | t -(5 rows) - ---Testcase 110: -DELETE FROM FLOAT8_TBL; ---Testcase 111: -INSERT INTO FLOAT8_TBL SELECT * FROM generate_series(0, 360, 90); ---Testcase 112: -SELECT x, y, - atan2d(y, x), - atan2d(y, x) IN (-90,0,90,180) AS atan2d_exact -FROM (SELECT 10*cosd(f1), 10*sind(f1) - FROM FLOAT8_TBL) AS t(x,y); - x | y | atan2d | atan2d_exact ------+-----+--------+-------------- - 10 | 0 | 0 | t - 0 | 10 | 90 | t - -10 | 0 | 180 | t - 0 | -10 | -90 | t - 10 | 0 | 0 | t -(5 rows) - -ROLLBACK; --- --- test output (and round-trip safety) of various values. --- To ensure we're testing what we think we're testing, start with --- float values specified by bit patterns (as a useful side effect, --- this means we'll fail on non-IEEE platforms). ---Testcase 256: -create type xfloat8; ---Testcase 257: -create function xfloat8in(cstring) returns xfloat8 immutable strict - language internal as 'int8in'; -NOTICE: return type xfloat8 is only a shell ---Testcase 258: -create function xfloat8out(xfloat8) returns cstring immutable strict - language internal as 'int8out'; -NOTICE: argument type xfloat8 is only a shell ---Testcase 259: -create type xfloat8 (input = xfloat8in, output = xfloat8out, like = float8); ---Testcase 260: -create cast (xfloat8 as float8) without function; ---Testcase 261: -create cast (float8 as xfloat8) without function; ---Testcase 262: -create cast (xfloat8 as bigint) without function; ---Testcase 263: -create cast (bigint as xfloat8) without function; --- float8: seeeeeee eeeeeeee eeeeeeee mmmmmmmm mmmmmmmm(x4) --- we don't care to assume the platform's strtod() handles subnormals --- correctly; those are "use at your own risk". However we do test --- subnormal outputs, since those are under our control. ---Testcase 264: -create foreign table testdata(bits text, id int OPTIONS (key 'true')) server sqlite_svr; -begin; ---Testcase 265: -insert into testdata(bits) values - -- small subnormals - (x'0000000000000001'), - (x'0000000000000002'), (x'0000000000000003'), - (x'0000000000001000'), (x'0000000100000000'), - (x'0000010000000000'), (x'0000010100000000'), - (x'0000400000000000'), (x'0000400100000000'), - (x'0000800000000000'), (x'0000800000000001'), - -- these values taken from upstream testsuite - (x'00000000000f4240'), - (x'00000000016e3600'), - (x'0000008cdcdea440'), - -- borderline between subnormal and normal - (x'000ffffffffffff0'), (x'000ffffffffffff1'), - (x'000ffffffffffffe'), (x'000fffffffffffff'); ---Testcase 266: -select float8send(flt) as ibits, - flt - from (select bits::bit(64)::bigint::xfloat8::float8 as flt - from testdata - offset 0) s; - ibits | flt ---------------------+----------------------- - \x0000000000000001 | 4.94065645841247e-324 - \x0000000000000002 | 9.88131291682493e-324 - \x0000000000000003 | 1.48219693752374e-323 - \x0000000000001000 | 2.02369288536575e-320 - \x0000000100000000 | 2.12199579096527e-314 - \x0000010000000000 | 5.4323092248711e-312 - \x0000010100000000 | 5.45352918278075e-312 - \x0000400000000000 | 3.4766779039175e-310 - \x0000400100000000 | 3.4768901034966e-310 - \x0000800000000000 | 6.953355807835e-310 - \x0000800000000001 | 6.95335580783505e-310 - \x00000000000f4240 | 4.94065645841247e-318 - \x00000000016e3600 | 1.18575755001899e-316 - \x0000008cdcdea440 | 2.989102097996e-312 - \x000ffffffffffff0 | 2.22507385850719e-308 - \x000ffffffffffff1 | 2.22507385850719e-308 - \x000ffffffffffffe | 2.2250738585072e-308 - \x000fffffffffffff | 2.2250738585072e-308 -(18 rows) - -rollback; --- round-trip tests -begin; ---Testcase 267: -insert into testdata(bits) values - (x'0000000000000000'), - -- smallest normal values - (x'0010000000000000'), (x'0010000000000001'), - (x'0010000000000002'), (x'0018000000000000'), - -- - (x'3ddb7cdfd9d7bdba'), (x'3ddb7cdfd9d7bdbb'), (x'3ddb7cdfd9d7bdbc'), - (x'3e112e0be826d694'), (x'3e112e0be826d695'), (x'3e112e0be826d696'), - (x'3e45798ee2308c39'), (x'3e45798ee2308c3a'), (x'3e45798ee2308c3b'), - (x'3e7ad7f29abcaf47'), (x'3e7ad7f29abcaf48'), (x'3e7ad7f29abcaf49'), - (x'3eb0c6f7a0b5ed8c'), (x'3eb0c6f7a0b5ed8d'), (x'3eb0c6f7a0b5ed8e'), - (x'3ee4f8b588e368ef'), (x'3ee4f8b588e368f0'), (x'3ee4f8b588e368f1'), - (x'3f1a36e2eb1c432c'), (x'3f1a36e2eb1c432d'), (x'3f1a36e2eb1c432e'), - (x'3f50624dd2f1a9fb'), (x'3f50624dd2f1a9fc'), (x'3f50624dd2f1a9fd'), - (x'3f847ae147ae147a'), (x'3f847ae147ae147b'), (x'3f847ae147ae147c'), - (x'3fb9999999999999'), (x'3fb999999999999a'), (x'3fb999999999999b'), - -- values very close to 1 - (x'3feffffffffffff0'), (x'3feffffffffffff1'), (x'3feffffffffffff2'), - (x'3feffffffffffff3'), (x'3feffffffffffff4'), (x'3feffffffffffff5'), - (x'3feffffffffffff6'), (x'3feffffffffffff7'), (x'3feffffffffffff8'), - (x'3feffffffffffff9'), (x'3feffffffffffffa'), (x'3feffffffffffffb'), - (x'3feffffffffffffc'), (x'3feffffffffffffd'), (x'3feffffffffffffe'), - (x'3fefffffffffffff'), - (x'3ff0000000000000'), - (x'3ff0000000000001'), (x'3ff0000000000002'), (x'3ff0000000000003'), - (x'3ff0000000000004'), (x'3ff0000000000005'), (x'3ff0000000000006'), - (x'3ff0000000000007'), (x'3ff0000000000008'), (x'3ff0000000000009'), - -- - (x'3ff921fb54442d18'), - (x'4005bf0a8b14576a'), - (x'400921fb54442d18'), - -- - (x'4023ffffffffffff'), (x'4024000000000000'), (x'4024000000000001'), - (x'4058ffffffffffff'), (x'4059000000000000'), (x'4059000000000001'), - (x'408f3fffffffffff'), (x'408f400000000000'), (x'408f400000000001'), - (x'40c387ffffffffff'), (x'40c3880000000000'), (x'40c3880000000001'), - (x'40f869ffffffffff'), (x'40f86a0000000000'), (x'40f86a0000000001'), - (x'412e847fffffffff'), (x'412e848000000000'), (x'412e848000000001'), - (x'416312cfffffffff'), (x'416312d000000000'), (x'416312d000000001'), - (x'4197d783ffffffff'), (x'4197d78400000000'), (x'4197d78400000001'), - (x'41cdcd64ffffffff'), (x'41cdcd6500000000'), (x'41cdcd6500000001'), - (x'4202a05f1fffffff'), (x'4202a05f20000000'), (x'4202a05f20000001'), - (x'42374876e7ffffff'), (x'42374876e8000000'), (x'42374876e8000001'), - (x'426d1a94a1ffffff'), (x'426d1a94a2000000'), (x'426d1a94a2000001'), - (x'42a2309ce53fffff'), (x'42a2309ce5400000'), (x'42a2309ce5400001'), - (x'42d6bcc41e8fffff'), (x'42d6bcc41e900000'), (x'42d6bcc41e900001'), - (x'430c6bf52633ffff'), (x'430c6bf526340000'), (x'430c6bf526340001'), - (x'4341c37937e07fff'), (x'4341c37937e08000'), (x'4341c37937e08001'), - (x'4376345785d89fff'), (x'4376345785d8a000'), (x'4376345785d8a001'), - (x'43abc16d674ec7ff'), (x'43abc16d674ec800'), (x'43abc16d674ec801'), - (x'43e158e460913cff'), (x'43e158e460913d00'), (x'43e158e460913d01'), - (x'4415af1d78b58c3f'), (x'4415af1d78b58c40'), (x'4415af1d78b58c41'), - (x'444b1ae4d6e2ef4f'), (x'444b1ae4d6e2ef50'), (x'444b1ae4d6e2ef51'), - (x'4480f0cf064dd591'), (x'4480f0cf064dd592'), (x'4480f0cf064dd593'), - (x'44b52d02c7e14af5'), (x'44b52d02c7e14af6'), (x'44b52d02c7e14af7'), - (x'44ea784379d99db3'), (x'44ea784379d99db4'), (x'44ea784379d99db5'), - (x'45208b2a2c280290'), (x'45208b2a2c280291'), (x'45208b2a2c280292'), - -- - (x'7feffffffffffffe'), (x'7fefffffffffffff'), - -- round to even tests (+ve) - (x'4350000000000002'), - (x'4350000000002e06'), - (x'4352000000000003'), - (x'4352000000000004'), - (x'4358000000000003'), - (x'4358000000000004'), - (x'435f000000000020'), - -- round to even tests (-ve) - (x'c350000000000002'), - (x'c350000000002e06'), - (x'c352000000000003'), - (x'c352000000000004'), - (x'c358000000000003'), - (x'c358000000000004'), - (x'c35f000000000020'), - -- exercise fixed-point memmoves - (x'42dc12218377de66'), - (x'42a674e79c5fe51f'), - (x'4271f71fb04cb74c'), - (x'423cbe991a145879'), - (x'4206fee0e1a9e061'), - (x'41d26580b487e6b4'), - (x'419d6f34540ca453'), - (x'41678c29dcd6e9dc'), - (x'4132d687e3df217d'), - (x'40fe240c9fcb68c8'), - (x'40c81cd6e63c53d3'), - (x'40934a4584fd0fdc'), - (x'405edd3c07fb4c93'), - (x'4028b0fcd32f7076'), - (x'3ff3c0ca428c59f8'), - -- these cases come from the upstream's testsuite - -- LotsOfTrailingZeros) - (x'3e60000000000000'), - -- Regression - (x'c352bd2668e077c4'), - (x'434018601510c000'), - (x'43d055dc36f24000'), - (x'43e052961c6f8000'), - (x'3ff3c0ca2a5b1d5d'), - -- LooksLikePow5 - (x'4830f0cf064dd592'), - (x'4840f0cf064dd592'), - (x'4850f0cf064dd592'), - -- OutputLength - (x'3ff3333333333333'), - (x'3ff3ae147ae147ae'), - (x'3ff3be76c8b43958'), - (x'3ff3c083126e978d'), - (x'3ff3c0c1fc8f3238'), - (x'3ff3c0c9539b8887'), - (x'3ff3c0ca2a5b1d5d'), - (x'3ff3c0ca4283de1b'), - (x'3ff3c0ca43db770a'), - (x'3ff3c0ca428abd53'), - (x'3ff3c0ca428c1d2b'), - (x'3ff3c0ca428c51f2'), - (x'3ff3c0ca428c58fc'), - (x'3ff3c0ca428c59dd'), - (x'3ff3c0ca428c59f8'), - (x'3ff3c0ca428c59fb'), - -- 32-bit chunking - (x'40112e0be8047a7d'), - (x'40112e0be815a889'), - (x'40112e0be826d695'), - (x'40112e0be83804a1'), - (x'40112e0be84932ad'), - -- MinMaxShift - (x'0040000000000000'), - (x'007fffffffffffff'), - (x'0290000000000000'), - (x'029fffffffffffff'), - (x'4350000000000000'), - (x'435fffffffffffff'), - (x'1330000000000000'), - (x'133fffffffffffff'), - (x'3a6fa7161a4d6e0c'); ---Testcase 268: -select float8send(flt) as ibits, - flt, - flt::text::float8 as r_flt, - float8send(flt::text::float8) as obits, - float8send(flt::text::float8) = float8send(flt) as correct - from (select bits::bit(64)::bigint::xfloat8::float8 as flt - from testdata - offset 0) s; -ERROR: "1.79769313486232e+308" is out of range for type double precision -rollback; --- clean up, lest opr_sanity complain ---Testcase 269: -drop type xfloat8 cascade; -NOTICE: drop cascades to 6 other objects -DETAIL: drop cascades to function xfloat8in(cstring) -drop cascades to function xfloat8out(xfloat8) -drop cascades to cast from xfloat8 to double precision -drop cascades to cast from double precision to xfloat8 -drop cascades to cast from xfloat8 to bigint -drop cascades to cast from bigint to xfloat8 --- Clean up -DO $d$ -declare - l_rec record; -begin - for l_rec in (select foreign_table_schema, foreign_table_name - from information_schema.foreign_tables) loop - execute format('drop foreign table %I.%I cascade;', l_rec.foreign_table_schema, l_rec.foreign_table_name); - end loop; -end; -$d$; ---Testcase 270: -DROP SERVER sqlite_svr; ---Testcase 271: -DROP EXTENSION sqlite_fdw CASCADE; diff --git a/expected/10.18/aggregate.out b/expected/11.16/aggregate.out similarity index 100% rename from expected/10.18/aggregate.out rename to expected/11.16/aggregate.out diff --git a/expected/11.13/extra/aggregates.out b/expected/11.16/extra/aggregates.out similarity index 100% rename from expected/11.13/extra/aggregates.out rename to expected/11.16/extra/aggregates.out diff --git a/expected/10.18/extra/float4.out b/expected/11.16/extra/float4.out similarity index 100% rename from expected/10.18/extra/float4.out rename to expected/11.16/extra/float4.out diff --git a/expected/10.18/extra/float8.out b/expected/11.16/extra/float8.out similarity index 100% rename from expected/10.18/extra/float8.out rename to expected/11.16/extra/float8.out diff --git a/expected/10.18/extra/insert.out b/expected/11.16/extra/insert.out similarity index 100% rename from expected/10.18/extra/insert.out rename to expected/11.16/extra/insert.out diff --git a/expected/10.18/extra/int4.out b/expected/11.16/extra/int4.out similarity index 100% rename from expected/10.18/extra/int4.out rename to expected/11.16/extra/int4.out diff --git a/expected/11.13/extra/int8.out b/expected/11.16/extra/int8.out similarity index 100% rename from expected/11.13/extra/int8.out rename to expected/11.16/extra/int8.out diff --git a/expected/11.13/extra/join.out b/expected/11.16/extra/join.out similarity index 100% rename from expected/11.13/extra/join.out rename to expected/11.16/extra/join.out diff --git a/expected/10.18/extra/limit.out b/expected/11.16/extra/limit.out similarity index 100% rename from expected/10.18/extra/limit.out rename to expected/11.16/extra/limit.out diff --git a/expected/11.13/extra/numeric.out b/expected/11.16/extra/numeric.out similarity index 100% rename from expected/11.13/extra/numeric.out rename to expected/11.16/extra/numeric.out diff --git a/expected/10.18/extra/prepare.out b/expected/11.16/extra/prepare.out similarity index 100% rename from expected/10.18/extra/prepare.out rename to expected/11.16/extra/prepare.out diff --git a/expected/10.18/extra/select.out b/expected/11.16/extra/select.out similarity index 100% rename from expected/10.18/extra/select.out rename to expected/11.16/extra/select.out diff --git a/expected/10.18/extra/select_having.out b/expected/11.16/extra/select_having.out similarity index 100% rename from expected/10.18/extra/select_having.out rename to expected/11.16/extra/select_having.out diff --git a/expected/11.13/extra/sqlite_fdw_post.out b/expected/11.16/extra/sqlite_fdw_post.out similarity index 100% rename from expected/11.13/extra/sqlite_fdw_post.out rename to expected/11.16/extra/sqlite_fdw_post.out diff --git a/expected/10.18/extra/timestamp.out b/expected/11.16/extra/timestamp.out similarity index 100% rename from expected/10.18/extra/timestamp.out rename to expected/11.16/extra/timestamp.out diff --git a/expected/10.18/extra/update.out b/expected/11.16/extra/update.out similarity index 100% rename from expected/10.18/extra/update.out rename to expected/11.16/extra/update.out diff --git a/expected/11.13/selectfunc.out b/expected/11.16/selectfunc.out similarity index 65% rename from expected/11.13/selectfunc.out rename to expected/11.16/selectfunc.out index 0f8ce8a9..e992bc3e 100644 --- a/expected/11.13/selectfunc.out +++ b/expected/11.16/selectfunc.out @@ -446,6 +446,332 @@ SELECT round(abs(value2), 0) FROM s3; 200 (6 rows) +-- select mod (builtin function, explain) +--Testcase 34: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2058.24 rows=2048 width=20) + Output: value1, mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value1`, `value2`, `value4` FROM main."s3" +(3 rows) + +-- select mod (builtin function, result) +--Testcase 35: +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + value1 | mod | mod | mod +--------+-----+-----+----- + 0.1 | 0 | 0 | 1 + 0.2 | 0 | 0 | 1 + 0.3 | 0 | 0 | 1 + 1.1 | 0 | 0 | 1 + 2.2 | 0 | 0 | 1 + 3.3 | 0 | 0 | 1 +(6 rows) + +-- select mod (builtin function, not pushdown constraints, explain) +--Testcase 36: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + QUERY PLAN +----------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..13.06 rows=13 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + Filter: (to_hex(s3.value2) = '64'::text) + SQLite query: SELECT `value2`, `value4` FROM main."s3" +(4 rows) + +-- select mod (builtin function, not pushdown constraints, result) +--Testcase 37: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod (builtin function, pushdown constraints, explain) +--Testcase 38: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2559.74 rows=2547 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((`value2` <> 200)) +(3 rows) + +-- select mod (builtin function, pushdown constraints, result) +--Testcase 39: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 40: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + QUERY PLAN +------------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2559.74 rows=2547 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((mod(`value2`, 2) <> 1)) +(3 rows) + +-- select mod (builtin function, mod in constraints, result) +--Testcase 41: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(6 rows) + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 42: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + QUERY PLAN +--------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..857.26 rows=853 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((1 > `value1`)) +(3 rows) + +-- select mod (builtin function, mod in constraints, result) +--Testcase 43: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod as nest function with agg (pushdown, explain) +--Testcase 44: +EXPLAIN VERBOSE +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + QUERY PLAN +---------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=16) + Output: (sum(value3)), (mod(sum(value2), '2'::bigint)) + SQLite query: SELECT sum(`value3`), mod(sum(`value2`), 2) FROM main."s3" +(3 rows) + +-- select mod as nest function with agg (pushdown, result) +--Testcase 45: +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + sum | mod +------+----- + -7.2 | 0 +(1 row) + +-- select mod as nest with abs (pushdown, explain) +--Testcase 46: +EXPLAIN VERBOSE +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2303.44 rows=2275 width=16) + Output: value1, mod(abs(value2), 2), mod(abs((1 / value2)), 2) + SQLite query: SELECT `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mod as nest with abs (pushdown, result) +--Testcase 47: +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + value1 | mod | mod +--------+-----+----- + 0.1 | 0 | 0 + 0.2 | 0 | 0 + 0.3 | 0 | 0 + 1.1 | 0 | 0 + 2.2 | 0 | 0 + 3.3 | 0 | 0 +(6 rows) + +-- select mod with non pushdown func and explicit constant (explain) +--Testcase 48: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + QUERY PLAN +----------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2280.69 rows=2275 width=52) + Output: value1, mod(value2, 2), '3.14159265358979'::double precision, 4.1 + SQLite query: SELECT `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mod with non pushdown func and explicit constant (result) +--Testcase 49: +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + value1 | mod | pi | ?column? +--------+-----+------------------+---------- + 0.1 | 0 | 3.14159265358979 | 4.1 + 0.2 | 0 | 3.14159265358979 | 4.1 + 0.3 | 0 | 3.14159265358979 | 4.1 + 1.1 | 0 | 3.14159265358979 | 4.1 + 2.2 | 0 | 3.14159265358979 | 4.1 + 3.3 | 0 | 3.14159265358979 | 4.1 +(6 rows) + +-- select mod with order by (explain) +--Testcase 50: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + QUERY PLAN +--------------------------------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..10.05 rows=10 width=12) + Output: value1, mod((1 - value2), 2) + SQLite query: SELECT `value1`, `value2` FROM main."s3" ORDER BY mod((1 - `value2`), 2) ASC NULLS LAST +(3 rows) + +-- select mod with order by (result) +--Testcase 51: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with order by index (result) +--Testcase 52: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 2,1; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with order by index (result) +--Testcase 53: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 1,2; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by (explain) +--Testcase 54: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + QUERY PLAN +-------------------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=12) + Output: value1, (mod((1 - value2), 2)) + SQLite query: SELECT `value1`, mod((1 - `value2`), 2) FROM main."s3" GROUP BY 1, 2 +(3 rows) + +-- select mod with group by (result) +--Testcase 55: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index (result) +--Testcase 56: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 2,1; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index (result) +--Testcase 57: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by having (explain) +--Testcase 58: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=12) + Output: value1, (mod((1 - value2), 2)) + SQLite query: SELECT `value1`, mod((1 - `value2`), 2) FROM main."s3" GROUP BY 1, 2 HAVING ((avg(`value1`) > 0)) +(3 rows) + +-- select mod with group by having (result) +--Testcase 59: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index having (result) +--Testcase 60: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2 HAVING value1 > 1; + value1 | mod +--------+----- + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(3 rows) + +-- select mod and as +--Testcase 61: +SELECT value1, mod(value2, 2) as mod1 FROM s3; + value1 | mod1 +--------+------ + 0.1 | 0 + 0.2 | 0 + 0.3 | 0 + 1.1 | 0 + 2.2 | 0 + 3.3 | 0 +(6 rows) + --Testcase 29: DROP FOREIGN TABLE s3; --Testcase 30: diff --git a/expected/13.4/sqlite_fdw.out b/expected/11.16/sqlite_fdw.out similarity index 92% rename from expected/13.4/sqlite_fdw.out rename to expected/11.16/sqlite_fdw.out index 0e09767b..a9b8ea58 100644 --- a/expected/13.4/sqlite_fdw.out +++ b/expected/11.16/sqlite_fdw.out @@ -1473,14 +1473,14 @@ SELECT * FROM noprimary; SELECT * FROM public.sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20101 + 20200 (1 row) --Testcase 155: SELECT sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20101 + 20200 (1 row) -- issue #44 github @@ -1500,6 +1500,122 @@ 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 +-- Executable test case for pushdown CASE expressions (results) +--Testcase 224: +CREATE FOREIGN TABLE case_exp(c1 int OPTIONS (key 'true'), c3 text, c6 varchar(10)) SERVER sqlite_svr; +--Testcase 225: +INSERT INTO case_exp + SELECT id, + to_char(id, 'FM00000'), + id % 10 + FROM generate_series(1, 10) id; +--Testcase 226: +SELECT * FROM case_exp; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +-- CASE arg WHEN +--Testcase 227: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE ((`c1` > CASE mod(`c1`, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END)) +(3 rows) + +--Testcase 228: +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + c1 | c3 | c6 +----+-------+---- + 4 | 00004 | 4 + 8 | 00008 | 8 +(2 rows) + +-- these are shippable +--Testcase 229: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE (CASE `c6` WHEN 'foo' THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 230: +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +--Testcase 231: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE (CASE `c3` WHEN `c6` THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 232: +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +-- but this is not because of collation +--Testcase 233: +SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +--Testcase 234: +DELETE FROM case_exp; --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -1520,6 +1636,8 @@ DROP FOREIGN TABLE columntest; DROP FOREIGN TABLE noprimary; --Testcase 161: DROP FOREIGN TABLE fts_table; +--Testcase 235: +DROP FOREIGN TABLE case_exp; --Testcase 151: DROP SERVER sqlite_svr; --Testcase 152: diff --git a/expected/10.18/type.out b/expected/11.16/type.out similarity index 99% rename from expected/10.18/type.out rename to expected/11.16/type.out index d1c05b99..86d7b629 100644 --- a/expected/10.18/type.out +++ b/expected/11.16/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 39 other objects +NOTICE: drop cascades to 40 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -322,6 +322,7 @@ drop cascades to foreign table noprimary drop cascades to foreign table limittest drop cascades to foreign table grem1_1 drop cascades to foreign table grem1_2 +drop cascades to foreign table case_exp drop cascades to foreign table "type_STRING" drop cascades to foreign table "type_BOOLEAN" drop cascades to foreign table "type_BYTE" diff --git a/expected/11.13/aggregate.out b/expected/12.11/aggregate.out similarity index 100% rename from expected/11.13/aggregate.out rename to expected/12.11/aggregate.out diff --git a/expected/12.8/extra/aggregates.out b/expected/12.11/extra/aggregates.out similarity index 100% rename from expected/12.8/extra/aggregates.out rename to expected/12.11/extra/aggregates.out diff --git a/expected/12.8/extra/float4.out b/expected/12.11/extra/float4.out similarity index 100% rename from expected/12.8/extra/float4.out rename to expected/12.11/extra/float4.out diff --git a/expected/12.8/extra/float8.out b/expected/12.11/extra/float8.out similarity index 100% rename from expected/12.8/extra/float8.out rename to expected/12.11/extra/float8.out diff --git a/expected/11.13/extra/insert.out b/expected/12.11/extra/insert.out similarity index 100% rename from expected/11.13/extra/insert.out rename to expected/12.11/extra/insert.out diff --git a/expected/12.8/extra/int4.out b/expected/12.11/extra/int4.out similarity index 100% rename from expected/12.8/extra/int4.out rename to expected/12.11/extra/int4.out diff --git a/expected/12.8/extra/int8.out b/expected/12.11/extra/int8.out similarity index 100% rename from expected/12.8/extra/int8.out rename to expected/12.11/extra/int8.out diff --git a/expected/12.8/extra/join.out b/expected/12.11/extra/join.out similarity index 100% rename from expected/12.8/extra/join.out rename to expected/12.11/extra/join.out diff --git a/expected/11.13/extra/limit.out b/expected/12.11/extra/limit.out similarity index 100% rename from expected/11.13/extra/limit.out rename to expected/12.11/extra/limit.out diff --git a/expected/12.8/extra/numeric.out b/expected/12.11/extra/numeric.out similarity index 100% rename from expected/12.8/extra/numeric.out rename to expected/12.11/extra/numeric.out diff --git a/expected/11.13/extra/prepare.out b/expected/12.11/extra/prepare.out similarity index 100% rename from expected/11.13/extra/prepare.out rename to expected/12.11/extra/prepare.out diff --git a/expected/12.8/extra/select.out b/expected/12.11/extra/select.out similarity index 100% rename from expected/12.8/extra/select.out rename to expected/12.11/extra/select.out diff --git a/expected/11.13/extra/select_having.out b/expected/12.11/extra/select_having.out similarity index 100% rename from expected/11.13/extra/select_having.out rename to expected/12.11/extra/select_having.out diff --git a/expected/12.8/extra/sqlite_fdw_post.out b/expected/12.11/extra/sqlite_fdw_post.out similarity index 100% rename from expected/12.8/extra/sqlite_fdw_post.out rename to expected/12.11/extra/sqlite_fdw_post.out diff --git a/expected/11.13/extra/timestamp.out b/expected/12.11/extra/timestamp.out similarity index 100% rename from expected/11.13/extra/timestamp.out rename to expected/12.11/extra/timestamp.out diff --git a/expected/11.13/extra/update.out b/expected/12.11/extra/update.out similarity index 100% rename from expected/11.13/extra/update.out rename to expected/12.11/extra/update.out diff --git a/expected/12.8/selectfunc.out b/expected/12.11/selectfunc.out similarity index 66% rename from expected/12.8/selectfunc.out rename to expected/12.11/selectfunc.out index f1d0eeaf..0ff93436 100644 --- a/expected/12.8/selectfunc.out +++ b/expected/12.11/selectfunc.out @@ -446,6 +446,332 @@ SELECT round(abs(value2), 0) FROM s3; 200 (6 rows) +-- select mod (builtin function, explain) +--Testcase 34: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2058.24 rows=2048 width=20) + Output: value1, mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value1`, `value2`, `value4` FROM main."s3" +(3 rows) + +-- select mod (builtin function, result) +--Testcase 35: +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + value1 | mod | mod | mod +--------+-----+-----+----- + 0.1 | 0 | 0 | 1 + 0.2 | 0 | 0 | 1 + 0.3 | 0 | 0 | 1 + 1.1 | 0 | 0 | 1 + 2.2 | 0 | 0 | 1 + 3.3 | 0 | 0 | 1 +(6 rows) + +-- select mod (builtin function, not pushdown constraints, explain) +--Testcase 36: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + QUERY PLAN +----------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..13.06 rows=13 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + Filter: (to_hex(s3.value2) = '64'::text) + SQLite query: SELECT `value2`, `value4` FROM main."s3" +(4 rows) + +-- select mod (builtin function, not pushdown constraints, result) +--Testcase 37: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod (builtin function, pushdown constraints, explain) +--Testcase 38: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2559.74 rows=2547 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((`value2` <> 200)) +(3 rows) + +-- select mod (builtin function, pushdown constraints, result) +--Testcase 39: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 40: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + QUERY PLAN +------------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2559.74 rows=2547 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((mod(`value2`, 2) <> 1)) +(3 rows) + +-- select mod (builtin function, mod in constraints, result) +--Testcase 41: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(6 rows) + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 42: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + QUERY PLAN +--------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..857.26 rows=853 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((1 > `value1`)) +(3 rows) + +-- select mod (builtin function, mod in constraints, result) +--Testcase 43: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod as nest function with agg (pushdown, explain) +--Testcase 44: +EXPLAIN VERBOSE +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + QUERY PLAN +---------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=16) + Output: (sum(value3)), (mod(sum(value2), '2'::bigint)) + SQLite query: SELECT sum(`value3`), mod(sum(`value2`), 2) FROM main."s3" +(3 rows) + +-- select mod as nest function with agg (pushdown, result) +--Testcase 45: +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + sum | mod +------+----- + -7.2 | 0 +(1 row) + +-- select mod as nest with abs (pushdown, explain) +--Testcase 46: +EXPLAIN VERBOSE +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2303.44 rows=2275 width=16) + Output: value1, mod(abs(value2), 2), mod(abs((1 / value2)), 2) + SQLite query: SELECT `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mod as nest with abs (pushdown, result) +--Testcase 47: +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + value1 | mod | mod +--------+-----+----- + 0.1 | 0 | 0 + 0.2 | 0 | 0 + 0.3 | 0 | 0 + 1.1 | 0 | 0 + 2.2 | 0 | 0 + 3.3 | 0 | 0 +(6 rows) + +-- select mod with non pushdown func and explicit constant (explain) +--Testcase 48: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + QUERY PLAN +------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2280.69 rows=2275 width=52) + Output: value1, mod(value2, 2), '3.141592653589793'::double precision, 4.1 + SQLite query: SELECT `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mod with non pushdown func and explicit constant (result) +--Testcase 49: +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + value1 | mod | pi | ?column? +--------+-----+-------------------+---------- + 0.1 | 0 | 3.141592653589793 | 4.1 + 0.2 | 0 | 3.141592653589793 | 4.1 + 0.3 | 0 | 3.141592653589793 | 4.1 + 1.1 | 0 | 3.141592653589793 | 4.1 + 2.2 | 0 | 3.141592653589793 | 4.1 + 3.3 | 0 | 3.141592653589793 | 4.1 +(6 rows) + +-- select mod with order by (explain) +--Testcase 50: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + QUERY PLAN +--------------------------------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..10.05 rows=10 width=12) + Output: value1, mod((1 - value2), 2) + SQLite query: SELECT `value1`, `value2` FROM main."s3" ORDER BY mod((1 - `value2`), 2) ASC NULLS LAST +(3 rows) + +-- select mod with order by (result) +--Testcase 51: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with order by index (result) +--Testcase 52: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 2,1; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with order by index (result) +--Testcase 53: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 1,2; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by (explain) +--Testcase 54: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + QUERY PLAN +-------------------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=12) + Output: value1, (mod((1 - value2), 2)) + SQLite query: SELECT `value1`, mod((1 - `value2`), 2) FROM main."s3" GROUP BY 1, 2 +(3 rows) + +-- select mod with group by (result) +--Testcase 55: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index (result) +--Testcase 56: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 2,1; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index (result) +--Testcase 57: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by having (explain) +--Testcase 58: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=12) + Output: value1, (mod((1 - value2), 2)) + SQLite query: SELECT `value1`, mod((1 - `value2`), 2) FROM main."s3" GROUP BY 1, 2 HAVING ((avg(`value1`) > 0)) +(3 rows) + +-- select mod with group by having (result) +--Testcase 59: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index having (result) +--Testcase 60: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2 HAVING value1 > 1; + value1 | mod +--------+----- + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(3 rows) + +-- select mod and as +--Testcase 61: +SELECT value1, mod(value2, 2) as mod1 FROM s3; + value1 | mod1 +--------+------ + 0.1 | 0 + 0.2 | 0 + 0.3 | 0 + 1.1 | 0 + 2.2 | 0 + 3.3 | 0 +(6 rows) + --Testcase 29: DROP FOREIGN TABLE s3; --Testcase 30: diff --git a/expected/11.13/sqlite_fdw.out b/expected/12.11/sqlite_fdw.out similarity index 92% rename from expected/11.13/sqlite_fdw.out rename to expected/12.11/sqlite_fdw.out index 0e09767b..a9b8ea58 100644 --- a/expected/11.13/sqlite_fdw.out +++ b/expected/12.11/sqlite_fdw.out @@ -1473,14 +1473,14 @@ SELECT * FROM noprimary; SELECT * FROM public.sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20101 + 20200 (1 row) --Testcase 155: SELECT sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20101 + 20200 (1 row) -- issue #44 github @@ -1500,6 +1500,122 @@ 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 +-- Executable test case for pushdown CASE expressions (results) +--Testcase 224: +CREATE FOREIGN TABLE case_exp(c1 int OPTIONS (key 'true'), c3 text, c6 varchar(10)) SERVER sqlite_svr; +--Testcase 225: +INSERT INTO case_exp + SELECT id, + to_char(id, 'FM00000'), + id % 10 + FROM generate_series(1, 10) id; +--Testcase 226: +SELECT * FROM case_exp; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +-- CASE arg WHEN +--Testcase 227: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE ((`c1` > CASE mod(`c1`, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END)) +(3 rows) + +--Testcase 228: +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + c1 | c3 | c6 +----+-------+---- + 4 | 00004 | 4 + 8 | 00008 | 8 +(2 rows) + +-- these are shippable +--Testcase 229: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE (CASE `c6` WHEN 'foo' THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 230: +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +--Testcase 231: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE (CASE `c3` WHEN `c6` THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 232: +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +-- but this is not because of collation +--Testcase 233: +SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +--Testcase 234: +DELETE FROM case_exp; --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -1520,6 +1636,8 @@ DROP FOREIGN TABLE columntest; DROP FOREIGN TABLE noprimary; --Testcase 161: DROP FOREIGN TABLE fts_table; +--Testcase 235: +DROP FOREIGN TABLE case_exp; --Testcase 151: DROP SERVER sqlite_svr; --Testcase 152: diff --git a/expected/11.13/type.out b/expected/12.11/type.out similarity index 99% rename from expected/11.13/type.out rename to expected/12.11/type.out index d1c05b99..86d7b629 100644 --- a/expected/11.13/type.out +++ b/expected/12.11/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 39 other objects +NOTICE: drop cascades to 40 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -322,6 +322,7 @@ drop cascades to foreign table noprimary drop cascades to foreign table limittest drop cascades to foreign table grem1_1 drop cascades to foreign table grem1_2 +drop cascades to foreign table case_exp drop cascades to foreign table "type_STRING" drop cascades to foreign table "type_BOOLEAN" drop cascades to foreign table "type_BYTE" diff --git a/expected/13.4/aggregate.out b/expected/13.7/aggregate.out similarity index 100% rename from expected/13.4/aggregate.out rename to expected/13.7/aggregate.out diff --git a/expected/13.4/extra/aggregates.out b/expected/13.7/extra/aggregates.out similarity index 100% rename from expected/13.4/extra/aggregates.out rename to expected/13.7/extra/aggregates.out diff --git a/expected/13.4/extra/float4.out b/expected/13.7/extra/float4.out similarity index 100% rename from expected/13.4/extra/float4.out rename to expected/13.7/extra/float4.out diff --git a/expected/13.4/extra/float8.out b/expected/13.7/extra/float8.out similarity index 100% rename from expected/13.4/extra/float8.out rename to expected/13.7/extra/float8.out diff --git a/expected/12.8/extra/insert.out b/expected/13.7/extra/insert.out similarity index 100% rename from expected/12.8/extra/insert.out rename to expected/13.7/extra/insert.out diff --git a/expected/13.4/extra/int4.out b/expected/13.7/extra/int4.out similarity index 100% rename from expected/13.4/extra/int4.out rename to expected/13.7/extra/int4.out diff --git a/expected/13.4/extra/int8.out b/expected/13.7/extra/int8.out similarity index 100% rename from expected/13.4/extra/int8.out rename to expected/13.7/extra/int8.out diff --git a/expected/13.4/extra/join.out b/expected/13.7/extra/join.out similarity index 100% rename from expected/13.4/extra/join.out rename to expected/13.7/extra/join.out diff --git a/expected/13.4/extra/limit.out b/expected/13.7/extra/limit.out similarity index 100% rename from expected/13.4/extra/limit.out rename to expected/13.7/extra/limit.out diff --git a/expected/13.4/extra/numeric.out b/expected/13.7/extra/numeric.out similarity index 100% rename from expected/13.4/extra/numeric.out rename to expected/13.7/extra/numeric.out diff --git a/expected/13.4/extra/prepare.out b/expected/13.7/extra/prepare.out similarity index 100% rename from expected/13.4/extra/prepare.out rename to expected/13.7/extra/prepare.out diff --git a/expected/13.4/extra/select.out b/expected/13.7/extra/select.out similarity index 100% rename from expected/13.4/extra/select.out rename to expected/13.7/extra/select.out diff --git a/expected/12.8/extra/select_having.out b/expected/13.7/extra/select_having.out similarity index 100% rename from expected/12.8/extra/select_having.out rename to expected/13.7/extra/select_having.out diff --git a/expected/13.4/extra/sqlite_fdw_post.out b/expected/13.7/extra/sqlite_fdw_post.out similarity index 100% rename from expected/13.4/extra/sqlite_fdw_post.out rename to expected/13.7/extra/sqlite_fdw_post.out diff --git a/expected/12.8/extra/timestamp.out b/expected/13.7/extra/timestamp.out similarity index 100% rename from expected/12.8/extra/timestamp.out rename to expected/13.7/extra/timestamp.out diff --git a/expected/12.8/extra/update.out b/expected/13.7/extra/update.out similarity index 100% rename from expected/12.8/extra/update.out rename to expected/13.7/extra/update.out diff --git a/expected/13.4/selectfunc.out b/expected/13.7/selectfunc.out similarity index 66% rename from expected/13.4/selectfunc.out rename to expected/13.7/selectfunc.out index f1d0eeaf..0ff93436 100644 --- a/expected/13.4/selectfunc.out +++ b/expected/13.7/selectfunc.out @@ -446,6 +446,332 @@ SELECT round(abs(value2), 0) FROM s3; 200 (6 rows) +-- select mod (builtin function, explain) +--Testcase 34: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2058.24 rows=2048 width=20) + Output: value1, mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value1`, `value2`, `value4` FROM main."s3" +(3 rows) + +-- select mod (builtin function, result) +--Testcase 35: +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + value1 | mod | mod | mod +--------+-----+-----+----- + 0.1 | 0 | 0 | 1 + 0.2 | 0 | 0 | 1 + 0.3 | 0 | 0 | 1 + 1.1 | 0 | 0 | 1 + 2.2 | 0 | 0 | 1 + 3.3 | 0 | 0 | 1 +(6 rows) + +-- select mod (builtin function, not pushdown constraints, explain) +--Testcase 36: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + QUERY PLAN +----------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..13.06 rows=13 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + Filter: (to_hex(s3.value2) = '64'::text) + SQLite query: SELECT `value2`, `value4` FROM main."s3" +(4 rows) + +-- select mod (builtin function, not pushdown constraints, result) +--Testcase 37: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod (builtin function, pushdown constraints, explain) +--Testcase 38: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2559.74 rows=2547 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((`value2` <> 200)) +(3 rows) + +-- select mod (builtin function, pushdown constraints, result) +--Testcase 39: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 40: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + QUERY PLAN +------------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2559.74 rows=2547 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((mod(`value2`, 2) <> 1)) +(3 rows) + +-- select mod (builtin function, mod in constraints, result) +--Testcase 41: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(6 rows) + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 42: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + QUERY PLAN +--------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..857.26 rows=853 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((1 > `value1`)) +(3 rows) + +-- select mod (builtin function, mod in constraints, result) +--Testcase 43: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod as nest function with agg (pushdown, explain) +--Testcase 44: +EXPLAIN VERBOSE +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + QUERY PLAN +---------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=16) + Output: (sum(value3)), (mod(sum(value2), '2'::bigint)) + SQLite query: SELECT sum(`value3`), mod(sum(`value2`), 2) FROM main."s3" +(3 rows) + +-- select mod as nest function with agg (pushdown, result) +--Testcase 45: +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + sum | mod +------+----- + -7.2 | 0 +(1 row) + +-- select mod as nest with abs (pushdown, explain) +--Testcase 46: +EXPLAIN VERBOSE +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2303.44 rows=2275 width=16) + Output: value1, mod(abs(value2), 2), mod(abs((1 / value2)), 2) + SQLite query: SELECT `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mod as nest with abs (pushdown, result) +--Testcase 47: +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + value1 | mod | mod +--------+-----+----- + 0.1 | 0 | 0 + 0.2 | 0 | 0 + 0.3 | 0 | 0 + 1.1 | 0 | 0 + 2.2 | 0 | 0 + 3.3 | 0 | 0 +(6 rows) + +-- select mod with non pushdown func and explicit constant (explain) +--Testcase 48: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + QUERY PLAN +------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2280.69 rows=2275 width=52) + Output: value1, mod(value2, 2), '3.141592653589793'::double precision, 4.1 + SQLite query: SELECT `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mod with non pushdown func and explicit constant (result) +--Testcase 49: +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + value1 | mod | pi | ?column? +--------+-----+-------------------+---------- + 0.1 | 0 | 3.141592653589793 | 4.1 + 0.2 | 0 | 3.141592653589793 | 4.1 + 0.3 | 0 | 3.141592653589793 | 4.1 + 1.1 | 0 | 3.141592653589793 | 4.1 + 2.2 | 0 | 3.141592653589793 | 4.1 + 3.3 | 0 | 3.141592653589793 | 4.1 +(6 rows) + +-- select mod with order by (explain) +--Testcase 50: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + QUERY PLAN +--------------------------------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..10.05 rows=10 width=12) + Output: value1, mod((1 - value2), 2) + SQLite query: SELECT `value1`, `value2` FROM main."s3" ORDER BY mod((1 - `value2`), 2) ASC NULLS LAST +(3 rows) + +-- select mod with order by (result) +--Testcase 51: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with order by index (result) +--Testcase 52: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 2,1; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with order by index (result) +--Testcase 53: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 1,2; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by (explain) +--Testcase 54: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + QUERY PLAN +-------------------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=12) + Output: value1, (mod((1 - value2), 2)) + SQLite query: SELECT `value1`, mod((1 - `value2`), 2) FROM main."s3" GROUP BY 1, 2 +(3 rows) + +-- select mod with group by (result) +--Testcase 55: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index (result) +--Testcase 56: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 2,1; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index (result) +--Testcase 57: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by having (explain) +--Testcase 58: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=12) + Output: value1, (mod((1 - value2), 2)) + SQLite query: SELECT `value1`, mod((1 - `value2`), 2) FROM main."s3" GROUP BY 1, 2 HAVING ((avg(`value1`) > 0)) +(3 rows) + +-- select mod with group by having (result) +--Testcase 59: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index having (result) +--Testcase 60: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2 HAVING value1 > 1; + value1 | mod +--------+----- + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(3 rows) + +-- select mod and as +--Testcase 61: +SELECT value1, mod(value2, 2) as mod1 FROM s3; + value1 | mod1 +--------+------ + 0.1 | 0 + 0.2 | 0 + 0.3 | 0 + 1.1 | 0 + 2.2 | 0 + 3.3 | 0 +(6 rows) + --Testcase 29: DROP FOREIGN TABLE s3; --Testcase 30: diff --git a/expected/12.8/sqlite_fdw.out b/expected/13.7/sqlite_fdw.out similarity index 92% rename from expected/12.8/sqlite_fdw.out rename to expected/13.7/sqlite_fdw.out index 0e09767b..a9b8ea58 100644 --- a/expected/12.8/sqlite_fdw.out +++ b/expected/13.7/sqlite_fdw.out @@ -1473,14 +1473,14 @@ SELECT * FROM noprimary; SELECT * FROM public.sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20101 + 20200 (1 row) --Testcase 155: SELECT sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20101 + 20200 (1 row) -- issue #44 github @@ -1500,6 +1500,122 @@ 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 +-- Executable test case for pushdown CASE expressions (results) +--Testcase 224: +CREATE FOREIGN TABLE case_exp(c1 int OPTIONS (key 'true'), c3 text, c6 varchar(10)) SERVER sqlite_svr; +--Testcase 225: +INSERT INTO case_exp + SELECT id, + to_char(id, 'FM00000'), + id % 10 + FROM generate_series(1, 10) id; +--Testcase 226: +SELECT * FROM case_exp; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +-- CASE arg WHEN +--Testcase 227: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE ((`c1` > CASE mod(`c1`, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END)) +(3 rows) + +--Testcase 228: +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + c1 | c3 | c6 +----+-------+---- + 4 | 00004 | 4 + 8 | 00008 | 8 +(2 rows) + +-- these are shippable +--Testcase 229: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE (CASE `c6` WHEN 'foo' THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 230: +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +--Testcase 231: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE (CASE `c3` WHEN `c6` THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 232: +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +-- but this is not because of collation +--Testcase 233: +SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +--Testcase 234: +DELETE FROM case_exp; --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -1520,6 +1636,8 @@ DROP FOREIGN TABLE columntest; DROP FOREIGN TABLE noprimary; --Testcase 161: DROP FOREIGN TABLE fts_table; +--Testcase 235: +DROP FOREIGN TABLE case_exp; --Testcase 151: DROP SERVER sqlite_svr; --Testcase 152: diff --git a/expected/13.4/type.out b/expected/13.7/type.out similarity index 99% rename from expected/13.4/type.out rename to expected/13.7/type.out index d1c05b99..86d7b629 100644 --- a/expected/13.4/type.out +++ b/expected/13.7/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 39 other objects +NOTICE: drop cascades to 40 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -322,6 +322,7 @@ drop cascades to foreign table noprimary drop cascades to foreign table limittest drop cascades to foreign table grem1_1 drop cascades to foreign table grem1_2 +drop cascades to foreign table case_exp drop cascades to foreign table "type_STRING" drop cascades to foreign table "type_BOOLEAN" drop cascades to foreign table "type_BYTE" diff --git a/expected/14.0/type.out b/expected/14.0/type.out deleted file mode 100644 index d1c05b99..00000000 --- a/expected/14.0/type.out +++ /dev/null @@ -1,351 +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 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/14.0/aggregate.out b/expected/14.4/aggregate.out similarity index 100% rename from expected/14.0/aggregate.out rename to expected/14.4/aggregate.out diff --git a/expected/14.0/extra/aggregates.out b/expected/14.4/extra/aggregates.out similarity index 100% rename from expected/14.0/extra/aggregates.out rename to expected/14.4/extra/aggregates.out diff --git a/expected/14.0/extra/float4.out b/expected/14.4/extra/float4.out similarity index 100% rename from expected/14.0/extra/float4.out rename to expected/14.4/extra/float4.out diff --git a/expected/14.0/extra/float8.out b/expected/14.4/extra/float8.out similarity index 100% rename from expected/14.0/extra/float8.out rename to expected/14.4/extra/float8.out diff --git a/expected/14.0/extra/insert.out b/expected/14.4/extra/insert.out similarity index 100% rename from expected/14.0/extra/insert.out rename to expected/14.4/extra/insert.out diff --git a/expected/14.0/extra/int4.out b/expected/14.4/extra/int4.out similarity index 100% rename from expected/14.0/extra/int4.out rename to expected/14.4/extra/int4.out diff --git a/expected/14.0/extra/int8.out b/expected/14.4/extra/int8.out similarity index 100% rename from expected/14.0/extra/int8.out rename to expected/14.4/extra/int8.out diff --git a/expected/14.0/extra/join.out b/expected/14.4/extra/join.out similarity index 99% rename from expected/14.0/extra/join.out rename to expected/14.4/extra/join.out index 455f87b8..8a20dd20 100644 --- a/expected/14.0/extra/join.out +++ b/expected/14.4/extra/join.out @@ -4632,10 +4632,11 @@ where t1.f1 = ss2.f1; -> Memoize Output: ((i8.q1)), (t2.f1) Cache Key: (i8.q1), t2.f1 + Cache Mode: binary -> Foreign Scan on public.text_tbl t3 Output: (i8.q1), t2.f1 SQLite query: SELECT NULL FROM main."text_tbl" LIMIT 1 -(17 rows) +(18 rows) --Testcase 222: select * from diff --git a/expected/14.0/extra/limit.out b/expected/14.4/extra/limit.out similarity index 100% rename from expected/14.0/extra/limit.out rename to expected/14.4/extra/limit.out diff --git a/expected/14.0/extra/numeric.out b/expected/14.4/extra/numeric.out similarity index 100% rename from expected/14.0/extra/numeric.out rename to expected/14.4/extra/numeric.out diff --git a/expected/14.0/extra/prepare.out b/expected/14.4/extra/prepare.out similarity index 100% rename from expected/14.0/extra/prepare.out rename to expected/14.4/extra/prepare.out diff --git a/expected/14.0/extra/select.out b/expected/14.4/extra/select.out similarity index 100% rename from expected/14.0/extra/select.out rename to expected/14.4/extra/select.out diff --git a/expected/13.4/extra/select_having.out b/expected/14.4/extra/select_having.out similarity index 100% rename from expected/13.4/extra/select_having.out rename to expected/14.4/extra/select_having.out diff --git a/expected/14.0/extra/sqlite_fdw_post.out b/expected/14.4/extra/sqlite_fdw_post.out similarity index 100% rename from expected/14.0/extra/sqlite_fdw_post.out rename to expected/14.4/extra/sqlite_fdw_post.out diff --git a/expected/13.4/extra/timestamp.out b/expected/14.4/extra/timestamp.out similarity index 100% rename from expected/13.4/extra/timestamp.out rename to expected/14.4/extra/timestamp.out diff --git a/expected/14.0/extra/update.out b/expected/14.4/extra/update.out similarity index 100% rename from expected/14.0/extra/update.out rename to expected/14.4/extra/update.out diff --git a/expected/14.0/selectfunc.out b/expected/14.4/selectfunc.out similarity index 66% rename from expected/14.0/selectfunc.out rename to expected/14.4/selectfunc.out index f1d0eeaf..0ff93436 100644 --- a/expected/14.0/selectfunc.out +++ b/expected/14.4/selectfunc.out @@ -446,6 +446,332 @@ SELECT round(abs(value2), 0) FROM s3; 200 (6 rows) +-- select mod (builtin function, explain) +--Testcase 34: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2058.24 rows=2048 width=20) + Output: value1, mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value1`, `value2`, `value4` FROM main."s3" +(3 rows) + +-- select mod (builtin function, result) +--Testcase 35: +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + value1 | mod | mod | mod +--------+-----+-----+----- + 0.1 | 0 | 0 | 1 + 0.2 | 0 | 0 | 1 + 0.3 | 0 | 0 | 1 + 1.1 | 0 | 0 | 1 + 2.2 | 0 | 0 | 1 + 3.3 | 0 | 0 | 1 +(6 rows) + +-- select mod (builtin function, not pushdown constraints, explain) +--Testcase 36: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + QUERY PLAN +----------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..13.06 rows=13 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + Filter: (to_hex(s3.value2) = '64'::text) + SQLite query: SELECT `value2`, `value4` FROM main."s3" +(4 rows) + +-- select mod (builtin function, not pushdown constraints, result) +--Testcase 37: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod (builtin function, pushdown constraints, explain) +--Testcase 38: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2559.74 rows=2547 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((`value2` <> 200)) +(3 rows) + +-- select mod (builtin function, pushdown constraints, result) +--Testcase 39: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 40: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + QUERY PLAN +------------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2559.74 rows=2547 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((mod(`value2`, 2) <> 1)) +(3 rows) + +-- select mod (builtin function, mod in constraints, result) +--Testcase 41: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(6 rows) + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 42: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + QUERY PLAN +--------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..857.26 rows=853 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((1 > `value1`)) +(3 rows) + +-- select mod (builtin function, mod in constraints, result) +--Testcase 43: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod as nest function with agg (pushdown, explain) +--Testcase 44: +EXPLAIN VERBOSE +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + QUERY PLAN +---------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=16) + Output: (sum(value3)), (mod(sum(value2), '2'::bigint)) + SQLite query: SELECT sum(`value3`), mod(sum(`value2`), 2) FROM main."s3" +(3 rows) + +-- select mod as nest function with agg (pushdown, result) +--Testcase 45: +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + sum | mod +------+----- + -7.2 | 0 +(1 row) + +-- select mod as nest with abs (pushdown, explain) +--Testcase 46: +EXPLAIN VERBOSE +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2303.44 rows=2275 width=16) + Output: value1, mod(abs(value2), 2), mod(abs((1 / value2)), 2) + SQLite query: SELECT `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mod as nest with abs (pushdown, result) +--Testcase 47: +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + value1 | mod | mod +--------+-----+----- + 0.1 | 0 | 0 + 0.2 | 0 | 0 + 0.3 | 0 | 0 + 1.1 | 0 | 0 + 2.2 | 0 | 0 + 3.3 | 0 | 0 +(6 rows) + +-- select mod with non pushdown func and explicit constant (explain) +--Testcase 48: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + QUERY PLAN +------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2280.69 rows=2275 width=52) + Output: value1, mod(value2, 2), '3.141592653589793'::double precision, 4.1 + SQLite query: SELECT `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mod with non pushdown func and explicit constant (result) +--Testcase 49: +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + value1 | mod | pi | ?column? +--------+-----+-------------------+---------- + 0.1 | 0 | 3.141592653589793 | 4.1 + 0.2 | 0 | 3.141592653589793 | 4.1 + 0.3 | 0 | 3.141592653589793 | 4.1 + 1.1 | 0 | 3.141592653589793 | 4.1 + 2.2 | 0 | 3.141592653589793 | 4.1 + 3.3 | 0 | 3.141592653589793 | 4.1 +(6 rows) + +-- select mod with order by (explain) +--Testcase 50: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + QUERY PLAN +--------------------------------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..10.05 rows=10 width=12) + Output: value1, mod((1 - value2), 2) + SQLite query: SELECT `value1`, `value2` FROM main."s3" ORDER BY mod((1 - `value2`), 2) ASC NULLS LAST +(3 rows) + +-- select mod with order by (result) +--Testcase 51: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with order by index (result) +--Testcase 52: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 2,1; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with order by index (result) +--Testcase 53: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 1,2; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by (explain) +--Testcase 54: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + QUERY PLAN +-------------------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=12) + Output: value1, (mod((1 - value2), 2)) + SQLite query: SELECT `value1`, mod((1 - `value2`), 2) FROM main."s3" GROUP BY 1, 2 +(3 rows) + +-- select mod with group by (result) +--Testcase 55: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index (result) +--Testcase 56: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 2,1; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index (result) +--Testcase 57: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by having (explain) +--Testcase 58: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=12) + Output: value1, (mod((1 - value2), 2)) + SQLite query: SELECT `value1`, mod((1 - `value2`), 2) FROM main."s3" GROUP BY 1, 2 HAVING ((avg(`value1`) > 0)) +(3 rows) + +-- select mod with group by having (result) +--Testcase 59: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index having (result) +--Testcase 60: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2 HAVING value1 > 1; + value1 | mod +--------+----- + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(3 rows) + +-- select mod and as +--Testcase 61: +SELECT value1, mod(value2, 2) as mod1 FROM s3; + value1 | mod1 +--------+------ + 0.1 | 0 + 0.2 | 0 + 0.3 | 0 + 1.1 | 0 + 2.2 | 0 + 3.3 | 0 +(6 rows) + --Testcase 29: DROP FOREIGN TABLE s3; --Testcase 30: diff --git a/expected/14.0/sqlite_fdw.out b/expected/14.4/sqlite_fdw.out similarity index 92% rename from expected/14.0/sqlite_fdw.out rename to expected/14.4/sqlite_fdw.out index dfb0e0d3..e4b46009 100644 --- a/expected/14.0/sqlite_fdw.out +++ b/expected/14.4/sqlite_fdw.out @@ -1455,14 +1455,14 @@ SELECT * FROM noprimary; SELECT * FROM public.sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20101 + 20200 (1 row) --Testcase 155: SELECT sqlite_fdw_version(); sqlite_fdw_version -------------------- - 20101 + 20200 (1 row) -- issue #44 github @@ -1512,6 +1512,122 @@ SELECT * FROM grem1_2; | | | (1 row) +-- Executable test case for pushdown CASE expressions (results) +--Testcase 224: +CREATE FOREIGN TABLE case_exp(c1 int OPTIONS (key 'true'), c3 text, c6 varchar(10)) SERVER sqlite_svr; +--Testcase 225: +INSERT INTO case_exp + SELECT id, + to_char(id, 'FM00000'), + id % 10 + FROM generate_series(1, 10) id; +--Testcase 226: +SELECT * FROM case_exp; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +-- CASE arg WHEN +--Testcase 227: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE ((`c1` > CASE mod(`c1`, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END)) +(3 rows) + +--Testcase 228: +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + c1 | c3 | c6 +----+-------+---- + 4 | 00004 | 4 + 8 | 00008 | 8 +(2 rows) + +-- these are shippable +--Testcase 229: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE (CASE `c6` WHEN 'foo' THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 230: +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +--Testcase 231: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE (CASE `c3` WHEN `c6` THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 232: +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +-- but this is not because of collation +--Testcase 233: +SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +--Testcase 234: +DELETE FROM case_exp; --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -1536,6 +1652,8 @@ DROP FOREIGN TABLE fts_table; DROP FOREIGN TABLE grem1_1; --Testcase 223: DROP FOREIGN TABLE grem1_2; +--Testcase 235: +DROP FOREIGN TABLE case_exp; --Testcase 151: DROP SERVER sqlite_svr; --Testcase 152: diff --git a/expected/12.8/type.out b/expected/14.4/type.out similarity index 99% rename from expected/12.8/type.out rename to expected/14.4/type.out index d1c05b99..86d7b629 100644 --- a/expected/12.8/type.out +++ b/expected/14.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 39 other objects +NOTICE: drop cascades to 40 other objects DETAIL: drop cascades to server sqlite_svr drop cascades to foreign table department drop cascades to foreign table employee @@ -322,6 +322,7 @@ drop cascades to foreign table noprimary drop cascades to foreign table limittest drop cascades to foreign table grem1_1 drop cascades to foreign table grem1_2 +drop cascades to foreign table case_exp drop cascades to foreign table "type_STRING" drop cascades to foreign table "type_BOOLEAN" drop cascades to foreign table "type_BYTE" diff --git a/expected/12.8/aggregate.out b/expected/15beta2/aggregate.out similarity index 79% rename from expected/12.8/aggregate.out rename to expected/15beta2/aggregate.out index 735edc82..d3f193e0 100644 --- a/expected/12.8/aggregate.out +++ b/expected/15beta2/aggregate.out @@ -107,36 +107,66 @@ INSERT INTO limittest(x, y) VALUES (1, 'z'), (2, 'z'), (3, 'z'), (4, 'z'); --Testcase 20: EXPLAIN VERBOSE SELECT avg(x) FROM limittest GROUP BY y ORDER BY 1 DESC FETCH FIRST 2 ROWS WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 2: ...est GROUP BY y ORDER BY 1 DESC FETCH FIRST 2 ROWS WITH TIES; - ^ + QUERY PLAN +---------------------------------------------------------------------------------------------------------------- + Limit (cost=1.00..1.00 rows=1 width=64) + Output: (avg(x)), y + -> Foreign Scan (cost=1.00..1.00 rows=1 width=64) + Output: (avg(x)), y + SQLite query: SELECT avg(`x`), `y` FROM main."limittest" GROUP BY 2 ORDER BY avg(`x`) DESC NULLS FIRST +(5 rows) + --Testcase 21: SELECT avg(x) FROM limittest GROUP BY y ORDER BY 1 DESC FETCH FIRST 2 ROWS WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 1: ...est GROUP BY y ORDER BY 1 DESC FETCH FIRST 2 ROWS WITH TIES; - ^ + avg +----- + 2.5 + 2.5 + 2.5 +(3 rows) + --Testcase 22: EXPLAIN VERBOSE SELECT avg(x) FROM limittest WHERE x >= 0 GROUP BY y ORDER BY 1 DESC FETCH FIRST 2 ROWS WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 2: ...= 0 GROUP BY y ORDER BY 1 DESC FETCH FIRST 2 ROWS WITH TIES; - ^ + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------- + Limit (cost=1.00..1.00 rows=1 width=64) + Output: (avg(x)), y + -> Foreign Scan (cost=1.00..1.00 rows=1 width=64) + Output: (avg(x)), y + SQLite query: SELECT avg(`x`), `y` FROM main."limittest" WHERE ((`x` >= 0)) GROUP BY 2 ORDER BY avg(`x`) DESC NULLS FIRST +(5 rows) + --Testcase 23: SELECT avg(x) FROM limittest WHERE x >= 0 GROUP BY y ORDER BY 1 DESC FETCH FIRST 2 ROWS WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 1: ...= 0 GROUP BY y ORDER BY 1 DESC FETCH FIRST 2 ROWS WITH TIES; - ^ + avg +----- + 2.5 + 2.5 + 2.5 +(3 rows) + --Testcase 24: EXPLAIN VERBOSE SELECT x FROM limittest WHERE x > 0 ORDER BY 1 FETCH FIRST 2 ROWS WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 2: ...mittest WHERE x > 0 ORDER BY 1 FETCH FIRST 2 ROWS WITH TIES; - ^ + QUERY PLAN +------------------------------------------------------------------------------------------------------ + Limit (cost=10.00..10.00 rows=2 width=4) + Output: x + -> Foreign Scan on public.limittest (cost=10.00..10.00 rows=10 width=4) + Output: x + SQLite query: SELECT `x` FROM main."limittest" WHERE ((`x` > 0)) ORDER BY `x` ASC NULLS LAST +(5 rows) + --Testcase 25: SELECT x FROM limittest WHERE x > 0 ORDER BY 1 FETCH FIRST 2 ROWS WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 1: ...mittest WHERE x > 0 ORDER BY 1 FETCH FIRST 2 ROWS WITH TIES; - ^ + x +--- + 1 + 1 + 1 +(3 rows) + --Testcase 26: EXPLAIN VERBOSE SELECT x FROM limittest ORDER BY 1 FETCH FIRST 2 ROWS ONLY; diff --git a/expected/10.18/extra/aggregates.out b/expected/15beta2/extra/aggregates.out similarity index 87% rename from expected/10.18/extra/aggregates.out rename to expected/15beta2/extra/aggregates.out index bb12658e..f1f893fe 100644 --- a/expected/10.18/extra/aggregates.out +++ b/expected/15beta2/extra/aggregates.out @@ -69,7 +69,198 @@ CREATE FOREIGN TABLE multi_arg_agg (a int OPTIONS (key 'true'), b int, c text) S CREATE FOREIGN TABLE VARCHAR_TBL(f1 varchar(4) OPTIONS (key 'true')) SERVER sqlite_svr; --Testcase 276: CREATE FOREIGN TABLE FLOAT8_TBL(f1 float8 OPTIONS (key 'true')) SERVER sqlite_svr; +-- GROUP BY optimization by reorder columns +--Testcase 678: +CREATE FOREIGN TABLE btg(id int, p int, v text, c float, d float, e int) SERVER sqlite_svr; +--Testcase 679: +INSERT INTO btg +SELECT + i, + i/2, + format('%60s', i%2), + i/4, + i/8, + (random() * (10000/8))::int --the same as d but no correlation with p +FROM + generate_series(1, 10000) i; +-- VACUUM btg; +-- ANALYZE btg; +-- GROUP BY optimization by reorder columns by frequency +SET enable_hashagg=off; +SET max_parallel_workers= 0; +SET max_parallel_workers_per_gather = 0; +--Testcase 680: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, v; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 681: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 682: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, c; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 683: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, c ORDER BY v, p, c; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 684: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, d, c; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 685: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, d, c ORDER BY v, p, d ,c; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 686: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, d, c ORDER BY p, v, d ,c; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 687: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, d, e; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 688: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, e, d; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 689: +CREATE STATISTICS btg_dep ON d, e, p FROM btg; +-- ANALYZE btg; +--Testcase 690: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, d, e; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 691: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, e, d; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +-- GROUP BY optimization by reorder columns by index scan +--Testcase 692: +CREATE INDEX ON btg(p, v); +ERROR: cannot create index on relation "btg" +DETAIL: This operation is not supported for foreign tables. +SET enable_seqscan=off; +SET enable_bitmapscan=off; +-- VACUUM btg; +--Testcase 693: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, v; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 694: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, v ORDER BY p, v; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 695: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 696: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p ORDER BY p, v; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 697: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, c; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 698: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, c ORDER BY p, v; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 699: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, c, p, d; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 700: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, c, p, d ORDER BY p, v; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 701: +DROP FOREIGN TABLE btg; +RESET enable_hashagg; +RESET max_parallel_workers; +RESET max_parallel_workers_per_gather; +RESET enable_seqscan; +RESET enable_bitmapscan; -- avoid bit-exact output here because operations may not be bit-exact. +--Testcase 588: SET extra_float_digits = 0; --Testcase 1: SELECT avg(four) AS avg_1 FROM onek; @@ -366,6 +557,28 @@ SELECT stddev_pop(a), stddev_samp(b) FROM agg_t5; 0 | (1 row) +--Testcase 597: +DELETE FROM agg_t5; +--Testcase 598: +INSERT INTO agg_t5 values ('inf'::numeric, 'inf'::numeric); +--Testcase 599: +SELECT var_pop(a), var_samp(b) FROM agg_t5; + var_pop | var_samp +---------+---------- + NaN | +(1 row) + +--Testcase 600: +DELETE FROM agg_t5; +--Testcase 601: +INSERT INTO agg_t5 values ('inf'::numeric, 'inf'::numeric); +--Testcase 602: +SELECT stddev_pop(a), stddev_samp(b) FROM agg_t5; + stddev_pop | stddev_samp +------------+------------- + NaN | +(1 row) + --Testcase 314: DELETE FROM agg_t5; --Testcase 315: @@ -467,10 +680,10 @@ DELETE FROM agg_t3; --Testcase 332: INSERT INTO agg_t3 VALUES ('1'::float8), ('infinity'::float8); --Testcase 333: -SELECT avg(a), var_pop(a) FROM agg_t3; - avg | var_pop -----------+--------- - Infinity | NaN +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + sum | avg | var_pop +----------+----------+--------- + Infinity | Infinity | NaN (1 row) --Testcase 334: @@ -478,10 +691,10 @@ DELETE FROM agg_t3; --Testcase 335: INSERT INTO agg_t3 VALUES ('infinity'::float8), ('1'::float8); --Testcase 336: -SELECT avg(a), var_pop(a) FROM agg_t3; - avg | var_pop -----------+--------- - Infinity | NaN +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + sum | avg | var_pop +----------+----------+--------- + Infinity | Infinity | NaN (1 row) --Testcase 337: @@ -489,10 +702,10 @@ DELETE FROM agg_t3; --Testcase 338: INSERT INTO agg_t3 VALUES ('infinity'::float8), ('infinity'::float8); --Testcase 339: -SELECT avg(a), var_pop(a) FROM agg_t3; - avg | var_pop -----------+--------- - Infinity | NaN +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + sum | avg | var_pop +----------+----------+--------- + Infinity | Infinity | NaN (1 row) --Testcase 340: @@ -500,10 +713,76 @@ DELETE FROM agg_t3; --Testcase 341: INSERT INTO agg_t3 VALUES ('-infinity'::float8), ('infinity'::float8); --Testcase 342: -SELECT avg(a), var_pop(a) FROM agg_t3; - avg | var_pop ------+--------- - NaN | NaN +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + sum | avg | var_pop +-----+-----+--------- + NaN | NaN | NaN +(1 row) + +--Testcase 603: +DELETE FROM agg_t3; +--Testcase 604: +INSERT INTO agg_t3 VALUES ('-infinity'::float8), ('-infinity'::float8); +--Testcase 605: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + sum | avg | var_pop +-----------+-----------+--------- + -Infinity | -Infinity | NaN +(1 row) + +--Testcase 606: +DELETE FROM agg_t3; +--Testcase 607: +INSERT INTO agg_t3 VALUES ('1'::numeric), ('infinity'::numeric); +--Testcase 608: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + sum | avg | var_pop +----------+----------+--------- + Infinity | Infinity | NaN +(1 row) + +--Testcase 609: +DELETE FROM agg_t3; +--Testcase 610: +INSERT INTO agg_t3 VALUES ('infinity'::numeric), ('1'::numeric); +--Testcase 611: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + sum | avg | var_pop +----------+----------+--------- + Infinity | Infinity | NaN +(1 row) + +--Testcase 612: +DELETE FROM agg_t3; +--Testcase 613: +INSERT INTO agg_t3 VALUES ('infinity'::numeric), ('infinity'::numeric); +--Testcase 614: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + sum | avg | var_pop +----------+----------+--------- + Infinity | Infinity | NaN +(1 row) + +--Testcase 615: +DELETE FROM agg_t3; +--Testcase 616: +INSERT INTO agg_t3 VALUES ('-infinity'::numeric), ('infinity'::numeric); +--Testcase 617: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + sum | avg | var_pop +-----+-----+--------- + NaN | NaN | NaN +(1 row) + +--Testcase 618: +DELETE FROM agg_t3; +--Testcase 619: +INSERT INTO agg_t3 VALUES ('-infinity'::numeric), ('-infinity'::numeric); +--Testcase 620: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + sum | avg | var_pop +-----------+-----------+--------- + -Infinity | -Infinity | NaN (1 row) -- test accuracy with a large input offset @@ -517,7 +796,7 @@ INSERT INTO agg_t6 VALUES (100000003), (100000004), (100000006), (100000007); SELECT avg(a), var_pop(a) FROM agg_t6; avg | var_pop -----------+--------- - 100000005 | 4 + 100000005 | 2.5 (1 row) --Testcase 347: @@ -528,7 +807,7 @@ INSERT INTO agg_t6 VALUES (7000000000005), (7000000000007); SELECT avg(a), var_pop(a) FROM agg_t6; avg | var_pop ---------------+--------- - 7000000000006 | 0 + 7000000000006 | 1 (1 row) -- SQL2003 binary aggregates @@ -669,9 +948,9 @@ delete from agg_t15; insert into agg_t15 values ('{4,140,2900}', 100); --Testcase 368: SELECT float8_accum(a::float8[], b) from agg_t15; - float8_accum ---------------- - {5,240,12900} + float8_accum +-------------- + {5,240,6280} (1 row) --Testcase 369: @@ -680,9 +959,9 @@ delete from agg_t15; insert into agg_t15 values ('{4,140,2900,1290,83075,15050}', 200, 100); --Testcase 371: SELECT float8_regr_accum(a::float8[], b, c) from agg_t15; - float8_regr_accum ---------------------------------- - {5,240,12900,1490,123075,35050} + float8_regr_accum +------------------------------ + {5,240,6280,1490,95080,8680} (1 row) --Testcase 372: @@ -713,7 +992,13 @@ insert into agg_t16 values ('{0,0,0}', '{2,180,200}'); insert into agg_t16 values ('{3,60,200}', '{2,180,200}'); --Testcase 379: SELECT float8_combine(a::float8[], b::float8[]) FROM agg_t16; -ERROR: aggregate function called in non-aggregate context + float8_combine +---------------- + {3,60,200} + {2,180,200} + {5,240,6280} +(3 rows) + --Testcase 380: delete from agg_t16; --Testcase 381: @@ -724,7 +1009,13 @@ insert into agg_t16 values ('{0,0,0,0,0,0}', '{2,180,200,740,57800,-3400}'); insert into agg_t16 values ('{3,60,200,750,20000,2000}', '{2,180,200,740,57800,-3400}'); --Testcase 384: SELECT float8_regr_combine(a::float8[], b::float8[]) FROM agg_t16; -ERROR: aggregate function called in non-aggregate context + float8_regr_combine +------------------------------ + {3,60,200,750,20000,2000} + {2,180,200,740,57800,-3400} + {5,240,6280,1490,95080,8680} +(3 rows) + --Testcase 385: DROP FOREIGN TABLE regr_test; -- test count, distinct @@ -982,11 +1273,12 @@ CREATE FOREIGN TABLE bitwise_test( --Testcase 43: SELECT BIT_AND(i2) AS "?", - BIT_OR(i4) AS "?" + BIT_OR(i4) AS "?", + BIT_XOR(i8) AS "?" FROM bitwise_test; - ? | ? ----+--- - | + ? | ? | ? +---+---+--- + | | (1 row) --Testcase 44: @@ -1005,11 +1297,16 @@ SELECT BIT_OR(i4) AS "7", BIT_OR(i8) AS "7", BIT_OR(i) AS "?", - BIT_OR(x) AS "7" + BIT_OR(x) AS "7", + BIT_XOR(i2) AS "5", + BIT_XOR(i4) AS "5", + BIT_XOR(i8) AS "5", + BIT_XOR(i) AS "?", + BIT_XOR(x) AS "7" FROM bitwise_test; - 1 | 1 | 1 | ? | 0 | 7 | 7 | 7 | ? | 7 ----+---+---+---+---+---+---+---+---+--- - 1 | 1 | 1 | 1 | 0 | 7 | 7 | 7 | 3 | 7 + 1 | 1 | 1 | ? | 0 | 7 | 7 | 7 | ? | 7 | 5 | 5 | 5 | ? | 7 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+--- + 1 | 1 | 1 | 1 | 0 | 7 | 7 | 7 | 3 | 7 | 5 | 5 | 5 | 2 | 7 (1 row) -- @@ -1258,6 +1555,7 @@ select max(unique1) from tenk1 where unique1 > 42; -- plan, which has almost identical cost, will not be. we want to test -- the optimized plan, so temporarily disable parallel query. begin; +--Testcase 628: set local max_parallel_workers_per_gather = 0; --Testcase 59: explain (costs off) @@ -1334,13 +1632,12 @@ select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt --Testcase 67: explain (costs off) select distinct max(unique2) from tenk1; - QUERY PLAN ----------------------------------- - Unique - -> Sort - Sort Key: (max(unique2)) - -> Foreign Scan -(4 rows) + QUERY PLAN +----------------------------- + HashAggregate + Group Key: (max(unique2)) + -> Foreign Scan +(3 rows) --Testcase 68: select distinct max(unique2) from tenk1; @@ -1456,29 +1753,29 @@ insert into minmaxtest3 values(17), (18); --Testcase 83: explain (costs off) select min(f1), max(f1) from minmaxtest; - QUERY PLAN ----------------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------- Result InitPlan 1 (returns $0) -> Limit -> Merge Append Sort Key: minmaxtest.f1 - -> Foreign Scan on minmaxtest - -> Index Only Scan using minmaxtest1i on minmaxtest1 + -> Foreign Scan on minmaxtest minmaxtest_1 + -> Index Only Scan using minmaxtest1i on minmaxtest1 minmaxtest_2 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan Backward using minmaxtest2i on minmaxtest2 + -> Index Only Scan Backward using minmaxtest2i on minmaxtest2 minmaxtest_3 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan using minmaxtest3i on minmaxtest3 + -> Index Only Scan using minmaxtest3i on minmaxtest3 minmaxtest_4 InitPlan 2 (returns $1) -> Limit -> Merge Append - Sort Key: minmaxtest_1.f1 DESC - -> Foreign Scan on minmaxtest minmaxtest_1 - -> Index Only Scan Backward using minmaxtest1i on minmaxtest1 minmaxtest1_1 + Sort Key: minmaxtest_5.f1 DESC + -> Foreign Scan on minmaxtest minmaxtest_6 + -> Index Only Scan Backward using minmaxtest1i on minmaxtest1 minmaxtest_7 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan using minmaxtest2i on minmaxtest2 minmaxtest2_1 + -> Index Only Scan using minmaxtest2i on minmaxtest2 minmaxtest_8 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan Backward using minmaxtest3i on minmaxtest3 minmaxtest3_1 + -> Index Only Scan Backward using minmaxtest3i on minmaxtest3 minmaxtest_9 (21 rows) --Testcase 84: @@ -1492,29 +1789,29 @@ select min(f1), max(f1) from minmaxtest; --Testcase 85: explain (costs off) select distinct min(f1), max(f1) from minmaxtest; - QUERY PLAN ----------------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------- Unique InitPlan 1 (returns $0) -> Limit -> Merge Append Sort Key: minmaxtest.f1 - -> Foreign Scan on minmaxtest - -> Index Only Scan using minmaxtest1i on minmaxtest1 + -> Foreign Scan on minmaxtest minmaxtest_1 + -> Index Only Scan using minmaxtest1i on minmaxtest1 minmaxtest_2 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan Backward using minmaxtest2i on minmaxtest2 + -> Index Only Scan Backward using minmaxtest2i on minmaxtest2 minmaxtest_3 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan using minmaxtest3i on minmaxtest3 + -> Index Only Scan using minmaxtest3i on minmaxtest3 minmaxtest_4 InitPlan 2 (returns $1) -> Limit -> Merge Append - Sort Key: minmaxtest_1.f1 DESC - -> Foreign Scan on minmaxtest minmaxtest_1 - -> Index Only Scan Backward using minmaxtest1i on minmaxtest1 minmaxtest1_1 + Sort Key: minmaxtest_5.f1 DESC + -> Foreign Scan on minmaxtest minmaxtest_6 + -> Index Only Scan Backward using minmaxtest1i on minmaxtest1 minmaxtest_7 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan using minmaxtest2i on minmaxtest2 minmaxtest2_1 + -> Index Only Scan using minmaxtest2i on minmaxtest2 minmaxtest_8 Index Cond: (f1 IS NOT NULL) - -> Index Only Scan Backward using minmaxtest3i on minmaxtest3 minmaxtest3_1 + -> Index Only Scan Backward using minmaxtest3i on minmaxtest3 minmaxtest_9 -> Sort Sort Key: ($0), ($1) -> Result @@ -1601,8 +1898,8 @@ explain (costs off) select * from agg_t1 group by a,b,c,d; HashAggregate Group Key: agg_t1.a, agg_t1.b, agg_t1.c, agg_t1.d -> Append - -> Foreign Scan on agg_t1 - -> Seq Scan on t1c + -> Foreign Scan on agg_t1 agg_t1_1 + -> Seq Scan on t1c agg_t1_2 (5 rows) -- Okay to remove columns if we're only querying the parent. @@ -2230,6 +2527,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: @@ -2280,7 +2613,7 @@ from generate_series(1,5) x, FLOAT8_TBL group by f1 order by f1; ERROR: sum is not an ordered-set aggregate, so it cannot have WITHIN GROUP -LINE 1: select f1, sum() within group (order by x::float8) +LINE 1: select f1, sum() within group (order by x::float8) -- error ^ rollback; begin; @@ -2294,7 +2627,7 @@ from generate_series(1,5) x, FLOAT8_TBL group by f1 order by f1; ERROR: WITHIN GROUP is required for ordered-set aggregate percentile_cont -LINE 1: select f1, percentile_cont(f1,f1) +LINE 1: select f1, percentile_cont(f1,f1) -- error ^ rollback; --Testcase 179: @@ -2455,7 +2788,6 @@ create aggregate my_percentile_disc(float8 ORDER BY anyelement) ( finalfunc_extra = true, finalfunc_modify = read_write ); -WARNING: aggregate attribute "finalfunc_modify" not recognized --Testcase 467: create aggregate my_rank(VARIADIC "any" ORDER BY VARIADIC "any") ( stype = internal, @@ -2464,9 +2796,11 @@ create aggregate my_rank(VARIADIC "any" ORDER BY VARIADIC "any") ( finalfunc_extra = true, hypothetical ); +--Testcase 633: alter aggregate my_percentile_disc(float8 ORDER BY anyelement) rename to test_percentile_disc; +--Testcase 634: alter aggregate my_rank(VARIADIC "any" ORDER BY VARIADIC "any") rename to test_rank; begin; @@ -2542,7 +2876,7 @@ begin; insert into agg_t21 select * from generate_series(1,5); --Testcase 477: select rank('fred') within group (order by x) from agg_t21; -ERROR: invalid input syntax for integer: "fred" +ERROR: invalid input syntax for type integer: "fred" LINE 1: select rank('fred') within group (order by x) from agg_t21; ^ rollback; @@ -2644,11 +2978,9 @@ create aggregate least_agg(variadic items anyarray) ( create function cleast_accum(anycompatible, variadic anycompatiblearray) returns anycompatible language sql as 'select least($1, min($2[i])) from generate_subscripts($2,1) g(i)'; -ERROR: type anycompatible does not exist --Testcase 491: create aggregate cleast_agg(variadic items anycompatiblearray) ( stype = anycompatible, sfunc = cleast_accum); -ERROR: type anycompatiblearray does not exist --Testcase 198: select least_agg(q1,q2) from int8_tbl; least_agg @@ -2665,28 +2997,32 @@ select least_agg(variadic array[q1,q2]) from int8_tbl; --Testcase 492: select cleast_agg(q1,q2) from int8_tbl; -ERROR: function cleast_agg(bigint, bigint) does not exist -LINE 1: select cleast_agg(q1,q2) from int8_tbl; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. + cleast_agg +------------------- + -4567890123456789 +(1 row) + --Testcase 493: select cleast_agg(4.5,f1) from int4_tbl; -ERROR: function cleast_agg(numeric, integer) does not exist -LINE 1: select cleast_agg(4.5,f1) from int4_tbl; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. + cleast_agg +------------- + -2147483647 +(1 row) + --Testcase 494: select cleast_agg(variadic array[4.5,f1]) from int4_tbl; -ERROR: function cleast_agg(numeric[]) does not exist -LINE 1: select cleast_agg(variadic array[4.5,f1]) from int4_tbl; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. + cleast_agg +------------- + -2147483647 +(1 row) + --Testcase 495: select pg_typeof(cleast_agg(variadic array[4.5,f1])) from int4_tbl; -ERROR: function cleast_agg(numeric[]) does not exist -LINE 1: select pg_typeof(cleast_agg(variadic array[4.5,f1])) from in... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. + pg_typeof +----------- + numeric +(1 row) + -- test aggregates with common transition functions share the same states --Testcase 496: create foreign table agg_t10(one int, id int options (key 'true')) server sqlite_svr; @@ -2827,10 +3163,10 @@ delete from agg_t11; insert into agg_t11 values (1,2),(3,4); --Testcase 518: select my_avg(one),my_sum(two) from agg_t11; -NOTICE: avg_transfn called with 2 NOTICE: avg_transfn called with 1 -NOTICE: avg_transfn called with 4 +NOTICE: avg_transfn called with 2 NOTICE: avg_transfn called with 3 +NOTICE: avg_transfn called with 4 my_avg | my_sum --------+-------- 2 | 6 @@ -3022,7 +3358,7 @@ ROLLBACK; -- Secondly test the case of a parallel aggregate combiner function -- returning NULL. For that use normal transition function, but a -- combiner function returning NULL. -BEGIN ISOLATION LEVEL REPEATABLE READ; +BEGIN; --Testcase 540: CREATE FUNCTION balkifnull(int8, int8) RETURNS int8 @@ -3053,15 +3389,19 @@ CREATE AGGREGATE balk(int4) -- SELECT balk(hundred) FROM tenk1; ROLLBACK; -- test coverage for aggregate combine/serial/deserial functions -BEGIN ISOLATION LEVEL REPEATABLE READ; +BEGIN; +--Testcase 635: SET parallel_setup_cost = 0; +--Testcase 636: SET parallel_tuple_cost = 0; +--Testcase 637: SET min_parallel_table_scan_size = 0; +--Testcase 638: SET max_parallel_workers_per_gather = 4; +--Testcase 639: SET parallel_leader_participation = off; -ERROR: unrecognized configuration parameter "parallel_leader_participation" +--Testcase 640: SET enable_indexonlyscan = off; -ERROR: current transaction is aborted, commands ignored until end of transaction block -- variance(int4) covers numeric_poly_combine -- sum(int8) covers int8_avg_combine -- regr_count(float8, float8) covers int8inc_float8_float8 and aggregates with > 1 arg @@ -3072,14 +3412,36 @@ FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1) u; -ERROR: current transaction is aborted, commands ignored until end of transaction block + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------- + Aggregate + Output: variance(tenk1.unique1), sum((tenk1.unique1)::bigint), regr_count((tenk1.unique1)::double precision, (tenk1.unique1)::double precision) + -> Append + -> Foreign Scan on public.tenk1 + Output: tenk1.unique1 + SQLite query: SELECT `unique1` FROM main."tenk1" + -> Foreign Scan on public.tenk1 tenk1_1 + Output: tenk1_1.unique1 + SQLite query: SELECT `unique1` FROM main."tenk1" + -> Foreign Scan on public.tenk1 tenk1_2 + Output: tenk1_2.unique1 + SQLite query: SELECT `unique1` FROM main."tenk1" + -> Foreign Scan on public.tenk1 tenk1_3 + Output: tenk1_3.unique1 + SQLite query: SELECT `unique1` FROM main."tenk1" +(15 rows) + --Testcase 543: SELECT variance(unique1::int4), sum(unique1::int8), regr_count(unique1::float8, unique1::float8) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1) u; -ERROR: current transaction is aborted, commands ignored until end of transaction block + variance | sum | regr_count +----------------------+-----------+------------ + 8333541.588539713493 | 199980000 | 40000 +(1 row) + -- variance(int8) covers numeric_combine -- avg(numeric) covers numeric_avg_combine --Testcase 544: @@ -3089,14 +3451,36 @@ FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1) u; -ERROR: current transaction is aborted, commands ignored until end of transaction block + QUERY PLAN +---------------------------------------------------------------------------- + Aggregate + Output: variance((tenk1.unique1)::bigint), avg((tenk1.unique1)::numeric) + -> Append + -> Foreign Scan on public.tenk1 + Output: tenk1.unique1 + SQLite query: SELECT `unique1` FROM main."tenk1" + -> Foreign Scan on public.tenk1 tenk1_1 + Output: tenk1_1.unique1 + SQLite query: SELECT `unique1` FROM main."tenk1" + -> Foreign Scan on public.tenk1 tenk1_2 + Output: tenk1_2.unique1 + SQLite query: SELECT `unique1` FROM main."tenk1" + -> Foreign Scan on public.tenk1 tenk1_3 + Output: tenk1_3.unique1 + SQLite query: SELECT `unique1` FROM main."tenk1" +(15 rows) + --Testcase 545: SELECT variance(unique1::int8), avg(unique1::numeric) FROM (SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1 UNION ALL SELECT * FROM tenk1) u; -ERROR: current transaction is aborted, commands ignored until end of transaction block + variance | avg +----------------------+----------------------- + 8333541.588539713493 | 4999.5000000000000000 +(1 row) + ROLLBACK; -- test coverage for dense_rank --Testcase 546: @@ -3165,6 +3549,8 @@ rollback; -- Make sure that generation of HashAggregate for uniqification purposes -- 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_memoize to off; --Testcase 558: explain (costs off) select 1 from tenk1 @@ -3180,10 +3566,14 @@ explain (costs off) -> Foreign Scan on tenk1 (7 rows) +--Testcase 642: +reset enable_memoize; -- -- Hash Aggregation Spill tests -- +--Testcase 643: set enable_sort=false; +--Testcase 644: set work_mem='64kB'; --Testcase 559: select unique1, count(*), sum(twothousand) from tenk1 @@ -3242,12 +3632,15 @@ order by sum(twothousand); 9999 | 1 | 1999 (48 rows) +--Testcase 645: set work_mem to default; +--Testcase 646: set enable_sort to default; -- -- Compare results between plans using sorting and plans using hash -- aggregation. Force spilling in both cases by setting work_mem low. -- +--Testcase 647: set work_mem='64kB'; --Testcase 560: create foreign table agg_data_2k(g int, id int options (key 'true')) server sqlite_svr; @@ -3276,9 +3669,10 @@ insert into agg_data_2k select g from generate_series(0, 1999) g; insert into agg_data_20k select g from generate_series(0, 19999) g; --analyze agg_data_20k; -- Produce results with sorting. +--Testcase 648: set enable_hashagg = false; +--Testcase 649: set jit_above_cost = 0; -ERROR: unrecognized configuration parameter "jit_above_cost" --Testcase 572: explain (costs off) select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3 @@ -3305,8 +3699,8 @@ select * from from agg_data_2k where g < r.a group by g/2) as s; +--Testcase 650: set jit_above_cost to default; -ERROR: unrecognized configuration parameter "jit_above_cost" --Testcase 575: insert into agg_group_3 select (g/2)::numeric as c1, sum(7::int4) as c2, count(*) as c3 @@ -3316,10 +3710,12 @@ insert into agg_group_4 select (g/2)::numeric as c1, array_agg(g::numeric) as c2, count(*) as c3 from agg_data_2k group by g/2; -- Produce results with hash aggregation +--Testcase 651: set enable_hashagg = true; +--Testcase 652: set enable_sort = false; +--Testcase 653: set jit_above_cost = 0; -ERROR: unrecognized configuration parameter "jit_above_cost" --Testcase 577: explain (costs off) select g%10000 as c1, sum(g::numeric) as c2, count(*) as c3 @@ -3346,8 +3742,8 @@ select * from from agg_data_2k where g < r.a group by g/2) as s; +--Testcase 654: set jit_above_cost to default; -ERROR: unrecognized configuration parameter "jit_above_cost" --Testcase 580: insert into agg_hash_3 select (g/2)::numeric as c1, sum(7::int4) as c2, count(*) as c3 @@ -3356,7 +3752,9 @@ select (g/2)::numeric as c1, sum(7::int4) as c2, count(*) as c3 insert into agg_hash_4 select (g/2)::numeric as c1, array_agg(g::numeric) as c2, count(*) as c3 from agg_data_2k group by g/2; +--Testcase 655: set enable_sort = true; +--Testcase 656: set work_mem to default; -- Compare group aggregation results to hash aggregation results --Testcase 582: diff --git a/expected/11.13/extra/float4.out b/expected/15beta2/extra/float4.out similarity index 53% rename from expected/11.13/extra/float4.out rename to expected/15beta2/extra/float4.out index 6260ad27..54eded03 100644 --- a/expected/11.13/extra/float4.out +++ b/expected/15beta2/extra/float4.out @@ -23,22 +23,22 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('1.2345678901234e-20'); -- test for over and under flow --Testcase 6: INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70'); -ERROR: value out of range: overflow +ERROR: "10e70" is out of range for type real LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('10e70'); ^ --Testcase 7: INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'); -ERROR: value out of range: overflow +ERROR: "-10e70" is out of range for type real LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e70'); ^ --Testcase 8: INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'); -ERROR: value out of range: underflow +ERROR: "10e-70" is out of range for type real LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('10e-70'); ^ --Testcase 9: INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'); -ERROR: value out of range: underflow +ERROR: "-10e-70" is out of range for type real LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('-10e-70'); ^ --Testcase 50: @@ -232,6 +232,17 @@ SELECT f1 FROM FLOAT4_TMP; (1 row) +--Testcase 185: +DELETE FROM FLOAT4_TMP; +--Testcase 186: +INSERT INTO FLOAT4_TMP VALUES ('42'::float4 / 'Infinity'::float4); +--Testcase 187: +SELECT f1 FROM FLOAT4_TMP; + f1 +---- + 0 +(1 row) + --Testcase 31: DELETE FROM FLOAT4_TMP; --Testcase 78: @@ -243,6 +254,17 @@ SELECT f1 FROM FLOAT4_TMP; (1 row) +--Testcase 188: +DELETE FROM FLOAT4_TMP; +--Testcase 189: +INSERT INTO FLOAT4_TMP VALUES ('nan'::float4 / '0'::float4); +--Testcase 190: +SELECT f1 FROM FLOAT4_TMP; + f1 +---- + +(1 row) + --Testcase 32: DELETE FROM FLOAT4_TMP; --Testcase 80: @@ -255,14 +277,14 @@ SELECT f1 FROM FLOAT4_TMP; (1 row) --Testcase 34: -SELECT '' AS five, * FROM FLOAT4_TBL; - five | f1 -------+------------- - | 0 - | 1004.3 - | -34.84 - | 1.23457e+20 - | 1.23457e-20 +SELECT * FROM FLOAT4_TBL; + f1 +--------------- + 0 + 1004.3 + -34.84 + 1.2345679e+20 + 1.2345679e-20 (5 rows) --SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3'; @@ -270,90 +292,90 @@ SELECT '' AS five, * FROM FLOAT4_TBL; --SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1; --SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3'; --Testcase 35: -SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1; - four | f1 -------+------------- - | 0 - | 1004.3 - | -34.84 - | 1.23457e-20 +SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1; + f1 +--------------- + 0 + 1004.3 + -34.84 + 1.2345679e-20 (4 rows) --Testcase 36: -SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3'; - four | f1 -------+------------- - | 0 - | 1004.3 - | -34.84 - | 1.23457e-20 +SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3'; + f1 +--------------- + 0 + 1004.3 + -34.84 + 1.2345679e-20 (4 rows) --Testcase 37: -SELECT '' AS three, f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f +SELECT f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f WHERE f.f1 > '0.0'; - three | f1 | x --------+-------------+-------------- - | 1004.3 | -10043 - | 1.23457e+20 | -1.23457e+21 - | 1.23457e-20 | -1.23457e-19 + f1 | x +---------------+---------------- + 1004.3 | -10043 + 1.2345679e+20 | -1.2345678e+21 + 1.2345679e-20 | -1.2345678e-19 (3 rows) --Testcase 38: -SELECT '' AS three, f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f +SELECT f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f WHERE f.f1 > '0.0'; - three | f1 | x --------+-------------+------------- - | 1004.3 | 994.3 - | 1.23457e+20 | 1.23457e+20 - | 1.23457e-20 | -10 + f1 | x +---------------+--------------- + 1004.3 | 994.3 + 1.2345679e+20 | 1.2345679e+20 + 1.2345679e-20 | -10 (3 rows) --Testcase 39: -SELECT '' AS three, f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f +SELECT f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f WHERE f.f1 > '0.0'; - three | f1 | x --------+-------------+-------------- - | 1004.3 | -100.43 - | 1.23457e+20 | -1.23457e+19 - | 1.23457e-20 | -1.23457e-21 + f1 | x +---------------+---------------- + 1004.3 | -100.43 + 1.2345679e+20 | -1.2345679e+19 + 1.2345679e-20 | -1.2345679e-21 (3 rows) --Testcase 40: -SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f +SELECT f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f WHERE f.f1 > '0.0'; - three | f1 | x --------+-------------+------------- - | 1004.3 | 1014.3 - | 1.23457e+20 | 1.23457e+20 - | 1.23457e-20 | 10 + f1 | x +---------------+--------------- + 1004.3 | 1014.3 + 1.2345679e+20 | 1.2345679e+20 + 1.2345679e-20 | 10 (3 rows) -- test divide by zero --Testcase 41: -SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f; +SELECT f.f1 / '0.0' from FLOAT4_TBL f; ERROR: division by zero --Testcase 42: -SELECT '' AS five, * FROM FLOAT4_TBL; - five | f1 -------+------------- - | 0 - | 1004.3 - | -34.84 - | 1.23457e+20 - | 1.23457e-20 +SELECT * FROM FLOAT4_TBL; + f1 +--------------- + 0 + 1004.3 + -34.84 + 1.2345679e+20 + 1.2345679e-20 (5 rows) -- test the unary float4abs operator --Testcase 43: -SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f; - five | f1 | abs_f1 -------+-------------+------------- - | 0 | 0 - | 1004.3 | 1004.3 - | -34.84 | 34.84 - | 1.23457e+20 | 1.23457e+20 - | 1.23457e-20 | 1.23457e-20 +SELECT f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f; + f1 | abs_f1 +---------------+--------------- + 0 | 0 + 1004.3 | 1004.3 + -34.84 | 34.84 + 1.2345679e+20 | 1.2345679e+20 + 1.2345679e-20 | 1.2345679e-20 (5 rows) --Testcase 44: @@ -361,14 +383,14 @@ UPDATE FLOAT4_TBL SET f1 = FLOAT4_TBL.f1 * '-1' WHERE FLOAT4_TBL.f1 > '0.0'; --Testcase 45: -SELECT '' AS five, * FROM FLOAT4_TBL; - five | f1 -------+-------------- - | 0 - | -1004.3 - | -34.84 - | -1.23457e+20 - | -1.23457e-20 +SELECT * FROM FLOAT4_TBL; + f1 +---------------- + 0 + -1004.3 + -34.84 + -1.2345679e+20 + -1.2345679e-20 (5 rows) -- test edge-case coercions to integer @@ -535,7 +557,7 @@ INSERT INTO FLOAT4_TMP VALUES ('7038531e-32'::float4); SELECT float4send(f1) FROM FLOAT4_TMP; float4send ------------ - \x15ae43fe + \x15ae43fd (1 row) --Testcase 133: @@ -634,7 +656,7 @@ INSERT INTO FLOAT4_TMP VALUES ('82381273e-35'::float4); SELECT float4send(f1) FROM FLOAT4_TMP; float4send ------------ - \x128289d0 + \x128289d1 (1 row) --Testcase 160: @@ -731,29 +753,29 @@ select float4send(flt) as ibits, from (select bits::bit(32)::integer::xfloat4::float4 as flt from testdata offset 0) s; - ibits | flt -------------+------------- - \x00000001 | 1.4013e-45 - \x00000002 | 2.8026e-45 - \x00000003 | 4.2039e-45 - \x00000010 | 2.24208e-44 - \x00000011 | 2.38221e-44 - \x00000100 | 3.58732e-43 - \x00000101 | 3.60134e-43 - \x00004000 | 2.29589e-41 - \x00004001 | 2.29603e-41 - \x00080000 | 7.34684e-40 - \x00080001 | 7.34685e-40 - \x0053c4f4 | 7.693e-39 - \x006c85c4 | 9.96622e-39 - \x0041ca76 | 6.04194e-39 - \x004b7678 | 6.93016e-39 - \x00000007 | 9.80909e-45 - \x00424fe2 | 6.0898e-39 - \x007ffff0 | 1.17549e-38 - \x007ffff1 | 1.17549e-38 - \x007ffffe | 1.17549e-38 - \x007fffff | 1.17549e-38 + ibits | flt +------------+--------------- + \x00000001 | 1e-45 + \x00000002 | 3e-45 + \x00000003 | 4e-45 + \x00000010 | 2.2e-44 + \x00000011 | 2.4e-44 + \x00000100 | 3.59e-43 + \x00000101 | 3.6e-43 + \x00004000 | 2.2959e-41 + \x00004001 | 2.296e-41 + \x00080000 | 7.34684e-40 + \x00080001 | 7.34685e-40 + \x0053c4f4 | 7.693e-39 + \x006c85c4 | 9.96622e-39 + \x0041ca76 | 6.041937e-39 + \x004b7678 | 6.930161e-39 + \x00000007 | 1e-44 + \x00424fe2 | 6.0898e-39 + \x007ffff0 | 1.1754921e-38 + \x007ffff1 | 1.1754922e-38 + \x007ffffe | 1.1754941e-38 + \x007fffff | 1.1754942e-38 (21 rows) rollback; @@ -924,269 +946,269 @@ select float4send(flt) as ibits, from (select bits::bit(32)::integer::xfloat4::float4 as flt from testdata offset 0) s; - ibits | flt | r_flt | obits | correct -------------+-------------+-------------+------------+--------- - \x00000000 | 0 | 0 | \x00000000 | t - \x00800000 | 1.17549e-38 | 1.17549e-38 | \x007fffe1 | f - \x00800001 | 1.17549e-38 | 1.17549e-38 | \x007fffe1 | f - \x00800004 | 1.17549e-38 | 1.17549e-38 | \x007fffe1 | f - \x00800005 | 1.1755e-38 | 1.1755e-38 | \x00800028 | f - \x00800006 | 1.1755e-38 | 1.1755e-38 | \x00800028 | f - \x008002f1 | 1.1756e-38 | 1.1756e-38 | \x008002f2 | f - \x008002f2 | 1.1756e-38 | 1.1756e-38 | \x008002f2 | t - \x008002f3 | 1.1756e-38 | 1.1756e-38 | \x008002f2 | f - \x00800e17 | 1.176e-38 | 1.176e-38 | \x00800e18 | f - \x00800e18 | 1.176e-38 | 1.176e-38 | \x00800e18 | t - \x00800e19 | 1.176e-38 | 1.176e-38 | \x00800e18 | f - \x01000001 | 2.35099e-38 | 2.35099e-38 | \x01000005 | f - \x01102843 | 2.64775e-38 | 2.64775e-38 | \x01102840 | f - \x01a52c98 | 6.06754e-38 | 6.06754e-38 | \x01a52c95 | f - \x0219c229 | 1.12964e-37 | 1.12964e-37 | \x0219c236 | f - \x02e4464d | 3.35419e-37 | 3.35419e-37 | \x02e4463b | f - \x037343c1 | 7.14891e-37 | 7.14891e-37 | \x037343ca | f - \x03a91b36 | 9.93917e-37 | 9.93917e-37 | \x03a91b31 | f - \x047ada65 | 2.94876e-36 | 2.94876e-36 | \x047ada4e | f - \x0496fe87 | 3.54986e-36 | 3.54986e-36 | \x0496fe8d | f - \x0550844f | 9.80441e-36 | 9.80441e-36 | \x05508449 | f - \x05999da3 | 1.4446e-35 | 1.4446e-35 | \x05999dc1 | f - \x060ea5e2 | 2.68291e-35 | 2.68291e-35 | \x060ea5e1 | f - \x06e63c45 | 8.66049e-35 | 8.66049e-35 | \x06e63c3e | f - \x07f1e548 | 3.63964e-34 | 3.63964e-34 | \x07f1e544 | f - \x0fc5282b | 1.94412e-29 | 1.94412e-29 | \x0fc5283e | f - \x1f850283 | 5.63318e-20 | 5.63318e-20 | \x1f85027c | f - \x2874a9d6 | 1.35815e-14 | 1.35815e-14 | \x2874a99d | f - \x3356bf94 | 5e-08 | 5e-08 | \x3356bf95 | f - \x3356bf95 | 5e-08 | 5e-08 | \x3356bf95 | t - \x3356bf96 | 5e-08 | 5e-08 | \x3356bf95 | f - \x33d6bf94 | 1e-07 | 1e-07 | \x33d6bf95 | f - \x33d6bf95 | 1e-07 | 1e-07 | \x33d6bf95 | t - \x33d6bf96 | 1e-07 | 1e-07 | \x33d6bf95 | f - \x34a10faf | 3e-07 | 3e-07 | \x34a10fb0 | f - \x34a10fb0 | 3e-07 | 3e-07 | \x34a10fb0 | t - \x34a10fb1 | 3e-07 | 3e-07 | \x34a10fb0 | f - \x350637bc | 5e-07 | 5e-07 | \x350637bd | f - \x350637bd | 5e-07 | 5e-07 | \x350637bd | t - \x350637be | 5e-07 | 5e-07 | \x350637bd | f - \x35719786 | 9e-07 | 9e-07 | \x35719787 | f - \x35719787 | 9e-07 | 9e-07 | \x35719787 | t - \x35719788 | 9e-07 | 9e-07 | \x35719787 | f - \x358637bc | 1e-06 | 1e-06 | \x358637bd | f - \x358637bd | 1e-06 | 1e-06 | \x358637bd | t - \x358637be | 1e-06 | 1e-06 | \x358637bd | f - \x36a7c5ab | 5e-06 | 5e-06 | \x36a7c5ac | f - \x36a7c5ac | 5e-06 | 5e-06 | \x36a7c5ac | t - \x36a7c5ad | 5e-06 | 5e-06 | \x36a7c5ac | f - \x3727c5ab | 1e-05 | 1e-05 | \x3727c5ac | f - \x3727c5ac | 1e-05 | 1e-05 | \x3727c5ac | t - \x3727c5ad | 1e-05 | 1e-05 | \x3727c5ac | f - \x38d1b714 | 0.0001 | 0.0001 | \x38d1b717 | f - \x38d1b715 | 0.0001 | 0.0001 | \x38d1b717 | f - \x38d1b716 | 0.0001 | 0.0001 | \x38d1b717 | f - \x38d1b717 | 0.0001 | 0.0001 | \x38d1b717 | t - \x38d1b718 | 0.0001 | 0.0001 | \x38d1b717 | f - \x38d1b719 | 0.0001 | 0.0001 | \x38d1b717 | f - \x38d1b71a | 0.0001 | 0.0001 | \x38d1b717 | f - \x38d1b71b | 0.0001 | 0.0001 | \x38d1b717 | f - \x38d1b71c | 0.0001 | 0.0001 | \x38d1b717 | f - \x38d1b71d | 0.0001 | 0.0001 | \x38d1b717 | f - \x38dffffe | 0.000106812 | 0.000106812 | \x38e00041 | f - \x38dfffff | 0.000106812 | 0.000106812 | \x38e00041 | f - \x38e00000 | 0.000106812 | 0.000106812 | \x38e00041 | f - \x38efffff | 0.000114441 | 0.000114441 | \x38f0000b | f - \x38f00000 | 0.000114441 | 0.000114441 | \x38f0000b | f - \x38f00001 | 0.000114441 | 0.000114441 | \x38f0000b | f - \x3a83126e | 0.001 | 0.001 | \x3a83126f | f - \x3a83126f | 0.001 | 0.001 | \x3a83126f | t - \x3a831270 | 0.001 | 0.001 | \x3a83126f | f - \x3c23d709 | 0.01 | 0.01 | \x3c23d70a | f - \x3c23d70a | 0.01 | 0.01 | \x3c23d70a | t - \x3c23d70b | 0.01 | 0.01 | \x3c23d70a | f - \x3dcccccc | 0.1 | 0.1 | \x3dcccccd | f - \x3dcccccd | 0.1 | 0.1 | \x3dcccccd | t - \x3dccccce | 0.1 | 0.1 | \x3dcccccd | f - \x3dcccd6f | 0.100001 | 0.100001 | \x3dcccd53 | f - \x3dcccd70 | 0.100001 | 0.100001 | \x3dcccd53 | f - \x3dcccd71 | 0.100001 | 0.100001 | \x3dcccd53 | f - \x3effffff | 0.5 | 0.5 | \x3f000000 | f - \x3f000000 | 0.5 | 0.5 | \x3f000000 | t - \x3f000001 | 0.5 | 0.5 | \x3f000000 | f - \x3f333332 | 0.7 | 0.7 | \x3f333333 | f - \x3f333333 | 0.7 | 0.7 | \x3f333333 | t - \x3f333334 | 0.7 | 0.7 | \x3f333333 | f - \x3f666665 | 0.9 | 0.9 | \x3f666666 | f - \x3f666666 | 0.9 | 0.9 | \x3f666666 | t - \x3f666667 | 0.9 | 0.9 | \x3f666666 | f - \x3f7d70a3 | 0.99 | 0.99 | \x3f7d70a4 | f - \x3f7d70a4 | 0.99 | 0.99 | \x3f7d70a4 | t - \x3f7d70a5 | 0.99 | 0.99 | \x3f7d70a4 | f - \x3f7fbe76 | 0.999 | 0.999 | \x3f7fbe77 | f - \x3f7fbe77 | 0.999 | 0.999 | \x3f7fbe77 | t - \x3f7fbe78 | 0.999 | 0.999 | \x3f7fbe77 | f - \x3f7ff971 | 0.9999 | 0.9999 | \x3f7ff972 | f - \x3f7ff972 | 0.9999 | 0.9999 | \x3f7ff972 | t - \x3f7ff973 | 0.9999 | 0.9999 | \x3f7ff972 | f - \x3f7fff57 | 0.99999 | 0.99999 | \x3f7fff58 | f - \x3f7fff58 | 0.99999 | 0.99999 | \x3f7fff58 | t - \x3f7fff59 | 0.99999 | 0.99999 | \x3f7fff58 | f - \x3f7fffee | 0.999999 | 0.999999 | \x3f7fffef | f - \x3f7fffef | 0.999999 | 0.999999 | \x3f7fffef | t - \x3f7ffff0 | 0.999999 | 0.999999 | \x3f7fffef | f - \x3f7ffff1 | 0.999999 | 0.999999 | \x3f7fffef | f - \x3f7ffff2 | 0.999999 | 0.999999 | \x3f7fffef | f - \x3f7ffff3 | 0.999999 | 0.999999 | \x3f7fffef | f - \x3f7ffff4 | 0.999999 | 0.999999 | \x3f7fffef | f - \x3f7ffff5 | 0.999999 | 0.999999 | \x3f7fffef | f - \x3f7ffff6 | 0.999999 | 0.999999 | \x3f7fffef | f - \x3f7ffff7 | 0.999999 | 0.999999 | \x3f7fffef | f - \x3f7ffff8 | 1 | 1 | \x3f800000 | f - \x3f7ffff9 | 1 | 1 | \x3f800000 | f - \x3f7ffffa | 1 | 1 | \x3f800000 | f - \x3f7ffffb | 1 | 1 | \x3f800000 | f - \x3f7ffffc | 1 | 1 | \x3f800000 | f - \x3f7ffffd | 1 | 1 | \x3f800000 | f - \x3f7ffffe | 1 | 1 | \x3f800000 | f - \x3f7fffff | 1 | 1 | \x3f800000 | f - \x3f800000 | 1 | 1 | \x3f800000 | t - \x3f800001 | 1 | 1 | \x3f800000 | f - \x3f800002 | 1 | 1 | \x3f800000 | f - \x3f800003 | 1 | 1 | \x3f800000 | f - \x3f800004 | 1 | 1 | \x3f800000 | f - \x3f800005 | 1 | 1 | \x3f800000 | f - \x3f800006 | 1 | 1 | \x3f800000 | f - \x3f800007 | 1 | 1 | \x3f800000 | f - \x3f800008 | 1 | 1 | \x3f800000 | f - \x3f800009 | 1 | 1 | \x3f800000 | f - \x3f80000f | 1 | 1 | \x3f800000 | f - \x3f800010 | 1 | 1 | \x3f800000 | f - \x3f800011 | 1 | 1 | \x3f800000 | f - \x3f800012 | 1 | 1 | \x3f800000 | f - \x3f800013 | 1 | 1 | \x3f800000 | f - \x3f800014 | 1 | 1 | \x3f800000 | f - \x3f800017 | 1 | 1 | \x3f800000 | f - \x3f800018 | 1 | 1 | \x3f800000 | f - \x3f800019 | 1 | 1 | \x3f800000 | f - \x3f80001a | 1 | 1 | \x3f800000 | f - \x3f80001b | 1 | 1 | \x3f800000 | f - \x3f80001c | 1 | 1 | \x3f800000 | f - \x3f800029 | 1 | 1 | \x3f800000 | f - \x3f80002a | 1.00001 | 1.00001 | \x3f800054 | f - \x3f80002b | 1.00001 | 1.00001 | \x3f800054 | f - \x3f800053 | 1.00001 | 1.00001 | \x3f800054 | f - \x3f800054 | 1.00001 | 1.00001 | \x3f800054 | t - \x3f800055 | 1.00001 | 1.00001 | \x3f800054 | f - \x3f800346 | 1.0001 | 1.0001 | \x3f800347 | f - \x3f800347 | 1.0001 | 1.0001 | \x3f800347 | t - \x3f800348 | 1.0001 | 1.0001 | \x3f800347 | f - \x3f8020c4 | 1.001 | 1.001 | \x3f8020c5 | f - \x3f8020c5 | 1.001 | 1.001 | \x3f8020c5 | t - \x3f8020c6 | 1.001 | 1.001 | \x3f8020c5 | f - \x3f8147ad | 1.01 | 1.01 | \x3f8147ae | f - \x3f8147ae | 1.01 | 1.01 | \x3f8147ae | t - \x3f8147af | 1.01 | 1.01 | \x3f8147ae | f - \x3f8ccccc | 1.1 | 1.1 | \x3f8ccccd | f - \x3f8ccccd | 1.1 | 1.1 | \x3f8ccccd | t - \x3f8cccce | 1.1 | 1.1 | \x3f8ccccd | f - \x3fc90fdb | 1.5708 | 1.5708 | \x3fc90ff9 | f - \x402df854 | 2.71828 | 2.71828 | \x402df84d | f - \x40490fdb | 3.14159 | 3.14159 | \x40490fd0 | f - \x409fffff | 5 | 5 | \x40a00000 | f - \x40a00000 | 5 | 5 | \x40a00000 | t - \x40a00001 | 5 | 5 | \x40a00000 | f - \x40afffff | 5.5 | 5.5 | \x40b00000 | f - \x40b00000 | 5.5 | 5.5 | \x40b00000 | t - \x40b00001 | 5.5 | 5.5 | \x40b00000 | f - \x411fffff | 10 | 10 | \x41200000 | f - \x41200000 | 10 | 10 | \x41200000 | t - \x41200001 | 10 | 10 | \x41200000 | f - \x42c7ffff | 100 | 100 | \x42c80000 | f - \x42c80000 | 100 | 100 | \x42c80000 | t - \x42c80001 | 100 | 100 | \x42c80000 | f - \x4479ffff | 1000 | 1000 | \x447a0000 | f - \x447a0000 | 1000 | 1000 | \x447a0000 | t - \x447a0001 | 1000 | 1000 | \x447a0000 | f - \x461c3fff | 10000 | 10000 | \x461c4000 | f - \x461c4000 | 10000 | 10000 | \x461c4000 | t - \x461c4001 | 10000 | 10000 | \x461c4000 | f - \x47c34fff | 100000 | 100000 | \x47c35000 | f - \x47c35000 | 100000 | 100000 | \x47c35000 | t - \x47c35001 | 100000 | 100000 | \x47c35000 | f - \x497423ff | 1e+06 | 1e+06 | \x49742400 | f - \x49742400 | 1e+06 | 1e+06 | \x49742400 | t - \x49742401 | 1e+06 | 1e+06 | \x49742400 | f - \x4b18967f | 1e+07 | 1e+07 | \x4b189680 | f - \x4b189680 | 1e+07 | 1e+07 | \x4b189680 | t - \x4b189681 | 1e+07 | 1e+07 | \x4b189680 | f - \x4cbebc1f | 1e+08 | 1e+08 | \x4cbebc20 | f - \x4cbebc20 | 1e+08 | 1e+08 | \x4cbebc20 | t - \x4cbebc21 | 1e+08 | 1e+08 | \x4cbebc20 | f - \x4e6e6b27 | 1e+09 | 1e+09 | \x4e6e6b28 | f - \x4e6e6b28 | 1e+09 | 1e+09 | \x4e6e6b28 | t - \x4e6e6b29 | 1e+09 | 1e+09 | \x4e6e6b28 | f - \x501502f8 | 1e+10 | 1e+10 | \x501502f9 | f - \x501502f9 | 1e+10 | 1e+10 | \x501502f9 | t - \x501502fa | 1e+10 | 1e+10 | \x501502f9 | f - \x51ba43b6 | 1e+11 | 1e+11 | \x51ba43b7 | f - \x51ba43b7 | 1e+11 | 1e+11 | \x51ba43b7 | t - \x51ba43b8 | 1e+11 | 1e+11 | \x51ba43b7 | f - \x1f6c1e4a | 5e-20 | 5e-20 | \x1f6c1e4a | t - \x59be6cea | 6.7e+15 | 6.7e+15 | \x59be6cea | t - \x5d5ab6c4 | 9.85e+17 | 9.85e+17 | \x5d5ab6c4 | t - \x2cc4a9bd | 5.5895e-12 | 5.5895e-12 | \x2cc4a9bd | t - \x15ae43fd | 7.03853e-26 | 7.03853e-26 | \x15ae43fc | f - \x2cf757ca | 7.02991e-12 | 7.02991e-12 | \x2cf757cd | f - \x665ba998 | 2.59332e+23 | 2.59332e+23 | \x665ba9aa | f - \x743c3324 | 5.96429e+31 | 5.96429e+31 | \x743c3327 | f - \x47f1205a | 123457 | 123457 | \x47f12080 | f - \x4640e6ae | 12345.7 | 12345.7 | \x4640e6cd | f - \x449a5225 | 1234.57 | 1234.57 | \x449a523d | f - \x42f6e9d5 | 123.457 | 123.457 | \x42f6e9fc | f - \x414587dd | 12.3457 | 12.3457 | \x414587fd | f - \x3f9e064b | 1.23457 | 1.23457 | \x3f9e0664 | f - \x4c000004 | 3.35544e+07 | 3.35544e+07 | \x4bfffff0 | f - \x50061c46 | 9e+09 | 9e+09 | \x50061c46 | t - \x510006a8 | 3.43667e+10 | 3.43667e+10 | \x510006a4 | f - \x48951f84 | 305404 | 305404 | \x48951f80 | f - \x45fd1840 | 8099.03 | 8099.03 | \x45fd183d | f - \x39800000 | 0.000244141 | 0.000244141 | \x3980000d | f - \x3b200000 | 0.00244141 | 0.00244141 | \x3b200010 | f - \x3b900000 | 0.00439453 | 0.00439453 | \x3b8ffffd | f - \x3bd00000 | 0.00634766 | 0.00634766 | \x3bd00008 | f - \x63800000 | 4.72237e+21 | 4.72237e+21 | \x63800006 | f - \x4b000000 | 8.38861e+06 | 8.38861e+06 | \x4b000002 | f - \x4b800000 | 1.67772e+07 | 1.67772e+07 | \x4b7ffff0 | f - \x4c000001 | 3.35544e+07 | 3.35544e+07 | \x4bfffff0 | f - \x4c800b0d | 6.71315e+07 | 6.71315e+07 | \x4c800b0e | f - \x00d24584 | 1.93104e-38 | 1.93104e-38 | \x00d2458a | f - \x00d90b88 | 1.99324e-38 | 1.99324e-38 | \x00d90b6c | f - \x45803f34 | 4103.9 | 4103.9 | \x45803f33 | f - \x4f9f24f7 | 5.34e+09 | 5.34e+09 | \x4f9f24f8 | f - \x3a8722c3 | 0.001031 | 0.001031 | \x3a87229f | f - \x5c800041 | 2.88233e+17 | 2.88233e+17 | \x5c80004c | f - \x15ae43fd | 7.03853e-26 | 7.03853e-26 | \x15ae43fc | f - \x5d4cccfb | 9.2234e+17 | 9.2234e+17 | \x5d4cccf5 | f - \x4c800001 | 6.71089e+07 | 6.71089e+07 | \x4c800004 | f - \x57800ed8 | 2.81602e+14 | 2.81602e+14 | \x57800eca | f - \x5f000000 | 9.22337e+18 | 9.22337e+18 | \x5efffffc | f - \x700000f0 | 1.58461e+29 | 1.58461e+29 | \x700000f7 | f - \x5f23e9ac | 1.18112e+19 | 1.18112e+19 | \x5f23e9d0 | f - \x5e9502f9 | 5.36871e+18 | 5.36871e+18 | \x5e9502fb | f - \x5e8012b1 | 4.61432e+18 | 4.61432e+18 | \x5e8012b7 | f - \x3c000028 | 0.00781254 | 0.00781254 | \x3c00002b | f - \x60cde861 | 1.18698e+20 | 1.18698e+20 | \x60cde880 | f - \x03aa2a50 | 1.00014e-36 | 1.00014e-36 | \x03aa2a3e | f - \x43480000 | 200 | 200 | \x43480000 | t - \x4c000000 | 3.35544e+07 | 3.35544e+07 | \x4bfffff0 | f - \x5d1502f9 | 6.71089e+17 | 6.71089e+17 | \x5d1502fe | f - \x5d9502f9 | 1.34218e+18 | 1.34218e+18 | \x5d95030d | f - \x5e1502f9 | 2.68435e+18 | 2.68435e+18 | \x5e1502e8 | f - \x3f99999a | 1.2 | 1.2 | \x3f99999a | t - \x3f9d70a4 | 1.23 | 1.23 | \x3f9d70a4 | t - \x3f9df3b6 | 1.234 | 1.234 | \x3f9df3b6 | t - \x3f9e0419 | 1.2345 | 1.2345 | \x3f9e0419 | t - \x3f9e0610 | 1.23456 | 1.23456 | \x3f9e0610 | t - \x3f9e064b | 1.23457 | 1.23457 | \x3f9e0664 | f - \x3f9e0651 | 1.23457 | 1.23457 | \x3f9e0664 | f - \x03d20cfe | 1.23457e-36 | 1.23457e-36 | \x03d20d1b | f + ibits | flt | r_flt | obits | correct +------------+----------------+----------------+------------+--------- + \x00000000 | 0 | 0 | \x00000000 | t + \x00800000 | 1.1754944e-38 | 1.1754944e-38 | \x00800000 | t + \x00800001 | 1.1754945e-38 | 1.1754945e-38 | \x00800001 | t + \x00800004 | 1.1754949e-38 | 1.1754949e-38 | \x00800004 | t + \x00800005 | 1.175495e-38 | 1.175495e-38 | \x00800005 | t + \x00800006 | 1.1754952e-38 | 1.1754952e-38 | \x00800006 | t + \x008002f1 | 1.1755999e-38 | 1.1755999e-38 | \x008002f1 | t + \x008002f2 | 1.1756e-38 | 1.1756e-38 | \x008002f2 | t + \x008002f3 | 1.1756001e-38 | 1.1756001e-38 | \x008002f3 | t + \x00800e17 | 1.1759998e-38 | 1.1759998e-38 | \x00800e17 | t + \x00800e18 | 1.176e-38 | 1.176e-38 | \x00800e18 | t + \x00800e19 | 1.1760001e-38 | 1.1760001e-38 | \x00800e19 | t + \x01000001 | 2.350989e-38 | 2.350989e-38 | \x01000001 | t + \x01102843 | 2.647751e-38 | 2.647751e-38 | \x01102843 | t + \x01a52c98 | 6.0675416e-38 | 6.0675416e-38 | \x01a52c98 | t + \x0219c229 | 1.1296386e-37 | 1.1296386e-37 | \x0219c229 | t + \x02e4464d | 3.354194e-37 | 3.354194e-37 | \x02e4464d | t + \x037343c1 | 7.148906e-37 | 7.148906e-37 | \x037343c1 | t + \x03a91b36 | 9.939175e-37 | 9.939175e-37 | \x03a91b36 | t + \x047ada65 | 2.948764e-36 | 2.948764e-36 | \x047ada65 | t + \x0496fe87 | 3.5498577e-36 | 3.5498577e-36 | \x0496fe87 | t + \x0550844f | 9.804414e-36 | 9.804414e-36 | \x0550844f | t + \x05999da3 | 1.4445957e-35 | 1.4445957e-35 | \x05999da3 | t + \x060ea5e2 | 2.6829103e-35 | 2.6829103e-35 | \x060ea5e2 | t + \x06e63c45 | 8.660494e-35 | 8.660494e-35 | \x06e63c45 | t + \x07f1e548 | 3.639641e-34 | 3.639641e-34 | \x07f1e548 | t + \x0fc5282b | 1.9441172e-29 | 1.9441172e-29 | \x0fc5282b | t + \x1f850283 | 5.6331846e-20 | 5.6331846e-20 | \x1f850283 | t + \x2874a9d6 | 1.3581548e-14 | 1.3581548e-14 | \x2874a9d6 | t + \x3356bf94 | 4.9999997e-08 | 4.9999997e-08 | \x3356bf94 | t + \x3356bf95 | 5e-08 | 5e-08 | \x3356bf95 | t + \x3356bf96 | 5.0000004e-08 | 5.0000004e-08 | \x3356bf96 | t + \x33d6bf94 | 9.9999994e-08 | 9.9999994e-08 | \x33d6bf94 | t + \x33d6bf95 | 1e-07 | 1e-07 | \x33d6bf95 | t + \x33d6bf96 | 1.0000001e-07 | 1.0000001e-07 | \x33d6bf96 | t + \x34a10faf | 2.9999998e-07 | 2.9999998e-07 | \x34a10faf | t + \x34a10fb0 | 3e-07 | 3e-07 | \x34a10fb0 | t + \x34a10fb1 | 3.0000004e-07 | 3.0000004e-07 | \x34a10fb1 | t + \x350637bc | 4.9999994e-07 | 4.9999994e-07 | \x350637bc | t + \x350637bd | 5e-07 | 5e-07 | \x350637bd | t + \x350637be | 5.0000006e-07 | 5.0000006e-07 | \x350637be | t + \x35719786 | 8.999999e-07 | 8.999999e-07 | \x35719786 | t + \x35719787 | 9e-07 | 9e-07 | \x35719787 | t + \x35719788 | 9.0000003e-07 | 9.0000003e-07 | \x35719788 | t + \x358637bc | 9.999999e-07 | 9.999999e-07 | \x358637bc | t + \x358637bd | 1e-06 | 1e-06 | \x358637bd | t + \x358637be | 1.0000001e-06 | 1.0000001e-06 | \x358637be | t + \x36a7c5ab | 4.9999994e-06 | 4.9999994e-06 | \x36a7c5ab | t + \x36a7c5ac | 5e-06 | 5e-06 | \x36a7c5ac | t + \x36a7c5ad | 5.0000003e-06 | 5.0000003e-06 | \x36a7c5ad | t + \x3727c5ab | 9.999999e-06 | 9.999999e-06 | \x3727c5ab | t + \x3727c5ac | 1e-05 | 1e-05 | \x3727c5ac | t + \x3727c5ad | 1.0000001e-05 | 1.0000001e-05 | \x3727c5ad | t + \x38d1b714 | 9.9999976e-05 | 9.9999976e-05 | \x38d1b714 | t + \x38d1b715 | 9.999998e-05 | 9.999998e-05 | \x38d1b715 | t + \x38d1b716 | 9.999999e-05 | 9.999999e-05 | \x38d1b716 | t + \x38d1b717 | 0.0001 | 0.0001 | \x38d1b717 | t + \x38d1b718 | 0.000100000005 | 0.000100000005 | \x38d1b718 | t + \x38d1b719 | 0.00010000001 | 0.00010000001 | \x38d1b719 | t + \x38d1b71a | 0.00010000002 | 0.00010000002 | \x38d1b71a | t + \x38d1b71b | 0.00010000003 | 0.00010000003 | \x38d1b71b | t + \x38d1b71c | 0.000100000034 | 0.000100000034 | \x38d1b71c | t + \x38d1b71d | 0.00010000004 | 0.00010000004 | \x38d1b71d | t + \x38dffffe | 0.00010681151 | 0.00010681151 | \x38dffffe | t + \x38dfffff | 0.000106811516 | 0.000106811516 | \x38dfffff | t + \x38e00000 | 0.00010681152 | 0.00010681152 | \x38e00000 | t + \x38efffff | 0.00011444091 | 0.00011444091 | \x38efffff | t + \x38f00000 | 0.00011444092 | 0.00011444092 | \x38f00000 | t + \x38f00001 | 0.000114440925 | 0.000114440925 | \x38f00001 | t + \x3a83126e | 0.0009999999 | 0.0009999999 | \x3a83126e | t + \x3a83126f | 0.001 | 0.001 | \x3a83126f | t + \x3a831270 | 0.0010000002 | 0.0010000002 | \x3a831270 | t + \x3c23d709 | 0.009999999 | 0.009999999 | \x3c23d709 | t + \x3c23d70a | 0.01 | 0.01 | \x3c23d70a | t + \x3c23d70b | 0.010000001 | 0.010000001 | \x3c23d70b | t + \x3dcccccc | 0.099999994 | 0.099999994 | \x3dcccccc | t + \x3dcccccd | 0.1 | 0.1 | \x3dcccccd | t + \x3dccccce | 0.10000001 | 0.10000001 | \x3dccccce | t + \x3dcccd6f | 0.10000121 | 0.10000121 | \x3dcccd6f | t + \x3dcccd70 | 0.100001216 | 0.100001216 | \x3dcccd70 | t + \x3dcccd71 | 0.10000122 | 0.10000122 | \x3dcccd71 | t + \x3effffff | 0.49999997 | 0.49999997 | \x3effffff | t + \x3f000000 | 0.5 | 0.5 | \x3f000000 | t + \x3f000001 | 0.50000006 | 0.50000006 | \x3f000001 | t + \x3f333332 | 0.6999999 | 0.6999999 | \x3f333332 | t + \x3f333333 | 0.7 | 0.7 | \x3f333333 | t + \x3f333334 | 0.70000005 | 0.70000005 | \x3f333334 | t + \x3f666665 | 0.8999999 | 0.8999999 | \x3f666665 | t + \x3f666666 | 0.9 | 0.9 | \x3f666666 | t + \x3f666667 | 0.90000004 | 0.90000004 | \x3f666667 | t + \x3f7d70a3 | 0.98999995 | 0.98999995 | \x3f7d70a3 | t + \x3f7d70a4 | 0.99 | 0.99 | \x3f7d70a4 | t + \x3f7d70a5 | 0.99000007 | 0.99000007 | \x3f7d70a5 | t + \x3f7fbe76 | 0.99899995 | 0.99899995 | \x3f7fbe76 | t + \x3f7fbe77 | 0.999 | 0.999 | \x3f7fbe77 | t + \x3f7fbe78 | 0.9990001 | 0.9990001 | \x3f7fbe78 | t + \x3f7ff971 | 0.9998999 | 0.9998999 | \x3f7ff971 | t + \x3f7ff972 | 0.9999 | 0.9999 | \x3f7ff972 | t + \x3f7ff973 | 0.99990004 | 0.99990004 | \x3f7ff973 | t + \x3f7fff57 | 0.9999899 | 0.9999899 | \x3f7fff57 | t + \x3f7fff58 | 0.99999 | 0.99999 | \x3f7fff58 | t + \x3f7fff59 | 0.99999005 | 0.99999005 | \x3f7fff59 | t + \x3f7fffee | 0.9999989 | 0.9999989 | \x3f7fffee | t + \x3f7fffef | 0.999999 | 0.999999 | \x3f7fffef | t + \x3f7ffff0 | 0.99999905 | 0.99999905 | \x3f7ffff0 | t + \x3f7ffff1 | 0.9999991 | 0.9999991 | \x3f7ffff1 | t + \x3f7ffff2 | 0.99999917 | 0.99999917 | \x3f7ffff2 | t + \x3f7ffff3 | 0.9999992 | 0.9999992 | \x3f7ffff3 | t + \x3f7ffff4 | 0.9999993 | 0.9999993 | \x3f7ffff4 | t + \x3f7ffff5 | 0.99999934 | 0.99999934 | \x3f7ffff5 | t + \x3f7ffff6 | 0.9999994 | 0.9999994 | \x3f7ffff6 | t + \x3f7ffff7 | 0.99999946 | 0.99999946 | \x3f7ffff7 | t + \x3f7ffff8 | 0.9999995 | 0.9999995 | \x3f7ffff8 | t + \x3f7ffff9 | 0.9999996 | 0.9999996 | \x3f7ffff9 | t + \x3f7ffffa | 0.99999964 | 0.99999964 | \x3f7ffffa | t + \x3f7ffffb | 0.9999997 | 0.9999997 | \x3f7ffffb | t + \x3f7ffffc | 0.99999976 | 0.99999976 | \x3f7ffffc | t + \x3f7ffffd | 0.9999998 | 0.9999998 | \x3f7ffffd | t + \x3f7ffffe | 0.9999999 | 0.9999999 | \x3f7ffffe | t + \x3f7fffff | 0.99999994 | 0.99999994 | \x3f7fffff | t + \x3f800000 | 1 | 1 | \x3f800000 | t + \x3f800001 | 1.0000001 | 1.0000001 | \x3f800001 | t + \x3f800002 | 1.0000002 | 1.0000002 | \x3f800002 | t + \x3f800003 | 1.0000004 | 1.0000004 | \x3f800003 | t + \x3f800004 | 1.0000005 | 1.0000005 | \x3f800004 | t + \x3f800005 | 1.0000006 | 1.0000006 | \x3f800005 | t + \x3f800006 | 1.0000007 | 1.0000007 | \x3f800006 | t + \x3f800007 | 1.0000008 | 1.0000008 | \x3f800007 | t + \x3f800008 | 1.000001 | 1.000001 | \x3f800008 | t + \x3f800009 | 1.0000011 | 1.0000011 | \x3f800009 | t + \x3f80000f | 1.0000018 | 1.0000018 | \x3f80000f | t + \x3f800010 | 1.0000019 | 1.0000019 | \x3f800010 | t + \x3f800011 | 1.000002 | 1.000002 | \x3f800011 | t + \x3f800012 | 1.0000021 | 1.0000021 | \x3f800012 | t + \x3f800013 | 1.0000023 | 1.0000023 | \x3f800013 | t + \x3f800014 | 1.0000024 | 1.0000024 | \x3f800014 | t + \x3f800017 | 1.0000027 | 1.0000027 | \x3f800017 | t + \x3f800018 | 1.0000029 | 1.0000029 | \x3f800018 | t + \x3f800019 | 1.000003 | 1.000003 | \x3f800019 | t + \x3f80001a | 1.0000031 | 1.0000031 | \x3f80001a | t + \x3f80001b | 1.0000032 | 1.0000032 | \x3f80001b | t + \x3f80001c | 1.0000033 | 1.0000033 | \x3f80001c | t + \x3f800029 | 1.0000049 | 1.0000049 | \x3f800029 | t + \x3f80002a | 1.000005 | 1.000005 | \x3f80002a | t + \x3f80002b | 1.0000051 | 1.0000051 | \x3f80002b | t + \x3f800053 | 1.0000099 | 1.0000099 | \x3f800053 | t + \x3f800054 | 1.00001 | 1.00001 | \x3f800054 | t + \x3f800055 | 1.0000101 | 1.0000101 | \x3f800055 | t + \x3f800346 | 1.0000999 | 1.0000999 | \x3f800346 | t + \x3f800347 | 1.0001 | 1.0001 | \x3f800347 | t + \x3f800348 | 1.0001001 | 1.0001001 | \x3f800348 | t + \x3f8020c4 | 1.0009999 | 1.0009999 | \x3f8020c4 | t + \x3f8020c5 | 1.001 | 1.001 | \x3f8020c5 | t + \x3f8020c6 | 1.0010002 | 1.0010002 | \x3f8020c6 | t + \x3f8147ad | 1.0099999 | 1.0099999 | \x3f8147ad | t + \x3f8147ae | 1.01 | 1.01 | \x3f8147ae | t + \x3f8147af | 1.0100001 | 1.0100001 | \x3f8147af | t + \x3f8ccccc | 1.0999999 | 1.0999999 | \x3f8ccccc | t + \x3f8ccccd | 1.1 | 1.1 | \x3f8ccccd | t + \x3f8cccce | 1.1000001 | 1.1000001 | \x3f8cccce | t + \x3fc90fdb | 1.5707964 | 1.5707964 | \x3fc90fdb | t + \x402df854 | 2.7182817 | 2.7182817 | \x402df854 | t + \x40490fdb | 3.1415927 | 3.1415927 | \x40490fdb | t + \x409fffff | 4.9999995 | 4.9999995 | \x409fffff | t + \x40a00000 | 5 | 5 | \x40a00000 | t + \x40a00001 | 5.0000005 | 5.0000005 | \x40a00001 | t + \x40afffff | 5.4999995 | 5.4999995 | \x40afffff | t + \x40b00000 | 5.5 | 5.5 | \x40b00000 | t + \x40b00001 | 5.5000005 | 5.5000005 | \x40b00001 | t + \x411fffff | 9.999999 | 9.999999 | \x411fffff | t + \x41200000 | 10 | 10 | \x41200000 | t + \x41200001 | 10.000001 | 10.000001 | \x41200001 | t + \x42c7ffff | 99.99999 | 99.99999 | \x42c7ffff | t + \x42c80000 | 100 | 100 | \x42c80000 | t + \x42c80001 | 100.00001 | 100.00001 | \x42c80001 | t + \x4479ffff | 999.99994 | 999.99994 | \x4479ffff | t + \x447a0000 | 1000 | 1000 | \x447a0000 | t + \x447a0001 | 1000.00006 | 1000.00006 | \x447a0001 | t + \x461c3fff | 9999.999 | 9999.999 | \x461c3fff | t + \x461c4000 | 10000 | 10000 | \x461c4000 | t + \x461c4001 | 10000.001 | 10000.001 | \x461c4001 | t + \x47c34fff | 99999.99 | 99999.99 | \x47c34fff | t + \x47c35000 | 100000 | 100000 | \x47c35000 | t + \x47c35001 | 100000.01 | 100000.01 | \x47c35001 | t + \x497423ff | 999999.94 | 999999.94 | \x497423ff | t + \x49742400 | 1e+06 | 1e+06 | \x49742400 | t + \x49742401 | 1.00000006e+06 | 1.00000006e+06 | \x49742401 | t + \x4b18967f | 9.999999e+06 | 9.999999e+06 | \x4b18967f | t + \x4b189680 | 1e+07 | 1e+07 | \x4b189680 | t + \x4b189681 | 1.0000001e+07 | 1.0000001e+07 | \x4b189681 | t + \x4cbebc1f | 9.999999e+07 | 9.999999e+07 | \x4cbebc1f | t + \x4cbebc20 | 1e+08 | 1e+08 | \x4cbebc20 | t + \x4cbebc21 | 1.0000001e+08 | 1.0000001e+08 | \x4cbebc21 | t + \x4e6e6b27 | 9.9999994e+08 | 9.9999994e+08 | \x4e6e6b27 | t + \x4e6e6b28 | 1e+09 | 1e+09 | \x4e6e6b28 | t + \x4e6e6b29 | 1.00000006e+09 | 1.00000006e+09 | \x4e6e6b29 | t + \x501502f8 | 9.999999e+09 | 9.999999e+09 | \x501502f8 | t + \x501502f9 | 1e+10 | 1e+10 | \x501502f9 | t + \x501502fa | 1.0000001e+10 | 1.0000001e+10 | \x501502fa | t + \x51ba43b6 | 9.999999e+10 | 9.999999e+10 | \x51ba43b6 | t + \x51ba43b7 | 1e+11 | 1e+11 | \x51ba43b7 | t + \x51ba43b8 | 1.0000001e+11 | 1.0000001e+11 | \x51ba43b8 | t + \x1f6c1e4a | 5e-20 | 5e-20 | \x1f6c1e4a | t + \x59be6cea | 6.7e+15 | 6.7e+15 | \x59be6cea | t + \x5d5ab6c4 | 9.85e+17 | 9.85e+17 | \x5d5ab6c4 | t + \x2cc4a9bd | 5.5895e-12 | 5.5895e-12 | \x2cc4a9bd | t + \x15ae43fd | 7.038531e-26 | 7.038531e-26 | \x15ae43fd | t + \x2cf757ca | 7.0299088e-12 | 7.0299088e-12 | \x2cf757ca | t + \x665ba998 | 2.5933168e+23 | 2.5933168e+23 | \x665ba998 | t + \x743c3324 | 5.9642887e+31 | 5.9642887e+31 | \x743c3324 | t + \x47f1205a | 123456.7 | 123456.7 | \x47f1205a | t + \x4640e6ae | 12345.67 | 12345.67 | \x4640e6ae | t + \x449a5225 | 1234.567 | 1234.567 | \x449a5225 | t + \x42f6e9d5 | 123.4567 | 123.4567 | \x42f6e9d5 | t + \x414587dd | 12.34567 | 12.34567 | \x414587dd | t + \x3f9e064b | 1.234567 | 1.234567 | \x3f9e064b | t + \x4c000004 | 3.3554448e+07 | 3.3554448e+07 | \x4c000004 | t + \x50061c46 | 8.999999e+09 | 8.999999e+09 | \x50061c46 | t + \x510006a8 | 3.4366718e+10 | 3.4366718e+10 | \x510006a8 | t + \x48951f84 | 305404.12 | 305404.12 | \x48951f84 | t + \x45fd1840 | 8099.0312 | 8099.0312 | \x45fd1840 | t + \x39800000 | 0.00024414062 | 0.00024414062 | \x39800000 | t + \x3b200000 | 0.0024414062 | 0.0024414062 | \x3b200000 | t + \x3b900000 | 0.0043945312 | 0.0043945312 | \x3b900000 | t + \x3bd00000 | 0.0063476562 | 0.0063476562 | \x3bd00000 | t + \x63800000 | 4.7223665e+21 | 4.7223665e+21 | \x63800000 | t + \x4b000000 | 8.388608e+06 | 8.388608e+06 | \x4b000000 | t + \x4b800000 | 1.6777216e+07 | 1.6777216e+07 | \x4b800000 | t + \x4c000001 | 3.3554436e+07 | 3.3554436e+07 | \x4c000001 | t + \x4c800b0d | 6.7131496e+07 | 6.7131496e+07 | \x4c800b0d | t + \x00d24584 | 1.9310392e-38 | 1.9310392e-38 | \x00d24584 | t + \x00d90b88 | 1.993244e-38 | 1.993244e-38 | \x00d90b88 | t + \x45803f34 | 4103.9004 | 4103.9004 | \x45803f34 | t + \x4f9f24f7 | 5.3399997e+09 | 5.3399997e+09 | \x4f9f24f7 | t + \x3a8722c3 | 0.0010310042 | 0.0010310042 | \x3a8722c3 | t + \x5c800041 | 2.882326e+17 | 2.882326e+17 | \x5c800041 | t + \x15ae43fd | 7.038531e-26 | 7.038531e-26 | \x15ae43fd | t + \x5d4cccfb | 9.223404e+17 | 9.223404e+17 | \x5d4cccfb | t + \x4c800001 | 6.710887e+07 | 6.710887e+07 | \x4c800001 | t + \x57800ed8 | 2.816025e+14 | 2.816025e+14 | \x57800ed8 | t + \x5f000000 | 9.223372e+18 | 9.223372e+18 | \x5f000000 | t + \x700000f0 | 1.5846086e+29 | 1.5846086e+29 | \x700000f0 | t + \x5f23e9ac | 1.1811161e+19 | 1.1811161e+19 | \x5f23e9ac | t + \x5e9502f9 | 5.368709e+18 | 5.368709e+18 | \x5e9502f9 | t + \x5e8012b1 | 4.6143166e+18 | 4.6143166e+18 | \x5e8012b1 | t + \x3c000028 | 0.007812537 | 0.007812537 | \x3c000028 | t + \x60cde861 | 1.18697725e+20 | 1.18697725e+20 | \x60cde861 | t + \x03aa2a50 | 1.00014165e-36 | 1.00014165e-36 | \x03aa2a50 | t + \x43480000 | 200 | 200 | \x43480000 | t + \x4c000000 | 3.3554432e+07 | 3.3554432e+07 | \x4c000000 | t + \x5d1502f9 | 6.7108864e+17 | 6.7108864e+17 | \x5d1502f9 | t + \x5d9502f9 | 1.3421773e+18 | 1.3421773e+18 | \x5d9502f9 | t + \x5e1502f9 | 2.6843546e+18 | 2.6843546e+18 | \x5e1502f9 | t + \x3f99999a | 1.2 | 1.2 | \x3f99999a | t + \x3f9d70a4 | 1.23 | 1.23 | \x3f9d70a4 | t + \x3f9df3b6 | 1.234 | 1.234 | \x3f9df3b6 | t + \x3f9e0419 | 1.2345 | 1.2345 | \x3f9e0419 | t + \x3f9e0610 | 1.23456 | 1.23456 | \x3f9e0610 | t + \x3f9e064b | 1.234567 | 1.234567 | \x3f9e064b | t + \x3f9e0651 | 1.2345678 | 1.2345678 | \x3f9e0651 | t + \x03d20cfe | 1.23456735e-36 | 1.23456735e-36 | \x03d20cfe | t (261 rows) rollback; diff --git a/expected/15beta2/extra/float8.out b/expected/15beta2/extra/float8.out new file mode 100644 index 00000000..7b747c2f --- /dev/null +++ b/expected/15beta2/extra/float8.out @@ -0,0 +1,1963 @@ +-- +-- FLOAT8 +-- +--Testcase 113: +CREATE EXTENSION sqlite_fdw; +--Testcase 114: +CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw +OPTIONS (database '/tmp/sqlitefdw_test_core.db'); +--Testcase 115: +CREATE FOREIGN TABLE FLOAT8_TBL(f1 float8 OPTIONS (key 'true')) SERVER sqlite_svr; +--Testcase 116: +CREATE FOREIGN TABLE FLOAT8_TMP(f1 float8, f2 float8, id int OPTIONS (key 'true')) SERVER sqlite_svr; +--Testcase 1: +INSERT INTO FLOAT8_TBL(f1) VALUES (' 0.0 '); +--Testcase 2: +INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30 '); +--Testcase 3: +INSERT INTO FLOAT8_TBL(f1) VALUES (' -34.84'); +--Testcase 4: +INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200'); +--Testcase 5: +INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200'); +-- test for underflow and overflow handling +--Testcase 6: +INSERT INTO FLOAT8_TMP(f1) VALUES ('10e400'::float8); +ERROR: "10e400" is out of range for type double precision +LINE 1: INSERT INTO FLOAT8_TMP(f1) VALUES ('10e400'::float8); + ^ +--Testcase 7: +INSERT INTO FLOAT8_TMP(f1) VALUES ('-10e400'::float8); +ERROR: "-10e400" is out of range for type double precision +LINE 1: INSERT INTO FLOAT8_TMP(f1) VALUES ('-10e400'::float8); + ^ +--Testcase 8: +INSERT INTO FLOAT8_TMP(f1) VALUES ('10e-400'::float8); +ERROR: "10e-400" is out of range for type double precision +LINE 1: INSERT INTO FLOAT8_TMP(f1) VALUES ('10e-400'::float8); + ^ +--Testcase 9: +INSERT INTO FLOAT8_TMP(f1) VALUES ('-10e-400'::float8); +ERROR: "-10e-400" is out of range for type double precision +LINE 1: INSERT INTO FLOAT8_TMP(f1) VALUES ('-10e-400'::float8); + ^ +-- test smallest normalized input +--Testcase 117: +INSERT INTO FLOAT8_TMP(f1) VALUES ('2.2250738585072014E-308'::float8); +--Testcase 118: +SELECT float8send(f1) FROM FLOAT8_TMP; + float8send +-------------------- + \x0010000000000000 +(1 row) + +-- bad input +--Testcase 10: +INSERT INTO FLOAT8_TBL(f1) VALUES (''); +ERROR: invalid input syntax for type double precision: "" +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES (''); + ^ +--Testcase 11: +INSERT INTO FLOAT8_TBL(f1) VALUES (' '); +ERROR: invalid input syntax for type double precision: " " +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES (' '); + ^ +--Testcase 12: +INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz'); +ERROR: invalid input syntax for type double precision: "xyz" +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz'); + ^ +--Testcase 13: +INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0'); +ERROR: invalid input syntax for type double precision: "5.0.0" +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0'); + ^ +--Testcase 14: +INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0'); +ERROR: invalid input syntax for type double precision: "5 . 0" +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0'); + ^ +--Testcase 15: +INSERT INTO FLOAT8_TBL(f1) VALUES ('5. 0'); +ERROR: invalid input syntax for type double precision: "5. 0" +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('5. 0'); + ^ +--Testcase 16: +INSERT INTO FLOAT8_TBL(f1) VALUES (' - 3'); +ERROR: invalid input syntax for type double precision: " - 3" +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES (' - 3'); + ^ +--Testcase 17: +INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5'); +ERROR: invalid input syntax for type double precision: "123 5" +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5'); + ^ +-- special inputs +--Testcase 19: +DELETE FROM FLOAT8_TMP; +--Testcase 119: +INSERT INTO FLOAT8_TMP VALUES ('NaN'::float8); +--Testcase 120: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- + +(1 row) + +--Testcase 20: +DELETE FROM FLOAT8_TMP; +--Testcase 121: +INSERT INTO FLOAT8_TMP VALUES ('nan'::float8); +--Testcase 122: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- + +(1 row) + +--Testcase 21: +DELETE FROM FLOAT8_TMP; +--Testcase 123: +INSERT INTO FLOAT8_TMP VALUES (' NAN '::float8); +--Testcase 124: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- + +(1 row) + +--Testcase 22: +DELETE FROM FLOAT8_TMP; +--Testcase 125: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8); +--Testcase 126: +SELECT f1 FROM FLOAT8_TMP; + f1 +---------- + Infinity +(1 row) + +--Testcase 23: +DELETE FROM FLOAT8_TMP; +--Testcase 127: +INSERT INTO FLOAT8_TMP VALUES (' -INFINiTY '::float8); +--Testcase 128: +SELECT f1 FROM FLOAT8_TMP; + f1 +----------- + -Infinity +(1 row) + +-- bad special inputs +--Testcase 25: +DELETE FROM FLOAT8_TMP; +--Testcase 129: +INSERT INTO FLOAT8_TMP VALUES ('N A N'::float8); +ERROR: invalid input syntax for type double precision: "N A N" +LINE 1: INSERT INTO FLOAT8_TMP VALUES ('N A N'::float8); + ^ +--Testcase 130: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- +(0 rows) + +--Testcase 26: +DELETE FROM FLOAT8_TMP; +--Testcase 131: +INSERT INTO FLOAT8_TMP VALUES ('NaN x'::float8); +ERROR: invalid input syntax for type double precision: "NaN x" +LINE 1: INSERT INTO FLOAT8_TMP VALUES ('NaN x'::float8); + ^ +--Testcase 132: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- +(0 rows) + +--Testcase 27: +DELETE FROM FLOAT8_TMP; +--Testcase 133: +INSERT INTO FLOAT8_TMP VALUES (' INFINITY x'::float8); +ERROR: invalid input syntax for type double precision: " INFINITY x" +LINE 1: INSERT INTO FLOAT8_TMP VALUES (' INFINITY x'::float8); + ^ +--Testcase 134: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- +(0 rows) + +--Testcase 28: +DELETE FROM FLOAT8_TMP; +--Testcase 135: +INSERT INTO FLOAT8_TMP VALUES ('Infinity'::float8 + 100.0); +--Testcase 136: +SELECT f1 FROM FLOAT8_TMP; + f1 +---------- + Infinity +(1 row) + +--Testcase 30: +DELETE FROM FLOAT8_TMP; +--Testcase 137: +INSERT INTO FLOAT8_TMP VALUES ('Infinity'::float8 / 'Infinity'::float8); +--Testcase 138: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- + +(1 row) + +--Testcase 272: +DELETE FROM FLOAT8_TMP; +--Testcase 273: +INSERT INTO FLOAT8_TMP VALUES ('42'::float8 / 'Infinity'::float8); +--Testcase 274: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- + 0 +(1 row) + +--Testcase 31: +DELETE FROM FLOAT8_TMP; +--Testcase 139: +INSERT INTO FLOAT8_TMP VALUES ('nan'::float8 / 'nan'::float8); +--Testcase 140: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- + +(1 row) + +--Testcase 275: +DELETE FROM FLOAT8_TMP; +--Testcase 276: +INSERT INTO FLOAT8_TMP VALUES ('nan'::float8 / '0'::float8); +--Testcase 277: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- + +(1 row) + +--Testcase 32: +DELETE FROM FLOAT8_TMP; +--Testcase 141: +INSERT INTO FLOAT8_TMP VALUES ('nan'::numeric::float8); +--Testcase 142: +SELECT f1 FROM FLOAT8_TMP; + f1 +---- + +(1 row) + +--Testcase 34: +SELECT * FROM FLOAT8_TBL; + f1 +---------------------- + 0 + 1004.3 + -34.84 + 1.2345678901234e+200 + 1.2345678901234e-200 +(5 rows) + +--Testcase 35: +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3'; + f1 +---------------------- + 0 + -34.84 + 1.2345678901234e+200 + 1.2345678901234e-200 +(4 rows) + +--Testcase 36: +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3'; + f1 +-------- + 1004.3 +(1 row) + +--Testcase 37: +SELECT f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1; + f1 +---------------------- + 0 + -34.84 + 1.2345678901234e-200 +(3 rows) + +--Testcase 38: +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 < '1004.3'; + f1 +---------------------- + 0 + -34.84 + 1.2345678901234e-200 +(3 rows) + +--Testcase 39: +SELECT f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1; + f1 +---------------------- + 0 + 1004.3 + -34.84 + 1.2345678901234e-200 +(4 rows) + +--Testcase 40: +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3'; + f1 +---------------------- + 0 + 1004.3 + -34.84 + 1.2345678901234e-200 +(4 rows) + +--Testcase 41: +SELECT f.f1, f.f1 * '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0'; + f1 | x +----------------------+----------------------- + 1004.3 | -10043 + 1.2345678901234e+200 | -1.2345678901234e+201 + 1.2345678901234e-200 | -1.2345678901234e-199 +(3 rows) + +--Testcase 42: +SELECT f.f1, f.f1 + '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0'; + f1 | x +----------------------+---------------------- + 1004.3 | 994.3 + 1.2345678901234e+200 | 1.2345678901234e+200 + 1.2345678901234e-200 | -10 +(3 rows) + +--Testcase 43: +SELECT f.f1, f.f1 / '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0'; + f1 | x +----------------------+----------------------- + 1004.3 | -100.42999999999999 + 1.2345678901234e+200 | -1.2345678901234e+199 + 1.2345678901234e-200 | -1.2345678901234e-201 +(3 rows) + +--Testcase 44: +SELECT f.f1, f.f1 - '-10' AS x + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0'; + f1 | x +----------------------+---------------------- + 1004.3 | 1014.3 + 1.2345678901234e+200 | 1.2345678901234e+200 + 1.2345678901234e-200 | 10 +(3 rows) + +--Testcase 45: +SELECT f.f1 ^ '2.0' AS square_f1 + FROM FLOAT8_TBL f where f.f1 = '1004.3'; + square_f1 +-------------------- + 1008618.4899999999 +(1 row) + +-- absolute value +--Testcase 46: +SELECT f.f1, @f.f1 AS abs_f1 + FROM FLOAT8_TBL f; + f1 | abs_f1 +----------------------+---------------------- + 0 | 0 + 1004.3 | 1004.3 + -34.84 | 34.84 + 1.2345678901234e+200 | 1.2345678901234e+200 + 1.2345678901234e-200 | 1.2345678901234e-200 +(5 rows) + +-- truncate +--Testcase 47: +SELECT f.f1, trunc(f.f1) AS trunc_f1 + FROM FLOAT8_TBL f; + f1 | trunc_f1 +----------------------+---------------------- + 0 | 0 + 1004.3 | 1004 + -34.84 | -34 + 1.2345678901234e+200 | 1.2345678901234e+200 + 1.2345678901234e-200 | 0 +(5 rows) + +-- round +--Testcase 48: +SELECT f.f1, round(f.f1) AS round_f1 + FROM FLOAT8_TBL f; + f1 | round_f1 +----------------------+---------------------- + 0 | 0 + 1004.3 | 1004 + -34.84 | -35 + 1.2345678901234e+200 | 1.2345678901234e+200 + 1.2345678901234e-200 | 0 +(5 rows) + +-- ceil / ceiling +--Testcase 49: +select ceil(f1) as ceil_f1 from float8_tbl f; + ceil_f1 +---------------------- + 0 + 1005 + -34 + 1.2345678901234e+200 + 1 +(5 rows) + +--Testcase 50: +select ceiling(f1) as ceiling_f1 from float8_tbl f; + ceiling_f1 +---------------------- + 0 + 1005 + -34 + 1.2345678901234e+200 + 1 +(5 rows) + +-- floor +--Testcase 51: +select floor(f1) as floor_f1 from float8_tbl f; + floor_f1 +---------------------- + 0 + 1004 + -35 + 1.2345678901234e+200 + 0 +(5 rows) + +-- sign +--Testcase 52: +select sign(f1) as sign_f1 from float8_tbl f; + sign_f1 +--------- + 0 + 1 + -1 + 1 + 1 +(5 rows) + +-- avoid bit-exact output here because operations may not be bit-exact. +--Testcase 278: +SET extra_float_digits = 0; +-- square root +BEGIN; +--Testcase 53: +DELETE FROM FLOAT8_TBL; +--Testcase 54: +INSERT INTO FLOAT8_TBL VALUES ('64'::float8); +--Testcase 55: +SELECT sqrt(f1) as eight FROM FLOAT8_TBL; + eight +------- + 8 +(1 row) + +--Testcase 56: +SELECT |/f1 as eight FROM FLOAT8_TBL; + eight +------- + 8 +(1 row) + +ROLLBACK; +--Testcase 57: +SELECT f.f1, |/f.f1 AS sqrt_f1 + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0'; + f1 | sqrt_f1 +----------------------+----------------------- + 1004.3 | 31.6906926399535 + 1.2345678901234e+200 | 1.11111110611109e+100 + 1.2345678901234e-200 | 1.11111110611109e-100 +(3 rows) + +-- power +--Testcase 58: +DELETE FROM FLOAT8_TMP; +--Testcase 143: +INSERT INTO FLOAT8_TMP VALUES ('144'::float8, '0.5'::float8); +--Testcase 144: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 12 +(1 row) + +--Testcase 60: +DELETE FROM FLOAT8_TMP; +--Testcase 145: +INSERT INTO FLOAT8_TMP VALUES ('NaN'::float8, '0.5'::float8); +--Testcase 146: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + +(1 row) + +--Testcase 61: +DELETE FROM FLOAT8_TMP; +--Testcase 147: +INSERT INTO FLOAT8_TMP VALUES ('144'::float8, 'NaN'::float8); +--Testcase 148: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + +(1 row) + +--Testcase 62: +DELETE FROM FLOAT8_TMP; +--Testcase 149: +INSERT INTO FLOAT8_TMP VALUES ('NaN'::float8, 'NaN'::float8); +--Testcase 150: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + +(1 row) + +--Testcase 63: +DELETE FROM FLOAT8_TMP; +--Testcase 151: +INSERT INTO FLOAT8_TMP VALUES ('-1'::float8, 'NaN'::float8); +--Testcase 152: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + +(1 row) + +--Testcase 64: +DELETE FROM FLOAT8_TMP; +--Testcase 153: +INSERT INTO FLOAT8_TMP VALUES ('1'::float8, 'NaN'::float8); +--Testcase 154: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + +(1 row) + +--Testcase 65: +DELETE FROM FLOAT8_TMP; +--Testcase 155: +INSERT INTO FLOAT8_TMP VALUES ('NaN'::float8 , '0'::float8); +--Testcase 156: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + +(1 row) + +--Testcase 279: +DELETE FROM FLOAT8_TMP; +--Testcase 280: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8, '0'::float8); +--Testcase 281: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 1 +(1 row) + +--Testcase 282: +DELETE FROM FLOAT8_TMP; +--Testcase 283: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '0'::float8); +--Testcase 284: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 1 +(1 row) + +--Testcase 285: +DELETE FROM FLOAT8_TMP; +--Testcase 286: +INSERT INTO FLOAT8_TMP VALUES ('0'::float8, 'infinity'::float8); +--Testcase 287: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 0 +(1 row) + +--Testcase 288: +DELETE FROM FLOAT8_TMP; +--Testcase 289: +INSERT INTO FLOAT8_TMP VALUES ('0'::float8, '-infinity'::float8); +--Testcase 290: +SELECT power(f1, f2) FROM FLOAT8_TMP; +ERROR: zero raised to a negative power is undefined +--Testcase 291: +DELETE FROM FLOAT8_TMP; +--Testcase 292: +INSERT INTO FLOAT8_TMP VALUES ('1'::float8, 'infinity'::float8); +--Testcase 293: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 1 +(1 row) + +--Testcase 294: +DELETE FROM FLOAT8_TMP; +--Testcase 295: +INSERT INTO FLOAT8_TMP VALUES ('1'::float8, '-infinity'::float8); +--Testcase 296: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 1 +(1 row) + +--Testcase 297: +DELETE FROM FLOAT8_TMP; +--Testcase 298: +INSERT INTO FLOAT8_TMP VALUES ('-1'::float8, 'infinity'::float8); +--Testcase 299: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 1 +(1 row) + +--Testcase 300: +DELETE FROM FLOAT8_TMP; +--Testcase 301: +INSERT INTO FLOAT8_TMP VALUES ('-1'::float8, '-infinity'::float8); +--Testcase 302: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 1 +(1 row) + +--Testcase 303: +DELETE FROM FLOAT8_TMP; +--Testcase 304: +INSERT INTO FLOAT8_TMP VALUES ('0.1'::float8, 'infinity'::float8); +--Testcase 305: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 0 +(1 row) + +--Testcase 306: +DELETE FROM FLOAT8_TMP; +--Testcase 307: +INSERT INTO FLOAT8_TMP VALUES ('-0.1'::float8, 'infinity'::float8); +--Testcase 308: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 0 +(1 row) + +--Testcase 309: +DELETE FROM FLOAT8_TMP; +--Testcase 310: +INSERT INTO FLOAT8_TMP VALUES ('1.1'::float8, 'infinity'::float8); +--Testcase 311: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +---------- + Infinity +(1 row) + +--Testcase 312: +DELETE FROM FLOAT8_TMP; +--Testcase 313: +INSERT INTO FLOAT8_TMP VALUES ('-1.1'::float8, 'infinity'::float8); +--Testcase 314: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +---------- + Infinity +(1 row) + +--Testcase 315: +DELETE FROM FLOAT8_TMP; +--Testcase 316: +INSERT INTO FLOAT8_TMP VALUES ('0.1'::float8, '-infinity'::float8); +--Testcase 317: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +---------- + Infinity +(1 row) + +--Testcase 318: +DELETE FROM FLOAT8_TMP; +--Testcase 319: +INSERT INTO FLOAT8_TMP VALUES ('-0.1'::float8, '-infinity'::float8); +--Testcase 320: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +---------- + Infinity +(1 row) + +--Testcase 321: +DELETE FROM FLOAT8_TMP; +--Testcase 322: +INSERT INTO FLOAT8_TMP VALUES ('1.1'::float8, '-infinity'::float8); +--Testcase 323: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 0 +(1 row) + +--Testcase 324: +DELETE FROM FLOAT8_TMP; +--Testcase 325: +INSERT INTO FLOAT8_TMP VALUES ('-1.1'::float8, '-infinity'::float8); +--Testcase 326: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 0 +(1 row) + +--Testcase 327: +DELETE FROM FLOAT8_TMP; +--Testcase 328: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8, '-2'::float8); +--Testcase 329: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 0 +(1 row) + +--Testcase 330: +DELETE FROM FLOAT8_TMP; +--Testcase 331: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8, '2'::float8); +--Testcase 332: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +---------- + Infinity +(1 row) + +--Testcase 333: +DELETE FROM FLOAT8_TMP; +--Testcase 334: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8, 'infinity'::float8); +--Testcase 335: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +---------- + Infinity +(1 row) + +--Testcase 336: +DELETE FROM FLOAT8_TMP; +--Testcase 337: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8, '-infinity'::float8); +--Testcase 338: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 0 +(1 row) + +-- Intel's icc misoptimizes the code that controls the sign of this result, +-- even with -mp1. Pending a fix for that, only test for "is it zero". +--Testcase 339: +DELETE FROM FLOAT8_TMP; +--Testcase 340: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '-2'::float8); +--Testcase 341: +SELECT power(f1, f2) = '0' FROM FLOAT8_TMP; + ?column? +---------- + t +(1 row) + +--Testcase 342: +DELETE FROM FLOAT8_TMP; +--Testcase 343: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '-3'::float8); +--Testcase 344: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + -0 +(1 row) + +--Testcase 345: +DELETE FROM FLOAT8_TMP; +--Testcase 346: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '2'::float8); +--Testcase 347: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +---------- + Infinity +(1 row) + +--Testcase 348: +DELETE FROM FLOAT8_TMP; +--Testcase 349: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '3'::float8); +--Testcase 350: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +----------- + -Infinity +(1 row) + +--Testcase 351: +DELETE FROM FLOAT8_TMP; +--Testcase 352: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '-3.5'::float8); +--Testcase 353: +SELECT power(f1, f2) FROM FLOAT8_TMP; +ERROR: a negative number raised to a non-integer power yields a complex result +--Testcase 354: +DELETE FROM FLOAT8_TMP; +--Testcase 355: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, 'infinity'::float8); +--Testcase 356: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +---------- + Infinity +(1 row) + +--Testcase 357: +DELETE FROM FLOAT8_TMP; +--Testcase 358: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '-infinity'::float8); +--Testcase 359: +SELECT power(f1, f2) FROM FLOAT8_TMP; + power +------- + 0 +(1 row) + +-- take exp of ln(f.f1) +--Testcase 67: +SELECT f.f1, exp(ln(f.f1)) AS exp_ln_f1 + FROM FLOAT8_TBL f + WHERE f.f1 > '0.0'; + f1 | exp_ln_f1 +----------------------+----------------------- + 1004.3 | 1004.3 + 1.2345678901234e+200 | 1.23456789012338e+200 + 1.2345678901234e-200 | 1.23456789012339e-200 +(3 rows) + +-- check edge cases for exp +--Testcase 360: +DELETE FROM FLOAT8_TMP; +--Testcase 361: +INSERT INTO FLOAT8_TMP VALUES ('inf'::float8), ('-inf'::float8), ('nan'::float8); +--Testcase 362: +SELECT exp(f1) FROM FLOAT8_TMP; + exp +---------- + Infinity + 0 + +(3 rows) + +-- cube root +BEGIN; +--Testcase 68: +DELETE FROM FLOAT8_TBL; +--Testcase 69: +INSERT INTO FLOAT8_TBL VALUES ('27'::float8); +--Testcase 70: +SELECT ||/f1 as three FROM FLOAT8_TBL; + three +------- + 3 +(1 row) + +ROLLBACK; +--Testcase 71: +SELECT f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f; + f1 | cbrt_f1 +----------------------+---------------------- + 0 | 0 + 1004.3 | 10.014312837827 + -34.84 | -3.26607421344208 + 1.2345678901234e+200 | 4.97933859234765e+66 + 1.2345678901234e-200 | 2.3112042409018e-67 +(5 rows) + +--Testcase 72: +SELECT * FROM FLOAT8_TBL; + f1 +---------------------- + 0 + 1004.3 + -34.84 + 1.2345678901234e+200 + 1.2345678901234e-200 +(5 rows) + +--Testcase 73: +UPDATE FLOAT8_TBL + SET f1 = FLOAT8_TBL.f1 * '-1' + WHERE FLOAT8_TBL.f1 > '0.0'; +--Testcase 74: +SELECT f.f1 * '1e200' from FLOAT8_TBL f; +ERROR: value out of range: overflow +--Testcase 75: +SELECT f.f1 ^ '1e200' from FLOAT8_TBL f; +ERROR: value out of range: overflow +BEGIN; +--Testcase 76: +DELETE FROM FLOAT8_TBL; +--Testcase 77: +INSERT INTO FLOAT8_TBL VALUES (0 ^ 0 + 0 ^ 1 + 0 ^ 0.0 + 0 ^ 0.5); +--Testcase 78: +SELECT * FROM FLOAT8_TBL; + f1 +---- + 2 +(1 row) + +ROLLBACK; +--Testcase 79: +SELECT ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ; +ERROR: cannot take logarithm of zero +--Testcase 80: +SELECT ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ; +ERROR: cannot take logarithm of a negative number +--Testcase 81: +SELECT exp(f.f1) from FLOAT8_TBL f; +ERROR: value out of range: underflow +--Testcase 82: +SELECT f.f1 / '0.0' from FLOAT8_TBL f; +ERROR: division by zero +--Testcase 83: +SELECT * FROM FLOAT8_TBL; + f1 +----------------------- + 0 + -1004.3 + -34.84 + -1.2345678901234e+200 + -1.2345678901234e-200 +(5 rows) + +-- hyperbolic functions +-- we run these with extra_float_digits = 0 too, since different platforms +-- tend to produce results that vary in the last place. +--Testcase 157: +DELETE FROM FLOAT8_TMP; +--Testcase 158: +INSERT INTO FLOAT8_TMP(f1) VALUES (1); +--Testcase 159: +SELECT sinh(f1) FROM FLOAT8_TMP; + sinh +----------------- + 1.1752011936438 +(1 row) + +--Testcase 160: +SELECT cosh(f1) FROM FLOAT8_TMP; + cosh +------------------ + 1.54308063481524 +(1 row) + +--Testcase 161: +SELECT tanh(f1) FROM FLOAT8_TMP; + tanh +------------------- + 0.761594155955765 +(1 row) + +--Testcase 162: +SELECT asinh(f1) FROM FLOAT8_TMP; + asinh +------------------- + 0.881373587019543 +(1 row) + +--Testcase 163: +DELETE FROM FLOAT8_TMP; +--Testcase 164: +INSERT INTO FLOAT8_TMP(f1) VALUES (2); +--Testcase 165: +SELECT acosh(f1) FROM FLOAT8_TMP; + acosh +------------------ + 1.31695789692482 +(1 row) + +--Testcase 166: +DELETE FROM FLOAT8_TMP; +--Testcase 167: +INSERT INTO FLOAT8_TMP(f1) VALUES (0.5); +--Testcase 168: +SELECT atanh(f1) FROM FLOAT8_TMP; + atanh +------------------- + 0.549306144334055 +(1 row) + +-- test Inf/NaN cases for hyperbolic functions +--Testcase 169: +DELETE FROM FLOAT8_TMP; +--Testcase 170: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'infinity'); +--Testcase 171: +SELECT sinh(f1) FROM FLOAT8_TMP; + sinh +---------- + Infinity +(1 row) + +--Testcase 172: +DELETE FROM FLOAT8_TMP; +--Testcase 173: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 '-infinity'); +--Testcase 174: +SELECT sinh(f1) FROM FLOAT8_TMP; + sinh +----------- + -Infinity +(1 row) + +--Testcase 175: +DELETE FROM FLOAT8_TMP; +--Testcase 176: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'nan'); +--Testcase 177: +SELECT sinh(f1) FROM FLOAT8_TMP; + sinh +------ + +(1 row) + +--Testcase 178: +DELETE FROM FLOAT8_TMP; +--Testcase 179: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'infinity'); +--Testcase 180: +SELECT cosh(f1) FROM FLOAT8_TMP; + cosh +---------- + Infinity +(1 row) + +--Testcase 181: +DELETE FROM FLOAT8_TMP; +--Testcase 182: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 '-infinity'); +--Testcase 183: +SELECT cosh(f1) FROM FLOAT8_TMP; + cosh +---------- + Infinity +(1 row) + +--Testcase 184: +DELETE FROM FLOAT8_TMP; +--Testcase 185: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'nan'); +--Testcase 186: +SELECT cosh(f1) FROM FLOAT8_TMP; + cosh +------ + +(1 row) + +--Testcase 187: +DELETE FROM FLOAT8_TMP; +--Testcase 188: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'infinity'); +--Testcase 189: +SELECT tanh(f1) FROM FLOAT8_TMP; + tanh +------ + 1 +(1 row) + +--Testcase 190: +DELETE FROM FLOAT8_TMP; +--Testcase 191: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 '-infinity'); +--Testcase 192: +SELECT tanh(f1) FROM FLOAT8_TMP; + tanh +------ + -1 +(1 row) + +--Testcase 193: +DELETE FROM FLOAT8_TMP; +--Testcase 194: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'nan'); +--Testcase 195: +SELECT tanh(f1) FROM FLOAT8_TMP; + tanh +------ + +(1 row) + +--Testcase 196: +DELETE FROM FLOAT8_TMP; +--Testcase 197: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'infinity'); +--Testcase 198: +SELECT asinh(f1) FROM FLOAT8_TMP; + asinh +---------- + Infinity +(1 row) + +--Testcase 199: +DELETE FROM FLOAT8_TMP; +--Testcase 200: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 '-infinity'); +--Testcase 201: +SELECT asinh(f1) FROM FLOAT8_TMP; + asinh +----------- + -Infinity +(1 row) + +--Testcase 202: +DELETE FROM FLOAT8_TMP; +--Testcase 203: +INSERT INTO FLOAT8_TMP(f1) VALUES (float8 'nan'); +--Testcase 204: +SELECT asinh(f1) FROM FLOAT8_TMP; + asinh +------- + +(1 row) + +-- acosh(Inf) should be Inf, but some mingw versions produce NaN, so skip test +-- SELECT acosh(float8 'infinity'); +--Testcase 205: +DELETE FROM FLOAT8_TMP; +--Testcase 206: +INSERT INTO FLOAT8_TMP VALUES (float8 '-infinity'); +--Testcase 207: +SELECT acosh(f1) FROM FLOAT8_TMP; +ERROR: input is out of range +--Testcase 208: +DELETE FROM FLOAT8_TMP; +--Testcase 209: +INSERT INTO FLOAT8_TMP VALUES ((float8 'nan')); +--Testcase 210: +SELECT acosh(f1) FROM FLOAT8_TMP; + acosh +------- + +(1 row) + +--Testcase 211: +DELETE FROM FLOAT8_TMP; +--Testcase 212: +INSERT INTO FLOAT8_TMP VALUES ((float8 'infinity')); +--Testcase 213: +SELECT atanh(f1) FROM FLOAT8_TMP; +ERROR: input is out of range +--Testcase 214: +DELETE FROM FLOAT8_TMP; +--Testcase 215: +INSERT INTO FLOAT8_TMP VALUES ((float8 '-infinity')); +--Testcase 216: +SELECT atanh(f1) FROM FLOAT8_TMP; +ERROR: input is out of range +--Testcase 217: +DELETE FROM FLOAT8_TMP; +--Testcase 218: +INSERT INTO FLOAT8_TMP VALUES ((float8 'nan')); +--Testcase 219: +SELECT atanh(f1) FROM FLOAT8_TMP; + atanh +------- + +(1 row) + +--Testcase 369: +RESET extra_float_digits; +-- test for over- and underflow +--Testcase 84: +INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400'); +ERROR: "10e400" is out of range for type double precision +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400'); + ^ +--Testcase 85: +INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400'); +ERROR: "-10e400" is out of range for type double precision +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400'); + ^ +--Testcase 86: +INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400'); +ERROR: "10e-400" is out of range for type double precision +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400'); + ^ +--Testcase 87: +INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400'); +ERROR: "-10e-400" is out of range for type double precision +LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400'); + ^ +-- maintain external table consistency across platforms +-- delete all values and reinsert well-behaved ones +--Testcase 88: +DELETE FROM FLOAT8_TBL; +--Testcase 89: +INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0'); +--Testcase 90: +INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84'); +--Testcase 91: +INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30'); +--Testcase 92: +INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200'); +--Testcase 93: +INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200'); +--Testcase 94: +SELECT * FROM FLOAT8_TBL; + f1 +----------------------- + 0 + -34.84 + -1004.3 + -1.2345678901234e+200 + -1.2345678901234e-200 +(5 rows) + +-- test edge-case coercions to integer +--Testcase 220: +DELETE FROM FLOAT8_TMP; +--Testcase 221: +INSERT INTO FLOAT8_TMP VALUES ('32767.4'::float8); +--Testcase 222: +SELECT f1::int2 FROM FLOAT8_TMP; + f1 +------- + 32767 +(1 row) + +--Testcase 223: +DELETE FROM FLOAT8_TMP; +--Testcase 224: +INSERT INTO FLOAT8_TMP VALUES ('32767.6'::float8); +--Testcase 225: +SELECT f1::int2 FROM FLOAT8_TMP; +ERROR: smallint out of range +--Testcase 226: +DELETE FROM FLOAT8_TMP; +--Testcase 227: +INSERT INTO FLOAT8_TMP VALUES ('-32768.4'::float8); +--Testcase 228: +SELECT f1::int2 FROM FLOAT8_TMP; + f1 +-------- + -32768 +(1 row) + +--Testcase 229: +DELETE FROM FLOAT8_TMP; +--Testcase 230: +INSERT INTO FLOAT8_TMP VALUES ('-32768.6'::float8); +--Testcase 231: +SELECT f1::int2 FROM FLOAT8_TMP; +ERROR: smallint out of range +--Testcase 232: +DELETE FROM FLOAT8_TMP; +--Testcase 233: +INSERT INTO FLOAT8_TMP VALUES ('2147483647.4'::float8); +--Testcase 234: +SELECT f1::int4 FROM FLOAT8_TMP; + f1 +------------ + 2147483647 +(1 row) + +--Testcase 235: +DELETE FROM FLOAT8_TMP; +--Testcase 236: +INSERT INTO FLOAT8_TMP VALUES ('2147483647.6'::float8); +--Testcase 237: +SELECT f1::int4 FROM FLOAT8_TMP; +ERROR: integer out of range +--Testcase 238: +DELETE FROM FLOAT8_TMP; +--Testcase 239: +INSERT INTO FLOAT8_TMP VALUES ('-2147483648.4'::float8); +--Testcase 240: +SELECT f1::int4 FROM FLOAT8_TMP; + f1 +------------- + -2147483648 +(1 row) + +--Testcase 241: +DELETE FROM FLOAT8_TMP; +--Testcase 242: +INSERT INTO FLOAT8_TMP VALUES ('-2147483648.6'::float8); +--Testcase 243: +SELECT f1::int4 FROM FLOAT8_TMP; +ERROR: integer out of range +--Testcase 244: +DELETE FROM FLOAT8_TMP; +--Testcase 245: +INSERT INTO FLOAT8_TMP VALUES ('9223372036854773760'::float8); +--Testcase 246: +SELECT f1::int8 FROM FLOAT8_TMP; + f1 +--------------------- + 9223372036854773760 +(1 row) + +--Testcase 247: +DELETE FROM FLOAT8_TMP; +--Testcase 248: +INSERT INTO FLOAT8_TMP VALUES ('9223372036854775807'::float8); +--Testcase 249: +SELECT f1::int8 FROM FLOAT8_TMP; +ERROR: bigint out of range +--Testcase 250: +DELETE FROM FLOAT8_TMP; +--Testcase 251: +INSERT INTO FLOAT8_TMP VALUES ('-9223372036854775808.5'::float8); +--Testcase 252: +SELECT f1::int8 FROM FLOAT8_TMP; + f1 +---------------------- + -9223372036854775808 +(1 row) + +--Testcase 253: +DELETE FROM FLOAT8_TMP; +--Testcase 254: +INSERT INTO FLOAT8_TMP VALUES ('-9223372036854780000'::float8); +--Testcase 255: +SELECT f1::int8 FROM FLOAT8_TMP; +ERROR: bigint out of range +-- test exact cases for trigonometric functions in degrees +BEGIN; +--Testcase 95: +DELETE FROM FLOAT8_TBL; +--Testcase 96: +INSERT INTO FLOAT8_TBL VALUES (0), (30), (90), (150), (180), + (210), (270), (330), (360); +--Testcase 97: +SELECT f1, + sind(f1), + sind(f1) IN (-1,-0.5,0,0.5,1) AS sind_exact + FROM FLOAT8_TBL; + f1 | sind | sind_exact +-----+------+------------ + 0 | 0 | t + 30 | 0.5 | t + 90 | 1 | t + 150 | 0.5 | t + 180 | 0 | t + 210 | -0.5 | t + 270 | -1 | t + 330 | -0.5 | t + 360 | 0 | t +(9 rows) + +--Testcase 98: +DELETE FROM FLOAT8_TBL; +--Testcase 99: +INSERT INTO FLOAT8_TBL VALUES (0), (60), (90), (120), (180), + (240), (270), (300), (360); +--Testcase 100: +SELECT f1, + cosd(f1), + cosd(f1) IN (-1,-0.5,0,0.5,1) AS cosd_exact + FROM FLOAT8_TBL; + f1 | cosd | cosd_exact +-----+------+------------ + 0 | 1 | t + 60 | 0.5 | t + 90 | 0 | t + 120 | -0.5 | t + 180 | -1 | t + 240 | -0.5 | t + 270 | 0 | t + 300 | 0.5 | t + 360 | 1 | t +(9 rows) + +--Testcase 101: +DELETE FROM FLOAT8_TBL; +--Testcase 102: +INSERT INTO FLOAT8_TBL VALUES (0), (45), (90), (135), (180), + (225), (270), (315), (360); +--Testcase 103: +SELECT f1, + tand(f1), + tand(f1) IN ('-Infinity'::float8,-1,0, + 1,'Infinity'::float8) AS tand_exact, + cotd(f1), + cotd(f1) IN ('-Infinity'::float8,-1,0, + 1,'Infinity'::float8) AS cotd_exact + FROM FLOAT8_TBL; + f1 | tand | tand_exact | cotd | cotd_exact +-----+-----------+------------+-----------+------------ + 0 | 0 | t | Infinity | t + 45 | 1 | t | 1 | t + 90 | Infinity | t | 0 | t + 135 | -1 | t | -1 | t + 180 | 0 | t | -Infinity | t + 225 | 1 | t | 1 | t + 270 | -Infinity | t | 0 | t + 315 | -1 | t | -1 | t + 360 | 0 | t | Infinity | t +(9 rows) + +--Testcase 104: +DELETE FROM FLOAT8_TBL; +--Testcase 105: +INSERT INTO FLOAT8_TBL VALUES (-1), (-0.5), (0), (0.5), (1); +--Testcase 106: +SELECT f1, + asind(f1), + asind(f1) IN (-90,-30,0,30,90) AS asind_exact, + acosd(f1), + acosd(f1) IN (0,60,90,120,180) AS acosd_exact + FROM FLOAT8_TBL; + f1 | asind | asind_exact | acosd | acosd_exact +------+-------+-------------+-------+------------- + -1 | -90 | t | 180 | t + -0.5 | -30 | t | 120 | t + 0 | 0 | t | 90 | t + 0.5 | 30 | t | 60 | t + 1 | 90 | t | 0 | t +(5 rows) + +--Testcase 107: +DELETE FROM FLOAT8_TBL; +--Testcase 108: +INSERT INTO FLOAT8_TBL VALUES ('-Infinity'::float8), (-1), (0), (1), + ('Infinity'::float8); +--Testcase 109: +SELECT f1, + atand(f1), + atand(f1) IN (-90,-45,0,45,90) AS atand_exact + FROM FLOAT8_TBL; + f1 | atand | atand_exact +-----------+-------+------------- + -Infinity | -90 | t + -1 | -45 | t + 0 | 0 | t + 1 | 45 | t + Infinity | 90 | t +(5 rows) + +--Testcase 110: +DELETE FROM FLOAT8_TBL; +--Testcase 111: +INSERT INTO FLOAT8_TBL SELECT * FROM generate_series(0, 360, 90); +--Testcase 112: +SELECT x, y, + atan2d(y, x), + atan2d(y, x) IN (-90,0,90,180) AS atan2d_exact +FROM (SELECT 10*cosd(f1), 10*sind(f1) + FROM FLOAT8_TBL) AS t(x,y); + x | y | atan2d | atan2d_exact +-----+-----+--------+-------------- + 10 | 0 | 0 | t + 0 | 10 | 90 | t + -10 | 0 | 180 | t + 0 | -10 | -90 | t + 10 | 0 | 0 | t +(5 rows) + +ROLLBACK; +-- +-- test output (and round-trip safety) of various values. +-- To ensure we're testing what we think we're testing, start with +-- float values specified by bit patterns (as a useful side effect, +-- this means we'll fail on non-IEEE platforms). +--Testcase 256: +create type xfloat8; +--Testcase 257: +create function xfloat8in(cstring) returns xfloat8 immutable strict + language internal as 'int8in'; +NOTICE: return type xfloat8 is only a shell +--Testcase 258: +create function xfloat8out(xfloat8) returns cstring immutable strict + language internal as 'int8out'; +NOTICE: argument type xfloat8 is only a shell +--Testcase 259: +create type xfloat8 (input = xfloat8in, output = xfloat8out, like = float8); +--Testcase 260: +create cast (xfloat8 as float8) without function; +--Testcase 261: +create cast (float8 as xfloat8) without function; +--Testcase 262: +create cast (xfloat8 as bigint) without function; +--Testcase 263: +create cast (bigint as xfloat8) without function; +-- float8: seeeeeee eeeeeeee eeeeeeee mmmmmmmm mmmmmmmm(x4) +-- we don't care to assume the platform's strtod() handles subnormals +-- correctly; those are "use at your own risk". However we do test +-- subnormal outputs, since those are under our control. +--Testcase 264: +create foreign table testdata(bits text, id int OPTIONS (key 'true')) server sqlite_svr; +begin; +--Testcase 265: +insert into testdata(bits) values + -- small subnormals + (x'0000000000000001'), + (x'0000000000000002'), (x'0000000000000003'), + (x'0000000000001000'), (x'0000000100000000'), + (x'0000010000000000'), (x'0000010100000000'), + (x'0000400000000000'), (x'0000400100000000'), + (x'0000800000000000'), (x'0000800000000001'), + -- these values taken from upstream testsuite + (x'00000000000f4240'), + (x'00000000016e3600'), + (x'0000008cdcdea440'), + -- borderline between subnormal and normal + (x'000ffffffffffff0'), (x'000ffffffffffff1'), + (x'000ffffffffffffe'), (x'000fffffffffffff'); +--Testcase 266: +select float8send(flt) as ibits, + flt + from (select bits::bit(64)::bigint::xfloat8::float8 as flt + from testdata + offset 0) s; + ibits | flt +--------------------+------------------------- + \x0000000000000001 | 5e-324 + \x0000000000000002 | 1e-323 + \x0000000000000003 | 1.5e-323 + \x0000000000001000 | 2.0237e-320 + \x0000000100000000 | 2.121995791e-314 + \x0000010000000000 | 5.43230922487e-312 + \x0000010100000000 | 5.45352918278e-312 + \x0000400000000000 | 3.4766779039175e-310 + \x0000400100000000 | 3.4768901034966e-310 + \x0000800000000000 | 6.953355807835e-310 + \x0000800000000001 | 6.95335580783505e-310 + \x00000000000f4240 | 4.940656e-318 + \x00000000016e3600 | 1.18575755e-316 + \x0000008cdcdea440 | 2.989102097996e-312 + \x000ffffffffffff0 | 2.2250738585071935e-308 + \x000ffffffffffff1 | 2.225073858507194e-308 + \x000ffffffffffffe | 2.2250738585072004e-308 + \x000fffffffffffff | 2.225073858507201e-308 +(18 rows) + +rollback; +-- round-trip tests +begin; +--Testcase 267: +insert into testdata(bits) values + (x'0000000000000000'), + -- smallest normal values + (x'0010000000000000'), (x'0010000000000001'), + (x'0010000000000002'), (x'0018000000000000'), + -- + (x'3ddb7cdfd9d7bdba'), (x'3ddb7cdfd9d7bdbb'), (x'3ddb7cdfd9d7bdbc'), + (x'3e112e0be826d694'), (x'3e112e0be826d695'), (x'3e112e0be826d696'), + (x'3e45798ee2308c39'), (x'3e45798ee2308c3a'), (x'3e45798ee2308c3b'), + (x'3e7ad7f29abcaf47'), (x'3e7ad7f29abcaf48'), (x'3e7ad7f29abcaf49'), + (x'3eb0c6f7a0b5ed8c'), (x'3eb0c6f7a0b5ed8d'), (x'3eb0c6f7a0b5ed8e'), + (x'3ee4f8b588e368ef'), (x'3ee4f8b588e368f0'), (x'3ee4f8b588e368f1'), + (x'3f1a36e2eb1c432c'), (x'3f1a36e2eb1c432d'), (x'3f1a36e2eb1c432e'), + (x'3f50624dd2f1a9fb'), (x'3f50624dd2f1a9fc'), (x'3f50624dd2f1a9fd'), + (x'3f847ae147ae147a'), (x'3f847ae147ae147b'), (x'3f847ae147ae147c'), + (x'3fb9999999999999'), (x'3fb999999999999a'), (x'3fb999999999999b'), + -- values very close to 1 + (x'3feffffffffffff0'), (x'3feffffffffffff1'), (x'3feffffffffffff2'), + (x'3feffffffffffff3'), (x'3feffffffffffff4'), (x'3feffffffffffff5'), + (x'3feffffffffffff6'), (x'3feffffffffffff7'), (x'3feffffffffffff8'), + (x'3feffffffffffff9'), (x'3feffffffffffffa'), (x'3feffffffffffffb'), + (x'3feffffffffffffc'), (x'3feffffffffffffd'), (x'3feffffffffffffe'), + (x'3fefffffffffffff'), + (x'3ff0000000000000'), + (x'3ff0000000000001'), (x'3ff0000000000002'), (x'3ff0000000000003'), + (x'3ff0000000000004'), (x'3ff0000000000005'), (x'3ff0000000000006'), + (x'3ff0000000000007'), (x'3ff0000000000008'), (x'3ff0000000000009'), + -- + (x'3ff921fb54442d18'), + (x'4005bf0a8b14576a'), + (x'400921fb54442d18'), + -- + (x'4023ffffffffffff'), (x'4024000000000000'), (x'4024000000000001'), + (x'4058ffffffffffff'), (x'4059000000000000'), (x'4059000000000001'), + (x'408f3fffffffffff'), (x'408f400000000000'), (x'408f400000000001'), + (x'40c387ffffffffff'), (x'40c3880000000000'), (x'40c3880000000001'), + (x'40f869ffffffffff'), (x'40f86a0000000000'), (x'40f86a0000000001'), + (x'412e847fffffffff'), (x'412e848000000000'), (x'412e848000000001'), + (x'416312cfffffffff'), (x'416312d000000000'), (x'416312d000000001'), + (x'4197d783ffffffff'), (x'4197d78400000000'), (x'4197d78400000001'), + (x'41cdcd64ffffffff'), (x'41cdcd6500000000'), (x'41cdcd6500000001'), + (x'4202a05f1fffffff'), (x'4202a05f20000000'), (x'4202a05f20000001'), + (x'42374876e7ffffff'), (x'42374876e8000000'), (x'42374876e8000001'), + (x'426d1a94a1ffffff'), (x'426d1a94a2000000'), (x'426d1a94a2000001'), + (x'42a2309ce53fffff'), (x'42a2309ce5400000'), (x'42a2309ce5400001'), + (x'42d6bcc41e8fffff'), (x'42d6bcc41e900000'), (x'42d6bcc41e900001'), + (x'430c6bf52633ffff'), (x'430c6bf526340000'), (x'430c6bf526340001'), + (x'4341c37937e07fff'), (x'4341c37937e08000'), (x'4341c37937e08001'), + (x'4376345785d89fff'), (x'4376345785d8a000'), (x'4376345785d8a001'), + (x'43abc16d674ec7ff'), (x'43abc16d674ec800'), (x'43abc16d674ec801'), + (x'43e158e460913cff'), (x'43e158e460913d00'), (x'43e158e460913d01'), + (x'4415af1d78b58c3f'), (x'4415af1d78b58c40'), (x'4415af1d78b58c41'), + (x'444b1ae4d6e2ef4f'), (x'444b1ae4d6e2ef50'), (x'444b1ae4d6e2ef51'), + (x'4480f0cf064dd591'), (x'4480f0cf064dd592'), (x'4480f0cf064dd593'), + (x'44b52d02c7e14af5'), (x'44b52d02c7e14af6'), (x'44b52d02c7e14af7'), + (x'44ea784379d99db3'), (x'44ea784379d99db4'), (x'44ea784379d99db5'), + (x'45208b2a2c280290'), (x'45208b2a2c280291'), (x'45208b2a2c280292'), + -- + (x'7feffffffffffffe'), (x'7fefffffffffffff'), + -- round to even tests (+ve) + (x'4350000000000002'), + (x'4350000000002e06'), + (x'4352000000000003'), + (x'4352000000000004'), + (x'4358000000000003'), + (x'4358000000000004'), + (x'435f000000000020'), + -- round to even tests (-ve) + (x'c350000000000002'), + (x'c350000000002e06'), + (x'c352000000000003'), + (x'c352000000000004'), + (x'c358000000000003'), + (x'c358000000000004'), + (x'c35f000000000020'), + -- exercise fixed-point memmoves + (x'42dc12218377de66'), + (x'42a674e79c5fe51f'), + (x'4271f71fb04cb74c'), + (x'423cbe991a145879'), + (x'4206fee0e1a9e061'), + (x'41d26580b487e6b4'), + (x'419d6f34540ca453'), + (x'41678c29dcd6e9dc'), + (x'4132d687e3df217d'), + (x'40fe240c9fcb68c8'), + (x'40c81cd6e63c53d3'), + (x'40934a4584fd0fdc'), + (x'405edd3c07fb4c93'), + (x'4028b0fcd32f7076'), + (x'3ff3c0ca428c59f8'), + -- these cases come from the upstream's testsuite + -- LotsOfTrailingZeros) + (x'3e60000000000000'), + -- Regression + (x'c352bd2668e077c4'), + (x'434018601510c000'), + (x'43d055dc36f24000'), + (x'43e052961c6f8000'), + (x'3ff3c0ca2a5b1d5d'), + -- LooksLikePow5 + (x'4830f0cf064dd592'), + (x'4840f0cf064dd592'), + (x'4850f0cf064dd592'), + -- OutputLength + (x'3ff3333333333333'), + (x'3ff3ae147ae147ae'), + (x'3ff3be76c8b43958'), + (x'3ff3c083126e978d'), + (x'3ff3c0c1fc8f3238'), + (x'3ff3c0c9539b8887'), + (x'3ff3c0ca2a5b1d5d'), + (x'3ff3c0ca4283de1b'), + (x'3ff3c0ca43db770a'), + (x'3ff3c0ca428abd53'), + (x'3ff3c0ca428c1d2b'), + (x'3ff3c0ca428c51f2'), + (x'3ff3c0ca428c58fc'), + (x'3ff3c0ca428c59dd'), + (x'3ff3c0ca428c59f8'), + (x'3ff3c0ca428c59fb'), + -- 32-bit chunking + (x'40112e0be8047a7d'), + (x'40112e0be815a889'), + (x'40112e0be826d695'), + (x'40112e0be83804a1'), + (x'40112e0be84932ad'), + -- MinMaxShift + (x'0040000000000000'), + (x'007fffffffffffff'), + (x'0290000000000000'), + (x'029fffffffffffff'), + (x'4350000000000000'), + (x'435fffffffffffff'), + (x'1330000000000000'), + (x'133fffffffffffff'), + (x'3a6fa7161a4d6e0c'); +--Testcase 268: +select float8send(flt) as ibits, + flt, + flt::text::float8 as r_flt, + float8send(flt::text::float8) as obits, + float8send(flt::text::float8) = float8send(flt) as correct + from (select bits::bit(64)::bigint::xfloat8::float8 as flt + from testdata + offset 0) s; + ibits | flt | r_flt | obits | correct +--------------------+-------------------------+-------------------------+--------------------+--------- + \x0000000000000000 | 0 | 0 | \x0000000000000000 | t + \x0010000000000000 | 2.2250738585072014e-308 | 2.2250738585072014e-308 | \x0010000000000000 | t + \x0010000000000001 | 2.225073858507202e-308 | 2.225073858507202e-308 | \x0010000000000001 | t + \x0010000000000002 | 2.2250738585072024e-308 | 2.2250738585072024e-308 | \x0010000000000002 | t + \x0018000000000000 | 3.337610787760802e-308 | 3.337610787760802e-308 | \x0018000000000000 | t + \x3ddb7cdfd9d7bdba | 9.999999999999999e-11 | 9.999999999999999e-11 | \x3ddb7cdfd9d7bdba | t + \x3ddb7cdfd9d7bdbb | 1e-10 | 1e-10 | \x3ddb7cdfd9d7bdbb | t + \x3ddb7cdfd9d7bdbc | 1.0000000000000002e-10 | 1.0000000000000002e-10 | \x3ddb7cdfd9d7bdbc | t + \x3e112e0be826d694 | 9.999999999999999e-10 | 9.999999999999999e-10 | \x3e112e0be826d694 | t + \x3e112e0be826d695 | 1e-09 | 1e-09 | \x3e112e0be826d695 | t + \x3e112e0be826d696 | 1.0000000000000003e-09 | 1.0000000000000003e-09 | \x3e112e0be826d696 | t + \x3e45798ee2308c39 | 9.999999999999999e-09 | 9.999999999999999e-09 | \x3e45798ee2308c39 | t + \x3e45798ee2308c3a | 1e-08 | 1e-08 | \x3e45798ee2308c3a | t + \x3e45798ee2308c3b | 1.0000000000000002e-08 | 1.0000000000000002e-08 | \x3e45798ee2308c3b | t + \x3e7ad7f29abcaf47 | 9.999999999999998e-08 | 9.999999999999998e-08 | \x3e7ad7f29abcaf47 | t + \x3e7ad7f29abcaf48 | 1e-07 | 1e-07 | \x3e7ad7f29abcaf48 | t + \x3e7ad7f29abcaf49 | 1.0000000000000001e-07 | 1.0000000000000001e-07 | \x3e7ad7f29abcaf49 | t + \x3eb0c6f7a0b5ed8c | 9.999999999999997e-07 | 9.999999999999997e-07 | \x3eb0c6f7a0b5ed8c | t + \x3eb0c6f7a0b5ed8d | 1e-06 | 1e-06 | \x3eb0c6f7a0b5ed8d | t + \x3eb0c6f7a0b5ed8e | 1.0000000000000002e-06 | 1.0000000000000002e-06 | \x3eb0c6f7a0b5ed8e | t + \x3ee4f8b588e368ef | 9.999999999999997e-06 | 9.999999999999997e-06 | \x3ee4f8b588e368ef | t + \x3ee4f8b588e368f0 | 9.999999999999999e-06 | 9.999999999999999e-06 | \x3ee4f8b588e368f0 | t + \x3ee4f8b588e368f1 | 1e-05 | 1e-05 | \x3ee4f8b588e368f1 | t + \x3f1a36e2eb1c432c | 9.999999999999999e-05 | 9.999999999999999e-05 | \x3f1a36e2eb1c432c | t + \x3f1a36e2eb1c432d | 0.0001 | 0.0001 | \x3f1a36e2eb1c432d | t + \x3f1a36e2eb1c432e | 0.00010000000000000002 | 0.00010000000000000002 | \x3f1a36e2eb1c432e | t + \x3f50624dd2f1a9fb | 0.0009999999999999998 | 0.0009999999999999998 | \x3f50624dd2f1a9fb | t + \x3f50624dd2f1a9fc | 0.001 | 0.001 | \x3f50624dd2f1a9fc | t + \x3f50624dd2f1a9fd | 0.0010000000000000002 | 0.0010000000000000002 | \x3f50624dd2f1a9fd | t + \x3f847ae147ae147a | 0.009999999999999998 | 0.009999999999999998 | \x3f847ae147ae147a | t + \x3f847ae147ae147b | 0.01 | 0.01 | \x3f847ae147ae147b | t + \x3f847ae147ae147c | 0.010000000000000002 | 0.010000000000000002 | \x3f847ae147ae147c | t + \x3fb9999999999999 | 0.09999999999999999 | 0.09999999999999999 | \x3fb9999999999999 | t + \x3fb999999999999a | 0.1 | 0.1 | \x3fb999999999999a | t + \x3fb999999999999b | 0.10000000000000002 | 0.10000000000000002 | \x3fb999999999999b | t + \x3feffffffffffff0 | 0.9999999999999982 | 0.9999999999999982 | \x3feffffffffffff0 | t + \x3feffffffffffff1 | 0.9999999999999983 | 0.9999999999999983 | \x3feffffffffffff1 | t + \x3feffffffffffff2 | 0.9999999999999984 | 0.9999999999999984 | \x3feffffffffffff2 | t + \x3feffffffffffff3 | 0.9999999999999986 | 0.9999999999999986 | \x3feffffffffffff3 | t + \x3feffffffffffff4 | 0.9999999999999987 | 0.9999999999999987 | \x3feffffffffffff4 | t + \x3feffffffffffff5 | 0.9999999999999988 | 0.9999999999999988 | \x3feffffffffffff5 | t + \x3feffffffffffff6 | 0.9999999999999989 | 0.9999999999999989 | \x3feffffffffffff6 | t + \x3feffffffffffff7 | 0.999999999999999 | 0.999999999999999 | \x3feffffffffffff7 | t + \x3feffffffffffff8 | 0.9999999999999991 | 0.9999999999999991 | \x3feffffffffffff8 | t + \x3feffffffffffff9 | 0.9999999999999992 | 0.9999999999999992 | \x3feffffffffffff9 | t + \x3feffffffffffffa | 0.9999999999999993 | 0.9999999999999993 | \x3feffffffffffffa | t + \x3feffffffffffffb | 0.9999999999999994 | 0.9999999999999994 | \x3feffffffffffffb | t + \x3feffffffffffffc | 0.9999999999999996 | 0.9999999999999996 | \x3feffffffffffffc | t + \x3feffffffffffffd | 0.9999999999999997 | 0.9999999999999997 | \x3feffffffffffffd | t + \x3feffffffffffffe | 0.9999999999999998 | 0.9999999999999998 | \x3feffffffffffffe | t + \x3fefffffffffffff | 0.9999999999999999 | 0.9999999999999999 | \x3fefffffffffffff | t + \x3ff0000000000000 | 1 | 1 | \x3ff0000000000000 | t + \x3ff0000000000001 | 1.0000000000000002 | 1.0000000000000002 | \x3ff0000000000001 | t + \x3ff0000000000002 | 1.0000000000000004 | 1.0000000000000004 | \x3ff0000000000002 | t + \x3ff0000000000003 | 1.0000000000000007 | 1.0000000000000007 | \x3ff0000000000003 | t + \x3ff0000000000004 | 1.0000000000000009 | 1.0000000000000009 | \x3ff0000000000004 | t + \x3ff0000000000005 | 1.000000000000001 | 1.000000000000001 | \x3ff0000000000005 | t + \x3ff0000000000006 | 1.0000000000000013 | 1.0000000000000013 | \x3ff0000000000006 | t + \x3ff0000000000007 | 1.0000000000000016 | 1.0000000000000016 | \x3ff0000000000007 | t + \x3ff0000000000008 | 1.0000000000000018 | 1.0000000000000018 | \x3ff0000000000008 | t + \x3ff0000000000009 | 1.000000000000002 | 1.000000000000002 | \x3ff0000000000009 | t + \x3ff921fb54442d18 | 1.5707963267948966 | 1.5707963267948966 | \x3ff921fb54442d18 | t + \x4005bf0a8b14576a | 2.7182818284590455 | 2.7182818284590455 | \x4005bf0a8b14576a | t + \x400921fb54442d18 | 3.141592653589793 | 3.141592653589793 | \x400921fb54442d18 | t + \x4023ffffffffffff | 9.999999999999998 | 9.999999999999998 | \x4023ffffffffffff | t + \x4024000000000000 | 10 | 10 | \x4024000000000000 | t + \x4024000000000001 | 10.000000000000002 | 10.000000000000002 | \x4024000000000001 | t + \x4058ffffffffffff | 99.99999999999999 | 99.99999999999999 | \x4058ffffffffffff | t + \x4059000000000000 | 100 | 100 | \x4059000000000000 | t + \x4059000000000001 | 100.00000000000001 | 100.00000000000001 | \x4059000000000001 | t + \x408f3fffffffffff | 999.9999999999999 | 999.9999999999999 | \x408f3fffffffffff | t + \x408f400000000000 | 1000 | 1000 | \x408f400000000000 | t + \x408f400000000001 | 1000.0000000000001 | 1000.0000000000001 | \x408f400000000001 | t + \x40c387ffffffffff | 9999.999999999998 | 9999.999999999998 | \x40c387ffffffffff | t + \x40c3880000000000 | 10000 | 10000 | \x40c3880000000000 | t + \x40c3880000000001 | 10000.000000000002 | 10000.000000000002 | \x40c3880000000001 | t + \x40f869ffffffffff | 99999.99999999999 | 99999.99999999999 | \x40f869ffffffffff | t + \x40f86a0000000000 | 100000 | 100000 | \x40f86a0000000000 | t + \x40f86a0000000001 | 100000.00000000001 | 100000.00000000001 | \x40f86a0000000001 | t + \x412e847fffffffff | 999999.9999999999 | 999999.9999999999 | \x412e847fffffffff | t + \x412e848000000000 | 1000000 | 1000000 | \x412e848000000000 | t + \x412e848000000001 | 1000000.0000000001 | 1000000.0000000001 | \x412e848000000001 | t + \x416312cfffffffff | 9999999.999999998 | 9999999.999999998 | \x416312cfffffffff | t + \x416312d000000000 | 10000000 | 10000000 | \x416312d000000000 | t + \x416312d000000001 | 10000000.000000002 | 10000000.000000002 | \x416312d000000001 | t + \x4197d783ffffffff | 99999999.99999999 | 99999999.99999999 | \x4197d783ffffffff | t + \x4197d78400000000 | 100000000 | 100000000 | \x4197d78400000000 | t + \x4197d78400000001 | 100000000.00000001 | 100000000.00000001 | \x4197d78400000001 | t + \x41cdcd64ffffffff | 999999999.9999999 | 999999999.9999999 | \x41cdcd64ffffffff | t + \x41cdcd6500000000 | 1000000000 | 1000000000 | \x41cdcd6500000000 | t + \x41cdcd6500000001 | 1000000000.0000001 | 1000000000.0000001 | \x41cdcd6500000001 | t + \x4202a05f1fffffff | 9999999999.999998 | 9999999999.999998 | \x4202a05f1fffffff | t + \x4202a05f20000000 | 10000000000 | 10000000000 | \x4202a05f20000000 | t + \x4202a05f20000001 | 10000000000.000002 | 10000000000.000002 | \x4202a05f20000001 | t + \x42374876e7ffffff | 99999999999.99998 | 99999999999.99998 | \x42374876e7ffffff | t + \x42374876e8000000 | 100000000000 | 100000000000 | \x42374876e8000000 | t + \x42374876e8000001 | 100000000000.00002 | 100000000000.00002 | \x42374876e8000001 | t + \x426d1a94a1ffffff | 999999999999.9999 | 999999999999.9999 | \x426d1a94a1ffffff | t + \x426d1a94a2000000 | 1000000000000 | 1000000000000 | \x426d1a94a2000000 | t + \x426d1a94a2000001 | 1000000000000.0001 | 1000000000000.0001 | \x426d1a94a2000001 | t + \x42a2309ce53fffff | 9999999999999.998 | 9999999999999.998 | \x42a2309ce53fffff | t + \x42a2309ce5400000 | 10000000000000 | 10000000000000 | \x42a2309ce5400000 | t + \x42a2309ce5400001 | 10000000000000.002 | 10000000000000.002 | \x42a2309ce5400001 | t + \x42d6bcc41e8fffff | 99999999999999.98 | 99999999999999.98 | \x42d6bcc41e8fffff | t + \x42d6bcc41e900000 | 100000000000000 | 100000000000000 | \x42d6bcc41e900000 | t + \x42d6bcc41e900001 | 100000000000000.02 | 100000000000000.02 | \x42d6bcc41e900001 | t + \x430c6bf52633ffff | 999999999999999.9 | 999999999999999.9 | \x430c6bf52633ffff | t + \x430c6bf526340000 | 1e+15 | 1e+15 | \x430c6bf526340000 | t + \x430c6bf526340001 | 1.0000000000000001e+15 | 1.0000000000000001e+15 | \x430c6bf526340001 | t + \x4341c37937e07fff | 9.999999999999998e+15 | 9.999999999999998e+15 | \x4341c37937e07fff | t + \x4341c37937e08000 | 1e+16 | 1e+16 | \x4341c37937e08000 | t + \x4341c37937e08001 | 1.0000000000000002e+16 | 1.0000000000000002e+16 | \x4341c37937e08001 | t + \x4376345785d89fff | 9.999999999999998e+16 | 9.999999999999998e+16 | \x4376345785d89fff | t + \x4376345785d8a000 | 1e+17 | 1e+17 | \x4376345785d8a000 | t + \x4376345785d8a001 | 1.0000000000000002e+17 | 1.0000000000000002e+17 | \x4376345785d8a001 | t + \x43abc16d674ec7ff | 9.999999999999999e+17 | 9.999999999999999e+17 | \x43abc16d674ec7ff | t + \x43abc16d674ec800 | 1e+18 | 1e+18 | \x43abc16d674ec800 | t + \x43abc16d674ec801 | 1.0000000000000001e+18 | 1.0000000000000001e+18 | \x43abc16d674ec801 | t + \x43e158e460913cff | 9.999999999999998e+18 | 9.999999999999998e+18 | \x43e158e460913cff | t + \x43e158e460913d00 | 1e+19 | 1e+19 | \x43e158e460913d00 | t + \x43e158e460913d01 | 1.0000000000000002e+19 | 1.0000000000000002e+19 | \x43e158e460913d01 | t + \x4415af1d78b58c3f | 9.999999999999998e+19 | 9.999999999999998e+19 | \x4415af1d78b58c3f | t + \x4415af1d78b58c40 | 1e+20 | 1e+20 | \x4415af1d78b58c40 | t + \x4415af1d78b58c41 | 1.0000000000000002e+20 | 1.0000000000000002e+20 | \x4415af1d78b58c41 | t + \x444b1ae4d6e2ef4f | 9.999999999999999e+20 | 9.999999999999999e+20 | \x444b1ae4d6e2ef4f | t + \x444b1ae4d6e2ef50 | 1e+21 | 1e+21 | \x444b1ae4d6e2ef50 | t + \x444b1ae4d6e2ef51 | 1.0000000000000001e+21 | 1.0000000000000001e+21 | \x444b1ae4d6e2ef51 | t + \x4480f0cf064dd591 | 9.999999999999998e+21 | 9.999999999999998e+21 | \x4480f0cf064dd591 | t + \x4480f0cf064dd592 | 1e+22 | 1e+22 | \x4480f0cf064dd592 | t + \x4480f0cf064dd593 | 1.0000000000000002e+22 | 1.0000000000000002e+22 | \x4480f0cf064dd593 | t + \x44b52d02c7e14af5 | 9.999999999999997e+22 | 9.999999999999997e+22 | \x44b52d02c7e14af5 | t + \x44b52d02c7e14af6 | 9.999999999999999e+22 | 9.999999999999999e+22 | \x44b52d02c7e14af6 | t + \x44b52d02c7e14af7 | 1.0000000000000001e+23 | 1.0000000000000001e+23 | \x44b52d02c7e14af7 | t + \x44ea784379d99db3 | 9.999999999999998e+23 | 9.999999999999998e+23 | \x44ea784379d99db3 | t + \x44ea784379d99db4 | 1e+24 | 1e+24 | \x44ea784379d99db4 | t + \x44ea784379d99db5 | 1.0000000000000001e+24 | 1.0000000000000001e+24 | \x44ea784379d99db5 | t + \x45208b2a2c280290 | 9.999999999999999e+24 | 9.999999999999999e+24 | \x45208b2a2c280290 | t + \x45208b2a2c280291 | 1e+25 | 1e+25 | \x45208b2a2c280291 | t + \x45208b2a2c280292 | 1.0000000000000003e+25 | 1.0000000000000003e+25 | \x45208b2a2c280292 | t + \x7feffffffffffffe | 1.7976931348623155e+308 | 1.7976931348623155e+308 | \x7feffffffffffffe | t + \x7fefffffffffffff | 1.7976931348623157e+308 | 1.7976931348623157e+308 | \x7fefffffffffffff | t + \x4350000000000002 | 1.8014398509481992e+16 | 1.8014398509481992e+16 | \x4350000000000002 | t + \x4350000000002e06 | 1.8014398509529112e+16 | 1.8014398509529112e+16 | \x4350000000002e06 | t + \x4352000000000003 | 2.0266198323167244e+16 | 2.0266198323167244e+16 | \x4352000000000003 | t + \x4352000000000004 | 2.0266198323167248e+16 | 2.0266198323167248e+16 | \x4352000000000004 | t + \x4358000000000003 | 2.7021597764222988e+16 | 2.7021597764222988e+16 | \x4358000000000003 | t + \x4358000000000004 | 2.7021597764222992e+16 | 2.7021597764222992e+16 | \x4358000000000004 | t + \x435f000000000020 | 3.4902897112121472e+16 | 3.4902897112121472e+16 | \x435f000000000020 | t + \xc350000000000002 | -1.8014398509481992e+16 | -1.8014398509481992e+16 | \xc350000000000002 | t + \xc350000000002e06 | -1.8014398509529112e+16 | -1.8014398509529112e+16 | \xc350000000002e06 | t + \xc352000000000003 | -2.0266198323167244e+16 | -2.0266198323167244e+16 | \xc352000000000003 | t + \xc352000000000004 | -2.0266198323167248e+16 | -2.0266198323167248e+16 | \xc352000000000004 | t + \xc358000000000003 | -2.7021597764222988e+16 | -2.7021597764222988e+16 | \xc358000000000003 | t + \xc358000000000004 | -2.7021597764222992e+16 | -2.7021597764222992e+16 | \xc358000000000004 | t + \xc35f000000000020 | -3.4902897112121472e+16 | -3.4902897112121472e+16 | \xc35f000000000020 | t + \x42dc12218377de66 | 123456789012345.6 | 123456789012345.6 | \x42dc12218377de66 | t + \x42a674e79c5fe51f | 12345678901234.56 | 12345678901234.56 | \x42a674e79c5fe51f | t + \x4271f71fb04cb74c | 1234567890123.456 | 1234567890123.456 | \x4271f71fb04cb74c | t + \x423cbe991a145879 | 123456789012.3456 | 123456789012.3456 | \x423cbe991a145879 | t + \x4206fee0e1a9e061 | 12345678901.23456 | 12345678901.23456 | \x4206fee0e1a9e061 | t + \x41d26580b487e6b4 | 1234567890.123456 | 1234567890.123456 | \x41d26580b487e6b4 | t + \x419d6f34540ca453 | 123456789.0123456 | 123456789.0123456 | \x419d6f34540ca453 | t + \x41678c29dcd6e9dc | 12345678.90123456 | 12345678.90123456 | \x41678c29dcd6e9dc | t + \x4132d687e3df217d | 1234567.890123456 | 1234567.890123456 | \x4132d687e3df217d | t + \x40fe240c9fcb68c8 | 123456.7890123456 | 123456.7890123456 | \x40fe240c9fcb68c8 | t + \x40c81cd6e63c53d3 | 12345.67890123456 | 12345.67890123456 | \x40c81cd6e63c53d3 | t + \x40934a4584fd0fdc | 1234.567890123456 | 1234.567890123456 | \x40934a4584fd0fdc | t + \x405edd3c07fb4c93 | 123.4567890123456 | 123.4567890123456 | \x405edd3c07fb4c93 | t + \x4028b0fcd32f7076 | 12.34567890123456 | 12.34567890123456 | \x4028b0fcd32f7076 | t + \x3ff3c0ca428c59f8 | 1.234567890123456 | 1.234567890123456 | \x3ff3c0ca428c59f8 | t + \x3e60000000000000 | 2.9802322387695312e-08 | 2.9802322387695312e-08 | \x3e60000000000000 | t + \xc352bd2668e077c4 | -2.1098088986959632e+16 | -2.1098088986959632e+16 | \xc352bd2668e077c4 | t + \x434018601510c000 | 9.0608011534336e+15 | 9.0608011534336e+15 | \x434018601510c000 | t + \x43d055dc36f24000 | 4.708356024711512e+18 | 4.708356024711512e+18 | \x43d055dc36f24000 | t + \x43e052961c6f8000 | 9.409340012568248e+18 | 9.409340012568248e+18 | \x43e052961c6f8000 | t + \x3ff3c0ca2a5b1d5d | 1.2345678 | 1.2345678 | \x3ff3c0ca2a5b1d5d | t + \x4830f0cf064dd592 | 5.764607523034235e+39 | 5.764607523034235e+39 | \x4830f0cf064dd592 | t + \x4840f0cf064dd592 | 1.152921504606847e+40 | 1.152921504606847e+40 | \x4840f0cf064dd592 | t + \x4850f0cf064dd592 | 2.305843009213694e+40 | 2.305843009213694e+40 | \x4850f0cf064dd592 | t + \x3ff3333333333333 | 1.2 | 1.2 | \x3ff3333333333333 | t + \x3ff3ae147ae147ae | 1.23 | 1.23 | \x3ff3ae147ae147ae | t + \x3ff3be76c8b43958 | 1.234 | 1.234 | \x3ff3be76c8b43958 | t + \x3ff3c083126e978d | 1.2345 | 1.2345 | \x3ff3c083126e978d | t + \x3ff3c0c1fc8f3238 | 1.23456 | 1.23456 | \x3ff3c0c1fc8f3238 | t + \x3ff3c0c9539b8887 | 1.234567 | 1.234567 | \x3ff3c0c9539b8887 | t + \x3ff3c0ca2a5b1d5d | 1.2345678 | 1.2345678 | \x3ff3c0ca2a5b1d5d | t + \x3ff3c0ca4283de1b | 1.23456789 | 1.23456789 | \x3ff3c0ca4283de1b | t + \x3ff3c0ca43db770a | 1.234567895 | 1.234567895 | \x3ff3c0ca43db770a | t + \x3ff3c0ca428abd53 | 1.2345678901 | 1.2345678901 | \x3ff3c0ca428abd53 | t + \x3ff3c0ca428c1d2b | 1.23456789012 | 1.23456789012 | \x3ff3c0ca428c1d2b | t + \x3ff3c0ca428c51f2 | 1.234567890123 | 1.234567890123 | \x3ff3c0ca428c51f2 | t + \x3ff3c0ca428c58fc | 1.2345678901234 | 1.2345678901234 | \x3ff3c0ca428c58fc | t + \x3ff3c0ca428c59dd | 1.23456789012345 | 1.23456789012345 | \x3ff3c0ca428c59dd | t + \x3ff3c0ca428c59f8 | 1.234567890123456 | 1.234567890123456 | \x3ff3c0ca428c59f8 | t + \x3ff3c0ca428c59fb | 1.2345678901234567 | 1.2345678901234567 | \x3ff3c0ca428c59fb | t + \x40112e0be8047a7d | 4.294967294 | 4.294967294 | \x40112e0be8047a7d | t + \x40112e0be815a889 | 4.294967295 | 4.294967295 | \x40112e0be815a889 | t + \x40112e0be826d695 | 4.294967296 | 4.294967296 | \x40112e0be826d695 | t + \x40112e0be83804a1 | 4.294967297 | 4.294967297 | \x40112e0be83804a1 | t + \x40112e0be84932ad | 4.294967298 | 4.294967298 | \x40112e0be84932ad | t + \x0040000000000000 | 1.7800590868057611e-307 | 1.7800590868057611e-307 | \x0040000000000000 | t + \x007fffffffffffff | 2.8480945388892175e-306 | 2.8480945388892175e-306 | \x007fffffffffffff | t + \x0290000000000000 | 2.446494580089078e-296 | 2.446494580089078e-296 | \x0290000000000000 | t + \x029fffffffffffff | 4.8929891601781557e-296 | 4.8929891601781557e-296 | \x029fffffffffffff | t + \x4350000000000000 | 1.8014398509481984e+16 | 1.8014398509481984e+16 | \x4350000000000000 | t + \x435fffffffffffff | 3.6028797018963964e+16 | 3.6028797018963964e+16 | \x435fffffffffffff | t + \x1330000000000000 | 2.900835519859558e-216 | 2.900835519859558e-216 | \x1330000000000000 | t + \x133fffffffffffff | 5.801671039719115e-216 | 5.801671039719115e-216 | \x133fffffffffffff | t + \x3a6fa7161a4d6e0c | 3.196104012172126e-27 | 3.196104012172126e-27 | \x3a6fa7161a4d6e0c | t +(209 rows) + +rollback; +-- clean up, lest opr_sanity complain +--Testcase 269: +drop type xfloat8 cascade; +NOTICE: drop cascades to 6 other objects +DETAIL: drop cascades to function xfloat8in(cstring) +drop cascades to function xfloat8out(xfloat8) +drop cascades to cast from xfloat8 to double precision +drop cascades to cast from double precision to xfloat8 +drop cascades to cast from xfloat8 to bigint +drop cascades to cast from bigint to xfloat8 +-- Clean up +DO $d$ +declare + l_rec record; +begin + for l_rec in (select foreign_table_schema, foreign_table_name + from information_schema.foreign_tables) loop + execute format('drop foreign table %I.%I cascade;', l_rec.foreign_table_schema, l_rec.foreign_table_name); + end loop; +end; +$d$; +--Testcase 270: +DROP SERVER sqlite_svr; +--Testcase 271: +DROP EXTENSION sqlite_fdw CASCADE; diff --git a/expected/13.4/extra/insert.out b/expected/15beta2/extra/insert.out similarity index 96% rename from expected/13.4/extra/insert.out rename to expected/15beta2/extra/insert.out index 917a45c8..090e257f 100644 --- a/expected/13.4/extra/insert.out +++ b/expected/15beta2/extra/insert.out @@ -101,6 +101,23 @@ select col1, col2, char_length(col3) from inserttest01; 30 | 50 | 10000 (8 rows) +-- +-- tuple larger than fillfactor +-- foreign table does not support fillfactor +-- +-- CREATE TABLE large_tuple_test (a int, b text) WITH (fillfactor = 10); +-- ALTER TABLE large_tuple_test ALTER COLUMN b SET STORAGE plain; +-- -- create page w/ free space in range [nearlyEmptyFreeSpace, MaxHeapTupleSize) +-- INSERT INTO large_tuple_test (select 1, NULL); +-- -- should still fit on the page +-- INSERT INTO large_tuple_test (select 2, repeat('a', 1000)); +-- SELECT pg_size_pretty(pg_relation_size('large_tuple_test'::regclass, 'main')); +-- -- add small record to the second page +-- INSERT INTO large_tuple_test (select 3, NULL); +-- -- now this tuple won't fit on the second page, but the insert should +-- -- still succeed by extending the relation +-- INSERT INTO large_tuple_test (select 4, repeat('a', 8126)); +-- DROP TABLE large_tuple_test; -- skip, sqlite fdw does not support customized type /* -- check indirection (field/array assignment), cf bug #14265 @@ -293,33 +310,6 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p -- direct partition inserts should check hash partition bound constraint --- Use hand-rolled hash functions and operator classes to get predictable --- result on different machines. The hash function for int4 simply returns --- the sum of the values passed to it and the one for text returns the length --- of the non-empty string value passed to it or 0. - -create or replace function part_hashint4_noop(value int4, seed int8) -returns int8 as $$ -select value + seed; -$$ language sql immutable; - -create operator class part_test_int4_ops -for type int4 -using hash as -operator 1 =, -function 2 part_hashint4_noop(int4, int8); - -create or replace function part_hashtext_length(value text, seed int8) -RETURNS int8 AS $$ -select length(coalesce(value, ''))::int8 -$$ language sql immutable; - -create operator class part_test_text_ops -for type text -using hash as -operator 1 =, -function 2 part_hashtext_length(text, int8); - create table hash_parted ( a int ) partition by hash (a part_test_int4_ops); @@ -607,9 +597,7 @@ drop table inserttest3; drop table brtrigpartcon; drop function brtrigpartcon1trigf(); --- check that "do nothing" BR triggers work with tuple-routing (this checks --- that estate->es_result_relation_info is appropriately set/reset for each --- routed tuple) +-- check that "do nothing" BR triggers work with tuple-routing create table donothingbrtrig_test (a int, b text) partition by list (a); create table donothingbrtrig_test1 (b text, a int); create table donothingbrtrig_test2 (c text, b text, a int); diff --git a/expected/11.13/extra/int4.out b/expected/15beta2/extra/int4.out similarity index 59% rename from expected/11.13/extra/int4.out rename to expected/15beta2/extra/int4.out index c85f41a9..26da5735 100644 --- a/expected/11.13/extra/int4.out +++ b/expected/15beta2/extra/int4.out @@ -19,7 +19,7 @@ INSERT INTO INT4_TBL(f1) VALUES ('123456 '); INSERT INTO INT4_TBL(f1) VALUES (' -123456'); --Testcase 4: INSERT INTO INT4_TBL(f1) VALUES ('34.5'); -ERROR: invalid input syntax for integer: "34.5" +ERROR: invalid input syntax for type integer: "34.5" LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('34.5'); ^ -- largest and smallest values @@ -35,267 +35,267 @@ LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('1000000000000'); ^ --Testcase 8: INSERT INTO INT4_TBL(f1) VALUES ('asdf'); -ERROR: invalid input syntax for integer: "asdf" +ERROR: invalid input syntax for type integer: "asdf" LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('asdf'); ^ --Testcase 9: INSERT INTO INT4_TBL(f1) VALUES (' '); -ERROR: invalid input syntax for integer: " " +ERROR: invalid input syntax for type integer: " " LINE 1: INSERT INTO INT4_TBL(f1) VALUES (' '); ^ --Testcase 10: INSERT INTO INT4_TBL(f1) VALUES (' asdf '); -ERROR: invalid input syntax for integer: " asdf " +ERROR: invalid input syntax for type integer: " asdf " LINE 1: INSERT INTO INT4_TBL(f1) VALUES (' asdf '); ^ --Testcase 11: INSERT INTO INT4_TBL(f1) VALUES ('- 1234'); -ERROR: invalid input syntax for integer: "- 1234" +ERROR: invalid input syntax for type integer: "- 1234" LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('- 1234'); ^ --Testcase 12: INSERT INTO INT4_TBL(f1) VALUES ('123 5'); -ERROR: invalid input syntax for integer: "123 5" +ERROR: invalid input syntax for type integer: "123 5" LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('123 5'); ^ --Testcase 13: INSERT INTO INT4_TBL(f1) VALUES (''); -ERROR: invalid input syntax for integer: "" +ERROR: invalid input syntax for type integer: "" LINE 1: INSERT INTO INT4_TBL(f1) VALUES (''); ^ --Testcase 14: -SELECT '' AS five, * FROM INT4_TBL; - five | f1 -------+------------- - | 0 - | 123456 - | -123456 - | 2147483647 - | -2147483647 +SELECT * FROM INT4_TBL; + f1 +------------- + 0 + 123456 + -123456 + 2147483647 + -2147483647 (5 rows) --Testcase 15: -SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0'; - four | f1 -------+------------- - | 123456 - | -123456 - | 2147483647 - | -2147483647 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0'; + f1 +------------- + 123456 + -123456 + 2147483647 + -2147483647 (4 rows) --Testcase 16: -SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0'; - four | f1 -------+------------- - | 123456 - | -123456 - | 2147483647 - | -2147483647 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0'; + f1 +------------- + 123456 + -123456 + 2147483647 + -2147483647 (4 rows) --Testcase 17: -SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int2 '0'; - one | f1 ------+---- - | 0 +SELECT i.* FROM INT4_TBL i WHERE i.f1 = int2 '0'; + f1 +---- + 0 (1 row) --Testcase 18: -SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int4 '0'; - one | f1 ------+---- - | 0 +SELECT i.* FROM INT4_TBL i WHERE i.f1 = int4 '0'; + f1 +---- + 0 (1 row) --Testcase 19: -SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int2 '0'; - two | f1 ------+------------- - | -123456 - | -2147483647 +SELECT i.* FROM INT4_TBL i WHERE i.f1 < int2 '0'; + f1 +------------- + -123456 + -2147483647 (2 rows) --Testcase 20: -SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int4 '0'; - two | f1 ------+------------- - | -123456 - | -2147483647 +SELECT i.* FROM INT4_TBL i WHERE i.f1 < int4 '0'; + f1 +------------- + -123456 + -2147483647 (2 rows) --Testcase 21: -SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0'; - three | f1 --------+------------- - | 0 - | -123456 - | -2147483647 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0'; + f1 +------------- + 0 + -123456 + -2147483647 (3 rows) --Testcase 22: -SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0'; - three | f1 --------+------------- - | 0 - | -123456 - | -2147483647 +SELECT i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0'; + f1 +------------- + 0 + -123456 + -2147483647 (3 rows) --Testcase 23: -SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int2 '0'; - two | f1 ------+------------ - | 123456 - | 2147483647 +SELECT i.* FROM INT4_TBL i WHERE i.f1 > int2 '0'; + f1 +------------ + 123456 + 2147483647 (2 rows) --Testcase 24: -SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int4 '0'; - two | f1 ------+------------ - | 123456 - | 2147483647 +SELECT i.* FROM INT4_TBL i WHERE i.f1 > int4 '0'; + f1 +------------ + 123456 + 2147483647 (2 rows) --Testcase 25: -SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0'; - three | f1 --------+------------ - | 0 - | 123456 - | 2147483647 +SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0'; + f1 +------------ + 0 + 123456 + 2147483647 (3 rows) --Testcase 26: -SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0'; - three | f1 --------+------------ - | 0 - | 123456 - | 2147483647 +SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0'; + f1 +------------ + 0 + 123456 + 2147483647 (3 rows) -- positive odds --Testcase 27: -SELECT '' AS one, i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1'; - one | f1 ------+------------ - | 2147483647 +SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1'; + f1 +------------ + 2147483647 (1 row) -- any evens --Testcase 28: -SELECT '' AS three, i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0'; - three | f1 --------+--------- - | 0 - | 123456 - | -123456 +SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0'; + f1 +--------- + 0 + 123456 + -123456 (3 rows) --Testcase 29: -SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i; ERROR: integer out of range --Testcase 30: -SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i WHERE abs(f1) < 1073741824; - five | f1 | x -------+---------+--------- - | 0 | 0 - | 123456 | 246912 - | -123456 | -246912 + f1 | x +---------+--------- + 0 | 0 + 123456 | 246912 + -123456 | -246912 (3 rows) --Testcase 31: -SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i; ERROR: integer out of range --Testcase 32: -SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i WHERE abs(f1) < 1073741824; - five | f1 | x -------+---------+--------- - | 0 | 0 - | 123456 | 246912 - | -123456 | -246912 + f1 | x +---------+--------- + 0 | 0 + 123456 | 246912 + -123456 | -246912 (3 rows) --Testcase 33: -SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i; ERROR: integer out of range --Testcase 34: -SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i WHERE f1 < 2147483646; - five | f1 | x -------+-------------+------------- - | 0 | 2 - | 123456 | 123458 - | -123456 | -123454 - | -2147483647 | -2147483645 + f1 | x +-------------+------------- + 0 | 2 + 123456 | 123458 + -123456 | -123454 + -2147483647 | -2147483645 (4 rows) --Testcase 35: -SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i; ERROR: integer out of range --Testcase 36: -SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i WHERE f1 < 2147483646; - five | f1 | x -------+-------------+------------- - | 0 | 2 - | 123456 | 123458 - | -123456 | -123454 - | -2147483647 | -2147483645 + f1 | x +-------------+------------- + 0 | 2 + 123456 | 123458 + -123456 | -123454 + -2147483647 | -2147483645 (4 rows) --Testcase 37: -SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i; ERROR: integer out of range --Testcase 38: -SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i WHERE f1 > -2147483647; - five | f1 | x -------+------------+------------ - | 0 | -2 - | 123456 | 123454 - | -123456 | -123458 - | 2147483647 | 2147483645 + f1 | x +------------+------------ + 0 | -2 + 123456 | 123454 + -123456 | -123458 + 2147483647 | 2147483645 (4 rows) --Testcase 39: -SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i; ERROR: integer out of range --Testcase 40: -SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i WHERE f1 > -2147483647; - five | f1 | x -------+------------+------------ - | 0 | -2 - | 123456 | 123454 - | -123456 | -123458 - | 2147483647 | 2147483645 + f1 | x +------------+------------ + 0 | -2 + 123456 | 123454 + -123456 | -123458 + 2147483647 | 2147483645 (4 rows) --Testcase 41: -SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i; - five | f1 | x -------+-------------+------------- - | 0 | 0 - | 123456 | 61728 - | -123456 | -61728 - | 2147483647 | 1073741823 - | -2147483647 | -1073741823 +SELECT i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i; + f1 | x +-------------+------------- + 0 | 0 + 123456 | 61728 + -123456 | -61728 + 2147483647 | 1073741823 + -2147483647 | -1073741823 (5 rows) --Testcase 42: -SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT4_TBL i; - five | f1 | x -------+-------------+------------- - | 0 | 0 - | 123456 | 61728 - | -123456 | -61728 - | 2147483647 | 1073741823 - | -2147483647 | -1073741823 +SELECT i.f1, i.f1 / int4 '2' AS x FROM INT4_TBL i; + f1 | x +-------------+------------- + 0 | 0 + 123456 | 61728 + -123456 | -61728 + 2147483647 | 1073741823 + -2147483647 | -1073741823 (5 rows) -- @@ -390,28 +390,6 @@ SELECT f1 < f2 AS false FROM INT4_TMP; f (1 row) ---Testcase 48: -DELETE FROM INT4_TMP; ---Testcase 87: -INSERT INTO INT4_TMP VALUES (4!); ---Testcase 88: -SELECT f1 as twenty_four FROM INT4_TMP; - twenty_four -------------- - 24 -(1 row) - ---Testcase 49: -DELETE FROM INT4_TMP; ---Testcase 89: -INSERT INTO INT4_TMP VALUES (!!3); ---Testcase 90: -SELECT f1 as six FROM INT4_TMP; - six ------ - 6 -(1 row) - --Testcase 50: DELETE FROM INT4_TMP; --Testcase 91: @@ -571,30 +549,31 @@ INSERT INTO INT4_TMP VALUES ((-2147483648)::int4, 1073741824::int4); --Testcase 119: SELECT f1, f2, gcd(f1, f2), gcd(f1, -f2), gcd(f2, f1), gcd(-f2, f1) FROM INT4_TMP; -ERROR: function gcd(integer, integer) does not exist -LINE 1: SELECT f1, f2, gcd(f1, f2), gcd(f1, -f2), gcd(f2, f1), gcd(-... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. + f1 | f2 | gcd | gcd | gcd | gcd +-------------+------------+------------+------------+------------+------------ + 0 | 0 | 0 | 0 | 0 | 0 + 0 | 6410818 | 6410818 | 6410818 | 6410818 | 6410818 + 61866666 | 6410818 | 1466 | 1466 | 1466 | 1466 + -61866666 | 6410818 | 1466 | 1466 | 1466 | 1466 + -2147483648 | 1 | 1 | 1 | 1 | 1 + -2147483648 | 2147483647 | 1 | 1 | 1 | 1 + -2147483648 | 1073741824 | 1073741824 | 1073741824 | 1073741824 | 1073741824 +(7 rows) + --Testcase 120: DELETE FROM INT4_TMP; --Testcase 121: INSERT INTO INT4_TMP VALUES ((-2147483648)::int4, 0::int4); --Testcase 122: SELECT gcd(f1, f2) FROM INT4_TMP; -- overflow -ERROR: function gcd(integer, integer) does not exist -LINE 1: SELECT gcd(f1, f2) FROM INT4_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. +ERROR: integer out of range --Testcase 123: DELETE FROM INT4_TMP; --Testcase 124: INSERT INTO INT4_TMP VALUES ((-2147483648)::int4, (-2147483648)::int4); --Testcase 125: SELECT gcd(f1, f2) FROM INT4_TMP; -- overflow -ERROR: function gcd(integer, integer) does not exist -LINE 1: SELECT gcd(f1, f2) FROM INT4_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. +ERROR: integer out of range -- test lcm() --Testcase 126: DELETE FROM INT4_TMP; @@ -608,30 +587,30 @@ INSERT INTO INT4_TMP VALUES ((-2147483648)::int4, 0::int4); --Testcase 128: SELECT f1, f2, lcm(f1, f2), lcm(f1, -f2), lcm(f2, f1), lcm(-f2, f1) FROM INT4_TMP; -ERROR: function lcm(integer, integer) does not exist -LINE 1: SELECT f1, f2, lcm(f1, f2), lcm(f1, -f2), lcm(f2, f1), lcm(-... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. + f1 | f2 | lcm | lcm | lcm | lcm +-------------+-----+------+------+------+------ + 0 | 0 | 0 | 0 | 0 | 0 + 0 | 42 | 0 | 0 | 0 | 0 + 42 | 42 | 42 | 42 | 42 | 42 + 330 | 462 | 2310 | 2310 | 2310 | 2310 + -330 | 462 | 2310 | 2310 | 2310 | 2310 + -2147483648 | 0 | 0 | 0 | 0 | 0 +(6 rows) + --Testcase 129: DELETE FROM INT4_TMP; --Testcase 130: INSERT INTO INT4_TMP VALUES ((-2147483648)::int4, 1::int4); --Testcase 131: SELECT lcm(f1, f2) FROM INT4_TMP; -- overflow -ERROR: function lcm(integer, integer) does not exist -LINE 1: SELECT lcm(f1, f2) FROM INT4_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. +ERROR: integer out of range --Testcase 132: DELETE FROM INT4_TMP; --Testcase 133: INSERT INTO INT4_TMP VALUES (2147483647::int4, 2147483646::int4); --Testcase 134: SELECT lcm(f1, f2) FROM INT4_TMP; -- overflow -ERROR: function lcm(integer, integer) does not exist -LINE 1: SELECT lcm(f1, f2) FROM INT4_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. +ERROR: integer out of range -- Clean up DO $d$ declare diff --git a/expected/10.18/extra/int8.out b/expected/15beta2/extra/int8.out similarity index 70% rename from expected/10.18/extra/int8.out rename to expected/15beta2/extra/int8.out index 63a8d66f..7b036da6 100644 --- a/expected/10.18/extra/int8.out +++ b/expected/15beta2/extra/int8.out @@ -34,12 +34,12 @@ INSERT INTO INT8_TBL VALUES('+4567890123456789','-4567890123456789'); -- bad inputs --Testcase 6: INSERT INTO INT8_TBL(q1) VALUES (' '); -ERROR: invalid input syntax for integer: " " +ERROR: invalid input syntax for type bigint: " " LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' '); ^ --Testcase 7: INSERT INTO INT8_TBL(q1) VALUES ('xxx'); -ERROR: invalid input syntax for integer: "xxx" +ERROR: invalid input syntax for type bigint: "xxx" LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('xxx'); ^ --Testcase 8: @@ -54,17 +54,17 @@ LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340... ^ --Testcase 10: INSERT INTO INT8_TBL(q1) VALUES ('- 123'); -ERROR: invalid input syntax for integer: "- 123" +ERROR: invalid input syntax for type bigint: "- 123" LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('- 123'); ^ --Testcase 11: INSERT INTO INT8_TBL(q1) VALUES (' 345 5'); -ERROR: invalid input syntax for integer: " 345 5" +ERROR: invalid input syntax for type bigint: " 345 5" LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' 345 5'); ^ --Testcase 12: INSERT INTO INT8_TBL(q1) VALUES (''); -ERROR: invalid input syntax for integer: "" +ERROR: invalid input syntax for type bigint: "" LINE 1: INSERT INTO INT8_TBL(q1) VALUES (''); ^ --Testcase 13: @@ -339,82 +339,82 @@ SELECT * FROM INT8_TBL WHERE '123'::int2 >= q1; (2 rows) --Testcase 44: -SELECT '' AS five, q1 AS plus, -q1 AS minus FROM INT8_TBL; - five | plus | minus -------+------------------+------------------- - | 123 | -123 - | 123 | -123 - | 4567890123456789 | -4567890123456789 - | 4567890123456789 | -4567890123456789 - | 4567890123456789 | -4567890123456789 +SELECT q1 AS plus, -q1 AS minus FROM INT8_TBL; + plus | minus +------------------+------------------- + 123 | -123 + 123 | -123 + 4567890123456789 | -4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | -4567890123456789 (5 rows) --Testcase 45: -SELECT '' AS five, q1, q2, q1 + q2 AS plus FROM INT8_TBL; - five | q1 | q2 | plus -------+------------------+-------------------+------------------ - | 123 | 456 | 579 - | 123 | 4567890123456789 | 4567890123456912 - | 4567890123456789 | 123 | 4567890123456912 - | 4567890123456789 | 4567890123456789 | 9135780246913578 - | 4567890123456789 | -4567890123456789 | 0 +SELECT q1, q2, q1 + q2 AS plus FROM INT8_TBL; + q1 | q2 | plus +------------------+-------------------+------------------ + 123 | 456 | 579 + 123 | 4567890123456789 | 4567890123456912 + 4567890123456789 | 123 | 4567890123456912 + 4567890123456789 | 4567890123456789 | 9135780246913578 + 4567890123456789 | -4567890123456789 | 0 (5 rows) --Testcase 46: -SELECT '' AS five, q1, q2, q1 - q2 AS minus FROM INT8_TBL; - five | q1 | q2 | minus -------+------------------+-------------------+------------------- - | 123 | 456 | -333 - | 123 | 4567890123456789 | -4567890123456666 - | 4567890123456789 | 123 | 4567890123456666 - | 4567890123456789 | 4567890123456789 | 0 - | 4567890123456789 | -4567890123456789 | 9135780246913578 +SELECT q1, q2, q1 - q2 AS minus FROM INT8_TBL; + q1 | q2 | minus +------------------+-------------------+------------------- + 123 | 456 | -333 + 123 | 4567890123456789 | -4567890123456666 + 4567890123456789 | 123 | 4567890123456666 + 4567890123456789 | 4567890123456789 | 0 + 4567890123456789 | -4567890123456789 | 9135780246913578 (5 rows) --Testcase 47: -SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL; +SELECT q1, q2, q1 * q2 AS multiply FROM INT8_TBL; ERROR: bigint out of range --Testcase 48: -SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL +SELECT q1, q2, q1 * q2 AS multiply FROM INT8_TBL WHERE q1 < 1000 or (q2 > 0 and q2 < 1000); - three | q1 | q2 | multiply --------+------------------+------------------+-------------------- - | 123 | 456 | 56088 - | 123 | 4567890123456789 | 561850485185185047 - | 4567890123456789 | 123 | 561850485185185047 + q1 | q2 | multiply +------------------+------------------+-------------------- + 123 | 456 | 56088 + 123 | 4567890123456789 | 561850485185185047 + 4567890123456789 | 123 | 561850485185185047 (3 rows) --Testcase 49: -SELECT '' AS five, q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM INT8_TBL; - five | q1 | q2 | divide | mod -------+------------------+-------------------+----------------+----- - | 123 | 456 | 0 | 123 - | 123 | 4567890123456789 | 0 | 123 - | 4567890123456789 | 123 | 37137318076884 | 57 - | 4567890123456789 | 4567890123456789 | 1 | 0 - | 4567890123456789 | -4567890123456789 | -1 | 0 +SELECT q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM INT8_TBL; + q1 | q2 | divide | mod +------------------+-------------------+----------------+----- + 123 | 456 | 0 | 123 + 123 | 4567890123456789 | 0 | 123 + 4567890123456789 | 123 | 37137318076884 | 57 + 4567890123456789 | 4567890123456789 | 1 | 0 + 4567890123456789 | -4567890123456789 | -1 | 0 (5 rows) --Testcase 50: -SELECT '' AS five, q1, float8(q1) FROM INT8_TBL; - five | q1 | float8 -------+------------------+---------------------- - | 123 | 123 - | 123 | 123 - | 4567890123456789 | 4.56789012345679e+15 - | 4567890123456789 | 4.56789012345679e+15 - | 4567890123456789 | 4.56789012345679e+15 +SELECT q1, float8(q1) FROM INT8_TBL; + q1 | float8 +------------------+----------------------- + 123 | 123 + 123 | 123 + 4567890123456789 | 4.567890123456789e+15 + 4567890123456789 | 4.567890123456789e+15 + 4567890123456789 | 4.567890123456789e+15 (5 rows) --Testcase 51: -SELECT '' AS five, q2, float8(q2) FROM INT8_TBL; - five | q2 | float8 -------+-------------------+----------------------- - | 456 | 456 - | 4567890123456789 | 4.56789012345679e+15 - | 123 | 123 - | 4567890123456789 | 4.56789012345679e+15 - | -4567890123456789 | -4.56789012345679e+15 +SELECT q2, float8(q2) FROM INT8_TBL; + q2 | float8 +-------------------+------------------------ + 456 | 456 + 4567890123456789 | 4.567890123456789e+15 + 123 | 123 + 4567890123456789 | 4.567890123456789e+15 + -4567890123456789 | -4.567890123456789e+15 (5 rows) --Testcase 52: @@ -440,25 +440,25 @@ SELECT 37 - q1 AS minus4 FROM INT8_TBL; (5 rows) --Testcase 54: -SELECT '' AS five, 2 * q1 AS "twice int4" FROM INT8_TBL; - five | twice int4 -------+------------------ - | 246 - | 246 - | 9135780246913578 - | 9135780246913578 - | 9135780246913578 +SELECT 2 * q1 AS "twice int4" FROM INT8_TBL; + twice int4 +------------------ + 246 + 246 + 9135780246913578 + 9135780246913578 + 9135780246913578 (5 rows) --Testcase 55: -SELECT '' AS five, q1 * 2 AS "twice int4" FROM INT8_TBL; - five | twice int4 -------+------------------ - | 246 - | 246 - | 9135780246913578 - | 9135780246913578 - | 9135780246913578 +SELECT q1 * 2 AS "twice int4" FROM INT8_TBL; + twice int4 +------------------ + 246 + 246 + 9135780246913578 + 9135780246913578 + 9135780246913578 (5 rows) -- int8 op int4 @@ -537,194 +537,194 @@ SELECT max(q1), max(q2) FROM INT8_TBL; -- TO_CHAR() -- --Testcase 63: -SELECT '' AS to_char_1, to_char(q1, '9G999G999G999G999G999'), to_char(q2, '9,999,999,999,999,999') +SELECT to_char(q1, '9G999G999G999G999G999'), to_char(q2, '9,999,999,999,999,999') FROM INT8_TBL; - to_char_1 | to_char | to_char ------------+------------------------+------------------------ - | 123 | 456 - | 123 | 4,567,890,123,456,789 - | 4,567,890,123,456,789 | 123 - | 4,567,890,123,456,789 | 4,567,890,123,456,789 - | 4,567,890,123,456,789 | -4,567,890,123,456,789 + to_char | to_char +------------------------+------------------------ + 123 | 456 + 123 | 4,567,890,123,456,789 + 4,567,890,123,456,789 | 123 + 4,567,890,123,456,789 | 4,567,890,123,456,789 + 4,567,890,123,456,789 | -4,567,890,123,456,789 (5 rows) --Testcase 64: -SELECT '' AS to_char_2, to_char(q1, '9G999G999G999G999G999D999G999'), to_char(q2, '9,999,999,999,999,999.999,999') +SELECT to_char(q1, '9G999G999G999G999G999D999G999'), to_char(q2, '9,999,999,999,999,999.999,999') FROM INT8_TBL; - to_char_2 | to_char | to_char ------------+--------------------------------+-------------------------------- - | 123.000,000 | 456.000,000 - | 123.000,000 | 4,567,890,123,456,789.000,000 - | 4,567,890,123,456,789.000,000 | 123.000,000 - | 4,567,890,123,456,789.000,000 | 4,567,890,123,456,789.000,000 - | 4,567,890,123,456,789.000,000 | -4,567,890,123,456,789.000,000 + to_char | to_char +--------------------------------+-------------------------------- + 123.000,000 | 456.000,000 + 123.000,000 | 4,567,890,123,456,789.000,000 + 4,567,890,123,456,789.000,000 | 123.000,000 + 4,567,890,123,456,789.000,000 | 4,567,890,123,456,789.000,000 + 4,567,890,123,456,789.000,000 | -4,567,890,123,456,789.000,000 (5 rows) --Testcase 65: -SELECT '' AS to_char_3, to_char( (q1 * -1), '9999999999999999PR'), to_char( (q2 * -1), '9999999999999999.999PR') +SELECT to_char( (q1 * -1), '9999999999999999PR'), to_char( (q2 * -1), '9999999999999999.999PR') FROM INT8_TBL; - to_char_3 | to_char | to_char ------------+--------------------+------------------------ - | <123> | <456.000> - | <123> | <4567890123456789.000> - | <4567890123456789> | <123.000> - | <4567890123456789> | <4567890123456789.000> - | <4567890123456789> | 4567890123456789.000 + to_char | to_char +--------------------+------------------------ + <123> | <456.000> + <123> | <4567890123456789.000> + <4567890123456789> | <123.000> + <4567890123456789> | <4567890123456789.000> + <4567890123456789> | 4567890123456789.000 (5 rows) --Testcase 66: -SELECT '' AS to_char_4, to_char( (q1 * -1), '9999999999999999S'), to_char( (q2 * -1), 'S9999999999999999') +SELECT to_char( (q1 * -1), '9999999999999999S'), to_char( (q2 * -1), 'S9999999999999999') FROM INT8_TBL; - to_char_4 | to_char | to_char ------------+-------------------+------------------- - | 123- | -456 - | 123- | -4567890123456789 - | 4567890123456789- | -123 - | 4567890123456789- | -4567890123456789 - | 4567890123456789- | +4567890123456789 + to_char | to_char +-------------------+------------------- + 123- | -456 + 123- | -4567890123456789 + 4567890123456789- | -123 + 4567890123456789- | -4567890123456789 + 4567890123456789- | +4567890123456789 (5 rows) --Testcase 67: -SELECT '' AS to_char_5, to_char(q2, 'MI9999999999999999') FROM INT8_TBL; - to_char_5 | to_char ------------+------------------- - | 456 - | 4567890123456789 - | 123 - | 4567890123456789 - | -4567890123456789 +SELECT to_char(q2, 'MI9999999999999999') FROM INT8_TBL; + to_char +------------------- + 456 + 4567890123456789 + 123 + 4567890123456789 + -4567890123456789 (5 rows) --Testcase 68: -SELECT '' AS to_char_6, to_char(q2, 'FMS9999999999999999') FROM INT8_TBL; - to_char_6 | to_char ------------+------------------- - | +456 - | +4567890123456789 - | +123 - | +4567890123456789 - | -4567890123456789 +SELECT to_char(q2, 'FMS9999999999999999') FROM INT8_TBL; + to_char +------------------- + +456 + +4567890123456789 + +123 + +4567890123456789 + -4567890123456789 (5 rows) --Testcase 69: -SELECT '' AS to_char_7, to_char(q2, 'FM9999999999999999THPR') FROM INT8_TBL; - to_char_7 | to_char ------------+-------------------- - | 456TH - | 4567890123456789TH - | 123RD - | 4567890123456789TH - | <4567890123456789> +SELECT to_char(q2, 'FM9999999999999999THPR') FROM INT8_TBL; + to_char +-------------------- + 456TH + 4567890123456789TH + 123RD + 4567890123456789TH + <4567890123456789> (5 rows) --Testcase 70: -SELECT '' AS to_char_8, to_char(q2, 'SG9999999999999999th') FROM INT8_TBL; - to_char_8 | to_char ------------+--------------------- - | + 456th - | +4567890123456789th - | + 123rd - | +4567890123456789th - | -4567890123456789 +SELECT to_char(q2, 'SG9999999999999999th') FROM INT8_TBL; + to_char +--------------------- + + 456th + +4567890123456789th + + 123rd + +4567890123456789th + -4567890123456789 (5 rows) --Testcase 71: -SELECT '' AS to_char_9, to_char(q2, '0999999999999999') FROM INT8_TBL; - to_char_9 | to_char ------------+------------------- - | 0000000000000456 - | 4567890123456789 - | 0000000000000123 - | 4567890123456789 - | -4567890123456789 +SELECT to_char(q2, '0999999999999999') FROM INT8_TBL; + to_char +------------------- + 0000000000000456 + 4567890123456789 + 0000000000000123 + 4567890123456789 + -4567890123456789 (5 rows) --Testcase 72: -SELECT '' AS to_char_10, to_char(q2, 'S0999999999999999') FROM INT8_TBL; - to_char_10 | to_char -------------+------------------- - | +0000000000000456 - | +4567890123456789 - | +0000000000000123 - | +4567890123456789 - | -4567890123456789 +SELECT to_char(q2, 'S0999999999999999') FROM INT8_TBL; + to_char +------------------- + +0000000000000456 + +4567890123456789 + +0000000000000123 + +4567890123456789 + -4567890123456789 (5 rows) --Testcase 73: -SELECT '' AS to_char_11, to_char(q2, 'FM0999999999999999') FROM INT8_TBL; - to_char_11 | to_char -------------+------------------- - | 0000000000000456 - | 4567890123456789 - | 0000000000000123 - | 4567890123456789 - | -4567890123456789 +SELECT to_char(q2, 'FM0999999999999999') FROM INT8_TBL; + to_char +------------------- + 0000000000000456 + 4567890123456789 + 0000000000000123 + 4567890123456789 + -4567890123456789 (5 rows) --Testcase 74: -SELECT '' AS to_char_12, to_char(q2, 'FM9999999999999999.000') FROM INT8_TBL; - to_char_12 | to_char -------------+----------------------- - | 456.000 - | 4567890123456789.000 - | 123.000 - | 4567890123456789.000 - | -4567890123456789.000 +SELECT to_char(q2, 'FM9999999999999999.000') FROM INT8_TBL; + to_char +----------------------- + 456.000 + 4567890123456789.000 + 123.000 + 4567890123456789.000 + -4567890123456789.000 (5 rows) --Testcase 75: -SELECT '' AS to_char_13, to_char(q2, 'L9999999999999999.000') FROM INT8_TBL; - to_char_13 | to_char -------------+------------------------ - | 456.000 - | 4567890123456789.000 - | 123.000 - | 4567890123456789.000 - | -4567890123456789.000 +SELECT to_char(q2, 'L9999999999999999.000') FROM INT8_TBL; + to_char +------------------------ + 456.000 + 4567890123456789.000 + 123.000 + 4567890123456789.000 + -4567890123456789.000 (5 rows) --Testcase 76: -SELECT '' AS to_char_14, to_char(q2, 'FM9999999999999999.999') FROM INT8_TBL; - to_char_14 | to_char -------------+-------------------- - | 456. - | 4567890123456789. - | 123. - | 4567890123456789. - | -4567890123456789. +SELECT to_char(q2, 'FM9999999999999999.999') FROM INT8_TBL; + to_char +-------------------- + 456. + 4567890123456789. + 123. + 4567890123456789. + -4567890123456789. (5 rows) --Testcase 77: -SELECT '' AS to_char_15, to_char(q2, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9') FROM INT8_TBL; - to_char_15 | to_char -------------+------------------------------------------- - | +4 5 6 . 0 0 0 - | +4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 . 0 0 0 - | +1 2 3 . 0 0 0 - | +4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 . 0 0 0 - | -4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 . 0 0 0 +SELECT to_char(q2, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9') FROM INT8_TBL; + to_char +------------------------------------------- + +4 5 6 . 0 0 0 + +4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 . 0 0 0 + +1 2 3 . 0 0 0 + +4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 . 0 0 0 + -4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 . 0 0 0 (5 rows) --Testcase 78: -SELECT '' AS to_char_16, to_char(q2, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM INT8_TBL; - to_char_16 | to_char -------------+----------------------------------------------------------- - | text 9999 "text between quote marks" 456 - | 45678 text 9012 9999 345 "text between quote marks" 6789 - | text 9999 "text between quote marks" 123 - | 45678 text 9012 9999 345 "text between quote marks" 6789 - | -45678 text 9012 9999 345 "text between quote marks" 6789 +SELECT to_char(q2, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM INT8_TBL; + to_char +----------------------------------------------------------- + text 9999 "text between quote marks" 456 + 45678 text 9012 9999 345 "text between quote marks" 6789 + text 9999 "text between quote marks" 123 + 45678 text 9012 9999 345 "text between quote marks" 6789 + -45678 text 9012 9999 345 "text between quote marks" 6789 (5 rows) --Testcase 79: -SELECT '' AS to_char_17, to_char(q2, '999999SG9999999999') FROM INT8_TBL; - to_char_17 | to_char -------------+------------------- - | + 456 - | 456789+0123456789 - | + 123 - | 456789+0123456789 - | 456789-0123456789 +SELECT to_char(q2, '999999SG9999999999') FROM INT8_TBL; + to_char +------------------- + + 456 + 456789+0123456789 + + 123 + 456789+0123456789 + 456789-0123456789 (5 rows) -- check min/max values and overflow behavior @@ -853,8 +853,7 @@ DELETE FROM INT8_TMP; INSERT INTO INT8_TMP VALUES ('-9223372036854775808'::int8); --Testcase 171: SELECT abs(q1) FROM INT8_TMP; -ERROR: failed to execute remote SQL: rc=1 integer overflow - sql=SELECT abs(`q1`) FROM main."int8_tmp" +ERROR: bigint out of range --Testcase 95: DELETE FROM INT8_TMP; --Testcase 172: @@ -991,13 +990,13 @@ SELECT CAST(q5::int2 as int8) FROM INT8_TMP; --Testcase 114: SELECT CAST(q1 AS float4), CAST(q2 AS float8) FROM INT8_TBL; - q1 | q2 --------------+----------------------- - 123 | 456 - 123 | 4.56789012345679e+15 - 4.56789e+15 | 123 - 4.56789e+15 | 4.56789012345679e+15 - 4.56789e+15 | -4.56789012345679e+15 + q1 | q2 +-------------+------------------------ + 123 | 456 + 123 | 4.567890123456789e+15 + 4.56789e+15 | 123 + 4.56789e+15 | 4.567890123456789e+15 + 4.56789e+15 | -4.567890123456789e+15 (5 rows) --Testcase 203: @@ -1245,30 +1244,31 @@ INSERT INTO INT8_TMP VALUES ((-9223372036854775808)::int8, 4611686018427387904::int8); --Testcase 233: SELECT q1, q2, gcd(q1, q2), gcd(q1, -q2), gcd(q2, q1), gcd(-q2, q1) FROM INT8_TMP; -ERROR: function gcd(bigint, bigint) does not exist -LINE 1: SELECT q1, q2, gcd(q1, q2), gcd(q1, -q2), gcd(q2, q1), gcd(-... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. + q1 | q2 | gcd | gcd | gcd | gcd +----------------------+---------------------+---------------------+---------------------+---------------------+--------------------- + 0 | 0 | 0 | 0 | 0 | 0 + 0 | 29893644334 | 29893644334 | 29893644334 | 29893644334 | 29893644334 + 288484263558 | 29893644334 | 6835958 | 6835958 | 6835958 | 6835958 + -288484263558 | 29893644334 | 6835958 | 6835958 | 6835958 | 6835958 + -9223372036854775808 | 1 | 1 | 1 | 1 | 1 + -9223372036854775808 | 9223372036854775807 | 1 | 1 | 1 | 1 + -9223372036854775808 | 4611686018427387904 | 4611686018427387904 | 4611686018427387904 | 4611686018427387904 | 4611686018427387904 +(7 rows) + --Testcase 234: DELETE FROM INT8_TMP; --Testcase 235: INSERT INTO INT8_TMP VALUES ((-9223372036854775808)::int8, 0::int8); --Testcase 236: SELECT gcd(q1, q2) FROM INT8_TMP; -- overflow -ERROR: function gcd(bigint, bigint) does not exist -LINE 1: SELECT gcd(q1, q2) FROM INT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. +ERROR: bigint out of range --Testcase 237: DELETE FROM INT8_TMP; --Testcase 238: INSERT INTO INT8_TMP VALUES ((-9223372036854775808)::int8, (-9223372036854775808)::int8); --Testcase 239: SELECT gcd(q1, q2) FROM INT8_TMP; -- overflow -ERROR: function gcd(bigint, bigint) does not exist -LINE 1: SELECT gcd(q1, q2) FROM INT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. +ERROR: bigint out of range -- test lcm() --Testcase 240: DELETE FROM INT8_TMP; @@ -1282,30 +1282,30 @@ INSERT INTO INT8_TMP VALUES ((-9223372036854775808)::int8, 0::int8); --Testcase 242: SELECT q1, q2, lcm(q1, q2), lcm(q1, -q2), lcm(q2, q1), lcm(-q2, q1) FROM INT8_TMP; -ERROR: function lcm(bigint, bigint) does not exist -LINE 1: SELECT q1, q2, lcm(q1, q2), lcm(q1, -q2), lcm(q2, q1), lcm(-... - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. + q1 | q2 | lcm | lcm | lcm | lcm +----------------------+-------------+------------------+------------------+------------------+------------------ + 0 | 0 | 0 | 0 | 0 | 0 + 0 | 29893644334 | 0 | 0 | 0 | 0 + 29893644334 | 29893644334 | 29893644334 | 29893644334 | 29893644334 | 29893644334 + 288484263558 | 29893644334 | 1261541684539134 | 1261541684539134 | 1261541684539134 | 1261541684539134 + -288484263558 | 29893644334 | 1261541684539134 | 1261541684539134 | 1261541684539134 | 1261541684539134 + -9223372036854775808 | 0 | 0 | 0 | 0 | 0 +(6 rows) + --Testcase 243: DELETE FROM INT8_TMP; --Testcase 244: INSERT INTO INT8_TMP VALUES ((-9223372036854775808)::int8, 1::int8); --Testcase 245: SELECT lcm(q1, q2) FROM INT8_TMP; -- overflow -ERROR: function lcm(bigint, bigint) does not exist -LINE 1: SELECT lcm(q1, q2) FROM INT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. +ERROR: bigint out of range --Testcase 246: DELETE FROM INT8_TMP; --Testcase 247: INSERT INTO INT8_TMP VALUES ((9223372036854775807)::int8, (9223372036854775806)::int8); --Testcase 248: SELECT lcm(q1, q2) FROM INT8_TMP; -- overflow -ERROR: function lcm(bigint, bigint) does not exist -LINE 1: SELECT lcm(q1, q2) FROM INT8_TMP; - ^ -HINT: No function matches the given name and argument types. You might need to add explicit type casts. +ERROR: bigint out of range -- Clean up DO $d$ declare diff --git a/expected/10.18/extra/join.out b/expected/15beta2/extra/join.out similarity index 74% rename from expected/10.18/extra/join.out rename to expected/15beta2/extra/join.out index 5634f624..f85a9643 100644 --- a/expected/10.18/extra/join.out +++ b/expected/15beta2/extra/join.out @@ -119,196 +119,196 @@ analyze onerow; -- before diving into more complex join syntax. -- --Testcase 21: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL AS tx; - xxx | i | j | t ------+---+---+------- - | 1 | 4 | one - | 2 | 3 | two - | 3 | 2 | three - | 4 | 1 | four - | 5 | 0 | five - | 6 | 6 | six - | 7 | 7 | seven - | 8 | 8 | eight - | 0 | | zero - | | | null - | | 0 | zero + i | j | t +---+---+------- + 1 | 4 | one + 2 | 3 | two + 3 | 2 | three + 4 | 1 | four + 5 | 0 | five + 6 | 6 | six + 7 | 7 | seven + 8 | 8 | eight + 0 | | zero + | | null + | 0 | zero (11 rows) --Testcase 22: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL tx; - xxx | i | j | t ------+---+---+------- - | 1 | 4 | one - | 2 | 3 | two - | 3 | 2 | three - | 4 | 1 | four - | 5 | 0 | five - | 6 | 6 | six - | 7 | 7 | seven - | 8 | 8 | eight - | 0 | | zero - | | | null - | | 0 | zero + i | j | t +---+---+------- + 1 | 4 | one + 2 | 3 | two + 3 | 2 | three + 4 | 1 | four + 5 | 0 | five + 6 | 6 | six + 7 | 7 | seven + 8 | 8 | eight + 0 | | zero + | | null + | 0 | zero (11 rows) --Testcase 23: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL AS t1 (a, b, c); - xxx | a | b | c ------+---+---+------- - | 1 | 4 | one - | 2 | 3 | two - | 3 | 2 | three - | 4 | 1 | four - | 5 | 0 | five - | 6 | 6 | six - | 7 | 7 | seven - | 8 | 8 | eight - | 0 | | zero - | | | null - | | 0 | zero + a | b | c +---+---+------- + 1 | 4 | one + 2 | 3 | two + 3 | 2 | three + 4 | 1 | four + 5 | 0 | five + 6 | 6 | six + 7 | 7 | seven + 8 | 8 | eight + 0 | | zero + | | null + | 0 | zero (11 rows) --Testcase 24: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c); - xxx | a | b | c ------+---+---+------- - | 1 | 4 | one - | 2 | 3 | two - | 3 | 2 | three - | 4 | 1 | four - | 5 | 0 | five - | 6 | 6 | six - | 7 | 7 | seven - | 8 | 8 | eight - | 0 | | zero - | | | null - | | 0 | zero + a | b | c +---+---+------- + 1 | 4 | one + 2 | 3 | two + 3 | 2 | three + 4 | 1 | four + 5 | 0 | five + 6 | 6 | six + 7 | 7 | seven + 8 | 8 | eight + 0 | | zero + | | null + | 0 | zero (11 rows) --Testcase 25: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e); - xxx | a | b | c | d | e ------+---+---+-------+---+---- - | 1 | 4 | one | 1 | -1 - | 2 | 3 | two | 1 | -1 - | 3 | 2 | three | 1 | -1 - | 4 | 1 | four | 1 | -1 - | 5 | 0 | five | 1 | -1 - | 6 | 6 | six | 1 | -1 - | 7 | 7 | seven | 1 | -1 - | 8 | 8 | eight | 1 | -1 - | 0 | | zero | 1 | -1 - | | | null | 1 | -1 - | | 0 | zero | 1 | -1 - | 1 | 4 | one | 2 | 2 - | 2 | 3 | two | 2 | 2 - | 3 | 2 | three | 2 | 2 - | 4 | 1 | four | 2 | 2 - | 5 | 0 | five | 2 | 2 - | 6 | 6 | six | 2 | 2 - | 7 | 7 | seven | 2 | 2 - | 8 | 8 | eight | 2 | 2 - | 0 | | zero | 2 | 2 - | | | null | 2 | 2 - | | 0 | zero | 2 | 2 - | 1 | 4 | one | 3 | -3 - | 2 | 3 | two | 3 | -3 - | 3 | 2 | three | 3 | -3 - | 4 | 1 | four | 3 | -3 - | 5 | 0 | five | 3 | -3 - | 6 | 6 | six | 3 | -3 - | 7 | 7 | seven | 3 | -3 - | 8 | 8 | eight | 3 | -3 - | 0 | | zero | 3 | -3 - | | | null | 3 | -3 - | | 0 | zero | 3 | -3 - | 1 | 4 | one | 2 | 4 - | 2 | 3 | two | 2 | 4 - | 3 | 2 | three | 2 | 4 - | 4 | 1 | four | 2 | 4 - | 5 | 0 | five | 2 | 4 - | 6 | 6 | six | 2 | 4 - | 7 | 7 | seven | 2 | 4 - | 8 | 8 | eight | 2 | 4 - | 0 | | zero | 2 | 4 - | | | null | 2 | 4 - | | 0 | zero | 2 | 4 - | 1 | 4 | one | 5 | -5 - | 2 | 3 | two | 5 | -5 - | 3 | 2 | three | 5 | -5 - | 4 | 1 | four | 5 | -5 - | 5 | 0 | five | 5 | -5 - | 6 | 6 | six | 5 | -5 - | 7 | 7 | seven | 5 | -5 - | 8 | 8 | eight | 5 | -5 - | 0 | | zero | 5 | -5 - | | | null | 5 | -5 - | | 0 | zero | 5 | -5 - | 1 | 4 | one | 5 | -5 - | 2 | 3 | two | 5 | -5 - | 3 | 2 | three | 5 | -5 - | 4 | 1 | four | 5 | -5 - | 5 | 0 | five | 5 | -5 - | 6 | 6 | six | 5 | -5 - | 7 | 7 | seven | 5 | -5 - | 8 | 8 | eight | 5 | -5 - | 0 | | zero | 5 | -5 - | | | null | 5 | -5 - | | 0 | zero | 5 | -5 - | 1 | 4 | one | 0 | - | 2 | 3 | two | 0 | - | 3 | 2 | three | 0 | - | 4 | 1 | four | 0 | - | 5 | 0 | five | 0 | - | 6 | 6 | six | 0 | - | 7 | 7 | seven | 0 | - | 8 | 8 | eight | 0 | - | 0 | | zero | 0 | - | | | null | 0 | - | | 0 | zero | 0 | - | 1 | 4 | one | | - | 2 | 3 | two | | - | 3 | 2 | three | | - | 4 | 1 | four | | - | 5 | 0 | five | | - | 6 | 6 | six | | - | 7 | 7 | seven | | - | 8 | 8 | eight | | - | 0 | | zero | | - | | | null | | - | | 0 | zero | | - | 1 | 4 | one | | 0 - | 2 | 3 | two | | 0 - | 3 | 2 | three | | 0 - | 4 | 1 | four | | 0 - | 5 | 0 | five | | 0 - | 6 | 6 | six | | 0 - | 7 | 7 | seven | | 0 - | 8 | 8 | eight | | 0 - | 0 | | zero | | 0 - | | | null | | 0 - | | 0 | zero | | 0 + a | b | c | d | e +---+---+-------+---+---- + 1 | 4 | one | 1 | -1 + 2 | 3 | two | 1 | -1 + 3 | 2 | three | 1 | -1 + 4 | 1 | four | 1 | -1 + 5 | 0 | five | 1 | -1 + 6 | 6 | six | 1 | -1 + 7 | 7 | seven | 1 | -1 + 8 | 8 | eight | 1 | -1 + 0 | | zero | 1 | -1 + | | null | 1 | -1 + | 0 | zero | 1 | -1 + 1 | 4 | one | 2 | 2 + 2 | 3 | two | 2 | 2 + 3 | 2 | three | 2 | 2 + 4 | 1 | four | 2 | 2 + 5 | 0 | five | 2 | 2 + 6 | 6 | six | 2 | 2 + 7 | 7 | seven | 2 | 2 + 8 | 8 | eight | 2 | 2 + 0 | | zero | 2 | 2 + | | null | 2 | 2 + | 0 | zero | 2 | 2 + 1 | 4 | one | 3 | -3 + 2 | 3 | two | 3 | -3 + 3 | 2 | three | 3 | -3 + 4 | 1 | four | 3 | -3 + 5 | 0 | five | 3 | -3 + 6 | 6 | six | 3 | -3 + 7 | 7 | seven | 3 | -3 + 8 | 8 | eight | 3 | -3 + 0 | | zero | 3 | -3 + | | null | 3 | -3 + | 0 | zero | 3 | -3 + 1 | 4 | one | 2 | 4 + 2 | 3 | two | 2 | 4 + 3 | 2 | three | 2 | 4 + 4 | 1 | four | 2 | 4 + 5 | 0 | five | 2 | 4 + 6 | 6 | six | 2 | 4 + 7 | 7 | seven | 2 | 4 + 8 | 8 | eight | 2 | 4 + 0 | | zero | 2 | 4 + | | null | 2 | 4 + | 0 | zero | 2 | 4 + 1 | 4 | one | 5 | -5 + 2 | 3 | two | 5 | -5 + 3 | 2 | three | 5 | -5 + 4 | 1 | four | 5 | -5 + 5 | 0 | five | 5 | -5 + 6 | 6 | six | 5 | -5 + 7 | 7 | seven | 5 | -5 + 8 | 8 | eight | 5 | -5 + 0 | | zero | 5 | -5 + | | null | 5 | -5 + | 0 | zero | 5 | -5 + 1 | 4 | one | 5 | -5 + 2 | 3 | two | 5 | -5 + 3 | 2 | three | 5 | -5 + 4 | 1 | four | 5 | -5 + 5 | 0 | five | 5 | -5 + 6 | 6 | six | 5 | -5 + 7 | 7 | seven | 5 | -5 + 8 | 8 | eight | 5 | -5 + 0 | | zero | 5 | -5 + | | null | 5 | -5 + | 0 | zero | 5 | -5 + 1 | 4 | one | 0 | + 2 | 3 | two | 0 | + 3 | 2 | three | 0 | + 4 | 1 | four | 0 | + 5 | 0 | five | 0 | + 6 | 6 | six | 0 | + 7 | 7 | seven | 0 | + 8 | 8 | eight | 0 | + 0 | | zero | 0 | + | | null | 0 | + | 0 | zero | 0 | + 1 | 4 | one | | + 2 | 3 | two | | + 3 | 2 | three | | + 4 | 1 | four | | + 5 | 0 | five | | + 6 | 6 | six | | + 7 | 7 | seven | | + 8 | 8 | eight | | + 0 | | zero | | + | | null | | + | 0 | zero | | + 1 | 4 | one | | 0 + 2 | 3 | two | | 0 + 3 | 2 | three | | 0 + 4 | 1 | four | | 0 + 5 | 0 | five | | 0 + 6 | 6 | six | | 0 + 7 | 7 | seven | | 0 + 8 | 8 | eight | | 0 + 0 | | zero | | 0 + | | null | | 0 + | 0 | zero | | 0 (99 rows) --Testcase 26: -SELECT '' AS "xxx", t1.a, t2.e +SELECT t1.a, t2.e FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e) WHERE t1.a = t2.d; - xxx | a | e ------+---+---- - | 0 | - | 1 | -1 - | 2 | 2 - | 2 | 4 - | 3 | -3 - | 5 | -5 - | 5 | -5 + a | e +---+---- + 0 | + 1 | -1 + 2 | 2 + 2 | 4 + 3 | -3 + 5 | -5 + 5 | -5 (7 rows) -- @@ -317,1335 +317,1335 @@ SELECT '' AS "xxx", t1.a, t2.e -- which degenerate into a standard unqualified inner join. -- --Testcase 27: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL CROSS JOIN J2_TBL; - xxx | i | j | t | i | k ------+---+---+-------+---+---- - | 1 | 4 | one | 1 | -1 - | 2 | 3 | two | 1 | -1 - | 3 | 2 | three | 1 | -1 - | 4 | 1 | four | 1 | -1 - | 5 | 0 | five | 1 | -1 - | 6 | 6 | six | 1 | -1 - | 7 | 7 | seven | 1 | -1 - | 8 | 8 | eight | 1 | -1 - | 0 | | zero | 1 | -1 - | | | null | 1 | -1 - | | 0 | zero | 1 | -1 - | 1 | 4 | one | 2 | 2 - | 2 | 3 | two | 2 | 2 - | 3 | 2 | three | 2 | 2 - | 4 | 1 | four | 2 | 2 - | 5 | 0 | five | 2 | 2 - | 6 | 6 | six | 2 | 2 - | 7 | 7 | seven | 2 | 2 - | 8 | 8 | eight | 2 | 2 - | 0 | | zero | 2 | 2 - | | | null | 2 | 2 - | | 0 | zero | 2 | 2 - | 1 | 4 | one | 3 | -3 - | 2 | 3 | two | 3 | -3 - | 3 | 2 | three | 3 | -3 - | 4 | 1 | four | 3 | -3 - | 5 | 0 | five | 3 | -3 - | 6 | 6 | six | 3 | -3 - | 7 | 7 | seven | 3 | -3 - | 8 | 8 | eight | 3 | -3 - | 0 | | zero | 3 | -3 - | | | null | 3 | -3 - | | 0 | zero | 3 | -3 - | 1 | 4 | one | 2 | 4 - | 2 | 3 | two | 2 | 4 - | 3 | 2 | three | 2 | 4 - | 4 | 1 | four | 2 | 4 - | 5 | 0 | five | 2 | 4 - | 6 | 6 | six | 2 | 4 - | 7 | 7 | seven | 2 | 4 - | 8 | 8 | eight | 2 | 4 - | 0 | | zero | 2 | 4 - | | | null | 2 | 4 - | | 0 | zero | 2 | 4 - | 1 | 4 | one | 5 | -5 - | 2 | 3 | two | 5 | -5 - | 3 | 2 | three | 5 | -5 - | 4 | 1 | four | 5 | -5 - | 5 | 0 | five | 5 | -5 - | 6 | 6 | six | 5 | -5 - | 7 | 7 | seven | 5 | -5 - | 8 | 8 | eight | 5 | -5 - | 0 | | zero | 5 | -5 - | | | null | 5 | -5 - | | 0 | zero | 5 | -5 - | 1 | 4 | one | 5 | -5 - | 2 | 3 | two | 5 | -5 - | 3 | 2 | three | 5 | -5 - | 4 | 1 | four | 5 | -5 - | 5 | 0 | five | 5 | -5 - | 6 | 6 | six | 5 | -5 - | 7 | 7 | seven | 5 | -5 - | 8 | 8 | eight | 5 | -5 - | 0 | | zero | 5 | -5 - | | | null | 5 | -5 - | | 0 | zero | 5 | -5 - | 1 | 4 | one | 0 | - | 2 | 3 | two | 0 | - | 3 | 2 | three | 0 | - | 4 | 1 | four | 0 | - | 5 | 0 | five | 0 | - | 6 | 6 | six | 0 | - | 7 | 7 | seven | 0 | - | 8 | 8 | eight | 0 | - | 0 | | zero | 0 | - | | | null | 0 | - | | 0 | zero | 0 | - | 1 | 4 | one | | - | 2 | 3 | two | | - | 3 | 2 | three | | - | 4 | 1 | four | | - | 5 | 0 | five | | - | 6 | 6 | six | | - | 7 | 7 | seven | | - | 8 | 8 | eight | | - | 0 | | zero | | - | | | null | | - | | 0 | zero | | - | 1 | 4 | one | | 0 - | 2 | 3 | two | | 0 - | 3 | 2 | three | | 0 - | 4 | 1 | four | | 0 - | 5 | 0 | five | | 0 - | 6 | 6 | six | | 0 - | 7 | 7 | seven | | 0 - | 8 | 8 | eight | | 0 - | 0 | | zero | | 0 - | | | null | | 0 - | | 0 | zero | | 0 + i | j | t | i | k +---+---+-------+---+---- + 1 | 4 | one | 1 | -1 + 2 | 3 | two | 1 | -1 + 3 | 2 | three | 1 | -1 + 4 | 1 | four | 1 | -1 + 5 | 0 | five | 1 | -1 + 6 | 6 | six | 1 | -1 + 7 | 7 | seven | 1 | -1 + 8 | 8 | eight | 1 | -1 + 0 | | zero | 1 | -1 + | | null | 1 | -1 + | 0 | zero | 1 | -1 + 1 | 4 | one | 2 | 2 + 2 | 3 | two | 2 | 2 + 3 | 2 | three | 2 | 2 + 4 | 1 | four | 2 | 2 + 5 | 0 | five | 2 | 2 + 6 | 6 | six | 2 | 2 + 7 | 7 | seven | 2 | 2 + 8 | 8 | eight | 2 | 2 + 0 | | zero | 2 | 2 + | | null | 2 | 2 + | 0 | zero | 2 | 2 + 1 | 4 | one | 3 | -3 + 2 | 3 | two | 3 | -3 + 3 | 2 | three | 3 | -3 + 4 | 1 | four | 3 | -3 + 5 | 0 | five | 3 | -3 + 6 | 6 | six | 3 | -3 + 7 | 7 | seven | 3 | -3 + 8 | 8 | eight | 3 | -3 + 0 | | zero | 3 | -3 + | | null | 3 | -3 + | 0 | zero | 3 | -3 + 1 | 4 | one | 2 | 4 + 2 | 3 | two | 2 | 4 + 3 | 2 | three | 2 | 4 + 4 | 1 | four | 2 | 4 + 5 | 0 | five | 2 | 4 + 6 | 6 | six | 2 | 4 + 7 | 7 | seven | 2 | 4 + 8 | 8 | eight | 2 | 4 + 0 | | zero | 2 | 4 + | | null | 2 | 4 + | 0 | zero | 2 | 4 + 1 | 4 | one | 5 | -5 + 2 | 3 | two | 5 | -5 + 3 | 2 | three | 5 | -5 + 4 | 1 | four | 5 | -5 + 5 | 0 | five | 5 | -5 + 6 | 6 | six | 5 | -5 + 7 | 7 | seven | 5 | -5 + 8 | 8 | eight | 5 | -5 + 0 | | zero | 5 | -5 + | | null | 5 | -5 + | 0 | zero | 5 | -5 + 1 | 4 | one | 5 | -5 + 2 | 3 | two | 5 | -5 + 3 | 2 | three | 5 | -5 + 4 | 1 | four | 5 | -5 + 5 | 0 | five | 5 | -5 + 6 | 6 | six | 5 | -5 + 7 | 7 | seven | 5 | -5 + 8 | 8 | eight | 5 | -5 + 0 | | zero | 5 | -5 + | | null | 5 | -5 + | 0 | zero | 5 | -5 + 1 | 4 | one | 0 | + 2 | 3 | two | 0 | + 3 | 2 | three | 0 | + 4 | 1 | four | 0 | + 5 | 0 | five | 0 | + 6 | 6 | six | 0 | + 7 | 7 | seven | 0 | + 8 | 8 | eight | 0 | + 0 | | zero | 0 | + | | null | 0 | + | 0 | zero | 0 | + 1 | 4 | one | | + 2 | 3 | two | | + 3 | 2 | three | | + 4 | 1 | four | | + 5 | 0 | five | | + 6 | 6 | six | | + 7 | 7 | seven | | + 8 | 8 | eight | | + 0 | | zero | | + | | null | | + | 0 | zero | | + 1 | 4 | one | | 0 + 2 | 3 | two | | 0 + 3 | 2 | three | | 0 + 4 | 1 | four | | 0 + 5 | 0 | five | | 0 + 6 | 6 | six | | 0 + 7 | 7 | seven | | 0 + 8 | 8 | eight | | 0 + 0 | | zero | | 0 + | | null | | 0 + | 0 | zero | | 0 (99 rows) -- ambiguous column --Testcase 28: -SELECT '' AS "xxx", i, k, t +SELECT i, k, t FROM J1_TBL CROSS JOIN J2_TBL; ERROR: column reference "i" is ambiguous -LINE 1: SELECT '' AS "xxx", i, k, t - ^ +LINE 1: SELECT i, k, t + ^ -- resolve previous ambiguity by specifying the table name --Testcase 29: -SELECT '' AS "xxx", t1.i, k, t +SELECT t1.i, k, t FROM J1_TBL t1 CROSS JOIN J2_TBL t2; - xxx | i | k | t ------+---+----+------- - | 1 | -1 | one - | 2 | -1 | two - | 3 | -1 | three - | 4 | -1 | four - | 5 | -1 | five - | 6 | -1 | six - | 7 | -1 | seven - | 8 | -1 | eight - | 0 | -1 | zero - | | -1 | null - | | -1 | zero - | 1 | 2 | one - | 2 | 2 | two - | 3 | 2 | three - | 4 | 2 | four - | 5 | 2 | five - | 6 | 2 | six - | 7 | 2 | seven - | 8 | 2 | eight - | 0 | 2 | zero - | | 2 | null - | | 2 | zero - | 1 | -3 | one - | 2 | -3 | two - | 3 | -3 | three - | 4 | -3 | four - | 5 | -3 | five - | 6 | -3 | six - | 7 | -3 | seven - | 8 | -3 | eight - | 0 | -3 | zero - | | -3 | null - | | -3 | zero - | 1 | 4 | one - | 2 | 4 | two - | 3 | 4 | three - | 4 | 4 | four - | 5 | 4 | five - | 6 | 4 | six - | 7 | 4 | seven - | 8 | 4 | eight - | 0 | 4 | zero - | | 4 | null - | | 4 | zero - | 1 | -5 | one - | 2 | -5 | two - | 3 | -5 | three - | 4 | -5 | four - | 5 | -5 | five - | 6 | -5 | six - | 7 | -5 | seven - | 8 | -5 | eight - | 0 | -5 | zero - | | -5 | null - | | -5 | zero - | 1 | -5 | one - | 2 | -5 | two - | 3 | -5 | three - | 4 | -5 | four - | 5 | -5 | five - | 6 | -5 | six - | 7 | -5 | seven - | 8 | -5 | eight - | 0 | -5 | zero - | | -5 | null - | | -5 | zero - | 1 | | one - | 2 | | two - | 3 | | three - | 4 | | four - | 5 | | five - | 6 | | six - | 7 | | seven - | 8 | | eight - | 0 | | zero - | | | null - | | | zero - | 1 | | one - | 2 | | two - | 3 | | three - | 4 | | four - | 5 | | five - | 6 | | six - | 7 | | seven - | 8 | | eight - | 0 | | zero - | | | null - | | | zero - | 1 | 0 | one - | 2 | 0 | two - | 3 | 0 | three - | 4 | 0 | four - | 5 | 0 | five - | 6 | 0 | six - | 7 | 0 | seven - | 8 | 0 | eight - | 0 | 0 | zero - | | 0 | null - | | 0 | zero + i | k | t +---+----+------- + 1 | -1 | one + 2 | -1 | two + 3 | -1 | three + 4 | -1 | four + 5 | -1 | five + 6 | -1 | six + 7 | -1 | seven + 8 | -1 | eight + 0 | -1 | zero + | -1 | null + | -1 | zero + 1 | 2 | one + 2 | 2 | two + 3 | 2 | three + 4 | 2 | four + 5 | 2 | five + 6 | 2 | six + 7 | 2 | seven + 8 | 2 | eight + 0 | 2 | zero + | 2 | null + | 2 | zero + 1 | -3 | one + 2 | -3 | two + 3 | -3 | three + 4 | -3 | four + 5 | -3 | five + 6 | -3 | six + 7 | -3 | seven + 8 | -3 | eight + 0 | -3 | zero + | -3 | null + | -3 | zero + 1 | 4 | one + 2 | 4 | two + 3 | 4 | three + 4 | 4 | four + 5 | 4 | five + 6 | 4 | six + 7 | 4 | seven + 8 | 4 | eight + 0 | 4 | zero + | 4 | null + | 4 | zero + 1 | -5 | one + 2 | -5 | two + 3 | -5 | three + 4 | -5 | four + 5 | -5 | five + 6 | -5 | six + 7 | -5 | seven + 8 | -5 | eight + 0 | -5 | zero + | -5 | null + | -5 | zero + 1 | -5 | one + 2 | -5 | two + 3 | -5 | three + 4 | -5 | four + 5 | -5 | five + 6 | -5 | six + 7 | -5 | seven + 8 | -5 | eight + 0 | -5 | zero + | -5 | null + | -5 | zero + 1 | | one + 2 | | two + 3 | | three + 4 | | four + 5 | | five + 6 | | six + 7 | | seven + 8 | | eight + 0 | | zero + | | null + | | zero + 1 | | one + 2 | | two + 3 | | three + 4 | | four + 5 | | five + 6 | | six + 7 | | seven + 8 | | eight + 0 | | zero + | | null + | | zero + 1 | 0 | one + 2 | 0 | two + 3 | 0 | three + 4 | 0 | four + 5 | 0 | five + 6 | 0 | six + 7 | 0 | seven + 8 | 0 | eight + 0 | 0 | zero + | 0 | null + | 0 | zero (99 rows) --Testcase 30: -SELECT '' AS "xxx", ii, tt, kk +SELECT ii, tt, kk FROM (J1_TBL CROSS JOIN J2_TBL) AS tx (ii, jj, tt, ii2, kk); - xxx | ii | tt | kk ------+----+-------+---- - | 1 | one | -1 - | 2 | two | -1 - | 3 | three | -1 - | 4 | four | -1 - | 5 | five | -1 - | 6 | six | -1 - | 7 | seven | -1 - | 8 | eight | -1 - | 0 | zero | -1 - | | null | -1 - | | zero | -1 - | 1 | one | 2 - | 2 | two | 2 - | 3 | three | 2 - | 4 | four | 2 - | 5 | five | 2 - | 6 | six | 2 - | 7 | seven | 2 - | 8 | eight | 2 - | 0 | zero | 2 - | | null | 2 - | | zero | 2 - | 1 | one | -3 - | 2 | two | -3 - | 3 | three | -3 - | 4 | four | -3 - | 5 | five | -3 - | 6 | six | -3 - | 7 | seven | -3 - | 8 | eight | -3 - | 0 | zero | -3 - | | null | -3 - | | zero | -3 - | 1 | one | 4 - | 2 | two | 4 - | 3 | three | 4 - | 4 | four | 4 - | 5 | five | 4 - | 6 | six | 4 - | 7 | seven | 4 - | 8 | eight | 4 - | 0 | zero | 4 - | | null | 4 - | | zero | 4 - | 1 | one | -5 - | 2 | two | -5 - | 3 | three | -5 - | 4 | four | -5 - | 5 | five | -5 - | 6 | six | -5 - | 7 | seven | -5 - | 8 | eight | -5 - | 0 | zero | -5 - | | null | -5 - | | zero | -5 - | 1 | one | -5 - | 2 | two | -5 - | 3 | three | -5 - | 4 | four | -5 - | 5 | five | -5 - | 6 | six | -5 - | 7 | seven | -5 - | 8 | eight | -5 - | 0 | zero | -5 - | | null | -5 - | | zero | -5 - | 1 | one | - | 2 | two | - | 3 | three | - | 4 | four | - | 5 | five | - | 6 | six | - | 7 | seven | - | 8 | eight | - | 0 | zero | - | | null | - | | zero | - | 1 | one | - | 2 | two | - | 3 | three | - | 4 | four | - | 5 | five | - | 6 | six | - | 7 | seven | - | 8 | eight | - | 0 | zero | - | | null | - | | zero | - | 1 | one | 0 - | 2 | two | 0 - | 3 | three | 0 - | 4 | four | 0 - | 5 | five | 0 - | 6 | six | 0 - | 7 | seven | 0 - | 8 | eight | 0 - | 0 | zero | 0 - | | null | 0 - | | zero | 0 + ii | tt | kk +----+-------+---- + 1 | one | -1 + 2 | two | -1 + 3 | three | -1 + 4 | four | -1 + 5 | five | -1 + 6 | six | -1 + 7 | seven | -1 + 8 | eight | -1 + 0 | zero | -1 + | null | -1 + | zero | -1 + 1 | one | 2 + 2 | two | 2 + 3 | three | 2 + 4 | four | 2 + 5 | five | 2 + 6 | six | 2 + 7 | seven | 2 + 8 | eight | 2 + 0 | zero | 2 + | null | 2 + | zero | 2 + 1 | one | -3 + 2 | two | -3 + 3 | three | -3 + 4 | four | -3 + 5 | five | -3 + 6 | six | -3 + 7 | seven | -3 + 8 | eight | -3 + 0 | zero | -3 + | null | -3 + | zero | -3 + 1 | one | 4 + 2 | two | 4 + 3 | three | 4 + 4 | four | 4 + 5 | five | 4 + 6 | six | 4 + 7 | seven | 4 + 8 | eight | 4 + 0 | zero | 4 + | null | 4 + | zero | 4 + 1 | one | -5 + 2 | two | -5 + 3 | three | -5 + 4 | four | -5 + 5 | five | -5 + 6 | six | -5 + 7 | seven | -5 + 8 | eight | -5 + 0 | zero | -5 + | null | -5 + | zero | -5 + 1 | one | -5 + 2 | two | -5 + 3 | three | -5 + 4 | four | -5 + 5 | five | -5 + 6 | six | -5 + 7 | seven | -5 + 8 | eight | -5 + 0 | zero | -5 + | null | -5 + | zero | -5 + 1 | one | + 2 | two | + 3 | three | + 4 | four | + 5 | five | + 6 | six | + 7 | seven | + 8 | eight | + 0 | zero | + | null | + | zero | + 1 | one | + 2 | two | + 3 | three | + 4 | four | + 5 | five | + 6 | six | + 7 | seven | + 8 | eight | + 0 | zero | + | null | + | zero | + 1 | one | 0 + 2 | two | 0 + 3 | three | 0 + 4 | four | 0 + 5 | five | 0 + 6 | six | 0 + 7 | seven | 0 + 8 | eight | 0 + 0 | zero | 0 + | null | 0 + | zero | 0 (99 rows) --Testcase 31: -SELECT '' AS "xxx", tx.ii, tx.jj, tx.kk +SELECT tx.ii, tx.jj, tx.kk FROM (J1_TBL t1 (a, b, c) CROSS JOIN J2_TBL t2 (d, e)) AS tx (ii, jj, tt, ii2, kk); - xxx | ii | jj | kk ------+----+----+---- - | 1 | 4 | -1 - | 2 | 3 | -1 - | 3 | 2 | -1 - | 4 | 1 | -1 - | 5 | 0 | -1 - | 6 | 6 | -1 - | 7 | 7 | -1 - | 8 | 8 | -1 - | 0 | | -1 - | | | -1 - | | 0 | -1 - | 1 | 4 | 2 - | 2 | 3 | 2 - | 3 | 2 | 2 - | 4 | 1 | 2 - | 5 | 0 | 2 - | 6 | 6 | 2 - | 7 | 7 | 2 - | 8 | 8 | 2 - | 0 | | 2 - | | | 2 - | | 0 | 2 - | 1 | 4 | -3 - | 2 | 3 | -3 - | 3 | 2 | -3 - | 4 | 1 | -3 - | 5 | 0 | -3 - | 6 | 6 | -3 - | 7 | 7 | -3 - | 8 | 8 | -3 - | 0 | | -3 - | | | -3 - | | 0 | -3 - | 1 | 4 | 4 - | 2 | 3 | 4 - | 3 | 2 | 4 - | 4 | 1 | 4 - | 5 | 0 | 4 - | 6 | 6 | 4 - | 7 | 7 | 4 - | 8 | 8 | 4 - | 0 | | 4 - | | | 4 - | | 0 | 4 - | 1 | 4 | -5 - | 2 | 3 | -5 - | 3 | 2 | -5 - | 4 | 1 | -5 - | 5 | 0 | -5 - | 6 | 6 | -5 - | 7 | 7 | -5 - | 8 | 8 | -5 - | 0 | | -5 - | | | -5 - | | 0 | -5 - | 1 | 4 | -5 - | 2 | 3 | -5 - | 3 | 2 | -5 - | 4 | 1 | -5 - | 5 | 0 | -5 - | 6 | 6 | -5 - | 7 | 7 | -5 - | 8 | 8 | -5 - | 0 | | -5 - | | | -5 - | | 0 | -5 - | 1 | 4 | - | 2 | 3 | - | 3 | 2 | - | 4 | 1 | - | 5 | 0 | - | 6 | 6 | - | 7 | 7 | - | 8 | 8 | - | 0 | | - | | | - | | 0 | - | 1 | 4 | - | 2 | 3 | - | 3 | 2 | - | 4 | 1 | - | 5 | 0 | - | 6 | 6 | - | 7 | 7 | - | 8 | 8 | - | 0 | | - | | | - | | 0 | - | 1 | 4 | 0 - | 2 | 3 | 0 - | 3 | 2 | 0 - | 4 | 1 | 0 - | 5 | 0 | 0 - | 6 | 6 | 0 - | 7 | 7 | 0 - | 8 | 8 | 0 - | 0 | | 0 - | | | 0 - | | 0 | 0 + ii | jj | kk +----+----+---- + 1 | 4 | -1 + 2 | 3 | -1 + 3 | 2 | -1 + 4 | 1 | -1 + 5 | 0 | -1 + 6 | 6 | -1 + 7 | 7 | -1 + 8 | 8 | -1 + 0 | | -1 + | | -1 + | 0 | -1 + 1 | 4 | 2 + 2 | 3 | 2 + 3 | 2 | 2 + 4 | 1 | 2 + 5 | 0 | 2 + 6 | 6 | 2 + 7 | 7 | 2 + 8 | 8 | 2 + 0 | | 2 + | | 2 + | 0 | 2 + 1 | 4 | -3 + 2 | 3 | -3 + 3 | 2 | -3 + 4 | 1 | -3 + 5 | 0 | -3 + 6 | 6 | -3 + 7 | 7 | -3 + 8 | 8 | -3 + 0 | | -3 + | | -3 + | 0 | -3 + 1 | 4 | 4 + 2 | 3 | 4 + 3 | 2 | 4 + 4 | 1 | 4 + 5 | 0 | 4 + 6 | 6 | 4 + 7 | 7 | 4 + 8 | 8 | 4 + 0 | | 4 + | | 4 + | 0 | 4 + 1 | 4 | -5 + 2 | 3 | -5 + 3 | 2 | -5 + 4 | 1 | -5 + 5 | 0 | -5 + 6 | 6 | -5 + 7 | 7 | -5 + 8 | 8 | -5 + 0 | | -5 + | | -5 + | 0 | -5 + 1 | 4 | -5 + 2 | 3 | -5 + 3 | 2 | -5 + 4 | 1 | -5 + 5 | 0 | -5 + 6 | 6 | -5 + 7 | 7 | -5 + 8 | 8 | -5 + 0 | | -5 + | | -5 + | 0 | -5 + 1 | 4 | + 2 | 3 | + 3 | 2 | + 4 | 1 | + 5 | 0 | + 6 | 6 | + 7 | 7 | + 8 | 8 | + 0 | | + | | + | 0 | + 1 | 4 | + 2 | 3 | + 3 | 2 | + 4 | 1 | + 5 | 0 | + 6 | 6 | + 7 | 7 | + 8 | 8 | + 0 | | + | | + | 0 | + 1 | 4 | 0 + 2 | 3 | 0 + 3 | 2 | 0 + 4 | 1 | 0 + 5 | 0 | 0 + 6 | 6 | 0 + 7 | 7 | 0 + 8 | 8 | 0 + 0 | | 0 + | | 0 + | 0 | 0 (99 rows) --Testcase 32: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL CROSS JOIN J2_TBL a CROSS JOIN J2_TBL b; - xxx | i | j | t | i | k | i | k ------+---+---+-------+---+----+---+---- - | 1 | 4 | one | 1 | -1 | 1 | -1 - | 1 | 4 | one | 1 | -1 | 2 | 2 - | 1 | 4 | one | 1 | -1 | 3 | -3 - | 1 | 4 | one | 1 | -1 | 2 | 4 - | 1 | 4 | one | 1 | -1 | 5 | -5 - | 1 | 4 | one | 1 | -1 | 5 | -5 - | 1 | 4 | one | 1 | -1 | 0 | - | 1 | 4 | one | 1 | -1 | | - | 1 | 4 | one | 1 | -1 | | 0 - | 2 | 3 | two | 1 | -1 | 1 | -1 - | 2 | 3 | two | 1 | -1 | 2 | 2 - | 2 | 3 | two | 1 | -1 | 3 | -3 - | 2 | 3 | two | 1 | -1 | 2 | 4 - | 2 | 3 | two | 1 | -1 | 5 | -5 - | 2 | 3 | two | 1 | -1 | 5 | -5 - | 2 | 3 | two | 1 | -1 | 0 | - | 2 | 3 | two | 1 | -1 | | - | 2 | 3 | two | 1 | -1 | | 0 - | 3 | 2 | three | 1 | -1 | 1 | -1 - | 3 | 2 | three | 1 | -1 | 2 | 2 - | 3 | 2 | three | 1 | -1 | 3 | -3 - | 3 | 2 | three | 1 | -1 | 2 | 4 - | 3 | 2 | three | 1 | -1 | 5 | -5 - | 3 | 2 | three | 1 | -1 | 5 | -5 - | 3 | 2 | three | 1 | -1 | 0 | - | 3 | 2 | three | 1 | -1 | | - | 3 | 2 | three | 1 | -1 | | 0 - | 4 | 1 | four | 1 | -1 | 1 | -1 - | 4 | 1 | four | 1 | -1 | 2 | 2 - | 4 | 1 | four | 1 | -1 | 3 | -3 - | 4 | 1 | four | 1 | -1 | 2 | 4 - | 4 | 1 | four | 1 | -1 | 5 | -5 - | 4 | 1 | four | 1 | -1 | 5 | -5 - | 4 | 1 | four | 1 | -1 | 0 | - | 4 | 1 | four | 1 | -1 | | - | 4 | 1 | four | 1 | -1 | | 0 - | 5 | 0 | five | 1 | -1 | 1 | -1 - | 5 | 0 | five | 1 | -1 | 2 | 2 - | 5 | 0 | five | 1 | -1 | 3 | -3 - | 5 | 0 | five | 1 | -1 | 2 | 4 - | 5 | 0 | five | 1 | -1 | 5 | -5 - | 5 | 0 | five | 1 | -1 | 5 | -5 - | 5 | 0 | five | 1 | -1 | 0 | - | 5 | 0 | five | 1 | -1 | | - | 5 | 0 | five | 1 | -1 | | 0 - | 6 | 6 | six | 1 | -1 | 1 | -1 - | 6 | 6 | six | 1 | -1 | 2 | 2 - | 6 | 6 | six | 1 | -1 | 3 | -3 - | 6 | 6 | six | 1 | -1 | 2 | 4 - | 6 | 6 | six | 1 | -1 | 5 | -5 - | 6 | 6 | six | 1 | -1 | 5 | -5 - | 6 | 6 | six | 1 | -1 | 0 | - | 6 | 6 | six | 1 | -1 | | - | 6 | 6 | six | 1 | -1 | | 0 - | 7 | 7 | seven | 1 | -1 | 1 | -1 - | 7 | 7 | seven | 1 | -1 | 2 | 2 - | 7 | 7 | seven | 1 | -1 | 3 | -3 - | 7 | 7 | seven | 1 | -1 | 2 | 4 - | 7 | 7 | seven | 1 | -1 | 5 | -5 - | 7 | 7 | seven | 1 | -1 | 5 | -5 - | 7 | 7 | seven | 1 | -1 | 0 | - | 7 | 7 | seven | 1 | -1 | | - | 7 | 7 | seven | 1 | -1 | | 0 - | 8 | 8 | eight | 1 | -1 | 1 | -1 - | 8 | 8 | eight | 1 | -1 | 2 | 2 - | 8 | 8 | eight | 1 | -1 | 3 | -3 - | 8 | 8 | eight | 1 | -1 | 2 | 4 - | 8 | 8 | eight | 1 | -1 | 5 | -5 - | 8 | 8 | eight | 1 | -1 | 5 | -5 - | 8 | 8 | eight | 1 | -1 | 0 | - | 8 | 8 | eight | 1 | -1 | | - | 8 | 8 | eight | 1 | -1 | | 0 - | 0 | | zero | 1 | -1 | 1 | -1 - | 0 | | zero | 1 | -1 | 2 | 2 - | 0 | | zero | 1 | -1 | 3 | -3 - | 0 | | zero | 1 | -1 | 2 | 4 - | 0 | | zero | 1 | -1 | 5 | -5 - | 0 | | zero | 1 | -1 | 5 | -5 - | 0 | | zero | 1 | -1 | 0 | - | 0 | | zero | 1 | -1 | | - | 0 | | zero | 1 | -1 | | 0 - | | | null | 1 | -1 | 1 | -1 - | | | null | 1 | -1 | 2 | 2 - | | | null | 1 | -1 | 3 | -3 - | | | null | 1 | -1 | 2 | 4 - | | | null | 1 | -1 | 5 | -5 - | | | null | 1 | -1 | 5 | -5 - | | | null | 1 | -1 | 0 | - | | | null | 1 | -1 | | - | | | null | 1 | -1 | | 0 - | | 0 | zero | 1 | -1 | 1 | -1 - | | 0 | zero | 1 | -1 | 2 | 2 - | | 0 | zero | 1 | -1 | 3 | -3 - | | 0 | zero | 1 | -1 | 2 | 4 - | | 0 | zero | 1 | -1 | 5 | -5 - | | 0 | zero | 1 | -1 | 5 | -5 - | | 0 | zero | 1 | -1 | 0 | - | | 0 | zero | 1 | -1 | | - | | 0 | zero | 1 | -1 | | 0 - | 1 | 4 | one | 2 | 2 | 1 | -1 - | 1 | 4 | one | 2 | 2 | 2 | 2 - | 1 | 4 | one | 2 | 2 | 3 | -3 - | 1 | 4 | one | 2 | 2 | 2 | 4 - | 1 | 4 | one | 2 | 2 | 5 | -5 - | 1 | 4 | one | 2 | 2 | 5 | -5 - | 1 | 4 | one | 2 | 2 | 0 | - | 1 | 4 | one | 2 | 2 | | - | 1 | 4 | one | 2 | 2 | | 0 - | 2 | 3 | two | 2 | 2 | 1 | -1 - | 2 | 3 | two | 2 | 2 | 2 | 2 - | 2 | 3 | two | 2 | 2 | 3 | -3 - | 2 | 3 | two | 2 | 2 | 2 | 4 - | 2 | 3 | two | 2 | 2 | 5 | -5 - | 2 | 3 | two | 2 | 2 | 5 | -5 - | 2 | 3 | two | 2 | 2 | 0 | - | 2 | 3 | two | 2 | 2 | | - | 2 | 3 | two | 2 | 2 | | 0 - | 3 | 2 | three | 2 | 2 | 1 | -1 - | 3 | 2 | three | 2 | 2 | 2 | 2 - | 3 | 2 | three | 2 | 2 | 3 | -3 - | 3 | 2 | three | 2 | 2 | 2 | 4 - | 3 | 2 | three | 2 | 2 | 5 | -5 - | 3 | 2 | three | 2 | 2 | 5 | -5 - | 3 | 2 | three | 2 | 2 | 0 | - | 3 | 2 | three | 2 | 2 | | - | 3 | 2 | three | 2 | 2 | | 0 - | 4 | 1 | four | 2 | 2 | 1 | -1 - | 4 | 1 | four | 2 | 2 | 2 | 2 - | 4 | 1 | four | 2 | 2 | 3 | -3 - | 4 | 1 | four | 2 | 2 | 2 | 4 - | 4 | 1 | four | 2 | 2 | 5 | -5 - | 4 | 1 | four | 2 | 2 | 5 | -5 - | 4 | 1 | four | 2 | 2 | 0 | - | 4 | 1 | four | 2 | 2 | | - | 4 | 1 | four | 2 | 2 | | 0 - | 5 | 0 | five | 2 | 2 | 1 | -1 - | 5 | 0 | five | 2 | 2 | 2 | 2 - | 5 | 0 | five | 2 | 2 | 3 | -3 - | 5 | 0 | five | 2 | 2 | 2 | 4 - | 5 | 0 | five | 2 | 2 | 5 | -5 - | 5 | 0 | five | 2 | 2 | 5 | -5 - | 5 | 0 | five | 2 | 2 | 0 | - | 5 | 0 | five | 2 | 2 | | - | 5 | 0 | five | 2 | 2 | | 0 - | 6 | 6 | six | 2 | 2 | 1 | -1 - | 6 | 6 | six | 2 | 2 | 2 | 2 - | 6 | 6 | six | 2 | 2 | 3 | -3 - | 6 | 6 | six | 2 | 2 | 2 | 4 - | 6 | 6 | six | 2 | 2 | 5 | -5 - | 6 | 6 | six | 2 | 2 | 5 | -5 - | 6 | 6 | six | 2 | 2 | 0 | - | 6 | 6 | six | 2 | 2 | | - | 6 | 6 | six | 2 | 2 | | 0 - | 7 | 7 | seven | 2 | 2 | 1 | -1 - | 7 | 7 | seven | 2 | 2 | 2 | 2 - | 7 | 7 | seven | 2 | 2 | 3 | -3 - | 7 | 7 | seven | 2 | 2 | 2 | 4 - | 7 | 7 | seven | 2 | 2 | 5 | -5 - | 7 | 7 | seven | 2 | 2 | 5 | -5 - | 7 | 7 | seven | 2 | 2 | 0 | - | 7 | 7 | seven | 2 | 2 | | - | 7 | 7 | seven | 2 | 2 | | 0 - | 8 | 8 | eight | 2 | 2 | 1 | -1 - | 8 | 8 | eight | 2 | 2 | 2 | 2 - | 8 | 8 | eight | 2 | 2 | 3 | -3 - | 8 | 8 | eight | 2 | 2 | 2 | 4 - | 8 | 8 | eight | 2 | 2 | 5 | -5 - | 8 | 8 | eight | 2 | 2 | 5 | -5 - | 8 | 8 | eight | 2 | 2 | 0 | - | 8 | 8 | eight | 2 | 2 | | - | 8 | 8 | eight | 2 | 2 | | 0 - | 0 | | zero | 2 | 2 | 1 | -1 - | 0 | | zero | 2 | 2 | 2 | 2 - | 0 | | zero | 2 | 2 | 3 | -3 - | 0 | | zero | 2 | 2 | 2 | 4 - | 0 | | zero | 2 | 2 | 5 | -5 - | 0 | | zero | 2 | 2 | 5 | -5 - | 0 | | zero | 2 | 2 | 0 | - | 0 | | zero | 2 | 2 | | - | 0 | | zero | 2 | 2 | | 0 - | | | null | 2 | 2 | 1 | -1 - | | | null | 2 | 2 | 2 | 2 - | | | null | 2 | 2 | 3 | -3 - | | | null | 2 | 2 | 2 | 4 - | | | null | 2 | 2 | 5 | -5 - | | | null | 2 | 2 | 5 | -5 - | | | null | 2 | 2 | 0 | - | | | null | 2 | 2 | | - | | | null | 2 | 2 | | 0 - | | 0 | zero | 2 | 2 | 1 | -1 - | | 0 | zero | 2 | 2 | 2 | 2 - | | 0 | zero | 2 | 2 | 3 | -3 - | | 0 | zero | 2 | 2 | 2 | 4 - | | 0 | zero | 2 | 2 | 5 | -5 - | | 0 | zero | 2 | 2 | 5 | -5 - | | 0 | zero | 2 | 2 | 0 | - | | 0 | zero | 2 | 2 | | - | | 0 | zero | 2 | 2 | | 0 - | 1 | 4 | one | 3 | -3 | 1 | -1 - | 1 | 4 | one | 3 | -3 | 2 | 2 - | 1 | 4 | one | 3 | -3 | 3 | -3 - | 1 | 4 | one | 3 | -3 | 2 | 4 - | 1 | 4 | one | 3 | -3 | 5 | -5 - | 1 | 4 | one | 3 | -3 | 5 | -5 - | 1 | 4 | one | 3 | -3 | 0 | - | 1 | 4 | one | 3 | -3 | | - | 1 | 4 | one | 3 | -3 | | 0 - | 2 | 3 | two | 3 | -3 | 1 | -1 - | 2 | 3 | two | 3 | -3 | 2 | 2 - | 2 | 3 | two | 3 | -3 | 3 | -3 - | 2 | 3 | two | 3 | -3 | 2 | 4 - | 2 | 3 | two | 3 | -3 | 5 | -5 - | 2 | 3 | two | 3 | -3 | 5 | -5 - | 2 | 3 | two | 3 | -3 | 0 | - | 2 | 3 | two | 3 | -3 | | - | 2 | 3 | two | 3 | -3 | | 0 - | 3 | 2 | three | 3 | -3 | 1 | -1 - | 3 | 2 | three | 3 | -3 | 2 | 2 - | 3 | 2 | three | 3 | -3 | 3 | -3 - | 3 | 2 | three | 3 | -3 | 2 | 4 - | 3 | 2 | three | 3 | -3 | 5 | -5 - | 3 | 2 | three | 3 | -3 | 5 | -5 - | 3 | 2 | three | 3 | -3 | 0 | - | 3 | 2 | three | 3 | -3 | | - | 3 | 2 | three | 3 | -3 | | 0 - | 4 | 1 | four | 3 | -3 | 1 | -1 - | 4 | 1 | four | 3 | -3 | 2 | 2 - | 4 | 1 | four | 3 | -3 | 3 | -3 - | 4 | 1 | four | 3 | -3 | 2 | 4 - | 4 | 1 | four | 3 | -3 | 5 | -5 - | 4 | 1 | four | 3 | -3 | 5 | -5 - | 4 | 1 | four | 3 | -3 | 0 | - | 4 | 1 | four | 3 | -3 | | - | 4 | 1 | four | 3 | -3 | | 0 - | 5 | 0 | five | 3 | -3 | 1 | -1 - | 5 | 0 | five | 3 | -3 | 2 | 2 - | 5 | 0 | five | 3 | -3 | 3 | -3 - | 5 | 0 | five | 3 | -3 | 2 | 4 - | 5 | 0 | five | 3 | -3 | 5 | -5 - | 5 | 0 | five | 3 | -3 | 5 | -5 - | 5 | 0 | five | 3 | -3 | 0 | - | 5 | 0 | five | 3 | -3 | | - | 5 | 0 | five | 3 | -3 | | 0 - | 6 | 6 | six | 3 | -3 | 1 | -1 - | 6 | 6 | six | 3 | -3 | 2 | 2 - | 6 | 6 | six | 3 | -3 | 3 | -3 - | 6 | 6 | six | 3 | -3 | 2 | 4 - | 6 | 6 | six | 3 | -3 | 5 | -5 - | 6 | 6 | six | 3 | -3 | 5 | -5 - | 6 | 6 | six | 3 | -3 | 0 | - | 6 | 6 | six | 3 | -3 | | - | 6 | 6 | six | 3 | -3 | | 0 - | 7 | 7 | seven | 3 | -3 | 1 | -1 - | 7 | 7 | seven | 3 | -3 | 2 | 2 - | 7 | 7 | seven | 3 | -3 | 3 | -3 - | 7 | 7 | seven | 3 | -3 | 2 | 4 - | 7 | 7 | seven | 3 | -3 | 5 | -5 - | 7 | 7 | seven | 3 | -3 | 5 | -5 - | 7 | 7 | seven | 3 | -3 | 0 | - | 7 | 7 | seven | 3 | -3 | | - | 7 | 7 | seven | 3 | -3 | | 0 - | 8 | 8 | eight | 3 | -3 | 1 | -1 - | 8 | 8 | eight | 3 | -3 | 2 | 2 - | 8 | 8 | eight | 3 | -3 | 3 | -3 - | 8 | 8 | eight | 3 | -3 | 2 | 4 - | 8 | 8 | eight | 3 | -3 | 5 | -5 - | 8 | 8 | eight | 3 | -3 | 5 | -5 - | 8 | 8 | eight | 3 | -3 | 0 | - | 8 | 8 | eight | 3 | -3 | | - | 8 | 8 | eight | 3 | -3 | | 0 - | 0 | | zero | 3 | -3 | 1 | -1 - | 0 | | zero | 3 | -3 | 2 | 2 - | 0 | | zero | 3 | -3 | 3 | -3 - | 0 | | zero | 3 | -3 | 2 | 4 - | 0 | | zero | 3 | -3 | 5 | -5 - | 0 | | zero | 3 | -3 | 5 | -5 - | 0 | | zero | 3 | -3 | 0 | - | 0 | | zero | 3 | -3 | | - | 0 | | zero | 3 | -3 | | 0 - | | | null | 3 | -3 | 1 | -1 - | | | null | 3 | -3 | 2 | 2 - | | | null | 3 | -3 | 3 | -3 - | | | null | 3 | -3 | 2 | 4 - | | | null | 3 | -3 | 5 | -5 - | | | null | 3 | -3 | 5 | -5 - | | | null | 3 | -3 | 0 | - | | | null | 3 | -3 | | - | | | null | 3 | -3 | | 0 - | | 0 | zero | 3 | -3 | 1 | -1 - | | 0 | zero | 3 | -3 | 2 | 2 - | | 0 | zero | 3 | -3 | 3 | -3 - | | 0 | zero | 3 | -3 | 2 | 4 - | | 0 | zero | 3 | -3 | 5 | -5 - | | 0 | zero | 3 | -3 | 5 | -5 - | | 0 | zero | 3 | -3 | 0 | - | | 0 | zero | 3 | -3 | | - | | 0 | zero | 3 | -3 | | 0 - | 1 | 4 | one | 2 | 4 | 1 | -1 - | 1 | 4 | one | 2 | 4 | 2 | 2 - | 1 | 4 | one | 2 | 4 | 3 | -3 - | 1 | 4 | one | 2 | 4 | 2 | 4 - | 1 | 4 | one | 2 | 4 | 5 | -5 - | 1 | 4 | one | 2 | 4 | 5 | -5 - | 1 | 4 | one | 2 | 4 | 0 | - | 1 | 4 | one | 2 | 4 | | - | 1 | 4 | one | 2 | 4 | | 0 - | 2 | 3 | two | 2 | 4 | 1 | -1 - | 2 | 3 | two | 2 | 4 | 2 | 2 - | 2 | 3 | two | 2 | 4 | 3 | -3 - | 2 | 3 | two | 2 | 4 | 2 | 4 - | 2 | 3 | two | 2 | 4 | 5 | -5 - | 2 | 3 | two | 2 | 4 | 5 | -5 - | 2 | 3 | two | 2 | 4 | 0 | - | 2 | 3 | two | 2 | 4 | | - | 2 | 3 | two | 2 | 4 | | 0 - | 3 | 2 | three | 2 | 4 | 1 | -1 - | 3 | 2 | three | 2 | 4 | 2 | 2 - | 3 | 2 | three | 2 | 4 | 3 | -3 - | 3 | 2 | three | 2 | 4 | 2 | 4 - | 3 | 2 | three | 2 | 4 | 5 | -5 - | 3 | 2 | three | 2 | 4 | 5 | -5 - | 3 | 2 | three | 2 | 4 | 0 | - | 3 | 2 | three | 2 | 4 | | - | 3 | 2 | three | 2 | 4 | | 0 - | 4 | 1 | four | 2 | 4 | 1 | -1 - | 4 | 1 | four | 2 | 4 | 2 | 2 - | 4 | 1 | four | 2 | 4 | 3 | -3 - | 4 | 1 | four | 2 | 4 | 2 | 4 - | 4 | 1 | four | 2 | 4 | 5 | -5 - | 4 | 1 | four | 2 | 4 | 5 | -5 - | 4 | 1 | four | 2 | 4 | 0 | - | 4 | 1 | four | 2 | 4 | | - | 4 | 1 | four | 2 | 4 | | 0 - | 5 | 0 | five | 2 | 4 | 1 | -1 - | 5 | 0 | five | 2 | 4 | 2 | 2 - | 5 | 0 | five | 2 | 4 | 3 | -3 - | 5 | 0 | five | 2 | 4 | 2 | 4 - | 5 | 0 | five | 2 | 4 | 5 | -5 - | 5 | 0 | five | 2 | 4 | 5 | -5 - | 5 | 0 | five | 2 | 4 | 0 | - | 5 | 0 | five | 2 | 4 | | - | 5 | 0 | five | 2 | 4 | | 0 - | 6 | 6 | six | 2 | 4 | 1 | -1 - | 6 | 6 | six | 2 | 4 | 2 | 2 - | 6 | 6 | six | 2 | 4 | 3 | -3 - | 6 | 6 | six | 2 | 4 | 2 | 4 - | 6 | 6 | six | 2 | 4 | 5 | -5 - | 6 | 6 | six | 2 | 4 | 5 | -5 - | 6 | 6 | six | 2 | 4 | 0 | - | 6 | 6 | six | 2 | 4 | | - | 6 | 6 | six | 2 | 4 | | 0 - | 7 | 7 | seven | 2 | 4 | 1 | -1 - | 7 | 7 | seven | 2 | 4 | 2 | 2 - | 7 | 7 | seven | 2 | 4 | 3 | -3 - | 7 | 7 | seven | 2 | 4 | 2 | 4 - | 7 | 7 | seven | 2 | 4 | 5 | -5 - | 7 | 7 | seven | 2 | 4 | 5 | -5 - | 7 | 7 | seven | 2 | 4 | 0 | - | 7 | 7 | seven | 2 | 4 | | - | 7 | 7 | seven | 2 | 4 | | 0 - | 8 | 8 | eight | 2 | 4 | 1 | -1 - | 8 | 8 | eight | 2 | 4 | 2 | 2 - | 8 | 8 | eight | 2 | 4 | 3 | -3 - | 8 | 8 | eight | 2 | 4 | 2 | 4 - | 8 | 8 | eight | 2 | 4 | 5 | -5 - | 8 | 8 | eight | 2 | 4 | 5 | -5 - | 8 | 8 | eight | 2 | 4 | 0 | - | 8 | 8 | eight | 2 | 4 | | - | 8 | 8 | eight | 2 | 4 | | 0 - | 0 | | zero | 2 | 4 | 1 | -1 - | 0 | | zero | 2 | 4 | 2 | 2 - | 0 | | zero | 2 | 4 | 3 | -3 - | 0 | | zero | 2 | 4 | 2 | 4 - | 0 | | zero | 2 | 4 | 5 | -5 - | 0 | | zero | 2 | 4 | 5 | -5 - | 0 | | zero | 2 | 4 | 0 | - | 0 | | zero | 2 | 4 | | - | 0 | | zero | 2 | 4 | | 0 - | | | null | 2 | 4 | 1 | -1 - | | | null | 2 | 4 | 2 | 2 - | | | null | 2 | 4 | 3 | -3 - | | | null | 2 | 4 | 2 | 4 - | | | null | 2 | 4 | 5 | -5 - | | | null | 2 | 4 | 5 | -5 - | | | null | 2 | 4 | 0 | - | | | null | 2 | 4 | | - | | | null | 2 | 4 | | 0 - | | 0 | zero | 2 | 4 | 1 | -1 - | | 0 | zero | 2 | 4 | 2 | 2 - | | 0 | zero | 2 | 4 | 3 | -3 - | | 0 | zero | 2 | 4 | 2 | 4 - | | 0 | zero | 2 | 4 | 5 | -5 - | | 0 | zero | 2 | 4 | 5 | -5 - | | 0 | zero | 2 | 4 | 0 | - | | 0 | zero | 2 | 4 | | - | | 0 | zero | 2 | 4 | | 0 - | 1 | 4 | one | 5 | -5 | 1 | -1 - | 1 | 4 | one | 5 | -5 | 2 | 2 - | 1 | 4 | one | 5 | -5 | 3 | -3 - | 1 | 4 | one | 5 | -5 | 2 | 4 - | 1 | 4 | one | 5 | -5 | 5 | -5 - | 1 | 4 | one | 5 | -5 | 5 | -5 - | 1 | 4 | one | 5 | -5 | 0 | - | 1 | 4 | one | 5 | -5 | | - | 1 | 4 | one | 5 | -5 | | 0 - | 2 | 3 | two | 5 | -5 | 1 | -1 - | 2 | 3 | two | 5 | -5 | 2 | 2 - | 2 | 3 | two | 5 | -5 | 3 | -3 - | 2 | 3 | two | 5 | -5 | 2 | 4 - | 2 | 3 | two | 5 | -5 | 5 | -5 - | 2 | 3 | two | 5 | -5 | 5 | -5 - | 2 | 3 | two | 5 | -5 | 0 | - | 2 | 3 | two | 5 | -5 | | - | 2 | 3 | two | 5 | -5 | | 0 - | 3 | 2 | three | 5 | -5 | 1 | -1 - | 3 | 2 | three | 5 | -5 | 2 | 2 - | 3 | 2 | three | 5 | -5 | 3 | -3 - | 3 | 2 | three | 5 | -5 | 2 | 4 - | 3 | 2 | three | 5 | -5 | 5 | -5 - | 3 | 2 | three | 5 | -5 | 5 | -5 - | 3 | 2 | three | 5 | -5 | 0 | - | 3 | 2 | three | 5 | -5 | | - | 3 | 2 | three | 5 | -5 | | 0 - | 4 | 1 | four | 5 | -5 | 1 | -1 - | 4 | 1 | four | 5 | -5 | 2 | 2 - | 4 | 1 | four | 5 | -5 | 3 | -3 - | 4 | 1 | four | 5 | -5 | 2 | 4 - | 4 | 1 | four | 5 | -5 | 5 | -5 - | 4 | 1 | four | 5 | -5 | 5 | -5 - | 4 | 1 | four | 5 | -5 | 0 | - | 4 | 1 | four | 5 | -5 | | - | 4 | 1 | four | 5 | -5 | | 0 - | 5 | 0 | five | 5 | -5 | 1 | -1 - | 5 | 0 | five | 5 | -5 | 2 | 2 - | 5 | 0 | five | 5 | -5 | 3 | -3 - | 5 | 0 | five | 5 | -5 | 2 | 4 - | 5 | 0 | five | 5 | -5 | 5 | -5 - | 5 | 0 | five | 5 | -5 | 5 | -5 - | 5 | 0 | five | 5 | -5 | 0 | - | 5 | 0 | five | 5 | -5 | | - | 5 | 0 | five | 5 | -5 | | 0 - | 6 | 6 | six | 5 | -5 | 1 | -1 - | 6 | 6 | six | 5 | -5 | 2 | 2 - | 6 | 6 | six | 5 | -5 | 3 | -3 - | 6 | 6 | six | 5 | -5 | 2 | 4 - | 6 | 6 | six | 5 | -5 | 5 | -5 - | 6 | 6 | six | 5 | -5 | 5 | -5 - | 6 | 6 | six | 5 | -5 | 0 | - | 6 | 6 | six | 5 | -5 | | - | 6 | 6 | six | 5 | -5 | | 0 - | 7 | 7 | seven | 5 | -5 | 1 | -1 - | 7 | 7 | seven | 5 | -5 | 2 | 2 - | 7 | 7 | seven | 5 | -5 | 3 | -3 - | 7 | 7 | seven | 5 | -5 | 2 | 4 - | 7 | 7 | seven | 5 | -5 | 5 | -5 - | 7 | 7 | seven | 5 | -5 | 5 | -5 - | 7 | 7 | seven | 5 | -5 | 0 | - | 7 | 7 | seven | 5 | -5 | | - | 7 | 7 | seven | 5 | -5 | | 0 - | 8 | 8 | eight | 5 | -5 | 1 | -1 - | 8 | 8 | eight | 5 | -5 | 2 | 2 - | 8 | 8 | eight | 5 | -5 | 3 | -3 - | 8 | 8 | eight | 5 | -5 | 2 | 4 - | 8 | 8 | eight | 5 | -5 | 5 | -5 - | 8 | 8 | eight | 5 | -5 | 5 | -5 - | 8 | 8 | eight | 5 | -5 | 0 | - | 8 | 8 | eight | 5 | -5 | | - | 8 | 8 | eight | 5 | -5 | | 0 - | 0 | | zero | 5 | -5 | 1 | -1 - | 0 | | zero | 5 | -5 | 2 | 2 - | 0 | | zero | 5 | -5 | 3 | -3 - | 0 | | zero | 5 | -5 | 2 | 4 - | 0 | | zero | 5 | -5 | 5 | -5 - | 0 | | zero | 5 | -5 | 5 | -5 - | 0 | | zero | 5 | -5 | 0 | - | 0 | | zero | 5 | -5 | | - | 0 | | zero | 5 | -5 | | 0 - | | | null | 5 | -5 | 1 | -1 - | | | null | 5 | -5 | 2 | 2 - | | | null | 5 | -5 | 3 | -3 - | | | null | 5 | -5 | 2 | 4 - | | | null | 5 | -5 | 5 | -5 - | | | null | 5 | -5 | 5 | -5 - | | | null | 5 | -5 | 0 | - | | | null | 5 | -5 | | - | | | null | 5 | -5 | | 0 - | | 0 | zero | 5 | -5 | 1 | -1 - | | 0 | zero | 5 | -5 | 2 | 2 - | | 0 | zero | 5 | -5 | 3 | -3 - | | 0 | zero | 5 | -5 | 2 | 4 - | | 0 | zero | 5 | -5 | 5 | -5 - | | 0 | zero | 5 | -5 | 5 | -5 - | | 0 | zero | 5 | -5 | 0 | - | | 0 | zero | 5 | -5 | | - | | 0 | zero | 5 | -5 | | 0 - | 1 | 4 | one | 5 | -5 | 1 | -1 - | 1 | 4 | one | 5 | -5 | 2 | 2 - | 1 | 4 | one | 5 | -5 | 3 | -3 - | 1 | 4 | one | 5 | -5 | 2 | 4 - | 1 | 4 | one | 5 | -5 | 5 | -5 - | 1 | 4 | one | 5 | -5 | 5 | -5 - | 1 | 4 | one | 5 | -5 | 0 | - | 1 | 4 | one | 5 | -5 | | - | 1 | 4 | one | 5 | -5 | | 0 - | 2 | 3 | two | 5 | -5 | 1 | -1 - | 2 | 3 | two | 5 | -5 | 2 | 2 - | 2 | 3 | two | 5 | -5 | 3 | -3 - | 2 | 3 | two | 5 | -5 | 2 | 4 - | 2 | 3 | two | 5 | -5 | 5 | -5 - | 2 | 3 | two | 5 | -5 | 5 | -5 - | 2 | 3 | two | 5 | -5 | 0 | - | 2 | 3 | two | 5 | -5 | | - | 2 | 3 | two | 5 | -5 | | 0 - | 3 | 2 | three | 5 | -5 | 1 | -1 - | 3 | 2 | three | 5 | -5 | 2 | 2 - | 3 | 2 | three | 5 | -5 | 3 | -3 - | 3 | 2 | three | 5 | -5 | 2 | 4 - | 3 | 2 | three | 5 | -5 | 5 | -5 - | 3 | 2 | three | 5 | -5 | 5 | -5 - | 3 | 2 | three | 5 | -5 | 0 | - | 3 | 2 | three | 5 | -5 | | - | 3 | 2 | three | 5 | -5 | | 0 - | 4 | 1 | four | 5 | -5 | 1 | -1 - | 4 | 1 | four | 5 | -5 | 2 | 2 - | 4 | 1 | four | 5 | -5 | 3 | -3 - | 4 | 1 | four | 5 | -5 | 2 | 4 - | 4 | 1 | four | 5 | -5 | 5 | -5 - | 4 | 1 | four | 5 | -5 | 5 | -5 - | 4 | 1 | four | 5 | -5 | 0 | - | 4 | 1 | four | 5 | -5 | | - | 4 | 1 | four | 5 | -5 | | 0 - | 5 | 0 | five | 5 | -5 | 1 | -1 - | 5 | 0 | five | 5 | -5 | 2 | 2 - | 5 | 0 | five | 5 | -5 | 3 | -3 - | 5 | 0 | five | 5 | -5 | 2 | 4 - | 5 | 0 | five | 5 | -5 | 5 | -5 - | 5 | 0 | five | 5 | -5 | 5 | -5 - | 5 | 0 | five | 5 | -5 | 0 | - | 5 | 0 | five | 5 | -5 | | - | 5 | 0 | five | 5 | -5 | | 0 - | 6 | 6 | six | 5 | -5 | 1 | -1 - | 6 | 6 | six | 5 | -5 | 2 | 2 - | 6 | 6 | six | 5 | -5 | 3 | -3 - | 6 | 6 | six | 5 | -5 | 2 | 4 - | 6 | 6 | six | 5 | -5 | 5 | -5 - | 6 | 6 | six | 5 | -5 | 5 | -5 - | 6 | 6 | six | 5 | -5 | 0 | - | 6 | 6 | six | 5 | -5 | | - | 6 | 6 | six | 5 | -5 | | 0 - | 7 | 7 | seven | 5 | -5 | 1 | -1 - | 7 | 7 | seven | 5 | -5 | 2 | 2 - | 7 | 7 | seven | 5 | -5 | 3 | -3 - | 7 | 7 | seven | 5 | -5 | 2 | 4 - | 7 | 7 | seven | 5 | -5 | 5 | -5 - | 7 | 7 | seven | 5 | -5 | 5 | -5 - | 7 | 7 | seven | 5 | -5 | 0 | - | 7 | 7 | seven | 5 | -5 | | - | 7 | 7 | seven | 5 | -5 | | 0 - | 8 | 8 | eight | 5 | -5 | 1 | -1 - | 8 | 8 | eight | 5 | -5 | 2 | 2 - | 8 | 8 | eight | 5 | -5 | 3 | -3 - | 8 | 8 | eight | 5 | -5 | 2 | 4 - | 8 | 8 | eight | 5 | -5 | 5 | -5 - | 8 | 8 | eight | 5 | -5 | 5 | -5 - | 8 | 8 | eight | 5 | -5 | 0 | - | 8 | 8 | eight | 5 | -5 | | - | 8 | 8 | eight | 5 | -5 | | 0 - | 0 | | zero | 5 | -5 | 1 | -1 - | 0 | | zero | 5 | -5 | 2 | 2 - | 0 | | zero | 5 | -5 | 3 | -3 - | 0 | | zero | 5 | -5 | 2 | 4 - | 0 | | zero | 5 | -5 | 5 | -5 - | 0 | | zero | 5 | -5 | 5 | -5 - | 0 | | zero | 5 | -5 | 0 | - | 0 | | zero | 5 | -5 | | - | 0 | | zero | 5 | -5 | | 0 - | | | null | 5 | -5 | 1 | -1 - | | | null | 5 | -5 | 2 | 2 - | | | null | 5 | -5 | 3 | -3 - | | | null | 5 | -5 | 2 | 4 - | | | null | 5 | -5 | 5 | -5 - | | | null | 5 | -5 | 5 | -5 - | | | null | 5 | -5 | 0 | - | | | null | 5 | -5 | | - | | | null | 5 | -5 | | 0 - | | 0 | zero | 5 | -5 | 1 | -1 - | | 0 | zero | 5 | -5 | 2 | 2 - | | 0 | zero | 5 | -5 | 3 | -3 - | | 0 | zero | 5 | -5 | 2 | 4 - | | 0 | zero | 5 | -5 | 5 | -5 - | | 0 | zero | 5 | -5 | 5 | -5 - | | 0 | zero | 5 | -5 | 0 | - | | 0 | zero | 5 | -5 | | - | | 0 | zero | 5 | -5 | | 0 - | 1 | 4 | one | 0 | | 1 | -1 - | 1 | 4 | one | 0 | | 2 | 2 - | 1 | 4 | one | 0 | | 3 | -3 - | 1 | 4 | one | 0 | | 2 | 4 - | 1 | 4 | one | 0 | | 5 | -5 - | 1 | 4 | one | 0 | | 5 | -5 - | 1 | 4 | one | 0 | | 0 | - | 1 | 4 | one | 0 | | | - | 1 | 4 | one | 0 | | | 0 - | 2 | 3 | two | 0 | | 1 | -1 - | 2 | 3 | two | 0 | | 2 | 2 - | 2 | 3 | two | 0 | | 3 | -3 - | 2 | 3 | two | 0 | | 2 | 4 - | 2 | 3 | two | 0 | | 5 | -5 - | 2 | 3 | two | 0 | | 5 | -5 - | 2 | 3 | two | 0 | | 0 | - | 2 | 3 | two | 0 | | | - | 2 | 3 | two | 0 | | | 0 - | 3 | 2 | three | 0 | | 1 | -1 - | 3 | 2 | three | 0 | | 2 | 2 - | 3 | 2 | three | 0 | | 3 | -3 - | 3 | 2 | three | 0 | | 2 | 4 - | 3 | 2 | three | 0 | | 5 | -5 - | 3 | 2 | three | 0 | | 5 | -5 - | 3 | 2 | three | 0 | | 0 | - | 3 | 2 | three | 0 | | | - | 3 | 2 | three | 0 | | | 0 - | 4 | 1 | four | 0 | | 1 | -1 - | 4 | 1 | four | 0 | | 2 | 2 - | 4 | 1 | four | 0 | | 3 | -3 - | 4 | 1 | four | 0 | | 2 | 4 - | 4 | 1 | four | 0 | | 5 | -5 - | 4 | 1 | four | 0 | | 5 | -5 - | 4 | 1 | four | 0 | | 0 | - | 4 | 1 | four | 0 | | | - | 4 | 1 | four | 0 | | | 0 - | 5 | 0 | five | 0 | | 1 | -1 - | 5 | 0 | five | 0 | | 2 | 2 - | 5 | 0 | five | 0 | | 3 | -3 - | 5 | 0 | five | 0 | | 2 | 4 - | 5 | 0 | five | 0 | | 5 | -5 - | 5 | 0 | five | 0 | | 5 | -5 - | 5 | 0 | five | 0 | | 0 | - | 5 | 0 | five | 0 | | | - | 5 | 0 | five | 0 | | | 0 - | 6 | 6 | six | 0 | | 1 | -1 - | 6 | 6 | six | 0 | | 2 | 2 - | 6 | 6 | six | 0 | | 3 | -3 - | 6 | 6 | six | 0 | | 2 | 4 - | 6 | 6 | six | 0 | | 5 | -5 - | 6 | 6 | six | 0 | | 5 | -5 - | 6 | 6 | six | 0 | | 0 | - | 6 | 6 | six | 0 | | | - | 6 | 6 | six | 0 | | | 0 - | 7 | 7 | seven | 0 | | 1 | -1 - | 7 | 7 | seven | 0 | | 2 | 2 - | 7 | 7 | seven | 0 | | 3 | -3 - | 7 | 7 | seven | 0 | | 2 | 4 - | 7 | 7 | seven | 0 | | 5 | -5 - | 7 | 7 | seven | 0 | | 5 | -5 - | 7 | 7 | seven | 0 | | 0 | - | 7 | 7 | seven | 0 | | | - | 7 | 7 | seven | 0 | | | 0 - | 8 | 8 | eight | 0 | | 1 | -1 - | 8 | 8 | eight | 0 | | 2 | 2 - | 8 | 8 | eight | 0 | | 3 | -3 - | 8 | 8 | eight | 0 | | 2 | 4 - | 8 | 8 | eight | 0 | | 5 | -5 - | 8 | 8 | eight | 0 | | 5 | -5 - | 8 | 8 | eight | 0 | | 0 | - | 8 | 8 | eight | 0 | | | - | 8 | 8 | eight | 0 | | | 0 - | 0 | | zero | 0 | | 1 | -1 - | 0 | | zero | 0 | | 2 | 2 - | 0 | | zero | 0 | | 3 | -3 - | 0 | | zero | 0 | | 2 | 4 - | 0 | | zero | 0 | | 5 | -5 - | 0 | | zero | 0 | | 5 | -5 - | 0 | | zero | 0 | | 0 | - | 0 | | zero | 0 | | | - | 0 | | zero | 0 | | | 0 - | | | null | 0 | | 1 | -1 - | | | null | 0 | | 2 | 2 - | | | null | 0 | | 3 | -3 - | | | null | 0 | | 2 | 4 - | | | null | 0 | | 5 | -5 - | | | null | 0 | | 5 | -5 - | | | null | 0 | | 0 | - | | | null | 0 | | | - | | | null | 0 | | | 0 - | | 0 | zero | 0 | | 1 | -1 - | | 0 | zero | 0 | | 2 | 2 - | | 0 | zero | 0 | | 3 | -3 - | | 0 | zero | 0 | | 2 | 4 - | | 0 | zero | 0 | | 5 | -5 - | | 0 | zero | 0 | | 5 | -5 - | | 0 | zero | 0 | | 0 | - | | 0 | zero | 0 | | | - | | 0 | zero | 0 | | | 0 - | 1 | 4 | one | | | 1 | -1 - | 1 | 4 | one | | | 2 | 2 - | 1 | 4 | one | | | 3 | -3 - | 1 | 4 | one | | | 2 | 4 - | 1 | 4 | one | | | 5 | -5 - | 1 | 4 | one | | | 5 | -5 - | 1 | 4 | one | | | 0 | - | 1 | 4 | one | | | | - | 1 | 4 | one | | | | 0 - | 2 | 3 | two | | | 1 | -1 - | 2 | 3 | two | | | 2 | 2 - | 2 | 3 | two | | | 3 | -3 - | 2 | 3 | two | | | 2 | 4 - | 2 | 3 | two | | | 5 | -5 - | 2 | 3 | two | | | 5 | -5 - | 2 | 3 | two | | | 0 | - | 2 | 3 | two | | | | - | 2 | 3 | two | | | | 0 - | 3 | 2 | three | | | 1 | -1 - | 3 | 2 | three | | | 2 | 2 - | 3 | 2 | three | | | 3 | -3 - | 3 | 2 | three | | | 2 | 4 - | 3 | 2 | three | | | 5 | -5 - | 3 | 2 | three | | | 5 | -5 - | 3 | 2 | three | | | 0 | - | 3 | 2 | three | | | | - | 3 | 2 | three | | | | 0 - | 4 | 1 | four | | | 1 | -1 - | 4 | 1 | four | | | 2 | 2 - | 4 | 1 | four | | | 3 | -3 - | 4 | 1 | four | | | 2 | 4 - | 4 | 1 | four | | | 5 | -5 - | 4 | 1 | four | | | 5 | -5 - | 4 | 1 | four | | | 0 | - | 4 | 1 | four | | | | - | 4 | 1 | four | | | | 0 - | 5 | 0 | five | | | 1 | -1 - | 5 | 0 | five | | | 2 | 2 - | 5 | 0 | five | | | 3 | -3 - | 5 | 0 | five | | | 2 | 4 - | 5 | 0 | five | | | 5 | -5 - | 5 | 0 | five | | | 5 | -5 - | 5 | 0 | five | | | 0 | - | 5 | 0 | five | | | | - | 5 | 0 | five | | | | 0 - | 6 | 6 | six | | | 1 | -1 - | 6 | 6 | six | | | 2 | 2 - | 6 | 6 | six | | | 3 | -3 - | 6 | 6 | six | | | 2 | 4 - | 6 | 6 | six | | | 5 | -5 - | 6 | 6 | six | | | 5 | -5 - | 6 | 6 | six | | | 0 | - | 6 | 6 | six | | | | - | 6 | 6 | six | | | | 0 - | 7 | 7 | seven | | | 1 | -1 - | 7 | 7 | seven | | | 2 | 2 - | 7 | 7 | seven | | | 3 | -3 - | 7 | 7 | seven | | | 2 | 4 - | 7 | 7 | seven | | | 5 | -5 - | 7 | 7 | seven | | | 5 | -5 - | 7 | 7 | seven | | | 0 | - | 7 | 7 | seven | | | | - | 7 | 7 | seven | | | | 0 - | 8 | 8 | eight | | | 1 | -1 - | 8 | 8 | eight | | | 2 | 2 - | 8 | 8 | eight | | | 3 | -3 - | 8 | 8 | eight | | | 2 | 4 - | 8 | 8 | eight | | | 5 | -5 - | 8 | 8 | eight | | | 5 | -5 - | 8 | 8 | eight | | | 0 | - | 8 | 8 | eight | | | | - | 8 | 8 | eight | | | | 0 - | 0 | | zero | | | 1 | -1 - | 0 | | zero | | | 2 | 2 - | 0 | | zero | | | 3 | -3 - | 0 | | zero | | | 2 | 4 - | 0 | | zero | | | 5 | -5 - | 0 | | zero | | | 5 | -5 - | 0 | | zero | | | 0 | - | 0 | | zero | | | | - | 0 | | zero | | | | 0 - | | | null | | | 1 | -1 - | | | null | | | 2 | 2 - | | | null | | | 3 | -3 - | | | null | | | 2 | 4 - | | | null | | | 5 | -5 - | | | null | | | 5 | -5 - | | | null | | | 0 | - | | | null | | | | - | | | null | | | | 0 - | | 0 | zero | | | 1 | -1 - | | 0 | zero | | | 2 | 2 - | | 0 | zero | | | 3 | -3 - | | 0 | zero | | | 2 | 4 - | | 0 | zero | | | 5 | -5 - | | 0 | zero | | | 5 | -5 - | | 0 | zero | | | 0 | - | | 0 | zero | | | | - | | 0 | zero | | | | 0 - | 1 | 4 | one | | 0 | 1 | -1 - | 1 | 4 | one | | 0 | 2 | 2 - | 1 | 4 | one | | 0 | 3 | -3 - | 1 | 4 | one | | 0 | 2 | 4 - | 1 | 4 | one | | 0 | 5 | -5 - | 1 | 4 | one | | 0 | 5 | -5 - | 1 | 4 | one | | 0 | 0 | - | 1 | 4 | one | | 0 | | - | 1 | 4 | one | | 0 | | 0 - | 2 | 3 | two | | 0 | 1 | -1 - | 2 | 3 | two | | 0 | 2 | 2 - | 2 | 3 | two | | 0 | 3 | -3 - | 2 | 3 | two | | 0 | 2 | 4 - | 2 | 3 | two | | 0 | 5 | -5 - | 2 | 3 | two | | 0 | 5 | -5 - | 2 | 3 | two | | 0 | 0 | - | 2 | 3 | two | | 0 | | - | 2 | 3 | two | | 0 | | 0 - | 3 | 2 | three | | 0 | 1 | -1 - | 3 | 2 | three | | 0 | 2 | 2 - | 3 | 2 | three | | 0 | 3 | -3 - | 3 | 2 | three | | 0 | 2 | 4 - | 3 | 2 | three | | 0 | 5 | -5 - | 3 | 2 | three | | 0 | 5 | -5 - | 3 | 2 | three | | 0 | 0 | - | 3 | 2 | three | | 0 | | - | 3 | 2 | three | | 0 | | 0 - | 4 | 1 | four | | 0 | 1 | -1 - | 4 | 1 | four | | 0 | 2 | 2 - | 4 | 1 | four | | 0 | 3 | -3 - | 4 | 1 | four | | 0 | 2 | 4 - | 4 | 1 | four | | 0 | 5 | -5 - | 4 | 1 | four | | 0 | 5 | -5 - | 4 | 1 | four | | 0 | 0 | - | 4 | 1 | four | | 0 | | - | 4 | 1 | four | | 0 | | 0 - | 5 | 0 | five | | 0 | 1 | -1 - | 5 | 0 | five | | 0 | 2 | 2 - | 5 | 0 | five | | 0 | 3 | -3 - | 5 | 0 | five | | 0 | 2 | 4 - | 5 | 0 | five | | 0 | 5 | -5 - | 5 | 0 | five | | 0 | 5 | -5 - | 5 | 0 | five | | 0 | 0 | - | 5 | 0 | five | | 0 | | - | 5 | 0 | five | | 0 | | 0 - | 6 | 6 | six | | 0 | 1 | -1 - | 6 | 6 | six | | 0 | 2 | 2 - | 6 | 6 | six | | 0 | 3 | -3 - | 6 | 6 | six | | 0 | 2 | 4 - | 6 | 6 | six | | 0 | 5 | -5 - | 6 | 6 | six | | 0 | 5 | -5 - | 6 | 6 | six | | 0 | 0 | - | 6 | 6 | six | | 0 | | - | 6 | 6 | six | | 0 | | 0 - | 7 | 7 | seven | | 0 | 1 | -1 - | 7 | 7 | seven | | 0 | 2 | 2 - | 7 | 7 | seven | | 0 | 3 | -3 - | 7 | 7 | seven | | 0 | 2 | 4 - | 7 | 7 | seven | | 0 | 5 | -5 - | 7 | 7 | seven | | 0 | 5 | -5 - | 7 | 7 | seven | | 0 | 0 | - | 7 | 7 | seven | | 0 | | - | 7 | 7 | seven | | 0 | | 0 - | 8 | 8 | eight | | 0 | 1 | -1 - | 8 | 8 | eight | | 0 | 2 | 2 - | 8 | 8 | eight | | 0 | 3 | -3 - | 8 | 8 | eight | | 0 | 2 | 4 - | 8 | 8 | eight | | 0 | 5 | -5 - | 8 | 8 | eight | | 0 | 5 | -5 - | 8 | 8 | eight | | 0 | 0 | - | 8 | 8 | eight | | 0 | | - | 8 | 8 | eight | | 0 | | 0 - | 0 | | zero | | 0 | 1 | -1 - | 0 | | zero | | 0 | 2 | 2 - | 0 | | zero | | 0 | 3 | -3 - | 0 | | zero | | 0 | 2 | 4 - | 0 | | zero | | 0 | 5 | -5 - | 0 | | zero | | 0 | 5 | -5 - | 0 | | zero | | 0 | 0 | - | 0 | | zero | | 0 | | - | 0 | | zero | | 0 | | 0 - | | | null | | 0 | 1 | -1 - | | | null | | 0 | 2 | 2 - | | | null | | 0 | 3 | -3 - | | | null | | 0 | 2 | 4 - | | | null | | 0 | 5 | -5 - | | | null | | 0 | 5 | -5 - | | | null | | 0 | 0 | - | | | null | | 0 | | - | | | null | | 0 | | 0 - | | 0 | zero | | 0 | 1 | -1 - | | 0 | zero | | 0 | 2 | 2 - | | 0 | zero | | 0 | 3 | -3 - | | 0 | zero | | 0 | 2 | 4 - | | 0 | zero | | 0 | 5 | -5 - | | 0 | zero | | 0 | 5 | -5 - | | 0 | zero | | 0 | 0 | - | | 0 | zero | | 0 | | - | | 0 | zero | | 0 | | 0 + i | j | t | i | k | i | k +---+---+-------+---+----+---+---- + 1 | 4 | one | 1 | -1 | 1 | -1 + 1 | 4 | one | 1 | -1 | 2 | 2 + 1 | 4 | one | 1 | -1 | 3 | -3 + 1 | 4 | one | 1 | -1 | 2 | 4 + 1 | 4 | one | 1 | -1 | 5 | -5 + 1 | 4 | one | 1 | -1 | 5 | -5 + 1 | 4 | one | 1 | -1 | 0 | + 1 | 4 | one | 1 | -1 | | + 1 | 4 | one | 1 | -1 | | 0 + 2 | 3 | two | 1 | -1 | 1 | -1 + 2 | 3 | two | 1 | -1 | 2 | 2 + 2 | 3 | two | 1 | -1 | 3 | -3 + 2 | 3 | two | 1 | -1 | 2 | 4 + 2 | 3 | two | 1 | -1 | 5 | -5 + 2 | 3 | two | 1 | -1 | 5 | -5 + 2 | 3 | two | 1 | -1 | 0 | + 2 | 3 | two | 1 | -1 | | + 2 | 3 | two | 1 | -1 | | 0 + 3 | 2 | three | 1 | -1 | 1 | -1 + 3 | 2 | three | 1 | -1 | 2 | 2 + 3 | 2 | three | 1 | -1 | 3 | -3 + 3 | 2 | three | 1 | -1 | 2 | 4 + 3 | 2 | three | 1 | -1 | 5 | -5 + 3 | 2 | three | 1 | -1 | 5 | -5 + 3 | 2 | three | 1 | -1 | 0 | + 3 | 2 | three | 1 | -1 | | + 3 | 2 | three | 1 | -1 | | 0 + 4 | 1 | four | 1 | -1 | 1 | -1 + 4 | 1 | four | 1 | -1 | 2 | 2 + 4 | 1 | four | 1 | -1 | 3 | -3 + 4 | 1 | four | 1 | -1 | 2 | 4 + 4 | 1 | four | 1 | -1 | 5 | -5 + 4 | 1 | four | 1 | -1 | 5 | -5 + 4 | 1 | four | 1 | -1 | 0 | + 4 | 1 | four | 1 | -1 | | + 4 | 1 | four | 1 | -1 | | 0 + 5 | 0 | five | 1 | -1 | 1 | -1 + 5 | 0 | five | 1 | -1 | 2 | 2 + 5 | 0 | five | 1 | -1 | 3 | -3 + 5 | 0 | five | 1 | -1 | 2 | 4 + 5 | 0 | five | 1 | -1 | 5 | -5 + 5 | 0 | five | 1 | -1 | 5 | -5 + 5 | 0 | five | 1 | -1 | 0 | + 5 | 0 | five | 1 | -1 | | + 5 | 0 | five | 1 | -1 | | 0 + 6 | 6 | six | 1 | -1 | 1 | -1 + 6 | 6 | six | 1 | -1 | 2 | 2 + 6 | 6 | six | 1 | -1 | 3 | -3 + 6 | 6 | six | 1 | -1 | 2 | 4 + 6 | 6 | six | 1 | -1 | 5 | -5 + 6 | 6 | six | 1 | -1 | 5 | -5 + 6 | 6 | six | 1 | -1 | 0 | + 6 | 6 | six | 1 | -1 | | + 6 | 6 | six | 1 | -1 | | 0 + 7 | 7 | seven | 1 | -1 | 1 | -1 + 7 | 7 | seven | 1 | -1 | 2 | 2 + 7 | 7 | seven | 1 | -1 | 3 | -3 + 7 | 7 | seven | 1 | -1 | 2 | 4 + 7 | 7 | seven | 1 | -1 | 5 | -5 + 7 | 7 | seven | 1 | -1 | 5 | -5 + 7 | 7 | seven | 1 | -1 | 0 | + 7 | 7 | seven | 1 | -1 | | + 7 | 7 | seven | 1 | -1 | | 0 + 8 | 8 | eight | 1 | -1 | 1 | -1 + 8 | 8 | eight | 1 | -1 | 2 | 2 + 8 | 8 | eight | 1 | -1 | 3 | -3 + 8 | 8 | eight | 1 | -1 | 2 | 4 + 8 | 8 | eight | 1 | -1 | 5 | -5 + 8 | 8 | eight | 1 | -1 | 5 | -5 + 8 | 8 | eight | 1 | -1 | 0 | + 8 | 8 | eight | 1 | -1 | | + 8 | 8 | eight | 1 | -1 | | 0 + 0 | | zero | 1 | -1 | 1 | -1 + 0 | | zero | 1 | -1 | 2 | 2 + 0 | | zero | 1 | -1 | 3 | -3 + 0 | | zero | 1 | -1 | 2 | 4 + 0 | | zero | 1 | -1 | 5 | -5 + 0 | | zero | 1 | -1 | 5 | -5 + 0 | | zero | 1 | -1 | 0 | + 0 | | zero | 1 | -1 | | + 0 | | zero | 1 | -1 | | 0 + | | null | 1 | -1 | 1 | -1 + | | null | 1 | -1 | 2 | 2 + | | null | 1 | -1 | 3 | -3 + | | null | 1 | -1 | 2 | 4 + | | null | 1 | -1 | 5 | -5 + | | null | 1 | -1 | 5 | -5 + | | null | 1 | -1 | 0 | + | | null | 1 | -1 | | + | | null | 1 | -1 | | 0 + | 0 | zero | 1 | -1 | 1 | -1 + | 0 | zero | 1 | -1 | 2 | 2 + | 0 | zero | 1 | -1 | 3 | -3 + | 0 | zero | 1 | -1 | 2 | 4 + | 0 | zero | 1 | -1 | 5 | -5 + | 0 | zero | 1 | -1 | 5 | -5 + | 0 | zero | 1 | -1 | 0 | + | 0 | zero | 1 | -1 | | + | 0 | zero | 1 | -1 | | 0 + 1 | 4 | one | 2 | 2 | 1 | -1 + 1 | 4 | one | 2 | 2 | 2 | 2 + 1 | 4 | one | 2 | 2 | 3 | -3 + 1 | 4 | one | 2 | 2 | 2 | 4 + 1 | 4 | one | 2 | 2 | 5 | -5 + 1 | 4 | one | 2 | 2 | 5 | -5 + 1 | 4 | one | 2 | 2 | 0 | + 1 | 4 | one | 2 | 2 | | + 1 | 4 | one | 2 | 2 | | 0 + 2 | 3 | two | 2 | 2 | 1 | -1 + 2 | 3 | two | 2 | 2 | 2 | 2 + 2 | 3 | two | 2 | 2 | 3 | -3 + 2 | 3 | two | 2 | 2 | 2 | 4 + 2 | 3 | two | 2 | 2 | 5 | -5 + 2 | 3 | two | 2 | 2 | 5 | -5 + 2 | 3 | two | 2 | 2 | 0 | + 2 | 3 | two | 2 | 2 | | + 2 | 3 | two | 2 | 2 | | 0 + 3 | 2 | three | 2 | 2 | 1 | -1 + 3 | 2 | three | 2 | 2 | 2 | 2 + 3 | 2 | three | 2 | 2 | 3 | -3 + 3 | 2 | three | 2 | 2 | 2 | 4 + 3 | 2 | three | 2 | 2 | 5 | -5 + 3 | 2 | three | 2 | 2 | 5 | -5 + 3 | 2 | three | 2 | 2 | 0 | + 3 | 2 | three | 2 | 2 | | + 3 | 2 | three | 2 | 2 | | 0 + 4 | 1 | four | 2 | 2 | 1 | -1 + 4 | 1 | four | 2 | 2 | 2 | 2 + 4 | 1 | four | 2 | 2 | 3 | -3 + 4 | 1 | four | 2 | 2 | 2 | 4 + 4 | 1 | four | 2 | 2 | 5 | -5 + 4 | 1 | four | 2 | 2 | 5 | -5 + 4 | 1 | four | 2 | 2 | 0 | + 4 | 1 | four | 2 | 2 | | + 4 | 1 | four | 2 | 2 | | 0 + 5 | 0 | five | 2 | 2 | 1 | -1 + 5 | 0 | five | 2 | 2 | 2 | 2 + 5 | 0 | five | 2 | 2 | 3 | -3 + 5 | 0 | five | 2 | 2 | 2 | 4 + 5 | 0 | five | 2 | 2 | 5 | -5 + 5 | 0 | five | 2 | 2 | 5 | -5 + 5 | 0 | five | 2 | 2 | 0 | + 5 | 0 | five | 2 | 2 | | + 5 | 0 | five | 2 | 2 | | 0 + 6 | 6 | six | 2 | 2 | 1 | -1 + 6 | 6 | six | 2 | 2 | 2 | 2 + 6 | 6 | six | 2 | 2 | 3 | -3 + 6 | 6 | six | 2 | 2 | 2 | 4 + 6 | 6 | six | 2 | 2 | 5 | -5 + 6 | 6 | six | 2 | 2 | 5 | -5 + 6 | 6 | six | 2 | 2 | 0 | + 6 | 6 | six | 2 | 2 | | + 6 | 6 | six | 2 | 2 | | 0 + 7 | 7 | seven | 2 | 2 | 1 | -1 + 7 | 7 | seven | 2 | 2 | 2 | 2 + 7 | 7 | seven | 2 | 2 | 3 | -3 + 7 | 7 | seven | 2 | 2 | 2 | 4 + 7 | 7 | seven | 2 | 2 | 5 | -5 + 7 | 7 | seven | 2 | 2 | 5 | -5 + 7 | 7 | seven | 2 | 2 | 0 | + 7 | 7 | seven | 2 | 2 | | + 7 | 7 | seven | 2 | 2 | | 0 + 8 | 8 | eight | 2 | 2 | 1 | -1 + 8 | 8 | eight | 2 | 2 | 2 | 2 + 8 | 8 | eight | 2 | 2 | 3 | -3 + 8 | 8 | eight | 2 | 2 | 2 | 4 + 8 | 8 | eight | 2 | 2 | 5 | -5 + 8 | 8 | eight | 2 | 2 | 5 | -5 + 8 | 8 | eight | 2 | 2 | 0 | + 8 | 8 | eight | 2 | 2 | | + 8 | 8 | eight | 2 | 2 | | 0 + 0 | | zero | 2 | 2 | 1 | -1 + 0 | | zero | 2 | 2 | 2 | 2 + 0 | | zero | 2 | 2 | 3 | -3 + 0 | | zero | 2 | 2 | 2 | 4 + 0 | | zero | 2 | 2 | 5 | -5 + 0 | | zero | 2 | 2 | 5 | -5 + 0 | | zero | 2 | 2 | 0 | + 0 | | zero | 2 | 2 | | + 0 | | zero | 2 | 2 | | 0 + | | null | 2 | 2 | 1 | -1 + | | null | 2 | 2 | 2 | 2 + | | null | 2 | 2 | 3 | -3 + | | null | 2 | 2 | 2 | 4 + | | null | 2 | 2 | 5 | -5 + | | null | 2 | 2 | 5 | -5 + | | null | 2 | 2 | 0 | + | | null | 2 | 2 | | + | | null | 2 | 2 | | 0 + | 0 | zero | 2 | 2 | 1 | -1 + | 0 | zero | 2 | 2 | 2 | 2 + | 0 | zero | 2 | 2 | 3 | -3 + | 0 | zero | 2 | 2 | 2 | 4 + | 0 | zero | 2 | 2 | 5 | -5 + | 0 | zero | 2 | 2 | 5 | -5 + | 0 | zero | 2 | 2 | 0 | + | 0 | zero | 2 | 2 | | + | 0 | zero | 2 | 2 | | 0 + 1 | 4 | one | 3 | -3 | 1 | -1 + 1 | 4 | one | 3 | -3 | 2 | 2 + 1 | 4 | one | 3 | -3 | 3 | -3 + 1 | 4 | one | 3 | -3 | 2 | 4 + 1 | 4 | one | 3 | -3 | 5 | -5 + 1 | 4 | one | 3 | -3 | 5 | -5 + 1 | 4 | one | 3 | -3 | 0 | + 1 | 4 | one | 3 | -3 | | + 1 | 4 | one | 3 | -3 | | 0 + 2 | 3 | two | 3 | -3 | 1 | -1 + 2 | 3 | two | 3 | -3 | 2 | 2 + 2 | 3 | two | 3 | -3 | 3 | -3 + 2 | 3 | two | 3 | -3 | 2 | 4 + 2 | 3 | two | 3 | -3 | 5 | -5 + 2 | 3 | two | 3 | -3 | 5 | -5 + 2 | 3 | two | 3 | -3 | 0 | + 2 | 3 | two | 3 | -3 | | + 2 | 3 | two | 3 | -3 | | 0 + 3 | 2 | three | 3 | -3 | 1 | -1 + 3 | 2 | three | 3 | -3 | 2 | 2 + 3 | 2 | three | 3 | -3 | 3 | -3 + 3 | 2 | three | 3 | -3 | 2 | 4 + 3 | 2 | three | 3 | -3 | 5 | -5 + 3 | 2 | three | 3 | -3 | 5 | -5 + 3 | 2 | three | 3 | -3 | 0 | + 3 | 2 | three | 3 | -3 | | + 3 | 2 | three | 3 | -3 | | 0 + 4 | 1 | four | 3 | -3 | 1 | -1 + 4 | 1 | four | 3 | -3 | 2 | 2 + 4 | 1 | four | 3 | -3 | 3 | -3 + 4 | 1 | four | 3 | -3 | 2 | 4 + 4 | 1 | four | 3 | -3 | 5 | -5 + 4 | 1 | four | 3 | -3 | 5 | -5 + 4 | 1 | four | 3 | -3 | 0 | + 4 | 1 | four | 3 | -3 | | + 4 | 1 | four | 3 | -3 | | 0 + 5 | 0 | five | 3 | -3 | 1 | -1 + 5 | 0 | five | 3 | -3 | 2 | 2 + 5 | 0 | five | 3 | -3 | 3 | -3 + 5 | 0 | five | 3 | -3 | 2 | 4 + 5 | 0 | five | 3 | -3 | 5 | -5 + 5 | 0 | five | 3 | -3 | 5 | -5 + 5 | 0 | five | 3 | -3 | 0 | + 5 | 0 | five | 3 | -3 | | + 5 | 0 | five | 3 | -3 | | 0 + 6 | 6 | six | 3 | -3 | 1 | -1 + 6 | 6 | six | 3 | -3 | 2 | 2 + 6 | 6 | six | 3 | -3 | 3 | -3 + 6 | 6 | six | 3 | -3 | 2 | 4 + 6 | 6 | six | 3 | -3 | 5 | -5 + 6 | 6 | six | 3 | -3 | 5 | -5 + 6 | 6 | six | 3 | -3 | 0 | + 6 | 6 | six | 3 | -3 | | + 6 | 6 | six | 3 | -3 | | 0 + 7 | 7 | seven | 3 | -3 | 1 | -1 + 7 | 7 | seven | 3 | -3 | 2 | 2 + 7 | 7 | seven | 3 | -3 | 3 | -3 + 7 | 7 | seven | 3 | -3 | 2 | 4 + 7 | 7 | seven | 3 | -3 | 5 | -5 + 7 | 7 | seven | 3 | -3 | 5 | -5 + 7 | 7 | seven | 3 | -3 | 0 | + 7 | 7 | seven | 3 | -3 | | + 7 | 7 | seven | 3 | -3 | | 0 + 8 | 8 | eight | 3 | -3 | 1 | -1 + 8 | 8 | eight | 3 | -3 | 2 | 2 + 8 | 8 | eight | 3 | -3 | 3 | -3 + 8 | 8 | eight | 3 | -3 | 2 | 4 + 8 | 8 | eight | 3 | -3 | 5 | -5 + 8 | 8 | eight | 3 | -3 | 5 | -5 + 8 | 8 | eight | 3 | -3 | 0 | + 8 | 8 | eight | 3 | -3 | | + 8 | 8 | eight | 3 | -3 | | 0 + 0 | | zero | 3 | -3 | 1 | -1 + 0 | | zero | 3 | -3 | 2 | 2 + 0 | | zero | 3 | -3 | 3 | -3 + 0 | | zero | 3 | -3 | 2 | 4 + 0 | | zero | 3 | -3 | 5 | -5 + 0 | | zero | 3 | -3 | 5 | -5 + 0 | | zero | 3 | -3 | 0 | + 0 | | zero | 3 | -3 | | + 0 | | zero | 3 | -3 | | 0 + | | null | 3 | -3 | 1 | -1 + | | null | 3 | -3 | 2 | 2 + | | null | 3 | -3 | 3 | -3 + | | null | 3 | -3 | 2 | 4 + | | null | 3 | -3 | 5 | -5 + | | null | 3 | -3 | 5 | -5 + | | null | 3 | -3 | 0 | + | | null | 3 | -3 | | + | | null | 3 | -3 | | 0 + | 0 | zero | 3 | -3 | 1 | -1 + | 0 | zero | 3 | -3 | 2 | 2 + | 0 | zero | 3 | -3 | 3 | -3 + | 0 | zero | 3 | -3 | 2 | 4 + | 0 | zero | 3 | -3 | 5 | -5 + | 0 | zero | 3 | -3 | 5 | -5 + | 0 | zero | 3 | -3 | 0 | + | 0 | zero | 3 | -3 | | + | 0 | zero | 3 | -3 | | 0 + 1 | 4 | one | 2 | 4 | 1 | -1 + 1 | 4 | one | 2 | 4 | 2 | 2 + 1 | 4 | one | 2 | 4 | 3 | -3 + 1 | 4 | one | 2 | 4 | 2 | 4 + 1 | 4 | one | 2 | 4 | 5 | -5 + 1 | 4 | one | 2 | 4 | 5 | -5 + 1 | 4 | one | 2 | 4 | 0 | + 1 | 4 | one | 2 | 4 | | + 1 | 4 | one | 2 | 4 | | 0 + 2 | 3 | two | 2 | 4 | 1 | -1 + 2 | 3 | two | 2 | 4 | 2 | 2 + 2 | 3 | two | 2 | 4 | 3 | -3 + 2 | 3 | two | 2 | 4 | 2 | 4 + 2 | 3 | two | 2 | 4 | 5 | -5 + 2 | 3 | two | 2 | 4 | 5 | -5 + 2 | 3 | two | 2 | 4 | 0 | + 2 | 3 | two | 2 | 4 | | + 2 | 3 | two | 2 | 4 | | 0 + 3 | 2 | three | 2 | 4 | 1 | -1 + 3 | 2 | three | 2 | 4 | 2 | 2 + 3 | 2 | three | 2 | 4 | 3 | -3 + 3 | 2 | three | 2 | 4 | 2 | 4 + 3 | 2 | three | 2 | 4 | 5 | -5 + 3 | 2 | three | 2 | 4 | 5 | -5 + 3 | 2 | three | 2 | 4 | 0 | + 3 | 2 | three | 2 | 4 | | + 3 | 2 | three | 2 | 4 | | 0 + 4 | 1 | four | 2 | 4 | 1 | -1 + 4 | 1 | four | 2 | 4 | 2 | 2 + 4 | 1 | four | 2 | 4 | 3 | -3 + 4 | 1 | four | 2 | 4 | 2 | 4 + 4 | 1 | four | 2 | 4 | 5 | -5 + 4 | 1 | four | 2 | 4 | 5 | -5 + 4 | 1 | four | 2 | 4 | 0 | + 4 | 1 | four | 2 | 4 | | + 4 | 1 | four | 2 | 4 | | 0 + 5 | 0 | five | 2 | 4 | 1 | -1 + 5 | 0 | five | 2 | 4 | 2 | 2 + 5 | 0 | five | 2 | 4 | 3 | -3 + 5 | 0 | five | 2 | 4 | 2 | 4 + 5 | 0 | five | 2 | 4 | 5 | -5 + 5 | 0 | five | 2 | 4 | 5 | -5 + 5 | 0 | five | 2 | 4 | 0 | + 5 | 0 | five | 2 | 4 | | + 5 | 0 | five | 2 | 4 | | 0 + 6 | 6 | six | 2 | 4 | 1 | -1 + 6 | 6 | six | 2 | 4 | 2 | 2 + 6 | 6 | six | 2 | 4 | 3 | -3 + 6 | 6 | six | 2 | 4 | 2 | 4 + 6 | 6 | six | 2 | 4 | 5 | -5 + 6 | 6 | six | 2 | 4 | 5 | -5 + 6 | 6 | six | 2 | 4 | 0 | + 6 | 6 | six | 2 | 4 | | + 6 | 6 | six | 2 | 4 | | 0 + 7 | 7 | seven | 2 | 4 | 1 | -1 + 7 | 7 | seven | 2 | 4 | 2 | 2 + 7 | 7 | seven | 2 | 4 | 3 | -3 + 7 | 7 | seven | 2 | 4 | 2 | 4 + 7 | 7 | seven | 2 | 4 | 5 | -5 + 7 | 7 | seven | 2 | 4 | 5 | -5 + 7 | 7 | seven | 2 | 4 | 0 | + 7 | 7 | seven | 2 | 4 | | + 7 | 7 | seven | 2 | 4 | | 0 + 8 | 8 | eight | 2 | 4 | 1 | -1 + 8 | 8 | eight | 2 | 4 | 2 | 2 + 8 | 8 | eight | 2 | 4 | 3 | -3 + 8 | 8 | eight | 2 | 4 | 2 | 4 + 8 | 8 | eight | 2 | 4 | 5 | -5 + 8 | 8 | eight | 2 | 4 | 5 | -5 + 8 | 8 | eight | 2 | 4 | 0 | + 8 | 8 | eight | 2 | 4 | | + 8 | 8 | eight | 2 | 4 | | 0 + 0 | | zero | 2 | 4 | 1 | -1 + 0 | | zero | 2 | 4 | 2 | 2 + 0 | | zero | 2 | 4 | 3 | -3 + 0 | | zero | 2 | 4 | 2 | 4 + 0 | | zero | 2 | 4 | 5 | -5 + 0 | | zero | 2 | 4 | 5 | -5 + 0 | | zero | 2 | 4 | 0 | + 0 | | zero | 2 | 4 | | + 0 | | zero | 2 | 4 | | 0 + | | null | 2 | 4 | 1 | -1 + | | null | 2 | 4 | 2 | 2 + | | null | 2 | 4 | 3 | -3 + | | null | 2 | 4 | 2 | 4 + | | null | 2 | 4 | 5 | -5 + | | null | 2 | 4 | 5 | -5 + | | null | 2 | 4 | 0 | + | | null | 2 | 4 | | + | | null | 2 | 4 | | 0 + | 0 | zero | 2 | 4 | 1 | -1 + | 0 | zero | 2 | 4 | 2 | 2 + | 0 | zero | 2 | 4 | 3 | -3 + | 0 | zero | 2 | 4 | 2 | 4 + | 0 | zero | 2 | 4 | 5 | -5 + | 0 | zero | 2 | 4 | 5 | -5 + | 0 | zero | 2 | 4 | 0 | + | 0 | zero | 2 | 4 | | + | 0 | zero | 2 | 4 | | 0 + 1 | 4 | one | 5 | -5 | 1 | -1 + 1 | 4 | one | 5 | -5 | 2 | 2 + 1 | 4 | one | 5 | -5 | 3 | -3 + 1 | 4 | one | 5 | -5 | 2 | 4 + 1 | 4 | one | 5 | -5 | 5 | -5 + 1 | 4 | one | 5 | -5 | 5 | -5 + 1 | 4 | one | 5 | -5 | 0 | + 1 | 4 | one | 5 | -5 | | + 1 | 4 | one | 5 | -5 | | 0 + 2 | 3 | two | 5 | -5 | 1 | -1 + 2 | 3 | two | 5 | -5 | 2 | 2 + 2 | 3 | two | 5 | -5 | 3 | -3 + 2 | 3 | two | 5 | -5 | 2 | 4 + 2 | 3 | two | 5 | -5 | 5 | -5 + 2 | 3 | two | 5 | -5 | 5 | -5 + 2 | 3 | two | 5 | -5 | 0 | + 2 | 3 | two | 5 | -5 | | + 2 | 3 | two | 5 | -5 | | 0 + 3 | 2 | three | 5 | -5 | 1 | -1 + 3 | 2 | three | 5 | -5 | 2 | 2 + 3 | 2 | three | 5 | -5 | 3 | -3 + 3 | 2 | three | 5 | -5 | 2 | 4 + 3 | 2 | three | 5 | -5 | 5 | -5 + 3 | 2 | three | 5 | -5 | 5 | -5 + 3 | 2 | three | 5 | -5 | 0 | + 3 | 2 | three | 5 | -5 | | + 3 | 2 | three | 5 | -5 | | 0 + 4 | 1 | four | 5 | -5 | 1 | -1 + 4 | 1 | four | 5 | -5 | 2 | 2 + 4 | 1 | four | 5 | -5 | 3 | -3 + 4 | 1 | four | 5 | -5 | 2 | 4 + 4 | 1 | four | 5 | -5 | 5 | -5 + 4 | 1 | four | 5 | -5 | 5 | -5 + 4 | 1 | four | 5 | -5 | 0 | + 4 | 1 | four | 5 | -5 | | + 4 | 1 | four | 5 | -5 | | 0 + 5 | 0 | five | 5 | -5 | 1 | -1 + 5 | 0 | five | 5 | -5 | 2 | 2 + 5 | 0 | five | 5 | -5 | 3 | -3 + 5 | 0 | five | 5 | -5 | 2 | 4 + 5 | 0 | five | 5 | -5 | 5 | -5 + 5 | 0 | five | 5 | -5 | 5 | -5 + 5 | 0 | five | 5 | -5 | 0 | + 5 | 0 | five | 5 | -5 | | + 5 | 0 | five | 5 | -5 | | 0 + 6 | 6 | six | 5 | -5 | 1 | -1 + 6 | 6 | six | 5 | -5 | 2 | 2 + 6 | 6 | six | 5 | -5 | 3 | -3 + 6 | 6 | six | 5 | -5 | 2 | 4 + 6 | 6 | six | 5 | -5 | 5 | -5 + 6 | 6 | six | 5 | -5 | 5 | -5 + 6 | 6 | six | 5 | -5 | 0 | + 6 | 6 | six | 5 | -5 | | + 6 | 6 | six | 5 | -5 | | 0 + 7 | 7 | seven | 5 | -5 | 1 | -1 + 7 | 7 | seven | 5 | -5 | 2 | 2 + 7 | 7 | seven | 5 | -5 | 3 | -3 + 7 | 7 | seven | 5 | -5 | 2 | 4 + 7 | 7 | seven | 5 | -5 | 5 | -5 + 7 | 7 | seven | 5 | -5 | 5 | -5 + 7 | 7 | seven | 5 | -5 | 0 | + 7 | 7 | seven | 5 | -5 | | + 7 | 7 | seven | 5 | -5 | | 0 + 8 | 8 | eight | 5 | -5 | 1 | -1 + 8 | 8 | eight | 5 | -5 | 2 | 2 + 8 | 8 | eight | 5 | -5 | 3 | -3 + 8 | 8 | eight | 5 | -5 | 2 | 4 + 8 | 8 | eight | 5 | -5 | 5 | -5 + 8 | 8 | eight | 5 | -5 | 5 | -5 + 8 | 8 | eight | 5 | -5 | 0 | + 8 | 8 | eight | 5 | -5 | | + 8 | 8 | eight | 5 | -5 | | 0 + 0 | | zero | 5 | -5 | 1 | -1 + 0 | | zero | 5 | -5 | 2 | 2 + 0 | | zero | 5 | -5 | 3 | -3 + 0 | | zero | 5 | -5 | 2 | 4 + 0 | | zero | 5 | -5 | 5 | -5 + 0 | | zero | 5 | -5 | 5 | -5 + 0 | | zero | 5 | -5 | 0 | + 0 | | zero | 5 | -5 | | + 0 | | zero | 5 | -5 | | 0 + | | null | 5 | -5 | 1 | -1 + | | null | 5 | -5 | 2 | 2 + | | null | 5 | -5 | 3 | -3 + | | null | 5 | -5 | 2 | 4 + | | null | 5 | -5 | 5 | -5 + | | null | 5 | -5 | 5 | -5 + | | null | 5 | -5 | 0 | + | | null | 5 | -5 | | + | | null | 5 | -5 | | 0 + | 0 | zero | 5 | -5 | 1 | -1 + | 0 | zero | 5 | -5 | 2 | 2 + | 0 | zero | 5 | -5 | 3 | -3 + | 0 | zero | 5 | -5 | 2 | 4 + | 0 | zero | 5 | -5 | 5 | -5 + | 0 | zero | 5 | -5 | 5 | -5 + | 0 | zero | 5 | -5 | 0 | + | 0 | zero | 5 | -5 | | + | 0 | zero | 5 | -5 | | 0 + 1 | 4 | one | 5 | -5 | 1 | -1 + 1 | 4 | one | 5 | -5 | 2 | 2 + 1 | 4 | one | 5 | -5 | 3 | -3 + 1 | 4 | one | 5 | -5 | 2 | 4 + 1 | 4 | one | 5 | -5 | 5 | -5 + 1 | 4 | one | 5 | -5 | 5 | -5 + 1 | 4 | one | 5 | -5 | 0 | + 1 | 4 | one | 5 | -5 | | + 1 | 4 | one | 5 | -5 | | 0 + 2 | 3 | two | 5 | -5 | 1 | -1 + 2 | 3 | two | 5 | -5 | 2 | 2 + 2 | 3 | two | 5 | -5 | 3 | -3 + 2 | 3 | two | 5 | -5 | 2 | 4 + 2 | 3 | two | 5 | -5 | 5 | -5 + 2 | 3 | two | 5 | -5 | 5 | -5 + 2 | 3 | two | 5 | -5 | 0 | + 2 | 3 | two | 5 | -5 | | + 2 | 3 | two | 5 | -5 | | 0 + 3 | 2 | three | 5 | -5 | 1 | -1 + 3 | 2 | three | 5 | -5 | 2 | 2 + 3 | 2 | three | 5 | -5 | 3 | -3 + 3 | 2 | three | 5 | -5 | 2 | 4 + 3 | 2 | three | 5 | -5 | 5 | -5 + 3 | 2 | three | 5 | -5 | 5 | -5 + 3 | 2 | three | 5 | -5 | 0 | + 3 | 2 | three | 5 | -5 | | + 3 | 2 | three | 5 | -5 | | 0 + 4 | 1 | four | 5 | -5 | 1 | -1 + 4 | 1 | four | 5 | -5 | 2 | 2 + 4 | 1 | four | 5 | -5 | 3 | -3 + 4 | 1 | four | 5 | -5 | 2 | 4 + 4 | 1 | four | 5 | -5 | 5 | -5 + 4 | 1 | four | 5 | -5 | 5 | -5 + 4 | 1 | four | 5 | -5 | 0 | + 4 | 1 | four | 5 | -5 | | + 4 | 1 | four | 5 | -5 | | 0 + 5 | 0 | five | 5 | -5 | 1 | -1 + 5 | 0 | five | 5 | -5 | 2 | 2 + 5 | 0 | five | 5 | -5 | 3 | -3 + 5 | 0 | five | 5 | -5 | 2 | 4 + 5 | 0 | five | 5 | -5 | 5 | -5 + 5 | 0 | five | 5 | -5 | 5 | -5 + 5 | 0 | five | 5 | -5 | 0 | + 5 | 0 | five | 5 | -5 | | + 5 | 0 | five | 5 | -5 | | 0 + 6 | 6 | six | 5 | -5 | 1 | -1 + 6 | 6 | six | 5 | -5 | 2 | 2 + 6 | 6 | six | 5 | -5 | 3 | -3 + 6 | 6 | six | 5 | -5 | 2 | 4 + 6 | 6 | six | 5 | -5 | 5 | -5 + 6 | 6 | six | 5 | -5 | 5 | -5 + 6 | 6 | six | 5 | -5 | 0 | + 6 | 6 | six | 5 | -5 | | + 6 | 6 | six | 5 | -5 | | 0 + 7 | 7 | seven | 5 | -5 | 1 | -1 + 7 | 7 | seven | 5 | -5 | 2 | 2 + 7 | 7 | seven | 5 | -5 | 3 | -3 + 7 | 7 | seven | 5 | -5 | 2 | 4 + 7 | 7 | seven | 5 | -5 | 5 | -5 + 7 | 7 | seven | 5 | -5 | 5 | -5 + 7 | 7 | seven | 5 | -5 | 0 | + 7 | 7 | seven | 5 | -5 | | + 7 | 7 | seven | 5 | -5 | | 0 + 8 | 8 | eight | 5 | -5 | 1 | -1 + 8 | 8 | eight | 5 | -5 | 2 | 2 + 8 | 8 | eight | 5 | -5 | 3 | -3 + 8 | 8 | eight | 5 | -5 | 2 | 4 + 8 | 8 | eight | 5 | -5 | 5 | -5 + 8 | 8 | eight | 5 | -5 | 5 | -5 + 8 | 8 | eight | 5 | -5 | 0 | + 8 | 8 | eight | 5 | -5 | | + 8 | 8 | eight | 5 | -5 | | 0 + 0 | | zero | 5 | -5 | 1 | -1 + 0 | | zero | 5 | -5 | 2 | 2 + 0 | | zero | 5 | -5 | 3 | -3 + 0 | | zero | 5 | -5 | 2 | 4 + 0 | | zero | 5 | -5 | 5 | -5 + 0 | | zero | 5 | -5 | 5 | -5 + 0 | | zero | 5 | -5 | 0 | + 0 | | zero | 5 | -5 | | + 0 | | zero | 5 | -5 | | 0 + | | null | 5 | -5 | 1 | -1 + | | null | 5 | -5 | 2 | 2 + | | null | 5 | -5 | 3 | -3 + | | null | 5 | -5 | 2 | 4 + | | null | 5 | -5 | 5 | -5 + | | null | 5 | -5 | 5 | -5 + | | null | 5 | -5 | 0 | + | | null | 5 | -5 | | + | | null | 5 | -5 | | 0 + | 0 | zero | 5 | -5 | 1 | -1 + | 0 | zero | 5 | -5 | 2 | 2 + | 0 | zero | 5 | -5 | 3 | -3 + | 0 | zero | 5 | -5 | 2 | 4 + | 0 | zero | 5 | -5 | 5 | -5 + | 0 | zero | 5 | -5 | 5 | -5 + | 0 | zero | 5 | -5 | 0 | + | 0 | zero | 5 | -5 | | + | 0 | zero | 5 | -5 | | 0 + 1 | 4 | one | 0 | | 1 | -1 + 1 | 4 | one | 0 | | 2 | 2 + 1 | 4 | one | 0 | | 3 | -3 + 1 | 4 | one | 0 | | 2 | 4 + 1 | 4 | one | 0 | | 5 | -5 + 1 | 4 | one | 0 | | 5 | -5 + 1 | 4 | one | 0 | | 0 | + 1 | 4 | one | 0 | | | + 1 | 4 | one | 0 | | | 0 + 2 | 3 | two | 0 | | 1 | -1 + 2 | 3 | two | 0 | | 2 | 2 + 2 | 3 | two | 0 | | 3 | -3 + 2 | 3 | two | 0 | | 2 | 4 + 2 | 3 | two | 0 | | 5 | -5 + 2 | 3 | two | 0 | | 5 | -5 + 2 | 3 | two | 0 | | 0 | + 2 | 3 | two | 0 | | | + 2 | 3 | two | 0 | | | 0 + 3 | 2 | three | 0 | | 1 | -1 + 3 | 2 | three | 0 | | 2 | 2 + 3 | 2 | three | 0 | | 3 | -3 + 3 | 2 | three | 0 | | 2 | 4 + 3 | 2 | three | 0 | | 5 | -5 + 3 | 2 | three | 0 | | 5 | -5 + 3 | 2 | three | 0 | | 0 | + 3 | 2 | three | 0 | | | + 3 | 2 | three | 0 | | | 0 + 4 | 1 | four | 0 | | 1 | -1 + 4 | 1 | four | 0 | | 2 | 2 + 4 | 1 | four | 0 | | 3 | -3 + 4 | 1 | four | 0 | | 2 | 4 + 4 | 1 | four | 0 | | 5 | -5 + 4 | 1 | four | 0 | | 5 | -5 + 4 | 1 | four | 0 | | 0 | + 4 | 1 | four | 0 | | | + 4 | 1 | four | 0 | | | 0 + 5 | 0 | five | 0 | | 1 | -1 + 5 | 0 | five | 0 | | 2 | 2 + 5 | 0 | five | 0 | | 3 | -3 + 5 | 0 | five | 0 | | 2 | 4 + 5 | 0 | five | 0 | | 5 | -5 + 5 | 0 | five | 0 | | 5 | -5 + 5 | 0 | five | 0 | | 0 | + 5 | 0 | five | 0 | | | + 5 | 0 | five | 0 | | | 0 + 6 | 6 | six | 0 | | 1 | -1 + 6 | 6 | six | 0 | | 2 | 2 + 6 | 6 | six | 0 | | 3 | -3 + 6 | 6 | six | 0 | | 2 | 4 + 6 | 6 | six | 0 | | 5 | -5 + 6 | 6 | six | 0 | | 5 | -5 + 6 | 6 | six | 0 | | 0 | + 6 | 6 | six | 0 | | | + 6 | 6 | six | 0 | | | 0 + 7 | 7 | seven | 0 | | 1 | -1 + 7 | 7 | seven | 0 | | 2 | 2 + 7 | 7 | seven | 0 | | 3 | -3 + 7 | 7 | seven | 0 | | 2 | 4 + 7 | 7 | seven | 0 | | 5 | -5 + 7 | 7 | seven | 0 | | 5 | -5 + 7 | 7 | seven | 0 | | 0 | + 7 | 7 | seven | 0 | | | + 7 | 7 | seven | 0 | | | 0 + 8 | 8 | eight | 0 | | 1 | -1 + 8 | 8 | eight | 0 | | 2 | 2 + 8 | 8 | eight | 0 | | 3 | -3 + 8 | 8 | eight | 0 | | 2 | 4 + 8 | 8 | eight | 0 | | 5 | -5 + 8 | 8 | eight | 0 | | 5 | -5 + 8 | 8 | eight | 0 | | 0 | + 8 | 8 | eight | 0 | | | + 8 | 8 | eight | 0 | | | 0 + 0 | | zero | 0 | | 1 | -1 + 0 | | zero | 0 | | 2 | 2 + 0 | | zero | 0 | | 3 | -3 + 0 | | zero | 0 | | 2 | 4 + 0 | | zero | 0 | | 5 | -5 + 0 | | zero | 0 | | 5 | -5 + 0 | | zero | 0 | | 0 | + 0 | | zero | 0 | | | + 0 | | zero | 0 | | | 0 + | | null | 0 | | 1 | -1 + | | null | 0 | | 2 | 2 + | | null | 0 | | 3 | -3 + | | null | 0 | | 2 | 4 + | | null | 0 | | 5 | -5 + | | null | 0 | | 5 | -5 + | | null | 0 | | 0 | + | | null | 0 | | | + | | null | 0 | | | 0 + | 0 | zero | 0 | | 1 | -1 + | 0 | zero | 0 | | 2 | 2 + | 0 | zero | 0 | | 3 | -3 + | 0 | zero | 0 | | 2 | 4 + | 0 | zero | 0 | | 5 | -5 + | 0 | zero | 0 | | 5 | -5 + | 0 | zero | 0 | | 0 | + | 0 | zero | 0 | | | + | 0 | zero | 0 | | | 0 + 1 | 4 | one | | | 1 | -1 + 1 | 4 | one | | | 2 | 2 + 1 | 4 | one | | | 3 | -3 + 1 | 4 | one | | | 2 | 4 + 1 | 4 | one | | | 5 | -5 + 1 | 4 | one | | | 5 | -5 + 1 | 4 | one | | | 0 | + 1 | 4 | one | | | | + 1 | 4 | one | | | | 0 + 2 | 3 | two | | | 1 | -1 + 2 | 3 | two | | | 2 | 2 + 2 | 3 | two | | | 3 | -3 + 2 | 3 | two | | | 2 | 4 + 2 | 3 | two | | | 5 | -5 + 2 | 3 | two | | | 5 | -5 + 2 | 3 | two | | | 0 | + 2 | 3 | two | | | | + 2 | 3 | two | | | | 0 + 3 | 2 | three | | | 1 | -1 + 3 | 2 | three | | | 2 | 2 + 3 | 2 | three | | | 3 | -3 + 3 | 2 | three | | | 2 | 4 + 3 | 2 | three | | | 5 | -5 + 3 | 2 | three | | | 5 | -5 + 3 | 2 | three | | | 0 | + 3 | 2 | three | | | | + 3 | 2 | three | | | | 0 + 4 | 1 | four | | | 1 | -1 + 4 | 1 | four | | | 2 | 2 + 4 | 1 | four | | | 3 | -3 + 4 | 1 | four | | | 2 | 4 + 4 | 1 | four | | | 5 | -5 + 4 | 1 | four | | | 5 | -5 + 4 | 1 | four | | | 0 | + 4 | 1 | four | | | | + 4 | 1 | four | | | | 0 + 5 | 0 | five | | | 1 | -1 + 5 | 0 | five | | | 2 | 2 + 5 | 0 | five | | | 3 | -3 + 5 | 0 | five | | | 2 | 4 + 5 | 0 | five | | | 5 | -5 + 5 | 0 | five | | | 5 | -5 + 5 | 0 | five | | | 0 | + 5 | 0 | five | | | | + 5 | 0 | five | | | | 0 + 6 | 6 | six | | | 1 | -1 + 6 | 6 | six | | | 2 | 2 + 6 | 6 | six | | | 3 | -3 + 6 | 6 | six | | | 2 | 4 + 6 | 6 | six | | | 5 | -5 + 6 | 6 | six | | | 5 | -5 + 6 | 6 | six | | | 0 | + 6 | 6 | six | | | | + 6 | 6 | six | | | | 0 + 7 | 7 | seven | | | 1 | -1 + 7 | 7 | seven | | | 2 | 2 + 7 | 7 | seven | | | 3 | -3 + 7 | 7 | seven | | | 2 | 4 + 7 | 7 | seven | | | 5 | -5 + 7 | 7 | seven | | | 5 | -5 + 7 | 7 | seven | | | 0 | + 7 | 7 | seven | | | | + 7 | 7 | seven | | | | 0 + 8 | 8 | eight | | | 1 | -1 + 8 | 8 | eight | | | 2 | 2 + 8 | 8 | eight | | | 3 | -3 + 8 | 8 | eight | | | 2 | 4 + 8 | 8 | eight | | | 5 | -5 + 8 | 8 | eight | | | 5 | -5 + 8 | 8 | eight | | | 0 | + 8 | 8 | eight | | | | + 8 | 8 | eight | | | | 0 + 0 | | zero | | | 1 | -1 + 0 | | zero | | | 2 | 2 + 0 | | zero | | | 3 | -3 + 0 | | zero | | | 2 | 4 + 0 | | zero | | | 5 | -5 + 0 | | zero | | | 5 | -5 + 0 | | zero | | | 0 | + 0 | | zero | | | | + 0 | | zero | | | | 0 + | | null | | | 1 | -1 + | | null | | | 2 | 2 + | | null | | | 3 | -3 + | | null | | | 2 | 4 + | | null | | | 5 | -5 + | | null | | | 5 | -5 + | | null | | | 0 | + | | null | | | | + | | null | | | | 0 + | 0 | zero | | | 1 | -1 + | 0 | zero | | | 2 | 2 + | 0 | zero | | | 3 | -3 + | 0 | zero | | | 2 | 4 + | 0 | zero | | | 5 | -5 + | 0 | zero | | | 5 | -5 + | 0 | zero | | | 0 | + | 0 | zero | | | | + | 0 | zero | | | | 0 + 1 | 4 | one | | 0 | 1 | -1 + 1 | 4 | one | | 0 | 2 | 2 + 1 | 4 | one | | 0 | 3 | -3 + 1 | 4 | one | | 0 | 2 | 4 + 1 | 4 | one | | 0 | 5 | -5 + 1 | 4 | one | | 0 | 5 | -5 + 1 | 4 | one | | 0 | 0 | + 1 | 4 | one | | 0 | | + 1 | 4 | one | | 0 | | 0 + 2 | 3 | two | | 0 | 1 | -1 + 2 | 3 | two | | 0 | 2 | 2 + 2 | 3 | two | | 0 | 3 | -3 + 2 | 3 | two | | 0 | 2 | 4 + 2 | 3 | two | | 0 | 5 | -5 + 2 | 3 | two | | 0 | 5 | -5 + 2 | 3 | two | | 0 | 0 | + 2 | 3 | two | | 0 | | + 2 | 3 | two | | 0 | | 0 + 3 | 2 | three | | 0 | 1 | -1 + 3 | 2 | three | | 0 | 2 | 2 + 3 | 2 | three | | 0 | 3 | -3 + 3 | 2 | three | | 0 | 2 | 4 + 3 | 2 | three | | 0 | 5 | -5 + 3 | 2 | three | | 0 | 5 | -5 + 3 | 2 | three | | 0 | 0 | + 3 | 2 | three | | 0 | | + 3 | 2 | three | | 0 | | 0 + 4 | 1 | four | | 0 | 1 | -1 + 4 | 1 | four | | 0 | 2 | 2 + 4 | 1 | four | | 0 | 3 | -3 + 4 | 1 | four | | 0 | 2 | 4 + 4 | 1 | four | | 0 | 5 | -5 + 4 | 1 | four | | 0 | 5 | -5 + 4 | 1 | four | | 0 | 0 | + 4 | 1 | four | | 0 | | + 4 | 1 | four | | 0 | | 0 + 5 | 0 | five | | 0 | 1 | -1 + 5 | 0 | five | | 0 | 2 | 2 + 5 | 0 | five | | 0 | 3 | -3 + 5 | 0 | five | | 0 | 2 | 4 + 5 | 0 | five | | 0 | 5 | -5 + 5 | 0 | five | | 0 | 5 | -5 + 5 | 0 | five | | 0 | 0 | + 5 | 0 | five | | 0 | | + 5 | 0 | five | | 0 | | 0 + 6 | 6 | six | | 0 | 1 | -1 + 6 | 6 | six | | 0 | 2 | 2 + 6 | 6 | six | | 0 | 3 | -3 + 6 | 6 | six | | 0 | 2 | 4 + 6 | 6 | six | | 0 | 5 | -5 + 6 | 6 | six | | 0 | 5 | -5 + 6 | 6 | six | | 0 | 0 | + 6 | 6 | six | | 0 | | + 6 | 6 | six | | 0 | | 0 + 7 | 7 | seven | | 0 | 1 | -1 + 7 | 7 | seven | | 0 | 2 | 2 + 7 | 7 | seven | | 0 | 3 | -3 + 7 | 7 | seven | | 0 | 2 | 4 + 7 | 7 | seven | | 0 | 5 | -5 + 7 | 7 | seven | | 0 | 5 | -5 + 7 | 7 | seven | | 0 | 0 | + 7 | 7 | seven | | 0 | | + 7 | 7 | seven | | 0 | | 0 + 8 | 8 | eight | | 0 | 1 | -1 + 8 | 8 | eight | | 0 | 2 | 2 + 8 | 8 | eight | | 0 | 3 | -3 + 8 | 8 | eight | | 0 | 2 | 4 + 8 | 8 | eight | | 0 | 5 | -5 + 8 | 8 | eight | | 0 | 5 | -5 + 8 | 8 | eight | | 0 | 0 | + 8 | 8 | eight | | 0 | | + 8 | 8 | eight | | 0 | | 0 + 0 | | zero | | 0 | 1 | -1 + 0 | | zero | | 0 | 2 | 2 + 0 | | zero | | 0 | 3 | -3 + 0 | | zero | | 0 | 2 | 4 + 0 | | zero | | 0 | 5 | -5 + 0 | | zero | | 0 | 5 | -5 + 0 | | zero | | 0 | 0 | + 0 | | zero | | 0 | | + 0 | | zero | | 0 | | 0 + | | null | | 0 | 1 | -1 + | | null | | 0 | 2 | 2 + | | null | | 0 | 3 | -3 + | | null | | 0 | 2 | 4 + | | null | | 0 | 5 | -5 + | | null | | 0 | 5 | -5 + | | null | | 0 | 0 | + | | null | | 0 | | + | | null | | 0 | | 0 + | 0 | zero | | 0 | 1 | -1 + | 0 | zero | | 0 | 2 | 2 + | 0 | zero | | 0 | 3 | -3 + | 0 | zero | | 0 | 2 | 4 + | 0 | zero | | 0 | 5 | -5 + | 0 | zero | | 0 | 5 | -5 + | 0 | zero | | 0 | 0 | + | 0 | zero | | 0 | | + | 0 | zero | | 0 | | 0 (891 rows) -- @@ -1660,163 +1660,235 @@ SELECT '' AS "xxx", * -- -- Inner equi-join on specified column --Testcase 33: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL INNER JOIN J2_TBL USING (i); - xxx | i | j | t | k ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 + i | j | t | k +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 5 | 0 | five | -5 + 5 | 0 | five | -5 (7 rows) -- Same as above, slightly different syntax --Testcase 34: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL JOIN J2_TBL USING (i); - xxx | i | j | t | k ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 + i | j | t | k +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 5 | 0 | five | -5 + 5 | 0 | five | -5 (7 rows) --Testcase 35: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, d) USING (a) ORDER BY a, d; - xxx | a | b | c | d ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 + a | b | c | d +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 5 | 0 | five | -5 + 5 | 0 | five | -5 (7 rows) --Testcase 36: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, b) USING (b) ORDER BY b, t1.a; - xxx | b | a | c | a ------+---+---+-------+--- - | 0 | 5 | five | - | 0 | | zero | - | 2 | 3 | three | 2 - | 4 | 1 | one | 2 + b | a | c | a +---+---+-------+--- + 0 | 5 | five | + 0 | | zero | + 2 | 3 | three | 2 + 4 | 1 | one | 2 (4 rows) +-- test join using aliases +--Testcase 489: +SELECT * + FROM J1_TBL JOIN J2_TBL USING (i) WHERE J1_TBL.t = 'one'; -- ok + i | j | t | k +---+---+-----+---- + 1 | 4 | one | -1 +(1 row) + +--Testcase 490: +SELECT * + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; -- ok + i | j | t | k +---+---+-----+---- + 1 | 4 | one | -1 +(1 row) + +--Testcase 491: +SELECT * + FROM (J1_TBL JOIN J2_TBL USING (i)) AS x WHERE J1_TBL.t = 'one'; -- error +ERROR: invalid reference to FROM-clause entry for table "j1_tbl" +LINE 2: FROM (J1_TBL JOIN J2_TBL USING (i)) AS x WHERE J1_TBL.t = ... + ^ +HINT: There is an entry for table "j1_tbl", but it cannot be referenced from this part of the query. +--Testcase 492: +SELECT * + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.i = 1; -- ok + i | j | t | k +---+---+-----+---- + 1 | 4 | one | -1 +(1 row) + +--Testcase 493: +SELECT * + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.t = 'one'; -- error +ERROR: column x.t does not exist +LINE 2: FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.t = 'one'; + ^ +--Testcase 494: +SELECT * + FROM (J1_TBL JOIN J2_TBL USING (i) AS x) AS xx WHERE x.i = 1; -- error (XXX could use better hint) +ERROR: missing FROM-clause entry for table "x" +LINE 2: ...ROM (J1_TBL JOIN J2_TBL USING (i) AS x) AS xx WHERE x.i = 1; + ^ +--Testcase 495: +SELECT * + FROM J1_TBL a1 JOIN J2_TBL a2 USING (i) AS a1; -- error +ERROR: table name "a1" specified more than once +--Testcase 496: +SELECT x.* + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; + i +--- + 1 +(1 row) + +--Testcase 497: +SELECT ROW(x.*) + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; + row +----- + (1) +(1 row) + +--Testcase 498: +SELECT row_to_json(x.*) + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; + row_to_json +------------- + {"i":1} +(1 row) + -- -- NATURAL JOIN -- Inner equi-join on all columns with the same name -- --Testcase 37: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL NATURAL JOIN J2_TBL; - xxx | i | j | t | k ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 + i | j | t | k +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 5 | 0 | five | -5 + 5 | 0 | five | -5 (7 rows) --Testcase 38: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (a, d); - xxx | a | b | c | d ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 + a | b | c | d +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 5 | 0 | five | -5 + 5 | 0 | five | -5 (7 rows) --Testcase 39: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (d, a); - xxx | a | b | c | d ------+---+---+------+--- - | 0 | | zero | - | 2 | 3 | two | 2 - | 4 | 1 | four | 2 + a | b | c | d +---+---+------+--- + 0 | | zero | + 2 | 3 | two | 2 + 4 | 1 | four | 2 (3 rows) -- mismatch number of columns -- currently, Postgres will fill in with underlying names --Testcase 40: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b) NATURAL JOIN J2_TBL t2 (a); - xxx | a | b | t | k ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 + a | b | t | k +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 5 | 0 | five | -5 + 5 | 0 | five | -5 (7 rows) -- -- Inner joins (equi-joins) -- --Testcase 41: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.i); - xxx | i | j | t | i | k ------+---+---+-------+---+---- - | 0 | | zero | 0 | - | 1 | 4 | one | 1 | -1 - | 2 | 3 | two | 2 | 2 - | 2 | 3 | two | 2 | 4 - | 3 | 2 | three | 3 | -3 - | 5 | 0 | five | 5 | -5 - | 5 | 0 | five | 5 | -5 + i | j | t | i | k +---+---+-------+---+---- + 0 | | zero | 0 | + 1 | 4 | one | 1 | -1 + 2 | 3 | two | 2 | 2 + 2 | 3 | two | 2 | 4 + 3 | 2 | three | 3 | -3 + 5 | 0 | five | 5 | -5 + 5 | 0 | five | 5 | -5 (7 rows) --Testcase 42: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.k); - xxx | i | j | t | i | k ------+---+---+------+---+--- - | 0 | | zero | | 0 - | 2 | 3 | two | 2 | 2 - | 4 | 1 | four | 2 | 4 + i | j | t | i | k +---+---+------+---+--- + 0 | | zero | | 0 + 2 | 3 | two | 2 | 2 + 4 | 1 | four | 2 | 4 (3 rows) -- -- Non-equi-joins -- --Testcase 43: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i <= J2_TBL.k); - xxx | i | j | t | i | k ------+---+---+-------+---+--- - | 1 | 4 | one | 2 | 2 - | 1 | 4 | one | 2 | 4 - | 2 | 3 | two | 2 | 2 - | 2 | 3 | two | 2 | 4 - | 3 | 2 | three | 2 | 4 - | 4 | 1 | four | 2 | 4 - | 0 | | zero | 2 | 2 - | 0 | | zero | 2 | 4 - | 0 | | zero | | 0 + i | j | t | i | k +---+---+-------+---+--- + 1 | 4 | one | 2 | 2 + 1 | 4 | one | 2 | 4 + 2 | 3 | two | 2 | 2 + 2 | 3 | two | 2 | 4 + 3 | 2 | three | 2 | 4 + 4 | 1 | four | 2 | 4 + 0 | | zero | 2 | 2 + 0 | | zero | 2 | 4 + 0 | | zero | | 0 (9 rows) -- @@ -1824,138 +1896,138 @@ SELECT '' AS "xxx", * -- Note that OUTER is a noise word -- --Testcase 44: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL LEFT OUTER JOIN J2_TBL USING (i) ORDER BY i, k, t; - xxx | i | j | t | k ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 4 | 1 | four | - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 - | 6 | 6 | six | - | 7 | 7 | seven | - | 8 | 8 | eight | - | | | null | - | | 0 | zero | + i | j | t | k +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 4 | 1 | four | + 5 | 0 | five | -5 + 5 | 0 | five | -5 + 6 | 6 | six | + 7 | 7 | seven | + 8 | 8 | eight | + | | null | + | 0 | zero | (13 rows) --Testcase 45: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL LEFT JOIN J2_TBL USING (i) ORDER BY i, k, t; - xxx | i | j | t | k ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 4 | 1 | four | - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 - | 6 | 6 | six | - | 7 | 7 | seven | - | 8 | 8 | eight | - | | | null | - | | 0 | zero | + i | j | t | k +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 4 | 1 | four | + 5 | 0 | five | -5 + 5 | 0 | five | -5 + 6 | 6 | six | + 7 | 7 | seven | + 8 | 8 | eight | + | | null | + | 0 | zero | (13 rows) --Testcase 46: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL RIGHT OUTER JOIN J2_TBL USING (i); - xxx | i | j | t | k ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 - | | | | - | | | | 0 + i | j | t | k +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 5 | 0 | five | -5 + 5 | 0 | five | -5 + | | | + | | | 0 (9 rows) --Testcase 47: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL RIGHT JOIN J2_TBL USING (i); - xxx | i | j | t | k ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 - | | | | - | | | | 0 + i | j | t | k +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 5 | 0 | five | -5 + 5 | 0 | five | -5 + | | | + | | | 0 (9 rows) --Testcase 48: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL FULL OUTER JOIN J2_TBL USING (i) ORDER BY i, k, t; - xxx | i | j | t | k ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 4 | 1 | four | - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 - | 6 | 6 | six | - | 7 | 7 | seven | - | 8 | 8 | eight | - | | | | 0 - | | | null | - | | 0 | zero | - | | | | + i | j | t | k +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 4 | 1 | four | + 5 | 0 | five | -5 + 5 | 0 | five | -5 + 6 | 6 | six | + 7 | 7 | seven | + 8 | 8 | eight | + | | | 0 + | | null | + | 0 | zero | + | | | (15 rows) --Testcase 49: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL FULL JOIN J2_TBL USING (i) ORDER BY i, k, t; - xxx | i | j | t | k ------+---+---+-------+---- - | 0 | | zero | - | 1 | 4 | one | -1 - | 2 | 3 | two | 2 - | 2 | 3 | two | 4 - | 3 | 2 | three | -3 - | 4 | 1 | four | - | 5 | 0 | five | -5 - | 5 | 0 | five | -5 - | 6 | 6 | six | - | 7 | 7 | seven | - | 8 | 8 | eight | - | | | | 0 - | | | null | - | | 0 | zero | - | | | | + i | j | t | k +---+---+-------+---- + 0 | | zero | + 1 | 4 | one | -1 + 2 | 3 | two | 2 + 2 | 3 | two | 4 + 3 | 2 | three | -3 + 4 | 1 | four | + 5 | 0 | five | -5 + 5 | 0 | five | -5 + 6 | 6 | six | + 7 | 7 | seven | + 8 | 8 | eight | + | | | 0 + | | null | + | 0 | zero | + | | | (15 rows) --Testcase 50: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (k = 1); - xxx | i | j | t | k ------+---+---+---+--- + i | j | t | k +---+---+---+--- (0 rows) --Testcase 51: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (i = 1); - xxx | i | j | t | k ------+---+---+-----+---- - | 1 | 4 | one | -1 + i | j | t | k +---+---+-----+---- + 1 | 4 | one | -1 (1 row) -- @@ -2052,8 +2124,8 @@ USING (name); ------+----+---- bb | 12 | 13 cc | 22 | 23 - dd | | 33 ee | 42 | + dd | | 33 (4 rows) -- Cases with non-nullable expressions in subquery results; @@ -2090,8 +2162,8 @@ NATURAL FULL JOIN ------+------+------+------+------ bb | 12 | 2 | 13 | 3 cc | 22 | 2 | 23 | 3 - dd | | | 33 | 3 ee | 42 | 2 | | + dd | | | 33 | 3 (4 rows) --Testcase 67: @@ -2162,7 +2234,14 @@ SELECT * FROM FULL JOIN (SELECT name, 2 as s2_n FROM t21) as s2 ON (s1_n = s2_n); -ERROR: FULL JOIN is only supported with merge-joinable or hash-joinable join conditions + name | s1_n | name | s2_n +------+------+------+------ + | | bb | 2 + | | cc | 2 + | | ee | 2 + bb | 11 | | +(4 rows) + -- Test for propagation of nullability constraints into sub-joins --Testcase 376: create foreign table x (x1 int, x2 int) server sqlite_svr; @@ -2337,7 +2416,9 @@ select count(*) from tenk1 x where -- try that with GEQO too begin; +--Testcase 499: set geqo = on; +--Testcase 500: set geqo_threshold = 2; --Testcase 93: select count(*) from tenk1 x where @@ -2386,18 +2467,14 @@ explain (costs off) select * from int8_tbl i1 left join (int8_tbl i2 join (select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2 order by 1, 2; - QUERY PLAN ------------------------------------------------ + QUERY PLAN +----------------------------------------- Nested Loop Left Join Join Filter: (i1.q2 = i2.q2) -> Foreign Scan on int8_tbl i1 -> Materialize - -> Hash Join - Hash Cond: (i2.q1 = (123)) - -> Foreign Scan on int8_tbl i2 - -> Hash - -> Result -(9 rows) + -> Foreign Scan on int8_tbl i2 +(5 rows) --Testcase 95: select * from int8_tbl i1 left join (int8_tbl i2 join @@ -2639,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 @@ -2655,7 +2733,9 @@ CREATE FOREIGN TABLE tt2 ( tt2_id int4, joincol int4 ) SERVER sqlite_svr; INSERT INTO tt2 VALUES (21, 11); --Testcase 124: INSERT INTO tt2 VALUES (22, 11); +--Testcase 501: set enable_hashjoin to off; +--Testcase 502: set enable_nestloop to off; -- these should give the same results --Testcase 125: @@ -2676,13 +2756,19 @@ select tt1.*, tt2.* from tt2 right join tt1 on tt1.joincol = tt2.joincol; 2 | | | (3 rows) +--Testcase 503: reset enable_hashjoin; +--Testcase 504: reset enable_nestloop; -- -- regression test for bug #13908 (hash join with skew tuples & nbatch increase) -- +--Testcase 505: set work_mem to '64kB'; +--Testcase 506: set enable_mergejoin to off; +--Testcase 507: +set enable_memoize to off; --Testcase 127: explain (costs off) select count(*) from tenk1 a, tenk1 b @@ -2700,8 +2786,12 @@ select count(*) from tenk1 a, tenk1 b 100000 (1 row) +--Testcase 508: reset work_mem; +--Testcase 509: reset enable_mergejoin; +--Testcase 510: +reset enable_memoize; -- -- regression test for 8.2 bug with improper re-ordering of left joins -- @@ -2866,6 +2956,7 @@ where f2 = 53; 53 | | | (1 row) +--Testcase 537: drop view zv1; -- -- regression test for improper extraction of OR indexqual conditions @@ -2906,8 +2997,11 @@ execute foo(false); -- test for sane behavior with noncanonical merge clauses, per bug #4926 -- begin; +--Testcase 511: set enable_mergejoin = 1; +--Testcase 512: set enable_hashjoin = 0; +--Testcase 513: set enable_nestloop = 0; --Testcase 403: create foreign table a1 (i integer) server sqlite_svr; @@ -3261,6 +3355,70 @@ order by 1,2; 4567890123456789 | 4567890123456789 | 4567890123456789 | 42 (8 rows) +-- +-- variant where a PlaceHolderVar is needed at a join, but not above the join +-- +--Testcase 514: +explain (costs off) +select * from + int4_tbl as i41, + lateral + (select 1 as x from + (select i41.f1 as lat, + i42.f1 as loc from + int8_tbl as i81, int4_tbl as i42) as ss1 + right join int4_tbl as i43 on (i43.f1 > 1) + where ss1.loc = ss1.lat) as ss2 +where i41.f1 > 0; + QUERY PLAN +------------------------------------------------------ + Nested Loop + -> Nested Loop + -> Foreign Scan on int4_tbl i41 + -> Nested Loop + Join Filter: (i41.f1 = i42.f1) + -> Foreign Scan on int8_tbl i81 + -> Materialize + -> Foreign Scan on int4_tbl i42 + -> Materialize + -> Foreign Scan on int4_tbl i43 +(10 rows) + +--Testcase 515: +select * from + int4_tbl as i41, + lateral + (select 1 as x from + (select i41.f1 as lat, + i42.f1 as loc from + int8_tbl as i81, int4_tbl as i42) as ss1 + right join int4_tbl as i43 on (i43.f1 > 1) + where ss1.loc = ss1.lat) as ss2 +where i41.f1 > 0; + f1 | x +------------+--- + 123456 | 1 + 123456 | 1 + 123456 | 1 + 123456 | 1 + 123456 | 1 + 123456 | 1 + 123456 | 1 + 123456 | 1 + 123456 | 1 + 123456 | 1 + 2147483647 | 1 + 2147483647 | 1 + 2147483647 | 1 + 2147483647 | 1 + 2147483647 | 1 + 2147483647 | 1 + 2147483647 | 1 + 2147483647 | 1 + 2147483647 | 1 + 2147483647 | 1 +(20 rows) + -- -- test the corner cases FULL JOIN ON TRUE and FULL JOIN ON FALSE -- @@ -3393,28 +3551,20 @@ select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from left join tenk1 t2 on (subq1.y1 = t2.unique1) where t1.unique2 < 42 and t1.stringu1 > t2.stringu2; - QUERY PLAN ------------------------------------------------------------------ - Merge Join - Merge Cond: (t2.unique1 = (3)) + QUERY PLAN +----------------------------------------------------- + Hash Join + Hash Cond: (t2.unique1 = (3)) Join Filter: (t1.stringu1 > t2.stringu2) - -> Sort - Sort Key: t2.unique1 - -> Foreign Scan on tenk1 t2 - -> Sort - Sort Key: (3) - -> Hash Join - Hash Cond: ((11) = t1.unique2) - -> Nested Loop Left Join - Join Filter: (i1.f1 = 0) - -> Foreign Scan on int4_tbl i1 - -> Materialize - -> Nested Loop Left Join - -> Seq Scan on onerow - -> Seq Scan on onerow onerow_1 - -> Hash - -> Foreign Scan on tenk1 t1 -(19 rows) + -> Foreign Scan + -> Hash + -> Nested Loop + Join Filter: ((11) = t1.unique2) + -> Nested Loop + -> Seq Scan on onerow + -> Seq Scan on onerow onerow_1 + -> Foreign Scan on tenk1 t1 +(11 rows) --Testcase 188: select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from @@ -3470,23 +3620,19 @@ select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from left join tenk1 t2 on (subq1.y1 = t2.unique1) where t1.unique2 < 42 and t1.stringu1 > t2.stringu2; - QUERY PLAN ---------------------------------------------------------------------------- - Nested Loop - Join Filter: ((0) = i1.f1) - -> Nested Loop - Join Filter: ((t1.stringu1 > t2.stringu2) AND ((3) = t2.unique1)) + QUERY PLAN +----------------------------------------------------- + Hash Join + Hash Cond: (t2.unique1 = (3)) + Join Filter: (t1.stringu1 > t2.stringu2) + -> Foreign Scan on tenk1 t2 + -> Hash -> Hash Join Hash Cond: (t1.unique2 = (11)) -> Foreign Scan on tenk1 t1 -> Hash - -> Nested Loop - Join Filter: ((1) = (1)) - -> Result - -> Result - -> Foreign Scan on tenk1 t2 - -> Foreign Scan on int4_tbl i1 -(14 rows) + -> Foreign Scan on int4_tbl i1 +(10 rows) --Testcase 420: select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from @@ -3542,6 +3688,44 @@ select * from 1 | 2 | 2 (1 row) +-- Test proper handling of appendrel PHVs during useless-RTE removal +--Testcase 516: +explain (costs off) +select * from + (select 0 as z) as t1 + left join + (select true as a) as t2 + on true, + lateral (select true as b + union all + select a as b) as t3 +where b; + QUERY PLAN +--------------------------------------- + Nested Loop + -> Result + -> Append + -> Result + -> Result + One-Time Filter: (true) +(6 rows) + +--Testcase 517: +select * from + (select 0 as z) as t1 + left join + (select true as a) as t2 + on true, + lateral (select true as b + union all + select a as b) as t3 +where b; + z | a | b +---+---+--- + 0 | t | t + 0 | t | t +(2 rows) + -- -- test inlining of immutable functions @@ -3554,14 +3738,10 @@ $$ begin return i; end; $$ language plpgsql immutable; explain (costs off) select unique1 from tenk1, (select * from f_immutable_int4(1) x) x where x = unique1; - QUERY PLAN ------------------------------------- - Hash Join - Hash Cond: (tenk1.unique1 = x.x) - -> Foreign Scan on tenk1 - -> Hash - -> Function Scan on x -(5 rows) + QUERY PLAN +----------------------- + Foreign Scan on tenk1 +(1 row) --Testcase 425: explain (verbose, costs off) @@ -3571,77 +3751,71 @@ where x = unique1; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Hash Join - Output: tenk1.unique1, x.x, (random()) - Hash Cond: (tenk1.unique1 = x.x) + Output: tenk1.unique1, (1), (random()) + Hash Cond: (tenk1.unique1 = (1)) -> Foreign Scan on public.tenk1 Output: tenk1.unique1, tenk1.unique2, tenk1.two, tenk1.four, tenk1.ten, tenk1.twenty, tenk1.hundred, tenk1.thousand, tenk1.twothousand, tenk1.fivethous, tenk1.tenthous, tenk1.odd, tenk1.even, tenk1.stringu1, tenk1.stringu2, tenk1.string4 SQLite query: SELECT `unique1` FROM main."tenk1" -> Hash - Output: x.x, (random()) - -> Function Scan on x - Output: x.x, random() - Function Call: 1 -(11 rows) + Output: (1), (random()) + -> Result + Output: 1, random() +(10 rows) --Testcase 426: explain (costs off) select unique1 from tenk1, f_immutable_int4(1) x where x = unique1; - QUERY PLAN ------------------------------------- - Hash Join - Hash Cond: (tenk1.unique1 = x.x) - -> Foreign Scan on tenk1 - -> Hash - -> Function Scan on x -(5 rows) + QUERY PLAN +----------------------- + Foreign Scan on tenk1 +(1 row) --Testcase 427: explain (costs off) select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1; - QUERY PLAN ------------------------------------- - Hash Join - Hash Cond: (tenk1.unique1 = x.x) - -> Foreign Scan on tenk1 - -> Hash - -> Function Scan on x -(5 rows) + QUERY PLAN +----------------------- + 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; - QUERY PLAN ------------------------------------- - Hash Join - Hash Cond: (tenk1.unique1 = x.x) - -> Foreign Scan on tenk1 - -> Hash - -> Function Scan on x -(5 rows) + QUERY PLAN +----------------------- + Foreign Scan on tenk1 +(1 row) --Testcase 429: explain (costs off) select unique1, x from tenk1 left join f_immutable_int4(1) x on unique1 = x; QUERY PLAN ------------------------------------ - Hash Left Join - Hash Cond: (tenk1.unique1 = x.x) + Nested Loop Left Join + Join Filter: (tenk1.unique1 = 1) -> Foreign Scan on tenk1 - -> Hash - -> Function Scan on x + -> Materialize + -> Result (5 rows) --Testcase 430: explain (costs off) select unique1, x from tenk1 right join f_immutable_int4(1) x on unique1 = x; - QUERY PLAN ------------------------------------- - Hash Right Join - Hash Cond: (tenk1.unique1 = x.x) + QUERY PLAN +----------------------------- + Nested Loop Left Join + -> Result -> Foreign Scan on tenk1 - -> Hash - -> Function Scan on x -(5 rows) +(3 rows) --Testcase 431: explain (costs off) @@ -3649,23 +3823,21 @@ select unique1, x from tenk1 full join f_immutable_int4(1) x on unique1 = x; QUERY PLAN ------------------------------------ Hash Full Join - Hash Cond: (tenk1.unique1 = x.x) + Hash Cond: (tenk1.unique1 = (1)) -> Foreign Scan on tenk1 -> Hash - -> Function Scan on x + -> Result (5 rows) -- check that pullup of a const function allows further const-folding --Testcase 432: explain (costs off) select unique1 from tenk1, f_immutable_int4(1) x where x = 42; - QUERY PLAN ------------------------------ - Nested Loop - -> Function Scan on x - Filter: (x = 42) - -> Foreign Scan on tenk1 -(4 rows) + QUERY PLAN +-------------------------- + Result + One-Time Filter: false +(2 rows) -- test inlining of immutable functions with PlaceHolderVars --Testcase 433: @@ -3681,16 +3853,16 @@ from nt3 as nt3 ) as ss2 on ss2.id = nt3.nt2_id where nt3.id = 1 and ss2.b3; - QUERY PLAN ------------------------------------------ + QUERY PLAN +--------------------------------------- Hash Right Join Hash Cond: (nt2.id = nt3.nt2_id) - Filter: ((nt2.b1 OR (i4.i4 = 42))) - -> Hash Left Join - Hash Cond: (nt2.nt1_id = i4.i4) + Filter: ((nt2.b1 OR ((0) = 42))) + -> Nested Loop Left Join + Join Filter: (0 = nt2.nt1_id) -> Foreign Scan on nt2 - -> Hash - -> Function Scan on i4 + -> Materialize + -> Result -> Hash -> Foreign Scan on nt3 (10 rows) @@ -3707,11 +3879,11 @@ $$select row($1)::int4_tbl$$ language sql; --Testcase 437: explain (verbose, costs off) select * from mki8(1,2); - QUERY PLAN ----------------------------------------------------------- + QUERY PLAN +------------------------------------ Function Scan on mki8 Output: q1, q2 - Function Call: ROW('1'::bigint, '2'::bigint)::int8_tbl + Function Call: '(1,2)'::int8_tbl (3 rows) --Testcase 438: @@ -3724,11 +3896,11 @@ select * from mki8(1,2); --Testcase 439: explain (verbose, costs off) select * from mki4(42); - QUERY PLAN ------------------------------------- + QUERY PLAN +----------------------------------- Function Scan on mki4 Output: f1 - Function Call: ROW(42)::int4_tbl + Function Call: '(42)'::int4_tbl (3 rows) --Testcase 440: @@ -3998,18 +4170,15 @@ select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand) ------------------------------------------------------------------- Hash Left Join Hash Cond: (COALESCE(b.twothousand, a.twothousand) = c.unique2) - -> Merge Left Join - Merge Cond: (a.unique1 = b.thousand) + -> Hash Right Join + Hash Cond: (b.thousand = a.unique1) Filter: (COALESCE(b.twothousand, a.twothousand) = 44) - -> Sort - Sort Key: a.unique1 + -> Foreign Scan on tenk1 b + -> Hash -> Foreign Scan on tenk1 a - -> Sort - Sort Key: b.thousand - -> Foreign Scan on tenk1 b -> Hash -> Foreign Scan on tenk1 c -(13 rows) +(10 rows) --Testcase 208: select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand) @@ -4135,7 +4304,7 @@ select t1.* from -> Sort Output: i8.q2, (NULL::integer) Sort Key: (NULL::integer) - -> Merge Left Join + -> Merge Join Output: i8.q2, (NULL::integer) Merge Cond: (i8.q1 = i8b2.q1) -> Sort @@ -4181,63 +4350,69 @@ select t1.* from on (t1.f1 = b1.d1) left join int4_tbl i4 on (i8.q2 = i4.f1); - QUERY PLAN --------------------------------------------------------------------------------------------------------------------- - Hash Left Join + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------------- + Merge Right Join Output: t1.f1 - Hash Cond: (i8.q2 = i4.f1) - -> Nested Loop Left Join - Output: t1.f1, i8.q2 - Join Filter: (t1.f1 = '***'::text) - -> Foreign Scan on public.text_tbl t1 - Output: t1.f1 - SQLite query: SELECT `f1` FROM main."text_tbl" - -> Materialize - Output: i8.q2 - -> Merge Left Join - Output: i8.q2 - Merge Cond: (i8b1.q2 = (NULL::integer)) - -> Sort - Output: i8b1.q2 - Sort Key: i8b1.q2 - -> Foreign Scan on public.int8_tbl i8b1 - Output: i8b1.q2 - SQLite query: SELECT `q2` FROM main."int8_tbl" - -> Materialize - Output: i8.q2, (NULL::integer) - -> Sort - Output: i8.q2, (NULL::integer) - Sort Key: (NULL::integer) - -> Merge Left Join - Output: i8.q2, (NULL::integer) - Merge Cond: (i8.q1 = i8b2.q1) - -> Sort - Output: i8.q1, i8.q2 - Sort Key: i8.q1 - -> Foreign Scan on public.int8_tbl i8 - Output: i8.q1, i8.q2 - SQLite query: SELECT `q1`, `q2` FROM main."int8_tbl" - -> Materialize - Output: i8b2.q1, (NULL::integer) - -> Sort - Output: i8b2.q1, (NULL::integer) - Sort Key: i8b2.q1 - -> Nested Loop - Output: i8b2.q1, NULL::integer - -> Foreign Scan on public.int4_tbl i4b2 - Output: i4b2.f1 - SQLite query: SELECT NULL FROM main."int4_tbl" - -> Materialize - Output: i8b2.q1 - -> Foreign Scan on public.int8_tbl i8b2 - Output: i8b2.q1 - SQLite query: SELECT `q1` FROM main."int8_tbl" - -> Hash + Merge Cond: (i4.f1 = i8.q2) + -> Sort Output: i4.f1 + Sort Key: i4.f1 -> Foreign Scan on public.int4_tbl i4 Output: i4.f1 SQLite query: SELECT `f1` FROM main."int4_tbl" -(54 rows) + -> Materialize + Output: t1.f1, i8.q2 + -> Sort + Output: t1.f1, i8.q2 + Sort Key: i8.q2 + -> Nested Loop Left Join + Output: t1.f1, i8.q2 + Join Filter: (t1.f1 = '***'::text) + -> Foreign Scan on public.text_tbl t1 + Output: t1.f1 + SQLite query: SELECT `f1` FROM main."text_tbl" + -> Materialize + Output: i8.q2 + -> Merge Left Join + Output: i8.q2 + Merge Cond: (i8b1.q2 = (NULL::integer)) + -> Sort + Output: i8b1.q2 + Sort Key: i8b1.q2 + -> Foreign Scan on public.int8_tbl i8b1 + Output: i8b1.q2 + SQLite query: SELECT `q2` FROM main."int8_tbl" + -> Materialize + Output: i8.q2, (NULL::integer) + -> Sort + Output: i8.q2, (NULL::integer) + Sort Key: (NULL::integer) + -> Merge Left Join + Output: i8.q2, (NULL::integer) + Merge Cond: (i8.q1 = i8b2.q1) + -> Sort + Output: i8.q1, i8.q2 + Sort Key: i8.q1 + -> Foreign Scan on public.int8_tbl i8 + Output: i8.q1, i8.q2 + SQLite query: SELECT `q1`, `q2` FROM main."int8_tbl" + -> Materialize + Output: i8b2.q1, (NULL::integer) + -> Sort + Output: i8b2.q1, (NULL::integer) + Sort Key: i8b2.q1 + -> Nested Loop + Output: i8b2.q1, NULL::integer + -> Foreign Scan on public.int4_tbl i4b2 + Output: i4b2.f1 + SQLite query: SELECT NULL FROM main."int4_tbl" + -> Materialize + Output: i8b2.q1 + -> Foreign Scan on public.int8_tbl i8b2 + Output: i8b2.q1 + SQLite query: SELECT `q1` FROM main."int8_tbl" +(60 rows) --Testcase 214: select t1.* from @@ -4457,10 +4632,14 @@ 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 - -> Foreign Scan on public.text_tbl t3 - Output: (i8.q1), t2.f1 - SQLite query: SELECT NULL FROM main."text_tbl" LIMIT 1 -(14 rows) + -> Memoize + Output: ((i8.q1)), (t2.f1) + Cache Key: (i8.q1), t2.f1 + Cache Mode: binary + -> Foreign Scan on public.text_tbl t3 + Output: (i8.q1), t2.f1 + SQLite query: SELECT NULL FROM main."text_tbl" LIMIT 1 +(18 rows) --Testcase 222: select * from @@ -4603,10 +4782,10 @@ select * from QUERY PLAN --------------------------------------- Nested Loop Left Join - Join Filter: ((1) = COALESCE((1))) -> Result -> Hash Full Join Hash Cond: (a1.unique1 = (1)) + Filter: (1 = COALESCE((1))) -> Foreign Scan on tenk1 a1 -> Hash -> Result @@ -4641,24 +4820,23 @@ explain (costs off) --Testcase 230: explain (costs off) select * from tenk1 a full join tenk1 b using(unique2) where unique2 = 42; - QUERY PLAN ---------------------------------------- - Merge Full Join - Merge Cond: (a.unique2 = b.unique2) - -> Sort - Sort Key: a.unique2 - -> Foreign Scan on tenk1 a - -> Sort - Sort Key: b.unique2 + QUERY PLAN +-------------------------------------- + Hash Full Join + Hash Cond: (a.unique2 = b.unique2) + -> Foreign Scan on tenk1 a + -> Hash -> Foreign Scan on tenk1 b -(8 rows) +(5 rows) -- -- test that quals attached to an outer join have correct semantics, -- specifically that they don't re-use expressions computed below the join; -- we force a mergejoin so that coalesce(b.q1, 1) appears as a join input -- +--Testcase 518: set enable_hashjoin to off; +--Testcase 519: set enable_nestloop to off; --Testcase 231: explain (verbose, costs off) @@ -4703,7 +4881,9 @@ select a.q2, b.q1 4567890123456789 | 4567890123456789 (10 rows) +--Testcase 520: reset enable_hashjoin; +--Testcase 521: reset enable_nestloop; -- -- test join removal @@ -5098,12 +5278,12 @@ where ss.stringu2 !~* ss.case1; -> Sort Sort Key: t1.unique2 -> Merge Right Join - Merge Cond: (u1.f1 = ((t1.string4)::text)) + Merge Cond: (u1.f1 = t1.string4) -> Sort - Sort Key: u1.f1 + Sort Key: u1.f1 COLLATE "C" -> Foreign Scan on uniquetbl u1 -> Sort - Sort Key: ((t1.string4)::text) + Sort Key: t1.string4 -> Merge Join Merge Cond: ((CASE t1.ten WHEN 0 THEN 'doh!'::text ELSE NULL::text END) = t0.f1) -> Sort @@ -5133,6 +5313,63 @@ where ss.stringu2 !~* ss.case1; (1 row) rollback; +-- test case to expose miscomputation of required relid set for a PHV +--Testcase 522: +explain (verbose, costs off) +select i8.*, ss.v, t.unique2 + from int8_tbl i8 + left join int4_tbl i4 on i4.f1 = 1 + left join lateral (select i4.f1 + 1 as v) as ss on true + left join tenk1 t on t.unique2 = ss.v +where q2 = 456; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Hash Right Join + Output: i8.q1, i8.q2, ((i4.f1 + 1)), t.unique2 + Hash Cond: (t.unique2 = ((i4.f1 + 1))) + -> Foreign Scan on public.tenk1 t + Output: t.unique1, t.unique2, t.two, t.four, t.ten, t.twenty, t.hundred, t.thousand, t.twothousand, t.fivethous, t.tenthous, t.odd, t.even, t.stringu1, t.stringu2, t.string4 + SQLite query: SELECT `unique2` FROM main."tenk1" + -> Hash + Output: i8.q1, i8.q2, ((i4.f1 + 1)) + -> Nested Loop Left Join + Output: i8.q1, i8.q2, (i4.f1 + 1) + -> Foreign Scan on public.int8_tbl i8 + Output: i8.q1, i8.q2 + SQLite query: SELECT `q1`, `q2` FROM main."int8_tbl" WHERE ((`q2` = 456)) + -> Materialize + Output: i4.f1 + -> Foreign Scan on public.int4_tbl i4 + Output: i4.f1 + SQLite query: SELECT `f1` FROM main."int4_tbl" WHERE ((`f1` = 1)) +(18 rows) + +--Testcase 523: +select i8.*, ss.v, t.unique2 + from int8_tbl i8 + left join int4_tbl i4 on i4.f1 = 1 + left join lateral (select i4.f1 + 1 as v) as ss on true + left join tenk1 t on t.unique2 = ss.v +where q2 = 456; + q1 | q2 | v | unique2 +-----+-----+---+--------- + 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 @@ -6029,37 +6266,43 @@ select * from ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Nested Loop Output: c.q1, c.q2, a.q1, a.q2, b.q1, (COALESCE(b.q2, '42'::bigint)), d.q1, (COALESCE((COALESCE(b.q2, '42'::bigint)), d.q2)), ((COALESCE((COALESCE(b.q2, '42'::bigint)), d.q2))) - -> Hash Right Join + -> Merge Left Join Output: c.q1, c.q2, a.q1, a.q2, b.q1, d.q1, (COALESCE(b.q2, '42'::bigint)), (COALESCE((COALESCE(b.q2, '42'::bigint)), d.q2)) - Hash Cond: (d.q1 = c.q2) - -> Nested Loop - Output: a.q1, a.q2, b.q1, d.q1, (COALESCE(b.q2, '42'::bigint)), (COALESCE((COALESCE(b.q2, '42'::bigint)), d.q2)) - -> Merge Left Join - Output: a.q1, a.q2, b.q1, (COALESCE(b.q2, '42'::bigint)) - Merge Cond: (a.q2 = b.q1) - -> Sort - Output: a.q1, a.q2 - Sort Key: a.q2 - -> Foreign Scan on public.int8_tbl a - Output: a.q1, a.q2 - SQLite query: SELECT `q1`, `q2` FROM main."int8_tbl" - -> Sort - Output: b.q1, (COALESCE(b.q2, '42'::bigint)) - Sort Key: b.q1 - -> Foreign Scan on public.int8_tbl b - Output: b.q1, COALESCE(b.q2, '42'::bigint) - SQLite query: SELECT `q1`, `q2` FROM main."int8_tbl" - -> Foreign Scan on public.int8_tbl d - Output: d.q1, COALESCE((COALESCE(b.q2, '42'::bigint)), d.q2) - SQLite query: SELECT `q1`, `q2` FROM main."int8_tbl" - -> Hash + Merge Cond: (c.q2 = d.q1) + -> Sort Output: c.q1, c.q2 + Sort Key: c.q2 -> Foreign Scan on public.int8_tbl c Output: c.q1, c.q2 SQLite query: SELECT `q1`, `q2` FROM main."int8_tbl" + -> Materialize + Output: a.q1, a.q2, b.q1, d.q1, (COALESCE(b.q2, '42'::bigint)), (COALESCE((COALESCE(b.q2, '42'::bigint)), d.q2)) + -> Sort + Output: a.q1, a.q2, b.q1, d.q1, (COALESCE(b.q2, '42'::bigint)), (COALESCE((COALESCE(b.q2, '42'::bigint)), d.q2)) + Sort Key: d.q1 + -> Nested Loop + Output: a.q1, a.q2, b.q1, d.q1, (COALESCE(b.q2, '42'::bigint)), (COALESCE((COALESCE(b.q2, '42'::bigint)), d.q2)) + -> Merge Left Join + Output: a.q1, a.q2, b.q1, (COALESCE(b.q2, '42'::bigint)) + Merge Cond: (a.q2 = b.q1) + -> Sort + Output: a.q1, a.q2 + Sort Key: a.q2 + -> Foreign Scan on public.int8_tbl a + Output: a.q1, a.q2 + SQLite query: SELECT `q1`, `q2` FROM main."int8_tbl" + -> Sort + Output: b.q1, (COALESCE(b.q2, '42'::bigint)) + Sort Key: b.q1 + -> Foreign Scan on public.int8_tbl b + Output: b.q1, COALESCE(b.q2, '42'::bigint) + SQLite query: SELECT `q1`, `q2` FROM main."int8_tbl" + -> Foreign Scan on public.int8_tbl d + Output: d.q1, COALESCE((COALESCE(b.q2, '42'::bigint)), d.q2) + SQLite query: SELECT `q1`, `q2` FROM main."int8_tbl" -> Result Output: (COALESCE((COALESCE(b.q2, '42'::bigint)), d.q2)) -(32 rows) +(38 rows) -- case that breaks the old ph_may_need optimization --Testcase 462: @@ -6207,6 +6450,10 @@ select * from 3 | 3 (6 rows) +-- check the number of columns specified +--Testcase 539: +SELECT * FROM (int8_tbl i cross join int4_tbl j) ss(a,b,c,d); +ERROR: join expression "ss" has 3 columns available but 4 columns specified -- check we don't try to do a unique-ified semijoin with LATERAL --Testcase 314: explain (verbose, costs off) @@ -6426,6 +6673,62 @@ HINT: There is an entry for table "xx1", but it cannot be referenced from this --drop table join_pt1; --drop table join_ut1; -- +-- test estimation behavior with multi-column foreign key and constant qual +-- +begin; +--Testcase 524: +create table fkest (x integer, x10 integer, x10b integer, x100 integer); +--Testcase 525: +insert into fkest select x, x/10, x/10, x/100 from generate_series(1,1000) x; +--Testcase 526: +create unique index on fkest(x, x10, x100); +analyze fkest; +--Testcase 527: +explain (costs off) +select * from fkest f1 + join fkest f2 on (f1.x = f2.x and f1.x10 = f2.x10b and f1.x100 = f2.x100) + join fkest f3 on f1.x = f3.x + where f1.x100 = 2; + QUERY PLAN +----------------------------------------------------------- + Nested Loop + -> Hash Join + Hash Cond: ((f2.x = f1.x) AND (f2.x10b = f1.x10)) + -> Seq Scan on fkest f2 + Filter: (x100 = 2) + -> Hash + -> Seq Scan on fkest f1 + Filter: (x100 = 2) + -> Index Scan using fkest_x_x10_x100_idx on fkest f3 + Index Cond: (x = f1.x) +(10 rows) + +--Testcase 528: +alter table fkest add constraint fk + foreign key (x, x10b, x100) references fkest (x, x10, x100); +--Testcase 529: +explain (costs off) +select * from fkest f1 + join fkest f2 on (f1.x = f2.x and f1.x10 = f2.x10b and f1.x100 = f2.x100) + join fkest f3 on f1.x = f3.x + where f1.x100 = 2; + QUERY PLAN +----------------------------------------------------- + Hash Join + Hash Cond: ((f2.x = f1.x) AND (f2.x10b = f1.x10)) + -> Hash Join + Hash Cond: (f3.x = f2.x) + -> Seq Scan on fkest f3 + -> Hash + -> Seq Scan on fkest f2 + Filter: (x100 = 2) + -> Hash + -> Seq Scan on fkest f1 + Filter: (x100 = 2) +(11 rows) + +rollback; +-- -- test that foreign key join estimation performs sanely for outer joins -- begin; @@ -6777,8 +7080,11 @@ left join j22 on j12.id1 = j22.id1 where j12.id2 = 1; -- validate logic in merge joins which skips mark and restore. -- it should only do this if all quals which were used to detect the unique -- are present as join quals, and not plain quals. +--Testcase 530: set enable_nestloop to 0; +--Testcase 531: set enable_hashjoin to 0; +--Testcase 532: set enable_sort to 0; -- skip, cannot create index on foreign table -- create indexes that will be preferred over the PKs to perform the join @@ -6847,8 +7153,11 @@ where j12.id1 % 1000 = 1 and j22.id1 % 1000 = 1 and j22.id1 >= any (array[1,5]); 1 | 2 | 1 | 2 (2 rows) +--Testcase 533: reset enable_nestloop; +--Testcase 534: reset enable_hashjoin; +--Testcase 535: reset enable_sort; --drop table j1; --drop table j2; diff --git a/expected/12.8/extra/limit.out b/expected/15beta2/extra/limit.out similarity index 88% rename from expected/12.8/extra/limit.out rename to expected/15beta2/extra/limit.out index a5f0141f..e3d82c38 100644 --- a/expected/12.8/extra/limit.out +++ b/expected/15beta2/extra/limit.out @@ -399,33 +399,65 @@ fetch all in c4; (0 rows) declare c5 scroll cursor for select * from int8_tbl order by q1 fetch first 2 rows with ties; -ERROR: syntax error at or near "with" -LINE 1: ...ct * from int8_tbl order by q1 fetch first 2 rows with ties; - ^ --Testcase 54: fetch all in c5; -ERROR: current transaction is aborted, commands ignored until end of transaction block + q1 | q2 +-----+------------------ + 123 | 456 + 123 | 4567890123456789 +(2 rows) + --Testcase 55: fetch 1 in c5; -ERROR: current transaction is aborted, commands ignored until end of transaction block + q1 | q2 +----+---- +(0 rows) + --Testcase 56: fetch backward 1 in c5; -ERROR: current transaction is aborted, commands ignored until end of transaction block + q1 | q2 +-----+------------------ + 123 | 4567890123456789 +(1 row) + --Testcase 57: fetch backward 1 in c5; -ERROR: current transaction is aborted, commands ignored until end of transaction block + q1 | q2 +-----+----- + 123 | 456 +(1 row) + --Testcase 58: fetch all in c5; -ERROR: current transaction is aborted, commands ignored until end of transaction block + q1 | q2 +-----+------------------ + 123 | 4567890123456789 +(1 row) + --Testcase 59: fetch backward all in c5; -ERROR: current transaction is aborted, commands ignored until end of transaction block + q1 | q2 +-----+------------------ + 123 | 4567890123456789 + 123 | 456 +(2 rows) + --Testcase 60: fetch all in c5; -ERROR: current transaction is aborted, commands ignored until end of transaction block + q1 | q2 +-----+------------------ + 123 | 456 + 123 | 4567890123456789 +(2 rows) + --Testcase 61: fetch backward all in c5; -ERROR: current transaction is aborted, commands ignored until end of transaction block + q1 | q2 +-----+------------------ + 123 | 4567890123456789 + 123 | 456 +(2 rows) + rollback; -- Stress test for variable LIMIT in conjunction with bounded-heap sorting --Testcase 62: @@ -662,12 +694,12 @@ select unique1, unique2, nextval('testseq') -> Merge Append Sort Key: parent_table.tenthous -> Sort - Output: parent_table.unique1, parent_table.unique2, parent_table.tenthous - Sort Key: parent_table.tenthous - -> Seq Scan on public.parent_table - Output: parent_table.unique1, parent_table.unique2, parent_table.tenthous - -> Foreign Scan on public.inherited_table - Output: inherited_table.unique1, inherited_table.unique2, inherited_table.tenthous + Output: parent_table_1.unique1, parent_table_1.unique2, parent_table_1.tenthous + Sort Key: parent_table_1.tenthous + -> Seq Scan on public.parent_table parent_table_1 + Output: parent_table_1.unique1, parent_table_1.unique2, parent_table_1.tenthous + -> Foreign Scan on public.inherited_table parent_table_2 + Output: parent_table_2.unique1, parent_table_2.unique2, parent_table_2.tenthous SQLite query: SELECT `unique1`, `unique2`, `tenthous` FROM main."tenk1" ORDER BY `tenthous` ASC NULLS LAST LIMIT 10 (14 rows) @@ -702,12 +734,12 @@ select unique1, unique2, nextval('testseq') -> Merge Append Sort Key: parent_table.tenthous -> Sort - Output: parent_table.unique1, parent_table.unique2, parent_table.tenthous - Sort Key: parent_table.tenthous - -> Seq Scan on public.parent_table - Output: parent_table.unique1, parent_table.unique2, parent_table.tenthous - -> Foreign Scan on public.inherited_table - Output: inherited_table.unique1, inherited_table.unique2, inherited_table.tenthous + Output: parent_table_1.unique1, parent_table_1.unique2, parent_table_1.tenthous + Sort Key: parent_table_1.tenthous + -> Seq Scan on public.parent_table parent_table_1 + Output: parent_table_1.unique1, parent_table_1.unique2, parent_table_1.tenthous + -> Foreign Scan on public.inherited_table parent_table_2 + Output: parent_table_2.unique1, parent_table_2.unique2, parent_table_2.tenthous SQLite query: SELECT `unique1`, `unique2`, `tenthous` FROM main."tenk1" ORDER BY `tenthous` ASC NULLS LAST (14 rows) @@ -868,23 +900,56 @@ select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 SELECT thousand FROM onek WHERE thousand < 5 ORDER BY thousand FETCH FIRST 2 ROW WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 3: ORDER BY thousand FETCH FIRST 2 ROW WITH TIES; - ^ + thousand +---------- + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 +(10 rows) + --Testcase 73: SELECT thousand FROM onek WHERE thousand < 5 ORDER BY thousand FETCH FIRST ROWS WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 3: ORDER BY thousand FETCH FIRST ROWS WITH TIES; - ^ + thousand +---------- + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 +(10 rows) + --Testcase 74: SELECT thousand FROM onek WHERE thousand < 5 ORDER BY thousand FETCH FIRST 1 ROW WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 3: ORDER BY thousand FETCH FIRST 1 ROW WITH TIES; - ^ + thousand +---------- + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 +(10 rows) + --Testcase 75: SELECT thousand FROM onek WHERE thousand < 5 @@ -895,23 +960,36 @@ SELECT thousand 0 (2 rows) +-- SKIP LOCKED and WITH TIES are incompatible +--Testcase 104: +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST 1 ROW WITH TIES FOR UPDATE SKIP LOCKED; +ERROR: SKIP LOCKED and WITH TIES options cannot be used together -- should fail --Testcase 76: SELECT ''::text AS two, unique1, unique2, stringu1 FROM onek WHERE unique1 > 50 FETCH FIRST 2 ROW WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 3: FETCH FIRST 2 ROW WITH TIES; - ^ +ERROR: WITH TIES cannot be specified without ORDER BY clause -- test ruleutils --Testcase 77: CREATE VIEW limit_thousand_v_1 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousand FETCH FIRST 5 ROWS WITH TIES OFFSET 10; -ERROR: syntax error at or near "WITH" -LINE 2: ORDER BY thousand FETCH FIRST 5 ROWS WITH TIES OFFSET 10; - ^ --Testcase 78: \d+ limit_thousand_v_1 + View "public.limit_thousand_v_1" + Column | Type | Collation | Nullable | Default | Storage | Description +----------+---------+-----------+----------+---------+---------+------------- + thousand | integer | | | | plain | +View definition: + SELECT onek.thousand + FROM onek + WHERE onek.thousand < 995 + ORDER BY onek.thousand + OFFSET 10 + FETCH FIRST 5 ROWS WITH TIES; + --Testcase 79: CREATE VIEW limit_thousand_v_2 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousand OFFSET 10 FETCH FIRST 5 ROWS ONLY; @@ -932,17 +1010,23 @@ View definition: --Testcase 81: CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousand FETCH FIRST NULL ROWS WITH TIES; -- fails -ERROR: syntax error at or near "WITH" -LINE 2: ORDER BY thousand FETCH FIRST NULL ROWS WITH TIES; - ^ +ERROR: row count cannot be null in FETCH FIRST ... WITH TIES clause --Testcase 82: CREATE VIEW limit_thousand_v_3 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousand FETCH FIRST (NULL+1) ROWS WITH TIES; -ERROR: syntax error at or near "WITH" -LINE 2: ORDER BY thousand FETCH FIRST (NULL+1) ROWS WITH TIES; - ^ --Testcase 83: \d+ limit_thousand_v_3 + View "public.limit_thousand_v_3" + Column | Type | Collation | Nullable | Default | Storage | Description +----------+---------+-----------+----------+---------+---------+------------- + thousand | integer | | | | plain | +View definition: + SELECT onek.thousand + FROM onek + WHERE onek.thousand < 995 + ORDER BY onek.thousand + FETCH FIRST (NULL::integer + 1) ROWS WITH TIES; + --Testcase 84: CREATE VIEW limit_thousand_v_4 AS SELECT thousand FROM onek WHERE thousand < 995 ORDER BY thousand FETCH FIRST NULL ROWS ONLY; @@ -971,8 +1055,10 @@ begin end loop; end; $d$; -NOTICE: drop cascades to 2 other objects -DETAIL: drop cascades to view limit_thousand_v_2 +NOTICE: drop cascades to 4 other objects +DETAIL: drop cascades to view limit_thousand_v_1 +drop cascades to view limit_thousand_v_2 +drop cascades to view limit_thousand_v_3 drop cascades to view limit_thousand_v_4 --Testcase 86: DROP SERVER sqlite_svr; diff --git a/expected/15beta2/extra/numeric.out b/expected/15beta2/extra/numeric.out new file mode 100644 index 00000000..a1b33d87 --- /dev/null +++ b/expected/15beta2/extra/numeric.out @@ -0,0 +1,5543 @@ +-- +-- NUMERIC +-- +--Testcase 567: +CREATE EXTENSION sqlite_fdw; +--Testcase 568: +CREATE SERVER sqlite_svr FOREIGN DATA WRAPPER sqlite_fdw +OPTIONS (database '/tmp/sqlitefdw_test_core.db'); +--Testcase 569: +CREATE FOREIGN TABLE num_data (id int4 OPTIONS (key 'true'), val numeric(210,10)) SERVER sqlite_svr; +--Testcase 570: +CREATE FOREIGN TABLE num_exp_add (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; +--Testcase 571: +CREATE FOREIGN TABLE num_exp_sub (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; +--Testcase 572: +CREATE FOREIGN TABLE num_exp_div (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; +--Testcase 573: +CREATE FOREIGN TABLE num_exp_mul (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; +--Testcase 574: +CREATE FOREIGN TABLE num_exp_sqrt (id int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; +--Testcase 575: +CREATE FOREIGN TABLE num_exp_ln (id int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; +--Testcase 576: +CREATE FOREIGN TABLE num_exp_log10 (id int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; +--Testcase 577: +CREATE FOREIGN TABLE num_exp_power_10_ln (id int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; +--Testcase 1556: +CREATE FOREIGN TABLE num_variance (a numeric) SERVER sqlite_svr; +--Testcase 578: +CREATE FOREIGN TABLE num_result (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), result numeric(210,10)) SERVER sqlite_svr; +-- ****************************** +-- * The following EXPECTED results are computed by bc(1) +-- * with a scale of 200 +-- ****************************** +BEGIN TRANSACTION; +--Testcase 1: +INSERT INTO num_exp_add VALUES (0,0,'0'); +--Testcase 2: +INSERT INTO num_exp_sub VALUES (0,0,'0'); +--Testcase 3: +INSERT INTO num_exp_mul VALUES (0,0,'0'); +--Testcase 4: +INSERT INTO num_exp_div VALUES (0,0,'NaN'); +--Testcase 5: +INSERT INTO num_exp_add VALUES (0,1,'0'); +--Testcase 6: +INSERT INTO num_exp_sub VALUES (0,1,'0'); +--Testcase 7: +INSERT INTO num_exp_mul VALUES (0,1,'0'); +--Testcase 8: +INSERT INTO num_exp_div VALUES (0,1,'NaN'); +--Testcase 9: +INSERT INTO num_exp_add VALUES (0,2,'-34338492.215397047'); +--Testcase 10: +INSERT INTO num_exp_sub VALUES (0,2,'34338492.215397047'); +--Testcase 11: +INSERT INTO num_exp_mul VALUES (0,2,'0'); +--Testcase 12: +INSERT INTO num_exp_div VALUES (0,2,'0'); +--Testcase 13: +INSERT INTO num_exp_add VALUES (0,3,'4.31'); +--Testcase 14: +INSERT INTO num_exp_sub VALUES (0,3,'-4.31'); +--Testcase 15: +INSERT INTO num_exp_mul VALUES (0,3,'0'); +--Testcase 16: +INSERT INTO num_exp_div VALUES (0,3,'0'); +--Testcase 17: +INSERT INTO num_exp_add VALUES (0,4,'7799461.4119'); +--Testcase 18: +INSERT INTO num_exp_sub VALUES (0,4,'-7799461.4119'); +--Testcase 19: +INSERT INTO num_exp_mul VALUES (0,4,'0'); +--Testcase 20: +INSERT INTO num_exp_div VALUES (0,4,'0'); +--Testcase 21: +INSERT INTO num_exp_add VALUES (0,5,'16397.038491'); +--Testcase 22: +INSERT INTO num_exp_sub VALUES (0,5,'-16397.038491'); +--Testcase 23: +INSERT INTO num_exp_mul VALUES (0,5,'0'); +--Testcase 24: +INSERT INTO num_exp_div VALUES (0,5,'0'); +--Testcase 25: +INSERT INTO num_exp_add VALUES (0,6,'93901.57763026'); +--Testcase 26: +INSERT INTO num_exp_sub VALUES (0,6,'-93901.57763026'); +--Testcase 27: +INSERT INTO num_exp_mul VALUES (0,6,'0'); +--Testcase 28: +INSERT INTO num_exp_div VALUES (0,6,'0'); +--Testcase 29: +INSERT INTO num_exp_add VALUES (0,7,'-83028485'); +--Testcase 30: +INSERT INTO num_exp_sub VALUES (0,7,'83028485'); +--Testcase 31: +INSERT INTO num_exp_mul VALUES (0,7,'0'); +--Testcase 32: +INSERT INTO num_exp_div VALUES (0,7,'0'); +--Testcase 33: +INSERT INTO num_exp_add VALUES (0,8,'74881'); +--Testcase 34: +INSERT INTO num_exp_sub VALUES (0,8,'-74881'); +--Testcase 35: +INSERT INTO num_exp_mul VALUES (0,8,'0'); +--Testcase 36: +INSERT INTO num_exp_div VALUES (0,8,'0'); +--Testcase 37: +INSERT INTO num_exp_add VALUES (0,9,'-24926804.045047420'); +--Testcase 38: +INSERT INTO num_exp_sub VALUES (0,9,'24926804.045047420'); +--Testcase 39: +INSERT INTO num_exp_mul VALUES (0,9,'0'); +--Testcase 40: +INSERT INTO num_exp_div VALUES (0,9,'0'); +--Testcase 41: +INSERT INTO num_exp_add VALUES (1,0,'0'); +--Testcase 42: +INSERT INTO num_exp_sub VALUES (1,0,'0'); +--Testcase 43: +INSERT INTO num_exp_mul VALUES (1,0,'0'); +--Testcase 44: +INSERT INTO num_exp_div VALUES (1,0,'NaN'); +--Testcase 45: +INSERT INTO num_exp_add VALUES (1,1,'0'); +--Testcase 46: +INSERT INTO num_exp_sub VALUES (1,1,'0'); +--Testcase 47: +INSERT INTO num_exp_mul VALUES (1,1,'0'); +--Testcase 48: +INSERT INTO num_exp_div VALUES (1,1,'NaN'); +--Testcase 49: +INSERT INTO num_exp_add VALUES (1,2,'-34338492.215397047'); +--Testcase 50: +INSERT INTO num_exp_sub VALUES (1,2,'34338492.215397047'); +--Testcase 51: +INSERT INTO num_exp_mul VALUES (1,2,'0'); +--Testcase 52: +INSERT INTO num_exp_div VALUES (1,2,'0'); +--Testcase 53: +INSERT INTO num_exp_add VALUES (1,3,'4.31'); +--Testcase 54: +INSERT INTO num_exp_sub VALUES (1,3,'-4.31'); +--Testcase 55: +INSERT INTO num_exp_mul VALUES (1,3,'0'); +--Testcase 56: +INSERT INTO num_exp_div VALUES (1,3,'0'); +--Testcase 57: +INSERT INTO num_exp_add VALUES (1,4,'7799461.4119'); +--Testcase 58: +INSERT INTO num_exp_sub VALUES (1,4,'-7799461.4119'); +--Testcase 59: +INSERT INTO num_exp_mul VALUES (1,4,'0'); +--Testcase 60: +INSERT INTO num_exp_div VALUES (1,4,'0'); +--Testcase 61: +INSERT INTO num_exp_add VALUES (1,5,'16397.038491'); +--Testcase 62: +INSERT INTO num_exp_sub VALUES (1,5,'-16397.038491'); +--Testcase 63: +INSERT INTO num_exp_mul VALUES (1,5,'0'); +--Testcase 64: +INSERT INTO num_exp_div VALUES (1,5,'0'); +--Testcase 65: +INSERT INTO num_exp_add VALUES (1,6,'93901.57763026'); +--Testcase 66: +INSERT INTO num_exp_sub VALUES (1,6,'-93901.57763026'); +--Testcase 67: +INSERT INTO num_exp_mul VALUES (1,6,'0'); +--Testcase 68: +INSERT INTO num_exp_div VALUES (1,6,'0'); +--Testcase 69: +INSERT INTO num_exp_add VALUES (1,7,'-83028485'); +--Testcase 70: +INSERT INTO num_exp_sub VALUES (1,7,'83028485'); +--Testcase 71: +INSERT INTO num_exp_mul VALUES (1,7,'0'); +--Testcase 72: +INSERT INTO num_exp_div VALUES (1,7,'0'); +--Testcase 73: +INSERT INTO num_exp_add VALUES (1,8,'74881'); +--Testcase 74: +INSERT INTO num_exp_sub VALUES (1,8,'-74881'); +--Testcase 75: +INSERT INTO num_exp_mul VALUES (1,8,'0'); +--Testcase 76: +INSERT INTO num_exp_div VALUES (1,8,'0'); +--Testcase 77: +INSERT INTO num_exp_add VALUES (1,9,'-24926804.045047420'); +--Testcase 78: +INSERT INTO num_exp_sub VALUES (1,9,'24926804.045047420'); +--Testcase 79: +INSERT INTO num_exp_mul VALUES (1,9,'0'); +--Testcase 80: +INSERT INTO num_exp_div VALUES (1,9,'0'); +--Testcase 81: +INSERT INTO num_exp_add VALUES (2,0,'-34338492.215397047'); +--Testcase 82: +INSERT INTO num_exp_sub VALUES (2,0,'-34338492.215397047'); +--Testcase 83: +INSERT INTO num_exp_mul VALUES (2,0,'0'); +--Testcase 84: +INSERT INTO num_exp_div VALUES (2,0,'NaN'); +--Testcase 85: +INSERT INTO num_exp_add VALUES (2,1,'-34338492.215397047'); +--Testcase 86: +INSERT INTO num_exp_sub VALUES (2,1,'-34338492.215397047'); +--Testcase 87: +INSERT INTO num_exp_mul VALUES (2,1,'0'); +--Testcase 88: +INSERT INTO num_exp_div VALUES (2,1,'NaN'); +--Testcase 89: +INSERT INTO num_exp_add VALUES (2,2,'-68676984.430794094'); +--Testcase 90: +INSERT INTO num_exp_sub VALUES (2,2,'0'); +--Testcase 91: +INSERT INTO num_exp_mul VALUES (2,2,'1179132047626883.596862135856320209'); +--Testcase 92: +INSERT INTO num_exp_div VALUES (2,2,'1.00000000000000000000'); +--Testcase 93: +INSERT INTO num_exp_add VALUES (2,3,'-34338487.905397047'); +--Testcase 94: +INSERT INTO num_exp_sub VALUES (2,3,'-34338496.525397047'); +--Testcase 95: +INSERT INTO num_exp_mul VALUES (2,3,'-147998901.44836127257'); +--Testcase 96: +INSERT INTO num_exp_div VALUES (2,3,'-7967167.56737750510440835266'); +--Testcase 97: +INSERT INTO num_exp_add VALUES (2,4,'-26539030.803497047'); +--Testcase 98: +INSERT INTO num_exp_sub VALUES (2,4,'-42137953.627297047'); +--Testcase 99: +INSERT INTO num_exp_mul VALUES (2,4,'-267821744976817.8111137106593'); +--Testcase 100: +INSERT INTO num_exp_div VALUES (2,4,'-4.40267480046830116685'); +--Testcase 101: +INSERT INTO num_exp_add VALUES (2,5,'-34322095.176906047'); +--Testcase 102: +INSERT INTO num_exp_sub VALUES (2,5,'-34354889.253888047'); +--Testcase 103: +INSERT INTO num_exp_mul VALUES (2,5,'-563049578578.769242506736077'); +--Testcase 104: +INSERT INTO num_exp_div VALUES (2,5,'-2094.18866914563535496429'); +--Testcase 105: +INSERT INTO num_exp_add VALUES (2,6,'-34244590.637766787'); +--Testcase 106: +INSERT INTO num_exp_sub VALUES (2,6,'-34432393.793027307'); +--Testcase 107: +INSERT INTO num_exp_mul VALUES (2,6,'-3224438592470.18449811926184222'); +--Testcase 108: +INSERT INTO num_exp_div VALUES (2,6,'-365.68599891479766440940'); +--Testcase 109: +INSERT INTO num_exp_add VALUES (2,7,'-117366977.215397047'); +--Testcase 110: +INSERT INTO num_exp_sub VALUES (2,7,'48689992.784602953'); +--Testcase 111: +INSERT INTO num_exp_mul VALUES (2,7,'2851072985828710.485883795'); +--Testcase 112: +INSERT INTO num_exp_div VALUES (2,7,'.41357483778485235518'); +--Testcase 113: +INSERT INTO num_exp_add VALUES (2,8,'-34263611.215397047'); +--Testcase 114: +INSERT INTO num_exp_sub VALUES (2,8,'-34413373.215397047'); +--Testcase 115: +INSERT INTO num_exp_mul VALUES (2,8,'-2571300635581.146276407'); +--Testcase 116: +INSERT INTO num_exp_div VALUES (2,8,'-458.57416721727870888476'); +--Testcase 117: +INSERT INTO num_exp_add VALUES (2,9,'-59265296.260444467'); +--Testcase 118: +INSERT INTO num_exp_sub VALUES (2,9,'-9411688.170349627'); +--Testcase 119: +INSERT INTO num_exp_mul VALUES (2,9,'855948866655588.453741509242968740'); +--Testcase 120: +INSERT INTO num_exp_div VALUES (2,9,'1.37757299946438931811'); +--Testcase 121: +INSERT INTO num_exp_add VALUES (3,0,'4.31'); +--Testcase 122: +INSERT INTO num_exp_sub VALUES (3,0,'4.31'); +--Testcase 123: +INSERT INTO num_exp_mul VALUES (3,0,'0'); +--Testcase 124: +INSERT INTO num_exp_div VALUES (3,0,'NaN'); +--Testcase 125: +INSERT INTO num_exp_add VALUES (3,1,'4.31'); +--Testcase 126: +INSERT INTO num_exp_sub VALUES (3,1,'4.31'); +--Testcase 127: +INSERT INTO num_exp_mul VALUES (3,1,'0'); +--Testcase 128: +INSERT INTO num_exp_div VALUES (3,1,'NaN'); +--Testcase 129: +INSERT INTO num_exp_add VALUES (3,2,'-34338487.905397047'); +--Testcase 130: +INSERT INTO num_exp_sub VALUES (3,2,'34338496.525397047'); +--Testcase 131: +INSERT INTO num_exp_mul VALUES (3,2,'-147998901.44836127257'); +--Testcase 132: +INSERT INTO num_exp_div VALUES (3,2,'-.00000012551512084352'); +--Testcase 133: +INSERT INTO num_exp_add VALUES (3,3,'8.62'); +--Testcase 134: +INSERT INTO num_exp_sub VALUES (3,3,'0'); +--Testcase 135: +INSERT INTO num_exp_mul VALUES (3,3,'18.5761'); +--Testcase 136: +INSERT INTO num_exp_div VALUES (3,3,'1.00000000000000000000'); +--Testcase 137: +INSERT INTO num_exp_add VALUES (3,4,'7799465.7219'); +--Testcase 138: +INSERT INTO num_exp_sub VALUES (3,4,'-7799457.1019'); +--Testcase 139: +INSERT INTO num_exp_mul VALUES (3,4,'33615678.685289'); +--Testcase 140: +INSERT INTO num_exp_div VALUES (3,4,'.00000055260225961552'); +--Testcase 141: +INSERT INTO num_exp_add VALUES (3,5,'16401.348491'); +--Testcase 142: +INSERT INTO num_exp_sub VALUES (3,5,'-16392.728491'); +--Testcase 143: +INSERT INTO num_exp_mul VALUES (3,5,'70671.23589621'); +--Testcase 144: +INSERT INTO num_exp_div VALUES (3,5,'.00026285234387695504'); +--Testcase 145: +INSERT INTO num_exp_add VALUES (3,6,'93905.88763026'); +--Testcase 146: +INSERT INTO num_exp_sub VALUES (3,6,'-93897.26763026'); +--Testcase 147: +INSERT INTO num_exp_mul VALUES (3,6,'404715.7995864206'); +--Testcase 148: +INSERT INTO num_exp_div VALUES (3,6,'.00004589912234457595'); +--Testcase 149: +INSERT INTO num_exp_add VALUES (3,7,'-83028480.69'); +--Testcase 150: +INSERT INTO num_exp_sub VALUES (3,7,'83028489.31'); +--Testcase 151: +INSERT INTO num_exp_mul VALUES (3,7,'-357852770.35'); +--Testcase 152: +INSERT INTO num_exp_div VALUES (3,7,'-.00000005190989574240'); +--Testcase 153: +INSERT INTO num_exp_add VALUES (3,8,'74885.31'); +--Testcase 154: +INSERT INTO num_exp_sub VALUES (3,8,'-74876.69'); +--Testcase 155: +INSERT INTO num_exp_mul VALUES (3,8,'322737.11'); +--Testcase 156: +INSERT INTO num_exp_div VALUES (3,8,'.00005755799201399553'); +--Testcase 157: +INSERT INTO num_exp_add VALUES (3,9,'-24926799.735047420'); +--Testcase 158: +INSERT INTO num_exp_sub VALUES (3,9,'24926808.355047420'); +--Testcase 159: +INSERT INTO num_exp_mul VALUES (3,9,'-107434525.43415438020'); +--Testcase 160: +INSERT INTO num_exp_div VALUES (3,9,'-.00000017290624149854'); +--Testcase 161: +INSERT INTO num_exp_add VALUES (4,0,'7799461.4119'); +--Testcase 162: +INSERT INTO num_exp_sub VALUES (4,0,'7799461.4119'); +--Testcase 163: +INSERT INTO num_exp_mul VALUES (4,0,'0'); +--Testcase 164: +INSERT INTO num_exp_div VALUES (4,0,'NaN'); +--Testcase 165: +INSERT INTO num_exp_add VALUES (4,1,'7799461.4119'); +--Testcase 166: +INSERT INTO num_exp_sub VALUES (4,1,'7799461.4119'); +--Testcase 167: +INSERT INTO num_exp_mul VALUES (4,1,'0'); +--Testcase 168: +INSERT INTO num_exp_div VALUES (4,1,'NaN'); +--Testcase 169: +INSERT INTO num_exp_add VALUES (4,2,'-26539030.803497047'); +--Testcase 170: +INSERT INTO num_exp_sub VALUES (4,2,'42137953.627297047'); +--Testcase 171: +INSERT INTO num_exp_mul VALUES (4,2,'-267821744976817.8111137106593'); +--Testcase 172: +INSERT INTO num_exp_div VALUES (4,2,'-.22713465002993920385'); +--Testcase 173: +INSERT INTO num_exp_add VALUES (4,3,'7799465.7219'); +--Testcase 174: +INSERT INTO num_exp_sub VALUES (4,3,'7799457.1019'); +--Testcase 175: +INSERT INTO num_exp_mul VALUES (4,3,'33615678.685289'); +--Testcase 176: +INSERT INTO num_exp_div VALUES (4,3,'1809619.81714617169373549883'); +--Testcase 177: +INSERT INTO num_exp_add VALUES (4,4,'15598922.8238'); +--Testcase 178: +INSERT INTO num_exp_sub VALUES (4,4,'0'); +--Testcase 179: +INSERT INTO num_exp_mul VALUES (4,4,'60831598315717.14146161'); +--Testcase 180: +INSERT INTO num_exp_div VALUES (4,4,'1.00000000000000000000'); +--Testcase 181: +INSERT INTO num_exp_add VALUES (4,5,'7815858.450391'); +--Testcase 182: +INSERT INTO num_exp_sub VALUES (4,5,'7783064.373409'); +--Testcase 183: +INSERT INTO num_exp_mul VALUES (4,5,'127888068979.9935054429'); +--Testcase 184: +INSERT INTO num_exp_div VALUES (4,5,'475.66281046305802686061'); +--Testcase 185: +INSERT INTO num_exp_add VALUES (4,6,'7893362.98953026'); +--Testcase 186: +INSERT INTO num_exp_sub VALUES (4,6,'7705559.83426974'); +--Testcase 187: +INSERT INTO num_exp_mul VALUES (4,6,'732381731243.745115764094'); +--Testcase 188: +INSERT INTO num_exp_div VALUES (4,6,'83.05996138436129499606'); +--Testcase 189: +INSERT INTO num_exp_add VALUES (4,7,'-75229023.5881'); +--Testcase 190: +INSERT INTO num_exp_sub VALUES (4,7,'90827946.4119'); +--Testcase 191: +INSERT INTO num_exp_mul VALUES (4,7,'-647577464846017.9715'); +--Testcase 192: +INSERT INTO num_exp_div VALUES (4,7,'-.09393717604145131637'); +--Testcase 193: +INSERT INTO num_exp_add VALUES (4,8,'7874342.4119'); +--Testcase 194: +INSERT INTO num_exp_sub VALUES (4,8,'7724580.4119'); +--Testcase 195: +INSERT INTO num_exp_mul VALUES (4,8,'584031469984.4839'); +--Testcase 196: +INSERT INTO num_exp_div VALUES (4,8,'104.15808298366741897143'); +--Testcase 197: +INSERT INTO num_exp_add VALUES (4,9,'-17127342.633147420'); +--Testcase 198: +INSERT INTO num_exp_sub VALUES (4,9,'32726265.456947420'); +--Testcase 199: +INSERT INTO num_exp_mul VALUES (4,9,'-194415646271340.1815956522980'); +--Testcase 200: +INSERT INTO num_exp_div VALUES (4,9,'-.31289456112403769409'); +--Testcase 201: +INSERT INTO num_exp_add VALUES (5,0,'16397.038491'); +--Testcase 202: +INSERT INTO num_exp_sub VALUES (5,0,'16397.038491'); +--Testcase 203: +INSERT INTO num_exp_mul VALUES (5,0,'0'); +--Testcase 204: +INSERT INTO num_exp_div VALUES (5,0,'NaN'); +--Testcase 205: +INSERT INTO num_exp_add VALUES (5,1,'16397.038491'); +--Testcase 206: +INSERT INTO num_exp_sub VALUES (5,1,'16397.038491'); +--Testcase 207: +INSERT INTO num_exp_mul VALUES (5,1,'0'); +--Testcase 208: +INSERT INTO num_exp_div VALUES (5,1,'NaN'); +--Testcase 209: +INSERT INTO num_exp_add VALUES (5,2,'-34322095.176906047'); +--Testcase 210: +INSERT INTO num_exp_sub VALUES (5,2,'34354889.253888047'); +--Testcase 211: +INSERT INTO num_exp_mul VALUES (5,2,'-563049578578.769242506736077'); +--Testcase 212: +INSERT INTO num_exp_div VALUES (5,2,'-.00047751189505192446'); +--Testcase 213: +INSERT INTO num_exp_add VALUES (5,3,'16401.348491'); +--Testcase 214: +INSERT INTO num_exp_sub VALUES (5,3,'16392.728491'); +--Testcase 215: +INSERT INTO num_exp_mul VALUES (5,3,'70671.23589621'); +--Testcase 216: +INSERT INTO num_exp_div VALUES (5,3,'3804.41728329466357308584'); +--Testcase 217: +INSERT INTO num_exp_add VALUES (5,4,'7815858.450391'); +--Testcase 218: +INSERT INTO num_exp_sub VALUES (5,4,'-7783064.373409'); +--Testcase 219: +INSERT INTO num_exp_mul VALUES (5,4,'127888068979.9935054429'); +--Testcase 220: +INSERT INTO num_exp_div VALUES (5,4,'.00210232958726897192'); +--Testcase 221: +INSERT INTO num_exp_add VALUES (5,5,'32794.076982'); +--Testcase 222: +INSERT INTO num_exp_sub VALUES (5,5,'0'); +--Testcase 223: +INSERT INTO num_exp_mul VALUES (5,5,'268862871.275335557081'); +--Testcase 224: +INSERT INTO num_exp_div VALUES (5,5,'1.00000000000000000000'); +--Testcase 225: +INSERT INTO num_exp_add VALUES (5,6,'110298.61612126'); +--Testcase 226: +INSERT INTO num_exp_sub VALUES (5,6,'-77504.53913926'); +--Testcase 227: +INSERT INTO num_exp_mul VALUES (5,6,'1539707782.76899778633766'); +--Testcase 228: +INSERT INTO num_exp_div VALUES (5,6,'.17461941433576102689'); +--Testcase 229: +INSERT INTO num_exp_add VALUES (5,7,'-83012087.961509'); +--Testcase 230: +INSERT INTO num_exp_sub VALUES (5,7,'83044882.038491'); +--Testcase 231: +INSERT INTO num_exp_mul VALUES (5,7,'-1361421264394.416135'); +--Testcase 232: +INSERT INTO num_exp_div VALUES (5,7,'-.00019748690453643710'); +--Testcase 233: +INSERT INTO num_exp_add VALUES (5,8,'91278.038491'); +--Testcase 234: +INSERT INTO num_exp_sub VALUES (5,8,'-58483.961509'); +--Testcase 235: +INSERT INTO num_exp_mul VALUES (5,8,'1227826639.244571'); +--Testcase 236: +INSERT INTO num_exp_div VALUES (5,8,'.21897461960978085228'); +--Testcase 237: +INSERT INTO num_exp_add VALUES (5,9,'-24910407.006556420'); +--Testcase 238: +INSERT INTO num_exp_sub VALUES (5,9,'24943201.083538420'); +--Testcase 239: +INSERT INTO num_exp_mul VALUES (5,9,'-408725765384.257043660243220'); +--Testcase 240: +INSERT INTO num_exp_div VALUES (5,9,'-.00065780749354660427'); +--Testcase 241: +INSERT INTO num_exp_add VALUES (6,0,'93901.57763026'); +--Testcase 242: +INSERT INTO num_exp_sub VALUES (6,0,'93901.57763026'); +--Testcase 243: +INSERT INTO num_exp_mul VALUES (6,0,'0'); +--Testcase 244: +INSERT INTO num_exp_div VALUES (6,0,'NaN'); +--Testcase 245: +INSERT INTO num_exp_add VALUES (6,1,'93901.57763026'); +--Testcase 246: +INSERT INTO num_exp_sub VALUES (6,1,'93901.57763026'); +--Testcase 247: +INSERT INTO num_exp_mul VALUES (6,1,'0'); +--Testcase 248: +INSERT INTO num_exp_div VALUES (6,1,'NaN'); +--Testcase 249: +INSERT INTO num_exp_add VALUES (6,2,'-34244590.637766787'); +--Testcase 250: +INSERT INTO num_exp_sub VALUES (6,2,'34432393.793027307'); +--Testcase 251: +INSERT INTO num_exp_mul VALUES (6,2,'-3224438592470.18449811926184222'); +--Testcase 252: +INSERT INTO num_exp_div VALUES (6,2,'-.00273458651128995823'); +--Testcase 253: +INSERT INTO num_exp_add VALUES (6,3,'93905.88763026'); +--Testcase 254: +INSERT INTO num_exp_sub VALUES (6,3,'93897.26763026'); +--Testcase 255: +INSERT INTO num_exp_mul VALUES (6,3,'404715.7995864206'); +--Testcase 256: +INSERT INTO num_exp_div VALUES (6,3,'21786.90896293735498839907'); +--Testcase 257: +INSERT INTO num_exp_add VALUES (6,4,'7893362.98953026'); +--Testcase 258: +INSERT INTO num_exp_sub VALUES (6,4,'-7705559.83426974'); +--Testcase 259: +INSERT INTO num_exp_mul VALUES (6,4,'732381731243.745115764094'); +--Testcase 260: +INSERT INTO num_exp_div VALUES (6,4,'.01203949512295682469'); +--Testcase 261: +INSERT INTO num_exp_add VALUES (6,5,'110298.61612126'); +--Testcase 262: +INSERT INTO num_exp_sub VALUES (6,5,'77504.53913926'); +--Testcase 263: +INSERT INTO num_exp_mul VALUES (6,5,'1539707782.76899778633766'); +--Testcase 264: +INSERT INTO num_exp_div VALUES (6,5,'5.72674008674192359679'); +--Testcase 265: +INSERT INTO num_exp_add VALUES (6,6,'187803.15526052'); +--Testcase 266: +INSERT INTO num_exp_sub VALUES (6,6,'0'); +--Testcase 267: +INSERT INTO num_exp_mul VALUES (6,6,'8817506281.4517452372676676'); +--Testcase 268: +INSERT INTO num_exp_div VALUES (6,6,'1.00000000000000000000'); +--Testcase 269: +INSERT INTO num_exp_add VALUES (6,7,'-82934583.42236974'); +--Testcase 270: +INSERT INTO num_exp_sub VALUES (6,7,'83122386.57763026'); +--Testcase 271: +INSERT INTO num_exp_mul VALUES (6,7,'-7796505729750.37795610'); +--Testcase 272: +INSERT INTO num_exp_div VALUES (6,7,'-.00113095617281538980'); +--Testcase 273: +INSERT INTO num_exp_add VALUES (6,8,'168782.57763026'); +--Testcase 274: +INSERT INTO num_exp_sub VALUES (6,8,'19020.57763026'); +--Testcase 275: +INSERT INTO num_exp_mul VALUES (6,8,'7031444034.53149906'); +--Testcase 276: +INSERT INTO num_exp_div VALUES (6,8,'1.25401073209839612184'); +--Testcase 277: +INSERT INTO num_exp_add VALUES (6,9,'-24832902.467417160'); +--Testcase 278: +INSERT INTO num_exp_sub VALUES (6,9,'25020705.622677680'); +--Testcase 279: +INSERT INTO num_exp_mul VALUES (6,9,'-2340666225110.29929521292692920'); +--Testcase 280: +INSERT INTO num_exp_div VALUES (6,9,'-.00376709254265256789'); +--Testcase 281: +INSERT INTO num_exp_add VALUES (7,0,'-83028485'); +--Testcase 282: +INSERT INTO num_exp_sub VALUES (7,0,'-83028485'); +--Testcase 283: +INSERT INTO num_exp_mul VALUES (7,0,'0'); +--Testcase 284: +INSERT INTO num_exp_div VALUES (7,0,'NaN'); +--Testcase 285: +INSERT INTO num_exp_add VALUES (7,1,'-83028485'); +--Testcase 286: +INSERT INTO num_exp_sub VALUES (7,1,'-83028485'); +--Testcase 287: +INSERT INTO num_exp_mul VALUES (7,1,'0'); +--Testcase 288: +INSERT INTO num_exp_div VALUES (7,1,'NaN'); +--Testcase 289: +INSERT INTO num_exp_add VALUES (7,2,'-117366977.215397047'); +--Testcase 290: +INSERT INTO num_exp_sub VALUES (7,2,'-48689992.784602953'); +--Testcase 291: +INSERT INTO num_exp_mul VALUES (7,2,'2851072985828710.485883795'); +--Testcase 292: +INSERT INTO num_exp_div VALUES (7,2,'2.41794207151503385700'); +--Testcase 293: +INSERT INTO num_exp_add VALUES (7,3,'-83028480.69'); +--Testcase 294: +INSERT INTO num_exp_sub VALUES (7,3,'-83028489.31'); +--Testcase 295: +INSERT INTO num_exp_mul VALUES (7,3,'-357852770.35'); +--Testcase 296: +INSERT INTO num_exp_div VALUES (7,3,'-19264149.65197215777262180974'); +--Testcase 297: +INSERT INTO num_exp_add VALUES (7,4,'-75229023.5881'); +--Testcase 298: +INSERT INTO num_exp_sub VALUES (7,4,'-90827946.4119'); +--Testcase 299: +INSERT INTO num_exp_mul VALUES (7,4,'-647577464846017.9715'); +--Testcase 300: +INSERT INTO num_exp_div VALUES (7,4,'-10.64541262725136247686'); +--Testcase 301: +INSERT INTO num_exp_add VALUES (7,5,'-83012087.961509'); +--Testcase 302: +INSERT INTO num_exp_sub VALUES (7,5,'-83044882.038491'); +--Testcase 303: +INSERT INTO num_exp_mul VALUES (7,5,'-1361421264394.416135'); +--Testcase 304: +INSERT INTO num_exp_div VALUES (7,5,'-5063.62688881730941836574'); +--Testcase 305: +INSERT INTO num_exp_add VALUES (7,6,'-82934583.42236974'); +--Testcase 306: +INSERT INTO num_exp_sub VALUES (7,6,'-83122386.57763026'); +--Testcase 307: +INSERT INTO num_exp_mul VALUES (7,6,'-7796505729750.37795610'); +--Testcase 308: +INSERT INTO num_exp_div VALUES (7,6,'-884.20756174009028770294'); +--Testcase 309: +INSERT INTO num_exp_add VALUES (7,7,'-166056970'); +--Testcase 310: +INSERT INTO num_exp_sub VALUES (7,7,'0'); +--Testcase 311: +INSERT INTO num_exp_mul VALUES (7,7,'6893729321395225'); +--Testcase 312: +INSERT INTO num_exp_div VALUES (7,7,'1.00000000000000000000'); +--Testcase 313: +INSERT INTO num_exp_add VALUES (7,8,'-82953604'); +--Testcase 314: +INSERT INTO num_exp_sub VALUES (7,8,'-83103366'); +--Testcase 315: +INSERT INTO num_exp_mul VALUES (7,8,'-6217255985285'); +--Testcase 316: +INSERT INTO num_exp_div VALUES (7,8,'-1108.80577182462841041118'); +--Testcase 317: +INSERT INTO num_exp_add VALUES (7,9,'-107955289.045047420'); +--Testcase 318: +INSERT INTO num_exp_sub VALUES (7,9,'-58101680.954952580'); +--Testcase 319: +INSERT INTO num_exp_mul VALUES (7,9,'2069634775752159.035758700'); +--Testcase 320: +INSERT INTO num_exp_div VALUES (7,9,'3.33089171198810413382'); +--Testcase 321: +INSERT INTO num_exp_add VALUES (8,0,'74881'); +--Testcase 322: +INSERT INTO num_exp_sub VALUES (8,0,'74881'); +--Testcase 323: +INSERT INTO num_exp_mul VALUES (8,0,'0'); +--Testcase 324: +INSERT INTO num_exp_div VALUES (8,0,'NaN'); +--Testcase 325: +INSERT INTO num_exp_add VALUES (8,1,'74881'); +--Testcase 326: +INSERT INTO num_exp_sub VALUES (8,1,'74881'); +--Testcase 327: +INSERT INTO num_exp_mul VALUES (8,1,'0'); +--Testcase 328: +INSERT INTO num_exp_div VALUES (8,1,'NaN'); +--Testcase 329: +INSERT INTO num_exp_add VALUES (8,2,'-34263611.215397047'); +--Testcase 330: +INSERT INTO num_exp_sub VALUES (8,2,'34413373.215397047'); +--Testcase 331: +INSERT INTO num_exp_mul VALUES (8,2,'-2571300635581.146276407'); +--Testcase 332: +INSERT INTO num_exp_div VALUES (8,2,'-.00218067233500788615'); +--Testcase 333: +INSERT INTO num_exp_add VALUES (8,3,'74885.31'); +--Testcase 334: +INSERT INTO num_exp_sub VALUES (8,3,'74876.69'); +--Testcase 335: +INSERT INTO num_exp_mul VALUES (8,3,'322737.11'); +--Testcase 336: +INSERT INTO num_exp_div VALUES (8,3,'17373.78190255220417633410'); +--Testcase 337: +INSERT INTO num_exp_add VALUES (8,4,'7874342.4119'); +--Testcase 338: +INSERT INTO num_exp_sub VALUES (8,4,'-7724580.4119'); +--Testcase 339: +INSERT INTO num_exp_mul VALUES (8,4,'584031469984.4839'); +--Testcase 340: +INSERT INTO num_exp_div VALUES (8,4,'.00960079113741758956'); +--Testcase 341: +INSERT INTO num_exp_add VALUES (8,5,'91278.038491'); +--Testcase 342: +INSERT INTO num_exp_sub VALUES (8,5,'58483.961509'); +--Testcase 343: +INSERT INTO num_exp_mul VALUES (8,5,'1227826639.244571'); +--Testcase 344: +INSERT INTO num_exp_div VALUES (8,5,'4.56673929509287019456'); +--Testcase 345: +INSERT INTO num_exp_add VALUES (8,6,'168782.57763026'); +--Testcase 346: +INSERT INTO num_exp_sub VALUES (8,6,'-19020.57763026'); +--Testcase 347: +INSERT INTO num_exp_mul VALUES (8,6,'7031444034.53149906'); +--Testcase 348: +INSERT INTO num_exp_div VALUES (8,6,'.79744134113322314424'); +--Testcase 349: +INSERT INTO num_exp_add VALUES (8,7,'-82953604'); +--Testcase 350: +INSERT INTO num_exp_sub VALUES (8,7,'83103366'); +--Testcase 351: +INSERT INTO num_exp_mul VALUES (8,7,'-6217255985285'); +--Testcase 352: +INSERT INTO num_exp_div VALUES (8,7,'-.00090187120721280172'); +--Testcase 353: +INSERT INTO num_exp_add VALUES (8,8,'149762'); +--Testcase 354: +INSERT INTO num_exp_sub VALUES (8,8,'0'); +--Testcase 355: +INSERT INTO num_exp_mul VALUES (8,8,'5607164161'); +--Testcase 356: +INSERT INTO num_exp_div VALUES (8,8,'1.00000000000000000000'); +--Testcase 357: +INSERT INTO num_exp_add VALUES (8,9,'-24851923.045047420'); +--Testcase 358: +INSERT INTO num_exp_sub VALUES (8,9,'25001685.045047420'); +--Testcase 359: +INSERT INTO num_exp_mul VALUES (8,9,'-1866544013697.195857020'); +--Testcase 360: +INSERT INTO num_exp_div VALUES (8,9,'-.00300403532938582735'); +--Testcase 361: +INSERT INTO num_exp_add VALUES (9,0,'-24926804.045047420'); +--Testcase 362: +INSERT INTO num_exp_sub VALUES (9,0,'-24926804.045047420'); +--Testcase 363: +INSERT INTO num_exp_mul VALUES (9,0,'0'); +--Testcase 364: +INSERT INTO num_exp_div VALUES (9,0,'NaN'); +--Testcase 365: +INSERT INTO num_exp_add VALUES (9,1,'-24926804.045047420'); +--Testcase 366: +INSERT INTO num_exp_sub VALUES (9,1,'-24926804.045047420'); +--Testcase 367: +INSERT INTO num_exp_mul VALUES (9,1,'0'); +--Testcase 368: +INSERT INTO num_exp_div VALUES (9,1,'NaN'); +--Testcase 369: +INSERT INTO num_exp_add VALUES (9,2,'-59265296.260444467'); +--Testcase 370: +INSERT INTO num_exp_sub VALUES (9,2,'9411688.170349627'); +--Testcase 371: +INSERT INTO num_exp_mul VALUES (9,2,'855948866655588.453741509242968740'); +--Testcase 372: +INSERT INTO num_exp_div VALUES (9,2,'.72591434384152961526'); +--Testcase 373: +INSERT INTO num_exp_add VALUES (9,3,'-24926799.735047420'); +--Testcase 374: +INSERT INTO num_exp_sub VALUES (9,3,'-24926808.355047420'); +--Testcase 375: +INSERT INTO num_exp_mul VALUES (9,3,'-107434525.43415438020'); +--Testcase 376: +INSERT INTO num_exp_div VALUES (9,3,'-5783481.21694835730858468677'); +--Testcase 377: +INSERT INTO num_exp_add VALUES (9,4,'-17127342.633147420'); +--Testcase 378: +INSERT INTO num_exp_sub VALUES (9,4,'-32726265.456947420'); +--Testcase 379: +INSERT INTO num_exp_mul VALUES (9,4,'-194415646271340.1815956522980'); +--Testcase 380: +INSERT INTO num_exp_div VALUES (9,4,'-3.19596478892958416484'); +--Testcase 381: +INSERT INTO num_exp_add VALUES (9,5,'-24910407.006556420'); +--Testcase 382: +INSERT INTO num_exp_sub VALUES (9,5,'-24943201.083538420'); +--Testcase 383: +INSERT INTO num_exp_mul VALUES (9,5,'-408725765384.257043660243220'); +--Testcase 384: +INSERT INTO num_exp_div VALUES (9,5,'-1520.20159364322004505807'); +--Testcase 385: +INSERT INTO num_exp_add VALUES (9,6,'-24832902.467417160'); +--Testcase 386: +INSERT INTO num_exp_sub VALUES (9,6,'-25020705.622677680'); +--Testcase 387: +INSERT INTO num_exp_mul VALUES (9,6,'-2340666225110.29929521292692920'); +--Testcase 388: +INSERT INTO num_exp_div VALUES (9,6,'-265.45671195426965751280'); +--Testcase 389: +INSERT INTO num_exp_add VALUES (9,7,'-107955289.045047420'); +--Testcase 390: +INSERT INTO num_exp_sub VALUES (9,7,'58101680.954952580'); +--Testcase 391: +INSERT INTO num_exp_mul VALUES (9,7,'2069634775752159.035758700'); +--Testcase 392: +INSERT INTO num_exp_div VALUES (9,7,'.30021990699995814689'); +--Testcase 393: +INSERT INTO num_exp_add VALUES (9,8,'-24851923.045047420'); +--Testcase 394: +INSERT INTO num_exp_sub VALUES (9,8,'-25001685.045047420'); +--Testcase 395: +INSERT INTO num_exp_mul VALUES (9,8,'-1866544013697.195857020'); +--Testcase 396: +INSERT INTO num_exp_div VALUES (9,8,'-332.88556569820675471748'); +--Testcase 397: +INSERT INTO num_exp_add VALUES (9,9,'-49853608.090094840'); +--Testcase 398: +INSERT INTO num_exp_sub VALUES (9,9,'0'); +--Testcase 399: +INSERT INTO num_exp_mul VALUES (9,9,'621345559900192.420120630048656400'); +--Testcase 400: +INSERT INTO num_exp_div VALUES (9,9,'1.00000000000000000000'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +--Testcase 401: +INSERT INTO num_exp_sqrt VALUES (0,'0'); +--Testcase 402: +INSERT INTO num_exp_sqrt VALUES (1,'0'); +--Testcase 403: +INSERT INTO num_exp_sqrt VALUES (2,'5859.90547836712524903505'); +--Testcase 404: +INSERT INTO num_exp_sqrt VALUES (3,'2.07605394920266944396'); +--Testcase 405: +INSERT INTO num_exp_sqrt VALUES (4,'2792.75158435189147418923'); +--Testcase 406: +INSERT INTO num_exp_sqrt VALUES (5,'128.05092147657509145473'); +--Testcase 407: +INSERT INTO num_exp_sqrt VALUES (6,'306.43364311096782703406'); +--Testcase 408: +INSERT INTO num_exp_sqrt VALUES (7,'9111.99676251039939975230'); +--Testcase 409: +INSERT INTO num_exp_sqrt VALUES (8,'273.64392922189960397542'); +--Testcase 410: +INSERT INTO num_exp_sqrt VALUES (9,'4992.67503899937593364766'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +--Testcase 411: +INSERT INTO num_exp_ln VALUES (0,'NaN'); +--Testcase 412: +INSERT INTO num_exp_ln VALUES (1,'NaN'); +--Testcase 413: +INSERT INTO num_exp_ln VALUES (2,'17.35177750493897715514'); +--Testcase 414: +INSERT INTO num_exp_ln VALUES (3,'1.46093790411565641971'); +--Testcase 415: +INSERT INTO num_exp_ln VALUES (4,'15.86956523951936572464'); +--Testcase 416: +INSERT INTO num_exp_ln VALUES (5,'9.70485601768871834038'); +--Testcase 417: +INSERT INTO num_exp_ln VALUES (6,'11.45000246622944403127'); +--Testcase 418: +INSERT INTO num_exp_ln VALUES (7,'18.23469429965478772991'); +--Testcase 419: +INSERT INTO num_exp_ln VALUES (8,'11.22365546576315513668'); +--Testcase 420: +INSERT INTO num_exp_ln VALUES (9,'17.03145425013166006962'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +--Testcase 421: +INSERT INTO num_exp_log10 VALUES (0,'NaN'); +--Testcase 422: +INSERT INTO num_exp_log10 VALUES (1,'NaN'); +--Testcase 423: +INSERT INTO num_exp_log10 VALUES (2,'7.53578122160797276459'); +--Testcase 424: +INSERT INTO num_exp_log10 VALUES (3,'.63447727016073160075'); +--Testcase 425: +INSERT INTO num_exp_log10 VALUES (4,'6.89206461372691743345'); +--Testcase 426: +INSERT INTO num_exp_log10 VALUES (5,'4.21476541614777768626'); +--Testcase 427: +INSERT INTO num_exp_log10 VALUES (6,'4.97267288886207207671'); +--Testcase 428: +INSERT INTO num_exp_log10 VALUES (7,'7.91922711353275546914'); +--Testcase 429: +INSERT INTO num_exp_log10 VALUES (8,'4.87437163556421004138'); +--Testcase 430: +INSERT INTO num_exp_log10 VALUES (9,'7.39666659961986567059'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +--Testcase 431: +INSERT INTO num_exp_power_10_ln VALUES (0,'NaN'); +--Testcase 432: +INSERT INTO num_exp_power_10_ln VALUES (1,'NaN'); +--Testcase 433: +INSERT INTO num_exp_power_10_ln VALUES (2,'224790267919917955.13261618583642653184'); +--Testcase 434: +INSERT INTO num_exp_power_10_ln VALUES (3,'28.90266599445155957393'); +--Testcase 435: +INSERT INTO num_exp_power_10_ln VALUES (4,'7405685069594999.07733999469386277636'); +--Testcase 436: +INSERT INTO num_exp_power_10_ln VALUES (5,'5068226527.32127265408584640098'); +--Testcase 437: +INSERT INTO num_exp_power_10_ln VALUES (6,'281839893606.99372343357047819067'); +--Testcase 438: +INSERT INTO num_exp_power_10_ln VALUES (7,'1716699575118597095.42330819910640247627'); +--Testcase 439: +INSERT INTO num_exp_power_10_ln VALUES (8,'167361463828.07491320069016125952'); +--Testcase 440: +INSERT INTO num_exp_power_10_ln VALUES (9,'107511333880052007.04141124673540337457'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +--Testcase 441: +INSERT INTO num_data VALUES (0, '0'); +--Testcase 442: +INSERT INTO num_data VALUES (1, '0'); +--Testcase 443: +INSERT INTO num_data VALUES (2, '-34338492.215397047'); +--Testcase 444: +INSERT INTO num_data VALUES (3, '4.31'); +--Testcase 445: +INSERT INTO num_data VALUES (4, '7799461.4119'); +--Testcase 446: +INSERT INTO num_data VALUES (5, '16397.038491'); +--Testcase 447: +INSERT INTO num_data VALUES (6, '93901.57763026'); +--Testcase 448: +INSERT INTO num_data VALUES (7, '-83028485'); +--Testcase 449: +INSERT INTO num_data VALUES (8, '74881'); +--Testcase 450: +INSERT INTO num_data VALUES (9, '-24926804.045047420'); +COMMIT TRANSACTION; +-- ****************************** +-- * Create indices for faster checks +-- ****************************** +-- Skip these setting, creating foreign table with primary key already covered. +--CREATE UNIQUE INDEX num_exp_add_idx ON num_exp_add (id1, id2); +--CREATE UNIQUE INDEX num_exp_sub_idx ON num_exp_sub (id1, id2); +--CREATE UNIQUE INDEX num_exp_div_idx ON num_exp_div (id1, id2); +--CREATE UNIQUE INDEX num_exp_mul_idx ON num_exp_mul (id1, id2); +--CREATE UNIQUE INDEX num_exp_sqrt_idx ON num_exp_sqrt (id); +--CREATE UNIQUE INDEX num_exp_ln_idx ON num_exp_ln (id); +--CREATE UNIQUE INDEX num_exp_log10_idx ON num_exp_log10 (id); +--CREATE UNIQUE INDEX num_exp_power_10_ln_idx ON num_exp_power_10_ln (id); +--VACUUM ANALYZE num_exp_add; +--VACUUM ANALYZE num_exp_sub; +--VACUUM ANALYZE num_exp_div; +--VACUUM ANALYZE num_exp_mul; +--VACUUM ANALYZE num_exp_sqrt; +--VACUUM ANALYZE num_exp_ln; +--VACUUM ANALYZE num_exp_log10; +--VACUUM ANALYZE num_exp_power_10_ln; +-- ****************************** +-- * Now check the behaviour of the NUMERIC type +-- ****************************** +-- ****************************** +-- * Addition check +-- ****************************** +--Testcase 451: +DELETE FROM num_result; +--Testcase 452: +INSERT INTO num_result SELECT t1.id, t2.id, t1.val + t2.val + FROM num_data t1, num_data t2; +--Testcase 453: +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected; + id1 | id2 | result | expected +-----+-----+--------------------+-------------------- + 2 | 3 | -34338487.90539704 | -34338487.90539705 + 2 | 5 | -34322095.17690604 | -34322095.17690605 + 2 | 9 | -59265296.26044446 | -59265296.26044447 + 3 | 2 | -34338487.90539704 | -34338487.90539705 + 5 | 2 | -34322095.17690604 | -34322095.17690605 + 9 | 2 | -59265296.26044446 | -59265296.26044447 +(6 rows) + +--Testcase 454: +DELETE FROM num_result; +--Testcase 455: +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val + t2.val, 10) + FROM num_data t1, num_data t2; +--Testcase 456: +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 10) as expected + FROM num_result t1, num_exp_add t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 10); + id1 | id2 | result | expected +-----+-----+--------------------+---------------------- + 2 | 3 | -34338487.90539704 | -34338487.9053970500 + 2 | 5 | -34322095.17690604 | -34322095.1769060500 + 2 | 9 | -59265296.26044446 | -59265296.2604444700 + 3 | 2 | -34338487.90539704 | -34338487.9053970500 + 5 | 2 | -34322095.17690604 | -34322095.1769060500 + 9 | 2 | -59265296.26044446 | -59265296.2604444700 +(6 rows) + +-- ****************************** +-- * Subtraction check +-- ****************************** +--Testcase 457: +DELETE FROM num_result; +--Testcase 458: +INSERT INTO num_result SELECT t1.id, t2.id, t1.val - t2.val + FROM num_data t1, num_data t2; +--Testcase 459: +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected; + id1 | id2 | result | expected +-----+-----+--------------------+-------------------- + 2 | 9 | -9411688.170349626 | -9411688.170349628 + 9 | 2 | 9411688.170349626 | 9411688.170349628 +(2 rows) + +--Testcase 460: +DELETE FROM num_result; +--Testcase 461: +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val - t2.val, 40) + FROM num_data t1, num_data t2; +--Testcase 462: +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 40) + FROM num_result t1, num_exp_sub t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 40); + id1 | id2 | result | round +-----+-----+--------------------+--------------------------------------------------- + 2 | 9 | -9411688.170349626 | -9411688.1703496280000000000000000000000000000000 + 9 | 2 | 9411688.170349626 | 9411688.1703496280000000000000000000000000000000 +(2 rows) + +-- ****************************** +-- * Multiply check +-- ****************************** +--Testcase 463: +DELETE FROM num_result; +--Testcase 464: +INSERT INTO num_result SELECT t1.id, t2.id, t1.val * t2.val + FROM num_data t1, num_data t2; +--Testcase 465: +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected; + id1 | id2 | result | expected +-----+-----+---------------------+--------------------- + 2 | 4 | -267821744976817.78 | -267821744976817.8 + 2 | 5 | -563049578578.7692 | -563049578578.7693 + 2 | 6 | -3224438592470.184 | -3224438592470.1846 + 2 | 8 | -2571300635581.146 | -2571300635581.1465 + 2 | 9 | 855948866655588.4 | 855948866655588.5 + 4 | 2 | -267821744976817.78 | -267821744976817.8 + 5 | 2 | -563049578578.7692 | -563049578578.7693 + 6 | 2 | -3224438592470.184 | -3224438592470.1846 + 8 | 2 | -2571300635581.146 | -2571300635581.1465 + 9 | 2 | 855948866655588.4 | 855948866655588.5 +(10 rows) + +--Testcase 466: +DELETE FROM num_result; +--Testcase 467: +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val * t2.val, 30) + FROM num_data t1, num_data t2; +--Testcase 468: +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 30) as expected + FROM num_result t1, num_exp_mul t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 30); + id1 | id2 | result | expected +-----+-----+---------------------+------------------------------------------------- + 2 | 4 | -267821744976817.78 | -267821744976817.800000000000000000000000000000 + 2 | 5 | -563049578578.7692 | -563049578578.769300000000000000000000000000 + 2 | 6 | -3224438592470.184 | -3224438592470.184600000000000000000000000000 + 2 | 8 | -2571300635581.146 | -2571300635581.146500000000000000000000000000 + 2 | 9 | 855948866655588.4 | 855948866655588.500000000000000000000000000000 + 4 | 2 | -267821744976817.78 | -267821744976817.800000000000000000000000000000 + 5 | 2 | -563049578578.7692 | -563049578578.769300000000000000000000000000 + 6 | 2 | -3224438592470.184 | -3224438592470.184600000000000000000000000000 + 8 | 2 | -2571300635581.146 | -2571300635581.146500000000000000000000000000 + 9 | 2 | 855948866655588.4 | 855948866655588.500000000000000000000000000000 +(10 rows) + +-- ****************************** +-- * Division check +-- ****************************** +--Testcase 469: +DELETE FROM num_result; +--Testcase 470: +INSERT INTO num_result SELECT t1.id, t2.id, t1.val / t2.val + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0'; +--Testcase 471: +SELECT t1.id1, t1.id2, t1.result, t2.expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != t2.expected; + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +--Testcase 472: +DELETE FROM num_result; +--Testcase 473: +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val / t2.val, 80) + FROM num_data t1, num_data t2 + WHERE t2.val != '0.0'; +--Testcase 474: +SELECT t1.id1, t1.id2, t1.result, round(t2.expected, 80) as expected + FROM num_result t1, num_exp_div t2 + WHERE t1.id1 = t2.id1 AND t1.id2 = t2.id2 + AND t1.result != round(t2.expected, 80); + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +-- ****************************** +-- * Square root check +-- ****************************** +--Testcase 475: +DELETE FROM num_result; +--Testcase 476: +INSERT INTO num_result SELECT id, 0, SQRT(ABS(val)) + FROM num_data; +--Testcase 477: +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_sqrt t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected; + id1 | result | expected +-----+--------+---------- +(0 rows) + +-- ****************************** +-- * Natural logarithm check +-- ****************************** +--Testcase 478: +DELETE FROM num_result; +--Testcase 479: +INSERT INTO num_result SELECT id, 0, LN(ABS(val)) + FROM num_data + WHERE val != '0.0'; +--Testcase 480: +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected; + id1 | result | expected +-----+--------+---------- +(0 rows) + +-- ****************************** +-- * Logarithm base 10 check +-- ****************************** +--Testcase 481: +DELETE FROM num_result; +--Testcase 482: +INSERT INTO num_result SELECT id, 0, LOG(numeric '10', ABS(val)) + FROM num_data + WHERE val != '0.0'; +--Testcase 483: +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_log10 t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected; + id1 | result | expected +-----+--------+---------- +(0 rows) + +-- ****************************** +-- * POWER(10, LN(value)) check +-- ****************************** +--Testcase 484: +DELETE FROM num_result; +--Testcase 485: +INSERT INTO num_result SELECT id, 0, POWER(numeric '10', LN(ABS(round(val,200)))) + FROM num_data + WHERE val != '0.0'; +--Testcase 486: +SELECT t1.id1, t1.result, t2.expected + FROM num_result t1, num_exp_power_10_ln t2 + WHERE t1.id1 = t2.id + AND t1.result != t2.expected; + id1 | result | expected +-----+--------------------+-------------------- + 2 | 224790267919917920 | 224790267919917950 +(1 row) + +-- ****************************** +-- * Check behavior with Inf and NaN inputs. It's easiest to handle these +-- * separately from the num_data framework used above, because some input +-- * combinations will throw errors. +-- ****************************** +--Testcase 1451: +CREATE FOREIGN TABLE v (id int4 OPTIONS (key 'true'), x numeric, val float8) SERVER sqlite_svr; +BEGIN; +--Testcase 1452: +DELETE FROM v; +--Testcase 1453: +INSERT INTO v(x) VALUES ('0'::float8),('1'),('-1'),('4.2'),('inf'),('-inf'),('nan'); +--Testcase 1454: +SELECT x1, x2, + x1::numeric + x2::numeric AS sum, + x1::numeric - x2::numeric AS diff, + x1::numeric * x2::numeric AS prod +FROM v AS v1(id, x1), v AS v2(id, x2); + x1 | x2 | sum | diff | prod +-----------+-----------+-----------+-----------+----------- + 0 | 0 | 0 | 0 | 0 + 0 | 1 | 1 | -1 | 0 + 0 | -1 | -1 | 1 | 0 + 0 | 4.2 | 4.2 | -4.2 | 0.0 + 0 | Infinity | Infinity | -Infinity | NaN + 0 | -Infinity | -Infinity | Infinity | NaN + 0 | | | | + 1 | 0 | 1 | 1 | 0 + 1 | 1 | 2 | 0 | 1 + 1 | -1 | 0 | 2 | -1 + 1 | 4.2 | 5.2 | -3.2 | 4.2 + 1 | Infinity | Infinity | -Infinity | Infinity + 1 | -Infinity | -Infinity | Infinity | -Infinity + 1 | | | | + -1 | 0 | -1 | -1 | 0 + -1 | 1 | 0 | -2 | -1 + -1 | -1 | -2 | 0 | 1 + -1 | 4.2 | 3.2 | -5.2 | -4.2 + -1 | Infinity | Infinity | -Infinity | -Infinity + -1 | -Infinity | -Infinity | Infinity | Infinity + -1 | | | | + 4.2 | 0 | 4.2 | 4.2 | 0.0 + 4.2 | 1 | 5.2 | 3.2 | 4.2 + 4.2 | -1 | 3.2 | 5.2 | -4.2 + 4.2 | 4.2 | 8.4 | 0.0 | 17.64 + 4.2 | Infinity | Infinity | -Infinity | Infinity + 4.2 | -Infinity | -Infinity | Infinity | -Infinity + 4.2 | | | | + Infinity | 0 | Infinity | Infinity | NaN + Infinity | 1 | Infinity | Infinity | Infinity + Infinity | -1 | Infinity | Infinity | -Infinity + Infinity | 4.2 | Infinity | Infinity | Infinity + Infinity | Infinity | Infinity | NaN | Infinity + Infinity | -Infinity | NaN | Infinity | -Infinity + Infinity | | | | + -Infinity | 0 | -Infinity | -Infinity | NaN + -Infinity | 1 | -Infinity | -Infinity | -Infinity + -Infinity | -1 | -Infinity | -Infinity | Infinity + -Infinity | 4.2 | -Infinity | -Infinity | -Infinity + -Infinity | Infinity | NaN | -Infinity | -Infinity + -Infinity | -Infinity | -Infinity | NaN | Infinity + -Infinity | | | | + | 0 | | | + | 1 | | | + | -1 | | | + | 4.2 | | | + | Infinity | | | + | -Infinity | | | + | | | | +(49 rows) + +--Testcase 1455: +SELECT x1, x2, + x1::numeric / x2::numeric AS quot, + x1::numeric % x2::numeric AS mod, + div(x1::numeric, x2::numeric) AS div +FROM v AS v1(id, x1), v AS v2(id, x2) WHERE x2 != 0; + x1 | x2 | quot | mod | div +-----------+-----------+-------------------------+------+----------- + 0 | 1 | 0.00000000000000000000 | 0 | 0 + 0 | -1 | 0.00000000000000000000 | 0 | 0 + 0 | 4.2 | 0.00000000000000000000 | 0.0 | 0 + 0 | Infinity | 0 | 0 | 0 + 0 | -Infinity | 0 | 0 | 0 + 1 | 1 | 1.00000000000000000000 | 0 | 1 + 1 | -1 | -1.00000000000000000000 | 0 | -1 + 1 | 4.2 | 0.23809523809523809524 | 1.0 | 0 + 1 | Infinity | 0 | 1 | 0 + 1 | -Infinity | 0 | 1 | 0 + -1 | 1 | -1.00000000000000000000 | 0 | -1 + -1 | -1 | 1.00000000000000000000 | 0 | 1 + -1 | 4.2 | -0.23809523809523809524 | -1.0 | 0 + -1 | Infinity | 0 | -1 | 0 + -1 | -Infinity | 0 | -1 | 0 + 4.2 | 1 | 4.2000000000000000 | 0.2 | 4 + 4.2 | -1 | -4.2000000000000000 | 0.2 | -4 + 4.2 | 4.2 | 1.00000000000000000000 | 0.0 | 1 + 4.2 | Infinity | 0 | 4.2 | 0 + 4.2 | -Infinity | 0 | 4.2 | 0 + Infinity | 1 | Infinity | NaN | Infinity + Infinity | -1 | -Infinity | NaN | -Infinity + Infinity | 4.2 | Infinity | NaN | Infinity + Infinity | Infinity | NaN | NaN | NaN + Infinity | -Infinity | NaN | NaN | NaN + -Infinity | 1 | -Infinity | NaN | -Infinity + -Infinity | -1 | Infinity | NaN | Infinity + -Infinity | 4.2 | -Infinity | NaN | -Infinity + -Infinity | Infinity | NaN | NaN | NaN + -Infinity | -Infinity | NaN | NaN | NaN + | 1 | | | + | -1 | | | + | 4.2 | | | + | Infinity | | | + | -Infinity | | | +(35 rows) + +ROLLBACK; +BEGIN; +--Testcase 1286: +DELETE FROM v; +--Testcase 1287: +INSERT INTO v(x) VALUES ('inf':: float8); +--Testcase 1288: +SELECT x::numeric / '0' FROM v; +ERROR: division by zero +ROLLBACK; +BEGIN; +--Testcase 1289: +DELETE FROM v; +--Testcase 1290: +INSERT INTO v(x) VALUES ('-inf':: float8); +--Testcase 1291: +SELECT x::numeric / '0' FROM v; +ERROR: division by zero +ROLLBACK; +BEGIN; +--Testcase 1292: +DELETE FROM v; +--Testcase 1293: +INSERT INTO v(x) VALUES ('nan':: float8); +--Testcase 1294: +SELECT x::numeric / '0' FROM v; + ?column? +---------- + +(1 row) + +ROLLBACK; +BEGIN; +--Testcase 1295: +DELETE FROM v; +--Testcase 1296: +INSERT INTO v(x) VALUES ('0':: float8); +--Testcase 1297: +SELECT x::numeric / '0' FROM v; +ERROR: division by zero +ROLLBACK; +BEGIN; +--Testcase 1298: +DELETE FROM v; +--Testcase 1299: +INSERT INTO v(x) VALUES ('inf':: float8); +--Testcase 1300: +SELECT x::numeric % '0' FROM v; +ERROR: division by zero +ROLLBACK; +BEGIN; +--Testcase 1301: +DELETE FROM v; +--Testcase 1302: +INSERT INTO v(x) VALUES ('-inf':: float8); +--Testcase 1303: +SELECT x::numeric % '0' FROM v; +ERROR: division by zero +ROLLBACK; +BEGIN; +--Testcase 1304: +DELETE FROM v; +--Testcase 1305: +INSERT INTO v(x) VALUES ('nan':: float8); +--Testcase 1306: +SELECT x::numeric % '0' FROM v; + ?column? +---------- + +(1 row) + +ROLLBACK; +BEGIN; +--Testcase 1307: +DELETE FROM v; +--Testcase 1308: +INSERT INTO v(x) VALUES ('0':: float8); +--Testcase 1309: +SELECT x::numeric % '0' FROM v; +ERROR: division by zero +ROLLBACK; +BEGIN; +--Testcase 1310: +DELETE FROM v; +--Testcase 1311: +INSERT INTO v(x) VALUES ('inf':: float8); +--Testcase 1312: +SELECT div(x::numeric, '0') FROM v; +ERROR: division by zero +ROLLBACK; +BEGIN; +--Testcase 1313: +DELETE FROM v; +--Testcase 1314: +INSERT INTO v(x) VALUES ('-inf':: float8); +--Testcase 1315: +SELECT div(x::numeric, '0') FROM v; +ERROR: division by zero +ROLLBACK; +BEGIN; +--Testcase 1316: +DELETE FROM v; +--Testcase 1317: +INSERT INTO v(x) VALUES ('nan':: float8); +--Testcase 1318: +SELECT div(x::numeric, '0') FROM v; + div +----- + +(1 row) + +ROLLBACK; +BEGIN; +--Testcase 1319: +DELETE FROM v; +--Testcase 1320: +INSERT INTO v(x) VALUES ('0':: float8); +--Testcase 1321: +SELECT div(x::numeric, '0') FROM v; +ERROR: division by zero +ROLLBACK; +BEGIN; +--Testcase 1456: +DELETE FROM v; +--Testcase 1457: +INSERT INTO v(x) VALUES('0'::numeric),('1'),('-1'),('4.2'),('-7.777'),('inf'),('-inf'),('nan'); +--Testcase 1458: +SELECT x, -x as minusx, abs(x::numeric), floor(x::numeric), ceil(x::numeric), sign(x::numeric), numeric_inc(x::numeric) as inc +FROM v; + x | minusx | abs | floor | ceil | sign | inc +-----------+-----------+----------+-----------+-----------+------+----------- + 0 | 0 | 0 | 0 | 0 | 0 | 1 + 1 | -1 | 1 | 1 | 1 | 1 | 2 + -1 | 1 | 1 | -1 | -1 | -1 | 0 + 4.2 | -4.2 | 4.2 | 4 | 5 | 1 | 5.2 + -7.777 | 7.777 | 7.777 | -8 | -7 | -1 | -6.777 + Infinity | -Infinity | Infinity | Infinity | Infinity | 1 | Infinity + -Infinity | Infinity | Infinity | -Infinity | -Infinity | -1 | -Infinity + | | | | | | +(8 rows) + +ROLLBACK; +BEGIN; +--Testcase 1459: +DELETE FROM v; +--Testcase 1460: +INSERT INTO v(x) VALUES('0'::numeric),('1'),('-1'),('4.2'),('-7.777'),('inf'),('-inf'),('nan'); +--Testcase 1461: +SELECT x, round(x::numeric), round(x::numeric,1) as round1, trunc(x::numeric), trunc(x::numeric,1) as trunc1 +FROM v; + x | round | round1 | trunc | trunc1 +-----------+-----------+-----------+-----------+----------- + 0 | 0 | 0.0 | 0 | 0.0 + 1 | 1 | 1.0 | 1 | 1.0 + -1 | -1 | -1.0 | -1 | -1.0 + 4.2 | 4 | 4.2 | 4 | 4.2 + -7.777 | -8 | -7.8 | -7 | -7.7 + Infinity | Infinity | Infinity | Infinity | Infinity + -Infinity | -Infinity | -Infinity | -Infinity | -Infinity + | | | | +(8 rows) + +ROLLBACK; +-- the large values fall into the numeric abbreviation code's maximal classes +BEGIN; +--Testcase 1462: +INSERT INTO v(x) VALUES ('0'::numeric),('1'),('-1'),('4.2'),('-7.777'), + ('inf'),('-inf'),('nan'), + ('inf'),('-inf'),('nan'); +--Testcase 1463: +SELECT substring(x::text, 1, 32) FROM v ORDER BY x; + substring +----------- + -Infinity + -Infinity + -Infinity + -7.777 + -1 + 0 + 1 + 4.2 + Infinity + Infinity + Infinity + + +(13 rows) + +ROLLBACK; +--Testcase 1464: +DELETE FROM v; +--Testcase 1465: +INSERT INTO v(x) VALUES('0'::numeric),('1'),('4.2'),('inf'),('nan'); +--Testcase 1466: +SELECT x, sqrt(x) FROM v; + x | sqrt +----------+------------------- + 0 | 0.000000000000000 + 1 | 1.000000000000000 + 4.2 | 2.049390153191920 + Infinity | Infinity + | +(5 rows) + +--Testcase 1333: +DELETE FROM v; +--Testcase 1334: +INSERT INTO v(x) VALUES ('-1'::float8); +--Testcase 1335: +SELECT sqrt(x::numeric) FROM v; +ERROR: cannot take square root of a negative number +--Testcase 1336: +DELETE FROM v; +--Testcase 1337: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1338: +SELECT sqrt(x::numeric) FROM v; +ERROR: cannot take square root of a negative number +--Testcase 1467: +DELETE FROM v; +--Testcase 1468: +INSERT INTO v(x) VALUES ('1'::numeric),('4.2'),('inf'),('nan'); +--Testcase 1469: +SELECT x, + log(x::numeric), + log10(x::numeric), + ln(x::numeric) +FROM v; + x | log | log10 | ln +----------+--------------------+--------------------+-------------------- + 1 | 0.0000000000000000 | 0.0000000000000000 | 0.0000000000000000 + 4.2 | 0.6232492903979005 | 0.6232492903979005 | 1.4350845252893226 + Infinity | Infinity | Infinity | Infinity + | | | +(4 rows) + +--Testcase 1342: +DELETE FROM v; +--Testcase 1343: +INSERT INTO v(x) VALUES ('0'::float8); +--Testcase 1344: +SELECT ln(x::numeric) FROM v; +ERROR: cannot take logarithm of zero +--Testcase 1345: +DELETE FROM v; +--Testcase 1346: +INSERT INTO v(x) VALUES ('-1'::float8); +--Testcase 1347: +SELECT ln(x::numeric) FROM v; +ERROR: cannot take logarithm of a negative number +--Testcase 1348: +DELETE FROM v; +--Testcase 1349: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1350: +SELECT ln(x::numeric) FROM v; +ERROR: cannot take logarithm of a negative number +--Testcase 1470: +DELETE FROM v; +--Testcase 1471: +INSERT INTO v(x) VALUES ('2'::numeric),('4.2'),('inf'),('nan'); +--Testcase 1472: +SELECT x1, x2, + log(x1::numeric, x2::numeric) +FROM v AS v1(id, x1), v AS v2(id, x2); + x1 | x2 | log +----------+----------+-------------------- + 2 | 2 | 1.0000000000000000 + 2 | 4.2 | 2.0703893278913979 + 2 | Infinity | Infinity + 2 | | + 4.2 | 2 | 0.4830009440873890 + 4.2 | 4.2 | 1.0000000000000000 + 4.2 | Infinity | Infinity + 4.2 | | + Infinity | 2 | 0 + Infinity | 4.2 | 0 + Infinity | Infinity | NaN + Infinity | | + | 2 | + | 4.2 | + | Infinity | + | | +(16 rows) + +--Testcase 1354: +DELETE FROM v; +--Testcase 1355: +INSERT INTO v(x) VALUES ('0'::float8); +--Testcase 1356: +SELECT log(x::numeric, '10') FROM v; +ERROR: cannot take logarithm of zero +--Testcase 1357: +DELETE FROM v; +--Testcase 1358: +INSERT INTO v(x) VALUES ('10'::float8); +--Testcase 1359: +SELECT log(x::numeric, '0') FROM v; +ERROR: cannot take logarithm of zero +--Testcase 1360: +DELETE FROM v; +--Testcase 1361: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1362: +SELECT log(x::numeric, '10') FROM v; +ERROR: cannot take logarithm of a negative number +--Testcase 1363: +DELETE FROM v; +--Testcase 1364: +INSERT INTO v(x) VALUES ('10'::float8); +--Testcase 1365: +SELECT log(x::numeric, '-inf') FROM v; +ERROR: cannot take logarithm of a negative number +--Testcase 1366: +DELETE FROM v; +--Testcase 1367: +INSERT INTO v(x) VALUES ('inf'::float8); +--Testcase 1368: +SELECT log(x::numeric, '0') FROM v; +ERROR: cannot take logarithm of zero +--Testcase 1369: +DELETE FROM v; +--Testcase 1370: +INSERT INTO v(x) VALUES ('inf'::float8); +--Testcase 1371: +SELECT log(x::numeric, '-inf') FROM v; +ERROR: cannot take logarithm of a negative number +--Testcase 1372: +DELETE FROM v; +--Testcase 1373: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1374: +SELECT log(x::numeric, 'inf') FROM v; +ERROR: cannot take logarithm of a negative number +--Testcase 1473: +DELETE FROM v; +--Testcase 1474: +INSERT INTO v(x) VALUES ('0'::numeric),('1'),('2'),('4.2'),('inf'),('nan'); +--Testcase 1475: +SELECT x1, x2, + power(x1::numeric, x2::numeric) +FROM v AS v1(id, x1), v AS v2(id, x2) WHERE x1 != 0 OR x2 >= 0; + x1 | x2 | power +----------+----------+--------------------- + 0 | 0 | 1.0000000000000000 + 0 | 1 | 0.0000000000000000 + 0 | 2 | 0.0000000000000000 + 0 | 4.2 | 0.0000000000000000 + 0 | Infinity | 0 + 1 | 0 | 1.0000000000000000 + 1 | 1 | 1.0000000000000000 + 1 | 2 | 1.0000000000000000 + 1 | 4.2 | 1.0000000000000000 + 1 | Infinity | 1 + 1 | | + 2 | 0 | 1.0000000000000000 + 2 | 1 | 2.0000000000000000 + 2 | 2 | 4.0000000000000000 + 2 | 4.2 | 18.379173679952560 + 2 | Infinity | Infinity + 2 | | + 4.2 | 0 | 1.0000000000000000 + 4.2 | 1 | 4.2000000000000000 + 4.2 | 2 | 17.6400000000000000 + 4.2 | 4.2 | 414.61691860129675 + 4.2 | Infinity | Infinity + 4.2 | | + Infinity | 0 | 1 + Infinity | 1 | Infinity + Infinity | 2 | Infinity + Infinity | 4.2 | Infinity + Infinity | Infinity | Infinity + Infinity | | + | 0 | + | 1 | + | 2 | + | 4.2 | + | Infinity | +(34 rows) + +--Testcase 1378: +DELETE FROM v; +--Testcase 1379: +INSERT INTO v(x) VALUES ('0'::float8); +--Testcase 1380: +SELECT power(x::numeric, '-1') FROM v; +ERROR: zero raised to a negative power is undefined +--Testcase 1381: +DELETE FROM v; +--Testcase 1382: +INSERT INTO v(x) VALUES ('0'::float8); +--Testcase 1383: +SELECT power(x::numeric, '-inf') FROM v; +ERROR: zero raised to a negative power is undefined +--Testcase 1384: +DELETE FROM v; +--Testcase 1385: +INSERT INTO v(x) VALUES ('-1'::float8); +--Testcase 1386: +SELECT power(x::numeric, 'inf') FROM v; + power +------- + 1 +(1 row) + +--Testcase 1387: +DELETE FROM v; +--Testcase 1388: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1389: +SELECT power(x::numeric, '3') FROM v; + power +--------------------- + -8.0000000000000000 +(1 row) + +--Testcase 1390: +DELETE FROM v; +--Testcase 1391: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1392: +SELECT power(x::numeric, '3.3') FROM v; +ERROR: a negative number raised to a non-integer power yields a complex result +--Testcase 1393: +DELETE FROM v; +--Testcase 1394: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1395: +SELECT power(x::numeric, '-1') FROM v; + power +--------------------- + -0.5000000000000000 +(1 row) + +--Testcase 1396: +DELETE FROM v; +--Testcase 1397: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1398: +SELECT power(x::numeric, '-1.5') FROM v; +ERROR: a negative number raised to a non-integer power yields a complex result +--Testcase 1399: +DELETE FROM v; +--Testcase 1400: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1401: +SELECT power(x::numeric, 'inf') FROM v; + power +---------- + Infinity +(1 row) + +--Testcase 1402: +DELETE FROM v; +--Testcase 1403: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1404: +SELECT power(x::numeric, '-inf') FROM v; + power +------- + 0 +(1 row) + +--Testcase 1405: +DELETE FROM v; +--Testcase 1406: +INSERT INTO v(x) VALUES ('inf'::float8); +--Testcase 1407: +SELECT power(x::numeric, '-2') FROM v; + power +------- + 0 +(1 row) + +--Testcase 1408: +DELETE FROM v; +--Testcase 1409: +INSERT INTO v(x) VALUES ('inf'::float8); +--Testcase 1410: +SELECT power(x::numeric, '-inf') FROM v; + power +------- + 0 +(1 row) + +--Testcase 1411: +DELETE FROM v; +--Testcase 1412: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1413: +SELECT power(x::numeric, '2') FROM v; + power +---------- + Infinity +(1 row) + +--Testcase 1414: +DELETE FROM v; +--Testcase 1415: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1416: +SELECT power(x::numeric, '3') FROM v; + power +----------- + -Infinity +(1 row) + +--Testcase 1417: +DELETE FROM v; +--Testcase 1418: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1419: +SELECT power(x::numeric, '4.5') FROM v; +ERROR: a negative number raised to a non-integer power yields a complex result +--Testcase 1420: +DELETE FROM v; +--Testcase 1421: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1422: +SELECT power(x::numeric, '-2') FROM v; + power +------- + 0 +(1 row) + +--Testcase 1423: +DELETE FROM v; +--Testcase 1424: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1425: +SELECT power(x::numeric, '-3') FROM v; + power +------- + 0 +(1 row) + +--Testcase 1426: +DELETE FROM v; +--Testcase 1427: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1428: +SELECT power(x::numeric, '0') FROM v; + power +------- + 1 +(1 row) + +--Testcase 1429: +DELETE FROM v; +--Testcase 1430: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1431: +SELECT power(x::numeric, 'inf') FROM v; + power +---------- + Infinity +(1 row) + +--Testcase 1432: +DELETE FROM v; +--Testcase 1433: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1434: +SELECT power(x::numeric, '-inf') FROM v; + power +------- + 0 +(1 row) + +-- ****************************** +-- * miscellaneous checks for things that have been broken in the past... +-- ****************************** +-- numeric AVG used to fail on some platforms +--Testcase 487: +SELECT AVG(val) FROM num_data; + avg +--------------------- + -13430913.592242321 +(1 row) + +--Testcase 1137: +SELECT MAX(val) FROM num_data; + max +-------------- + 7799461.4119 +(1 row) + +--Testcase 1138: +SELECT MIN(val) FROM num_data; + min +----------- + -83028485 +(1 row) + +--Testcase 488: +SELECT STDDEV(val) FROM num_data; + stddev +----------------------------- + 27791203.287588353130876346 +(1 row) + +--Testcase 489: +SELECT VARIANCE(val) FROM num_data; + variance +------------------------------------ + 772350980172061.687298801053312091 +(1 row) + +-- Check for appropriate rounding and overflow +--Testcase 579: +CREATE FOREIGN TABLE fract_only (id int, val numeric(4,4)) SERVER sqlite_svr; +--Testcase 490: +INSERT INTO fract_only VALUES (1, '0.0'); +--Testcase 491: +INSERT INTO fract_only VALUES (2, '0.1'); +--Testcase 492: +INSERT INTO fract_only VALUES (3, '1.0'); -- should fail +ERROR: numeric field overflow +DETAIL: A field with precision 4, scale 4 must round to an absolute value less than 1. +--Testcase 493: +INSERT INTO fract_only VALUES (4, '-0.9999'); +--Testcase 494: +INSERT INTO fract_only VALUES (5, '0.99994'); +--Testcase 495: +INSERT INTO fract_only VALUES (6, '0.99995'); -- should fail +ERROR: numeric field overflow +DETAIL: A field with precision 4, scale 4 must round to an absolute value less than 1. +--Testcase 496: +INSERT INTO fract_only VALUES (7, '0.00001'); +--Testcase 497: +INSERT INTO fract_only VALUES (8, '0.00017'); +--Testcase 1139: +INSERT INTO fract_only VALUES (9, 'NaN'); +--Testcase 1140: +INSERT INTO fract_only VALUES (10, 'Inf'); -- should fail +ERROR: numeric field overflow +DETAIL: A field with precision 4, scale 4 cannot hold an infinite value. +--Testcase 1141: +INSERT INTO fract_only VALUES (11, '-Inf'); -- should fail +ERROR: numeric field overflow +DETAIL: A field with precision 4, scale 4 cannot hold an infinite value. +--Testcase 498: +SELECT * FROM fract_only; + id | val +----+--------- + 1 | 0 + 2 | 0.1 + 4 | -0.9999 + 5 | 0.9999 + 7 | 0 + 8 | 0.0002 + 9 | +(7 rows) + +--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; +--Testcase 582: +DELETE FROM FLOAT8_TMP; +--Testcase 583: +INSERT INTO FLOAT8_TMP VALUES ('NaN'); +--Testcase 584: +SELECT f1::numeric FROM FLOAT8_TMP; + f1 +---- + +(1 row) + +--Testcase 585: +DELETE FROM FLOAT8_TMP; +--Testcase 586: +INSERT INTO FLOAT8_TMP VALUES ('Infinity'); +--Testcase 587: +SELECT f1::numeric FROM FLOAT8_TMP; + f1 +---------- + Infinity +(1 row) + +--Testcase 588: +DELETE FROM FLOAT8_TMP; +--Testcase 589: +INSERT INTO FLOAT8_TMP VALUES ('-Infinity'); +--Testcase 590: +SELECT f1::numeric FROM FLOAT8_TMP; + f1 +----------- + -Infinity +(1 row) + +--Testcase 1142: +CREATE FOREIGN TABLE NUMERIC_TMP(f1 numeric, f2 numeric, id int OPTIONS (key 'true')) SERVER sqlite_svr; +--Testcase 1143: +DELETE FROM NUMERIC_TMP; +--Testcase 1144: +INSERT INTO NUMERIC_TMP VALUES ('NaN'); +--Testcase 1145: +SELECT f1::float8 FROM NUMERIC_TMP; + f1 +---- + +(1 row) + +--Testcase 1146: +DELETE FROM NUMERIC_TMP; +--Testcase 1147: +INSERT INTO NUMERIC_TMP VALUES ('Infinity'); +--Testcase 1148: +SELECT f1::float8 FROM NUMERIC_TMP; + f1 +---------- + Infinity +(1 row) + +--Testcase 1149: +DELETE FROM NUMERIC_TMP; +--Testcase 1150: +INSERT INTO NUMERIC_TMP VALUES ('-Infinity'); +--Testcase 1151: +SELECT f1::float8 FROM NUMERIC_TMP; + f1 +----------- + -Infinity +(1 row) + +--Testcase 591: +CREATE FOREIGN TABLE FLOAT4_TMP(f1 float4, id int OPTIONS (key 'true')) SERVER sqlite_svr; +--Testcase 592: +DELETE FROM FLOAT4_TMP; +--Testcase 593: +INSERT INTO FLOAT4_TMP VALUES ('NaN'); +--Testcase 594: +SELECT f1::numeric FROM FLOAT4_TMP; + f1 +---- + +(1 row) + +--Testcase 595: +DELETE FROM FLOAT4_TMP; +--Testcase 596: +INSERT INTO FLOAT4_TMP VALUES ('Infinity'); +--Testcase 597: +SELECT f1::numeric FROM FLOAT4_TMP; + f1 +---------- + Infinity +(1 row) + +--Testcase 598: +DELETE FROM FLOAT4_TMP; +--Testcase 599: +INSERT INTO FLOAT4_TMP VALUES ('-Infinity'); +--Testcase 600: +SELECT f1::numeric FROM FLOAT4_TMP; + f1 +----------- + -Infinity +(1 row) + +--Testcase 1152: +DELETE FROM NUMERIC_TMP; +--Testcase 1153: +INSERT INTO NUMERIC_TMP VALUES ('NaN'); +--Testcase 1154: +SELECT f1::float4 FROM NUMERIC_TMP; + f1 +---- + +(1 row) + +--Testcase 1155: +DELETE FROM NUMERIC_TMP; +--Testcase 1156: +INSERT INTO NUMERIC_TMP VALUES ('Infinity'); +--Testcase 1157: +SELECT f1::float4 FROM NUMERIC_TMP; + f1 +---------- + Infinity +(1 row) + +--Testcase 1158: +DELETE FROM NUMERIC_TMP; +--Testcase 1159: +INSERT INTO NUMERIC_TMP VALUES ('-Infinity'); +--Testcase 1160: +SELECT f1::float4 FROM NUMERIC_TMP; + f1 +----------- + -Infinity +(1 row) + +--Testcase 1161: +DELETE FROM NUMERIC_TMP; +--Testcase 1162: +INSERT INTO NUMERIC_TMP VALUES ('42'::int2); +--Testcase 1163: +SELECT f1::numeric FROM NUMERIC_TMP; + f1 +---- + 42 +(1 row) + +--Testcase 1164: +DELETE FROM NUMERIC_TMP; +--Testcase 1165: +INSERT INTO NUMERIC_TMP VALUES ('NaN'); +--Testcase 1166: +SELECT f1::int2 FROM NUMERIC_TMP; + f1 +---- + +(1 row) + +--Testcase 1167: +DELETE FROM NUMERIC_TMP; +--Testcase 1168: +INSERT INTO NUMERIC_TMP VALUES ('Infinity'); +--Testcase 1169: +SELECT f1::int2 FROM NUMERIC_TMP; +ERROR: cannot convert infinity to smallint +--Testcase 1170: +DELETE FROM NUMERIC_TMP; +--Testcase 1171: +INSERT INTO NUMERIC_TMP VALUES ('-Infinity'); +--Testcase 1172: +SELECT f1::int2 FROM NUMERIC_TMP; +ERROR: cannot convert infinity to smallint +--Testcase 1173: +DELETE FROM NUMERIC_TMP; +--Testcase 1174: +INSERT INTO NUMERIC_TMP VALUES ('NaN'); +--Testcase 1175: +SELECT f1::int4 FROM NUMERIC_TMP; + f1 +---- + +(1 row) + +--Testcase 1176: +DELETE FROM NUMERIC_TMP; +--Testcase 1177: +INSERT INTO NUMERIC_TMP VALUES ('Infinity'); +--Testcase 1178: +SELECT f1::int4 FROM NUMERIC_TMP; +ERROR: cannot convert infinity to integer +--Testcase 1179: +DELETE FROM NUMERIC_TMP; +--Testcase 1180: +INSERT INTO NUMERIC_TMP VALUES ('-Infinity'); +--Testcase 1181: +SELECT f1::int4 FROM NUMERIC_TMP; +ERROR: cannot convert infinity to integer +--Testcase 1182: +DELETE FROM NUMERIC_TMP; +--Testcase 1183: +INSERT INTO NUMERIC_TMP VALUES ('NaN'); +--Testcase 1184: +SELECT f1::int8 FROM NUMERIC_TMP; + f1 +---- + +(1 row) + +--Testcase 1185: +DELETE FROM NUMERIC_TMP; +--Testcase 1186: +INSERT INTO NUMERIC_TMP VALUES ('Infinity'); +--Testcase 1187: +SELECT f1::int8 FROM NUMERIC_TMP; +ERROR: cannot convert infinity to bigint +--Testcase 1188: +DELETE FROM NUMERIC_TMP; +--Testcase 1189: +INSERT INTO NUMERIC_TMP VALUES ('-Infinity'); +--Testcase 1190: +SELECT f1::int8 FROM NUMERIC_TMP; +ERROR: cannot convert infinity to bigint +-- Simple check that ceil(), floor(), and round() work correctly +--Testcase 601: +CREATE FOREIGN TABLE ceil_floor_round (a numeric OPTIONS (key 'true')) SERVER sqlite_svr; +--Testcase 499: +INSERT INTO ceil_floor_round VALUES ('-5.5'); +--Testcase 500: +INSERT INTO ceil_floor_round VALUES ('-5.499999'); +--Testcase 501: +INSERT INTO ceil_floor_round VALUES ('9.5'); +--Testcase 502: +INSERT INTO ceil_floor_round VALUES ('9.4999999'); +--Testcase 503: +INSERT INTO ceil_floor_round VALUES ('0.0'); +--Testcase 504: +INSERT INTO ceil_floor_round VALUES ('0.0000001'); +--Testcase 505: +INSERT INTO ceil_floor_round VALUES ('-0.000001'); +--Testcase 506: +SELECT a, ceil(a), ceiling(a), floor(a), round(a) FROM ceil_floor_round ORDER BY a; + a | ceil | ceiling | floor | round +-----------+------+---------+-------+------- + -5.5 | -5 | -5 | -6 | -6 + -5.499999 | -5 | -5 | -6 | -5 + -0.000001 | 0 | 0 | -1 | 0 + 0 | 0 | 0 | 0 | 0 + 0.0000001 | 1 | 1 | 0 | 0 + 9.4999999 | 10 | 10 | 9 | 9 + 9.5 | 10 | 10 | 9 | 10 +(7 rows) + +-- Check rounding, it should round ties away from zero. +--Testcase 602: +CREATE FOREIGN TABLE INT4_TMP(f1 int4, f2 int4, id int OPTIONS (key 'true')) SERVER sqlite_svr; +--Testcase 603: +DELETE FROM INT4_TMP; +--Testcase 604: +INSERT INTO INT4_TMP SELECT a FROM generate_series(-5,5) a; +--Testcase 605: +SELECT f1 as pow, + round((-2.5 * 10 ^ f1)::numeric, -f1), + round((-1.5 * 10 ^ f1)::numeric, -f1), + round((-0.5 * 10 ^ f1)::numeric, -f1), + round((0.5 * 10 ^ f1)::numeric, -f1), + round((1.5 * 10 ^ f1)::numeric, -f1), + round((2.5 * 10 ^ f1)::numeric, -f1) +FROM INT4_TMP; + pow | round | round | round | round | round | round +-----+----------+----------+----------+---------+---------+--------- + -5 | -0.00003 | -0.00002 | -0.00001 | 0.00001 | 0.00002 | 0.00003 + -4 | -0.0003 | -0.0002 | -0.0001 | 0.0001 | 0.0002 | 0.0003 + -3 | -0.003 | -0.002 | -0.001 | 0.001 | 0.002 | 0.003 + -2 | -0.03 | -0.02 | -0.01 | 0.01 | 0.02 | 0.03 + -1 | -0.3 | -0.2 | -0.1 | 0.1 | 0.2 | 0.3 + 0 | -3 | -2 | -1 | 1 | 2 | 3 + 1 | -30 | -20 | -10 | 10 | 20 | 30 + 2 | -300 | -200 | -100 | 100 | 200 | 300 + 3 | -3000 | -2000 | -1000 | 1000 | 2000 | 3000 + 4 | -30000 | -20000 | -10000 | 10000 | 20000 | 30000 + 5 | -300000 | -200000 | -100000 | 100000 | 200000 | 300000 +(11 rows) + +-- Testing for width_bucket(). For convenience, we test both the +-- numeric and float8 versions of the function in this file. +-- errors +--Testcase 606: +CREATE FOREIGN TABLE width_bucket_tbl ( + id1 numeric, + id2 numeric, + id3 numeric, + id4 int, + id int OPTIONS (key 'true') +) SERVER sqlite_svr; +--Testcase 607: +DELETE FROM width_bucket_tbl; +--Testcase 608: +INSERT INTO width_bucket_tbl VALUES (5.0, 3.0, 4.0, 0); +--Testcase 609: +SELECT width_bucket(id1, id2, id3, id4) FROM width_bucket_tbl; +ERROR: count must be greater than zero +--Testcase 610: +DELETE FROM width_bucket_tbl; +--Testcase 611: +INSERT INTO width_bucket_tbl VALUES (5.0, 3.0, 4.0, -5); +--Testcase 612: +SELECT width_bucket(id1, id2, id3, id4) FROM width_bucket_tbl; +ERROR: count must be greater than zero +--Testcase 613: +DELETE FROM width_bucket_tbl; +--Testcase 614: +INSERT INTO width_bucket_tbl VALUES (3.5, 3.0, 3.0, 888); +--Testcase 615: +SELECT width_bucket(id1, id2, id3, id4) FROM width_bucket_tbl; +ERROR: lower bound cannot equal upper bound +--Testcase 616: +DELETE FROM width_bucket_tbl; +--Testcase 617: +INSERT INTO width_bucket_tbl VALUES (5.0, 3.0, 4.0, 0); +--Testcase 618: +SELECT width_bucket(id1::float8, id2::float8, id3::float8, id4) FROM width_bucket_tbl; +ERROR: count must be greater than zero +--Testcase 619: +DELETE FROM width_bucket_tbl; +--Testcase 620: +INSERT INTO width_bucket_tbl VALUES (5.0, 3.0, 4.0, -5); +--Testcase 621: +SELECT width_bucket(id1::float8, id2::float8, id3::float8, id4) FROM width_bucket_tbl; +ERROR: count must be greater than zero +--Testcase 622: +DELETE FROM width_bucket_tbl; +--Testcase 623: +INSERT INTO width_bucket_tbl VALUES (3.5, 3.0, 3.0, 888); +--Testcase 624: +SELECT width_bucket(id1::float8, id2::float8, id3::float8, id4) FROM width_bucket_tbl; +ERROR: lower bound cannot equal upper bound +--Testcase 625: +DELETE FROM width_bucket_tbl; +--Testcase 626: +INSERT INTO width_bucket_tbl VALUES ('NaN'::numeric, 3.0, 4.0, 888); +--Testcase 627: +SELECT width_bucket(id1, id2, id3, id4) FROM width_bucket_tbl; + width_bucket +-------------- + +(1 row) + +--Testcase 628: +DELETE FROM width_bucket_tbl; +--Testcase 629: +INSERT INTO width_bucket_tbl VALUES (0, 'NaN'::numeric, 4.0, 888); +--Testcase 630: +SELECT width_bucket(id1::float8, id2, id3::float8, id4) FROM width_bucket_tbl; + width_bucket +-------------- + +(1 row) + +--Testcase 1191: +DELETE FROM width_bucket_tbl; +--Testcase 1192: +INSERT INTO width_bucket_tbl VALUES (2.0, 3.0, '-inf'::numeric, 888); +--Testcase 1193: +SELECT width_bucket(id1, id2, id3, id4) FROM width_bucket_tbl; +ERROR: lower and upper bounds must be finite +--Testcase 1194: +DELETE FROM width_bucket_tbl; +--Testcase 1195: +INSERT INTO width_bucket_tbl VALUES (0, '-inf'::numeric, 4.0 , 888); +--Testcase 1196: +SELECT width_bucket(id1::float8, id2, id3::float8, id4) FROM width_bucket_tbl; +ERROR: lower and upper bounds must be finite +-- normal operation +--Testcase 631: +CREATE FOREIGN TABLE width_bucket_test ( + operand_num numeric OPTIONS (key 'true'), + operand_f8 float8 +) SERVER sqlite_svr; +--COPY width_bucket_test (operand_num) FROM stdin; +--Testcase 507: +INSERT INTO width_bucket_test (operand_num) VALUES +(-5.2), +(-0.0000000001), +(0.000000000001), +(1), +(1.99999999999999), +(2), +(2.00000000000001), +(3), +(4), +(4.5), +(5), +(5.5), +(6), +(7), +(8), +(9), +(9.99999999999999), +(10), +(10.0000000000001); +--Testcase 508: +UPDATE width_bucket_test SET operand_f8 = operand_num::float8; +--Testcase 509: +SELECT + operand_num, + width_bucket(operand_num, 0, 10, 5) AS wb_1, + width_bucket(operand_f8, 0, 10, 5) AS wb_1f, + width_bucket(operand_num, 10, 0, 5) AS wb_2, + width_bucket(operand_f8, 10, 0, 5) AS wb_2f, + width_bucket(operand_num, 2, 8, 4) AS wb_3, + width_bucket(operand_f8, 2, 8, 4) AS wb_3f, + width_bucket(operand_num, 5.0, 5.5, 20) AS wb_4, + width_bucket(operand_f8, 5.0, 5.5, 20) AS wb_4f, + width_bucket(operand_num, -25, 25, 10) AS wb_5, + width_bucket(operand_f8, -25, 25, 10) AS wb_5f + FROM width_bucket_test; + operand_num | wb_1 | wb_1f | wb_2 | wb_2f | wb_3 | wb_3f | wb_4 | wb_4f | wb_5 | wb_5f +------------------+------+-------+------+-------+------+-------+------+-------+------+------- + -5.2 | 0 | 0 | 6 | 6 | 0 | 0 | 0 | 0 | 4 | 4 + -0.0000000001 | 0 | 0 | 6 | 6 | 0 | 0 | 0 | 0 | 5 | 5 + 0.000000000001 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 + 1 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 + 1.99999999999999 | 1 | 1 | 5 | 5 | 0 | 0 | 0 | 0 | 6 | 6 + 2 | 2 | 2 | 5 | 5 | 1 | 1 | 0 | 0 | 6 | 6 + 2.00000000000001 | 2 | 2 | 4 | 4 | 1 | 1 | 0 | 0 | 6 | 6 + 3 | 2 | 2 | 4 | 4 | 1 | 1 | 0 | 0 | 6 | 6 + 4 | 3 | 3 | 4 | 4 | 2 | 2 | 0 | 0 | 6 | 6 + 4.5 | 3 | 3 | 3 | 3 | 2 | 2 | 0 | 0 | 6 | 6 + 5 | 3 | 3 | 3 | 3 | 3 | 3 | 1 | 1 | 7 | 7 + 5.5 | 3 | 3 | 3 | 3 | 3 | 3 | 21 | 21 | 7 | 7 + 6 | 4 | 4 | 3 | 3 | 3 | 3 | 21 | 21 | 7 | 7 + 7 | 4 | 4 | 2 | 2 | 4 | 4 | 21 | 21 | 7 | 7 + 8 | 5 | 5 | 2 | 2 | 5 | 5 | 21 | 21 | 7 | 7 + 9 | 5 | 5 | 1 | 1 | 5 | 5 | 21 | 21 | 7 | 7 + 9.99999999999999 | 5 | 5 | 1 | 1 | 5 | 5 | 21 | 21 | 7 | 7 + 10 | 6 | 6 | 1 | 1 | 5 | 5 | 21 | 21 | 8 | 8 + 10.0000000000001 | 6 | 6 | 0 | 0 | 5 | 5 | 21 | 21 | 8 | 8 +(19 rows) + +-- Check positive and negative infinity: we require +-- finite bucket bounds, but allow an infinite operand +--Testcase 1197: +DELETE FROM width_bucket_tbl; +--Testcase 1198: +INSERT INTO width_bucket_tbl VALUES (0.0, 'Infinity'::numeric , 5, 10); +--Testcase 1199: +SELECT width_bucket(id1::numeric, 'Infinity'::numeric, id3, id4) FROM width_bucket_tbl; -- error +ERROR: lower and upper bounds must be finite +--Testcase 1200: +DELETE FROM width_bucket_tbl; +--Testcase 1201: +INSERT INTO width_bucket_tbl VALUES (0.0, 5, '-Infinity'::numeric, 20); +--Testcase 1202: +SELECT width_bucket(id1::numeric, id2, '-Infinity'::numeric, id4) FROM width_bucket_tbl; -- error +ERROR: lower and upper bounds must be finite +--Testcase 1203: +DELETE FROM width_bucket_tbl; +--Testcase 1204: +INSERT INTO width_bucket_tbl VALUES ('Infinity'::numeric, 1, 10, 10), ('-Infinity'::numeric, 1, 10, 10); +--Testcase 1205: +SELECT width_bucket(id1::numeric, id2, id3, id4) FROM width_bucket_tbl; + width_bucket +-------------- + 11 + 0 +(2 rows) + +--Testcase 510: +DELETE FROM width_bucket_tbl; +-- postgres does not support insert 'Infinity' and '-Infinity' as numeric. +--Testcase 632: +INSERT INTO width_bucket_tbl VALUES (0.0, 0.0, 5, 10); +--Testcase 633: +SELECT width_bucket(id1::float8, 'Infinity'::float8, id3, id4) FROM width_bucket_tbl; -- error +ERROR: lower and upper bounds must be finite +--Testcase 511: +DELETE FROM width_bucket_tbl; +--Testcase 634: +INSERT INTO width_bucket_tbl VALUES (0.0, 5, 0.0, 20); +--Testcase 635: +SELECT width_bucket(id1::float8, id2, 'Infinity'::float8, id4) FROM width_bucket_tbl; -- error +ERROR: lower and upper bounds must be finite +--Testcase 512: +DELETE FROM width_bucket_tbl; +--Testcase 636: +INSERT INTO width_bucket_tbl VALUES (0.0, 1, 10, 10); +--Testcase 637: +SELECT width_bucket('Infinity'::float8, id2, id3, id4), width_bucket('-Infinity'::float8, id2, id3, id4) FROM width_bucket_tbl; + width_bucket | width_bucket +--------------+-------------- + 11 | 0 +(1 row) + +-- Simple test for roundoff error when results should be exact +--Testcase 1445: +DELETE FROM width_bucket_tbl; +--Testcase 1446: +INSERT INTO width_bucket_tbl SELECT x, 10, 100, 9 FROM generate_series(0, 110, 10) x; +--Testcase 1447: +SELECT id1, width_bucket(id1::float8, id2, id3, id4) as flt, + width_bucket(id1::numeric, id2, id3, id4) as num FROM width_bucket_tbl; + id1 | flt | num +-----+-----+----- + 0 | 0 | 0 + 10 | 1 | 1 + 20 | 2 | 2 + 30 | 3 | 3 + 40 | 4 | 4 + 50 | 5 | 5 + 60 | 6 | 6 + 70 | 7 | 7 + 80 | 8 | 8 + 90 | 9 | 9 + 100 | 10 | 10 + 110 | 10 | 10 +(12 rows) + +--Testcase 1448: +DELETE FROM width_bucket_tbl; +--Testcase 1449: +INSERT INTO width_bucket_tbl SELECT x, 100, 10, 9 FROM generate_series(0, 110, 10) x; +--Testcase 1450: +SELECT id1, width_bucket(id1::float8, 100, 10, 9) as flt, + width_bucket(id1::numeric, id2, id3, id4) as num FROM width_bucket_tbl; + id1 | flt | num +-----+-----+----- + 0 | 10 | 10 + 10 | 10 | 10 + 20 | 9 | 9 + 30 | 8 | 8 + 40 | 7 | 7 + 50 | 6 | 6 + 60 | 5 | 5 + 70 | 4 | 4 + 80 | 3 | 3 + 90 | 2 | 2 + 100 | 1 | 1 + 110 | 0 | 0 +(12 rows) + +--Testcase 638: +DROP FOREIGN TABLE width_bucket_test; +-- TO_CHAR() +-- +--Testcase 513: +SELECT to_char(val, '9G999G999G999G999G999') + FROM num_data; + to_char +------------------------ + 0 + 0 + -34,338,492 + 4 + 7,799,461 + 16,397 + 93,902 + -83,028,485 + 74,881 + -24,926,804 +(10 rows) + +--Testcase 514: +SELECT to_char(val, '9G999G999G999G999G999D999G999G999G999G999') + FROM num_data; + to_char +-------------------------------------------- + .000,000,000,000,000 + .000,000,000,000,000 + -34,338,492.215,397,045,000,000 + 4.310,000,000,000,000 + 7,799,461.411,900,000,000,000 + 16,397.038,491,000,000,000 + 93,901.577,630,260,000,000 + -83,028,485.000,000,000,000,000 + 74,881.000,000,000,000,000 + -24,926,804.045,047,420,000,000 +(10 rows) + +--Testcase 515: +SELECT to_char(val, '9999999999999999.999999999999999PR') + FROM num_data; + to_char +------------------------------------ + .000000000000000 + .000000000000000 + <34338492.215397045000000> + 4.310000000000000 + 7799461.411900000000000 + 16397.038491000000000 + 93901.577630260000000 + <83028485.000000000000000> + 74881.000000000000000 + <24926804.045047420000000> +(10 rows) + +--Testcase 516: +SELECT to_char(val, '9999999999999999.999999999999999S') + FROM num_data; + to_char +----------------------------------- + .000000000000000+ + .000000000000000+ + 34338492.215397045000000- + 4.310000000000000+ + 7799461.411900000000000+ + 16397.038491000000000+ + 93901.577630260000000+ + 83028485.000000000000000- + 74881.000000000000000+ + 24926804.045047420000000- +(10 rows) + +--Testcase 517: +SELECT to_char(val, 'MI9999999999999999.999999999999999') FROM num_data; + to_char +----------------------------------- + .000000000000000 + .000000000000000 + - 34338492.215397045000000 + 4.310000000000000 + 7799461.411900000000000 + 16397.038491000000000 + 93901.577630260000000 + - 83028485.000000000000000 + 74881.000000000000000 + - 24926804.045047420000000 +(10 rows) + +--Testcase 518: +SELECT to_char(val, 'FMS9999999999999999.999999999999999') FROM num_data; + to_char +--------------------- + +0. + +0. + -34338492.215397045 + +4.31 + +7799461.4119 + +16397.038491 + +93901.57763026 + -83028485. + +74881. + -24926804.04504742 +(10 rows) + +--Testcase 519: +SELECT to_char(val, 'FM9999999999999999.999999999999999THPR') FROM num_data; + to_char +---------------------- + 0. + 0. + <34338492.215397045> + 4.31 + 7799461.4119 + 16397.038491 + 93901.57763026 + <83028485.> + 74881. + <24926804.04504742> +(10 rows) + +--Testcase 520: +SELECT to_char(val, 'SG9999999999999999.999999999999999th') FROM num_data; + to_char +----------------------------------- + + .000000000000000 + + .000000000000000 + - 34338492.215397045000000 + + 4.310000000000000 + + 7799461.411900000000000 + + 16397.038491000000000 + + 93901.577630260000000 + - 83028485.000000000000000 + + 74881.000000000000000 + - 24926804.045047420000000 +(10 rows) + +--Testcase 521: +SELECT to_char(val, '0999999999999999.999999999999999') FROM num_data; + to_char +----------------------------------- + 0000000000000000.000000000000000 + 0000000000000000.000000000000000 + -0000000034338492.215397045000000 + 0000000000000004.310000000000000 + 0000000007799461.411900000000000 + 0000000000016397.038491000000000 + 0000000000093901.577630260000000 + -0000000083028485.000000000000000 + 0000000000074881.000000000000000 + -0000000024926804.045047420000000 +(10 rows) + +--Testcase 522: +SELECT to_char(val, 'S0999999999999999.999999999999999') FROM num_data; + to_char +----------------------------------- + +0000000000000000.000000000000000 + +0000000000000000.000000000000000 + -0000000034338492.215397045000000 + +0000000000000004.310000000000000 + +0000000007799461.411900000000000 + +0000000000016397.038491000000000 + +0000000000093901.577630260000000 + -0000000083028485.000000000000000 + +0000000000074881.000000000000000 + -0000000024926804.045047420000000 +(10 rows) + +--Testcase 523: +SELECT to_char(val, 'FM0999999999999999.999999999999999') FROM num_data; + to_char +----------------------------- + 0000000000000000. + 0000000000000000. + -0000000034338492.215397045 + 0000000000000004.31 + 0000000007799461.4119 + 0000000000016397.038491 + 0000000000093901.57763026 + -0000000083028485. + 0000000000074881. + -0000000024926804.04504742 +(10 rows) + +--Testcase 524: +SELECT to_char(val, 'FM9999999999999999.099999999999999') FROM num_data; + to_char +--------------------- + .0 + .0 + -34338492.215397045 + 4.31 + 7799461.4119 + 16397.038491 + 93901.57763026 + -83028485.0 + 74881.0 + -24926804.04504742 +(10 rows) + +--Testcase 525: +SELECT to_char(val, 'FM9999999999990999.990999999999999') FROM num_data; + to_char +--------------------- + 0000.000 + 0000.000 + -34338492.215397045 + 0004.310 + 7799461.4119 + 16397.038491 + 93901.57763026 + -83028485.000 + 74881.000 + -24926804.04504742 +(10 rows) + +--Testcase 526: +SELECT to_char(val, 'FM0999999999999999.999909999999999') FROM num_data; + to_char +----------------------------- + 0000000000000000.00000 + 0000000000000000.00000 + -0000000034338492.215397045 + 0000000000000004.31000 + 0000000007799461.41190 + 0000000000016397.038491 + 0000000000093901.57763026 + -0000000083028485.00000 + 0000000000074881.00000 + -0000000024926804.04504742 +(10 rows) + +--Testcase 527: +SELECT to_char(val, 'FM9999999990999999.099999999999999') FROM num_data; + to_char +--------------------- + 0000000.0 + 0000000.0 + -34338492.215397045 + 0000004.31 + 7799461.4119 + 0016397.038491 + 0093901.57763026 + -83028485.0 + 0074881.0 + -24926804.04504742 +(10 rows) + +--Testcase 528: +SELECT to_char(val, 'L9999999999999999.099999999999999') FROM num_data; + to_char +------------------------------------ + .000000000000000 + .000000000000000 + -34338492.215397045000000 + 4.310000000000000 + 7799461.411900000000000 + 16397.038491000000000 + 93901.577630260000000 + -83028485.000000000000000 + 74881.000000000000000 + -24926804.045047420000000 +(10 rows) + +--Testcase 529: +SELECT to_char(val, 'FM9999999999999999.99999999999999') FROM num_data; + to_char +--------------------- + 0. + 0. + -34338492.215397045 + 4.31 + 7799461.4119 + 16397.038491 + 93901.57763026 + -83028485. + 74881. + -24926804.04504742 +(10 rows) + +--Testcase 530: +SELECT to_char(val, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data; + to_char +----------------------------------------------------------------------- + +. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + -3 4 3 3 8 4 9 2 . 2 1 5 3 9 7 0 4 5 0 0 0 0 0 0 0 0 + +4 . 3 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +7 7 9 9 4 6 1 . 4 1 1 9 0 0 0 0 0 0 0 0 0 0 0 0 0 + +1 6 3 9 7 . 0 3 8 4 9 1 0 0 0 0 0 0 0 0 0 0 0 + +9 3 9 0 1 . 5 7 7 6 3 0 2 6 0 0 0 0 0 0 0 0 0 + -8 3 0 2 8 4 8 5 . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + +7 4 8 8 1 . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + -2 4 9 2 6 8 0 4 . 0 4 5 0 4 7 4 2 0 0 0 0 0 0 0 0 0 +(10 rows) + +--Testcase 531: +SELECT to_char(val, 'FMS 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data; + to_char +------------------------------------------------------- + +0 . + +0 . + -3 4 3 3 8 4 9 2 . 2 1 5 3 9 7 0 4 5 + +4 . 3 1 + +7 7 9 9 4 6 1 . 4 1 1 9 + +1 6 3 9 7 . 0 3 8 4 9 1 + +9 3 9 0 1 . 5 7 7 6 3 0 2 6 + -8 3 0 2 8 4 8 5 . + +7 4 8 8 1 . + -2 4 9 2 6 8 0 4 . 0 4 5 0 4 7 4 2 +(10 rows) + +--Testcase 532: +SELECT to_char(val, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM num_data; + to_char +----------------------------------------------------------- + text 9999 "text between quote marks" 0 + text 9999 "text between quote marks" 0 + text -3 9999 433 "text between quote marks" 8492 + text 9999 "text between quote marks" 4 + text 9999 779 "text between quote marks" 9461 + text 9999 1 "text between quote marks" 6397 + text 9999 9 "text between quote marks" 3902 + text -8 9999 302 "text between quote marks" 8485 + text 9999 7 "text between quote marks" 4881 + text -2 9999 492 "text between quote marks" 6804 +(10 rows) + +--Testcase 533: +SELECT to_char(val, '999999SG9999999999') FROM num_data; + to_char +------------------- + + 0 + + 0 + - 34338492 + + 4 + + 7799461 + + 16397 + + 93902 + - 83028485 + + 74881 + - 24926804 +(10 rows) + +--Testcase 534: +SELECT to_char(val, 'FM9999999999999999.999999999999999') FROM num_data; + to_char +--------------------- + 0. + 0. + -34338492.215397045 + 4.31 + 7799461.4119 + 16397.038491 + 93901.57763026 + -83028485. + 74881. + -24926804.04504742 +(10 rows) + +--Testcase 535: +SELECT to_char(val, '9.999EEEE') FROM num_data; + to_char +------------ + 0.000e+00 + 0.000e+00 + -3.434e+07 + 4.310e+00 + 7.799e+06 + 1.640e+04 + 9.390e+04 + -8.303e+07 + 7.488e+04 + -2.493e+07 +(10 rows) + +--Testcase 1476: +DELETE FROM v; +--Testcase 1477: +INSERT INTO v(x) VALUES ('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan'); +--Testcase 1478: +SELECT x, + to_char(x, '9.999EEEE') as numeric, + to_char(x::float8, '9.999EEEE') as float8, + to_char(x::float4, '9.999EEEE') as float4 +FROM v; + x | numeric | float8 | float4 +------------+------------+------------+------------ + 0 | 0.000e+00 | 0.000e+00 | 0.000e+00 + -4.2 | -4.200e+00 | -4.200e+00 | -4.200e+00 + 4200000000 | 4.200e+09 | 4.200e+09 | 4.200e+09 + 0.000012 | 1.200e-05 | 1.200e-05 | 1.200e-05 + Infinity | #.####### | #.####### | #.####### + -Infinity | #.####### | #.####### | #.####### + | | | +(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: +INSERT INTO v(x) VALUES ('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan'); +--Testcase 1481: +SELECT x, + to_char(x, 'MI9999999999.99') as numeric, + to_char(x::float8, 'MI9999999999.99') as float8, + to_char(x::float4, 'MI9999999999.99') as float4 +FROM v; + x | numeric | float8 | float4 +------------+----------------+----------------+---------------- + 0 | .00 | .00 | .00 + -4.2 | - 4.20 | - 4.20 | - 4.20 + 4200000000 | 4200000000.00 | 4200000000.00 | 4200000000 + 0.000012 | .00 | .00 | .00 + Infinity | Infinity | Infinity | Infinity + -Infinity | - Infinity | - Infinity | - Infinity + | | | +(7 rows) + +--Testcase 1482: +DELETE FROM v; +--Testcase 1483: +INSERT INTO v(x) VALUES ('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan'); +--Testcase 1484: +SELECT x, + to_char(x, 'MI99.99') as numeric, + to_char(x::float8, 'MI99.99') as float8, + to_char(x::float4, 'MI99.99') as float4 +FROM v; + x | numeric | float8 | float4 +------------+---------+--------+-------- + 0 | .00 | .00 | .00 + -4.2 | - 4.20 | - 4.20 | - 4.20 + 4200000000 | ##.## | ##.## | ##. + 0.000012 | .00 | .00 | .00 + Infinity | ##.## | ##.## | ##. + -Infinity | -##.## | -##.## | -##. + | | | +(7 rows) + +--Testcase 536: +DELETE FROM ceil_floor_round; +--Testcase 537: +INSERT INTO ceil_floor_round VALUES ('100'::numeric); +--Testcase 538: +SELECT to_char(a, 'FM999.9') FROM ceil_floor_round; + to_char +--------- + 100. +(1 row) + +--Testcase 539: +SELECT to_char(a, 'FM999.') FROM ceil_floor_round; + to_char +--------- + 100 +(1 row) + +--Testcase 540: +SELECT to_char(a, 'FM999') FROM ceil_floor_round; + to_char +--------- + 100 +(1 row) + +-- Check parsing of literal text in a format string +--Testcase 541: +SELECT to_char(a, 'foo999') FROM ceil_floor_round; + to_char +--------- + foo 100 +(1 row) + +--Testcase 542: +SELECT to_char(a, 'f\oo999') FROM ceil_floor_round; + to_char +---------- + f\oo 100 +(1 row) + +--Testcase 543: +SELECT to_char(a, 'f\\oo999') FROM ceil_floor_round; + to_char +----------- + f\\oo 100 +(1 row) + +--Testcase 544: +SELECT to_char(a, 'f\"oo999') FROM ceil_floor_round; + to_char +---------- + f"oo 100 +(1 row) + +--Testcase 545: +SELECT to_char(a, 'f\\"oo999') FROM ceil_floor_round; + to_char +----------- + f\"oo 100 +(1 row) + +--Testcase 546: +SELECT to_char(a, 'f"ool"999') FROM ceil_floor_round; + to_char +---------- + fool 100 +(1 row) + +--Testcase 547: +SELECT to_char(a, 'f"\ool"999') FROM ceil_floor_round; + to_char +---------- + fool 100 +(1 row) + +--Testcase 548: +SELECT to_char(a, 'f"\\ool"999') FROM ceil_floor_round; + to_char +----------- + f\ool 100 +(1 row) + +--Testcase 549: +SELECT to_char(a, 'f"ool\"999') FROM ceil_floor_round; + to_char +---------- + fool"999 +(1 row) + +--Testcase 550: +SELECT to_char(a, 'f"ool\\"999') FROM ceil_floor_round; + to_char +----------- + fool\ 100 +(1 row) + +-- TO_NUMBER() +-- +--Testcase 639: +create foreign table to_number_tbl (a text, id int options (key 'true')) server sqlite_svr; +--Testcase 1211: +SET lc_numeric = 'C'; +--Testcase 640: +DELETE FROM to_number_tbl; +--Testcase 641: +INSERT INTO to_number_tbl VALUES ('-34,338,492'); +--Testcase 642: +SELECT to_number(a, '99G999G999') FROM to_number_tbl; + to_number +----------- + -34338492 +(1 row) + +--Testcase 643: +DELETE FROM to_number_tbl; +--Testcase 644: +INSERT INTO to_number_tbl VALUES ('-34,338,492.654,878'); +--Testcase 645: +SELECT to_number(a, '99G999G999D999G999') FROM to_number_tbl; + to_number +------------------ + -34338492.654878 +(1 row) + +--Testcase 646: +DELETE FROM to_number_tbl; +--Testcase 647: +INSERT INTO to_number_tbl VALUES ('<564646.654564>'); +--Testcase 648: +SELECT to_number(a, '999999.999999PR') FROM to_number_tbl; + to_number +---------------- + -564646.654564 +(1 row) + +--Testcase 649: +DELETE FROM to_number_tbl; +--Testcase 650: +INSERT INTO to_number_tbl VALUES ('0.00001-'); +--Testcase 651: +SELECT to_number(a, '9.999999S') FROM to_number_tbl; + to_number +----------- + -0.00001 +(1 row) + +--Testcase 652: +DELETE FROM to_number_tbl; +--Testcase 653: +INSERT INTO to_number_tbl VALUES ('5.01-'); +--Testcase 654: +SELECT to_number(a, 'FM9.999999S') FROM to_number_tbl; + to_number +----------- + -5.01 +(1 row) + +--Testcase 655: +DELETE FROM to_number_tbl; +--Testcase 656: +INSERT INTO to_number_tbl VALUES ('5.01-'); +--Testcase 657: +SELECT to_number(a, 'FM9.999999MI') FROM to_number_tbl; + to_number +----------- + -5.01 +(1 row) + +--Testcase 658: +DELETE FROM to_number_tbl; +--Testcase 659: +INSERT INTO to_number_tbl VALUES ('5 4 4 4 4 8 . 7 8'); +--Testcase 660: +SELECT to_number(a, '9 9 9 9 9 9 . 9 9') FROM to_number_tbl; + to_number +----------- + 544448.78 +(1 row) + +--Testcase 661: +DELETE FROM to_number_tbl; +--Testcase 662: +INSERT INTO to_number_tbl VALUES ('.01'); +--Testcase 663: +SELECT to_number(a, 'FM9.99') FROM to_number_tbl; + to_number +----------- + 0.01 +(1 row) + +--Testcase 664: +DELETE FROM to_number_tbl; +--Testcase 665: +INSERT INTO to_number_tbl VALUES ('.0'); +--Testcase 666: +SELECT to_number(a, '99999999.99999999') FROM to_number_tbl; + to_number +----------- + 0.0 +(1 row) + +--Testcase 667: +DELETE FROM to_number_tbl; +--Testcase 668: +INSERT INTO to_number_tbl VALUES ('0'); +--Testcase 669: +SELECT to_number(a, '99.99') FROM to_number_tbl; + to_number +----------- + 0 +(1 row) + +--Testcase 670: +DELETE FROM to_number_tbl; +--Testcase 671: +INSERT INTO to_number_tbl VALUES ('.-01'); +--Testcase 672: +SELECT to_number(a, 'S99.99') FROM to_number_tbl; + to_number +----------- + -0.01 +(1 row) + +--Testcase 673: +DELETE FROM to_number_tbl; +--Testcase 674: +INSERT INTO to_number_tbl VALUES ('.01-'); +--Testcase 675: +SELECT to_number(a, '99.99S') FROM to_number_tbl; + to_number +----------- + -0.01 +(1 row) + +--Testcase 676: +DELETE FROM to_number_tbl; +--Testcase 677: +INSERT INTO to_number_tbl VALUES (' . 0 1-'); +--Testcase 678: +SELECT to_number(a, ' 9 9 . 9 9 S') FROM to_number_tbl; + to_number +----------- + -0.01 +(1 row) + +--Testcase 679: +DELETE FROM to_number_tbl; +--Testcase 680: +INSERT INTO to_number_tbl VALUES ('34,50'); +--Testcase 681: +SELECT to_number(a,'999,99') FROM to_number_tbl; + to_number +----------- + 3450 +(1 row) + +--Testcase 682: +DELETE FROM to_number_tbl; +--Testcase 683: +INSERT INTO to_number_tbl VALUES ('123,000'); +--Testcase 684: +SELECT to_number(a,'999G') FROM to_number_tbl; + to_number +----------- + 123 +(1 row) + +--Testcase 685: +DELETE FROM to_number_tbl; +--Testcase 686: +INSERT INTO to_number_tbl VALUES ('123456'); +--Testcase 687: +SELECT to_number(a,'999G999') FROM to_number_tbl; + to_number +----------- + 123456 +(1 row) + +--Testcase 688: +DELETE FROM to_number_tbl; +--Testcase 689: +INSERT INTO to_number_tbl VALUES ('$1234.56'); +--Testcase 690: +SELECT to_number(a,'L9,999.99') FROM to_number_tbl; + to_number +----------- + 1234.56 +(1 row) + +--Testcase 691: +DELETE FROM to_number_tbl; +--Testcase 692: +INSERT INTO to_number_tbl VALUES ('$1234.56'); +--Testcase 693: +SELECT to_number(a,'L99,999.99') FROM to_number_tbl; + to_number +----------- + 1234.56 +(1 row) + +--Testcase 694: +DELETE FROM to_number_tbl; +--Testcase 695: +INSERT INTO to_number_tbl VALUES ('$1,234.56'); +--Testcase 696: +SELECT to_number(a,'L99,999.99') FROM to_number_tbl; + to_number +----------- + 1234.56 +(1 row) + +--Testcase 697: +DELETE FROM to_number_tbl; +--Testcase 698: +INSERT INTO to_number_tbl VALUES ('1234.56'); +--Testcase 699: +SELECT to_number(a,'L99,999.99') FROM to_number_tbl; + to_number +----------- + 1234.56 +(1 row) + +--Testcase 700: +DELETE FROM to_number_tbl; +--Testcase 701: +INSERT INTO to_number_tbl VALUES ('1,234.56'); +--Testcase 702: +SELECT to_number(a,'L99,999.99') FROM to_number_tbl; + to_number +----------- + 1234.56 +(1 row) + +--Testcase 703: +DELETE FROM to_number_tbl; +--Testcase 704: +INSERT INTO to_number_tbl VALUES ('42nd'); +--Testcase 705: +SELECT to_number(a, '99th') FROM to_number_tbl; + to_number +----------- + 42 +(1 row) + +--Testcase 1212: +RESET lc_numeric; +-- +-- Input syntax +-- +--Testcase 706: +CREATE FOREIGN TABLE num_input_test (n1 numeric) SERVER sqlite_svr; +-- good inputs +--Testcase 551: +INSERT INTO num_input_test(n1) VALUES (' 123'); +--Testcase 552: +INSERT INTO num_input_test(n1) VALUES (' 3245874 '); +--Testcase 553: +INSERT INTO num_input_test(n1) VALUES (' -93853'); +--Testcase 554: +INSERT INTO num_input_test(n1) VALUES ('555.50'); +--Testcase 555: +INSERT INTO num_input_test(n1) VALUES ('-555.50'); +--Testcase 556: +INSERT INTO num_input_test(n1) VALUES ('NaN '); +--Testcase 557: +INSERT INTO num_input_test(n1) VALUES (' nan'); +--Testcase 1213: +INSERT INTO num_input_test(n1) VALUES (' inf '); +--Testcase 1214: +INSERT INTO num_input_test(n1) VALUES (' +inf '); +--Testcase 1215: +INSERT INTO num_input_test(n1) VALUES (' -inf '); +--Testcase 1216: +INSERT INTO num_input_test(n1) VALUES (' Infinity '); +--Testcase 1217: +INSERT INTO num_input_test(n1) VALUES (' +inFinity '); +--Testcase 1218: +INSERT INTO num_input_test(n1) VALUES (' -INFINITY '); +-- bad inputs +--Testcase 558: +INSERT INTO num_input_test(n1) VALUES (' '); +ERROR: invalid input syntax for type numeric: " " +LINE 1: INSERT INTO num_input_test(n1) VALUES (' '); + ^ +--Testcase 559: +INSERT INTO num_input_test(n1) VALUES (' 1234 %'); +ERROR: invalid input syntax for type numeric: " 1234 %" +LINE 1: INSERT INTO num_input_test(n1) VALUES (' 1234 %'); + ^ +--Testcase 560: +INSERT INTO num_input_test(n1) VALUES ('xyz'); +ERROR: invalid input syntax for type numeric: "xyz" +LINE 1: INSERT INTO num_input_test(n1) VALUES ('xyz'); + ^ +--Testcase 561: +INSERT INTO num_input_test(n1) VALUES ('- 1234'); +ERROR: invalid input syntax for type numeric: "- 1234" +LINE 1: INSERT INTO num_input_test(n1) VALUES ('- 1234'); + ^ +--Testcase 562: +INSERT INTO num_input_test(n1) VALUES ('5 . 0'); +ERROR: invalid input syntax for type numeric: "5 . 0" +LINE 1: INSERT INTO num_input_test(n1) VALUES ('5 . 0'); + ^ +--Testcase 563: +INSERT INTO num_input_test(n1) VALUES ('5. 0 '); +ERROR: invalid input syntax for type numeric: "5. 0 " +LINE 1: INSERT INTO num_input_test(n1) VALUES ('5. 0 '); + ^ +--Testcase 564: +INSERT INTO num_input_test(n1) VALUES (''); +ERROR: invalid input syntax for type numeric: "" +LINE 1: INSERT INTO num_input_test(n1) VALUES (''); + ^ +--Testcase 565: +INSERT INTO num_input_test(n1) VALUES (' N aN '); +ERROR: invalid input syntax for type numeric: " N aN " +LINE 1: INSERT INTO num_input_test(n1) VALUES (' N aN '); + ^ +--Testcase 1219: +INSERT INTO num_input_test(n1) VALUES ('+ infinity'); +ERROR: invalid input syntax for type numeric: "+ infinity" +LINE 1: INSERT INTO num_input_test(n1) VALUES ('+ infinity'); + ^ +--Testcase 566: +SELECT * FROM num_input_test; + n1 +----------- + 123 + 3245874 + -93853 + 555.5 + -555.5 + + + Infinity + Infinity + -Infinity + Infinity + Infinity + -Infinity +(13 rows) + +-- +-- Test precision and scale typemods +-- +--Testcase 1557: +CREATE FOREIGN TABLE num_typemod_test ( + millions numeric(3, -6), + thousands numeric(3, -3), + units numeric(3, 0), + thousandths numeric(3, 3), + millionths numeric(3, 6) +) SERVER sqlite_svr; +--Testcase 1558: +\d num_typemod_test + Foreign table "public.num_typemod_test" + Column | Type | Collation | Nullable | Default | FDW options +-------------+---------------+-----------+----------+---------+------------- + millions | numeric(3,-6) | | | | + thousands | numeric(3,-3) | | | | + units | numeric(3,0) | | | | + thousandths | numeric(3,3) | | | | + millionths | numeric(3,6) | | | | +Server: sqlite_svr + +-- rounding of valid inputs +--Testcase 1559: +INSERT INTO num_typemod_test VALUES (123456, 123, 0.123, 0.000123, 0.000000123); +--Testcase 1560: +INSERT INTO num_typemod_test VALUES (654321, 654, 0.654, 0.000654, 0.000000654); +--Testcase 1561: +INSERT INTO num_typemod_test VALUES (2345678, 2345, 2.345, 0.002345, 0.000002345); +--Testcase 1562: +INSERT INTO num_typemod_test VALUES (7654321, 7654, 7.654, 0.007654, 0.000007654); +--Testcase 1563: +INSERT INTO num_typemod_test VALUES (12345678, 12345, 12.345, 0.012345, 0.000012345); +--Testcase 1564: +INSERT INTO num_typemod_test VALUES (87654321, 87654, 87.654, 0.087654, 0.000087654); +--Testcase 1565: +INSERT INTO num_typemod_test VALUES (123456789, 123456, 123.456, 0.123456, 0.000123456); +--Testcase 1566: +INSERT INTO num_typemod_test VALUES (987654321, 987654, 987.654, 0.987654, 0.000987654); +--Testcase 1567: +INSERT INTO num_typemod_test VALUES ('NaN', 'NaN', 'NaN', 'NaN', 'NaN'); +--Testcase 1568: +SELECT scale(millions), * FROM num_typemod_test ORDER BY millions; + scale | millions | thousands | units | thousandths | millionths +-------+-----------+-----------+-------+-------------+------------ + 0 | 0 | 0 | 0 | 0 | 0 + 0 | 1000000 | 1000 | 1 | 0.001 | 0.000001 + 0 | 2000000 | 2000 | 2 | 0.002 | 0.000002 + 0 | 8000000 | 8000 | 8 | 0.008 | 0.000008 + 0 | 12000000 | 12000 | 12 | 0.012 | 0.000012 + 0 | 88000000 | 88000 | 88 | 0.088 | 0.000088 + 0 | 123000000 | 123000 | 123 | 0.123 | 0.000123 + 0 | 988000000 | 988000 | 988 | 0.988 | 0.000988 + | | | | | +(9 rows) + +-- invalid inputs +--Testcase 1569: +INSERT INTO num_typemod_test (millions) VALUES ('inf'); +ERROR: numeric field overflow +DETAIL: A field with precision 3, scale -6 cannot hold an infinite value. +--Testcase 1570: +INSERT INTO num_typemod_test (millions) VALUES (999500000); +ERROR: numeric field overflow +DETAIL: A field with precision 3, scale -6 must round to an absolute value less than 10^9. +--Testcase 1571: +INSERT INTO num_typemod_test (thousands) VALUES (999500); +ERROR: numeric field overflow +DETAIL: A field with precision 3, scale -3 must round to an absolute value less than 10^6. +--Testcase 1572: +INSERT INTO num_typemod_test (units) VALUES (999.5); +ERROR: numeric field overflow +DETAIL: A field with precision 3, scale 0 must round to an absolute value less than 10^3. +--Testcase 1573: +INSERT INTO num_typemod_test (thousandths) VALUES (0.9995); +ERROR: numeric field overflow +DETAIL: A field with precision 3, scale 3 must round to an absolute value less than 1. +--Testcase 1574: +INSERT INTO num_typemod_test (millionths) VALUES (0.0009995); +ERROR: numeric field overflow +DETAIL: A field with precision 3, scale 6 must round to an absolute value less than 10^-3. +-- +-- Test some corner cases for multiplication +-- +--Testcase 707: +CREATE FOREIGN TABLE num_tmp (n1 numeric, n2 numeric, id int options (key 'true')) SERVER sqlite_svr; +--Testcase 708: +INSERT INTO num_tmp VALUES (4790999999999999999999999999999999999999999999999999999999999999999999999999999999999999, 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); +--Testcase 709: +SELECT n1 * n2 FROM num_tmp; + ?column? +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 47910000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +(1 row) + +--Testcase 710: +DELETE FROM num_tmp; +--Testcase 711: +INSERT INTO num_tmp VALUES (4789999999999999999999999999999999999999999999999999999999999999999999999999999999999999, 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); +--Testcase 712: +SELECT n1 * n2 FROM num_tmp; + ?column? +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 47900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +(1 row) + +--Testcase 713: +DELETE FROM num_tmp; +--Testcase 714: +INSERT INTO num_tmp VALUES (4770999999999999999999999999999999999999999999999999999999999999999999999999999999999999, 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); +--Testcase 715: +SELECT n1 * n2 FROM num_tmp; + ?column? +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 47710000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +(1 row) + +--Testcase 716: +DELETE FROM num_tmp; +--Testcase 717: +INSERT INTO num_tmp VALUES (4769999999999999999999999999999999999999999999999999999999999999999999999999999999999999, 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999); +--Testcase 718: +SELECT n1 * n2 FROM num_tmp; + ?column? +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 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 +-- +--Testcase 719: +DELETE FROM num_tmp; +--Testcase 720: +INSERT INTO num_tmp VALUES (999999999999999999999, 1000000000000000000000); +--Testcase 721: +SELECT n1::numeric / n2 FROM num_tmp; + ?column? +------------------------ + 1.00000000000000000000 +(1 row) + +--Testcase 722: +DELETE FROM num_tmp; +--Testcase 723: +INSERT INTO num_tmp VALUES (999999999999999999999, 1000000000000000000000); +--Testcase 724: +SELECT div(n1::numeric, n2) FROM num_tmp; + div +----- + 1 +(1 row) + +--Testcase 725: +SELECT mod(n1::numeric, n2) FROM num_tmp; + mod +----- + 0 +(1 row) + +--Testcase 726: +SELECT div(-n1::numeric, n2) FROM num_tmp; + div +----- + -1 +(1 row) + +--Testcase 727: +SELECT mod(-n1::numeric, n2) FROM num_tmp; + mod +----- + 0 +(1 row) + +--Testcase 728: +select div(-n1::numeric,n2)*n2 + mod(-n1::numeric,n2) FROM num_tmp; + ?column? +------------------------- + -1000000000000000000000 +(1 row) + +--Testcase 729: +DELETE FROM num_tmp; +--Testcase 730: +INSERT INTO num_tmp VALUES (70.0,70); +--Testcase 731: +select mod (n1, n2) FROM num_tmp; + mod +----- + 0 +(1 row) + +--Testcase 732: +select div (n1, n2) FROM num_tmp; + div +----- + 1 +(1 row) + +--Testcase 733: +select n1 / n2 FROM num_tmp; + ?column? +------------------------ + 1.00000000000000000000 +(1 row) + +--Testcase 734: +DELETE FROM num_tmp; +--Testcase 735: +INSERT INTO num_tmp VALUES (12345678901234567890, 123); +--Testcase 736: +select n1 % n2 FROM num_tmp; + ?column? +---------- + 49 +(1 row) + +--Testcase 737: +select n1 / n2 FROM num_tmp; + ?column? +-------------------- + 100371373180768837 +(1 row) + +--Testcase 738: +select div(n1, n2) FROM num_tmp; + div +-------------------- + 100371373180768837 +(1 row) + +--Testcase 739: +select div(n1, n2) * n2 + n1 % n2 FROM num_tmp; + ?column? +---------------------- + 12345678901234567000 +(1 row) + +-- +-- Test some corner cases for square root +-- +--Testcase 740: +DELETE FROM num_tmp; +--Testcase 741: +INSERT INTO num_tmp VALUES (1.000000000000003::numeric); +--Testcase 742: +SELECT sqrt(n1) FROM num_tmp; + sqrt +------------------- + 1.000000000000001 +(1 row) + +--Testcase 743: +DELETE FROM num_tmp; +--Testcase 744: +INSERT INTO num_tmp VALUES (1.000000000000004::numeric); +--Testcase 745: +SELECT sqrt(n1) FROM num_tmp; + sqrt +------------------- + 1.000000000000002 +(1 row) + +--Testcase 746: +DELETE FROM num_tmp; +--Testcase 747: +INSERT INTO num_tmp VALUES (96627521408608.56340355805::numeric); +--Testcase 748: +SELECT sqrt(n1) FROM num_tmp; + sqrt +------------------- + 9829929.878112486 +(1 row) + +--Testcase 749: +DELETE FROM num_tmp; +--Testcase 750: +INSERT INTO num_tmp VALUES (96627521408608.56340355806::numeric); +--Testcase 751: +SELECT sqrt(n1) FROM num_tmp; + sqrt +------------------- + 9829929.878112486 +(1 row) + +--Testcase 752: +DELETE FROM num_tmp; +--Testcase 753: +INSERT INTO num_tmp VALUES (515549506212297735.073688290367::numeric); +--Testcase 754: +SELECT sqrt(n1) FROM num_tmp; + sqrt +------------------- + 718017761.7665859 +(1 row) + +--Testcase 755: +DELETE FROM num_tmp; +--Testcase 756: +INSERT INTO num_tmp VALUES (515549506212297735.073688290368::numeric); +--Testcase 757: +SELECT sqrt(n1) FROM num_tmp; + sqrt +------------------- + 718017761.7665859 +(1 row) + +--Testcase 758: +DELETE FROM num_tmp; +--Testcase 759: +INSERT INTO num_tmp VALUES (8015491789940783531003294973900306::numeric); +--Testcase 760: +SELECT sqrt(n1) FROM num_tmp; + sqrt +------------------- + 89529278953540020 +(1 row) + +--Testcase 761: +DELETE FROM num_tmp; +--Testcase 762: +INSERT INTO num_tmp VALUES (8015491789940783531003294973900307::numeric); +--Testcase 763: +SELECT sqrt(n1) FROM num_tmp; + sqrt +------------------- + 89529278953540020 +(1 row) + +-- +-- Test code path for raising to integer powers +-- +--Testcase 764: +DELETE FROM num_tmp; +--Testcase 765: +INSERT INTO num_tmp VALUES (10.0, -2147483648); +--Testcase 766: +SELECT n1 ^ n2 as rounds_to_zero FROM num_tmp; + rounds_to_zero +-------------------- + 0.0000000000000000 +(1 row) + +--Testcase 767: +DELETE FROM num_tmp; +--Testcase 768: +INSERT INTO num_tmp VALUES (10.0, -2147483647); +--Testcase 769: +SELECT n1 ^ n2 as rounds_to_zero FROM num_tmp; + rounds_to_zero +-------------------- + 0.0000000000000000 +(1 row) + +--Testcase 770: +DELETE FROM num_tmp; +--Testcase 771: +INSERT INTO num_tmp VALUES (10.0, 2147483647); +--Testcase 772: +SELECT n1 ^ n2 as overflows FROM num_tmp; +ERROR: value overflows numeric format +--Testcase 773: +DELETE FROM num_tmp; +--Testcase 774: +INSERT INTO num_tmp VALUES (117743296169.0, -1000000000); +--Testcase 775: +SELECT n1 ^ n2 as overflows FROM num_tmp; + overflows +-------------------- + 0.0000000000000000 +(1 row) + +-- cases that used to return inaccurate results +--Testcase 776: +DELETE FROM num_tmp; +--Testcase 777: +INSERT INTO num_tmp VALUES (3.789, 21); +--Testcase 778: +SELECT n1 ^ n2 FROM num_tmp; + ?column? +-------------------------------- + 1409343026052.8716016316022141 +(1 row) + +--Testcase 779: +DELETE FROM num_tmp; +--Testcase 780: +INSERT INTO num_tmp VALUES (3.789, 35); +--Testcase 781: +SELECT n1 ^ n2 FROM num_tmp; + ?column? +---------------------------------------- + 177158169650516670809.3820586142670135 +(1 row) + +--Testcase 782: +DELETE FROM num_tmp; +--Testcase 783: +INSERT INTO num_tmp VALUES (1.2, 345); +--Testcase 784: +SELECT n1 ^ n2 FROM num_tmp; + ?column? +----------------------------------------------- + 2077446682327378559843444695.5827049735727869 +(1 row) + +--Testcase 785: +DELETE FROM num_tmp; +--Testcase 786: +INSERT INTO num_tmp VALUES (0.12, (-20)); +--Testcase 787: +SELECT n1 ^ n2 FROM num_tmp; + ?column? +-------------------------------------- + 2608405330458882702.5529619561355838 +(1 row) + +--Testcase 1220: +DELETE FROM num_tmp; +--Testcase 1221: +INSERT INTO num_tmp VALUES (1.000000000123, (-2147483648)); +--Testcase 1222: +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) + +--Testcase 1575: +DELETE FROM num_tmp; +--Testcase 1576: +INSERT INTO num_tmp VALUES ((1 - 1.500012345678e-1000), 1.45e1003); +ERROR: "14500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" is out of range for type double precision +--Testcase 1577: +SELECT round(((1 - 1.500012345678e-1000) ^ 1.45e1003) * 1e1000) FROM num_tmp; + round +------- +(0 rows) + +-- 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; + ?column? +------------------------------------------- + 104825960103961013959336.4983657883169110 +(1 row) + +--Testcase 791: +DELETE FROM num_tmp; +--Testcase 792: +INSERT INTO num_tmp VALUES (0.5678, (-85)); +--Testcase 793: +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 +-- +-- special cases +--Testcase 794: +DELETE FROM num_tmp; +--Testcase 795: +INSERT INTO num_tmp VALUES (0.0, 0.0); +--Testcase 796: +select n1 ^ n2 FROM num_tmp; + ?column? +-------------------- + 1.0000000000000000 +(1 row) + +--Testcase 797: +DELETE FROM num_tmp; +--Testcase 798: +INSERT INTO num_tmp VALUES ((-12.34), 0.0); +--Testcase 799: +select n1 ^ n2 FROM num_tmp; + ?column? +-------------------- + 1.0000000000000000 +(1 row) + +--Testcase 800: +DELETE FROM num_tmp; +--Testcase 801: +INSERT INTO num_tmp VALUES (12.34, 0.0); +--Testcase 802: +select n1 ^ n2 FROM num_tmp; + ?column? +-------------------- + 1.0000000000000000 +(1 row) + +--Testcase 803: +DELETE FROM num_tmp; +--Testcase 804: +INSERT INTO num_tmp VALUES (0.0, 12.34); +--Testcase 805: +select n1 ^ n2 FROM num_tmp; + ?column? +-------------------- + 0.0000000000000000 +(1 row) + +-- NaNs +--Testcase 806: +DELETE FROM num_tmp; +--Testcase 807: +INSERT INTO num_tmp VALUES ('NaN'::numeric, 'NaN'::numeric); +--Testcase 808: +select n1 ^ n2 FROM num_tmp; + ?column? +---------- + +(1 row) + +--Testcase 809: +DELETE FROM num_tmp; +--Testcase 810: +INSERT INTO num_tmp VALUES ('NaN'::numeric, 0); +--Testcase 811: +select n1 ^ n2 FROM num_tmp; + ?column? +---------- + +(1 row) + +--Testcase 812: +DELETE FROM num_tmp; +--Testcase 813: +INSERT INTO num_tmp VALUES ('NaN'::numeric, 1); +--Testcase 814: +select n1 ^ n2 FROM num_tmp; + ?column? +---------- + +(1 row) + +--Testcase 815: +DELETE FROM num_tmp; +--Testcase 816: +INSERT INTO num_tmp VALUES (0, 'NaN'::numeric); +--Testcase 817: +select n1 ^ n2 FROM num_tmp; + ?column? +---------- + +(1 row) + +--Testcase 818: +DELETE FROM num_tmp; +--Testcase 819: +INSERT INTO num_tmp VALUES (1, 'NaN'::numeric); +--Testcase 820: +select n1 ^ n2 FROM num_tmp; + ?column? +---------- + +(1 row) + +-- invalid inputs +--Testcase 821: +DELETE FROM num_tmp; +--Testcase 822: +INSERT INTO num_tmp VALUES (0.0, (-12.34)); +--Testcase 823: +select n1 ^ n2 FROM num_tmp; +ERROR: zero raised to a negative power is undefined +--Testcase 824: +DELETE FROM num_tmp; +--Testcase 825: +INSERT INTO num_tmp VALUES ((-12.34), 1.2); +--Testcase 826: +select n1 ^ n2 FROM num_tmp; +ERROR: a negative number raised to a non-integer power yields a complex result +-- cases that used to generate inaccurate results +--Testcase 827: +DELETE FROM num_tmp; +--Testcase 828: +INSERT INTO num_tmp VALUES (32.1, 9.8); +--Testcase 829: +select n1 ^ n2 FROM num_tmp; + ?column? +-------------------- + 580429286790711.10 +(1 row) + +--Testcase 830: +DELETE FROM num_tmp; +--Testcase 831: +INSERT INTO num_tmp VALUES (32.1, (-9.8)); +--Testcase 832: +select n1 ^ n2 FROM num_tmp; + ?column? +---------------------------------- + 0.000000000000001722862754788209 +(1 row) + +--Testcase 833: +DELETE FROM num_tmp; +--Testcase 834: +INSERT INTO num_tmp VALUES (12.3, 45.6); +--Testcase 835: +select n1 ^ n2 FROM num_tmp; + ?column? +------------------------------------------------------ + 50081010321492803393171165777624533697036806969694.9 +(1 row) + +--Testcase 836: +DELETE FROM num_tmp; +--Testcase 837: +INSERT INTO num_tmp VALUES (12.3, (-45.6)); +--Testcase 838: +select n1 ^ n2 FROM num_tmp; + ?column? +--------------------------------------------------------------------- + 0.00000000000000000000000000000000000000000000000001996764828785491 +(1 row) + +-- big test +--Testcase 839: +DELETE FROM num_tmp; +--Testcase 840: +INSERT INTO num_tmp VALUES (1.234, 5678); +--Testcase 841: +select n1 ^ n2 FROM num_tmp; + ?column? +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 307239295662090741644584872593956173493568238595074141254349565406661439636598896798876823220904084953233015553994854875890890858118656468658643918169805277399402542281777901029346337707622181574346585989613344285010764501017625366742865066948856161360224801370482171458030533346309750557140549621313515752078638620714732831815297168231790779296290266207315344008883935010274044001522606235576584215999260117523114297033944018699691024106823438431754073086813382242140602291215149759520833200152654884259619588924545324.5973362312547382 +(1 row) + +-- +-- Tests for EXP() +-- +-- special cases +--Testcase 842: +DELETE FROM num_tmp; +--Testcase 843: +INSERT INTO num_tmp VALUES (0.0); +--Testcase 844: +select exp(n1) from num_tmp; + exp +-------------------- + 1.0000000000000000 +(1 row) + +--Testcase 845: +DELETE FROM num_tmp; +--Testcase 846: +INSERT INTO num_tmp VALUES (1.0); +--Testcase 847: +select exp(n1) from num_tmp; + exp +-------------------- + 2.7182818284590452 +(1 row) + +--Testcase 848: +DELETE FROM num_tmp; +--Testcase 849: +INSERT INTO num_tmp VALUES (1.0::numeric(71,70)); +--Testcase 850: +select exp(n1) from num_tmp; + exp +-------------------- + 2.7182818284590452 +(1 row) + +--Testcase 1223: +DELETE FROM num_tmp; +--Testcase 1224: +INSERT INTO num_tmp VALUES ('nan'::numeric); +--Testcase 1225: +select exp(n1) from num_tmp; + exp +----- + +(1 row) + +--Testcase 1226: +DELETE FROM num_tmp; +--Testcase 1227: +INSERT INTO num_tmp VALUES ('inf'::numeric); +--Testcase 1228: +select exp(n1) from num_tmp; + exp +---------- + Infinity +(1 row) + +--Testcase 1229: +DELETE FROM num_tmp; +--Testcase 1230: +INSERT INTO num_tmp VALUES ('-inf'::numeric); +--Testcase 1231: +select exp(n1) from num_tmp; + exp +----- + 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; +--Testcase 852: +INSERT INTO num_tmp VALUES (32.999); +--Testcase 853: +select exp(n1) from num_tmp; + exp +--------------------- + 214429043492155.053 +(1 row) + +--Testcase 854: +DELETE FROM num_tmp; +--Testcase 855: +INSERT INTO num_tmp VALUES (-32.999); +--Testcase 856: +select exp(n1) from num_tmp; + exp +---------------------------------- + 0.000000000000004663547361468248 +(1 row) + +--Testcase 857: +DELETE FROM num_tmp; +--Testcase 858: +INSERT INTO num_tmp VALUES (123.456); +--Testcase 859: +select exp(n1) from num_tmp; + exp +------------------------------------------------------------ + 413294435277809344957685441227343146614594393746575438.725 +(1 row) + +--Testcase 860: +DELETE FROM num_tmp; +--Testcase 861: +INSERT INTO num_tmp VALUES (-123.456); +--Testcase 862: +select exp(n1) from num_tmp; + exp +------------------------------------------------------------------------- + 0.000000000000000000000000000000000000000000000000000002419582541264601 +(1 row) + +-- big test +--Testcase 863: +DELETE FROM num_tmp; +--Testcase 864: +INSERT INTO num_tmp VALUES (1234.5678); +--Testcase 865: +select exp(n1) from num_tmp; + exp +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + 146549072930959479983482138503979804217622199675223653966270157446954995433819741094410764947112047906012815540251009949604426069672532417736057033099274204598385314594846509975629046864798765888104789074984927709616261452461385220475510438783429612447831614003668421849727379202555580791042606170523016207262965336641214601082882495255771621327088265411334088968112458492660609809762865582162764292604697957813514621259353683899630997077707406305730694385703091201347848855199354307506425820147289848677003277208302716466011827836279231.9667 +(1 row) + +-- +-- Tests for generate_series +-- +--Testcase 866: +DELETE FROM num_tmp; +--Testcase 867: +INSERT INTO num_tmp select * from generate_series(0.0::numeric, 4.0::numeric); +--Testcase 868: +SELECT n1 FROM num_tmp; + n1 +---- + 0 + 1 + 2 + 3 + 4 +(5 rows) + +--Testcase 869: +DELETE FROM num_tmp; +--Testcase 870: +INSERT INTO num_tmp select * from generate_series(0.1::numeric, 4.0::numeric, 1.3::numeric); +--Testcase 871: +SELECT n1 FROM num_tmp; + n1 +----- + 0.1 + 1.4 + 2.7 + 4 +(4 rows) + +--Testcase 872: +DELETE FROM num_tmp; +--Testcase 873: +INSERT INTO num_tmp select * from generate_series(4.0::numeric, -1.5::numeric, -2.2::numeric); +--Testcase 874: +SELECT n1 FROM num_tmp; + n1 +------ + 4 + 1.8 + -0.4 +(3 rows) + +-- Trigger errors +--Testcase 875: +DELETE FROM num_tmp; +--Testcase 876: +INSERT INTO num_tmp select * from generate_series(-100::numeric, 100::numeric, 0::numeric); +ERROR: step size cannot equal zero +--Testcase 877: +SELECT n1 FROM num_tmp; + n1 +---- +(0 rows) + +--Testcase 878: +DELETE FROM num_tmp; +--Testcase 879: +INSERT INTO num_tmp select * from generate_series(-100::numeric, 100::numeric, 'nan'::numeric); +ERROR: step size cannot be NaN +--Testcase 880: +SELECT n1 FROM num_tmp; + n1 +---- +(0 rows) + +--Testcase 881: +DELETE FROM num_tmp; +--Testcase 882: +INSERT INTO num_tmp select * from generate_series('nan'::numeric, 100::numeric, 10::numeric); +ERROR: start value cannot be NaN +--Testcase 883: +SELECT n1 FROM num_tmp; + n1 +---- +(0 rows) + +--Testcase 884: +DELETE FROM num_tmp; +--Testcase 885: +INSERT INTO num_tmp select * from generate_series(0::numeric, 'nan'::numeric, 10::numeric); +ERROR: stop value cannot be NaN +--Testcase 886: +SELECT n2 FROM num_tmp; + n2 +---- +(0 rows) + +--Testcase 1232: +DELETE FROM num_tmp; +--Testcase 1233: +INSERT INTO num_tmp select * from generate_series('inf'::numeric, 'inf'::numeric, 10::numeric); +ERROR: start value cannot be infinity +--Testcase 1234: +SELECT n2 FROM num_tmp; + n2 +---- +(0 rows) + +--Testcase 1235: +DELETE FROM num_tmp; +--Testcase 1236: +INSERT INTO num_tmp select * from generate_series(0::numeric, 'inf'::numeric, 10::numeric); +ERROR: stop value cannot be infinity +--Testcase 1237: +SELECT n2 FROM num_tmp; + n2 +---- +(0 rows) + +--Testcase 1238: +DELETE FROM num_tmp; +--Testcase 1239: +INSERT INTO num_tmp select * from generate_series(0::numeric, '42'::numeric, '-inf'::numeric); +ERROR: step size cannot be infinity +--Testcase 1240: +SELECT n2 FROM num_tmp; + n2 +---- +(0 rows) + +-- Checks maximum, output is truncated +--Testcase 887: +DELETE FROM num_tmp; +--Testcase 888: +INSERT INTO num_tmp select (i / (10::numeric ^ 131071))::numeric(1,0) + from generate_series(6 * (10::numeric ^ 131071), + 9 * (10::numeric ^ 131071), + 10::numeric ^ 131071) i; +--Testcase 889: +SELECT n1 FROM num_tmp; + n1 +---- + 6 + 7 + 8 + 9 +(4 rows) + + +-- Check usage with variables +--Testcase 890: +DELETE FROM num_tmp; +--Testcase 891: +INSERT INTO num_tmp select * from generate_series(1::numeric, 3::numeric) i, generate_series(i,3) j; +--Testcase 892: +SELECT n1, n2 FROM num_tmp; + n1 | n2 +----+---- + 1 | 1 + 1 | 2 + 1 | 3 + 2 | 2 + 2 | 3 + 3 | 3 +(6 rows) + +--Testcase 893: +DELETE FROM num_tmp; +--Testcase 894: +INSERT INTO num_tmp select * from generate_series(1::numeric, 3::numeric) i, generate_series(1,i) j; +--Testcase 895: +SELECT n1, n2 FROM num_tmp; + n1 | n2 +----+---- + 1 | 1 + 2 | 1 + 2 | 2 + 3 | 1 + 3 | 2 + 3 | 3 +(6 rows) + +--Testcase 896: +DELETE FROM num_tmp; +--Testcase 897: +INSERT INTO num_tmp select * from generate_series(1::numeric, 3::numeric) i, generate_series(1,5,i) j; +--Testcase 898: +SELECT n1, n2 FROM num_tmp; + n1 | n2 +----+---- + 1 | 1 + 1 | 2 + 1 | 3 + 1 | 4 + 1 | 5 + 2 | 1 + 2 | 3 + 2 | 5 + 3 | 1 + 3 | 4 +(10 rows) + +-- +-- Tests for LN() +-- +-- Invalid inputs +--Testcase 899: +DELETE FROM num_tmp; +--Testcase 900: +INSERT INTO num_tmp VALUES (-12.34); +--Testcase 901: +select ln(n1) from num_tmp; +ERROR: cannot take logarithm of a negative number +--Testcase 902: +DELETE FROM num_tmp; +--Testcase 903: +INSERT INTO num_tmp VALUES (0.0); +--Testcase 904: +select ln(n1) from num_tmp; +ERROR: cannot take logarithm of zero +-- Some random tests +--Testcase 905: +DELETE FROM num_tmp; +--Testcase 906: +INSERT INTO num_tmp VALUES (1.2345678e-28); +--Testcase 907: +select ln(n1) from num_tmp; + ln +----------------------------------------- + -64.26166165451762991204894255882820859 +(1 row) + +--Testcase 908: +DELETE FROM num_tmp; +--Testcase 909: +INSERT INTO num_tmp VALUES (0.0456789); +--Testcase 910: +select ln(n1) from num_tmp; + ln +--------------------- + -3.0861187944847439 +(1 row) + +--Testcase 911: +DELETE FROM num_tmp; +--Testcase 912: +INSERT INTO num_tmp VALUES (0.349873948359354029493948309745709580730482050975); +--Testcase 913: +select ln(n1) from num_tmp; + ln +---------------------- + -1.05018233691208275 +(1 row) + +--Testcase 914: +DELETE FROM num_tmp; +--Testcase 915: +INSERT INTO num_tmp VALUES (0.99949452); +--Testcase 916: +select ln(n1) from num_tmp; + ln +------------------------- + -0.00050560779808326467 +(1 row) + +--Testcase 917: +DELETE FROM num_tmp; +--Testcase 918: +INSERT INTO num_tmp VALUES (1.00049687395); +--Testcase 919: +select ln(n1) from num_tmp; + ln +------------------------ + 0.00049675054901370394 +(1 row) + +--Testcase 920: +DELETE FROM num_tmp; +--Testcase 921: +INSERT INTO num_tmp VALUES (1234.567890123456789); +--Testcase 922: +select ln(n1) from num_tmp; + ln +-------------------- + 7.1184763012977898 +(1 row) + +--Testcase 923: +DELETE FROM num_tmp; +--Testcase 924: +INSERT INTO num_tmp VALUES (5.80397490724e5); +--Testcase 925: +select ln(n1) from num_tmp; + ln +-------------------- + 13.271468476626518 +(1 row) + +--Testcase 926: +DELETE FROM num_tmp; +--Testcase 927: +INSERT INTO num_tmp VALUES (9.342536355e34); +--Testcase 928: +select ln(n1) from num_tmp; + ln +-------------------- + 80.522470935524187 +(1 row) + +-- +-- Tests for LOG() (base 10) +-- +-- invalid inputs +--Testcase 929: +DELETE FROM num_tmp; +--Testcase 930: +INSERT INTO num_tmp VALUES (-12.34); +--Testcase 931: +select log(n1) from num_tmp; +ERROR: cannot take logarithm of a negative number +--Testcase 932: +DELETE FROM num_tmp; +--Testcase 933: +INSERT INTO num_tmp VALUES (0.0); +--Testcase 934: +select log(n1) from num_tmp; +ERROR: cannot take logarithm of zero +-- some random tests +--Testcase 935: +DELETE FROM num_tmp; +--Testcase 936: +INSERT INTO num_tmp VALUES (1.234567e-89); +--Testcase 937: +select log(n1) from num_tmp; + log +----------------------------------------------------------------------------------------------------- + -88.90848533591373725637496492944925187293052336306443143312825869985819779294142441287021741054275 +(1 row) + +--Testcase 938: +DELETE FROM num_tmp; +--Testcase 939: +INSERT INTO num_tmp VALUES (3.4634998359873254962349856073435545); +--Testcase 940: +select log(n1) from num_tmp; + log +-------------------- + 0.5395151714070135 +(1 row) + +--Testcase 941: +DELETE FROM num_tmp; +--Testcase 942: +INSERT INTO num_tmp VALUES (9.999999999999999999); +--Testcase 943: +select log(n1) from num_tmp; + log +-------------------- + 1.0000000000000000 +(1 row) + +--Testcase 944: +DELETE FROM num_tmp; +--Testcase 945: +INSERT INTO num_tmp VALUES (10.00000000000000000); +--Testcase 946: +select log(n1) from num_tmp; + log +-------------------- + 1.0000000000000000 +(1 row) + +--Testcase 947: +DELETE FROM num_tmp; +--Testcase 948: +INSERT INTO num_tmp VALUES (10.00000000000000001); +--Testcase 949: +select log(n1) from num_tmp; + log +-------------------- + 1.0000000000000000 +(1 row) + +--Testcase 950: +DELETE FROM num_tmp; +--Testcase 951: +INSERT INTO num_tmp VALUES (590489.45235237); +--Testcase 952: +select log(n1) from num_tmp; + log +------------------- + 5.771212144411727 +(1 row) + +-- +-- Tests for LOG() (arbitrary base) +-- +-- invalid inputs +--Testcase 953: +DELETE FROM num_tmp; +--Testcase 954: +INSERT INTO num_tmp VALUES (-12.34, 56.78); +--Testcase 955: +select log(n1, n2) from num_tmp; +ERROR: cannot take logarithm of a negative number +--Testcase 956: +DELETE FROM num_tmp; +--Testcase 957: +INSERT INTO num_tmp VALUES (-12.34, -56.78); +--Testcase 958: +select log(n1, n2) from num_tmp; +ERROR: cannot take logarithm of a negative number +--Testcase 959: +DELETE FROM num_tmp; +--Testcase 960: +INSERT INTO num_tmp VALUES (12.34, -56.78); +--Testcase 961: +select log(n1, n2) from num_tmp; +ERROR: cannot take logarithm of a negative number +--Testcase 962: +DELETE FROM num_tmp; +--Testcase 963: +INSERT INTO num_tmp VALUES (0.0, 12.34); +--Testcase 964: +select log(n1, n2) from num_tmp; +ERROR: cannot take logarithm of zero +--Testcase 965: +DELETE FROM num_tmp; +--Testcase 966: +INSERT INTO num_tmp VALUES (12.34, 0.0); +--Testcase 967: +select log(n1, n2) from num_tmp; +ERROR: cannot take logarithm of zero +--Testcase 968: +DELETE FROM num_tmp; +--Testcase 969: +INSERT INTO num_tmp VALUES (.0, 12.34); +--Testcase 970: +select log(n1, n2) from num_tmp; +ERROR: cannot take logarithm of zero +-- some random tests +--Testcase 971: +DELETE FROM num_tmp; +--Testcase 972: +INSERT INTO num_tmp VALUES (1.23e-89, 6.4689e45); +--Testcase 973: +select log(n1, n2) from num_tmp; + log +------------------------------------------------------------------------------------------------ + -0.5152489207781856983977054971756484879653568168479201885425588841094788842469115325262329756 +(1 row) + +--Testcase 974: +DELETE FROM num_tmp; +--Testcase 975: +INSERT INTO num_tmp VALUES (0.99923, 4.58934e34); +--Testcase 976: +select log(n1, n2) from num_tmp; + log +--------------------- + -103611.55579544132 +(1 row) + +--Testcase 977: +DELETE FROM num_tmp; +--Testcase 978: +INSERT INTO num_tmp VALUES (1.000016, 8.452010e18); +--Testcase 979: +select log(n1, n2) from num_tmp; + log +-------------------- + 2723830.2877097365 +(1 row) + +--Testcase 980: +DELETE FROM num_tmp; +--Testcase 981: +INSERT INTO num_tmp VALUES (3.1954752e47, 9.4792021e-73); +--Testcase 982: +select log(n1, n2) from num_tmp; + log +------------------------------------------------------------------------------------- + -1.51613372350688302142917386143459361608600157692779164475351842333265418126982165 +(1 row) + +-- +-- Tests for scale() +-- +--Testcase 983: +DELETE FROM num_tmp; +--Testcase 984: +INSERT INTO num_tmp VALUES (numeric 'NaN'); +--Testcase 985: +select scale(n1) from num_tmp; + scale +------- + +(1 row) + +--Testcase 1241: +DELETE FROM num_tmp; +--Testcase 1242: +INSERT INTO num_tmp VALUES (numeric 'inf'); +--Testcase 1243: +select scale(n1) from num_tmp; + scale +------- + +(1 row) + +--Testcase 986: +DELETE FROM num_tmp; +--Testcase 987: +INSERT INTO num_tmp VALUES (NULL::numeric); +--Testcase 988: +select scale(n1) from num_tmp; + scale +------- + +(1 row) + +--Testcase 989: +DELETE FROM num_tmp; +--Testcase 990: +INSERT INTO num_tmp VALUES (1.12); +--Testcase 991: +select scale(n1) from num_tmp; + scale +------- + 2 +(1 row) + +--Testcase 992: +DELETE FROM num_tmp; +--Testcase 993: +INSERT INTO num_tmp VALUES (0); +--Testcase 994: +select scale(n1) from num_tmp; + scale +------- + 0 +(1 row) + +--Testcase 995: +DELETE FROM num_tmp; +--Testcase 996: +INSERT INTO num_tmp VALUES (0.00); +--Testcase 997: +select scale(n1) from num_tmp; + scale +------- + 0 +(1 row) + +--Testcase 998: +DELETE FROM num_tmp; +--Testcase 999: +INSERT INTO num_tmp VALUES (1.12345); +--Testcase 1000: +select scale(n1) from num_tmp; + scale +------- + 5 +(1 row) + +--Testcase 1001: +DELETE FROM num_tmp; +--Testcase 1002: +INSERT INTO num_tmp VALUES (110123.12475871856128); +--Testcase 1003: +select scale(n1) from num_tmp; + scale +------- + 11 +(1 row) + +--Testcase 1004: +DELETE FROM num_tmp; +--Testcase 1005: +INSERT INTO num_tmp VALUES (-1123.12471856128); +--Testcase 1006: +select scale(n1) from num_tmp; + scale +------- + 11 +(1 row) + +--Testcase 1007: +DELETE FROM num_tmp; +--Testcase 1008: +INSERT INTO num_tmp VALUES (-13.000000000000000); +--Testcase 1009: +select scale(n1) from num_tmp; + scale +------- + 0 +(1 row) + +-- +-- Tests for min_scale() +-- +--Testcase 1010: +DELETE FROM num_tmp; +--Testcase 1011: +INSERT INTO num_tmp VALUES (numeric 'NaN'); +--Testcase 1012: +select min_scale(n1) is NULL from num_tmp; -- should be true + ?column? +---------- + t +(1 row) + +--Testcase 1244: +DELETE FROM num_tmp; +--Testcase 1245: +INSERT INTO num_tmp VALUES (numeric 'inf'); +--Testcase 1246: +select min_scale(n1) is NULL from num_tmp; -- should be true + ?column? +---------- + t +(1 row) + +--Testcase 1013: +DELETE FROM num_tmp; +--Testcase 1014: +INSERT INTO num_tmp VALUES (0); +--Testcase 1015: +select min_scale(n1) from num_tmp; -- no digits + min_scale +----------- + 0 +(1 row) + +--Testcase 1016: +DELETE FROM num_tmp; +--Testcase 1017: +INSERT INTO num_tmp VALUES (0.00); +--Testcase 1018: +select min_scale(n1) from num_tmp; -- no digits again + min_scale +----------- + 0 +(1 row) + +--Testcase 1019: +DELETE FROM num_tmp; +--Testcase 1020: +INSERT INTO num_tmp VALUES (1.0); +--Testcase 1021: +select min_scale(n1) from num_tmp; -- no scale + min_scale +----------- + 0 +(1 row) + +--Testcase 1022: +DELETE FROM num_tmp; +--Testcase 1023: +INSERT INTO num_tmp VALUES (1.1); +--Testcase 1024: +select min_scale(n1) from num_tmp; -- scale 1 + min_scale +----------- + 1 +(1 row) + +--Testcase 1025: +DELETE FROM num_tmp; +--Testcase 1026: +INSERT INTO num_tmp VALUES (1.12); +--Testcase 1027: +select min_scale(n1) from num_tmp; -- scale 2 + min_scale +----------- + 2 +(1 row) + +--Testcase 1028: +DELETE FROM num_tmp; +--Testcase 1029: +INSERT INTO num_tmp VALUES (1.123); +--Testcase 1030: +select min_scale(n1) from num_tmp; -- scale 3 + min_scale +----------- + 3 +(1 row) + +--Testcase 1031: +DELETE FROM num_tmp; +--Testcase 1032: +INSERT INTO num_tmp VALUES (1.1234); +--Testcase 1033: +select min_scale(n1) from num_tmp; -- scale 4, filled digit + min_scale +----------- + 4 +(1 row) + +--Testcase 1034: +DELETE FROM num_tmp; +--Testcase 1035: +INSERT INTO num_tmp VALUES (1.12345); +--Testcase 1036: +select min_scale(n1) from num_tmp; -- scale 5, 2 NDIGITS + min_scale +----------- + 5 +(1 row) + +--Testcase 1037: +DELETE FROM num_tmp; +--Testcase 1038: +INSERT INTO num_tmp VALUES (1.1000); +--Testcase 1039: +select min_scale(n1) from num_tmp; -- 1 pos in NDIGITS + min_scale +----------- + 1 +(1 row) + +--Testcase 1040: +DELETE FROM num_tmp; +--Testcase 1041: +INSERT INTO num_tmp VALUES (1e100); +--Testcase 1042: +select min_scale(n1) from num_tmp; -- very big number + min_scale +----------- + 0 +(1 row) + +-- +-- Tests for trim_scale() +-- +--Testcase 1043: +DELETE FROM num_tmp; +--Testcase 1044: +INSERT INTO num_tmp VALUES (numeric 'NaN'); +--Testcase 1045: +select trim_scale(n1) from num_tmp; + trim_scale +------------ + +(1 row) + +--Testcase 1247: +DELETE FROM num_tmp; +--Testcase 1248: +INSERT INTO num_tmp VALUES (numeric 'inf'); +--Testcase 1249: +select trim_scale(n1) from num_tmp; + trim_scale +------------ + Infinity +(1 row) + +--Testcase 1046: +DELETE FROM num_tmp; +--Testcase 1047: +INSERT INTO num_tmp VALUES (1.120); +--Testcase 1048: +select trim_scale(n1) from num_tmp; + trim_scale +------------ + 1.12 +(1 row) + +--Testcase 1049: +DELETE FROM num_tmp; +--Testcase 1050: +INSERT INTO num_tmp VALUES (0); +--Testcase 1051: +select trim_scale(n1) from num_tmp; + trim_scale +------------ + 0 +(1 row) + +--Testcase 1052: +DELETE FROM num_tmp; +--Testcase 1053: +INSERT INTO num_tmp VALUES (0.00); +--Testcase 1054: +select trim_scale(n1) from num_tmp; + trim_scale +------------ + 0 +(1 row) + +--Testcase 1055: +DELETE FROM num_tmp; +--Testcase 1056: +INSERT INTO num_tmp VALUES (1.1234500); +--Testcase 1057: +select trim_scale(n1) from num_tmp; + trim_scale +------------ + 1.12345 +(1 row) + +--Testcase 1058: +DELETE FROM num_tmp; +--Testcase 1059: +INSERT INTO num_tmp VALUES (110123.12475871856128000); +--Testcase 1060: +select trim_scale(n1) from num_tmp; + trim_scale +-------------------- + 110123.12475871856 +(1 row) + +--Testcase 1061: +DELETE FROM num_tmp; +--Testcase 1062: +INSERT INTO num_tmp VALUES (-123.124718561280000000); +--Testcase 1063: +select trim_scale(n1) from num_tmp; + trim_scale +------------------ + -123.12471856128 +(1 row) + +--Testcase 1064: +DELETE FROM num_tmp; +--Testcase 1065: +INSERT INTO num_tmp VALUES (-13.00000000000000000000); +--Testcase 1066: +select trim_scale(n1) from num_tmp; + trim_scale +------------ + -13 +(1 row) + +--Testcase 1067: +DELETE FROM num_tmp; +--Testcase 1068: +INSERT INTO num_tmp VALUES (1e100); +--Testcase 1069: +select trim_scale(n1) from num_tmp; + trim_scale +------------------------------------------------------------------------------------------------------- + 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +(1 row) + +-- +-- Tests for SUM() +-- +-- cases that need carry propagation +--Testcase 1070: +DELETE FROM num_tmp; +--Testcase 1071: +INSERT INTO num_tmp SELECT * FROM generate_series(1, 100000); +--Testcase 1072: +SELECT SUM(9999::numeric) FROM num_tmp; + sum +----------- + 999900000 +(1 row) + +--Testcase 1073: +SELECT SUM((-9999)::numeric) FROM num_tmp; + sum +------------ + -999900000 +(1 row) + +-- +-- Tests for VARIANCE() +-- +--Testcase 1578: +INSERT INTO num_variance VALUES (0); +--Testcase 1579: +INSERT INTO num_variance VALUES (3e-500); +ERROR: "0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003" is out of range for type double precision +--Testcase 1580: +INSERT INTO num_variance VALUES (-3e-500); +ERROR: "-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003" is out of range for type double precision +--Testcase 1581: +INSERT INTO num_variance VALUES (4e-500 - 1e-16383); +ERROR: "0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" is out of range for type double precision +--Testcase 1582: +INSERT INTO num_variance VALUES (-4e-500 + 1e-16383); +ERROR: "-0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000039999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999" is out of range for type double precision +-- variance is just under 12.5e-1000 and so should round down to 12e-1000 +--Testcase 1583: +SELECT trim_scale(variance(a) * 1e1000) FROM num_variance; + trim_scale +------------ + +(1 row) + +-- check that parallel execution produces the same result +BEGIN; +-- ALTER TABLE num_variance SET (parallel_workers = 4); +SET LOCAL parallel_setup_cost = 0; +SET LOCAL max_parallel_workers_per_gather = 4; +--Testcase 1584: +SELECT trim_scale(variance(a) * 1e1000) FROM num_variance; + trim_scale +------------ + +(1 row) + +ROLLBACK; +-- case where sum of squares would overflow but variance does not +--Testcase 1585: +DELETE FROM num_variance; +ERROR: no primary key column specified for foreign table +DETAIL: For UPDATE or DELETE, at least one foreign table column must be marked as primary key column. +HINT: Set the option "key" on the columns that belong to the primary key. +--Testcase 1586: +INSERT INTO num_variance SELECT 9e131071 + x FROM generate_series(1, 5) x; +ERROR: "90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001" is out of range for type double precision +--Testcase 1587: +SELECT variance(a) FROM num_variance; + variance +---------- + +(1 row) + +-- check that parallel execution produces the same result +BEGIN; +-- ALTER TABLE num_variance SET (parallel_workers = 4); +SET LOCAL parallel_setup_cost = 0; +SET LOCAL max_parallel_workers_per_gather = 4; +--Testcase 1588: +SELECT variance(a) FROM num_variance; + variance +---------- + +(1 row) + +ROLLBACK; +-- +-- Tests for GCD() +-- +--Testcase 1074: +DELETE FROM num_tmp; +--Testcase 1075: +INSERT INTO num_tmp VALUES + (0::numeric, 0::numeric), + (0::numeric, numeric 'NaN'), + (0::numeric, 46375::numeric), + (433125::numeric, 46375::numeric), + (43312.5::numeric, 4637.5::numeric), + (4331.250::numeric, 463.75000::numeric), + ('Infinity', '0'), + ('Infinity', '42'), + ('Infinity', 'Infinity'); +--Testcase 1076: +SELECT n1 as a, n2 as b, gcd(n1, n2), gcd(n1, -n2), gcd(-n2, n1), gcd(-n2, -n1) FROM num_tmp; + a | b | gcd | gcd | gcd | gcd +----------+----------+-------+-------+-------+------- + 0 | 0 | 0 | 0 | 0 | 0 + 0 | | | | | + 0 | 46375 | 46375 | 46375 | 46375 | 46375 + 433125 | 46375 | 875 | 875 | 875 | 875 + 43312.5 | 4637.5 | 87.5 | 87.5 | 87.5 | 87.5 + 4331.25 | 463.75 | 8.75 | 8.75 | 8.75 | 8.75 + Infinity | 0 | NaN | NaN | NaN | NaN + Infinity | 42 | NaN | NaN | NaN | NaN + Infinity | Infinity | NaN | NaN | NaN | NaN +(9 rows) + +-- +-- Tests for LCM() +-- +--Testcase 1077: +DELETE FROM num_tmp; +--Testcase 1078: +INSERT INTO num_tmp VALUES + (0::numeric, 0::numeric), + (0::numeric, numeric 'NaN'), + (0::numeric, 13272::numeric), + (13272::numeric, 13272::numeric), + (423282::numeric, 13272::numeric), + (42328.2::numeric, 1327.2::numeric), + (4232.820::numeric, 132.72000::numeric), + ('Infinity', '0'), + ('Infinity', '42'), + ('Infinity', 'Infinity'); +--Testcase 1079: +SELECT n1 as a, n2 as b, lcm(n1, n2), lcm(n1, -n2), lcm(-n2, n1), lcm(-n2, -n1) FROM num_tmp; + a | b | lcm | lcm | lcm | lcm +----------+----------+-----------+-----------+-----------+----------- + 0 | 0 | 0 | 0 | 0 | 0 + 0 | | | | | + 0 | 13272 | 0 | 0 | 0 | 0 + 13272 | 13272 | 13272 | 13272 | 13272 | 13272 + 423282 | 13272 | 11851896 | 11851896 | 11851896 | 11851896 + 42328.2 | 1327.2 | 1185189.6 | 1185189.6 | 1185189.6 | 1185189.6 + 4232.82 | 132.72 | 118518.96 | 118518.96 | 118518.96 | 118518.96 + Infinity | 0 | NaN | NaN | NaN | NaN + Infinity | 42 | NaN | NaN | NaN | NaN + Infinity | Infinity | NaN | NaN | NaN | NaN +(10 rows) + +--Testcase 1080: +DELETE FROM num_tmp; +--Testcase 1081: +INSERT INTO num_tmp VALUES (10::numeric, 131068); +--Testcase 1082: +SELECT lcm(9999 * (n1)^n2 + (n1^n2 - 1), 2) FROM num_tmp; -- overflow +ERROR: value overflows numeric format +-- +-- Tests for factorial +-- +--Testcase 1250: +DELETE FROM num_tmp; +--Testcase 1251: +INSERT INTO num_tmp VALUES (4); +--Testcase 1252: +SELECT factorial(n1::int4) FROM num_tmp; + factorial +----------- + 24 +(1 row) + +--Testcase 1253: +DELETE FROM num_tmp; +--Testcase 1254: +INSERT INTO num_tmp VALUES (15); +--Testcase 1255: +SELECT factorial(n1::int4) FROM num_tmp; + factorial +--------------- + 1307674368000 +(1 row) + +--Testcase 1256: +DELETE FROM num_tmp; +--Testcase 1257: +INSERT INTO num_tmp VALUES (100000); +--Testcase 1258: +SELECT factorial(n1::int4) FROM num_tmp; +ERROR: value overflows numeric format +--Testcase 1259: +DELETE FROM num_tmp; +--Testcase 1260: +INSERT INTO num_tmp VALUES (0); +--Testcase 1261: +SELECT factorial(n1::int4) FROM num_tmp; + factorial +----------- + 1 +(1 row) + +--Testcase 1262: +DELETE FROM num_tmp; +--Testcase 1263: +INSERT INTO num_tmp VALUES (-4); +--Testcase 1264: +SELECT factorial(n1::int4) FROM num_tmp; +ERROR: factorial of a negative number is undefined +-- +-- Tests for pg_lsn() +-- +--Testcase 1265: +DELETE FROM num_tmp; +--Testcase 1266: +INSERT INTO num_tmp VALUES (23783416::numeric); +--Testcase 1267: +SELECT pg_lsn(n1) FROM num_tmp; + pg_lsn +----------- + 0/16AE7F8 +(1 row) + +--Testcase 1268: +DELETE FROM num_tmp; +--Testcase 1269: +INSERT INTO num_tmp VALUES (0::numeric); +--Testcase 1270: +SELECT pg_lsn(n1) FROM num_tmp; + pg_lsn +-------- + 0/0 +(1 row) + +--Testcase 1271: +DELETE FROM num_tmp; +--Testcase 1272: +INSERT INTO num_tmp VALUES (18446744073709551615::numeric); +--Testcase 1273: +SELECT pg_lsn(n1) FROM num_tmp; +ERROR: pg_lsn out of range +--Testcase 1274: +DELETE FROM num_tmp; +--Testcase 1275: +INSERT INTO num_tmp VALUES (-1::numeric); +--Testcase 1276: +SELECT pg_lsn(n1) FROM num_tmp; +ERROR: pg_lsn out of range +--Testcase 1277: +DELETE FROM num_tmp; +--Testcase 1278: +INSERT INTO num_tmp VALUES (18446744073709551616::numeric); +--Testcase 1279: +SELECT pg_lsn(n1) FROM num_tmp; +ERROR: pg_lsn out of range +--Testcase 1280: +DELETE FROM num_tmp; +--Testcase 1281: +INSERT INTO num_tmp VALUES ('NaN'::numeric); +--Testcase 1282: +SELECT pg_lsn(n1) FROM num_tmp; + pg_lsn +-------- + +(1 row) + +DO $d$ +declare + l_rec record; +begin + for l_rec in (select foreign_table_schema, foreign_table_name + from information_schema.foreign_tables) loop + execute format('drop foreign table %I.%I cascade;', l_rec.foreign_table_schema, l_rec.foreign_table_name); + end loop; +end; +$d$; +--Testcase 1083: +DROP SERVER sqlite_svr; +--Testcase 1084: +DROP EXTENSION sqlite_fdw CASCADE; diff --git a/expected/12.8/extra/prepare.out b/expected/15beta2/extra/prepare.out similarity index 99% rename from expected/12.8/extra/prepare.out rename to expected/15beta2/extra/prepare.out index 980e3492..cbdeaa4c 100644 --- a/expected/12.8/extra/prepare.out +++ b/expected/15beta2/extra/prepare.out @@ -164,6 +164,8 @@ DETAIL: Expected 5 parameters but got 6. --Testcase 18: EXECUTE q3(5::smallint, 10.5::float, false, 4::bigint, 'bytea'); ERROR: parameter $3 of type boolean cannot be coerced to the expected type double precision +LINE 1: EXECUTE q3(5::smallint, 10.5::float, false, 4::bigint, 'byte... + ^ HINT: You will need to rewrite or cast the expression. -- invalid type --Testcase 19: diff --git a/expected/11.13/extra/select.out b/expected/15beta2/extra/select.out similarity index 94% rename from expected/11.13/extra/select.out rename to expected/15beta2/extra/select.out index f0dc4f2f..49394537 100644 --- a/expected/11.13/extra/select.out +++ b/expected/15beta2/extra/select.out @@ -356,10 +356,6 @@ SELECT onek2.unique1, onek2.stringu1 FROM onek2 RESET enable_seqscan; RESET enable_bitmapscan; RESET enable_sort; ---Testcase 11: -SELECT two, stringu1, ten, string4 - INTO TABLE tmp - FROM onek; -- -- awk '{print $1,$2;}' person.data | -- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data | @@ -576,6 +572,10 @@ TABLE int8_tbl; 4567890123456789 | -4567890123456789 (9 rows) +-- corner case: VALUES with no columns +-- CREATE TEMP TABLE nocols(); +-- INSERT INTO nocols DEFAULT VALUES; +-- SELECT * FROM nocols n, LATERAL (VALUES(n.*)) v; -- -- Test ORDER BY options -- @@ -675,10 +675,11 @@ SELECT * FROM foo ORDER BY f1 DESC NULLS LAST; --Testcase 24: explain (costs off) select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; - QUERY PLAN ------------------------ + QUERY PLAN +--------------------------------------- Foreign Scan on onek2 -(1 row) + Filter: (stringu1 = 'ATAAAA'::name) +(2 rows) --Testcase 25: select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; @@ -694,15 +695,17 @@ select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; QUERY PLAN ----------------------------------------------- Foreign Scan on onek2 (actual rows=1 loops=1) -(1 row) + Filter: (stringu1 = 'ATAAAA'::name) +(2 rows) --Testcase 27: explain (costs off) select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; - QUERY PLAN ------------------------ + QUERY PLAN +--------------------------------------- Foreign Scan on onek2 -(1 row) + Filter: (stringu1 = 'ATAAAA'::name) +(2 rows) --Testcase 28: select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; @@ -715,10 +718,11 @@ select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; --Testcase 29: explain (costs off) select * from onek2 where unique2 = 11 and stringu1 < 'B'; - QUERY PLAN ------------------------ + QUERY PLAN +---------------------------------- Foreign Scan on onek2 -(1 row) + Filter: (stringu1 < 'B'::name) +(2 rows) --Testcase 30: select * from onek2 where unique2 = 11 and stringu1 < 'B'; @@ -730,10 +734,11 @@ select * from onek2 where unique2 = 11 and stringu1 < 'B'; --Testcase 31: explain (costs off) select unique2 from onek2 where unique2 = 11 and stringu1 < 'B'; - QUERY PLAN ------------------------ + QUERY PLAN +---------------------------------- Foreign Scan on onek2 -(1 row) + Filter: (stringu1 < 'B'::name) +(2 rows) --Testcase 32: select unique2 from onek2 where unique2 = 11 and stringu1 < 'B'; @@ -746,11 +751,12 @@ select unique2 from onek2 where unique2 = 11 and stringu1 < 'B'; --Testcase 33: explain (costs off) select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update; - QUERY PLAN ------------------------------ + QUERY PLAN +---------------------------------------- LockRows -> Foreign Scan on onek2 -(2 rows) + Filter: (stringu1 < 'B'::name) +(3 rows) --Testcase 34: select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update; @@ -763,10 +769,11 @@ select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update; --Testcase 35: explain (costs off) select unique2 from onek2 where unique2 = 11 and stringu1 < 'C'; - QUERY PLAN ------------------------ + QUERY PLAN +---------------------------------- Foreign Scan on onek2 -(1 row) + Filter: (stringu1 < 'C'::name) +(2 rows) --Testcase 36: select unique2 from onek2 where unique2 = 11 and stringu1 < 'C'; @@ -780,10 +787,11 @@ SET enable_indexscan TO off; --Testcase 37: explain (costs off) select unique2 from onek2 where unique2 = 11 and stringu1 < 'B'; - QUERY PLAN ------------------------ + QUERY PLAN +---------------------------------- Foreign Scan on onek2 -(1 row) + Filter: (stringu1 < 'B'::name) +(2 rows) --Testcase 38: select unique2 from onek2 where unique2 = 11 and stringu1 < 'B'; @@ -798,10 +806,11 @@ RESET enable_indexscan; explain (costs off) select unique1, unique2 from onek2 where (unique2 = 11 or unique1 = 0) and stringu1 < 'B'; - QUERY PLAN ------------------------ + QUERY PLAN +---------------------------------- Foreign Scan on onek2 -(1 row) + Filter: (stringu1 < 'B'::name) +(2 rows) --Testcase 40: select unique1, unique2 from onek2 @@ -816,10 +825,11 @@ select unique1, unique2 from onek2 explain (costs off) select unique1, unique2 from onek2 where (unique2 = 11 and stringu1 < 'B') or unique1 = 0; - QUERY PLAN ------------------------ + QUERY PLAN +-------------------------------------------------------------------------- Foreign Scan on onek2 -(1 row) + Filter: (((unique2 = 11) AND (stringu1 < 'B'::name)) OR (unique1 = 0)) +(2 rows) --Testcase 42: select unique1, unique2 from onek2 diff --git a/expected/14.0/extra/select_having.out b/expected/15beta2/extra/select_having.out similarity index 100% rename from expected/14.0/extra/select_having.out rename to expected/15beta2/extra/select_having.out diff --git a/expected/10.18/extra/sqlite_fdw_post.out b/expected/15beta2/extra/sqlite_fdw_post.out similarity index 84% rename from expected/10.18/extra/sqlite_fdw_post.out rename to expected/15beta2/extra/sqlite_fdw_post.out index 12ed846b..3585f07d 100644 --- a/expected/10.18/extra/sqlite_fdw_post.out +++ b/expected/15beta2/extra/sqlite_fdw_post.out @@ -9,12 +9,16 @@ DO $d$ OPTIONS (database '/tmp/sqlitefdw_test_post.db')$$; EXECUTE $$CREATE SERVER sqlite_svr2 FOREIGN DATA WRAPPER sqlite_fdw OPTIONS (database '/tmp/sqlitefdw_test_post.db')$$; + EXECUTE $$CREATE SERVER sqlite_svr3 FOREIGN DATA WRAPPER sqlite_fdw + OPTIONS (database '/tmp/sqlitefdw_test_post.db')$$; END; $d$; --Testcase 484: 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 -- =================================================================== @@ -72,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 ( @@ -85,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 ( @@ -104,9 +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+ @@ -118,7 +134,8 @@ ALTER FOREIGN TABLE ft2 ALTER COLUMN c1 OPTIONS (column_name 'C 1'); public | ft4 | sqlite_svr | ("table" 'T 3') | public | ft5 | sqlite_svr | ("table" 'T 4') | public | ft6 | sqlite_svr2 | ("table" 'T 4') | -(5 rows) + public | ft7 | sqlite_svr3 | ("table" 'T 4') | +(6 rows) -- Test that alteration of server options causes reconnection -- Remote's errors might be non-English, so hide them to ensure stable results @@ -130,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 @@ -154,6 +172,13 @@ SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work again --ANALYZE ft1; --ALTER FOREIGN TABLE ft2 OPTIONS (use_remote_estimate 'true'); -- =================================================================== +-- test error case for create publication on foreign table +-- =================================================================== +--Testcase 955: +CREATE PUBLICATION testpub_ftbl FOR TABLE ft1; -- should fail +ERROR: cannot add relation "ft1" to publication +DETAIL: This operation is not supported for foreign tables. +-- =================================================================== -- simple queries -- =================================================================== -- single table without alias @@ -357,7 +382,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: @@ -452,7 +479,7 @@ EXPLAIN (VERBOSE, COSTS OFF) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: t1."C 1", t2.c1, t3.c1 - SQLite query: SELECT r1.`C 1`, r3.`C 1`, r2.`C 1` FROM ((main."T 1" r1 LEFT JOIN main."T 1" r3 ON (((r3.`C 1` = r1.`C 1`)))) LEFT JOIN main."T 1" r2 ON (((r2.`C 1` = r3.`C 1`)))) LIMIT 10 OFFSET 100 + SQLite query: SELECT r1.`C 1`, r2.`C 1`, r3.`C 1` FROM ((main."T 1" r1 LEFT JOIN main."T 1" r3 ON (((r3.`C 1` = r1.`C 1`)))) LEFT JOIN main."T 1" r2 ON (((r2.`C 1` = r3.`C 1`)))) LIMIT 10 OFFSET 100 (3 rows) --Testcase 34: @@ -524,8 +551,32 @@ 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 +--------------------------------------------------------------------------------------- + Foreign Scan on public.ft_empty + Output: c1, c2 + SQLite query: SELECT `c1`, `c2` FROM main."loct_empty" ORDER BY `c1` ASC NULLS LAST +(3 rows) + -- =================================================================== -- WHERE with remotely-executable conditions -- =================================================================== @@ -575,6 +626,7 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE round(abs(c1), 0) = 1; - (3 rows) --Testcase 42: +--Testcase 956: EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = -c1; -- OpExpr(l) QUERY PLAN -------------------------------------------------------------------------------------------------------------------- @@ -583,16 +635,6 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = -c1; -- Op SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` = (- `C 1`))) (3 rows) ---Testcase 43: -EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE 1 = c1!; -- OpExpr(r) - QUERY PLAN ----------------------------------------------------------------------------------------- - Foreign Scan on public.ft1 t1 - Output: c1, c2, c3, c4, c5, c6, c7, c8 - Filter: ('1'::numeric = ((t1.c1)::bigint !)) - SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" -(4 rows) - --Testcase 44: EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE (c1 IS NOT NULL) IS DISTINCT FROM (c1 IS NOT NULL); -- DistinctExpr QUERY PLAN @@ -939,7 +981,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 @@ -1004,6 +1048,105 @@ SELECT * FROM ft1 t1 WHERE t1.c1 === t1.c2 order by t1.c2 limit 1; 1 | 1 | 00001 | Fri Jan 02 00:00:00 1970 PST | Fri Jan 02 00:00:00 1970 | 1 | 1 | foo (1 row) +-- Test CASE pushdown +--Testcase 957: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT c1,c2,c3 FROM ft2 WHERE CASE WHEN c1 > 990 THEN c1 END < 1000 ORDER BY c1; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.ft2 + Output: c1, c2, c3 + SQLite query: SELECT `C 1`, `c2`, `c3` FROM main."T 1" WHERE ((CASE WHEN (`C 1` > 990) THEN `C 1` ELSE NULL END < 1000)) ORDER BY `C 1` ASC NULLS LAST +(3 rows) + +--Testcase 958: +SELECT c1,c2,c3 FROM ft2 WHERE CASE WHEN c1 > 990 THEN c1 END < 1000 ORDER BY c1; + c1 | c2 | c3 +-----+----+------- + 991 | 1 | 00991 + 992 | 2 | 00992 + 993 | 3 | 00993 + 994 | 4 | 00994 + 995 | 5 | 00995 + 996 | 6 | 00996 + 997 | 7 | 00997 + 998 | 8 | 00998 + 999 | 9 | 00999 +(9 rows) + +-- Nested CASE +--Testcase 959: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT c1,c2,c3 FROM ft2 WHERE CASE CASE WHEN c2 > 0 THEN c2 END WHEN 100 THEN 601 WHEN c2 THEN c2 ELSE 0 END > 600 ORDER BY c1; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + Foreign Scan on public.ft2 + Output: c1, c2, c3 + SQLite query: SELECT `C 1`, `c2`, `c3` FROM main."T 1" WHERE ((CASE CASE WHEN (`c2` > 0) THEN `c2` ELSE NULL END WHEN 100 THEN 601 WHEN `c2` THEN `c2` ELSE 0 END > 600)) ORDER BY `C 1` ASC NULLS LAST +(3 rows) + +--Testcase 960: +SELECT c1,c2,c3 FROM ft2 WHERE CASE CASE WHEN c2 > 0 THEN c2 END WHEN 100 THEN 601 WHEN c2 THEN c2 ELSE 0 END > 600 ORDER BY c1; + c1 | c2 | c3 +----+----+---- +(0 rows) + +-- CASE arg WHEN +--Testcase 961: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.ft1 + Output: c1, c2, c3, c4, c5, c6, c7, c8 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` > CASE mod(`C 1`, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END)) +(3 rows) + +-- CASE cannot be pushed down because of unshippable arg clause +--Testcase 962: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE c1 > (CASE random()::integer WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + QUERY PLAN +----------------------------------------------------------------------------------------- + Foreign Scan on public.ft1 + Output: c1, c2, c3, c4, c5, c6, c7, c8 + Filter: (ft1.c1 > CASE (random())::integer WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END) + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" +(4 rows) + +-- these are shippable +--Testcase 963: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.ft1 + Output: c1, c2, c3, c4, c5, c6, c7, c8 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE (CASE `c6` WHEN 'foo' THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 964: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.ft1 + Output: c1, c2, c3, c4, c5, c6, c7, c8 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE (CASE `c3` WHEN `c6` THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +-- but this is not because of collation +--Testcase 965: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + QUERY PLAN +---------------------------------------------------------------------------------------- + Foreign Scan on public.ft1 + Output: c1, c2, c3, c4, c5, c6, c7, c8 + Filter: CASE (ft1.c3)::text WHEN ft1.c6 THEN true ELSE (ft1.c3 < 'bar'::text) END + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" +(4 rows) + -- =================================================================== -- JOIN queries -- =================================================================== @@ -1019,7 +1162,7 @@ SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c3, t ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Foreign Scan Output: t1.c1, t2.c1, t1.c3 - SQLite query: SELECT r1.`C 1`, r1.`c3`, r2.`C 1` FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST LIMIT 10 OFFSET 100 + SQLite query: SELECT r1.`C 1`, r2.`C 1`, r1.`c3` FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST LIMIT 10 OFFSET 100 (3 rows) --Testcase 66: @@ -1046,7 +1189,7 @@ SELECT t1.c1, t2.c2, t3.c3 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1) JOIN ft4 t -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: t1.c1, t2.c2, t3.c3, t1.c3 - SQLite query: SELECT r1.`C 1`, r1.`c3`, r2.`c2`, r4.`c3` FROM ((main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) INNER JOIN main."T 3" r4 ON (((r1.`C 1` = r4.`c1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST LIMIT 10 OFFSET 10 + SQLite query: SELECT r1.`C 1`, r2.`c2`, r4.`c3`, r1.`c3` FROM ((main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) INNER JOIN main."T 3" r4 ON (((r1.`C 1` = r4.`c1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST LIMIT 10 OFFSET 10 (3 rows) --Testcase 68: @@ -1191,7 +1334,7 @@ SELECT t1.c1, t2.c1 FROM ft5 t1 RIGHT JOIN ft4 t2 ON (t1.c1 = t2.c1) ORDER BY t2 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: t1.c1, t2.c1 - SQLite query: SELECT r2.`c1`, r1.`c1` FROM (main."T 3" r2 LEFT JOIN main."T 4" r1 ON (((r1.`c1` = r2.`c1`)))) ORDER BY r2.`c1` ASC NULLS LAST, r1.`c1` ASC NULLS LAST LIMIT 10 OFFSET 10 + SQLite query: SELECT r1.`c1`, r2.`c1` FROM (main."T 3" r2 LEFT JOIN main."T 4" r1 ON (((r1.`c1` = r2.`c1`)))) ORDER BY r2.`c1` ASC NULLS LAST, r1.`c1` ASC NULLS LAST LIMIT 10 OFFSET 10 (3 rows) --Testcase 78: @@ -1218,7 +1361,7 @@ SELECT t1.c1, t2.c2, t3.c3 FROM ft2 t1 RIGHT JOIN ft2 t2 ON (t1.c1 = t2.c1) RIGH ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Foreign Scan Output: t1.c1, t2.c2, t3.c3 - SQLite query: SELECT r4.`c3`, r2.`c2`, r1.`C 1` FROM ((main."T 3" r4 LEFT JOIN main."T 1" r2 ON (((r2.`C 1` = r4.`c1`)))) LEFT JOIN main."T 1" r1 ON (((r1.`C 1` = r2.`C 1`)))) LIMIT 10 OFFSET 10 + SQLite query: SELECT r1.`C 1`, r2.`c2`, r4.`c3` FROM ((main."T 3" r4 LEFT JOIN main."T 1" r2 ON (((r2.`C 1` = r4.`c1`)))) LEFT JOIN main."T 1" r1 ON (((r1.`C 1` = r2.`C 1`)))) LIMIT 10 OFFSET 10 (3 rows) --Testcase 80: @@ -1437,8 +1580,8 @@ SELECT t1.c1, ss.a, ss.b FROM (SELECT c1 FROM ft4 WHERE c1 between 50 and 60) t1 --Testcase 91: EXPLAIN (VERBOSE, COSTS OFF) SELECT t1.c1, ss.a, ss.b FROM (SELECT c1 FROM "S 1"."T 3" WHERE c1 = 50) t1 INNER JOIN (SELECT t2.c1, t3.c1 FROM (SELECT c1 FROM ft4 WHERE c1 between 50 and 60) t2 FULL JOIN (SELECT c1 FROM ft5 WHERE c1 between 50 and 60) t3 ON (t2.c1 = t3.c1) WHERE t2.c1 IS NULL OR t2.c1 IS NOT NULL) ss(a, b) ON (TRUE) ORDER BY t1.c1, ss.a, ss.b FOR UPDATE OF t1; - QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------- LockRows Output: "T 3".c1, ft4.c1, ft5.c1, "T 3".*, ft4.*, ft5.* -> Sort @@ -1449,25 +1592,19 @@ SELECT t1.c1, ss.a, ss.b FROM (SELECT c1 FROM "S 1"."T 3" WHERE c1 = 50) t1 INNE -> Foreign Scan on "S 1"."T 3" Output: "T 3".c1, "T 3".* SQLite query: SELECT `c1`, `c2`, `c3` FROM main."T 3" WHERE ((`c1` = 50)) - -> Materialize + -> Hash Full Join Output: ft4.c1, ft4.*, ft5.c1, ft5.* - -> Merge Full Join - Output: ft4.c1, ft4.*, ft5.c1, ft5.* - Merge Cond: (ft4.c1 = ft5.c1) - Filter: ((ft4.c1 IS NULL) OR (ft4.c1 IS NOT NULL)) - -> Sort - Output: ft4.c1, ft4.* - Sort Key: ft4.c1 - -> Foreign Scan on public.ft4 - Output: ft4.c1, ft4.* - SQLite query: SELECT `c1`, `c2`, `c3` FROM main."T 3" WHERE ((`c1` >= 50)) AND ((`c1` <= 60)) - -> Sort + Hash Cond: (ft4.c1 = ft5.c1) + Filter: ((ft4.c1 IS NULL) OR (ft4.c1 IS NOT NULL)) + -> Foreign Scan on public.ft4 + Output: ft4.c1, ft4.* + SQLite query: SELECT `c1`, `c2`, `c3` FROM main."T 3" WHERE ((`c1` >= 50)) AND ((`c1` <= 60)) + -> Hash + Output: ft5.c1, ft5.* + -> Foreign Scan on public.ft5 Output: ft5.c1, ft5.* - Sort Key: ft5.c1 - -> Foreign Scan on public.ft5 - Output: ft5.c1, ft5.* - SQLite query: SELECT `c1`, `c2`, `c3` FROM main."T 4" WHERE ((`c1` >= 50)) AND ((`c1` <= 60)) -(28 rows) + SQLite query: SELECT `c1`, `c2`, `c3` FROM main."T 4" WHERE ((`c1` >= 50)) AND ((`c1` <= 60)) +(22 rows) --Testcase 92: SELECT t1.c1, ss.a, ss.b FROM (SELECT c1 FROM "S 1"."T 3" WHERE c1 = 50) t1 INNER JOIN (SELECT t2.c1, t3.c1 FROM (SELECT c1 FROM ft4 WHERE c1 between 50 and 60) t2 FULL JOIN (SELECT c1 FROM ft5 WHERE c1 between 50 and 60) t3 ON (t2.c1 = t3.c1) WHERE t2.c1 IS NULL OR t2.c1 IS NOT NULL) ss(a, b) ON (TRUE) ORDER BY t1.c1, ss.a, ss.b FOR UPDATE OF t1; @@ -1576,7 +1713,7 @@ SELECT t1.c1, t2.c2, t3.c3 FROM ft2 t1 FULL JOIN ft2 t2 ON (t1.c1 = t2.c1) RIGHT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Foreign Scan Output: t1.c1, t2.c2, t3.c3 - SQLite query: SELECT r4.`c3`, r2.`c2`, r1.`C 1` FROM ((main."T 3" r4 LEFT JOIN main."T 1" r2 ON (((r2.`C 1` = r4.`c1`)))) LEFT JOIN main."T 1" r1 ON (((r1.`C 1` = r2.`C 1`)))) LIMIT 10 OFFSET 10 + SQLite query: SELECT r1.`C 1`, r2.`c2`, r4.`c3` FROM ((main."T 3" r4 LEFT JOIN main."T 1" r2 ON (((r2.`C 1` = r4.`c1`)))) LEFT JOIN main."T 1" r1 ON (((r1.`C 1` = r2.`C 1`)))) LIMIT 10 OFFSET 10 (3 rows) --Testcase 98: @@ -1730,6 +1867,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) +--Testcase 775: +SET enable_memoize TO off; -- right outer join + left outer join --Testcase 105: EXPLAIN (VERBOSE, COSTS OFF) @@ -1738,7 +1877,7 @@ SELECT t1.c1, t2.c2, t3.c3 FROM ft2 t1 RIGHT JOIN ft2 t2 ON (t1.c1 = t2.c1) LEFT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Foreign Scan Output: t1.c1, t2.c2, t3.c3 - SQLite query: SELECT r2.`c2`, r1.`C 1`, r4.`c3` FROM ((main."T 1" r2 LEFT JOIN main."T 1" r1 ON (((r1.`C 1` = r2.`C 1`)))) LEFT JOIN main."T 3" r4 ON (((r2.`C 1` = r4.`c1`)))) LIMIT 10 OFFSET 10 + SQLite query: SELECT r1.`C 1`, r2.`c2`, r4.`c3` FROM ((main."T 1" r2 LEFT JOIN main."T 1" r1 ON (((r1.`C 1` = r2.`C 1`)))) LEFT JOIN main."T 3" r4 ON (((r2.`C 1` = r4.`c1`)))) LIMIT 10 OFFSET 10 (3 rows) --Testcase 106: @@ -1757,6 +1896,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) +--Testcase 776: +RESET enable_memoize; -- left outer join + right outer join --Testcase 107: EXPLAIN (VERBOSE, COSTS OFF) @@ -1765,7 +1906,7 @@ SELECT t1.c1, t2.c2, t3.c3 FROM ft2 t1 LEFT JOIN ft2 t2 ON (t1.c1 = t2.c1) RIGHT ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: t1.c1, t2.c2, t3.c3 - SQLite query: SELECT r4.`c3`, r1.`C 1`, r2.`c2` FROM (main."T 3" r4 LEFT JOIN (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ON (((r2.`C 1` = r4.`c1`)))) LIMIT 10 OFFSET 10 + SQLite query: SELECT r1.`C 1`, r2.`c2`, r4.`c3` FROM (main."T 3" r4 LEFT JOIN (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ON (((r2.`C 1` = r4.`c1`)))) LIMIT 10 OFFSET 10 (3 rows) --Testcase 108: @@ -1874,6 +2015,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 @@ -1889,10 +2031,10 @@ SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c3, t Output: t1.c1, t2.c1, t1.c3, t1.*, t2.* -> Foreign Scan Output: t1.c1, t2.c1, t1.c3, t1.*, t2.* - SQLite query: SELECT r1.`C 1`, r1.`c3`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, r2.`C 1`, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST + SQLite query: SELECT r1.`C 1`, r2.`C 1`, r1.`c3`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST -> Sort Output: t1.c1, t1.c3, t1.*, t2.c1, t2.* - Sort Key: t1.c3, t1.c1 + Sort Key: t1.c3 COLLATE "default" USING <, t1.c1 -> Hash Join Output: t1.c1, t1.c3, t1.*, t2.c1, t2.* Hash Cond: (t1.c1 = t2.c1) @@ -1933,10 +2075,10 @@ SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c3, t Output: t1.c1, t2.c1, t1.c3, t1.*, t2.* -> Foreign Scan Output: t1.c1, t2.c1, t1.c3, t1.*, t2.* - SQLite query: SELECT r1.`C 1`, r1.`c3`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, r2.`C 1`, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST + SQLite query: SELECT r1.`C 1`, r2.`C 1`, r1.`c3`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST -> Sort Output: t1.c1, t1.c3, t1.*, t2.c1, t2.* - Sort Key: t1.c3, t1.c1 + Sort Key: t1.c3 COLLATE "default" USING <, t1.c1 -> Hash Join Output: t1.c1, t1.c3, t1.*, t2.c1, t2.* Hash Cond: (t1.c1 = t2.c1) @@ -1978,10 +2120,10 @@ SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c3, t Output: t1.c1, t2.c1, t1.c3, t1.*, t2.* -> Foreign Scan Output: t1.c1, t2.c1, t1.c3, t1.*, t2.* - SQLite query: SELECT r1.`C 1`, r1.`c3`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, r2.`C 1`, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST + SQLite query: SELECT r1.`C 1`, r2.`C 1`, r1.`c3`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST -> Sort Output: t1.c1, t1.c3, t1.*, t2.c1, t2.* - Sort Key: t1.c3, t1.c1 + Sort Key: t1.c3 COLLATE "default" USING <, t1.c1 -> Hash Join Output: t1.c1, t1.c3, t1.*, t2.c1, t2.* Hash Cond: (t1.c1 = t2.c1) @@ -2022,10 +2164,10 @@ SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c3, t Output: t1.c1, t2.c1, t1.c3, t1.*, t2.* -> Foreign Scan Output: t1.c1, t2.c1, t1.c3, t1.*, t2.* - SQLite query: SELECT r1.`C 1`, r1.`c3`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, r2.`C 1`, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST + SQLite query: SELECT r1.`C 1`, r2.`C 1`, r1.`c3`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST -> Sort Output: t1.c1, t1.c3, t1.*, t2.c1, t2.* - Sort Key: t1.c3, t1.c1 + Sort Key: t1.c3 COLLATE "default" USING <, t1.c1 -> Hash Join Output: t1.c1, t1.c3, t1.*, t2.c1, t2.* Hash Cond: (t1.c1 = t2.c1) @@ -2059,14 +2201,49 @@ SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c3, t --Testcase 119: EXPLAIN (VERBOSE, COSTS OFF) WITH t (c1_1, c1_3, c2_1) AS MATERIALIZED (SELECT t1.c1, t1.c3, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1)) SELECT c1_1, c2_1 FROM t ORDER BY c1_3, c1_1 OFFSET 100 LIMIT 10; -ERROR: syntax error at or near "MATERIALIZED" -LINE 2: WITH t (c1_1, c1_3, c2_1) AS MATERIALIZED (SELECT t1.c1, t1.... - ^ + QUERY PLAN +------------------------------------------------------------------------ + Limit + Output: t.c1_1, t.c2_1, t.c1_3 + CTE t + -> Merge Join + Output: t1.c1, t1.c3, t2.c1 + Merge Cond: (t1.c1 = t2.c1) + -> Sort + Output: t1.c1, t1.c3 + Sort Key: t1.c1 + -> Foreign Scan on public.ft1 t1 + Output: t1.c1, t1.c3 + SQLite query: SELECT `C 1`, `c3` FROM main."T 1" + -> Sort + Output: t2.c1 + Sort Key: t2.c1 + -> Foreign Scan on public.ft2 t2 + Output: t2.c1 + SQLite query: SELECT `C 1` FROM main."T 1" + -> Sort + Output: t.c1_1, t.c2_1, t.c1_3 + Sort Key: t.c1_3, t.c1_1 + -> CTE Scan on t + Output: t.c1_1, t.c2_1, t.c1_3 +(23 rows) + --Testcase 120: WITH t (c1_1, c1_3, c2_1) AS MATERIALIZED (SELECT t1.c1, t1.c3, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1)) SELECT c1_1, c2_1 FROM t ORDER BY c1_3, c1_1 OFFSET 100 LIMIT 10; -ERROR: syntax error at or near "MATERIALIZED" -LINE 1: WITH t (c1_1, c1_3, c2_1) AS MATERIALIZED (SELECT t1.c1, t1.... - ^ + c1_1 | c2_1 +------+------ + 101 | 101 + 102 | 102 + 103 | 103 + 104 | 104 + 105 | 105 + 106 | 106 + 107 | 107 + 108 | 108 + 109 | 109 + 110 | 110 +(10 rows) + -- ctid with whole-row reference --Testcase 121: EXPLAIN (VERBOSE, COSTS OFF) @@ -2075,7 +2252,7 @@ SELECT t1.ctid, t1, t2, t1.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1) ORDER B ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: t1.ctid, t1.*, t2.*, t1.c1, t1.c3 - SQLite query: SELECT r1.`ctid`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, r1.`C 1`, r1.`c3`, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST LIMIT 10 OFFSET 100 + SQLite query: SELECT r1.`ctid`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END, r1.`C 1`, r1.`c3` FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST LIMIT 10 OFFSET 100 (3 rows) -- SEMI JOIN, not pushed down @@ -2240,7 +2417,7 @@ SELECT t1.c1, t2.c1 FROM ft1 t1 LEFT JOIN ft2 t2 ON (t1.c1 = t2.c1) WHERE t1.c8 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: t1.c1, t2.c1, t1.c3 - SQLite query: SELECT r1.`C 1`, r1.`c3`, r2.`C 1` FROM (main."T 1" r1 LEFT JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) WHERE ((r1.`c8` = 'foo')) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST LIMIT 10 OFFSET 100 + SQLite query: SELECT r1.`C 1`, r2.`C 1`, r1.`c3` FROM (main."T 1" r1 LEFT JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)))) WHERE ((r1.`c8` = 'foo')) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST LIMIT 10 OFFSET 100 (3 rows) --Testcase 133: @@ -2270,7 +2447,7 @@ SELECT t1.c1, t2.c1 FROM ft1 t1 JOIN ft2 t2 ON (t1.c1 = t2.c1) WHERE t1.c8 = t2. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: t1.c1, t2.c1, t1.c3 - SQLite query: SELECT r1.`C 1`, r1.`c3`, r2.`C 1` FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)) AND ((r1.`c8` = r2.`c8`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST LIMIT 10 OFFSET 100 + SQLite query: SELECT r1.`C 1`, r2.`C 1`, r1.`c3` FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)) AND ((r1.`c8` = r2.`c8`)))) ORDER BY r1.`c3` ASC NULLS LAST, r1.`C 1` ASC NULLS LAST LIMIT 10 OFFSET 100 (3 rows) --Testcase 135: @@ -2489,7 +2666,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) @@ -2568,7 +2747,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 @@ -2582,6 +2763,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) @@ -2590,25 +2772,26 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN v5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c1 --------------------------------------------------------------------------- Limit Output: ft4.c1, ft5.c2, ft5.c1 - -> Sort + -> Incremental Sort Output: ft4.c1, ft5.c2, ft5.c1 Sort Key: ft4.c1, ft5.c1 - -> Merge Right Join + Presorted Key: ft4.c1 + -> Merge Left Join Output: ft4.c1, ft5.c2, ft5.c1 - Merge Cond: (ft5.c1 = ft4.c1) - -> Sort - Output: ft5.c2, ft5.c1 - Sort Key: ft5.c1 - -> Foreign Scan on public.ft5 - Output: ft5.c2, ft5.c1 - SQLite query: SELECT `c1`, `c2` FROM main."T 4" + Merge Cond: (ft4.c1 = ft5.c1) -> Sort Output: ft4.c1 Sort Key: ft4.c1 -> Foreign Scan on public.ft4 Output: ft4.c1 SQLite query: SELECT `c1` FROM main."T 3" -(20 rows) + -> Sort + Output: ft5.c2, ft5.c1 + Sort Key: ft5.c1 + -> Foreign Scan on public.ft5 + Output: ft5.c2, ft5.c1 + SQLite query: SELECT `c1`, `c2` FROM main."T 4" +(21 rows) --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; @@ -2626,6 +2809,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) @@ -2660,25 +2844,26 @@ SELECT t1.c1, t2.c2 FROM v4 t1 LEFT JOIN ft5 t2 ON (t1.c1 = t2.c1) ORDER BY t1.c --------------------------------------------------------------------------- Limit Output: ft4.c1, t2.c2, t2.c1 - -> Sort + -> Incremental Sort Output: ft4.c1, t2.c2, t2.c1 Sort Key: ft4.c1, t2.c1 - -> Merge Right Join + Presorted Key: ft4.c1 + -> Merge Left Join Output: ft4.c1, t2.c2, t2.c1 - Merge Cond: (t2.c1 = ft4.c1) - -> Sort - Output: t2.c2, t2.c1 - Sort Key: t2.c1 - -> Foreign Scan on public.ft5 t2 - Output: t2.c2, t2.c1 - SQLite query: SELECT `c1`, `c2` FROM main."T 4" + Merge Cond: (ft4.c1 = t2.c1) -> Sort Output: ft4.c1 Sort Key: ft4.c1 -> Foreign Scan on public.ft4 Output: ft4.c1 SQLite query: SELECT `c1` FROM main."T 3" -(20 rows) + -> Sort + Output: t2.c2, t2.c1 + Sort Key: t2.c1 + -> Foreign Scan on public.ft5 t2 + Output: t2.c2, t2.c1 + SQLite query: SELECT `c1`, `c2` FROM main."T 4" +(21 rows) --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; @@ -2696,6 +2881,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) @@ -2723,6 +2909,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: @@ -2747,7 +2934,7 @@ select count(c6), sum(c1), avg(c1), min(c2), max(c1), stddev(c2), sum(c1) * (ran Output: count(c6), sum(c1), avg(c1), min(c2), max(c1), stddev(c2), c2 Group Key: ft1.c2 -> Foreign Scan on public.ft1 - Output: c2, c6, c1 + Output: c6, c1, c2 SQLite query: SELECT `C 1`, `c2`, `c6` FROM main."T 1" WHERE ((`c2` < 5)) ORDER BY `c2` ASC NULLS LAST (11 rows) @@ -2778,7 +2965,7 @@ select count(c6), sum(c1), avg(c1), min(c2), max(c1), stddev(c2), sum(c1) * (ran Output: count(c6), sum(c1), avg(c1), min(c2), max(c1), stddev(c2), c2 Group Key: ft1.c2 -> Foreign Scan on public.ft1 - Output: c2, c6, c1 + Output: c6, c1, c2 SQLite query: SELECT `C 1`, `c2`, `c6` FROM main."T 1" WHERE ((`c2` < 5)) ORDER BY `c2` ASC NULLS LAST (13 rows) @@ -2971,6 +3158,7 @@ select count(c2) w, c2 x, 5 y, 7.0 z from ft1 group by 2, y, 9.0::int order by 2 -- GROUP BY clause referring to same column multiple times -- Also, ORDER BY contains an aggregate function --Testcase 170: +--Testcase 966: explain (verbose, costs off) select c2, c2 from ft1 where c2 > 6 group by 1, 2 order by sum(c1); QUERY PLAN @@ -3046,7 +3234,7 @@ select sum(c1) from ft1 group by c2 having avg(c1 * (random() <= 1)::int) > 100 Group Key: ft1.c2 Filter: (avg((ft1.c1 * ((random() <= '1'::double precision))::integer)) > '100'::numeric) -> Foreign Scan on public.ft1 - Output: c2, c1 + Output: c1, c2 SQLite query: SELECT `C 1`, `c2` FROM main."T 1" ORDER BY `c2` ASC NULLS LAST (10 rows) @@ -3107,7 +3295,7 @@ select array_agg(c1 order by c1) from ft1 where c1 < 100 group by c2 order by 1; Output: array_agg(c1 ORDER BY c1), c2 Group Key: ft1.c2 -> Foreign Scan on public.ft1 - Output: c2, c1 + Output: c1, c2 SQLite query: SELECT `C 1`, `c2` FROM main."T 1" WHERE ((`C 1` < 100)) ORDER BY `c2` ASC NULLS LAST (9 rows) @@ -3270,7 +3458,7 @@ select sum(c1) filter (where c1 < 100 and c2 > 5) from ft1 group by c2 order by Output: sum(c1) FILTER (WHERE ((c1 < 100) AND (c2 > 5))), c2 Group Key: ft1.c2 -> Foreign Scan on public.ft1 - Output: c2, c1 + Output: c1, c2 SQLite query: SELECT `C 1`, `c2` FROM main."T 1" ORDER BY `c2` ASC NULLS LAST (9 rows) @@ -3300,7 +3488,7 @@ select sum(c1%3), sum(distinct c1%3 order by c1%3) filter (where c1%3 < 2), c2 f Output: sum((c1 % 3)), sum(DISTINCT (c1 % 3) ORDER BY (c1 % 3)) FILTER (WHERE ((c1 % 3) < 2)), c2 Group Key: ft1.c2 -> Foreign Scan on public.ft1 - Output: c2, c1 + Output: c1, c2 SQLite query: SELECT `C 1`, `c2` FROM main."T 1" WHERE ((`c2` = 6)) (6 rows) @@ -3383,7 +3571,7 @@ select sum(c1) filter (where (c1 / c1) * random() <= 1) from ft1 group by c2 ord Output: sum(c1) FILTER (WHERE ((((c1 / c1))::double precision * random()) <= '1'::double precision)), c2 Group Key: ft1.c2 -> Foreign Scan on public.ft1 - Output: c2, c1 + Output: c1, c2 SQLite query: SELECT `C 1`, `c2` FROM main."T 1" ORDER BY `c2` ASC NULLS LAST (9 rows) @@ -3460,6 +3648,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: @@ -3528,6 +3717,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); @@ -3578,18 +3768,38 @@ select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 Output: array_agg(c1 ORDER BY c1 USING <^ NULLS LAST), c2 Group Key: ft2.c2 -> Foreign Scan on public.ft2 - Output: c2, c1 + Output: c1, c2 SQLite query: SELECT `C 1`, `c2` FROM main."T 1" WHERE ((`C 1` < 100)) AND ((`c2` = 6)) (6 rows) +-- This should not be pushed either. +--Testcase 967: +explain (verbose, costs off) +select * from ft2 order by c1 using operator(public.<^); + QUERY PLAN +---------------------------------------------------------------------------------------------- + Sort + Output: c1, c2, c3, c4, c5, c6, c7, c8 + Sort Key: ft2.c1 USING <^ + -> Foreign Scan on public.ft2 + Output: c1, c2, c3, c4, c5, c6, c7, c8 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" +(6 rows) + -- 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. @@ -3602,7 +3812,7 @@ select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 Output: array_agg(c1 ORDER BY c1 USING <^ NULLS LAST), c2 Group Key: ft2.c2 -> Foreign Scan on public.ft2 - Output: c2, c1 + Output: c1, c2 SQLite query: SELECT `C 1`, `c2` FROM main."T 1" WHERE ((`C 1` < 100)) AND ((`c2` = 6)) (6 rows) @@ -3613,12 +3823,33 @@ select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 {6,16,26,36,46,56,66,76,86,96} (1 row) +-- This should be pushed too. +-- Sqlite not support pushdown user defined operators +--Testcase 968: +explain (verbose, costs off) +select * from ft2 order by c1 using operator(public.<^); + QUERY PLAN +---------------------------------------------------------------------------------------------- + Sort + Output: c1, c2, c3, c4, c5, c6, c7, c8 + Sort Key: ft2.c1 USING <^ + -> Foreign Scan on public.ft2 + Output: c1, c2, c3, c4, c5, c6, c7, c8 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" +(6 rows) + -- 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. @@ -3631,7 +3862,7 @@ select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 Output: array_agg(c1 ORDER BY c1 USING <^ NULLS LAST), c2 Group Key: ft2.c2 -> Foreign Scan on public.ft2 - Output: c2, c1 + Output: c1, c2 SQLite query: SELECT `C 1`, `c2` FROM main."T 1" WHERE ((`C 1` < 100)) AND ((`c2` = 6)) (6 rows) @@ -3804,6 +4035,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) @@ -3831,6 +4063,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: @@ -4190,21 +4423,24 @@ EXECUTE st1(101, 101); PREPARE st2(int) AS SELECT * FROM ft1 t1 WHERE t1.c1 < $2 AND t1.c3 IN (SELECT c3 FROM ft2 t2 WHERE c1 > $1 AND date(c4) = '1970-01-17'::date) ORDER BY c1; --Testcase 235: EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st2(10, 20); - QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------- - Nested Loop Semi Join + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort Output: t1.c1, t1.c2, t1.c3, t1.c4, t1.c5, t1.c6, t1.c7, t1.c8 - Join Filter: (t1.c3 = t2.c3) - -> Foreign Scan on public.ft1 t1 + Sort Key: t1.c1 + -> Hash Semi Join Output: t1.c1, t1.c2, t1.c3, t1.c4, t1.c5, t1.c6, t1.c7, t1.c8 - SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` < 20)) ORDER BY `C 1` ASC NULLS LAST - -> Materialize - Output: t2.c3 - -> Foreign Scan on public.ft2 t2 + Hash Cond: (t1.c3 = t2.c3) + -> Foreign Scan on public.ft1 t1 + Output: t1.c1, t1.c2, t1.c3, t1.c4, t1.c5, t1.c6, t1.c7, t1.c8 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` < 20)) ORDER BY `C 1` ASC NULLS LAST + -> Hash Output: t2.c3 - Filter: (date(t2.c4) = '01-17-1970'::date) - SQLite query: SELECT `c3`, `c4` FROM main."T 1" WHERE ((`C 1` > 10)) -(12 rows) + -> Foreign Scan on public.ft2 t2 + Output: t2.c3 + Filter: (date(t2.c4) = '01-17-1970'::date) + SQLite query: SELECT `c3`, `c4` FROM main."T 1" WHERE ((`C 1` > 10)) +(15 rows) --Testcase 236: EXECUTE st2(10, 20); @@ -4225,21 +4461,24 @@ EXECUTE st2(101, 121); PREPARE st3(int) AS SELECT * FROM ft1 t1 WHERE t1.c1 < $2 AND t1.c3 IN (SELECT c3 FROM ft2 t2 WHERE c1 > $1 AND date(c5) = '1970-01-17'::date) ORDER BY c1; --Testcase 239: EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st3(10, 20); - QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------- - Nested Loop Semi Join + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------- + Sort Output: t1.c1, t1.c2, t1.c3, t1.c4, t1.c5, t1.c6, t1.c7, t1.c8 - Join Filter: (t1.c3 = t2.c3) - -> Foreign Scan on public.ft1 t1 + Sort Key: t1.c1 + -> Hash Semi Join Output: t1.c1, t1.c2, t1.c3, t1.c4, t1.c5, t1.c6, t1.c7, t1.c8 - SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` < 20)) ORDER BY `C 1` ASC NULLS LAST - -> Materialize - Output: t2.c3 - -> Foreign Scan on public.ft2 t2 + Hash Cond: (t1.c3 = t2.c3) + -> Foreign Scan on public.ft1 t1 + Output: t1.c1, t1.c2, t1.c3, t1.c4, t1.c5, t1.c6, t1.c7, t1.c8 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` < 20)) ORDER BY `C 1` ASC NULLS LAST + -> Hash Output: t2.c3 - Filter: (date(t2.c5) = '01-17-1970'::date) - SQLite query: SELECT `c3`, `c5` FROM main."T 1" WHERE ((`C 1` > 10)) -(12 rows) + -> Foreign Scan on public.ft2 t2 + Output: t2.c3 + Filter: (date(t2.c5) = '01-17-1970'::date) + SQLite query: SELECT `c3`, `c5` FROM main."T 1" WHERE ((`C 1` > 10)) +(15 rows) --Testcase 240: EXECUTE st3(10, 20); @@ -4395,12 +4634,14 @@ EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st7; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Insert on public.ft1 + Batch Size: 1 -> Result 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 -(3 rows) +(4 rows) --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; @@ -4431,10 +4672,12 @@ EXPLAIN (VERBOSE, COSTS OFF) EXECUTE st7; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Insert on public.ft1 + Batch Size: 1 -> Result 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 -(3 rows) +(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; @@ -4576,22 +4819,111 @@ SELECT f_test(100); --Testcase 557: 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 +-- ANALYZE ft1; -- ERROR +-- =================================================================== +-- local type can be different from remote type in some cases, +-- in particular if similarly-named operators do equivalent things +-- =================================================================== +--Testcase 811: ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE text; +--Testcase 969: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE c8 = 'foo' LIMIT 1; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.ft1 + Output: c1, c2, c3, c4, c5, c6, c7, c8 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`c8` = 'foo')) LIMIT 1 +(3 rows) + +--Testcase 970: +SELECT * FROM ft1 WHERE c8 = 'foo' LIMIT 1; + c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 +----+----+-------+------------------------------+--------------------------+----+------------+----- + 1 | 1 | 00001 | Fri Jan 02 00:00:00 1970 PST | Fri Jan 02 00:00:00 1970 | 1 | 1 | foo +(1 row) + +--Testcase 971: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE 'foo' = c8 LIMIT 1; + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.ft1 + Output: c1, c2, c3, c4, c5, c6, c7, c8 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE (('foo' = `c8`)) LIMIT 1 +(3 rows) + +--Testcase 972: +SELECT * FROM ft1 WHERE 'foo' = c8 LIMIT 1; + c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 +----+----+-------+------------------------------+--------------------------+----+------------+----- + 1 | 1 | 00001 | Fri Jan 02 00:00:00 1970 PST | Fri Jan 02 00:00:00 1970 | 1 | 1 | foo +(1 row) + +-- we declared c8 to be text locally, but it's still the same type on +-- the remote which will balk if we try to do anything incompatible +-- with that remote type +-- Can not create user define type in SqliteDB. +-- Type c8 of foreign table ft1 and remote table T1 are +-- match. These case below not error with sqlite_fdw. +-- with that remote type +--Testcase 973: +SELECT * FROM ft1 WHERE c8 LIKE 'foo' LIMIT 1; -- ERROR + c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 +----+----+-------+------------------------------+--------------------------+----+------------+----- + 1 | 1 | 00001 | Fri Jan 02 00:00:00 1970 PST | Fri Jan 02 00:00:00 1970 | 1 | 1 | foo +(1 row) + +--Testcase 974: +SELECT * FROM ft1 WHERE c8::text LIKE 'foo' LIMIT 1; -- ERROR; cast not pushed down + c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 +----+----+-------+------------------------------+--------------------------+----+------------+----- + 1 | 1 | 00001 | Fri Jan 02 00:00:00 1970 PST | Fri Jan 02 00:00:00 1970 | 1 | 1 | foo +(1 row) + -- =================================================================== -- subtransaction -- + local/remote error doesn't break cursor @@ -4746,12 +5078,13 @@ INSERT INTO ft2 (c1,c2,c3) SELECT c1+1000,c2+100, c3 || c3 FROM ft2 LIMIT 20; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Insert on public.ft2 + Batch Size: 1 -> Subquery Scan on "*SELECT*" Output: "*SELECT*"."?column?", "*SELECT*"."?column?_1", NULL::integer, "*SELECT*"."?column?_2", NULL::timestamp with time zone, NULL::timestamp without time zone, NULL::character varying, 'ft2 '::character(10), NULL::text -> Foreign Scan on public.ft2 ft2_1 Output: (ft2_1.c1 + 1000), (ft2_1.c2 + 100), (ft2_1.c3 || ft2_1.c3) SQLite query: SELECT `C 1`, `c2`, `c3` FROM main."T 1" LIMIT 20 -(6 rows) +(7 rows) --Testcase 283: INSERT INTO ft2 (c1,c2,c3) SELECT c1+1000,c2+100, c3 || c3 FROM ft2 LIMIT 20; @@ -4904,18 +5237,18 @@ SELECT * FROM ft2 WHERE c1 % 10 = 7; EXPLAIN (verbose, costs off) UPDATE ft2 SET c2 = ft2.c2 + 500, c3 = ft2.c3 || '_update9', c7 = DEFAULT FROM ft1 WHERE ft1.c1 = ft2.c2 AND ft1.c1 % 10 = 9; -- can be pushed down - QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Update on public.ft2 -> Foreign Scan - Output: ft2.c1, (ft2.c2 + 500), NULL::integer, (ft2.c3 || '_update9'::text), ft2.c4, ft2.c5, ft2.c6, 'ft2 '::character(10), ft2.c8, ft2.c1, ft1.* - SQLite query: SELECT r1.`C 1`, r1.`c2`, r1.`c3`, r1.`c4`, r1.`c5`, r1.`c6`, r1.`c8`, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`c2` = r2.`C 1`)) AND (((r2.`C 1` % 10) = 9)))) + Output: (ft2.c2 + 500), (ft2.c3 || '_update9'::text), 'ft2 '::character(10), ft2.c1, ft2.*, ft1.* + SQLite query: SELECT r1.`c2`, r1.`c3`, r1.`C 1`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`c2` = r2.`C 1`)) AND (((r2.`C 1` % 10) = 9)))) -> Hash Join - Output: ft2.c1, ft2.c2, ft2.c3, ft2.c4, ft2.c5, ft2.c6, ft2.c8, ft1.* + Output: ft2.c2, ft2.c3, ft2.c1, ft2.*, ft1.* Hash Cond: (ft2.c2 = ft1.c1) -> Foreign Scan on public.ft2 - Output: ft2.c1, ft2.c2, ft2.c3, ft2.c4, ft2.c5, ft2.c6, ft2.c8 - SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c8` FROM main."T 1" + Output: ft2.c2, ft2.c3, ft2.c1, ft2.* + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" -> Hash Output: ft1.*, ft1.c1 -> Foreign Scan on public.ft1 @@ -5902,9 +6235,10 @@ INSERT INTO ft2 (c1,c2,c3) VALUES (1200,999,'foo'); QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Insert on public.ft2 + Batch Size: 1 -> Result Output: 1200, 999, NULL::integer, 'foo'::text, NULL::timestamp with time zone, NULL::timestamp without time zone, NULL::character varying, 'ft2 '::character(10), NULL::text -(3 rows) +(4 rows) --Testcase 301: INSERT INTO ft2 (c1,c2,c3) VALUES (1200,999,'foo'); @@ -5941,26 +6275,26 @@ EXPLAIN (verbose, costs off) UPDATE ft2 SET c3 = 'foo' FROM ft4 INNER JOIN ft5 ON (ft4.c1 = ft5.c1) WHERE ft2.c1 > 1200 AND ft2.c2 = ft4.c1; -- can be pushed down - QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Update on public.ft2 -> Hash Join - Output: ft2.c1, ft2.c2, NULL::integer, 'foo'::text, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft2.c1, ft4.*, ft5.* + Output: 'foo'::text, ft2.c1, ft2.*, ft4.*, ft5.* Hash Cond: (ft5.c1 = ft4.c1) -> Foreign Scan on public.ft5 Output: ft5.*, ft5.c1 SQLite query: SELECT `c1`, `c2`, `c3` FROM main."T 4" -> Hash - Output: ft2.c1, ft2.c2, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft4.*, ft4.c1 + Output: ft2.c1, ft2.*, ft2.c2, ft4.*, ft4.c1 -> Foreign Scan - Output: ft2.c1, ft2.c2, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft4.*, ft4.c1 - SQLite query: SELECT r1.`C 1`, r1.`c2`, r1.`c4`, r1.`c5`, r1.`c6`, r1.`c7`, r1.`c8`, CASE WHEN ( r2.`c1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) THEN ("(" || COALESCE(r2.`c1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '')|| ")") END, r2.`c1` FROM (main."T 1" r1 INNER JOIN main."T 3" r2 ON (((r1.`c2` = r2.`c1`)) AND ((r1.`C 1` > 1200)))) + Output: ft2.c1, ft2.*, ft2.c2, ft4.*, ft4.c1 + SQLite query: SELECT r1.`C 1`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, r1.`c2`, CASE WHEN ( r2.`c1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) THEN ("(" || COALESCE(r2.`c1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '')|| ")") END, r2.`c1` FROM (main."T 1" r1 INNER JOIN main."T 3" r2 ON (((r1.`c2` = r2.`c1`)) AND ((r1.`C 1` > 1200)))) -> Hash Join - Output: ft2.c1, ft2.c2, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft4.*, ft4.c1 + Output: ft2.c1, ft2.*, ft2.c2, ft4.*, ft4.c1 Hash Cond: (ft2.c2 = ft4.c1) -> Foreign Scan on public.ft2 - Output: ft2.c1, ft2.c2, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8 - SQLite query: SELECT `C 1`, `c2`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` > 1200)) + Output: ft2.c1, ft2.*, ft2.c2 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` > 1200)) -> Hash Output: ft4.*, ft4.c1 -> Foreign Scan on public.ft4 @@ -6060,12 +6394,12 @@ UPDATE ft2 AS target SET (c2, c7) = ( FROM ft2 AS src WHERE target.c1 = src.c1 ) WHERE c1 > 1100; - QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------- Update on public.ft2 target -> Foreign Scan on public.ft2 target - Output: target.c1, $1, NULL::integer, target.c3, target.c4, target.c5, target.c6, $2, target.c8, (SubPlan 1 (returns $1,$2)), target.c1 - SQLite query: SELECT `C 1`, `c3`, `c4`, `c5`, `c6`, `c8` FROM main."T 1" WHERE ((`C 1` > 1100)) + Output: $1, $2, (SubPlan 1 (returns $1,$2)), target.c1, target.* + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` > 1100)) SubPlan 1 (returns $1,$2) -> Foreign Scan on public.ft2 src Output: (src.c2 * 10), src.c7 @@ -6084,6 +6418,34 @@ UPDATE ft2 AS target SET (c2) = ( FROM ft2 AS src WHERE target.c1 = src.c1 ) 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; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Update on public.ft2 d + -> Foreign Scan + Output: CASE WHEN (random() >= '0'::double precision) THEN d.c2 ELSE 0 END, d.c1, d.*, t.* + SQLite query: SELECT r1.`c2`, r1.`C 1`, CASE WHEN ( r1.`C 1` IS NOT NULL) OR ( r1.`c2` IS NOT NULL) OR ( r1.`c3` IS NOT NULL) OR ( r1.`c4` IS NOT NULL) OR ( r1.`c5` IS NOT NULL) OR ( r1.`c6` IS NOT NULL) OR ( r1.`c7` IS NOT NULL) OR ( r1.`c8` IS NOT NULL) THEN ("(" || COALESCE(r1.`C 1`, '') || "," || COALESCE(r1.`c2`, '') || "," || COALESCE(r1.`c3`, '') || "," || COALESCE(r1.`c4`, '') || "," || COALESCE(r1.`c5`, '') || "," || COALESCE(r1.`c6`, '') || "," || COALESCE(r1.`c7`, '') || "," || COALESCE(r1.`c8`, '')|| ")") END, CASE WHEN ( r2.`C 1` IS NOT NULL) OR ( r2.`c2` IS NOT NULL) OR ( r2.`c3` IS NOT NULL) OR ( r2.`c4` IS NOT NULL) OR ( r2.`c5` IS NOT NULL) OR ( r2.`c6` IS NOT NULL) OR ( r2.`c7` IS NOT NULL) OR ( r2.`c8` IS NOT NULL) THEN ("(" || COALESCE(r2.`C 1`, '') || "," || COALESCE(r2.`c2`, '') || "," || COALESCE(r2.`c3`, '') || "," || COALESCE(r2.`c4`, '') || "," || COALESCE(r2.`c5`, '') || "," || COALESCE(r2.`c6`, '') || "," || COALESCE(r2.`c7`, '') || "," || COALESCE(r2.`c8`, '')|| ")") END FROM (main."T 1" r1 INNER JOIN main."T 1" r2 ON (((r1.`C 1` = r2.`C 1`)) AND ((r1.`C 1` > 1000)))) + -> Hash Join + Output: d.c2, d.c1, d.*, t.* + Hash Cond: (d.c1 = t.c1) + -> Foreign Scan on public.ft2 d + Output: d.c2, d.c1, d.* + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` > 1000)) + -> Hash + Output: t.*, t.c1 + -> Foreign Scan on public.ft2 t + Output: t.*, t.c1 + 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 -- user-defined operators/functions --ALTER SERVER loopback OPTIONS (DROP extensions); @@ -6093,13 +6455,13 @@ INSERT INTO ft2 (c1,c2,c3) --Testcase 575: EXPLAIN (verbose, costs off) UPDATE ft2 SET c3 = 'bar' WHERE sqlite_fdw_abs(c1) > 2000; -- can't be pushed down - QUERY PLAN ----------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------------------------------------------------------- Update on public.ft2 -> Foreign Scan on public.ft2 - Output: c1, c2, NULL::integer, 'bar'::text, c4, c5, c6, c7, c8, c1 + Output: 'bar'::text, c1, ft2.* Filter: (sqlite_fdw_abs(ft2.c1) > 2000) - SQLite query: SELECT `C 1`, `c2`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" (5 rows) --Testcase 576: @@ -6125,11 +6487,11 @@ EXPLAIN (verbose, costs off) UPDATE ft2 SET c3 = 'baz' FROM ft4 INNER JOIN ft5 ON (ft4.c1 = ft5.c1) WHERE ft2.c1 > 2000 AND ft2.c2 === ft4.c1; -- can't be pushed down - QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------------- Update on public.ft2 -> Nested Loop - Output: ft2.c1, ft2.c2, NULL::integer, 'baz'::text, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8, ft2.c1, ft4.*, ft5.* + Output: 'baz'::text, ft2.c1, ft2.*, ft4.*, ft5.* Join Filter: (ft2.c2 === ft4.c1) -> Hash Join Output: ft4.*, ft4.c1, ft5.* @@ -6143,10 +6505,10 @@ UPDATE ft2 SET c3 = 'baz' Output: ft5.*, ft5.c1 SQLite query: SELECT `c1`, `c2`, `c3` FROM main."T 4" -> Materialize - Output: ft2.c1, ft2.c2, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8 + Output: ft2.c1, ft2.*, ft2.c2 -> Foreign Scan on public.ft2 - Output: ft2.c1, ft2.c2, ft2.c4, ft2.c5, ft2.c6, ft2.c7, ft2.c8 - SQLite query: SELECT `C 1`, `c2`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` > 2000)) + Output: ft2.c1, ft2.*, ft2.c2 + SQLite query: SELECT `C 1`, `c2`, `c3`, `c4`, `c5`, `c6`, `c7`, `c8` FROM main."T 1" WHERE ((`C 1` > 2000)) (20 rows) --Testcase 579: @@ -6752,6 +7114,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; @@ -6769,6 +7132,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; @@ -6787,6 +7151,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: @@ -6797,8 +7162,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; @@ -6816,6 +7183,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; @@ -6834,12 +7202,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 @@ -6874,9 +7244,10 @@ INSERT INTO rw_view VALUES (0, 5); QUERY PLAN ------------------------------ Insert on public.foreign_tbl + Batch Size: 1 -> Result Output: 0, 5 -(3 rows) +(4 rows) --Testcase 602: INSERT INTO rw_view VALUES (0, 5); -- should fail @@ -6888,9 +7259,10 @@ INSERT INTO rw_view VALUES (0, 15); QUERY PLAN ------------------------------ Insert on public.foreign_tbl + Batch Size: 1 -> Result Output: 0, 15 -(3 rows) +(4 rows) --Testcase 604: INSERT INTO rw_view VALUES (0, 15); -- error @@ -6908,7 +7280,7 @@ UPDATE rw_view SET b = b + 5; ----------------------------------------------------------------------------------- Update on public.foreign_tbl -> Foreign Scan on public.foreign_tbl - Output: foreign_tbl.a, (foreign_tbl.b + 5), foreign_tbl.a, foreign_tbl.* + Output: (foreign_tbl.b + 5), foreign_tbl.a, foreign_tbl.* SQLite query: SELECT `a`, `b` FROM main."foreign_tbl" WHERE ((`a` < `b`)) (4 rows) @@ -6923,7 +7295,7 @@ UPDATE rw_view SET b = b + 15; ----------------------------------------------------------------------------------- Update on public.foreign_tbl -> Foreign Scan on public.foreign_tbl - Output: foreign_tbl.a, (foreign_tbl.b + 15), foreign_tbl.a, foreign_tbl.* + Output: (foreign_tbl.b + 15), foreign_tbl.a, foreign_tbl.* SQLite query: SELECT `a`, `b` FROM main."foreign_tbl" WHERE ((`a` < `b`)) (4 rows) @@ -6950,6 +7322,12 @@ 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); +-- Detach and re-attach once, to stress the concurrent detach case. +--Testcase 975: +ALTER TABLE parent_tbl DETACH PARTITION foreign_tbl CONCURRENTLY; +--Testcase 976: 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 @@ -6980,7 +7358,7 @@ INSERT INTO rw_view VALUES (0, 5); --Testcase 619: INSERT INTO rw_view VALUES (0, 5); -- should fail -ERROR: cannot route inserted tuples to a foreign table +ERROR: Not support partition insert --Testcase 620: EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO rw_view VALUES (0, 15); @@ -6993,7 +7371,7 @@ INSERT INTO rw_view VALUES (0, 15); --Testcase 621: INSERT INTO rw_view VALUES (0, 15); -- ok -ERROR: cannot route inserted tuples to a foreign table +ERROR: Not support partition insert --Testcase 622: SELECT * FROM foreign_tbl; a | b @@ -7004,12 +7382,12 @@ SELECT * FROM foreign_tbl; --Testcase 623: EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view SET b = b + 5; - QUERY PLAN ------------------------------------------------------------------------------------ + QUERY PLAN +--------------------------------------------------------------------------------------------- Update on public.parent_tbl - Foreign Update on public.foreign_tbl - -> Foreign Scan on public.foreign_tbl - Output: foreign_tbl.a, (foreign_tbl.b + 5), foreign_tbl.a, foreign_tbl.* + Foreign Update on public.foreign_tbl parent_tbl_1 + -> Foreign Scan on public.foreign_tbl parent_tbl_1 + Output: (parent_tbl_1.b + 5), parent_tbl_1.tableoid, parent_tbl_1.a, parent_tbl_1.* SQLite query: SELECT `a`, `b` FROM main."foreign_tbl" WHERE ((`a` < `b`)) (5 rows) @@ -7018,12 +7396,12 @@ UPDATE rw_view SET b = b + 5; -- should fail --Testcase 625: EXPLAIN (VERBOSE, COSTS OFF) UPDATE rw_view SET b = b + 15; - QUERY PLAN ------------------------------------------------------------------------------------ + QUERY PLAN +---------------------------------------------------------------------------------------------- Update on public.parent_tbl - Foreign Update on public.foreign_tbl - -> Foreign Scan on public.foreign_tbl - Output: foreign_tbl.a, (foreign_tbl.b + 15), foreign_tbl.a, foreign_tbl.* + Foreign Update on public.foreign_tbl parent_tbl_1 + -> Foreign Scan on public.foreign_tbl parent_tbl_1 + Output: (parent_tbl_1.b + 15), parent_tbl_1.tableoid, parent_tbl_1.a, parent_tbl_1.* SQLite query: SELECT `a`, `b` FROM main."foreign_tbl" WHERE ((`a` < `b`)) (5 rows) @@ -7096,29 +7474,82 @@ 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; -ERROR: syntax error at or near "(" -LINE 3: b int generated always as (a * 2) stored) - ^ + 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); -ERROR: relation "grem1" does not exist -LINE 1: 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; -ERROR: relation "grem1" does not exist -LINE 1: update grem1 set a = 22 where a = 2; - ^ --Testcase 640: select * from grem1; -ERROR: relation "grem1" does not exist -LINE 1: select * from grem1; - ^ --- =================================================================== --- test local triggers --- =================================================================== --- Trigger functions "borrowed" from triggers regress test. + a | b +----+---- + 1 | 2 + 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 +-- =================================================================== +-- Trigger functions "borrowed" from triggers regress test. --Testcase 641: CREATE FUNCTION trigger_func() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN @@ -7391,7 +7822,7 @@ UPDATE rem1 set f1 = 10; -- all columns should be transmitted ---------------------------------------------------------------- Update on public.rem1 -> Foreign Scan on public.rem1 - Output: 10, f2, id, id, rem1.* + Output: 10, id, rem1.* SQLite query: SELECT `f1`, `f2`, `id` FROM main."loc1" (4 rows) @@ -7542,6 +7973,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 @@ -7660,7 +8112,7 @@ UPDATE rem1 set f2 = ''; -- can't be pushed down ---------------------------------------------------------------- Update on public.rem1 -> Foreign Scan on public.rem1 - Output: f1, ''::text, id, id, rem1.* + Output: ''::text, id, rem1.* SQLite query: SELECT `f1`, `f2`, `id` FROM main."loc1" (4 rows) @@ -7687,7 +8139,7 @@ UPDATE rem1 set f2 = ''; -- can't be pushed down ---------------------------------------------------------------- Update on public.rem1 -> Foreign Scan on public.rem1 - Output: f1, ''::text, id, id, rem1.* + Output: ''::text, id, rem1.* SQLite query: SELECT `f1`, `f2`, `id` FROM main."loc1" (4 rows) @@ -7763,6 +8215,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) @@ -7940,7 +8393,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); @@ -7968,27 +8423,27 @@ select * from bar where f1 in (select f1 from foo) for update; QUERY PLAN ---------------------------------------------------------------------------------------------- LockRows - Output: bar.f1, bar.f2, bar.ctid, bar.*, bar.tableoid, foo.ctid, foo.*, foo.tableoid + Output: bar.f1, bar.f2, bar.ctid, foo.ctid, bar.*, bar.tableoid, foo.*, foo.tableoid -> Hash Join - Output: bar.f1, bar.f2, bar.ctid, bar.*, bar.tableoid, foo.ctid, foo.*, foo.tableoid + Output: bar.f1, bar.f2, bar.ctid, foo.ctid, bar.*, bar.tableoid, foo.*, foo.tableoid Inner Unique: true Hash Cond: (bar.f1 = foo.f1) -> Append - -> Seq Scan on public.bar - Output: bar.f1, bar.f2, bar.ctid, bar.*, bar.tableoid - -> Foreign Scan on public.bar2 - Output: bar2.f1, bar2.f2, bar2.ctid, bar2.*, bar2.tableoid + -> Seq Scan on public.bar bar_1 + Output: bar_1.f1, bar_1.f2, bar_1.ctid, bar_1.*, bar_1.tableoid + -> Foreign Scan on public.bar2 bar_2 + Output: bar_2.f1, bar_2.f2, bar_2.ctid, bar_2.*, bar_2.tableoid SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" -> Hash - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 + Output: foo.ctid, foo.f1, foo.*, foo.tableoid -> HashAggregate - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 + Output: foo.ctid, foo.f1, foo.*, foo.tableoid Group Key: foo.f1 -> Append - -> Seq Scan on public.foo - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 - -> Foreign Scan on public.foo2 - Output: foo2.ctid, foo2.*, foo2.tableoid, foo2.f1 + -> Seq Scan on public.foo foo_1 + Output: foo_1.ctid, foo_1.f1, foo_1.*, foo_1.tableoid + -> Foreign Scan on public.foo2 foo_2 + Output: foo_2.ctid, foo_2.f1, foo_2.*, foo_2.tableoid SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct1" (23 rows) @@ -8008,27 +8463,27 @@ select * from bar where f1 in (select f1 from foo) for share; QUERY PLAN ---------------------------------------------------------------------------------------------- LockRows - Output: bar.f1, bar.f2, bar.ctid, bar.*, bar.tableoid, foo.ctid, foo.*, foo.tableoid + Output: bar.f1, bar.f2, bar.ctid, foo.ctid, bar.*, bar.tableoid, foo.*, foo.tableoid -> Hash Join - Output: bar.f1, bar.f2, bar.ctid, bar.*, bar.tableoid, foo.ctid, foo.*, foo.tableoid + Output: bar.f1, bar.f2, bar.ctid, foo.ctid, bar.*, bar.tableoid, foo.*, foo.tableoid Inner Unique: true Hash Cond: (bar.f1 = foo.f1) -> Append - -> Seq Scan on public.bar - Output: bar.f1, bar.f2, bar.ctid, bar.*, bar.tableoid - -> Foreign Scan on public.bar2 - Output: bar2.f1, bar2.f2, bar2.ctid, bar2.*, bar2.tableoid + -> Seq Scan on public.bar bar_1 + Output: bar_1.f1, bar_1.f2, bar_1.ctid, bar_1.*, bar_1.tableoid + -> Foreign Scan on public.bar2 bar_2 + Output: bar_2.f1, bar_2.f2, bar_2.ctid, bar_2.*, bar_2.tableoid SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" -> Hash - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 + Output: foo.ctid, foo.f1, foo.*, foo.tableoid -> HashAggregate - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 + Output: foo.ctid, foo.f1, foo.*, foo.tableoid Group Key: foo.f1 -> Append - -> Seq Scan on public.foo - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 - -> Foreign Scan on public.foo2 - Output: foo2.ctid, foo2.*, foo2.tableoid, foo2.f1 + -> Seq Scan on public.foo foo_1 + Output: foo_1.ctid, foo_1.f1, foo_1.*, foo_1.tableoid + -> Foreign Scan on public.foo2 foo_2 + Output: foo_2.ctid, foo_2.f1, foo_2.*, foo_2.tableoid SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct1" (23 rows) @@ -8042,51 +8497,130 @@ select * from bar where f1 in (select f1 from foo) for share; 4 | 44 (4 rows) --- Check UPDATE with inherited target and an inherited source table ---Testcase 451: +-- 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) -update bar set f2 = f2 + 100 where f1 in (select f1 from foo); +select * from bar where f1 in (select f1 from foo2) for share; QUERY PLAN ------------------------------------------------------------------------------------------- - Update on public.bar - Update on public.bar - Foreign Update on public.bar2 + LockRows + Output: bar.f1, bar.f2, bar.ctid, foo2.*, bar.*, bar.tableoid, foo2.tableoid -> Hash Join - Output: bar.f1, (bar.f2 + 100), bar.ctid, foo.ctid, foo.*, foo.tableoid + Output: bar.f1, bar.f2, bar.ctid, foo2.*, bar.*, bar.tableoid, foo2.tableoid Inner Unique: true - Hash Cond: (bar.f1 = foo.f1) - -> Seq Scan on public.bar - Output: bar.f1, bar.f2, bar.ctid + Hash Cond: (bar.f1 = foo2.f1) + -> Append + -> Seq Scan on public.bar bar_1 + Output: bar_1.f1, bar_1.f2, bar_1.ctid, bar_1.*, bar_1.tableoid + -> Foreign Scan on public.bar2 bar_2 + Output: bar_2.f1, bar_2.f2, bar_2.ctid, bar_2.*, bar_2.tableoid + SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" -> Hash - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 + Output: foo2.*, foo2.f1, foo2.tableoid -> HashAggregate - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 - Group Key: foo.f1 + Output: foo2.*, foo2.f1, foo2.tableoid + Group Key: foo2.f1 + -> Append + -> Foreign Scan on public.foo2 foo2_1 + Output: foo2_1.*, foo2_1.f1, foo2_1.tableoid + SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct1" + -> Foreign Scan on public.foo2child foo2_2 + Output: foo2_2.*, foo2_2.f1, foo2_2.tableoid + 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 +----+---- + 2 | 22 + 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 +------------------------------------------------------------------------------------------------- + LockRows + Output: bar.f1, bar.f2, bar.ctid, foo2.*, bar.*, bar.tableoid, foo2.ctid, foo2.tableoid + -> Hash Join + Output: bar.f1, bar.f2, bar.ctid, foo2.*, bar.*, bar.tableoid, foo2.ctid, foo2.tableoid + Inner Unique: true + Hash Cond: (bar.f1 = foo2.f1) + -> Append + -> Seq Scan on public.bar bar_1 + Output: bar_1.f1, bar_1.f2, bar_1.ctid, bar_1.*, bar_1.tableoid + -> Foreign Scan on public.bar2 bar_2 + Output: bar_2.f1, bar_2.f2, bar_2.ctid, bar_2.*, bar_2.tableoid + SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" + -> Hash + Output: foo2.*, foo2.f1, foo2.ctid, foo2.tableoid + -> HashAggregate + Output: foo2.*, foo2.f1, foo2.ctid, foo2.tableoid + Group Key: foo2.f1 -> Append - -> Seq Scan on public.foo - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 - -> Foreign Scan on public.foo2 - Output: foo2.ctid, foo2.*, foo2.tableoid, foo2.f1 + -> Foreign Scan on public.foo2 foo2_1 + Output: foo2_1.*, foo2_1.f1, foo2_1.ctid, foo2_1.tableoid SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct1" + -> Seq Scan on public.foo2child foo2_2 + 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 +----+---- + 2 | 22 + 4 | 44 +(2 rows) + +--Testcase 844: +drop table foo2child; +-- Check UPDATE with inherited target and an inherited source table +--Testcase 451: +explain (verbose, costs off) +update bar set f2 = f2 + 100 where f1 in (select f1 from foo); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------ + Update on public.bar + Update on public.bar bar_1 + Foreign Update on public.bar2 bar_2 -> Hash Join - Output: bar2.f1, (bar2.f2 + 100), bar2.f3, bar2.f3, foo.ctid, foo.*, foo.tableoid + Output: (bar.f2 + 100), foo.ctid, bar.tableoid, bar.ctid, (NULL::integer), (NULL::record), foo.*, foo.tableoid Inner Unique: true - Hash Cond: (bar2.f1 = foo.f1) - -> Foreign Scan on public.bar2 - Output: bar2.f1, bar2.f2, bar2.f3 - SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" + Hash Cond: (bar.f1 = foo.f1) + -> Append + -> Seq Scan on public.bar bar_1 + Output: bar_1.f2, bar_1.f1, bar_1.tableoid, bar_1.ctid, NULL::integer, NULL::record + -> Foreign Scan on public.bar2 bar_2 + Output: bar_2.f2, bar_2.f1, bar_2.tableoid, NULL::tid, bar_2.f3, bar_2.* + SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" -> Hash - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 + Output: foo.ctid, foo.f1, foo.*, foo.tableoid -> HashAggregate - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 + Output: foo.ctid, foo.f1, foo.*, foo.tableoid Group Key: foo.f1 -> Append - -> Seq Scan on public.foo - Output: foo.ctid, foo.*, foo.tableoid, foo.f1 - -> Foreign Scan on public.foo2 - Output: foo2.ctid, foo2.*, foo2.tableoid, foo2.f1 + -> Seq Scan on public.foo foo_1 + Output: foo_1.ctid, foo_1.f1, foo_1.*, foo_1.tableoid + -> Foreign Scan on public.foo2 foo_2 + Output: foo_2.ctid, foo_2.f1, foo_2.*, foo_2.tableoid SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct1" -(38 rows) +(24 rows) --Testcase 452: update bar set f2 = f2 + 100 where f1 in (select f1 from foo); @@ -8109,53 +8643,38 @@ update bar set f2 = f2 + 100 from ( select f1 from foo union all select f1+3 from foo ) ss where bar.f1 = ss.f1; - QUERY PLAN ------------------------------------------------------------------------------ + QUERY PLAN +--------------------------------------------------------------------------------------------------------------- Update on public.bar - Update on public.bar - Foreign Update on public.bar2 - -> Hash Join - Output: bar.f1, (bar.f2 + 100), bar.ctid, (ROW(foo.f1)) - Hash Cond: (foo.f1 = bar.f1) - -> Append - -> Seq Scan on public.foo - Output: ROW(foo.f1), foo.f1 - -> Foreign Scan on public.foo2 - Output: ROW(foo2.f1), foo2.f1 - SQLite query: SELECT `f1` FROM main."loct1" - -> Seq Scan on public.foo foo_1 - Output: ROW((foo_1.f1 + 3)), (foo_1.f1 + 3) - -> Foreign Scan on public.foo2 foo2_1 - Output: ROW((foo2_1.f1 + 3)), (foo2_1.f1 + 3) - SQLite query: SELECT `f1` FROM main."loct1" - -> Hash - Output: bar.f1, bar.f2, bar.ctid - -> Seq Scan on public.bar - Output: bar.f1, bar.f2, bar.ctid + Update on public.bar bar_1 + Foreign Update on public.bar2 bar_2 -> Merge Join - Output: bar2.f1, (bar2.f2 + 100), bar2.f3, bar2.f3, (ROW(foo.f1)) - Merge Cond: (bar2.f1 = foo.f1) + Output: (bar.f2 + 100), (ROW(foo.f1)), bar.tableoid, bar.ctid, (NULL::integer), (NULL::record) + Merge Cond: (bar.f1 = foo.f1) -> Sort - Output: bar2.f1, bar2.f2, bar2.f3 - Sort Key: bar2.f1 - -> Foreign Scan on public.bar2 - Output: bar2.f1, bar2.f2, bar2.f3 - SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" + Output: bar.f2, bar.f1, bar.tableoid, bar.ctid, (NULL::integer), (NULL::record) + Sort Key: bar.f1 + -> Append + -> Seq Scan on public.bar bar_1 + Output: bar_1.f2, bar_1.f1, bar_1.tableoid, bar_1.ctid, NULL::integer, NULL::record + -> Foreign Scan on public.bar2 bar_2 + Output: bar_2.f2, bar_2.f1, bar_2.tableoid, NULL::tid, bar_2.f3, bar_2.* + SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" -> Sort Output: (ROW(foo.f1)), foo.f1 Sort Key: foo.f1 -> Append -> Seq Scan on public.foo Output: ROW(foo.f1), foo.f1 - -> Foreign Scan on public.foo2 - Output: ROW(foo2.f1), foo2.f1 + -> Foreign Scan on public.foo2 foo_1 + Output: ROW(foo_1.f1), foo_1.f1 SQLite query: SELECT `f1` FROM main."loct1" - -> Seq Scan on public.foo foo_1 - Output: ROW((foo_1.f1 + 3)), (foo_1.f1 + 3) - -> Foreign Scan on public.foo2 foo2_1 - Output: ROW((foo2_1.f1 + 3)), (foo2_1.f1 + 3) + -> Seq Scan on public.foo foo_2 + Output: ROW((foo_2.f1 + 3)), (foo_2.f1 + 3) + -> Foreign Scan on public.foo2 foo_3 + Output: ROW((foo_3.f1 + 3)), (foo_3.f1 + 3) SQLite query: SELECT `f1` FROM main."loct1" -(44 rows) +(29 rows) --Testcase 455: update bar set f2 = f2 + 100 @@ -8185,7 +8704,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); @@ -8211,10 +8732,10 @@ explain (verbose, costs off) Output: foo.f1, foo.f2 Sort Key: foo.f1 -> Append - -> Seq Scan on public.foo - Output: foo.f1, foo.f2 - -> Foreign Scan on public.foo2 foo2_1 - Output: foo2_1.f1, foo2_1.f2 + -> Seq Scan on public.foo foo_1 + Output: foo_1.f1, foo_1.f2 + -> Foreign Scan on public.foo2 foo_2 + Output: foo_2.f1, foo_2.f2 SQLite query: SELECT `f1`, `f2` FROM main."loct1" ORDER BY `f2` ASC NULLS LAST -> Sort Output: foo2.f1 @@ -8259,10 +8780,10 @@ explain (verbose, costs off) Output: foo.f1, foo.f2 Sort Key: foo.f1 -> Append - -> Seq Scan on public.foo - Output: foo.f1, foo.f2 - -> Foreign Scan on public.foo2 foo2_1 - Output: foo2_1.f1, foo2_1.f2 + -> Seq Scan on public.foo foo_1 + Output: foo_1.f1, foo_1.f2 + -> Foreign Scan on public.foo2 foo_2 + Output: foo_2.f1, foo_2.f2 SQLite query: SELECT `f1`, `f2` FROM main."loct1" ORDER BY `f2` ASC NULLS LAST -> Sort Output: foo2.f1 @@ -8288,7 +8809,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; @@ -8307,33 +8830,37 @@ rollback; --Testcase 459: explain (verbose, costs off) delete from foo where f1 < 5; - QUERY PLAN -------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------- Delete on public.foo - Delete on public.foo - Foreign Delete on public.foo2 - -> Index Scan using i_foo_f1 on public.foo - Output: foo.ctid - Index Cond: (foo.f1 < 5) - -> Foreign Delete on public.foo2 - SQLite query: DELETE FROM main."loct1" WHERE ((`f1` < 5)) -(8 rows) + Delete on public.foo foo_1 + Foreign Delete on public.foo2 foo_2 + -> Append + -> Index Scan using i_foo_f1 on public.foo foo_1 + Output: foo_1.tableoid, foo_1.ctid, NULL::integer + Index Cond: (foo_1.f1 < 5) + -> Foreign Delete on public.foo2 foo_2 + SQLite query: DELETE FROM main."loct1" WHERE ((`f1` < 5)) +(9 rows) --Testcase 460: delete from foo where f1 < 5; --Testcase 461: explain (verbose, costs off) update bar set f2 = f2 + 100; - QUERY PLAN -------------------------------------------------------------------- + QUERY PLAN +----------------------------------------------------------------------------------------------- Update on public.bar - Update on public.bar - Foreign Update on public.bar2 - -> Seq Scan on public.bar - Output: bar.f1, (bar.f2 + 100), bar.ctid - -> Foreign Update on public.bar2 - SQLite query: UPDATE main."loct2" SET `f2` = (`f2` + 100) -(7 rows) + Update on public.bar bar_1 + Foreign Update on public.bar2 bar_2 + -> Result + Output: (bar.f2 + 100), bar.tableoid, bar.ctid, (NULL::integer), (NULL::record) + -> Append + -> Seq Scan on public.bar bar_1 + Output: bar_1.f2, bar_1.tableoid, bar_1.ctid, NULL::integer, NULL::record + -> Foreign Update on public.bar2 bar_2 + SQLite query: UPDATE main."loct2" SET `f2` = (`f2` + 100) +(10 rows) --Testcase 462: update bar set f2 = f2 + 100; @@ -8361,17 +8888,20 @@ FOR EACH ROW EXECUTE PROCEDURE trigger_data(23,'skidoo'); --Testcase 464: explain (verbose, costs off) update bar set f2 = f2 + 100; - QUERY PLAN --------------------------------------------------------------------- + QUERY PLAN +----------------------------------------------------------------------------------------------- Update on public.bar - Update on public.bar - Foreign Update on public.bar2 - -> Seq Scan on public.bar - Output: bar.f1, (bar.f2 + 100), bar.ctid - -> Foreign Scan on public.bar2 - Output: bar2.f1, (bar2.f2 + 100), bar2.f3, bar2.f3, bar2.* - SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" -(8 rows) + Update on public.bar bar_1 + Foreign Update on public.bar2 bar_2 + -> Result + Output: (bar.f2 + 100), bar.tableoid, bar.ctid, (NULL::integer), (NULL::record) + -> Append + -> Seq Scan on public.bar bar_1 + Output: bar_1.f2, bar_1.tableoid, bar_1.ctid, NULL::integer, NULL::record + -> Foreign Scan on public.bar2 bar_2 + Output: bar_2.f2, bar_2.tableoid, NULL::tid, bar_2.f3, bar_2.* + SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" +(11 rows) --Testcase 465: update bar set f2 = f2 + 100; @@ -8390,18 +8920,19 @@ NOTICE: OLD: (7,277,77),NEW: (7,377,77) --Testcase 466: explain (verbose, costs off) delete from bar where f2 < 400; - QUERY PLAN --------------------------------------------------------------------------------------- + QUERY PLAN +-------------------------------------------------------------------------------------------- Delete on public.bar - Delete on public.bar - Foreign Delete on public.bar2 - -> Seq Scan on public.bar - Output: bar.ctid - Filter: (bar.f2 < 400) - -> Foreign Scan on public.bar2 - Output: bar2.f3, bar2.* - SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" WHERE ((`f2` < 400)) -(9 rows) + Delete on public.bar bar_1 + Foreign Delete on public.bar2 bar_2 + -> Append + -> Seq Scan on public.bar bar_1 + Output: bar_1.tableoid, bar_1.ctid, NULL::integer, NULL::record + Filter: (bar_1.f2 < 400) + -> Foreign Scan on public.bar2 bar_2 + Output: bar_2.tableoid, NULL::tid, bar_2.f3, bar_2.* + SQLite query: SELECT `f1`, `f2`, `f3` FROM main."loct2" WHERE ((`f2` < 400)) +(10 rows) --Testcase 467: delete from bar where f2 < 400; @@ -8425,6 +8956,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'); @@ -8437,33 +8969,26 @@ insert into remt2 values (2, 'bar'); --Testcase 472: explain (verbose, costs off) update parent set b = parent.b || remt2.b from remt2 where parent.a = remt2.a; - QUERY PLAN ------------------------------------------------------------------------ + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- Update on public.parent - Update on public.parent - Foreign Update on public.remt1 + Update on public.parent parent_1 + Foreign Update on public.remt1 parent_2 -> Hash Join - Output: parent.a, (parent.b || remt2.b), parent.ctid, remt2.* + Output: (parent.b || remt2.b), remt2.*, parent.tableoid, parent.ctid, (NULL::integer), (NULL::record) Hash Cond: (remt2.a = parent.a) -> Foreign Scan on public.remt2 Output: remt2.b, remt2.*, remt2.a SQLite query: SELECT `a`, `b` FROM main."loct4" -> Hash - Output: parent.a, parent.b, parent.ctid - -> Seq Scan on public.parent - Output: parent.a, parent.b, parent.ctid - -> Hash Join - Output: remt1.a, (remt1.b || remt2.b), remt1.a, remt2.* - Hash Cond: (remt1.a = remt2.a) - -> Foreign Scan on public.remt1 - Output: remt1.a, remt1.b - SQLite query: SELECT `a`, `b` FROM main."loct3" - -> Hash - Output: remt2.b, remt2.*, remt2.a - -> Foreign Scan on public.remt2 - Output: remt2.b, remt2.*, remt2.a - SQLite query: SELECT `a`, `b` FROM main."loct4" -(24 rows) + Output: parent.b, parent.a, parent.tableoid, parent.ctid, (NULL::integer), (NULL::record) + -> Append + -> Seq Scan on public.parent parent_1 + Output: parent_1.b, parent_1.a, parent_1.tableoid, parent_1.ctid, NULL::integer, NULL::record + -> Foreign Scan on public.remt1 parent_2 + Output: parent_2.b, parent_2.a, parent_2.tableoid, NULL::tid, parent_2.a, parent_2.* + SQLite query: SELECT `a`, `b` FROM main."loct3" +(17 rows) --Testcase 473: update parent set b = parent.b || remt2.b from remt2 where parent.a = remt2.a; @@ -8478,37 +9003,26 @@ select * from parent inner join remt2 on (parent.a = remt2.a); --Testcase 475: explain (verbose, costs off) delete from parent using remt2 where parent.a = remt2.a; - QUERY PLAN ---------------------------------------------------------------------- + QUERY PLAN +----------------------------------------------------------------------------------------- Delete on public.parent - Delete on public.parent - Foreign Delete on public.remt1 + Delete on public.parent parent_1 + Foreign Delete on public.remt1 parent_2 -> Hash Join - Output: parent.ctid, remt2.* - Hash Cond: (remt2.a = parent.a) - -> Foreign Scan on public.remt2 - Output: remt2.*, remt2.a - SQLite query: SELECT `a`, `b` FROM main."loct4" + Output: remt2.*, parent.tableoid, parent.ctid, (NULL::integer) + Hash Cond: (parent.a = remt2.a) + -> Append + -> Seq Scan on public.parent parent_1 + Output: parent_1.a, parent_1.tableoid, parent_1.ctid, NULL::integer + -> Foreign Scan on public.remt1 parent_2 + Output: parent_2.a, parent_2.tableoid, NULL::tid, parent_2.a + SQLite query: SELECT `a` FROM main."loct3" -> Hash - Output: parent.ctid, parent.a - -> Seq Scan on public.parent - Output: parent.ctid, parent.a - -> Merge Join - Output: remt1.a, remt2.* - Merge Cond: (remt2.a = remt1.a) - -> Sort Output: remt2.*, remt2.a - Sort Key: remt2.a -> Foreign Scan on public.remt2 Output: remt2.*, remt2.a SQLite query: SELECT `a`, `b` FROM main."loct4" - -> Sort - Output: remt1.a - Sort Key: remt1.a - -> Foreign Scan on public.remt1 - Output: remt1.a - SQLite query: SELECT `a` FROM main."loct3" -(28 rows) +(17 rows) --Testcase 476: delete from parent using remt2 where parent.a = remt2.a; @@ -8867,6 +9381,189 @@ drop foreign table rem3; 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 +-- FOR VALUES WITH (MODULUS 2, REMAINDER 0); +-- CREATE TABLE tru_rtable1 (id int primary key); +-- 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 +----- + 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 +------- + 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 +-- SELECT sum(id) FROM tru_ptable; -- 155 +-- TRUNCATE tru_ptable; +-- SELECT count(*) FROM tru_ptable; -- 0 +-- SELECT count(*) FROM tru_ptable__p0; -- 0 +-- 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 +----- + 55 +(1 row) + +-- 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 + count +------- + 0 +(1 row) + +--Testcase 870: +SELECT count(*) FROM "S 1".tru_fk_table; -- also truncated,0 + count +------- + 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 +------- + 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 +------- + 0 +(1 row) + +-- 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 + sum +----- + 126 +(1 row) + +TRUNCATE tru_ftable_parent; +--Testcase 878: +SELECT count(*) FROM tru_ftable_parent; -- 0 + count +------- + 0 +(1 row) + +-- -- in case when remote table has inherited children +-- CREATE TABLE tru_rtable0_child () INHERITS (tru_rtable0); +-- INSERT INTO tru_rtable0 (SELECT x FROM generate_series(5,9) x); +-- INSERT INTO "S 1".tru_rtable0_child (SELECT x FROM generate_series(10,14) x); +-- SELECT sum(id) FROM tru_ftable; -- 95 +-- -- Both parent and child tables in the foreign server are truncated +-- -- even though ONLY is specified because ONLY has no effect +-- -- when truncating a foreign table. +-- TRUNCATE ONLY tru_ftable; +-- SELECT count(*) FROM tru_ftable; -- 0 +-- INSERT INTO tru_rtable0 (SELECT x FROM generate_series(21,25) x); +-- INSERT INTO tru_rtable0_child (SELECT x FROM generate_series(26,30) x); +-- SELECT sum(id) FROM tru_ftable; -- 255 +-- 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; +-- =================================================================== -- test IMPORT FOREIGN SCHEMA -- =================================================================== --Testcase 728: @@ -9658,8 +10355,8 @@ INSERT INTO pagg_tab_p3 SELECT i % 30, i % 50, to_char(i/30, 'FM0000') FROM gene -- Create foreign partitions CREATE FOREIGN TABLE fpagg_tab_p1 PARTITION OF pagg_tab FOR VALUES FROM (0) TO (10) SERVER loopback OPTIONS (table_name 'pagg_tab_p1'); -CREATE FOREIGN TABLE fpagg_tab_p2 PARTITION OF pagg_tab FOR VALUES FROM (10) TO (20) SERVER loopback OPTIONS (table_name 'pagg_tab_p2');; -CREATE FOREIGN TABLE fpagg_tab_p3 PARTITION OF pagg_tab FOR VALUES FROM (20) TO (30) SERVER loopback OPTIONS (table_name 'pagg_tab_p3');; +CREATE FOREIGN TABLE fpagg_tab_p2 PARTITION OF pagg_tab FOR VALUES FROM (10) TO (20) SERVER loopback OPTIONS (table_name 'pagg_tab_p2'); +CREATE FOREIGN TABLE fpagg_tab_p3 PARTITION OF pagg_tab FOR VALUES FROM (20) TO (30) SERVER loopback OPTIONS (table_name 'pagg_tab_p3'); ANALYZE pagg_tab; ANALYZE fpagg_tab_p1; @@ -9729,7 +10426,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. @@ -9747,13 +10444,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; @@ -9763,7 +10460,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 @@ -9777,13 +10474,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; @@ -9808,6 +10505,882 @@ PREPARE TRANSACTION 'fdw_tpc'; ERROR: cannot prepare a transaction that modified remote tables ROLLBACK; WARNING: there is no transaction in progress +-- =================================================================== +-- reestablish new connection +-- =================================================================== +-- -- Test case relative with option application_name is not suitable for SQLite FDW. +-- -- Because this option is in libpq of postgres. +-- -- 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_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_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. +-- SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity +-- WHERE application_name = 'fdw_retry_check'; +-- -- This query should detect the broken connection when starting new remote +-- -- transaction, reestablish new connection, and then succeed. +-- BEGIN; +-- SELECT 1 FROM ft1 LIMIT 1; +-- -- If we detect the broken connection when starting a new remote +-- -- subtransaction, we should fail instead of establishing a new connection. +-- -- Terminate the remote connection and wait for the termination to complete. +-- SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity +-- WHERE application_name = 'fdw_retry_check'; +-- SAVEPOINT s; +-- -- The text of the error might vary across platforms, so only show SQLSTATE. +-- \set VERBOSITY sqlstate +-- SELECT 1 FROM ft1 LIMIT 1; -- should fail +-- \set VERBOSITY default +-- COMMIT; +-- 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? +---------- + 1 +(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 +------------- +(0 rows) + +-- 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? +---------- + 1 +(1 row) + +-- 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 +------------- + sqlite_svr + sqlite_svr3 +(2 rows) + +-- 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 +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 +-------------+------- + sqlite_svr | f + | f +(2 rows) + +-- 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 +------------- +(0 rows) + +-- ======================================================================= +-- test sqlite_fdw_disconnect and sqlite_fdw_disconnect_all functions +-- ======================================================================= +BEGIN; +-- Ensure to cache loopback connection. +--Testcase 890: +SELECT 1 FROM ft1 LIMIT 1; + ?column? +---------- + 1 +(1 row) + +-- Ensure to cache loopback2 connection. +--Testcase 891: +SELECT 1 FROM ft6 LIMIT 1; + ?column? +---------- + 1 +(1 row) + +-- 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 +------------- + sqlite_svr + sqlite_svr2 +(2 rows) + +-- 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 +----------------------- + f +(1 row) + +-- 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 +------------- + sqlite_svr + sqlite_svr2 +(2 rows) + +-- 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 +----------------------- + f +(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? +---------- + 1 +(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 +------------- +(0 rows) + +-- ============================================================================= +-- 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 +------------- + sqlite_svr +(1 row) + +COMMIT; +-- Let's ensure to close all the existing cached connections. +--Testcase 915: +SELECT 1 FROM sqlite_fdw_disconnect_all(); + ?column? +---------- + 1 +(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? +---------- + 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' +AND srvoptions @> array['batch_size=10']; + count +------- + 1 +(1 row) + +--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']; + count +------- + 0 +(1 row) + +--Testcase 929: +SELECT count(*) +FROM pg_foreign_server +WHERE srvname = 'batch10' +AND srvoptions @> array['batch_size=20']; + count +------- + 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 +AND ftoptions @> array['batch_size=30']; + count +------- + 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 +AND ftoptions @> array['batch_size=30']; + count +------- + 0 +(1 row) + +--Testcase 934: +SELECT COUNT(*) +FROM pg_foreign_table +WHERE ftrelid = 'table30'::regclass +AND ftoptions @> array['batch_size=40']; + count +------- + 1 +(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 +----------------------------------------------------- + Insert on public.ftable + Batch Size: 10 + -> Function Scan on pg_catalog.generate_series i + Output: i.i + 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 +------------------------------------ + Insert on public.ftable + Batch Size: 1 + -> Values Scan on "*VALUES*" + Output: "*VALUES*".column1 +(4 rows) + +--Testcase 951: +INSERT INTO ftable VALUES (1), (2); +--Testcase 952: +SELECT COUNT(*) FROM ftable; + count +------- + 2 +(1 row) + +-- Disable batch inserting into foreign tables with BEFORE ROW INSERT triggers +-- even if the batch_size option is enabled. +--Testcase 977: +ALTER FOREIGN TABLE ftable OPTIONS ( SET batch_size '10' ); +--Testcase 978: +CREATE TRIGGER trig_row_before BEFORE INSERT ON ftable +--Testcase 979: +FOR EACH ROW EXECUTE PROCEDURE trigger_data(23,'skidoo'); +--Testcase 980: +EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO ftable VALUES (3), (4); + QUERY PLAN +------------------------------------ + Insert on public.ftable + Batch Size: 1 + -> Values Scan on "*VALUES*" + Output: "*VALUES*".column1 +(4 rows) + +--Testcase 981: +INSERT INTO ftable VALUES (3), (4); +NOTICE: trig_row_before(23, skidoo) BEFORE ROW INSERT ON ftable +NOTICE: NEW: (3) +NOTICE: trig_row_before(23, skidoo) BEFORE ROW INSERT ON ftable +NOTICE: NEW: (4) +--Testcase 982: +SELECT COUNT(*) FROM ftable; + count +------- + 4 +(1 row) + +-- Clean up +--Testcase 983: +DROP TRIGGER trig_row_before ON ftable; +--Testcase 953: +DROP FOREIGN TABLE ftable; +-- DROP TABLE batch_table; +-- -- Use partitioning +-- CREATE TABLE batch_table ( x int ) PARTITION BY HASH (x); +-- CREATE TABLE batch_table_p0 (LIKE batch_table); +-- CREATE FOREIGN TABLE batch_table_p0f + -- PARTITION OF batch_table + -- FOR VALUES WITH (MODULUS 3, REMAINDER 0) + -- SERVER sqlite_svr + -- OPTIONS (table 'batch_table_p0', batch_size '10'); +-- CREATE TABLE batch_table_p1 (LIKE batch_table); +-- CREATE FOREIGN TABLE batch_table_p1f + -- PARTITION OF batch_table + -- FOR VALUES WITH (MODULUS 3, REMAINDER 1) +-- SERVER sqlite_svr +-- OPTIONS (table 'batch_table_p1', batch_size '1'); +-- CREATE TABLE batch_table_p2 +-- PARTITION OF batch_table +-- FOR VALUES WITH (MODULUS 3, REMAINDER 2); +-- INSERT INTO "S 1".batch_table SELECT * FROM generate_series(1, 66) i; +-- SELECT COUNT(*) FROM "S 1".batch_table; +-- -- Check that enabling batched inserts doesn't interfere with cross-partition +-- -- updates +-- CREATE TABLE batch_cp_upd_test (a int) PARTITION BY LIST (a); +-- CREATE TABLE batch_cp_upd_test1 (LIKE batch_cp_upd_test); +-- CREATE FOREIGN TABLE batch_cp_upd_test1_f +-- PARTITION OF batch_cp_upd_test +-- FOR VALUES IN (1) +-- SERVER sqlite_svr +-- OPTIONS (table_name 'batch_cp_upd_test1', batch_size '10'); +-- CREATE TABLE batch_cp_up_test1 PARTITION OF batch_cp_upd_test +-- FOR VALUES IN (2); +-- INSERT INTO batch_cp_upd_test VALUES (1), (2); +-- -- The following moves a row from the local partition to the foreign one +-- UPDATE batch_cp_upd_test t SET a = 1 FROM (VALUES (1), (2)) s(a) WHERE t.a = s.a; +-- SELECT tableoid::regclass, * FROM batch_cp_upd_test; +-- -- Clean up +-- DROP TABLE batch_table, batch_cp_upd_test, batch_table_p0, batch_table_p1 CASCADE; +-- -- Use partitioning +-- ALTER SERVER loopback OPTIONS (ADD batch_size '10'); +-- CREATE TABLE batch_table ( x int, field1 text, field2 text) PARTITION BY HASH (x); +-- CREATE TABLE batch_table_p0 (LIKE batch_table); +-- ALTER TABLE batch_table_p0 ADD CONSTRAINT p0_pkey PRIMARY KEY (x); +-- CREATE FOREIGN TABLE batch_table_p0f +-- PARTITION OF batch_table +-- FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- SERVER loopback +-- OPTIONS (table_name 'batch_table_p0'); +-- CREATE TABLE batch_table_p1 (LIKE batch_table); +-- ALTER TABLE batch_table_p1 ADD CONSTRAINT p1_pkey PRIMARY KEY (x); +-- CREATE FOREIGN TABLE batch_table_p1f +-- PARTITION OF batch_table +-- FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- SERVER loopback +-- OPTIONS (table_name 'batch_table_p1'); +-- INSERT INTO batch_table SELECT i, 'test'||i, 'test'|| i FROM generate_series(1, 50) i; +-- SELECT COUNT(*) FROM batch_table; +-- SELECT * FROM batch_table ORDER BY x; +-- ALTER SERVER loopback OPTIONS (DROP batch_size); +-- =================================================================== +-- test asynchronous execution +-- =================================================================== +-- ALTER SERVER loopback OPTIONS (DROP extensions); +-- ALTER SERVER loopback OPTIONS (ADD async_capable 'true'); +-- ALTER SERVER loopback2 OPTIONS (ADD async_capable 'true'); +-- CREATE TABLE async_pt (a int, b int, c text) PARTITION BY RANGE (a); +-- CREATE TABLE base_tbl1 (a int, b int, c text); +-- CREATE TABLE base_tbl2 (a int, b int, c text); +-- CREATE FOREIGN TABLE async_p1 PARTITION OF async_pt FOR VALUES FROM (1000) TO (2000) +-- SERVER loopback OPTIONS (table_name 'base_tbl1'); +-- CREATE FOREIGN TABLE async_p2 PARTITION OF async_pt FOR VALUES FROM (2000) TO (3000) +-- SERVER loopback2 OPTIONS (table_name 'base_tbl2'); +-- INSERT INTO async_p1 SELECT 1000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i; +-- INSERT INTO async_p2 SELECT 2000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i; +-- ANALYZE async_pt; +-- -- simple queries +-- CREATE TABLE result_tbl (a int, b int, c text); +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b % 100 = 0; +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b % 100 = 0; +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; +-- -- Check case where multiple partitions use the same connection +-- CREATE TABLE base_tbl3 (a int, b int, c text); +-- CREATE FOREIGN TABLE async_p3 PARTITION OF async_pt FOR VALUES FROM (3000) TO (4000) +-- SERVER loopback2 OPTIONS (table_name 'base_tbl3'); +-- INSERT INTO async_p3 SELECT 3000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i; +-- ANALYZE async_pt; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; +-- DROP FOREIGN TABLE async_p3; +-- DROP TABLE base_tbl3; +-- -- Check case where the partitioned table has local/remote partitions +-- CREATE TABLE async_p3 PARTITION OF async_pt FOR VALUES FROM (3000) TO (4000); +-- INSERT INTO async_p3 SELECT 3000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i; +-- ANALYZE async_pt; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; +-- -- partitionwise joins +-- SET enable_partitionwise_join TO true; +-- CREATE TABLE join_tbl (a1 int, b1 int, c1 text, a2 int, b2 int, c2 text); +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO join_tbl SELECT * FROM async_pt t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; +-- INSERT INTO join_tbl SELECT * FROM async_pt t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; +-- SELECT * FROM join_tbl ORDER BY a1; +-- DELETE FROM join_tbl; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO join_tbl SELECT t1.a, t1.b, 'AAA' || t1.c, t2.a, t2.b, 'AAA' || t2.c FROM async_pt t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; +-- INSERT INTO join_tbl SELECT t1.a, t1.b, 'AAA' || t1.c, t2.a, t2.b, 'AAA' || t2.c FROM async_pt t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; +-- SELECT * FROM join_tbl ORDER BY a1; +-- DELETE FROM join_tbl; +-- RESET enable_partitionwise_join; +-- -- Test rescan of an async Append node with do_exec_prune=false +-- SET enable_hashjoin TO false; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO join_tbl SELECT * FROM async_p1 t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; +-- INSERT INTO join_tbl SELECT * FROM async_p1 t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; +-- SELECT * FROM join_tbl ORDER BY a1; +-- DELETE FROM join_tbl; +-- RESET enable_hashjoin; +-- -- Test interaction of async execution with plan-time partition pruning +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM async_pt WHERE a < 3000; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM async_pt WHERE a < 2000; +-- -- Test interaction of async execution with run-time partition pruning +-- SET plan_cache_mode TO force_generic_plan; +-- PREPARE async_pt_query (int, int) AS +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE a < $1 AND b === $2; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- EXECUTE async_pt_query (3000, 505); +-- EXECUTE async_pt_query (3000, 505); +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- EXECUTE async_pt_query (2000, 505); +-- EXECUTE async_pt_query (2000, 505); +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; +-- RESET plan_cache_mode; +-- CREATE TABLE local_tbl(a int, b int, c text); +-- INSERT INTO local_tbl VALUES (1505, 505, 'foo'), (2505, 505, 'bar'); +-- ANALYZE local_tbl; +-- CREATE INDEX base_tbl1_idx ON base_tbl1 (a); +-- CREATE INDEX base_tbl2_idx ON base_tbl2 (a); +-- CREATE INDEX async_p3_idx ON async_p3 (a); +-- ANALYZE base_tbl1; +-- ANALYZE base_tbl2; +-- ANALYZE async_p3; +-- ALTER FOREIGN TABLE async_p1 OPTIONS (use_remote_estimate 'true'); +-- ALTER FOREIGN TABLE async_p2 OPTIONS (use_remote_estimate 'true'); +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM local_tbl, async_pt WHERE local_tbl.a = async_pt.a AND local_tbl.c = 'bar'; +-- EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +-- SELECT * FROM local_tbl, async_pt WHERE local_tbl.a = async_pt.a AND local_tbl.c = 'bar'; +-- SELECT * FROM local_tbl, async_pt WHERE local_tbl.a = async_pt.a AND local_tbl.c = 'bar'; +-- ALTER FOREIGN TABLE async_p1 OPTIONS (DROP use_remote_estimate); +-- ALTER FOREIGN TABLE async_p2 OPTIONS (DROP use_remote_estimate); +-- DROP TABLE local_tbl; +-- DROP INDEX base_tbl1_idx; +-- DROP INDEX base_tbl2_idx; +-- DROP INDEX async_p3_idx; +-- -- UNION queries +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl +-- (SELECT a, b, 'AAA' || c FROM async_p1 ORDER BY a LIMIT 10) +-- UNION +-- (SELECT a, b, 'AAA' || c FROM async_p2 WHERE b < 10); +-- INSERT INTO result_tbl +-- (SELECT a, b, 'AAA' || c FROM async_p1 ORDER BY a LIMIT 10) +-- UNION +-- (SELECT a, b, 'AAA' || c FROM async_p2 WHERE b < 10); +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl +-- (SELECT a, b, 'AAA' || c FROM async_p1 ORDER BY a LIMIT 10) +-- UNION ALL +-- (SELECT a, b, 'AAA' || c FROM async_p2 WHERE b < 10); +-- INSERT INTO result_tbl +-- (SELECT a, b, 'AAA' || c FROM async_p1 ORDER BY a LIMIT 10) +-- UNION ALL +-- (SELECT a, b, 'AAA' || c FROM async_p2 WHERE b < 10); +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; +-- -- Disable async execution if we use gating Result nodes for pseudoconstant +-- -- quals +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM async_pt WHERE CURRENT_USER = SESSION_USER; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- (SELECT * FROM async_p1 WHERE CURRENT_USER = SESSION_USER) +-- UNION ALL +-- (SELECT * FROM async_p2 WHERE CURRENT_USER = SESSION_USER); +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM ((SELECT * FROM async_p1 WHERE b < 10) UNION ALL (SELECT * FROM async_p2 WHERE b < 10)) s WHERE CURRENT_USER = SESSION_USER; +-- -- Test that pending requests are processed properly +-- SET enable_mergejoin TO false; +-- SET enable_hashjoin TO false; +-- 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 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'); +-- INSERT INTO remote_tbl VALUES (2505, 505, 'bar'); +-- CREATE TABLE base_tbl4 (a int, b int, c text); +-- CREATE FOREIGN TABLE insert_tbl (a int, b int, c text) +-- SERVER loopback OPTIONS (table_name 'base_tbl4'); +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO insert_tbl (SELECT * FROM local_tbl UNION ALL SELECT * FROM remote_tbl); +-- INSERT INTO insert_tbl (SELECT * FROM local_tbl UNION ALL SELECT * FROM remote_tbl); +-- SELECT * FROM insert_tbl ORDER BY a; +-- -- Check with direct modify +-- EXPLAIN (VERBOSE, COSTS OFF) +-- WITH t AS (UPDATE remote_tbl SET c = c || c RETURNING *) +-- INSERT INTO join_tbl SELECT * FROM async_pt LEFT JOIN t ON (async_pt.a = t.a AND async_pt.b = t.b) WHERE async_pt.b === 505; +-- WITH t AS (UPDATE remote_tbl SET c = c || c RETURNING *) +-- INSERT INTO join_tbl SELECT * FROM async_pt LEFT JOIN t ON (async_pt.a = t.a AND async_pt.b = t.b) WHERE async_pt.b === 505; +-- SELECT * FROM join_tbl ORDER BY a1; +-- DELETE FROM join_tbl; +-- DROP TABLE local_tbl; +-- DROP FOREIGN TABLE remote_tbl; +-- DROP FOREIGN TABLE insert_tbl; +-- DROP TABLE base_tbl3; +-- DROP TABLE base_tbl4; +-- RESET enable_mergejoin; +-- RESET enable_hashjoin; +-- -- Test that UPDATE/DELETE with inherited target works with async_capable enabled +-- EXPLAIN (VERBOSE, COSTS OFF) +-- UPDATE async_pt SET c = c || c WHERE b = 0 RETURNING *; +-- UPDATE async_pt SET c = c || c WHERE b = 0 RETURNING *; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- DELETE FROM async_pt WHERE b = 0 RETURNING *; +-- DELETE FROM async_pt WHERE b = 0 RETURNING *; +-- -- Check EXPLAIN ANALYZE for a query that scans empty partitions asynchronously +-- DELETE FROM async_p1; +-- DELETE FROM async_p2; +-- DELETE FROM async_p3; +-- EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +-- SELECT * FROM async_pt; +-- -- Clean up +-- DROP TABLE async_pt; +-- DROP TABLE base_tbl1; +-- DROP TABLE base_tbl2; +-- DROP TABLE result_tbl; +-- DROP TABLE join_tbl; +-- -- Test that an asynchronous fetch is processed before restarting the scan in +-- -- ReScanForeignScan +-- CREATE TABLE base_tbl (a int, b int); +-- INSERT INTO base_tbl VALUES (1, 11), (2, 22), (3, 33); +-- CREATE FOREIGN TABLE foreign_tbl (b int) +-- SERVER loopback OPTIONS (table_name 'base_tbl'); +-- CREATE FOREIGN TABLE foreign_tbl2 () INHERITS (foreign_tbl) +-- SERVER loopback OPTIONS (table_name 'base_tbl'); +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT a FROM base_tbl WHERE a IN (SELECT a FROM foreign_tbl); +-- SELECT a FROM base_tbl WHERE a IN (SELECT a FROM foreign_tbl); +-- -- Clean up +-- DROP FOREIGN TABLE foreign_tbl CASCADE; +-- DROP TABLE base_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$%$#$# +-- -- No option is allowed to be specified at foreign data wrapper level +-- ALTER FOREIGN DATA WRAPPER postgres_fdw OPTIONS (nonexistent 'fdw'); +-- -- =================================================================== +-- -- test postgres_fdw.application_name GUC +-- -- =================================================================== +-- --- Turn debug_discard_caches off for this test to make sure that +-- --- the remote connection is alive when checking its application_name. +-- SET debug_discard_caches = 0; +-- -- Specify escape sequences in application_name option of a server +-- -- object so as to test that they are replaced with status information +-- -- expectedly. +-- -- +-- -- Since pg_stat_activity.application_name may be truncated to less than +-- -- NAMEDATALEN characters, note that substring() needs to be used +-- -- at the condition of test query to make sure that the string consisting +-- -- of database name and process ID is also less than that. +-- ALTER SERVER loopback2 OPTIONS (application_name 'fdw_%d%p'); +-- SELECT 1 FROM ft6 LIMIT 1; +-- SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity +-- WHERE application_name = +-- substring('fdw_' || current_database() || pg_backend_pid() for +-- current_setting('max_identifier_length')::int); +-- -- postgres_fdw.application_name overrides application_name option +-- -- of a server object if both settings are present. +-- SET postgres_fdw.application_name TO 'fdw_%a%u%%'; +-- SELECT 1 FROM ft6 LIMIT 1; +-- SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity +-- WHERE application_name = +-- substring('fdw_' || current_setting('application_name') || +-- CURRENT_USER || '%' for current_setting('max_identifier_length')::int); +-- -- Test %c (session ID) and %C (cluster name) escape sequences. +-- SET postgres_fdw.application_name TO 'fdw_%C%c'; +-- SELECT 1 FROM ft6 LIMIT 1; +-- SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity +-- WHERE application_name = +-- substring('fdw_' || current_setting('cluster_name') || +-- to_hex(trunc(EXTRACT(EPOCH FROM (SELECT backend_start FROM +-- pg_stat_get_activity(pg_backend_pid()))))::integer) || '.' || +-- to_hex(pg_backend_pid()) +-- for current_setting('max_identifier_length')::int); +-- --Clean up +-- RESET postgres_fdw.application_name; +-- RESET debug_discard_caches; +-- -- =================================================================== +-- -- test parallel commit +-- -- =================================================================== +-- ALTER SERVER loopback OPTIONS (ADD parallel_commit 'true'); +-- ALTER SERVER loopback2 OPTIONS (ADD parallel_commit 'true'); +-- CREATE TABLE ploc1 (f1 int, f2 text); +-- CREATE FOREIGN TABLE prem1 (f1 int, f2 text) +-- SERVER loopback OPTIONS (table_name 'ploc1'); +-- CREATE TABLE ploc2 (f1 int, f2 text); +-- CREATE FOREIGN TABLE prem2 (f1 int, f2 text) +-- SERVER loopback2 OPTIONS (table_name 'ploc2'); +-- BEGIN; +-- INSERT INTO prem1 VALUES (101, 'foo'); +-- INSERT INTO prem2 VALUES (201, 'bar'); +-- COMMIT; +-- SELECT * FROM prem1; +-- SELECT * FROM prem2; +-- BEGIN; +-- SAVEPOINT s; +-- INSERT INTO prem1 VALUES (102, 'foofoo'); +-- INSERT INTO prem2 VALUES (202, 'barbar'); +-- RELEASE SAVEPOINT s; +-- COMMIT; +-- SELECT * FROM prem1; +-- SELECT * FROM prem2; +-- -- This tests executing DEALLOCATE ALL against foreign servers in parallel +-- -- during pre-commit +-- BEGIN; +-- SAVEPOINT s; +-- INSERT INTO prem1 VALUES (103, 'baz'); +-- INSERT INTO prem2 VALUES (203, 'qux'); +-- ROLLBACK TO SAVEPOINT s; +-- RELEASE SAVEPOINT s; +-- INSERT INTO prem1 VALUES (104, 'bazbaz'); +-- INSERT INTO prem2 VALUES (204, 'quxqux'); +-- COMMIT; +-- SELECT * FROM prem1; +-- SELECT * FROM prem2; +-- ALTER SERVER loopback OPTIONS (DROP parallel_commit); +-- ALTER SERVER loopback2 OPTIONS (DROP parallel_commit); -- Clean-up --Testcase 733: DROP USER MAPPING FOR CURRENT_USER SERVER sqlite_svr; @@ -9815,7 +11388,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 124 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" @@ -9849,10 +11422,12 @@ drop cascades to foreign table ft1_org drop cascades to foreign table ft2 drop cascades to foreign table ft4 drop cascades to foreign table ft5 +drop cascades to foreign table ft_empty drop cascades to foreign table ft3 drop cascades to foreign table ft1 drop cascades to foreign table loc1 drop cascades to foreign table rem1 +drop cascades to foreign table grem1 drop cascades to foreign table import_dest1."T 0" drop cascades to foreign table import_dest1."T 1" drop cascades to foreign table import_dest1."T 2" @@ -9914,9 +11489,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" -and 24 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/14.0/extra/timestamp.out b/expected/15beta2/extra/timestamp.out similarity index 100% rename from expected/14.0/extra/timestamp.out rename to expected/15beta2/extra/timestamp.out diff --git a/expected/13.4/extra/update.out b/expected/15beta2/extra/update.out similarity index 91% rename from expected/13.4/extra/update.out rename to expected/15beta2/extra/update.out index d5b713cd..69411f9e 100644 --- a/expected/13.4/extra/update.out +++ b/expected/15beta2/extra/update.out @@ -216,11 +216,11 @@ UPDATE update_test t ----------------------------------------------------------------------------------------- Update on public.update_test t -> Result - Output: t.i, $1, $2, t.c, (SubPlan 1 (returns $1,$2)), t.i + Output: $1, $2, (SubPlan 1 (returns $1,$2)), t.i, t.* One-Time Filter: (CURRENT_USER = SESSION_USER) -> Foreign Scan on public.update_test t - Output: t.i, t.a, t.b, t.c - SQLite query: SELECT `i`, `a`, `c` FROM main."update_test" + Output: t.a, t.i, t.* + SQLite query: SELECT `i`, `a`, `b`, `c` FROM main."update_test" SubPlan 1 (returns $1,$2) -> Foreign Scan on public.update_test s Output: s.b, s.a @@ -243,17 +243,17 @@ SELECT a, b, char_length(c) FROM update_test; /* Skip, sqlite fdw does not support ON CONFLICT DO UPDATE -- Test ON CONFLICT DO UPDATE -INSERT INTO upsert_test VALUES(1, 'Boo'); +INSERT INTO upsert_test VALUES(1, 'Boo'), (3, 'Zoo'); -- uncorrelated sub-select: WITH aaa AS (SELECT 1 AS a, 'Foo' AS b) INSERT INTO upsert_test VALUES (1, 'Bar') ON CONFLICT(a) DO UPDATE SET (b, a) = (SELECT b, a FROM aaa) RETURNING *; -- correlated sub-select: -INSERT INTO upsert_test VALUES (1, 'Baz') ON CONFLICT(a) +INSERT INTO upsert_test VALUES (1, 'Baz'), (3, 'Zaz') ON CONFLICT(a) DO UPDATE SET (b, a) = (SELECT b || ', Correlated', a from upsert_test i WHERE i.a = upsert_test.a) RETURNING *; -- correlated sub-select (EXCLUDED.* alias): -INSERT INTO upsert_test VALUES (1, 'Bat') ON CONFLICT(a) +INSERT INTO upsert_test VALUES (1, 'Bat'), (3, 'Zot') ON CONFLICT(a) DO UPDATE SET (b, a) = (SELECT b || ', Excluded', a from upsert_test i WHERE i.a = excluded.a) RETURNING *; @@ -274,6 +274,29 @@ DROP FOREIGN TABLE update_test; DROP FOREIGN TABLE upsert_test; */ /*Skip, sqlite fdw does not support create partition table +-- Test ON CONFLICT DO UPDATE with partitioned table and non-identical children + +CREATE TABLE upsert_test ( + a INT PRIMARY KEY, + b TEXT +) PARTITION BY LIST (a); + +CREATE TABLE upsert_test_1 PARTITION OF upsert_test FOR VALUES IN (1); +CREATE TABLE upsert_test_2 (b TEXT, a INT PRIMARY KEY); +ALTER TABLE upsert_test ATTACH PARTITION upsert_test_2 FOR VALUES IN (2); + +INSERT INTO upsert_test VALUES(1, 'Boo'), (2, 'Zoo'); +-- uncorrelated sub-select: +WITH aaa AS (SELECT 1 AS a, 'Foo' AS b) INSERT INTO upsert_test + VALUES (1, 'Bar') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b, a FROM aaa) RETURNING *; +-- correlated sub-select: +WITH aaa AS (SELECT 1 AS ctea, ' Foo' AS cteb) INSERT INTO upsert_test + VALUES (1, 'Bar'), (2, 'Baz') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT upsert_test.b||cteb, upsert_test.a FROM aaa) RETURNING *; + +DROP TABLE upsert_test; + --------------------------- -- UPDATE with row movement --------------------------- @@ -645,6 +668,37 @@ UPDATE list_default set a = 'x' WHERE a = 'd'; DROP TABLE list_parted; +-- Test retrieval of system columns with non-consistent partition row types. +-- This is only partially supported, as seen in the results. + +create table utrtest (a int, b text) partition by list (a); +create table utr1 (a int check (a in (1)), q text, b text); +create table utr2 (a int check (a in (2)), b text); +alter table utr1 drop column q; +alter table utrtest attach partition utr1 for values in (1); +alter table utrtest attach partition utr2 for values in (2); + +insert into utrtest values (1, 'foo') + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok; +insert into utrtest values (2, 'bar') + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok; -- fails +insert into utrtest values (2, 'bar') + returning *, tableoid::regclass; + +update utrtest set b = b || b from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok; + +update utrtest set a = 3 - a from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok; -- fails + +update utrtest set a = 3 - a from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass; + +delete from utrtest + returning *, tableoid::regclass, xmax = pg_current_xact_id()::xid as xmax_ok; + +drop table utrtest; + -------------- -- Some more update-partition-key test scenarios below. This time use list -- partitions. diff --git a/expected/15beta2/selectfunc.out b/expected/15beta2/selectfunc.out new file mode 100644 index 00000000..0ff93436 --- /dev/null +++ b/expected/15beta2/selectfunc.out @@ -0,0 +1,780 @@ +SET datestyle=ISO; +SET timezone='Japan'; +--Testcase 1: +CREATE EXTENSION sqlite_fdw; +--Testcase 2: +CREATE SERVER server1 FOREIGN DATA WRAPPER sqlite_fdw +OPTIONS (database '/tmp/sqlitefdw_test_selectfunc.db'); +--CREATE USER MAPPING FOR CURRENT_USER SERVER server1 OPTIONS(user 'user', password 'pass'); +--IMPORT FOREIGN SCHEMA public FROM SERVER server1 INTO public OPTIONS(import_time_text 'false'); +--Testcase 3: +CREATE FOREIGN TABLE s3(id text OPTIONS (key 'true'), time timestamp, tag1 text, value1 float, value2 int, value3 float, value4 int, str1 text, str2 text) SERVER server1; +-- s3 (value1 as float8, value2 as bigint) +--Testcase 4: +\d s3; + Foreign table "public.s3" + Column | Type | Collation | Nullable | Default | FDW options +--------+-----------------------------+-----------+----------+---------+-------------- + id | text | | | | (key 'true') + time | timestamp without time zone | | | | + tag1 | text | | | | + value1 | double precision | | | | + value2 | integer | | | | + value3 | double precision | | | | + value4 | integer | | | | + str1 | text | | | | + str2 | text | | | | +Server: server1 + +--Testcase 5: +SELECT * FROM s3; + id | time | tag1 | value1 | value2 | value3 | value4 | str1 | str2 +----+---------------------+------+--------+--------+--------+--------+-----------+----------- + 0 | 1970-01-01 00:00:00 | a | 0.1 | 100 | -0.1 | -100 | ---XYZ--- | XYZ + 1 | 1970-01-01 00:00:01 | a | 0.2 | 100 | -0.2 | -100 | ---XYZ--- | XYZ + 2 | 1970-01-01 00:00:02 | a | 0.3 | 100 | -0.3 | -100 | ---XYZ--- | XYZ + 3 | 1970-01-01 00:00:03 | b | 1.1 | 200 | -1.1 | -200 | ---XYZ--- | XYZ + 4 | 1970-01-01 00:00:04 | b | 2.2 | 200 | -2.2 | -200 | ---XYZ--- | XYZ + 5 | 1970-01-01 00:00:05 | b | 3.3 | 200 | -3.3 | -200 | ---XYZ--- | XYZ +(6 rows) + +-- select float8() (not pushdown, remove float8, explain) +-- EXPLAIN VERBOSE +-- SELECT float8(value1), float8(value2), float8(value3), float8(value4) FROM s3; +-- sqlite fdw does not support +-- select float8() (not pushdown, remove float8, result) +-- SELECT float8(value1), float8(value2), float8(value3), float8(value4) FROM s3; +-- sqlite fdw does not support +-- select sqrt (builtin function, explain) +-- EXPLAIN VERBOSE +-- SELECT sqrt(value1), sqrt(value2) FROM s3; +-- sqlite fdw does not have sqrt() +-- select sqrt (buitin function, result) +-- SELECT sqrt(value1), sqrt(value2) FROM s3; +-- sqlite fdw does not have sqrt() +-- select sqrt (builtin function,, not pushdown constraints, explain) +-- EXPLAIN VERBOSE +-- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE to_hex(value2) != '64'; +-- sqlite fdw does not have sqrt() +-- select sqrt (builtin function, not pushdown constraints, result) +-- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE to_hex(value2) != '64'; +-- sqlite fdw does not have sqrt() +-- select sqrt (builtin function, pushdown constraints, explain) +-- EXPLAIN VERBOSE +-- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE value2 != 200; +-- sqlite fdw does not have sqrt() +-- select sqrt (builtin function, pushdown constraints, result) +-- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE value2 != 200; +-- sqlite fdw does not have sqrt() +-- select abs (builtin function, explain) +--Testcase 6: +EXPLAIN VERBOSE +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3; + QUERY PLAN +------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..1723.06 rows=1706 width=24) + Output: abs(value1), abs(value2), abs(value3), abs(value4) + SQLite query: SELECT `value1`, `value2`, `value3`, `value4` FROM main."s3" +(3 rows) + +-- select abs (buitin function, result) +--Testcase 7: +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3; + abs | abs | abs | abs +-----+-----+-----+----- + 0.1 | 100 | 0.1 | 100 + 0.2 | 100 | 0.2 | 100 + 0.3 | 100 | 0.3 | 100 + 1.1 | 200 | 1.1 | 200 + 2.2 | 200 | 2.2 | 200 + 3.3 | 200 | 3.3 | 200 +(6 rows) + +-- select abs (builtin function, not pushdown constraints, explain) +--Testcase 8: +EXPLAIN VERBOSE +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE to_hex(value2) != '64'; + QUERY PLAN +------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..1713.97 rows=1697 width=24) + Output: abs(value1), abs(value2), abs(value3), abs(value4) + Filter: (to_hex(s3.value2) <> '64'::text) + SQLite query: SELECT `value1`, `value2`, `value3`, `value4` FROM main."s3" +(4 rows) + +-- select abs (builtin function, not pushdown constraints, result) +--Testcase 9: +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE to_hex(value2) != '64'; + abs | abs | abs | abs +-----+-----+-----+----- + 1.1 | 200 | 1.1 | 200 + 2.2 | 200 | 2.2 | 200 + 3.3 | 200 | 3.3 | 200 +(3 rows) + +-- select abs (builtin function, pushdown constraints, explain) +--Testcase 10: +EXPLAIN VERBOSE +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE value2 != 200; + QUERY PLAN +-------------------------------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..1713.97 rows=1697 width=24) + Output: abs(value1), abs(value2), abs(value3), abs(value4) + SQLite query: SELECT `value1`, `value2`, `value3`, `value4` FROM main."s3" WHERE ((`value2` <> 200)) +(3 rows) + +-- select abs (builtin function, pushdown constraints, result) +--Testcase 11: +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE value2 != 200; + abs | abs | abs | abs +-----+-----+-----+----- + 0.1 | 100 | 0.1 | 100 + 0.2 | 100 | 0.2 | 100 + 0.3 | 100 | 0.3 | 100 +(3 rows) + +-- select log (builtin function, need to swap arguments, numeric cast, explain) +-- log_(v) : postgresql (base, v), sqlite (v, base) +-- EXPLAIN VERBOSE +-- SELECT log(value1::numeric, value2::numeric) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() +-- select log (builtin function, need to swap arguments, numeric cast, result) +-- SELECT log(value1::numeric, value2::numeric) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() +-- select log (stub function, need to swap arguments, float8, explain) +-- EXPLAIN VERBOSE +-- SELECT log(value1, 0.1) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() +-- select log (stub function, need to swap arguments, float8, result) +-- SELECT log(value1, 0.1) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() +-- select log (stub function, need to swap arguments, bigint, explain) +-- EXPLAIN VERBOSE +-- SELECT log(value2, 3) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() +-- select log (stub function, need to swap arguments, bigint, result) +-- SELECT log(value2, 3) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() +-- select log (stub function, need to swap arguments, mix type, explain) +-- EXPLAIN VERBOSE +-- SELECT log(value1, value2) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() +-- select log (stub function, need to swap arguments, mix type, result) +-- SELECT log(value1, value2) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() +-- select log2 (stub function, explain) +-- EXPLAIN VERBOSE +-- SELECT log2(value1),log2(value2) FROM s3; +-- sqlite fdw does not have log2() +-- select log2 (stub function, result) +-- SELECT log2(value1),log2(value2) FROM s3; +-- sqlite fdw does not have log2() +-- select spread (stub agg function, explain) +-- EXPLAIN VERBOSE +-- SELECT spread(value1),spread(value2),spread(value3),spread(value4) FROM s3; +-- sqlite fdw does not have spread() +-- select spread (stub agg function, result) +-- SELECT spread(value1),spread(value2),spread(value3),spread(value4) FROM s3; +-- sqlite fdw does not have spread() +-- select spread (stub agg function, raise exception if not expected type) +-- SELECT spread(value1::numeric),spread(value2::numeric),spread(value3::numeric),spread(value4::numeric) FROM s3; +-- sqlite fdw does not have spread() +-- select abs as nest function with agg (pushdown, explain) +--Testcase 12: +EXPLAIN VERBOSE +SELECT sum(value3),abs(sum(value3)) FROM s3; + QUERY PLAN +------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=16) + Output: (sum(value3)), (abs(sum(value3))) + SQLite query: SELECT sum(`value3`), abs(sum(`value3`)) FROM main."s3" +(3 rows) + +-- select abs as nest function with agg (pushdown, result) +--Testcase 13: +SELECT sum(value3),abs(sum(value3)) FROM s3; + sum | abs +------+----- + -7.2 | 7.2 +(1 row) + +-- select abs as nest with log2 (pushdown, explain) +-- EXPLAIN VERBOSE +-- SELECT abs(log2(value1)),abs(log2(1/value1)) FROM s3; +-- sqlite fdw does not have log2() +-- select abs as nest with log2 (pushdown, result) +-- SELECT abs(log2(value1)),abs(log2(1/value1)) FROM s3; +-- sqlite fdw does not have log2() +-- select abs with non pushdown func and explicit constant (explain) +--Testcase 14: +EXPLAIN VERBOSE +SELECT abs(value3), pi(), 4.1 FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2566.40 rows=2560 width=48) + Output: abs(value3), '3.141592653589793'::double precision, 4.1 + SQLite query: SELECT `value3` FROM main."s3" +(3 rows) + +-- select abs with non pushdown func and explicit constant (result) +--Testcase 15: +SELECT abs(value3), pi(), 4.1 FROM s3; + abs | pi | ?column? +-----+-------------------+---------- + 0.1 | 3.141592653589793 | 4.1 + 0.2 | 3.141592653589793 | 4.1 + 0.3 | 3.141592653589793 | 4.1 + 1.1 | 3.141592653589793 | 4.1 + 2.2 | 3.141592653589793 | 4.1 + 3.3 | 3.141592653589793 | 4.1 +(6 rows) + +-- select sqrt as nest function with agg and explicit constant (pushdown, explain) +-- EXPLAIN VERBOSE +-- SELECT sqrt(count(value1)), pi(), 4.1 FROM s3; +-- sqlite fdw does not have sqrt() +-- select sqrt as nest function with agg and explicit constant (pushdown, result) +-- SELECT sqrt(count(value1)), pi(), 4.1 FROM s3; +-- sqlite fdw does not have sqrt() +-- select sqrt as nest function with agg and explicit constant and tag (error, explain) +-- EXPLAIN VERBOSE +-- SELECT sqrt(count(value1)), pi(), 4.1, tag1 FROM s3; +-- sqlite fdw does not have sqrt() +-- select spread (stub agg function and group by influx_time() and tag) (explain) +-- EXPLAIN VERBOSE +-- SELECT spread("value1"),influx_time(time, interval '1s'),tag1 FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY influx_time(time, interval '1s'), tag1; +-- sqlite fdw does not have spread() and influx_time() +-- select spread (stub agg function and group by influx_time() and tag) (result) +-- SELECT spread("value1"),influx_time(time, interval '1s'),tag1 FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY influx_time(time, interval '1s'), tag1; +-- sqlite fdw does not have spread() and influx_time() +-- select spread (stub agg function and group by tag only) (result) +-- SELECT tag1,spread("value1") FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY tag1; +-- sqlite fdw does not have spread() +-- select spread (stub agg function and other aggs) (result) +-- SELECT sum("value1"),spread("value1"),count("value1") FROM s3; +-- sqlite fdw does not have spread() +-- select abs with order by (explain) +--Testcase 16: +EXPLAIN VERBOSE +SELECT value1, abs(1-value1) FROM s3 order by abs(1-value1); + QUERY PLAN +-------------------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..10.05 rows=10 width=16) + Output: value1, abs(('1'::double precision - value1)) + SQLite query: SELECT `value1` FROM main."s3" ORDER BY abs((1 - `value1`)) ASC NULLS LAST +(3 rows) + +-- select abs with order by (result) +--Testcase 17: +SELECT value1, abs(1-value1) FROM s3 order by abs(1-value1); + value1 | abs +--------+--------------------- + 1.1 | 0.10000000000000009 + 0.3 | 0.7 + 0.2 | 0.8 + 0.1 | 0.9 + 2.2 | 1.2000000000000002 + 3.3 | 2.3 +(6 rows) + +-- select abs with order by index (result) +--Testcase 18: +SELECT value1, abs(1-value1) FROM s3 order by 2,1; + value1 | abs +--------+--------------------- + 1.1 | 0.10000000000000009 + 0.3 | 0.7 + 0.2 | 0.8 + 0.1 | 0.9 + 2.2 | 1.2000000000000002 + 3.3 | 2.3 +(6 rows) + +-- select abs with order by index (result) +--Testcase 19: +SELECT value1, abs(1-value1) FROM s3 order by 1,2; + value1 | abs +--------+--------------------- + 0.1 | 0.9 + 0.2 | 0.8 + 0.3 | 0.7 + 1.1 | 0.10000000000000009 + 2.2 | 1.2000000000000002 + 3.3 | 2.3 +(6 rows) + +-- select abs and as +--Testcase 20: +SELECT abs(value3) as abs1 FROM s3; + abs1 +------ + 0.1 + 0.2 + 0.3 + 1.1 + 2.2 + 3.3 +(6 rows) + +-- select spread over join query (explain) +-- EXPLAIN VERBOSE +-- SELECT spread(t1.value1), spread(t2.value1) FROM s3 t1 INNER JOIN s3 t2 ON (t1.value1 = t2.value1) where t1.value1 = 0.1; +-- sqlite fdw does not have spread() +-- select spread over join query (result, stub call error) +-- SELECT spread(t1.value1), spread(t2.value1) FROM s3 t1 INNER JOIN s3 t2 ON (t1.value1 = t2.value1) where t1.value1 = 0.1; +-- sqlite fdw does not have spread() +-- select spread with having (explain) +-- EXPLAIN VERBOSE +-- SELECT spread(value1) FROM s3 HAVING spread(value1) > 100; +-- sqlite fdw does not have spread() +-- select spread with having (explain, cannot pushdown, stub call error) +-- SELECT spread(value1) FROM s3 HAVING spread(value1) > 100; +-- sqlite fdw does not have spread() +-- select abs with arithmetic and tag in the middle (explain) +--Testcase 21: +EXPLAIN VERBOSE +SELECT abs(value1) + 1, value2, tag1, sqrt(value2) FROM s3; + QUERY PLAN +------------------------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..1216.04 rows=1204 width=52) + Output: (abs(value1) + '1'::double precision), value2, tag1, sqrt((value2)::double precision) + SQLite query: SELECT `tag1`, `value1`, `value2` FROM main."s3" +(3 rows) + +-- select abs with arithmetic and tag in the middle (result) +--Testcase 22: +SELECT abs(value1) + 1, value2, tag1, sqrt(value2) FROM s3; + ?column? | value2 | tag1 | sqrt +----------+--------+------+-------------------- + 1.1 | 100 | a | 10 + 1.2 | 100 | a | 10 + 1.3 | 100 | a | 10 + 2.1 | 200 | b | 14.142135623730951 + 3.2 | 200 | b | 14.142135623730951 + 4.3 | 200 | b | 14.142135623730951 +(6 rows) + +-- select with order by limit (explain) +--Testcase 23: +EXPLAIN VERBOSE +SELECT abs(value1), abs(value3), sqrt(value2) FROM s3 ORDER BY abs(value3) LIMIT 1; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=1.00..1.00 rows=1 width=24) + Output: abs(value1), abs(value3), sqrt((value2)::double precision) + SQLite query: SELECT `value1`, `value2`, `value3` FROM main."s3" ORDER BY abs(`value3`) ASC NULLS LAST LIMIT 1 +(3 rows) + +-- select with order by limit (explain) +--Testcase 24: +SELECT abs(value1), abs(value3), sqrt(value2) FROM s3 ORDER BY abs(value3) LIMIT 1; + abs | abs | sqrt +-----+-----+------ + 0.1 | 0.1 | 10 +(1 row) + +-- select mixing with non pushdown func (all not pushdown, explain) +--Testcase 25: +EXPLAIN VERBOSE +SELECT abs(value1), sqrt(value2), upper(tag1) FROM s3; + QUERY PLAN +---------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..1216.04 rows=1204 width=48) + Output: abs(value1), sqrt((value2)::double precision), upper(tag1) + SQLite query: SELECT `tag1`, `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mixing with non pushdown func (result) +--Testcase 26: +SELECT abs(value1), sqrt(value2), upper(tag1) FROM s3; + abs | sqrt | upper +-----+--------------------+------- + 0.1 | 10 | A + 0.2 | 10 | A + 0.3 | 10 | A + 1.1 | 14.142135623730951 | B + 2.2 | 14.142135623730951 | B + 3.3 | 14.142135623730951 | B +(6 rows) + +-- sqlite data prep +-- sqlite pushdown supported functions (explain) +--Testcase 27: +EXPLAIN VERBOSE +SELECT abs(value3), length(tag1), lower(str1), ltrim(str2), ltrim(str1, '-'), replace(str1, 'XYZ', 'ABC'), round(value3), rtrim(str1, '-'), rtrim(str2), substr(str1, 4), substr(str1, 4, 3) FROM s3; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..657.60 rows=640 width=276) + Output: abs(value3), length(tag1), lower(str1), ltrim(str2), ltrim(str1, '-'::text), replace(str1, 'XYZ'::text, 'ABC'::text), round(value3), rtrim(str1, '-'::text), rtrim(str2), substr(str1, 4), substr(str1, 4, 3) + SQLite query: SELECT `tag1`, `value3`, `str1`, `str2` FROM main."s3" +(3 rows) + +-- sqlite pushdown supported functions (result) +--Testcase 28: +SELECT abs(value3), length(tag1), lower(str1), ltrim(str2), ltrim(str1, '-'), replace(str1, 'XYZ', 'ABC'), round(value3), rtrim(str1, '-'), rtrim(str2), substr(str1, 4), substr(str1, 4, 3) FROM s3; + abs | length | lower | ltrim | ltrim | replace | round | rtrim | rtrim | substr | substr +-----+--------+-----------+--------+--------+-----------+-------+--------+--------+--------+-------- + 0.1 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -0 | ---XYZ | XYZ | XYZ--- | XYZ + 0.2 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -0 | ---XYZ | XYZ | XYZ--- | XYZ + 0.3 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -0 | ---XYZ | XYZ | XYZ--- | XYZ + 1.1 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -1 | ---XYZ | XYZ | XYZ--- | XYZ + 2.2 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -2 | ---XYZ | XYZ | XYZ--- | XYZ + 3.3 | 1 | ---xyz--- | XYZ | XYZ--- | ---ABC--- | -3 | ---XYZ | XYZ | XYZ--- | XYZ +(6 rows) + +-- sqlite pushdown nest functions (explain) +--Testcase 32: +EXPLAIN VERBOSE +SELECT round(abs(value2), 0) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2946.94 rows=2925 width=32) + Output: round((abs(value2))::numeric, 0) + SQLite query: SELECT `value2` FROM main."s3" +(3 rows) + +-- sqlite pushdown nest functions (result) +--Testcase 33: +SELECT round(abs(value2), 0) FROM s3; + round +------- + 100 + 100 + 100 + 200 + 200 + 200 +(6 rows) + +-- select mod (builtin function, explain) +--Testcase 34: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2058.24 rows=2048 width=20) + Output: value1, mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value1`, `value2`, `value4` FROM main."s3" +(3 rows) + +-- select mod (builtin function, result) +--Testcase 35: +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + value1 | mod | mod | mod +--------+-----+-----+----- + 0.1 | 0 | 0 | 1 + 0.2 | 0 | 0 | 1 + 0.3 | 0 | 0 | 1 + 1.1 | 0 | 0 | 1 + 2.2 | 0 | 0 | 1 + 3.3 | 0 | 0 | 1 +(6 rows) + +-- select mod (builtin function, not pushdown constraints, explain) +--Testcase 36: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + QUERY PLAN +----------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..13.06 rows=13 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + Filter: (to_hex(s3.value2) = '64'::text) + SQLite query: SELECT `value2`, `value4` FROM main."s3" +(4 rows) + +-- select mod (builtin function, not pushdown constraints, result) +--Testcase 37: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod (builtin function, pushdown constraints, explain) +--Testcase 38: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + QUERY PLAN +------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2559.74 rows=2547 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((`value2` <> 200)) +(3 rows) + +-- select mod (builtin function, pushdown constraints, result) +--Testcase 39: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 40: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + QUERY PLAN +------------------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2559.74 rows=2547 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((mod(`value2`, 2) <> 1)) +(3 rows) + +-- select mod (builtin function, mod in constraints, result) +--Testcase 41: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(6 rows) + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 42: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + QUERY PLAN +--------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..857.26 rows=853 width=12) + Output: mod(value2, 2), mod(value4, 2), 1 + SQLite query: SELECT `value2`, `value4` FROM main."s3" WHERE ((1 > `value1`)) +(3 rows) + +-- select mod (builtin function, mod in constraints, result) +--Testcase 43: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + mod | mod | mod +-----+-----+----- + 0 | 0 | 1 + 0 | 0 | 1 + 0 | 0 | 1 +(3 rows) + +-- select mod as nest function with agg (pushdown, explain) +--Testcase 44: +EXPLAIN VERBOSE +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + QUERY PLAN +---------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=16) + Output: (sum(value3)), (mod(sum(value2), '2'::bigint)) + SQLite query: SELECT sum(`value3`), mod(sum(`value2`), 2) FROM main."s3" +(3 rows) + +-- select mod as nest function with agg (pushdown, result) +--Testcase 45: +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + sum | mod +------+----- + -7.2 | 0 +(1 row) + +-- select mod as nest with abs (pushdown, explain) +--Testcase 46: +EXPLAIN VERBOSE +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + QUERY PLAN +--------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..2303.44 rows=2275 width=16) + Output: value1, mod(abs(value2), 2), mod(abs((1 / value2)), 2) + SQLite query: SELECT `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mod as nest with abs (pushdown, result) +--Testcase 47: +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + value1 | mod | mod +--------+-----+----- + 0.1 | 0 | 0 + 0.2 | 0 | 0 + 0.3 | 0 | 0 + 1.1 | 0 | 0 + 2.2 | 0 | 0 + 3.3 | 0 | 0 +(6 rows) + +-- select mod with non pushdown func and explicit constant (explain) +--Testcase 48: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + QUERY PLAN +------------------------------------------------------------------------------ + Foreign Scan on public.s3 (cost=10.00..2280.69 rows=2275 width=52) + Output: value1, mod(value2, 2), '3.141592653589793'::double precision, 4.1 + SQLite query: SELECT `value1`, `value2` FROM main."s3" +(3 rows) + +-- select mod with non pushdown func and explicit constant (result) +--Testcase 49: +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + value1 | mod | pi | ?column? +--------+-----+-------------------+---------- + 0.1 | 0 | 3.141592653589793 | 4.1 + 0.2 | 0 | 3.141592653589793 | 4.1 + 0.3 | 0 | 3.141592653589793 | 4.1 + 1.1 | 0 | 3.141592653589793 | 4.1 + 2.2 | 0 | 3.141592653589793 | 4.1 + 3.3 | 0 | 3.141592653589793 | 4.1 +(6 rows) + +-- select mod with order by (explain) +--Testcase 50: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + QUERY PLAN +--------------------------------------------------------------------------------------------------------- + Foreign Scan on public.s3 (cost=10.00..10.05 rows=10 width=12) + Output: value1, mod((1 - value2), 2) + SQLite query: SELECT `value1`, `value2` FROM main."s3" ORDER BY mod((1 - `value2`), 2) ASC NULLS LAST +(3 rows) + +-- select mod with order by (result) +--Testcase 51: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with order by index (result) +--Testcase 52: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 2,1; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with order by index (result) +--Testcase 53: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 1,2; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by (explain) +--Testcase 54: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + QUERY PLAN +-------------------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=12) + Output: value1, (mod((1 - value2), 2)) + SQLite query: SELECT `value1`, mod((1 - `value2`), 2) FROM main."s3" GROUP BY 1, 2 +(3 rows) + +-- select mod with group by (result) +--Testcase 55: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index (result) +--Testcase 56: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 2,1; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index (result) +--Testcase 57: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by having (explain) +--Testcase 58: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------- + Foreign Scan (cost=1.00..1.00 rows=1 width=12) + Output: value1, (mod((1 - value2), 2)) + SQLite query: SELECT `value1`, mod((1 - `value2`), 2) FROM main."s3" GROUP BY 1, 2 HAVING ((avg(`value1`) > 0)) +(3 rows) + +-- select mod with group by having (result) +--Testcase 59: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + value1 | mod +--------+----- + 0.1 | -1 + 0.2 | -1 + 0.3 | -1 + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(6 rows) + +-- select mod with group by index having (result) +--Testcase 60: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2 HAVING value1 > 1; + value1 | mod +--------+----- + 1.1 | -1 + 2.2 | -1 + 3.3 | -1 +(3 rows) + +-- select mod and as +--Testcase 61: +SELECT value1, mod(value2, 2) as mod1 FROM s3; + value1 | mod1 +--------+------ + 0.1 | 0 + 0.2 | 0 + 0.3 | 0 + 1.1 | 0 + 2.2 | 0 + 3.3 | 0 +(6 rows) + +--Testcase 29: +DROP FOREIGN TABLE s3; +--Testcase 30: +DROP SERVER server1; +--Testcase 31: +DROP EXTENSION sqlite_fdw; diff --git a/expected/15beta2/sqlite_fdw.out b/expected/15beta2/sqlite_fdw.out new file mode 100644 index 00000000..e4b46009 --- /dev/null +++ b/expected/15beta2/sqlite_fdw.out @@ -0,0 +1,1660 @@ +--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; + department_id | department_name +---------------+----------------- +(0 rows) + +--Testcase 2: +SELECT * FROM employee LIMIT 10; + emp_id | emp_name | emp_dept_id +--------+----------+------------- +(0 rows) + +--Testcase 3: +SELECT * FROM empdata LIMIT 10; + emp_id | emp_dat +--------+--------- +(0 rows) + +--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; + count +------- + 100 +(1 row) + +--Testcase 17: +SELECT count(*) FROM employee; + count +------- + 100 +(1 row) + +--Testcase 18: +SELECT count(*) FROM empdata; + count +------- + 1 +(1 row) + +--Testcase 19: +EXPLAIN (COSTS FALSE) SELECT * FROM department d, employee e WHERE d.department_id = e.emp_dept_id LIMIT 10; + QUERY PLAN +-------------- + Foreign Scan +(1 row) + +--Testcase 20: +EXPLAIN (COSTS FALSE) SELECT * FROM department d, employee e WHERE d.department_id IN (SELECT department_id FROM department) LIMIT 10; + QUERY PLAN +------------------------------------------------------------------------- + Limit + -> Nested Loop + -> Nested Loop Semi Join + Join Filter: (d.department_id = department.department_id) + -> Foreign Scan on department d + -> Materialize + -> Foreign Scan on department + -> Materialize + -> Foreign Scan on employee e +(9 rows) + +--Testcase 21: +SELECT * FROM department d, employee e WHERE d.department_id = e.emp_dept_id LIMIT 10; + department_id | department_name | emp_id | emp_name | emp_dept_id +---------------+-----------------+--------+----------+------------- + 1 | dept - 1 | 1 | emp - 1 | 1 + 2 | dept - 2 | 2 | emp - 2 | 2 + 3 | dept - 3 | 3 | emp - 3 | 3 + 4 | dept - 4 | 4 | emp - 4 | 4 + 5 | dept - 5 | 5 | emp - 5 | 5 + 6 | dept - 6 | 6 | emp - 6 | 6 + 7 | dept - 7 | 7 | emp - 7 | 7 + 8 | dept - 8 | 8 | emp - 8 | 8 + 9 | dept - 9 | 9 | emp - 9 | 9 + 10 | dept - 10 | 10 | emp - 10 | 10 +(10 rows) + +--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; + department_id | department_name | emp_id | emp_name | emp_dept_id +---------------+-----------------+--------+----------+------------- + 1 | dept - 1 | 1 | emp - 1 | 1 + 1 | dept - 1 | 2 | emp - 2 | 2 + 1 | dept - 1 | 3 | emp - 3 | 3 + 1 | dept - 1 | 4 | emp - 4 | 4 + 1 | dept - 1 | 5 | emp - 5 | 5 + 1 | dept - 1 | 6 | emp - 6 | 6 + 1 | dept - 1 | 7 | emp - 7 | 7 + 1 | dept - 1 | 8 | emp - 8 | 8 + 1 | dept - 1 | 9 | emp - 9 | 9 + 1 | dept - 1 | 10 | emp - 10 | 10 +(10 rows) + +--Testcase 23: +SELECT * FROM empdata; + emp_id | emp_dat +--------+------------ + 1 | \x01234567 +(1 row) + +--Testcase 24: +DELETE FROM employee WHERE emp_id = 10; +--Testcase 25: +SELECT COUNT(*) FROM department LIMIT 10; + count +------- + 100 +(1 row) + +--Testcase 26: +SELECT COUNT(*) FROM employee WHERE emp_id = 10; + count +------- + 0 +(1 row) + +--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'; + emp_id | emp_name +--------+------------- + 20 | UPDATEd emp +(1 row) + +--Testcase 29: +UPDATE empdata SET emp_dat = decode ('0123', 'hex'); +--Testcase 30: +SELECT * FROM empdata; + emp_id | emp_dat +--------+--------- + 1 | \x0123 +(1 row) + +--Testcase 31: +SELECT * FROM employee LIMIT 10; + emp_id | emp_name | emp_dept_id +--------+----------+------------- + 1 | emp - 1 | 1 + 2 | emp - 2 | 2 + 3 | emp - 3 | 3 + 4 | emp - 4 | 4 + 5 | emp - 5 | 5 + 6 | emp - 6 | 6 + 7 | emp - 7 | 7 + 8 | emp - 8 | 8 + 9 | emp - 9 | 9 + 11 | emp - 11 | 11 +(10 rows) + +--Testcase 32: +SELECT * FROM employee WHERE emp_id IN (1); + emp_id | emp_name | emp_dept_id +--------+----------+------------- + 1 | emp - 1 | 1 +(1 row) + +--Testcase 33: +SELECT * FROM employee WHERE emp_id IN (1,3,4,5); + emp_id | emp_name | emp_dept_id +--------+----------+------------- + 1 | emp - 1 | 1 + 3 | emp - 3 | 3 + 4 | emp - 4 | 4 + 5 | emp - 5 | 5 +(4 rows) + +--Testcase 34: +SELECT * FROM employee WHERE emp_id IN (10000,1000); + emp_id | emp_name | emp_dept_id +--------+----------+------------- +(0 rows) + +--Testcase 35: +SELECT * FROM employee WHERE emp_id NOT IN (1) LIMIT 5; + emp_id | emp_name | emp_dept_id +--------+----------+------------- + 2 | emp - 2 | 2 + 3 | emp - 3 | 3 + 4 | emp - 4 | 4 + 5 | emp - 5 | 5 + 6 | emp - 6 | 6 +(5 rows) + +--Testcase 36: +SELECT * FROM employee WHERE emp_id NOT IN (1,3,4,5) LIMIT 5; + emp_id | emp_name | emp_dept_id +--------+----------+------------- + 2 | emp - 2 | 2 + 6 | emp - 6 | 6 + 7 | emp - 7 | 7 + 8 | emp - 8 | 8 + 9 | emp - 9 | 9 +(5 rows) + +--Testcase 37: +SELECT * FROM employee WHERE emp_id NOT IN (10000,1000) LIMIT 5; + emp_id | emp_name | emp_dept_id +--------+----------+------------- + 1 | emp - 1 | 1 + 2 | emp - 2 | 2 + 3 | emp - 3 | 3 + 4 | emp - 4 | 4 + 5 | emp - 5 | 5 +(5 rows) + +--Testcase 38: +SELECT * FROM employee WHERE emp_id NOT IN (SELECT emp_id FROM employee WHERE emp_id IN (1,10)); + emp_id | emp_name | emp_dept_id +--------+-------------+------------- + 2 | emp - 2 | 2 + 3 | emp - 3 | 3 + 4 | emp - 4 | 4 + 5 | emp - 5 | 5 + 6 | emp - 6 | 6 + 7 | emp - 7 | 7 + 8 | emp - 8 | 8 + 9 | emp - 9 | 9 + 11 | emp - 11 | 11 + 12 | emp - 12 | 12 + 13 | emp - 13 | 13 + 14 | emp - 14 | 14 + 15 | emp - 15 | 15 + 16 | emp - 16 | 16 + 17 | emp - 17 | 17 + 18 | emp - 18 | 18 + 19 | emp - 19 | 19 + 20 | UPDATEd emp | 20 + 21 | emp - 21 | 21 + 22 | emp - 22 | 22 + 23 | emp - 23 | 23 + 24 | emp - 24 | 24 + 25 | emp - 25 | 25 + 26 | emp - 26 | 26 + 27 | emp - 27 | 27 + 28 | emp - 28 | 28 + 29 | emp - 29 | 29 + 30 | emp - 30 | 30 + 31 | emp - 31 | 31 + 32 | emp - 32 | 32 + 33 | emp - 33 | 33 + 34 | emp - 34 | 34 + 35 | emp - 35 | 35 + 36 | emp - 36 | 36 + 37 | emp - 37 | 37 + 38 | emp - 38 | 38 + 39 | emp - 39 | 39 + 40 | emp - 40 | 40 + 41 | emp - 41 | 41 + 42 | emp - 42 | 42 + 43 | emp - 43 | 43 + 44 | emp - 44 | 44 + 45 | emp - 45 | 45 + 46 | emp - 46 | 46 + 47 | emp - 47 | 47 + 48 | emp - 48 | 48 + 49 | emp - 49 | 49 + 50 | emp - 50 | 50 + 51 | emp - 51 | 51 + 52 | emp - 52 | 52 + 53 | emp - 53 | 53 + 54 | emp - 54 | 54 + 55 | emp - 55 | 55 + 56 | emp - 56 | 56 + 57 | emp - 57 | 57 + 58 | emp - 58 | 58 + 59 | emp - 59 | 59 + 60 | emp - 60 | 60 + 61 | emp - 61 | 61 + 62 | emp - 62 | 62 + 63 | emp - 63 | 63 + 64 | emp - 64 | 64 + 65 | emp - 65 | 65 + 66 | emp - 66 | 66 + 67 | emp - 67 | 67 + 68 | emp - 68 | 68 + 69 | emp - 69 | 69 + 70 | emp - 70 | 70 + 71 | emp - 71 | 71 + 72 | emp - 72 | 72 + 73 | emp - 73 | 73 + 74 | emp - 74 | 74 + 75 | emp - 75 | 75 + 76 | emp - 76 | 76 + 77 | emp - 77 | 77 + 78 | emp - 78 | 78 + 79 | emp - 79 | 79 + 80 | emp - 80 | 80 + 81 | emp - 81 | 81 + 82 | emp - 82 | 82 + 83 | emp - 83 | 83 + 84 | emp - 84 | 84 + 85 | emp - 85 | 85 + 86 | emp - 86 | 86 + 87 | emp - 87 | 87 + 88 | emp - 88 | 88 + 89 | emp - 89 | 89 + 90 | emp - 90 | 90 + 91 | emp - 91 | 91 + 92 | emp - 92 | 92 + 93 | emp - 93 | 93 + 94 | emp - 94 | 94 + 95 | emp - 95 | 95 + 96 | emp - 96 | 96 + 97 | emp - 97 | 97 + 98 | emp - 98 | 98 + 99 | emp - 99 | 99 + 100 | emp - 100 | 100 +(98 rows) + +--Testcase 39: +SELECT * FROM employee WHERE emp_name NOT IN ('emp - 1', 'emp - 2') LIMIT 5; + emp_id | emp_name | emp_dept_id +--------+----------+------------- + 3 | emp - 3 | 3 + 4 | emp - 4 | 4 + 5 | emp - 5 | 5 + 6 | emp - 6 | 6 + 7 | emp - 7 | 7 +(5 rows) + +--Testcase 40: +SELECT * FROM employee WHERE emp_name NOT IN ('emp - 10') LIMIT 5; + emp_id | emp_name | emp_dept_id +--------+----------+------------- + 1 | emp - 1 | 1 + 2 | emp - 2 | 2 + 3 | emp - 3 | 3 + 4 | emp - 4 | 4 + 5 | emp - 5 | 5 +(5 rows) + +--Testcase 41: +SELECT * FROM numbers WHERE (CASE WHEN a % 2 = 0 THEN 1 WHEN a % 5 = 0 THEN 1 ELSE 0 END) = 1; + a | b +---+------- + 2 | Two + 4 | Four + 5 | Five + 6 | Six + 8 | Eight +(5 rows) + +--Testcase 42: +SELECT * FROM numbers WHERE (CASE b WHEN 'Two' THEN 1 WHEN 'Six' THEN 1 ELSE 0 END) = 1; + a | b +---+----- + 2 | Two + 6 | Six +(2 rows) + +--Testcase 152: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE (round(abs(a)) = 1); + QUERY PLAN +----------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..1.00 rows=1 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((round(abs(`a`)) = 1)) +(3 rows) + +--Testcase 153: +SELECT * FROM numbers WHERE (round(abs(a)) = 1); + a | b +---+----- + 1 | One +(1 row) + +--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(); +NOTICE: Found number One +NOTICE: Found number Two +NOTICE: Found number Three +NOTICE: Found number Four +NOTICE: Found number Five +NOTICE: Found number Six +NOTICE: Found number Seven +NOTICE: Found number Eight +NOTICE: Found number Nine + test_param_where +------------------ + +(1 row) + +--Testcase 44: +SELECT b from numbers WHERE a=1; + b +----- + One +(1 row) + +--Testcase 45: +EXPLAIN(COSTS OFF) SELECT b from numbers WHERE a=1; + QUERY PLAN +------------------------- + Foreign Scan on numbers +(1 row) + +--Testcase 46: +SELECT a FROM numbers WHERE b = (SELECT NULL::text); + a +--- +(0 rows) + +--Testcase 47: +PREPARE stmt1 (int, int) AS + SELECT * FROM numbers WHERE a=$1 or a=$2; +--Testcase 48: +EXECUTE stmt1(1,2); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 49: +EXECUTE stmt1(2,2); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 50: +EXECUTE stmt1(3,2); + a | b +---+------- + 2 | Two + 3 | Three +(2 rows) + +--Testcase 51: +EXECUTE stmt1(4,2); + a | b +---+------ + 2 | Two + 4 | Four +(2 rows) + +-- generic plan +--Testcase 52: +EXECUTE stmt1(5,2); + a | b +---+------ + 2 | Two + 5 | Five +(2 rows) + +--Testcase 53: +EXECUTE stmt1(6,2); + a | b +---+----- + 2 | Two + 6 | Six +(2 rows) + +--Testcase 54: +EXECUTE stmt1(7,2); + a | b +---+------- + 2 | Two + 7 | Seven +(2 rows) + +--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; + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +BEGIN; +--Testcase 62: +INSERT INTO numbers VALUES(3, 'Three'); +ROLLBACK; +--Testcase 63: +SELECT * from numbers; + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +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; + a | b +---+------ + 1 | One + 2 | Two + 4 | Four + 6 | Six +(4 rows) + +-- duplicate key +--Testcase 68: +INSERT INTO numbers VALUES(1, 'One'); +ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b + sql=INSERT INTO main."numbers"(`a`, `b`) VALUES (?, ?) +--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; +ERROR: failed to execute remote SQL: rc=19 UNIQUE constraint failed: numbers.b + sql=UPDATE main."numbers" SET `b` = 'Two' WHERE ((`a` = 1)) +--Testcase 73: +SELECT * from numbers; + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +-- push down +--Testcase 74: +explain (verbose, costs off) SELECT * from numbers WHERE a = any(ARRAY[2,3,4,5]::int[]); + QUERY PLAN +--------------------------------------------------------------------------------- + Foreign Scan on public.numbers + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (2, 3, 4, 5)) +(3 rows) + +-- (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); + QUERY PLAN +------------------------------------------------------------------------------ + Foreign Scan on public.numbers + Output: a, b + Filter: (ROW(1, 2) < ROW(numbers.a, 5)) + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (1, 2, 3)) +(4 rows) + +--Testcase 76: +explain (verbose, costs off) SELECT * from numbers WHERE a in (a+2*a,5); + QUERY PLAN +------------------------------------------------------------------------------------------------------ + Foreign Scan on public.numbers + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (((`a` = (`a` + (2 * `a`))) OR (`a` = 5))) +(3 rows) + +--Testcase 77: +explain (verbose, costs off) SELECT * from numbers WHERE a = any(ARRAY[1,2,a]::int[]); + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public.numbers + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (1, 2, `a`)) +(3 rows) + +--Testcase 78: +SELECT * from numbers WHERE a = any(ARRAY[2,3,4,5]::int[]); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 79: +SELECT * from numbers WHERE a = any(ARRAY[1,2,a]::int[]); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +-- ANY with ARRAY expression +--Testcase 154: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY(ARRAY[1, a + 1]); + QUERY PLAN +----------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..2.00 rows=2 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (1, (`a` + 1))) +(3 rows) + +--Testcase 155: +SELECT * FROM numbers WHERE a = ANY(ARRAY[1, a + 1]); + a | b +---+----- + 1 | One +(1 row) + +--Testcase 156: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, a + 1]); + QUERY PLAN +---------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..150.00 rows=150 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` <> 1) OR (`a` <> (`a` + 1))) +(3 rows) + +--Testcase 157: +SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, a + 1]); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 158: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, a + 1]); + QUERY PLAN +---------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` >= 1) OR (`a` >= (`a` + 1))) +(3 rows) + +--Testcase 159: +SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, a + 1]); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 160: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, a + 1]); + QUERY PLAN +---------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` <= 1) OR (`a` <= (`a` + 1))) +(3 rows) + +--Testcase 161: +SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, a + 1]); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 162: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ANY(ARRAY[1, a + 1]); + QUERY PLAN +-------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` > 1) OR (`a` > (`a` + 1))) +(3 rows) + +--Testcase 163: +SELECT * FROM numbers WHERE a > ANY(ARRAY[1, a + 1]); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 164: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ANY(ARRAY[1, a + 1]); + QUERY PLAN +-------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` < 1) OR (`a` < (`a` + 1))) +(3 rows) + +--Testcase 165: +SELECT * FROM numbers WHERE a < ANY(ARRAY[1, a + 1]); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +-- ANY with ARRAY const +--Testcase 166: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY(ARRAY[1, 2]); + QUERY PLAN +--------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..2.00 rows=2 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (1, 2)) +(3 rows) + +--Testcase 167: +SELECT * FROM numbers WHERE a = ANY(ARRAY[1, 2]); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 168: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, 2]); + QUERY PLAN +---------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..150.00 rows=150 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` <> 1 OR `a` <> 2) +(3 rows) + +--Testcase 169: +SELECT * FROM numbers WHERE a <> ANY(ARRAY[1, 2]); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 170: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, 2]); + QUERY PLAN +---------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` >= 1 OR `a` >= 2) +(3 rows) + +--Testcase 171: +SELECT * FROM numbers WHERE a >= ANY(ARRAY[1, 2]); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 172: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, 2]); + QUERY PLAN +---------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` <= 1 OR `a` <= 2) +(3 rows) + +--Testcase 173: +SELECT * FROM numbers WHERE a <= ANY(ARRAY[1, 2]); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 174: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ANY(ARRAY[1, 2]); + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` > 1 OR `a` > 2) +(3 rows) + +--Testcase 175: +SELECT * FROM numbers WHERE a > ANY(ARRAY[1, 2]); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 176: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ANY(ARRAY[1, 2]); + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` < 1 OR `a` < 2) +(3 rows) + +--Testcase 177: +SELECT * FROM numbers WHERE a < ANY(ARRAY[1, 2]); + a | b +---+----- + 1 | One +(1 row) + +--Testcase 210: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ANY('{1, 2, 3}'); + QUERY PLAN +------------------------------------------------------------------------------ + Foreign Scan on public.numbers (cost=10.00..3.00 rows=3 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` IN (1, 2, 3)) +(3 rows) + +--Testcase 211: +SELECT * FROM numbers WHERE a = ANY('{1, 2, 3}'); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 212: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ANY('{1, 2, 3}'); + QUERY PLAN +---------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..150.00 rows=150 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` <> 1 OR `a` <> 2 OR `a` <> 3) +(3 rows) + +--Testcase 213: +SELECT * FROM numbers WHERE a <> ANY('{1, 2, 3}'); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +-- ALL with ARRAY expression +--Testcase 178: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ALL(ARRAY[1, a * 1]); + QUERY PLAN +--------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..1.00 rows=1 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` = 1) AND (`a` = (`a` * 1))) +(3 rows) + +--Testcase 179: +SELECT * FROM numbers WHERE a = ALL(ARRAY[1, a * 1]); + a | b +---+----- + 1 | One +(1 row) + +--Testcase 180: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, a + 1]); + QUERY PLAN +--------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..148.00 rows=148 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` NOT IN (1, (`a` + 1))) +(3 rows) + +--Testcase 181: +SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, a + 1]); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 182: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, a / 1]); + QUERY PLAN +----------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` >= 1) AND (`a` >= (`a` / 1))) +(3 rows) + +--Testcase 183: +SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, a / 1]); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 184: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, a + 1]); + QUERY PLAN +----------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` <= 1) AND (`a` <= (`a` + 1))) +(3 rows) + +--Testcase 185: +SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, a + 1]); + a | b +---+----- + 1 | One +(1 row) + +--Testcase 186: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ALL(ARRAY[1, a - 1]); + QUERY PLAN +--------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` > 1) AND (`a` > (`a` - 1))) +(3 rows) + +--Testcase 187: +SELECT * FROM numbers WHERE a > ALL(ARRAY[1, a - 1]); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 188: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ALL(ARRAY[2, a + 1]); + QUERY PLAN +--------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((`a` < 2) AND (`a` < (`a` + 1))) +(3 rows) + +--Testcase 189: +SELECT * FROM numbers WHERE a < ALL(ARRAY[2, a + 1]); + a | b +---+----- + 1 | One +(1 row) + +-- ALL with ARRAY const +--Testcase 190: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a = ALL(ARRAY[1, 1]); + QUERY PLAN +--------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..1.00 rows=1 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` = 1 AND `a` = 1) +(3 rows) + +--Testcase 191: +SELECT * FROM numbers WHERE a = ALL(ARRAY[1, 1]); + a | b +---+----- + 1 | One +(1 row) + +--Testcase 192: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, 3]); + QUERY PLAN +------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..148.00 rows=148 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` NOT IN (1, 3)) +(3 rows) + +--Testcase 193: +SELECT * FROM numbers WHERE a <> ALL(ARRAY[1, 3]); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 194: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, 2]); + QUERY PLAN +----------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` >= 1 AND `a` >= 2) +(3 rows) + +--Testcase 195: +SELECT * FROM numbers WHERE a >= ALL(ARRAY[1, 2]); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 196: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, 2]); + QUERY PLAN +----------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` <= 1 AND `a` <= 2) +(3 rows) + +--Testcase 197: +SELECT * FROM numbers WHERE a <= ALL(ARRAY[1, 2]); + a | b +---+----- + 1 | One +(1 row) + +--Testcase 198: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a > ALL(ARRAY[0, 1]); + QUERY PLAN +--------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` > 0 AND `a` > 1) +(3 rows) + +--Testcase 199: +SELECT * FROM numbers WHERE a > ALL(ARRAY[0, 1]); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 200: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE a < ALL(ARRAY[2, 3]); + QUERY PLAN +--------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`a` < 2 AND `a` < 3) +(3 rows) + +--Testcase 201: +SELECT * FROM numbers WHERE a < ALL(ARRAY[2, 3]); + a | b +---+----- + 1 | One +(1 row) + +-- ANY/ALL with TEXT ARRAY const +--Testcase 202: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE b = ANY(ARRAY['One', 'Two']); + QUERY PLAN +----------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..2.00 rows=2 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`b` IN ('One', 'Two')) +(3 rows) + +--Testcase 203: +SELECT * FROM numbers WHERE b = ANY(ARRAY['One', 'Two']); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--Testcase 204: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE b <> ALL(ARRAY['One', 'Four']); + QUERY PLAN +---------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..148.00 rows=148 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`b` NOT IN ('One', 'Four')) +(3 rows) + +--Testcase 205: +SELECT * FROM numbers WHERE b <> ALL(ARRAY['One', 'Four']); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 206: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE b > ANY(ARRAY['One', 'Two']); + QUERY PLAN +---------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..83.00 rows=83 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`b` > 'One' OR `b` > 'Two') +(3 rows) + +--Testcase 207: +SELECT * FROM numbers WHERE b > ANY(ARRAY['One', 'Two']); + a | b +---+----- + 2 | Two +(1 row) + +--Testcase 208: +EXPLAIN VERBOSE SELECT * FROM numbers WHERE b > ALL(ARRAY['Four', 'Five']); + QUERY PLAN +------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers (cost=10.00..17.00 rows=17 width=520) + Output: a, b + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE (`b` > 'Four' AND `b` > 'Five') +(3 rows) + +--Testcase 209: +SELECT * FROM numbers WHERE b > ALL(ARRAY['Four', 'Five']); + a | b +---+----- + 1 | One + 2 | Two +(2 rows) + +--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; + a | b | c +---+----+--- + 1 | 10 | 3 + 1 | 2 | 4 +(2 rows) + +--Testcase 84: +UPDATE multiprimary SET a = 10 WHERE a = 1; +--Testcase 85: +SELECT * from multiprimary; + a | b | c +----+----+--- + 10 | 10 | 3 + 10 | 2 | 4 +(2 rows) + +--Testcase 86: +UPDATE multiprimary SET a = 100, b=200, c=300 WHERE a=10 AND b=10; +--Testcase 87: +SELECT * from multiprimary; + a | b | c +-----+-----+----- + 100 | 200 | 300 + 10 | 2 | 4 +(2 rows) + +--Testcase 88: +UPDATE multiprimary SET a = 1234; +--Testcase 89: +SELECT * from multiprimary; + a | b | c +------+-----+----- + 1234 | 200 | 300 + 1234 | 2 | 4 +(2 rows) + +--Testcase 90: +UPDATE multiprimary SET a = a+1, b=b+1 WHERE b=200 AND c=300; +--Testcase 91: +SELECT * from multiprimary; + a | b | c +------+-----+----- + 1235 | 201 | 300 + 1234 | 2 | 4 +(2 rows) + +--Testcase 92: +DELETE from multiprimary WHERE a = 1235; +--Testcase 93: +SELECT * from multiprimary; + a | b | c +------+---+--- + 1234 | 2 | 4 +(1 row) + +--Testcase 94: +DELETE from multiprimary WHERE b = 2; +--Testcase 95: +SELECT * from multiprimary; + a | b | c +---+---+--- +(0 rows) + +--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; + count +------- + 2 +(1 row) + +--Testcase 101: +SELECT sum(b),max(b), min(b) from multiprimary; + sum | max | min +-----+-----+----- + 34 | 20 | 2 +(1 row) + +--Testcase 102: +SELECT sum(b+5)+2 from multiprimary group by b/2 order by b/2; + ?column? +---------- + 16 + 17 + 27 +(3 rows) + +--Testcase 103: +SELECT sum(a) from multiprimary group by b having sum(a) > 0 order by sum(a); + sum +----- + 1 + 2 + 2 +(3 rows) + +--Testcase 104: +SELECT sum(a) A from multiprimary group by b having avg(abs(a)) > 0 AND sum(a) > 0 order by A; + a +--- + 1 + 2 + 2 +(3 rows) + +--Testcase 105: +SELECT count(nullif(a, 1)) FROM multiprimary; + count +------- + 1 +(1 row) + +--Testcase 106: +SELECT a,a FROM multiprimary group by 1,2; + a | a +---+--- + 1 | 1 + 2 | 2 +(2 rows) + +--Testcase 107: +SELECT * from multiprimary, numbers WHERE multiprimary.a=numbers.a; + a | b | c | a | b +---+----+----+---+----- + 1 | 2 | 3 | 1 | One + 1 | 2 | 4 | 1 | One + 1 | 10 | 20 | 1 | One + 2 | 20 | 40 | 2 | Two +(4 rows) + +--Testcase 108: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT sum(a) FROM multiprimary HAVING sum(a) > 0; + QUERY PLAN +----------------------------------------------------------- + Aggregate + Output: sum(a) + Filter: (sum(multiprimary.a) > 0) + -> Foreign Scan on public.multiprimary + Output: a, b, c + SQLite query: SELECT `a` FROM main."multiprimary" +(6 rows) + +--Testcase 109: +SELECT sum(a) FROM multiprimary HAVING sum(a) > 0; + sum +----- + 5 +(1 row) + +--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'; + a | b +---+------ + 4 | Four +(1 row) + +--Testcase 112: +EXPLAIN (verbose, costs off) SELECT b, length(b) FROM numbers WHERE abs(a) = 4 AND upper(b) = 'FOUR' AND lower(b) = 'four'; + QUERY PLAN +----------------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers + Output: b, length((b)::text) + Filter: ((upper((numbers.b)::text) = 'FOUR'::text) AND (lower((numbers.b)::text) = 'four'::text)) + SQLite query: SELECT `b` FROM main."numbers" WHERE ((abs(`a`) = 4)) +(4 rows) + +-- 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; + b | length +------+-------- + Four | 4 +(1 row) + +--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; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.numbers + Output: b, length((b)::text) + Filter: ((power('1'::double precision, (numbers.a)::double precision) <> '0'::double precision) AND (length(reverse((numbers.b)::text)) = 4)) + SQLite query: SELECT `a`, `b` FROM main."numbers" WHERE ((length(`b`) = 4)) +(4 rows) + +--Testcase 115: +INSERT INTO multiprimary (b,c) VALUES (99, 100); +--Testcase 116: +SELECT c FROM multiprimary WHERE COALESCE(a,b,c) = 99; + c +----- + 100 +(1 row) + +--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; + a | b | c +---+----+---- + 1 | 2 | 2 + 1 | 2 | 2 + 1 | 10 | 10 + 2 | 20 | 20 + | 99 | 99 +(5 rows) + +--Testcase 214: +ALTER FOREIGN TABLE multiprimary2 ALTER COLUMN a OPTIONS(ADD column_name 'b'); +--Testcase 118: +SELECT * FROM multiprimary2; + a | b | c +----+----+---- + 2 | 2 | 2 + 2 | 2 | 2 + 10 | 10 | 10 + 20 | 20 | 20 + 99 | 99 | 99 +(5 rows) + +--Testcase 215: +ALTER FOREIGN TABLE multiprimary2 ALTER COLUMN b OPTIONS (column_name 'nosuch column'); +--Testcase 119: +SELECT * FROM multiprimary2; +ERROR: SQL error during prepare: no such column: nosuch column SELECT `b`, `nosuch column`, `b` FROM main."multiprimary" +--Testcase 140: +EXPLAIN (VERBOSE) SELECT * FROM multiprimary2; + QUERY PLAN +-------------------------------------------------------------------------------- + Foreign Scan on public.multiprimary2 (cost=10.00..2275.00 rows=2275 width=12) + Output: a, b, c + SQLite query: SELECT `b`, `nosuch column`, `b` FROM main."multiprimary" +(3 rows) + +--Testcase 120: +SELECT a FROM multiprimary2 WHERE b = 1; +ERROR: SQL error during prepare: no such column: nosuch column SELECT `b` FROM main."multiprimary" WHERE ((`nosuch column` = 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; + a | b b | c +---+-----+---- + 1 | 2 | 10 +(1 row) + +--Testcase 124: +UPDATE columntest SET a=100 WHERE c = 10; +--Testcase 125: +SELECT * FROM columntest; + a | b b | c +-----+-----+---- + 100 | 2 | 10 +(1 row) + +--Testcase 126: +INSERT INTO noprimary VALUES(1,'2'); +--Testcase 127: +INSERT INTO noprimary SELECT * FROM noprimary; +--Testcase 128: +SELECT * FROM noprimary; + a | b +---+--- + 1 | 2 + 1 | 2 +(2 rows) + +--get version +--Testcase 153: +\df sqlite* + List of functions + Schema | Name | Result data type | Argument data types | Type +--------+----------------------------+------------------+-----------------------------------------+------ + public | sqlite_fdw_disconnect | boolean | text | func + public | sqlite_fdw_disconnect_all | boolean | | func + public | sqlite_fdw_get_connections | SETOF record | OUT server_name text, OUT valid boolean | func + public | sqlite_fdw_handler | fdw_handler | | func + public | sqlite_fdw_validator | void | text[], oid | func + public | sqlite_fdw_version | integer | | func +(6 rows) + +--Testcase 154: +SELECT * FROM public.sqlite_fdw_version(); + sqlite_fdw_version +-------------------- + 20200 +(1 row) + +--Testcase 155: +SELECT sqlite_fdw_version(); + sqlite_fdw_version +-------------------- + 20200 +(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) + +-- Executable test case for pushdown CASE expressions (results) +--Testcase 224: +CREATE FOREIGN TABLE case_exp(c1 int OPTIONS (key 'true'), c3 text, c6 varchar(10)) SERVER sqlite_svr; +--Testcase 225: +INSERT INTO case_exp + SELECT id, + to_char(id, 'FM00000'), + id % 10 + FROM generate_series(1, 10) id; +--Testcase 226: +SELECT * FROM case_exp; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +-- CASE arg WHEN +--Testcase 227: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE ((`c1` > CASE mod(`c1`, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END)) +(3 rows) + +--Testcase 228: +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + c1 | c3 | c6 +----+-------+---- + 4 | 00004 | 4 + 8 | 00008 | 8 +(2 rows) + +-- these are shippable +--Testcase 229: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + QUERY PLAN +-------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE (CASE `c6` WHEN 'foo' THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 230: +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +--Testcase 231: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + QUERY PLAN +------------------------------------------------------------------------------------------------------------------------- + Foreign Scan on public.case_exp + Output: c1, c3, c6 + SQLite query: SELECT `c1`, `c3`, `c6` FROM main."case_exp" WHERE (CASE `c3` WHEN `c6` THEN 1 ELSE (`c3` < 'bar') END) +(3 rows) + +--Testcase 232: +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +-- but this is not because of collation +--Testcase 233: +SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + c1 | c3 | c6 +----+-------+---- + 1 | 00001 | 1 + 2 | 00002 | 2 + 3 | 00003 | 3 + 4 | 00004 | 4 + 5 | 00005 | 5 + 6 | 00006 | 6 + 7 | 00007 | 7 + 8 | 00008 | 8 + 9 | 00009 | 9 + 10 | 00010 | 0 +(10 rows) + +--Testcase 234: +DELETE FROM case_exp; +--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 235: +DROP FOREIGN TABLE case_exp; +--Testcase 151: +DROP SERVER sqlite_svr; +--Testcase 152: +DROP EXTENSION sqlite_fdw CASCADE; diff --git a/expected/15beta2/type.out b/expected/15beta2/type.out new file mode 100644 index 00000000..86d7b629 --- /dev/null +++ b/expected/15beta2/type.out @@ -0,0 +1,352 @@ +--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 40 other objects +DETAIL: drop cascades to server sqlite_svr +drop cascades to foreign table department +drop cascades to foreign table employee +drop cascades to foreign table empdata +drop cascades to foreign table numbers +drop cascades to foreign table t +drop cascades to foreign table multiprimary +drop cascades to foreign table columntest +drop cascades to foreign table noprimary +drop cascades to foreign table limittest +drop cascades to foreign table grem1_1 +drop cascades to foreign table grem1_2 +drop cascades to foreign table case_exp +drop cascades to foreign table "type_STRING" +drop cascades to foreign table "type_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/option.c b/option.c index e47b1a80..440823ee 100644 --- a/option.c +++ b/option.c @@ -2,7 +2,7 @@ * * SQLite Foreign Data Wrapper for PostgreSQL * - * Portions Copyright (c) 2021, TOSHIBA CORPORATION + * Portions Copyright (c) 2018, TOSHIBA CORPORATION * * IDENTIFICATION * option.c @@ -119,8 +119,9 @@ sqlite_fdw_validator(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_FDW_INVALID_OPTION_NAME), errmsg("invalid option \"%s\"", def->defname), - errhint("Valid options in this context are: %s", buf.len ? buf.data : "") - )); + buf.len > 0 ? + errhint("Valid options in this context are: %s", buf.data) : + errhint("There are no valid options in this context."))); } /* Validate option value */ diff --git a/sql/10.18/aggregate.sql b/sql/11.16/aggregate.sql similarity index 100% rename from sql/10.18/aggregate.sql rename to sql/11.16/aggregate.sql diff --git a/sql/10.18/extra/aggregates.sql b/sql/11.16/extra/aggregates.sql similarity index 100% rename from sql/10.18/extra/aggregates.sql rename to sql/11.16/extra/aggregates.sql diff --git a/sql/10.18/extra/float4.sql b/sql/11.16/extra/float4.sql similarity index 100% rename from sql/10.18/extra/float4.sql rename to sql/11.16/extra/float4.sql diff --git a/sql/10.18/extra/float8.sql b/sql/11.16/extra/float8.sql similarity index 100% rename from sql/10.18/extra/float8.sql rename to sql/11.16/extra/float8.sql diff --git a/sql/10.18/extra/insert.sql b/sql/11.16/extra/insert.sql similarity index 100% rename from sql/10.18/extra/insert.sql rename to sql/11.16/extra/insert.sql diff --git a/sql/10.18/extra/int4.sql b/sql/11.16/extra/int4.sql similarity index 100% rename from sql/10.18/extra/int4.sql rename to sql/11.16/extra/int4.sql diff --git a/sql/10.18/extra/int8.sql b/sql/11.16/extra/int8.sql similarity index 100% rename from sql/10.18/extra/int8.sql rename to sql/11.16/extra/int8.sql diff --git a/sql/10.18/extra/join.sql b/sql/11.16/extra/join.sql similarity index 100% rename from sql/10.18/extra/join.sql rename to sql/11.16/extra/join.sql diff --git a/sql/10.18/extra/limit.sql b/sql/11.16/extra/limit.sql similarity index 100% rename from sql/10.18/extra/limit.sql rename to sql/11.16/extra/limit.sql diff --git a/sql/10.18/extra/numeric.sql b/sql/11.16/extra/numeric.sql similarity index 100% rename from sql/10.18/extra/numeric.sql rename to sql/11.16/extra/numeric.sql diff --git a/sql/10.18/extra/prepare.sql b/sql/11.16/extra/prepare.sql similarity index 100% rename from sql/10.18/extra/prepare.sql rename to sql/11.16/extra/prepare.sql diff --git a/sql/10.18/extra/select.sql b/sql/11.16/extra/select.sql similarity index 100% rename from sql/10.18/extra/select.sql rename to sql/11.16/extra/select.sql diff --git a/sql/10.18/extra/select_having.sql b/sql/11.16/extra/select_having.sql similarity index 100% rename from sql/10.18/extra/select_having.sql rename to sql/11.16/extra/select_having.sql diff --git a/sql/10.18/extra/sqlite_fdw_post.sql b/sql/11.16/extra/sqlite_fdw_post.sql similarity index 100% rename from sql/10.18/extra/sqlite_fdw_post.sql rename to sql/11.16/extra/sqlite_fdw_post.sql diff --git a/sql/10.18/extra/timestamp.sql b/sql/11.16/extra/timestamp.sql similarity index 100% rename from sql/10.18/extra/timestamp.sql rename to sql/11.16/extra/timestamp.sql diff --git a/sql/10.18/extra/update.sql b/sql/11.16/extra/update.sql similarity index 100% rename from sql/10.18/extra/update.sql rename to sql/11.16/extra/update.sql diff --git a/sql/10.18/selectfunc.sql b/sql/11.16/selectfunc.sql similarity index 72% rename from sql/10.18/selectfunc.sql rename to sql/11.16/selectfunc.sql index 86e4fd1e..3db3d875 100644 --- a/sql/10.18/selectfunc.sql +++ b/sql/11.16/selectfunc.sql @@ -284,6 +284,129 @@ SELECT round(abs(value2), 0) FROM s3; --Testcase 33: SELECT round(abs(value2), 0) FROM s3; +-- select mod (builtin function, explain) +--Testcase 34: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + +-- select mod (builtin function, result) +--Testcase 35: +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + +-- select mod (builtin function, not pushdown constraints, explain) +--Testcase 36: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + +-- select mod (builtin function, not pushdown constraints, result) +--Testcase 37: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + +-- select mod (builtin function, pushdown constraints, explain) +--Testcase 38: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + +-- select mod (builtin function, pushdown constraints, result) +--Testcase 39: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 40: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + +-- select mod (builtin function, mod in constraints, result) +--Testcase 41: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 42: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + +-- select mod (builtin function, mod in constraints, result) +--Testcase 43: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + +-- select mod as nest function with agg (pushdown, explain) +--Testcase 44: +EXPLAIN VERBOSE +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + +-- select mod as nest function with agg (pushdown, result) +--Testcase 45: +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + +-- select mod as nest with abs (pushdown, explain) +--Testcase 46: +EXPLAIN VERBOSE +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + +-- select mod as nest with abs (pushdown, result) +--Testcase 47: +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + +-- select mod with non pushdown func and explicit constant (explain) +--Testcase 48: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + +-- select mod with non pushdown func and explicit constant (result) +--Testcase 49: +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + +-- select mod with order by (explain) +--Testcase 50: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + +-- select mod with order by (result) +--Testcase 51: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + +-- select mod with order by index (result) +--Testcase 52: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 2,1; + +-- select mod with order by index (result) +--Testcase 53: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 1,2; + +-- select mod with group by (explain) +--Testcase 54: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + +-- select mod with group by (result) +--Testcase 55: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + +-- select mod with group by index (result) +--Testcase 56: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 2,1; + +-- select mod with group by index (result) +--Testcase 57: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2; + +-- select mod with group by having (explain) +--Testcase 58: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + +-- select mod with group by having (result) +--Testcase 59: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + +-- select mod with group by index having (result) +--Testcase 60: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2 HAVING value1 > 1; + +-- select mod and as +--Testcase 61: +SELECT value1, mod(value2, 2) as mod1 FROM s3; + --Testcase 29: DROP FOREIGN TABLE s3; --Testcase 30: diff --git a/sql/10.18/sqlite_fdw.sql b/sql/11.16/sqlite_fdw.sql similarity index 92% rename from sql/10.18/sqlite_fdw.sql rename to sql/11.16/sqlite_fdw.sql index 9c18231a..e29ae880 100644 --- a/sql/10.18/sqlite_fdw.sql +++ b/sql/11.16/sqlite_fdw.sql @@ -551,6 +551,46 @@ ALTER TABLE fts_table ALTER COLUMN name TYPE int; --Testcase 160: SELECT * FROM fts_table; -- should fail +-- Executable test case for pushdown CASE expressions (results) +--Testcase 224: +CREATE FOREIGN TABLE case_exp(c1 int OPTIONS (key 'true'), c3 text, c6 varchar(10)) SERVER sqlite_svr; + +--Testcase 225: +INSERT INTO case_exp + SELECT id, + to_char(id, 'FM00000'), + id % 10 + FROM generate_series(1, 10) id; + +--Testcase 226: +SELECT * FROM case_exp; + +-- CASE arg WHEN +--Testcase 227: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); +--Testcase 228: +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + +-- these are shippable +--Testcase 229: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 230: +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 231: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; +--Testcase 232: +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + +-- but this is not because of collation +--Testcase 233: +SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + +--Testcase 234: +DELETE FROM case_exp; + --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -571,6 +611,8 @@ DROP FOREIGN TABLE columntest; DROP FOREIGN TABLE noprimary; --Testcase 161: DROP FOREIGN TABLE fts_table; +--Testcase 235: +DROP FOREIGN TABLE case_exp; --Testcase 151: DROP SERVER sqlite_svr; diff --git a/sql/10.18/type.sql b/sql/11.16/type.sql similarity index 100% rename from sql/10.18/type.sql rename to sql/11.16/type.sql diff --git a/sql/11.13/aggregate.sql b/sql/12.11/aggregate.sql similarity index 100% rename from sql/11.13/aggregate.sql rename to sql/12.11/aggregate.sql diff --git a/sql/11.13/extra/aggregates.sql b/sql/12.11/extra/aggregates.sql similarity index 100% rename from sql/11.13/extra/aggregates.sql rename to sql/12.11/extra/aggregates.sql diff --git a/sql/11.13/extra/float4.sql b/sql/12.11/extra/float4.sql similarity index 100% rename from sql/11.13/extra/float4.sql rename to sql/12.11/extra/float4.sql diff --git a/sql/11.13/extra/float8.sql b/sql/12.11/extra/float8.sql similarity index 100% rename from sql/11.13/extra/float8.sql rename to sql/12.11/extra/float8.sql diff --git a/sql/11.13/extra/insert.sql b/sql/12.11/extra/insert.sql similarity index 100% rename from sql/11.13/extra/insert.sql rename to sql/12.11/extra/insert.sql diff --git a/sql/11.13/extra/int4.sql b/sql/12.11/extra/int4.sql similarity index 100% rename from sql/11.13/extra/int4.sql rename to sql/12.11/extra/int4.sql diff --git a/sql/11.13/extra/int8.sql b/sql/12.11/extra/int8.sql similarity index 100% rename from sql/11.13/extra/int8.sql rename to sql/12.11/extra/int8.sql diff --git a/sql/11.13/extra/join.sql b/sql/12.11/extra/join.sql similarity index 100% rename from sql/11.13/extra/join.sql rename to sql/12.11/extra/join.sql diff --git a/sql/11.13/extra/limit.sql b/sql/12.11/extra/limit.sql similarity index 100% rename from sql/11.13/extra/limit.sql rename to sql/12.11/extra/limit.sql diff --git a/sql/11.13/extra/numeric.sql b/sql/12.11/extra/numeric.sql similarity index 100% rename from sql/11.13/extra/numeric.sql rename to sql/12.11/extra/numeric.sql diff --git a/sql/11.13/extra/prepare.sql b/sql/12.11/extra/prepare.sql similarity index 100% rename from sql/11.13/extra/prepare.sql rename to sql/12.11/extra/prepare.sql diff --git a/sql/11.13/extra/select.sql b/sql/12.11/extra/select.sql similarity index 100% rename from sql/11.13/extra/select.sql rename to sql/12.11/extra/select.sql diff --git a/sql/11.13/extra/select_having.sql b/sql/12.11/extra/select_having.sql similarity index 100% rename from sql/11.13/extra/select_having.sql rename to sql/12.11/extra/select_having.sql diff --git a/sql/11.13/extra/sqlite_fdw_post.sql b/sql/12.11/extra/sqlite_fdw_post.sql similarity index 100% rename from sql/11.13/extra/sqlite_fdw_post.sql rename to sql/12.11/extra/sqlite_fdw_post.sql diff --git a/sql/11.13/extra/timestamp.sql b/sql/12.11/extra/timestamp.sql similarity index 100% rename from sql/11.13/extra/timestamp.sql rename to sql/12.11/extra/timestamp.sql diff --git a/sql/11.13/extra/update.sql b/sql/12.11/extra/update.sql similarity index 100% rename from sql/11.13/extra/update.sql rename to sql/12.11/extra/update.sql diff --git a/sql/11.13/selectfunc.sql b/sql/12.11/selectfunc.sql similarity index 72% rename from sql/11.13/selectfunc.sql rename to sql/12.11/selectfunc.sql index 86e4fd1e..3db3d875 100644 --- a/sql/11.13/selectfunc.sql +++ b/sql/12.11/selectfunc.sql @@ -284,6 +284,129 @@ SELECT round(abs(value2), 0) FROM s3; --Testcase 33: SELECT round(abs(value2), 0) FROM s3; +-- select mod (builtin function, explain) +--Testcase 34: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + +-- select mod (builtin function, result) +--Testcase 35: +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + +-- select mod (builtin function, not pushdown constraints, explain) +--Testcase 36: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + +-- select mod (builtin function, not pushdown constraints, result) +--Testcase 37: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + +-- select mod (builtin function, pushdown constraints, explain) +--Testcase 38: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + +-- select mod (builtin function, pushdown constraints, result) +--Testcase 39: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 40: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + +-- select mod (builtin function, mod in constraints, result) +--Testcase 41: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 42: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + +-- select mod (builtin function, mod in constraints, result) +--Testcase 43: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + +-- select mod as nest function with agg (pushdown, explain) +--Testcase 44: +EXPLAIN VERBOSE +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + +-- select mod as nest function with agg (pushdown, result) +--Testcase 45: +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + +-- select mod as nest with abs (pushdown, explain) +--Testcase 46: +EXPLAIN VERBOSE +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + +-- select mod as nest with abs (pushdown, result) +--Testcase 47: +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + +-- select mod with non pushdown func and explicit constant (explain) +--Testcase 48: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + +-- select mod with non pushdown func and explicit constant (result) +--Testcase 49: +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + +-- select mod with order by (explain) +--Testcase 50: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + +-- select mod with order by (result) +--Testcase 51: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + +-- select mod with order by index (result) +--Testcase 52: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 2,1; + +-- select mod with order by index (result) +--Testcase 53: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 1,2; + +-- select mod with group by (explain) +--Testcase 54: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + +-- select mod with group by (result) +--Testcase 55: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + +-- select mod with group by index (result) +--Testcase 56: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 2,1; + +-- select mod with group by index (result) +--Testcase 57: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2; + +-- select mod with group by having (explain) +--Testcase 58: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + +-- select mod with group by having (result) +--Testcase 59: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + +-- select mod with group by index having (result) +--Testcase 60: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2 HAVING value1 > 1; + +-- select mod and as +--Testcase 61: +SELECT value1, mod(value2, 2) as mod1 FROM s3; + --Testcase 29: DROP FOREIGN TABLE s3; --Testcase 30: diff --git a/sql/13.4/sqlite_fdw.sql b/sql/12.11/sqlite_fdw.sql similarity index 92% rename from sql/13.4/sqlite_fdw.sql rename to sql/12.11/sqlite_fdw.sql index 9c18231a..e29ae880 100644 --- a/sql/13.4/sqlite_fdw.sql +++ b/sql/12.11/sqlite_fdw.sql @@ -551,6 +551,46 @@ ALTER TABLE fts_table ALTER COLUMN name TYPE int; --Testcase 160: SELECT * FROM fts_table; -- should fail +-- Executable test case for pushdown CASE expressions (results) +--Testcase 224: +CREATE FOREIGN TABLE case_exp(c1 int OPTIONS (key 'true'), c3 text, c6 varchar(10)) SERVER sqlite_svr; + +--Testcase 225: +INSERT INTO case_exp + SELECT id, + to_char(id, 'FM00000'), + id % 10 + FROM generate_series(1, 10) id; + +--Testcase 226: +SELECT * FROM case_exp; + +-- CASE arg WHEN +--Testcase 227: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); +--Testcase 228: +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + +-- these are shippable +--Testcase 229: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 230: +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 231: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; +--Testcase 232: +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + +-- but this is not because of collation +--Testcase 233: +SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + +--Testcase 234: +DELETE FROM case_exp; + --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -571,6 +611,8 @@ DROP FOREIGN TABLE columntest; DROP FOREIGN TABLE noprimary; --Testcase 161: DROP FOREIGN TABLE fts_table; +--Testcase 235: +DROP FOREIGN TABLE case_exp; --Testcase 151: DROP SERVER sqlite_svr; diff --git a/sql/11.13/type.sql b/sql/12.11/type.sql similarity index 100% rename from sql/11.13/type.sql rename to sql/12.11/type.sql diff --git a/sql/12.8/aggregate.sql b/sql/13.7/aggregate.sql similarity index 100% rename from sql/12.8/aggregate.sql rename to sql/13.7/aggregate.sql diff --git a/sql/12.8/extra/aggregates.sql b/sql/13.7/extra/aggregates.sql similarity index 100% rename from sql/12.8/extra/aggregates.sql rename to sql/13.7/extra/aggregates.sql diff --git a/sql/12.8/extra/float4.sql b/sql/13.7/extra/float4.sql similarity index 100% rename from sql/12.8/extra/float4.sql rename to sql/13.7/extra/float4.sql diff --git a/sql/12.8/extra/float8.sql b/sql/13.7/extra/float8.sql similarity index 100% rename from sql/12.8/extra/float8.sql rename to sql/13.7/extra/float8.sql diff --git a/sql/12.8/extra/insert.sql b/sql/13.7/extra/insert.sql similarity index 100% rename from sql/12.8/extra/insert.sql rename to sql/13.7/extra/insert.sql diff --git a/sql/12.8/extra/int4.sql b/sql/13.7/extra/int4.sql similarity index 100% rename from sql/12.8/extra/int4.sql rename to sql/13.7/extra/int4.sql diff --git a/sql/12.8/extra/int8.sql b/sql/13.7/extra/int8.sql similarity index 100% rename from sql/12.8/extra/int8.sql rename to sql/13.7/extra/int8.sql diff --git a/sql/12.8/extra/join.sql b/sql/13.7/extra/join.sql similarity index 100% rename from sql/12.8/extra/join.sql rename to sql/13.7/extra/join.sql diff --git a/sql/12.8/extra/limit.sql b/sql/13.7/extra/limit.sql similarity index 100% rename from sql/12.8/extra/limit.sql rename to sql/13.7/extra/limit.sql diff --git a/sql/12.8/extra/numeric.sql b/sql/13.7/extra/numeric.sql similarity index 100% rename from sql/12.8/extra/numeric.sql rename to sql/13.7/extra/numeric.sql diff --git a/sql/12.8/extra/prepare.sql b/sql/13.7/extra/prepare.sql similarity index 100% rename from sql/12.8/extra/prepare.sql rename to sql/13.7/extra/prepare.sql diff --git a/sql/12.8/extra/select.sql b/sql/13.7/extra/select.sql similarity index 100% rename from sql/12.8/extra/select.sql rename to sql/13.7/extra/select.sql diff --git a/sql/12.8/extra/select_having.sql b/sql/13.7/extra/select_having.sql similarity index 100% rename from sql/12.8/extra/select_having.sql rename to sql/13.7/extra/select_having.sql diff --git a/sql/12.8/extra/sqlite_fdw_post.sql b/sql/13.7/extra/sqlite_fdw_post.sql similarity index 100% rename from sql/12.8/extra/sqlite_fdw_post.sql rename to sql/13.7/extra/sqlite_fdw_post.sql diff --git a/sql/12.8/extra/timestamp.sql b/sql/13.7/extra/timestamp.sql similarity index 100% rename from sql/12.8/extra/timestamp.sql rename to sql/13.7/extra/timestamp.sql diff --git a/sql/12.8/extra/update.sql b/sql/13.7/extra/update.sql similarity index 100% rename from sql/12.8/extra/update.sql rename to sql/13.7/extra/update.sql diff --git a/sql/13.4/selectfunc.sql b/sql/13.7/selectfunc.sql similarity index 72% rename from sql/13.4/selectfunc.sql rename to sql/13.7/selectfunc.sql index 86e4fd1e..3db3d875 100644 --- a/sql/13.4/selectfunc.sql +++ b/sql/13.7/selectfunc.sql @@ -284,6 +284,129 @@ SELECT round(abs(value2), 0) FROM s3; --Testcase 33: SELECT round(abs(value2), 0) FROM s3; +-- select mod (builtin function, explain) +--Testcase 34: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + +-- select mod (builtin function, result) +--Testcase 35: +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + +-- select mod (builtin function, not pushdown constraints, explain) +--Testcase 36: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + +-- select mod (builtin function, not pushdown constraints, result) +--Testcase 37: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + +-- select mod (builtin function, pushdown constraints, explain) +--Testcase 38: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + +-- select mod (builtin function, pushdown constraints, result) +--Testcase 39: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 40: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + +-- select mod (builtin function, mod in constraints, result) +--Testcase 41: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 42: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + +-- select mod (builtin function, mod in constraints, result) +--Testcase 43: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + +-- select mod as nest function with agg (pushdown, explain) +--Testcase 44: +EXPLAIN VERBOSE +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + +-- select mod as nest function with agg (pushdown, result) +--Testcase 45: +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + +-- select mod as nest with abs (pushdown, explain) +--Testcase 46: +EXPLAIN VERBOSE +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + +-- select mod as nest with abs (pushdown, result) +--Testcase 47: +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + +-- select mod with non pushdown func and explicit constant (explain) +--Testcase 48: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + +-- select mod with non pushdown func and explicit constant (result) +--Testcase 49: +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + +-- select mod with order by (explain) +--Testcase 50: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + +-- select mod with order by (result) +--Testcase 51: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + +-- select mod with order by index (result) +--Testcase 52: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 2,1; + +-- select mod with order by index (result) +--Testcase 53: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 1,2; + +-- select mod with group by (explain) +--Testcase 54: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + +-- select mod with group by (result) +--Testcase 55: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + +-- select mod with group by index (result) +--Testcase 56: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 2,1; + +-- select mod with group by index (result) +--Testcase 57: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2; + +-- select mod with group by having (explain) +--Testcase 58: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + +-- select mod with group by having (result) +--Testcase 59: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + +-- select mod with group by index having (result) +--Testcase 60: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2 HAVING value1 > 1; + +-- select mod and as +--Testcase 61: +SELECT value1, mod(value2, 2) as mod1 FROM s3; + --Testcase 29: DROP FOREIGN TABLE s3; --Testcase 30: diff --git a/sql/11.13/sqlite_fdw.sql b/sql/13.7/sqlite_fdw.sql similarity index 92% rename from sql/11.13/sqlite_fdw.sql rename to sql/13.7/sqlite_fdw.sql index 9c18231a..e29ae880 100644 --- a/sql/11.13/sqlite_fdw.sql +++ b/sql/13.7/sqlite_fdw.sql @@ -551,6 +551,46 @@ ALTER TABLE fts_table ALTER COLUMN name TYPE int; --Testcase 160: SELECT * FROM fts_table; -- should fail +-- Executable test case for pushdown CASE expressions (results) +--Testcase 224: +CREATE FOREIGN TABLE case_exp(c1 int OPTIONS (key 'true'), c3 text, c6 varchar(10)) SERVER sqlite_svr; + +--Testcase 225: +INSERT INTO case_exp + SELECT id, + to_char(id, 'FM00000'), + id % 10 + FROM generate_series(1, 10) id; + +--Testcase 226: +SELECT * FROM case_exp; + +-- CASE arg WHEN +--Testcase 227: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); +--Testcase 228: +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + +-- these are shippable +--Testcase 229: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 230: +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 231: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; +--Testcase 232: +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + +-- but this is not because of collation +--Testcase 233: +SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + +--Testcase 234: +DELETE FROM case_exp; + --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -571,6 +611,8 @@ DROP FOREIGN TABLE columntest; DROP FOREIGN TABLE noprimary; --Testcase 161: DROP FOREIGN TABLE fts_table; +--Testcase 235: +DROP FOREIGN TABLE case_exp; --Testcase 151: DROP SERVER sqlite_svr; diff --git a/sql/12.8/type.sql b/sql/13.7/type.sql similarity index 100% rename from sql/12.8/type.sql rename to sql/13.7/type.sql diff --git a/sql/14.0/selectfunc.sql b/sql/14.0/selectfunc.sql deleted file mode 100644 index 86e4fd1e..00000000 --- a/sql/14.0/selectfunc.sql +++ /dev/null @@ -1,292 +0,0 @@ -SET datestyle=ISO; -SET timezone='Japan'; - ---Testcase 1: -CREATE EXTENSION sqlite_fdw; ---Testcase 2: -CREATE SERVER server1 FOREIGN DATA WRAPPER sqlite_fdw -OPTIONS (database '/tmp/sqlitefdw_test_selectfunc.db'); ---CREATE USER MAPPING FOR CURRENT_USER SERVER server1 OPTIONS(user 'user', password 'pass'); - ---IMPORT FOREIGN SCHEMA public FROM SERVER server1 INTO public OPTIONS(import_time_text 'false'); ---Testcase 3: -CREATE FOREIGN TABLE s3(id text OPTIONS (key 'true'), time timestamp, tag1 text, value1 float, value2 int, value3 float, value4 int, str1 text, str2 text) SERVER server1; - --- s3 (value1 as float8, value2 as bigint) ---Testcase 4: -\d s3; ---Testcase 5: -SELECT * FROM s3; - --- select float8() (not pushdown, remove float8, explain) --- EXPLAIN VERBOSE --- SELECT float8(value1), float8(value2), float8(value3), float8(value4) FROM s3; --- sqlite fdw does not support - --- select float8() (not pushdown, remove float8, result) --- SELECT float8(value1), float8(value2), float8(value3), float8(value4) FROM s3; --- sqlite fdw does not support - --- select sqrt (builtin function, explain) --- EXPLAIN VERBOSE --- SELECT sqrt(value1), sqrt(value2) FROM s3; --- sqlite fdw does not have sqrt() - --- select sqrt (buitin function, result) --- SELECT sqrt(value1), sqrt(value2) FROM s3; --- sqlite fdw does not have sqrt() - --- select sqrt (builtin function,, not pushdown constraints, explain) --- EXPLAIN VERBOSE --- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE to_hex(value2) != '64'; --- sqlite fdw does not have sqrt() - --- select sqrt (builtin function, not pushdown constraints, result) --- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE to_hex(value2) != '64'; --- sqlite fdw does not have sqrt() - --- select sqrt (builtin function, pushdown constraints, explain) --- EXPLAIN VERBOSE --- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE value2 != 200; --- sqlite fdw does not have sqrt() - --- select sqrt (builtin function, pushdown constraints, result) --- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE value2 != 200; --- sqlite fdw does not have sqrt() - --- select abs (builtin function, explain) ---Testcase 6: -EXPLAIN VERBOSE -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3; - --- select abs (buitin function, result) ---Testcase 7: -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3; - --- select abs (builtin function, not pushdown constraints, explain) ---Testcase 8: -EXPLAIN VERBOSE -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE to_hex(value2) != '64'; - --- select abs (builtin function, not pushdown constraints, result) ---Testcase 9: -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE to_hex(value2) != '64'; - --- select abs (builtin function, pushdown constraints, explain) ---Testcase 10: -EXPLAIN VERBOSE -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE value2 != 200; - --- select abs (builtin function, pushdown constraints, result) ---Testcase 11: -SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE value2 != 200; - --- select log (builtin function, need to swap arguments, numeric cast, explain) --- log_(v) : postgresql (base, v), sqlite (v, base) --- EXPLAIN VERBOSE --- SELECT log(value1::numeric, value2::numeric) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() - --- select log (builtin function, need to swap arguments, numeric cast, result) --- SELECT log(value1::numeric, value2::numeric) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() - --- select log (stub function, need to swap arguments, float8, explain) --- EXPLAIN VERBOSE --- SELECT log(value1, 0.1) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() - --- select log (stub function, need to swap arguments, float8, result) --- SELECT log(value1, 0.1) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() - --- select log (stub function, need to swap arguments, bigint, explain) --- EXPLAIN VERBOSE --- SELECT log(value2, 3) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() - --- select log (stub function, need to swap arguments, bigint, result) --- SELECT log(value2, 3) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() - --- select log (stub function, need to swap arguments, mix type, explain) --- EXPLAIN VERBOSE --- SELECT log(value1, value2) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() - --- select log (stub function, need to swap arguments, mix type, result) --- SELECT log(value1, value2) FROM s3 WHERE value1 != 1; --- sqlite fdw does not have log() - --- select log2 (stub function, explain) --- EXPLAIN VERBOSE --- SELECT log2(value1),log2(value2) FROM s3; --- sqlite fdw does not have log2() - --- select log2 (stub function, result) --- SELECT log2(value1),log2(value2) FROM s3; --- sqlite fdw does not have log2() - --- select spread (stub agg function, explain) --- EXPLAIN VERBOSE --- SELECT spread(value1),spread(value2),spread(value3),spread(value4) FROM s3; --- sqlite fdw does not have spread() - --- select spread (stub agg function, result) --- SELECT spread(value1),spread(value2),spread(value3),spread(value4) FROM s3; --- sqlite fdw does not have spread() - --- select spread (stub agg function, raise exception if not expected type) --- SELECT spread(value1::numeric),spread(value2::numeric),spread(value3::numeric),spread(value4::numeric) FROM s3; --- sqlite fdw does not have spread() - --- select abs as nest function with agg (pushdown, explain) ---Testcase 12: -EXPLAIN VERBOSE -SELECT sum(value3),abs(sum(value3)) FROM s3; - --- select abs as nest function with agg (pushdown, result) ---Testcase 13: -SELECT sum(value3),abs(sum(value3)) FROM s3; - --- select abs as nest with log2 (pushdown, explain) --- EXPLAIN VERBOSE --- SELECT abs(log2(value1)),abs(log2(1/value1)) FROM s3; --- sqlite fdw does not have log2() - --- select abs as nest with log2 (pushdown, result) --- SELECT abs(log2(value1)),abs(log2(1/value1)) FROM s3; --- sqlite fdw does not have log2() - --- select abs with non pushdown func and explicit constant (explain) ---Testcase 14: -EXPLAIN VERBOSE -SELECT abs(value3), pi(), 4.1 FROM s3; - --- select abs with non pushdown func and explicit constant (result) ---Testcase 15: -SELECT abs(value3), pi(), 4.1 FROM s3; - --- select sqrt as nest function with agg and explicit constant (pushdown, explain) --- EXPLAIN VERBOSE --- SELECT sqrt(count(value1)), pi(), 4.1 FROM s3; --- sqlite fdw does not have sqrt() - --- select sqrt as nest function with agg and explicit constant (pushdown, result) --- SELECT sqrt(count(value1)), pi(), 4.1 FROM s3; --- sqlite fdw does not have sqrt() - --- select sqrt as nest function with agg and explicit constant and tag (error, explain) --- EXPLAIN VERBOSE --- SELECT sqrt(count(value1)), pi(), 4.1, tag1 FROM s3; --- sqlite fdw does not have sqrt() - --- select spread (stub agg function and group by influx_time() and tag) (explain) --- EXPLAIN VERBOSE --- SELECT spread("value1"),influx_time(time, interval '1s'),tag1 FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY influx_time(time, interval '1s'), tag1; --- sqlite fdw does not have spread() and influx_time() - --- select spread (stub agg function and group by influx_time() and tag) (result) --- SELECT spread("value1"),influx_time(time, interval '1s'),tag1 FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY influx_time(time, interval '1s'), tag1; --- sqlite fdw does not have spread() and influx_time() - --- select spread (stub agg function and group by tag only) (result) --- SELECT tag1,spread("value1") FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY tag1; --- sqlite fdw does not have spread() - --- select spread (stub agg function and other aggs) (result) --- SELECT sum("value1"),spread("value1"),count("value1") FROM s3; --- sqlite fdw does not have spread() - --- select abs with order by (explain) ---Testcase 16: -EXPLAIN VERBOSE -SELECT value1, abs(1-value1) FROM s3 order by abs(1-value1); - --- select abs with order by (result) ---Testcase 17: -SELECT value1, abs(1-value1) FROM s3 order by abs(1-value1); - --- select abs with order by index (result) ---Testcase 18: -SELECT value1, abs(1-value1) FROM s3 order by 2,1; - --- select abs with order by index (result) ---Testcase 19: -SELECT value1, abs(1-value1) FROM s3 order by 1,2; - --- select abs and as ---Testcase 20: -SELECT abs(value3) as abs1 FROM s3; - --- select spread over join query (explain) --- EXPLAIN VERBOSE --- SELECT spread(t1.value1), spread(t2.value1) FROM s3 t1 INNER JOIN s3 t2 ON (t1.value1 = t2.value1) where t1.value1 = 0.1; --- sqlite fdw does not have spread() - --- select spread over join query (result, stub call error) --- SELECT spread(t1.value1), spread(t2.value1) FROM s3 t1 INNER JOIN s3 t2 ON (t1.value1 = t2.value1) where t1.value1 = 0.1; --- sqlite fdw does not have spread() - --- select spread with having (explain) --- EXPLAIN VERBOSE --- SELECT spread(value1) FROM s3 HAVING spread(value1) > 100; --- sqlite fdw does not have spread() - --- select spread with having (explain, cannot pushdown, stub call error) --- SELECT spread(value1) FROM s3 HAVING spread(value1) > 100; --- sqlite fdw does not have spread() - --- select abs with arithmetic and tag in the middle (explain) ---Testcase 21: -EXPLAIN VERBOSE -SELECT abs(value1) + 1, value2, tag1, sqrt(value2) FROM s3; - --- select abs with arithmetic and tag in the middle (result) ---Testcase 22: -SELECT abs(value1) + 1, value2, tag1, sqrt(value2) FROM s3; - --- select with order by limit (explain) ---Testcase 23: -EXPLAIN VERBOSE -SELECT abs(value1), abs(value3), sqrt(value2) FROM s3 ORDER BY abs(value3) LIMIT 1; - --- select with order by limit (explain) ---Testcase 24: -SELECT abs(value1), abs(value3), sqrt(value2) FROM s3 ORDER BY abs(value3) LIMIT 1; - --- select mixing with non pushdown func (all not pushdown, explain) ---Testcase 25: -EXPLAIN VERBOSE -SELECT abs(value1), sqrt(value2), upper(tag1) FROM s3; - --- select mixing with non pushdown func (result) ---Testcase 26: -SELECT abs(value1), sqrt(value2), upper(tag1) FROM s3; - --- sqlite data prep - --- sqlite pushdown supported functions (explain) ---Testcase 27: -EXPLAIN VERBOSE -SELECT abs(value3), length(tag1), lower(str1), ltrim(str2), ltrim(str1, '-'), replace(str1, 'XYZ', 'ABC'), round(value3), rtrim(str1, '-'), rtrim(str2), substr(str1, 4), substr(str1, 4, 3) FROM s3; - --- sqlite pushdown supported functions (result) ---Testcase 28: -SELECT abs(value3), length(tag1), lower(str1), ltrim(str2), ltrim(str1, '-'), replace(str1, 'XYZ', 'ABC'), round(value3), rtrim(str1, '-'), rtrim(str2), substr(str1, 4), substr(str1, 4, 3) FROM s3; - --- sqlite pushdown nest functions (explain) ---Testcase 32: -EXPLAIN VERBOSE -SELECT round(abs(value2), 0) FROM s3; - --- sqlite pushdown nest functions (result) ---Testcase 33: -SELECT round(abs(value2), 0) FROM s3; - ---Testcase 29: -DROP FOREIGN TABLE s3; ---Testcase 30: -DROP SERVER server1; ---Testcase 31: -DROP EXTENSION sqlite_fdw; diff --git a/sql/13.4/aggregate.sql b/sql/14.4/aggregate.sql similarity index 100% rename from sql/13.4/aggregate.sql rename to sql/14.4/aggregate.sql diff --git a/sql/14.0/extra/aggregates.sql b/sql/14.4/extra/aggregates.sql similarity index 100% rename from sql/14.0/extra/aggregates.sql rename to sql/14.4/extra/aggregates.sql diff --git a/sql/14.0/extra/float4.sql b/sql/14.4/extra/float4.sql similarity index 100% rename from sql/14.0/extra/float4.sql rename to sql/14.4/extra/float4.sql diff --git a/sql/14.0/extra/float8.sql b/sql/14.4/extra/float8.sql similarity index 100% rename from sql/14.0/extra/float8.sql rename to sql/14.4/extra/float8.sql diff --git a/sql/14.0/extra/insert.sql b/sql/14.4/extra/insert.sql similarity index 100% rename from sql/14.0/extra/insert.sql rename to sql/14.4/extra/insert.sql diff --git a/sql/14.0/extra/int4.sql b/sql/14.4/extra/int4.sql similarity index 100% rename from sql/14.0/extra/int4.sql rename to sql/14.4/extra/int4.sql diff --git a/sql/14.0/extra/int8.sql b/sql/14.4/extra/int8.sql similarity index 100% rename from sql/14.0/extra/int8.sql rename to sql/14.4/extra/int8.sql diff --git a/sql/14.0/extra/join.sql b/sql/14.4/extra/join.sql similarity index 100% rename from sql/14.0/extra/join.sql rename to sql/14.4/extra/join.sql diff --git a/sql/13.4/extra/limit.sql b/sql/14.4/extra/limit.sql similarity index 100% rename from sql/13.4/extra/limit.sql rename to sql/14.4/extra/limit.sql diff --git a/sql/14.0/extra/numeric.sql b/sql/14.4/extra/numeric.sql similarity index 100% rename from sql/14.0/extra/numeric.sql rename to sql/14.4/extra/numeric.sql diff --git a/sql/13.4/extra/prepare.sql b/sql/14.4/extra/prepare.sql similarity index 100% rename from sql/13.4/extra/prepare.sql rename to sql/14.4/extra/prepare.sql diff --git a/sql/13.4/extra/select.sql b/sql/14.4/extra/select.sql similarity index 100% rename from sql/13.4/extra/select.sql rename to sql/14.4/extra/select.sql diff --git a/sql/13.4/extra/select_having.sql b/sql/14.4/extra/select_having.sql similarity index 100% rename from sql/13.4/extra/select_having.sql rename to sql/14.4/extra/select_having.sql diff --git a/sql/14.0/extra/sqlite_fdw_post.sql b/sql/14.4/extra/sqlite_fdw_post.sql similarity index 100% rename from sql/14.0/extra/sqlite_fdw_post.sql rename to sql/14.4/extra/sqlite_fdw_post.sql diff --git a/sql/13.4/extra/timestamp.sql b/sql/14.4/extra/timestamp.sql similarity index 100% rename from sql/13.4/extra/timestamp.sql rename to sql/14.4/extra/timestamp.sql diff --git a/sql/14.0/extra/update.sql b/sql/14.4/extra/update.sql similarity index 100% rename from sql/14.0/extra/update.sql rename to sql/14.4/extra/update.sql diff --git a/sql/12.8/selectfunc.sql b/sql/14.4/selectfunc.sql similarity index 72% rename from sql/12.8/selectfunc.sql rename to sql/14.4/selectfunc.sql index 86e4fd1e..3db3d875 100644 --- a/sql/12.8/selectfunc.sql +++ b/sql/14.4/selectfunc.sql @@ -284,6 +284,129 @@ SELECT round(abs(value2), 0) FROM s3; --Testcase 33: SELECT round(abs(value2), 0) FROM s3; +-- select mod (builtin function, explain) +--Testcase 34: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + +-- select mod (builtin function, result) +--Testcase 35: +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + +-- select mod (builtin function, not pushdown constraints, explain) +--Testcase 36: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + +-- select mod (builtin function, not pushdown constraints, result) +--Testcase 37: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + +-- select mod (builtin function, pushdown constraints, explain) +--Testcase 38: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + +-- select mod (builtin function, pushdown constraints, result) +--Testcase 39: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 40: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + +-- select mod (builtin function, mod in constraints, result) +--Testcase 41: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 42: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + +-- select mod (builtin function, mod in constraints, result) +--Testcase 43: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + +-- select mod as nest function with agg (pushdown, explain) +--Testcase 44: +EXPLAIN VERBOSE +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + +-- select mod as nest function with agg (pushdown, result) +--Testcase 45: +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + +-- select mod as nest with abs (pushdown, explain) +--Testcase 46: +EXPLAIN VERBOSE +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + +-- select mod as nest with abs (pushdown, result) +--Testcase 47: +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + +-- select mod with non pushdown func and explicit constant (explain) +--Testcase 48: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + +-- select mod with non pushdown func and explicit constant (result) +--Testcase 49: +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + +-- select mod with order by (explain) +--Testcase 50: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + +-- select mod with order by (result) +--Testcase 51: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + +-- select mod with order by index (result) +--Testcase 52: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 2,1; + +-- select mod with order by index (result) +--Testcase 53: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 1,2; + +-- select mod with group by (explain) +--Testcase 54: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + +-- select mod with group by (result) +--Testcase 55: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + +-- select mod with group by index (result) +--Testcase 56: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 2,1; + +-- select mod with group by index (result) +--Testcase 57: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2; + +-- select mod with group by having (explain) +--Testcase 58: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + +-- select mod with group by having (result) +--Testcase 59: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + +-- select mod with group by index having (result) +--Testcase 60: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2 HAVING value1 > 1; + +-- select mod and as +--Testcase 61: +SELECT value1, mod(value2, 2) as mod1 FROM s3; + --Testcase 29: DROP FOREIGN TABLE s3; --Testcase 30: diff --git a/sql/14.0/sqlite_fdw.sql b/sql/14.4/sqlite_fdw.sql similarity index 92% rename from sql/14.0/sqlite_fdw.sql rename to sql/14.4/sqlite_fdw.sql index 04ffce90..589782fc 100644 --- a/sql/14.0/sqlite_fdw.sql +++ b/sql/14.4/sqlite_fdw.sql @@ -570,6 +570,46 @@ INSERT INTO grem1_2 DEFAULT VALUES; --Testcase 221: SELECT * FROM grem1_2; +-- Executable test case for pushdown CASE expressions (results) +--Testcase 224: +CREATE FOREIGN TABLE case_exp(c1 int OPTIONS (key 'true'), c3 text, c6 varchar(10)) SERVER sqlite_svr; + +--Testcase 225: +INSERT INTO case_exp + SELECT id, + to_char(id, 'FM00000'), + id % 10 + FROM generate_series(1, 10) id; + +--Testcase 226: +SELECT * FROM case_exp; + +-- CASE arg WHEN +--Testcase 227: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); +--Testcase 228: +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + +-- these are shippable +--Testcase 229: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 230: +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 231: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; +--Testcase 232: +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + +-- but this is not because of collation +--Testcase 233: +SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + +--Testcase 234: +DELETE FROM case_exp; + --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -594,6 +634,8 @@ DROP FOREIGN TABLE fts_table; DROP FOREIGN TABLE grem1_1; --Testcase 223: DROP FOREIGN TABLE grem1_2; +--Testcase 235: +DROP FOREIGN TABLE case_exp; --Testcase 151: DROP SERVER sqlite_svr; diff --git a/sql/13.4/type.sql b/sql/14.4/type.sql similarity index 100% rename from sql/13.4/type.sql rename to sql/14.4/type.sql diff --git a/sql/14.0/aggregate.sql b/sql/15beta2/aggregate.sql similarity index 100% rename from sql/14.0/aggregate.sql rename to sql/15beta2/aggregate.sql diff --git a/sql/13.4/extra/aggregates.sql b/sql/15beta2/extra/aggregates.sql similarity index 91% rename from sql/13.4/extra/aggregates.sql rename to sql/15beta2/extra/aggregates.sql index 3440e077..b3462e45 100644 --- a/sql/13.4/extra/aggregates.sql +++ b/sql/15beta2/extra/aggregates.sql @@ -78,7 +78,131 @@ CREATE FOREIGN TABLE VARCHAR_TBL(f1 varchar(4) OPTIONS (key 'true')) SERVER sqli --Testcase 276: CREATE FOREIGN TABLE FLOAT8_TBL(f1 float8 OPTIONS (key 'true')) SERVER sqlite_svr; + +-- GROUP BY optimization by reorder columns +--Testcase 678: +CREATE FOREIGN TABLE btg(id int, p int, v text, c float, d float, e int) SERVER sqlite_svr; + +--Testcase 679: +INSERT INTO btg +SELECT + i, + i/2, + format('%60s', i%2), + i/4, + i/8, + (random() * (10000/8))::int --the same as d but no correlation with p +FROM + generate_series(1, 10000) i; + +-- VACUUM btg; +-- ANALYZE btg; + +-- GROUP BY optimization by reorder columns by frequency + +SET enable_hashagg=off; +SET max_parallel_workers= 0; +SET max_parallel_workers_per_gather = 0; + +--Testcase 680: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, v; + +--Testcase 681: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p; + +--Testcase 682: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, c; + +--Testcase 683: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, c ORDER BY v, p, c; + +--Testcase 684: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, d, c; + +--Testcase 685: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, d, c ORDER BY v, p, d ,c; + +--Testcase 686: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, d, c ORDER BY p, v, d ,c; + +--Testcase 687: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, d, e; + +--Testcase 688: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, e, d; + +--Testcase 689: +CREATE STATISTICS btg_dep ON d, e, p FROM btg; +-- ANALYZE btg; + +--Testcase 690: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, d, e; + +--Testcase 691: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, e, d; + + +-- GROUP BY optimization by reorder columns by index scan + +--Testcase 692: +CREATE INDEX ON btg(p, v); +SET enable_seqscan=off; +SET enable_bitmapscan=off; +-- VACUUM btg; + +--Testcase 693: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, v; + +--Testcase 694: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY p, v ORDER BY p, v; + +--Testcase 695: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p; + +--Testcase 696: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p ORDER BY p, v; + +--Testcase 697: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, c; + +--Testcase 698: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, p, c ORDER BY p, v; + +--Testcase 699: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, c, p, d; + +--Testcase 700: +EXPLAIN (COSTS off) +SELECT count(*) FROM btg GROUP BY v, c, p, d ORDER BY p, v; + +--Testcase 701: +DROP FOREIGN TABLE btg; +RESET enable_hashagg; +RESET max_parallel_workers; +RESET max_parallel_workers_per_gather; +RESET enable_seqscan; +RESET enable_bitmapscan; + -- avoid bit-exact output here because operations may not be bit-exact. +--Testcase 588: SET extra_float_digits = 0; --Testcase 1: SELECT avg(four) AS avg_1 FROM onek; @@ -224,6 +348,20 @@ INSERT INTO agg_t5 values (3.0::numeric, 4.0::numeric); --Testcase 313: SELECT stddev_pop(a), stddev_samp(b) FROM agg_t5; +--Testcase 597: +DELETE FROM agg_t5; +--Testcase 598: +INSERT INTO agg_t5 values ('inf'::numeric, 'inf'::numeric); +--Testcase 599: +SELECT var_pop(a), var_samp(b) FROM agg_t5; + +--Testcase 600: +DELETE FROM agg_t5; +--Testcase 601: +INSERT INTO agg_t5 values ('inf'::numeric, 'inf'::numeric); +--Testcase 602: +SELECT stddev_pop(a), stddev_samp(b) FROM agg_t5; + --Testcase 314: DELETE FROM agg_t5; --Testcase 315: @@ -267,28 +405,70 @@ DELETE FROM agg_t3; --Testcase 332: INSERT INTO agg_t3 VALUES ('1'::float8), ('infinity'::float8); --Testcase 333: -SELECT avg(a), var_pop(a) FROM agg_t3; +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; --Testcase 334: DELETE FROM agg_t3; --Testcase 335: INSERT INTO agg_t3 VALUES ('infinity'::float8), ('1'::float8); --Testcase 336: -SELECT avg(a), var_pop(a) FROM agg_t3; +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; --Testcase 337: DELETE FROM agg_t3; --Testcase 338: INSERT INTO agg_t3 VALUES ('infinity'::float8), ('infinity'::float8); --Testcase 339: -SELECT avg(a), var_pop(a) FROM agg_t3; +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; --Testcase 340: DELETE FROM agg_t3; --Testcase 341: INSERT INTO agg_t3 VALUES ('-infinity'::float8), ('infinity'::float8); --Testcase 342: -SELECT avg(a), var_pop(a) FROM agg_t3; +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + +--Testcase 603: +DELETE FROM agg_t3; +--Testcase 604: +INSERT INTO agg_t3 VALUES ('-infinity'::float8), ('-infinity'::float8); +--Testcase 605: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + +--Testcase 606: +DELETE FROM agg_t3; +--Testcase 607: +INSERT INTO agg_t3 VALUES ('1'::numeric), ('infinity'::numeric); +--Testcase 608: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + +--Testcase 609: +DELETE FROM agg_t3; +--Testcase 610: +INSERT INTO agg_t3 VALUES ('infinity'::numeric), ('1'::numeric); +--Testcase 611: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + +--Testcase 612: +DELETE FROM agg_t3; +--Testcase 613: +INSERT INTO agg_t3 VALUES ('infinity'::numeric), ('infinity'::numeric); +--Testcase 614: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + +--Testcase 615: +DELETE FROM agg_t3; +--Testcase 616: +INSERT INTO agg_t3 VALUES ('-infinity'::numeric), ('infinity'::numeric); +--Testcase 617: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; + +--Testcase 618: +DELETE FROM agg_t3; +--Testcase 619: +INSERT INTO agg_t3 VALUES ('-infinity'::numeric), ('-infinity'::numeric); +--Testcase 620: +SELECT sum(a), avg(a), var_pop(a) FROM agg_t3; -- test accuracy with a large input offset --Testcase 343: @@ -558,7 +738,8 @@ CREATE FOREIGN TABLE bitwise_test( --Testcase 43: SELECT BIT_AND(i2) AS "?", - BIT_OR(i4) AS "?" + BIT_OR(i4) AS "?", + BIT_XOR(i8) AS "?" FROM bitwise_test; --Testcase 44: @@ -579,7 +760,13 @@ SELECT BIT_OR(i4) AS "7", BIT_OR(i8) AS "7", BIT_OR(i) AS "?", - BIT_OR(x) AS "7" + BIT_OR(x) AS "7", + + BIT_XOR(i2) AS "5", + BIT_XOR(i4) AS "5", + BIT_XOR(i8) AS "5", + BIT_XOR(i) AS "?", + BIT_XOR(x) AS "7" FROM bitwise_test; -- @@ -742,6 +929,7 @@ select max(unique1) from tenk1 where unique1 > 42; -- plan, which has almost identical cost, will not be. we want to test -- the optimized plan, so temporarily disable parallel query. begin; +--Testcase 628: set local max_parallel_workers_per_gather = 0; --Testcase 59: explain (costs off) @@ -1245,6 +1433,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; @@ -1386,9 +1590,11 @@ create aggregate my_rank(VARIADIC "any" ORDER BY VARIADIC "any") ( hypothetical ); +--Testcase 633: alter aggregate my_percentile_disc(float8 ORDER BY anyelement) rename to test_percentile_disc; +--Testcase 634: alter aggregate my_rank(VARIADIC "any" ORDER BY VARIADIC "any") rename to test_rank; @@ -1807,7 +2013,7 @@ ROLLBACK; -- Secondly test the case of a parallel aggregate combiner function -- returning NULL. For that use normal transition function, but a -- combiner function returning NULL. -BEGIN ISOLATION LEVEL REPEATABLE READ; +BEGIN; --Testcase 540: CREATE FUNCTION balkifnull(int8, int8) RETURNS int8 @@ -1843,13 +2049,19 @@ CREATE AGGREGATE balk(int4) ROLLBACK; -- test coverage for aggregate combine/serial/deserial functions -BEGIN ISOLATION LEVEL REPEATABLE READ; +BEGIN; +--Testcase 635: SET parallel_setup_cost = 0; +--Testcase 636: SET parallel_tuple_cost = 0; +--Testcase 637: SET min_parallel_table_scan_size = 0; +--Testcase 638: SET max_parallel_workers_per_gather = 4; +--Testcase 639: SET parallel_leader_participation = off; +--Testcase 640: SET enable_indexonlyscan = off; -- variance(int4) covers numeric_poly_combine @@ -1932,16 +2144,22 @@ rollback; -- Make sure that generation of HashAggregate for uniqification purposes -- 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_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_memoize; -- -- Hash Aggregation Spill tests -- +--Testcase 643: set enable_sort=false; +--Testcase 644: set work_mem='64kB'; --Testcase 559: @@ -1950,7 +2168,9 @@ group by unique1 having sum(fivethous) > 4975 order by sum(twothousand); +--Testcase 645: set work_mem to default; +--Testcase 646: set enable_sort to default; -- @@ -1958,6 +2178,7 @@ set enable_sort to default; -- aggregation. Force spilling in both cases by setting work_mem low. -- +--Testcase 647: set work_mem='64kB'; --Testcase 560: @@ -1994,8 +2215,10 @@ insert into agg_data_20k select g from generate_series(0, 19999) g; -- Produce results with sorting. +--Testcase 648: set enable_hashagg = false; +--Testcase 649: set jit_above_cost = 0; --Testcase 572: @@ -2020,6 +2243,7 @@ select * from where g < r.a group by g/2) as s; +--Testcase 650: set jit_above_cost to default; --Testcase 575: @@ -2034,9 +2258,12 @@ select (g/2)::numeric as c1, array_agg(g::numeric) as c2, count(*) as c3 -- Produce results with hash aggregation +--Testcase 651: set enable_hashagg = true; +--Testcase 652: set enable_sort = false; +--Testcase 653: set jit_above_cost = 0; --Testcase 577: @@ -2061,6 +2288,7 @@ select * from where g < r.a group by g/2) as s; +--Testcase 654: set jit_above_cost to default; --Testcase 580: @@ -2073,7 +2301,9 @@ insert into agg_hash_4 select (g/2)::numeric as c1, array_agg(g::numeric) as c2, count(*) as c3 from agg_data_2k group by g/2; +--Testcase 655: set enable_sort = true; +--Testcase 656: set work_mem to default; -- Compare group aggregation results to hash aggregation results diff --git a/sql/13.4/extra/float4.sql b/sql/15beta2/extra/float4.sql similarity index 95% rename from sql/13.4/extra/float4.sql rename to sql/15beta2/extra/float4.sql index 90001b29..efd16a44 100644 --- a/sql/13.4/extra/float4.sql +++ b/sql/15beta2/extra/float4.sql @@ -132,12 +132,24 @@ DELETE FROM FLOAT4_TMP; INSERT INTO FLOAT4_TMP VALUES ('Infinity'::float4 / 'Infinity'::float4); --Testcase 77: SELECT f1 FROM FLOAT4_TMP; +--Testcase 185: +DELETE FROM FLOAT4_TMP; +--Testcase 186: +INSERT INTO FLOAT4_TMP VALUES ('42'::float4 / 'Infinity'::float4); +--Testcase 187: +SELECT f1 FROM FLOAT4_TMP; --Testcase 31: DELETE FROM FLOAT4_TMP; --Testcase 78: INSERT INTO FLOAT4_TMP VALUES ('nan'::float4 / 'nan'::float4); --Testcase 79: SELECT f1 FROM FLOAT4_TMP; +--Testcase 188: +DELETE FROM FLOAT4_TMP; +--Testcase 189: +INSERT INTO FLOAT4_TMP VALUES ('nan'::float4 / '0'::float4); +--Testcase 190: +SELECT f1 FROM FLOAT4_TMP; --Testcase 32: DELETE FROM FLOAT4_TMP; --Testcase 80: @@ -146,7 +158,7 @@ INSERT INTO FLOAT4_TMP VALUES ('nan'::numeric::float4); SELECT f1 FROM FLOAT4_TMP; --Testcase 34: -SELECT '' AS five, * FROM FLOAT4_TBL; +SELECT * FROM FLOAT4_TBL; --SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3'; @@ -157,37 +169,37 @@ SELECT '' AS five, * FROM FLOAT4_TBL; --SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3'; --Testcase 35: -SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1; +SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1; --Testcase 36: -SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3'; +SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3'; --Testcase 37: -SELECT '' AS three, f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f +SELECT f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f WHERE f.f1 > '0.0'; --Testcase 38: -SELECT '' AS three, f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f +SELECT f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f WHERE f.f1 > '0.0'; --Testcase 39: -SELECT '' AS three, f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f +SELECT f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f WHERE f.f1 > '0.0'; --Testcase 40: -SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f +SELECT f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f WHERE f.f1 > '0.0'; -- test divide by zero --Testcase 41: -SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f; +SELECT f.f1 / '0.0' from FLOAT4_TBL f; --Testcase 42: -SELECT '' AS five, * FROM FLOAT4_TBL; +SELECT * FROM FLOAT4_TBL; -- test the unary float4abs operator --Testcase 43: -SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f; +SELECT f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f; --Testcase 44: UPDATE FLOAT4_TBL @@ -195,7 +207,7 @@ UPDATE FLOAT4_TBL WHERE FLOAT4_TBL.f1 > '0.0'; --Testcase 45: -SELECT '' AS five, * FROM FLOAT4_TBL; +SELECT * FROM FLOAT4_TBL; -- test edge-case coercions to integer --Testcase 82: diff --git a/sql/13.4/extra/float8.sql b/sql/15beta2/extra/float8.sql similarity index 78% rename from sql/13.4/extra/float8.sql rename to sql/15beta2/extra/float8.sql index 97edb4aa..ba94009e 100644 --- a/sql/13.4/extra/float8.sql +++ b/sql/15beta2/extra/float8.sql @@ -120,12 +120,24 @@ DELETE FROM FLOAT8_TMP; INSERT INTO FLOAT8_TMP VALUES ('Infinity'::float8 / 'Infinity'::float8); --Testcase 138: SELECT f1 FROM FLOAT8_TMP; +--Testcase 272: +DELETE FROM FLOAT8_TMP; +--Testcase 273: +INSERT INTO FLOAT8_TMP VALUES ('42'::float8 / 'Infinity'::float8); +--Testcase 274: +SELECT f1 FROM FLOAT8_TMP; --Testcase 31: DELETE FROM FLOAT8_TMP; --Testcase 139: INSERT INTO FLOAT8_TMP VALUES ('nan'::float8 / 'nan'::float8); --Testcase 140: SELECT f1 FROM FLOAT8_TMP; +--Testcase 275: +DELETE FROM FLOAT8_TMP; +--Testcase 276: +INSERT INTO FLOAT8_TMP VALUES ('nan'::float8 / '0'::float8); +--Testcase 277: +SELECT f1 FROM FLOAT8_TMP; --Testcase 32: DELETE FROM FLOAT8_TMP; --Testcase 141: @@ -134,63 +146,63 @@ INSERT INTO FLOAT8_TMP VALUES ('nan'::numeric::float8); SELECT f1 FROM FLOAT8_TMP; --Testcase 34: -SELECT '' AS five, * FROM FLOAT8_TBL; +SELECT * FROM FLOAT8_TBL; --Testcase 35: -SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3'; +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3'; --Testcase 36: -SELECT '' AS one, f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3'; +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3'; --Testcase 37: -SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1; +SELECT f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1; --Testcase 38: -SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE f.f1 < '1004.3'; +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 < '1004.3'; --Testcase 39: -SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1; +SELECT f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1; --Testcase 40: -SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3'; +SELECT f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3'; --Testcase 41: -SELECT '' AS three, f.f1, f.f1 * '-10' AS x +SELECT f.f1, f.f1 * '-10' AS x FROM FLOAT8_TBL f WHERE f.f1 > '0.0'; --Testcase 42: -SELECT '' AS three, f.f1, f.f1 + '-10' AS x +SELECT f.f1, f.f1 + '-10' AS x FROM FLOAT8_TBL f WHERE f.f1 > '0.0'; --Testcase 43: -SELECT '' AS three, f.f1, f.f1 / '-10' AS x +SELECT f.f1, f.f1 / '-10' AS x FROM FLOAT8_TBL f WHERE f.f1 > '0.0'; --Testcase 44: -SELECT '' AS three, f.f1, f.f1 - '-10' AS x +SELECT f.f1, f.f1 - '-10' AS x FROM FLOAT8_TBL f WHERE f.f1 > '0.0'; --Testcase 45: -SELECT '' AS one, f.f1 ^ '2.0' AS square_f1 +SELECT f.f1 ^ '2.0' AS square_f1 FROM FLOAT8_TBL f where f.f1 = '1004.3'; -- absolute value --Testcase 46: -SELECT '' AS five, f.f1, @f.f1 AS abs_f1 +SELECT f.f1, @f.f1 AS abs_f1 FROM FLOAT8_TBL f; -- truncate --Testcase 47: -SELECT '' AS five, f.f1, trunc(f.f1) AS trunc_f1 +SELECT f.f1, trunc(f.f1) AS trunc_f1 FROM FLOAT8_TBL f; -- round --Testcase 48: -SELECT '' AS five, f.f1, round(f.f1) AS round_f1 +SELECT f.f1, round(f.f1) AS round_f1 FROM FLOAT8_TBL f; -- ceil / ceiling @@ -208,6 +220,7 @@ select floor(f1) as floor_f1 from float8_tbl f; select sign(f1) as sign_f1 from float8_tbl f; -- avoid bit-exact output here because operations may not be bit-exact. +--Testcase 278: SET extra_float_digits = 0; -- square root @@ -223,7 +236,7 @@ SELECT |/f1 as eight FROM FLOAT8_TBL; ROLLBACK; --Testcase 57: -SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1 +SELECT f.f1, |/f.f1 AS sqrt_f1 FROM FLOAT8_TBL f WHERE f.f1 > '0.0'; @@ -270,13 +283,186 @@ DELETE FROM FLOAT8_TMP; INSERT INTO FLOAT8_TMP VALUES ('NaN'::float8 , '0'::float8); --Testcase 156: SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 279: +DELETE FROM FLOAT8_TMP; +--Testcase 280: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8, '0'::float8); +--Testcase 281: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 282: +DELETE FROM FLOAT8_TMP; +--Testcase 283: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '0'::float8); +--Testcase 284: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 285: +DELETE FROM FLOAT8_TMP; +--Testcase 286: +INSERT INTO FLOAT8_TMP VALUES ('0'::float8, 'infinity'::float8); +--Testcase 287: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 288: +DELETE FROM FLOAT8_TMP; +--Testcase 289: +INSERT INTO FLOAT8_TMP VALUES ('0'::float8, '-infinity'::float8); +--Testcase 290: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 291: +DELETE FROM FLOAT8_TMP; +--Testcase 292: +INSERT INTO FLOAT8_TMP VALUES ('1'::float8, 'infinity'::float8); +--Testcase 293: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 294: +DELETE FROM FLOAT8_TMP; +--Testcase 295: +INSERT INTO FLOAT8_TMP VALUES ('1'::float8, '-infinity'::float8); +--Testcase 296: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 297: +DELETE FROM FLOAT8_TMP; +--Testcase 298: +INSERT INTO FLOAT8_TMP VALUES ('-1'::float8, 'infinity'::float8); +--Testcase 299: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 300: +DELETE FROM FLOAT8_TMP; +--Testcase 301: +INSERT INTO FLOAT8_TMP VALUES ('-1'::float8, '-infinity'::float8); +--Testcase 302: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 303: +DELETE FROM FLOAT8_TMP; +--Testcase 304: +INSERT INTO FLOAT8_TMP VALUES ('0.1'::float8, 'infinity'::float8); +--Testcase 305: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 306: +DELETE FROM FLOAT8_TMP; +--Testcase 307: +INSERT INTO FLOAT8_TMP VALUES ('-0.1'::float8, 'infinity'::float8); +--Testcase 308: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 309: +DELETE FROM FLOAT8_TMP; +--Testcase 310: +INSERT INTO FLOAT8_TMP VALUES ('1.1'::float8, 'infinity'::float8); +--Testcase 311: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 312: +DELETE FROM FLOAT8_TMP; +--Testcase 313: +INSERT INTO FLOAT8_TMP VALUES ('-1.1'::float8, 'infinity'::float8); +--Testcase 314: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 315: +DELETE FROM FLOAT8_TMP; +--Testcase 316: +INSERT INTO FLOAT8_TMP VALUES ('0.1'::float8, '-infinity'::float8); +--Testcase 317: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 318: +DELETE FROM FLOAT8_TMP; +--Testcase 319: +INSERT INTO FLOAT8_TMP VALUES ('-0.1'::float8, '-infinity'::float8); +--Testcase 320: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 321: +DELETE FROM FLOAT8_TMP; +--Testcase 322: +INSERT INTO FLOAT8_TMP VALUES ('1.1'::float8, '-infinity'::float8); +--Testcase 323: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 324: +DELETE FROM FLOAT8_TMP; +--Testcase 325: +INSERT INTO FLOAT8_TMP VALUES ('-1.1'::float8, '-infinity'::float8); +--Testcase 326: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 327: +DELETE FROM FLOAT8_TMP; +--Testcase 328: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8, '-2'::float8); +--Testcase 329: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 330: +DELETE FROM FLOAT8_TMP; +--Testcase 331: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8, '2'::float8); +--Testcase 332: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 333: +DELETE FROM FLOAT8_TMP; +--Testcase 334: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8, 'infinity'::float8); +--Testcase 335: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 336: +DELETE FROM FLOAT8_TMP; +--Testcase 337: +INSERT INTO FLOAT8_TMP VALUES ('infinity'::float8, '-infinity'::float8); +--Testcase 338: +SELECT power(f1, f2) FROM FLOAT8_TMP; + +-- Intel's icc misoptimizes the code that controls the sign of this result, +-- even with -mp1. Pending a fix for that, only test for "is it zero". +--Testcase 339: +DELETE FROM FLOAT8_TMP; +--Testcase 340: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '-2'::float8); +--Testcase 341: +SELECT power(f1, f2) = '0' FROM FLOAT8_TMP; +--Testcase 342: +DELETE FROM FLOAT8_TMP; +--Testcase 343: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '-3'::float8); +--Testcase 344: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 345: +DELETE FROM FLOAT8_TMP; +--Testcase 346: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '2'::float8); +--Testcase 347: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 348: +DELETE FROM FLOAT8_TMP; +--Testcase 349: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '3'::float8); +--Testcase 350: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 351: +DELETE FROM FLOAT8_TMP; +--Testcase 352: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '-3.5'::float8); +--Testcase 353: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 354: +DELETE FROM FLOAT8_TMP; +--Testcase 355: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, 'infinity'::float8); +--Testcase 356: +SELECT power(f1, f2) FROM FLOAT8_TMP; +--Testcase 357: +DELETE FROM FLOAT8_TMP; +--Testcase 358: +INSERT INTO FLOAT8_TMP VALUES ('-infinity'::float8, '-infinity'::float8); +--Testcase 359: +SELECT power(f1, f2) FROM FLOAT8_TMP; -- take exp of ln(f.f1) --Testcase 67: -SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1 +SELECT f.f1, exp(ln(f.f1)) AS exp_ln_f1 FROM FLOAT8_TBL f WHERE f.f1 > '0.0'; +-- check edge cases for exp +--Testcase 360: +DELETE FROM FLOAT8_TMP; +--Testcase 361: +INSERT INTO FLOAT8_TMP VALUES ('inf'::float8), ('-inf'::float8), ('nan'::float8); +--Testcase 362: +SELECT exp(f1) FROM FLOAT8_TMP; + -- cube root BEGIN; --Testcase 68: @@ -288,11 +474,11 @@ SELECT ||/f1 as three FROM FLOAT8_TBL; ROLLBACK; --Testcase 71: -SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f; +SELECT f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f; --Testcase 72: -SELECT '' AS five, * FROM FLOAT8_TBL; +SELECT * FROM FLOAT8_TBL; --Testcase 73: UPDATE FLOAT8_TBL @@ -300,10 +486,10 @@ UPDATE FLOAT8_TBL WHERE FLOAT8_TBL.f1 > '0.0'; --Testcase 74: -SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f; +SELECT f.f1 * '1e200' from FLOAT8_TBL f; --Testcase 75: -SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f; +SELECT f.f1 ^ '1e200' from FLOAT8_TBL f; BEGIN; --Testcase 76: @@ -315,19 +501,19 @@ SELECT * FROM FLOAT8_TBL; ROLLBACK; --Testcase 79: -SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ; +SELECT ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ; --Testcase 80: -SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ; +SELECT ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ; --Testcase 81: -SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f; +SELECT exp(f.f1) from FLOAT8_TBL f; --Testcase 82: -SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f; +SELECT f.f1 / '0.0' from FLOAT8_TBL f; --Testcase 83: -SELECT '' AS five, * FROM FLOAT8_TBL; +SELECT * FROM FLOAT8_TBL; -- hyperbolic functions -- we run these with extra_float_digits = 0 too, since different platforms @@ -480,6 +666,7 @@ INSERT INTO FLOAT8_TMP VALUES ((float8 'nan')); --Testcase 219: SELECT atanh(f1) FROM FLOAT8_TMP; +--Testcase 369: RESET extra_float_digits; -- test for over- and underflow @@ -517,7 +704,7 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200'); INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200'); --Testcase 94: -SELECT '' AS five, * FROM FLOAT8_TBL; +SELECT * FROM FLOAT8_TBL; -- test edge-case coercions to integer --Testcase 220: diff --git a/sql/13.4/extra/insert.sql b/sql/15beta2/extra/insert.sql similarity index 96% rename from sql/13.4/extra/insert.sql rename to sql/15beta2/extra/insert.sql index c9947f02..eeef6e7c 100644 --- a/sql/13.4/extra/insert.sql +++ b/sql/15beta2/extra/insert.sql @@ -56,6 +56,29 @@ insert into inserttest01 values(30, 50, repeat('x', 10000)); --Testcase 15: select col1, col2, char_length(col3) from inserttest01; +-- +-- tuple larger than fillfactor +-- foreign table does not support fillfactor +-- +-- CREATE TABLE large_tuple_test (a int, b text) WITH (fillfactor = 10); +-- ALTER TABLE large_tuple_test ALTER COLUMN b SET STORAGE plain; + +-- -- create page w/ free space in range [nearlyEmptyFreeSpace, MaxHeapTupleSize) +-- INSERT INTO large_tuple_test (select 1, NULL); + +-- -- should still fit on the page +-- INSERT INTO large_tuple_test (select 2, repeat('a', 1000)); +-- SELECT pg_size_pretty(pg_relation_size('large_tuple_test'::regclass, 'main')); + +-- -- add small record to the second page +-- INSERT INTO large_tuple_test (select 3, NULL); + +-- -- now this tuple won't fit on the second page, but the insert should +-- -- still succeed by extending the relation +-- INSERT INTO large_tuple_test (select 4, repeat('a', 8126)); + +-- DROP TABLE large_tuple_test; + -- skip, sqlite fdw does not support customized type /* -- check indirection (field/array assignment), cf bug #14265 @@ -248,33 +271,6 @@ select tableoid::regclass::text, a, min(b) as min_b, max(b) as max_b from list_p -- direct partition inserts should check hash partition bound constraint --- Use hand-rolled hash functions and operator classes to get predictable --- result on different machines. The hash function for int4 simply returns --- the sum of the values passed to it and the one for text returns the length --- of the non-empty string value passed to it or 0. - -create or replace function part_hashint4_noop(value int4, seed int8) -returns int8 as $$ -select value + seed; -$$ language sql immutable; - -create operator class part_test_int4_ops -for type int4 -using hash as -operator 1 =, -function 2 part_hashint4_noop(int4, int8); - -create or replace function part_hashtext_length(value text, seed int8) -RETURNS int8 AS $$ -select length(coalesce(value, ''))::int8 -$$ language sql immutable; - -create operator class part_test_text_ops -for type text -using hash as -operator 1 =, -function 2 part_hashtext_length(text, int8); - create table hash_parted ( a int ) partition by hash (a part_test_int4_ops); @@ -562,9 +558,7 @@ drop table inserttest3; drop table brtrigpartcon; drop function brtrigpartcon1trigf(); --- check that "do nothing" BR triggers work with tuple-routing (this checks --- that estate->es_result_relation_info is appropriately set/reset for each --- routed tuple) +-- check that "do nothing" BR triggers work with tuple-routing create table donothingbrtrig_test (a int, b text) partition by list (a); create table donothingbrtrig_test1 (b text, a int); create table donothingbrtrig_test2 (c text, b text, a int); diff --git a/sql/13.4/extra/int4.sql b/sql/15beta2/extra/int4.sql similarity index 78% rename from sql/13.4/extra/int4.sql rename to sql/15beta2/extra/int4.sql index 4b499700..638dd321 100644 --- a/sql/13.4/extra/int4.sql +++ b/sql/15beta2/extra/int4.sql @@ -48,99 +48,99 @@ INSERT INTO INT4_TBL(f1) VALUES (''); --Testcase 14: -SELECT '' AS five, * FROM INT4_TBL; +SELECT * FROM INT4_TBL; --Testcase 15: -SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0'; --Testcase 16: -SELECT '' AS four, i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0'; --Testcase 17: -SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int2 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 = int2 '0'; --Testcase 18: -SELECT '' AS one, i.* FROM INT4_TBL i WHERE i.f1 = int4 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 = int4 '0'; --Testcase 19: -SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int2 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 < int2 '0'; --Testcase 20: -SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 < int4 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 < int4 '0'; --Testcase 21: -SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 <= int2 '0'; --Testcase 22: -SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 <= int4 '0'; --Testcase 23: -SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int2 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 > int2 '0'; --Testcase 24: -SELECT '' AS two, i.* FROM INT4_TBL i WHERE i.f1 > int4 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 > int4 '0'; --Testcase 25: -SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int2 '0'; --Testcase 26: -SELECT '' AS three, i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0'; +SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0'; -- positive odds --Testcase 27: -SELECT '' AS one, i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1'; +SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1'; -- any evens --Testcase 28: -SELECT '' AS three, i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0'; +SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0'; --Testcase 29: -SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i; --Testcase 30: -SELECT '' AS five, i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i WHERE abs(f1) < 1073741824; --Testcase 31: -SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i; --Testcase 32: -SELECT '' AS five, i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i WHERE abs(f1) < 1073741824; --Testcase 33: -SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i; --Testcase 34: -SELECT '' AS five, i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i WHERE f1 < 2147483646; --Testcase 35: -SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i; --Testcase 36: -SELECT '' AS five, i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i WHERE f1 < 2147483646; --Testcase 37: -SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i; --Testcase 38: -SELECT '' AS five, i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i WHERE f1 > -2147483647; --Testcase 39: -SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i; --Testcase 40: -SELECT '' AS five, i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i +SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i WHERE f1 > -2147483647; --Testcase 41: -SELECT '' AS five, i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i; --Testcase 42: -SELECT '' AS five, i.f1, i.f1 / int4 '2' AS x FROM INT4_TBL i; +SELECT i.f1, i.f1 / int4 '2' AS x FROM INT4_TBL i; -- -- more complex expressions @@ -204,20 +204,6 @@ INSERT INTO INT4_TMP VALUES ('1000'::int4, '999'::int4); --Testcase 86: SELECT f1 < f2 AS false FROM INT4_TMP; ---Testcase 48: -DELETE FROM INT4_TMP; ---Testcase 87: -INSERT INTO INT4_TMP VALUES (4!); ---Testcase 88: -SELECT f1 as twenty_four FROM INT4_TMP; - ---Testcase 49: -DELETE FROM INT4_TMP; ---Testcase 89: -INSERT INTO INT4_TMP VALUES (!!3); ---Testcase 90: -SELECT f1 as six FROM INT4_TMP; - --Testcase 50: DELETE FROM INT4_TMP; --Testcase 91: diff --git a/sql/13.4/extra/int8.sql b/sql/15beta2/extra/int8.sql similarity index 88% rename from sql/13.4/extra/int8.sql rename to sql/15beta2/extra/int8.sql index 6ce11b96..2b2aa83e 100644 --- a/sql/13.4/extra/int8.sql +++ b/sql/15beta2/extra/int8.sql @@ -124,33 +124,33 @@ SELECT * FROM INT8_TBL WHERE '123'::int2 >= q1; --Testcase 44: -SELECT '' AS five, q1 AS plus, -q1 AS minus FROM INT8_TBL; +SELECT q1 AS plus, -q1 AS minus FROM INT8_TBL; --Testcase 45: -SELECT '' AS five, q1, q2, q1 + q2 AS plus FROM INT8_TBL; +SELECT q1, q2, q1 + q2 AS plus FROM INT8_TBL; --Testcase 46: -SELECT '' AS five, q1, q2, q1 - q2 AS minus FROM INT8_TBL; +SELECT q1, q2, q1 - q2 AS minus FROM INT8_TBL; --Testcase 47: -SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL; +SELECT q1, q2, q1 * q2 AS multiply FROM INT8_TBL; --Testcase 48: -SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL +SELECT q1, q2, q1 * q2 AS multiply FROM INT8_TBL WHERE q1 < 1000 or (q2 > 0 and q2 < 1000); --Testcase 49: -SELECT '' AS five, q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM INT8_TBL; +SELECT q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM INT8_TBL; --Testcase 50: -SELECT '' AS five, q1, float8(q1) FROM INT8_TBL; +SELECT q1, float8(q1) FROM INT8_TBL; --Testcase 51: -SELECT '' AS five, q2, float8(q2) FROM INT8_TBL; +SELECT q2, float8(q2) FROM INT8_TBL; --Testcase 52: SELECT 37 + q1 AS plus4 FROM INT8_TBL; --Testcase 53: SELECT 37 - q1 AS minus4 FROM INT8_TBL; --Testcase 54: -SELECT '' AS five, 2 * q1 AS "twice int4" FROM INT8_TBL; +SELECT 2 * q1 AS "twice int4" FROM INT8_TBL; --Testcase 55: -SELECT '' AS five, q1 * 2 AS "twice int4" FROM INT8_TBL; +SELECT q1 * 2 AS "twice int4" FROM INT8_TBL; -- int8 op int4 --Testcase 56: @@ -177,47 +177,47 @@ SELECT max(q1), max(q2) FROM INT8_TBL; -- TO_CHAR() -- --Testcase 63: -SELECT '' AS to_char_1, to_char(q1, '9G999G999G999G999G999'), to_char(q2, '9,999,999,999,999,999') +SELECT to_char(q1, '9G999G999G999G999G999'), to_char(q2, '9,999,999,999,999,999') FROM INT8_TBL; --Testcase 64: -SELECT '' AS to_char_2, to_char(q1, '9G999G999G999G999G999D999G999'), to_char(q2, '9,999,999,999,999,999.999,999') +SELECT to_char(q1, '9G999G999G999G999G999D999G999'), to_char(q2, '9,999,999,999,999,999.999,999') FROM INT8_TBL; --Testcase 65: -SELECT '' AS to_char_3, to_char( (q1 * -1), '9999999999999999PR'), to_char( (q2 * -1), '9999999999999999.999PR') +SELECT to_char( (q1 * -1), '9999999999999999PR'), to_char( (q2 * -1), '9999999999999999.999PR') FROM INT8_TBL; --Testcase 66: -SELECT '' AS to_char_4, to_char( (q1 * -1), '9999999999999999S'), to_char( (q2 * -1), 'S9999999999999999') +SELECT to_char( (q1 * -1), '9999999999999999S'), to_char( (q2 * -1), 'S9999999999999999') FROM INT8_TBL; --Testcase 67: -SELECT '' AS to_char_5, to_char(q2, 'MI9999999999999999') FROM INT8_TBL; +SELECT to_char(q2, 'MI9999999999999999') FROM INT8_TBL; --Testcase 68: -SELECT '' AS to_char_6, to_char(q2, 'FMS9999999999999999') FROM INT8_TBL; +SELECT to_char(q2, 'FMS9999999999999999') FROM INT8_TBL; --Testcase 69: -SELECT '' AS to_char_7, to_char(q2, 'FM9999999999999999THPR') FROM INT8_TBL; +SELECT to_char(q2, 'FM9999999999999999THPR') FROM INT8_TBL; --Testcase 70: -SELECT '' AS to_char_8, to_char(q2, 'SG9999999999999999th') FROM INT8_TBL; +SELECT to_char(q2, 'SG9999999999999999th') FROM INT8_TBL; --Testcase 71: -SELECT '' AS to_char_9, to_char(q2, '0999999999999999') FROM INT8_TBL; +SELECT to_char(q2, '0999999999999999') FROM INT8_TBL; --Testcase 72: -SELECT '' AS to_char_10, to_char(q2, 'S0999999999999999') FROM INT8_TBL; +SELECT to_char(q2, 'S0999999999999999') FROM INT8_TBL; --Testcase 73: -SELECT '' AS to_char_11, to_char(q2, 'FM0999999999999999') FROM INT8_TBL; +SELECT to_char(q2, 'FM0999999999999999') FROM INT8_TBL; --Testcase 74: -SELECT '' AS to_char_12, to_char(q2, 'FM9999999999999999.000') FROM INT8_TBL; +SELECT to_char(q2, 'FM9999999999999999.000') FROM INT8_TBL; --Testcase 75: -SELECT '' AS to_char_13, to_char(q2, 'L9999999999999999.000') FROM INT8_TBL; +SELECT to_char(q2, 'L9999999999999999.000') FROM INT8_TBL; --Testcase 76: -SELECT '' AS to_char_14, to_char(q2, 'FM9999999999999999.999') FROM INT8_TBL; +SELECT to_char(q2, 'FM9999999999999999.999') FROM INT8_TBL; --Testcase 77: -SELECT '' AS to_char_15, to_char(q2, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9') FROM INT8_TBL; +SELECT to_char(q2, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9') FROM INT8_TBL; --Testcase 78: -SELECT '' AS to_char_16, to_char(q2, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM INT8_TBL; +SELECT to_char(q2, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM INT8_TBL; --Testcase 79: -SELECT '' AS to_char_17, to_char(q2, '999999SG9999999999') FROM INT8_TBL; +SELECT to_char(q2, '999999SG9999999999') FROM INT8_TBL; -- check min/max values and overflow behavior --Testcase 80: diff --git a/sql/13.4/extra/join.sql b/sql/15beta2/extra/join.sql similarity index 93% rename from sql/13.4/extra/join.sql rename to sql/15beta2/extra/join.sql index d633d623..e10b19fc 100644 --- a/sql/13.4/extra/join.sql +++ b/sql/15beta2/extra/join.sql @@ -130,27 +130,27 @@ analyze onerow; -- --Testcase 21: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL AS tx; --Testcase 22: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL tx; --Testcase 23: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL AS t1 (a, b, c); --Testcase 24: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c); --Testcase 25: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e); --Testcase 26: -SELECT '' AS "xxx", t1.a, t2.e +SELECT t1.a, t2.e FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e) WHERE t1.a = t2.d; @@ -162,31 +162,31 @@ SELECT '' AS "xxx", t1.a, t2.e -- --Testcase 27: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL CROSS JOIN J2_TBL; -- ambiguous column --Testcase 28: -SELECT '' AS "xxx", i, k, t +SELECT i, k, t FROM J1_TBL CROSS JOIN J2_TBL; -- resolve previous ambiguity by specifying the table name --Testcase 29: -SELECT '' AS "xxx", t1.i, k, t +SELECT t1.i, k, t FROM J1_TBL t1 CROSS JOIN J2_TBL t2; --Testcase 30: -SELECT '' AS "xxx", ii, tt, kk +SELECT ii, tt, kk FROM (J1_TBL CROSS JOIN J2_TBL) AS tx (ii, jj, tt, ii2, kk); --Testcase 31: -SELECT '' AS "xxx", tx.ii, tx.jj, tx.kk +SELECT tx.ii, tx.jj, tx.kk FROM (J1_TBL t1 (a, b, c) CROSS JOIN J2_TBL t2 (d, e)) AS tx (ii, jj, tt, ii2, kk); --Testcase 32: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL CROSS JOIN J2_TBL a CROSS JOIN J2_TBL b; @@ -204,24 +204,55 @@ SELECT '' AS "xxx", * -- Inner equi-join on specified column --Testcase 33: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL INNER JOIN J2_TBL USING (i); -- Same as above, slightly different syntax --Testcase 34: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL JOIN J2_TBL USING (i); --Testcase 35: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, d) USING (a) ORDER BY a, d; --Testcase 36: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, b) USING (b) ORDER BY b, t1.a; +-- test join using aliases +--Testcase 489: +SELECT * + FROM J1_TBL JOIN J2_TBL USING (i) WHERE J1_TBL.t = 'one'; -- ok +--Testcase 490: +SELECT * + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; -- ok +--Testcase 491: +SELECT * + FROM (J1_TBL JOIN J2_TBL USING (i)) AS x WHERE J1_TBL.t = 'one'; -- error +--Testcase 492: +SELECT * + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.i = 1; -- ok +--Testcase 493: +SELECT * + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.t = 'one'; -- error +--Testcase 494: +SELECT * + FROM (J1_TBL JOIN J2_TBL USING (i) AS x) AS xx WHERE x.i = 1; -- error (XXX could use better hint) +--Testcase 495: +SELECT * + FROM J1_TBL a1 JOIN J2_TBL a2 USING (i) AS a1; -- error +--Testcase 496: +SELECT x.* + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; +--Testcase 497: +SELECT ROW(x.*) + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; +--Testcase 498: +SELECT row_to_json(x.*) + FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; -- -- NATURAL JOIN @@ -229,21 +260,21 @@ SELECT '' AS "xxx", * -- --Testcase 37: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL NATURAL JOIN J2_TBL; --Testcase 38: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (a, d); --Testcase 39: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (d, a); -- mismatch number of columns -- currently, Postgres will fill in with underlying names --Testcase 40: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL t1 (a, b) NATURAL JOIN J2_TBL t2 (a); @@ -252,11 +283,11 @@ SELECT '' AS "xxx", * -- --Testcase 41: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.i); --Testcase 42: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.k); @@ -265,7 +296,7 @@ SELECT '' AS "xxx", * -- --Testcase 43: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i <= J2_TBL.k); @@ -275,39 +306,39 @@ SELECT '' AS "xxx", * -- --Testcase 44: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL LEFT OUTER JOIN J2_TBL USING (i) ORDER BY i, k, t; --Testcase 45: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL LEFT JOIN J2_TBL USING (i) ORDER BY i, k, t; --Testcase 46: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL RIGHT OUTER JOIN J2_TBL USING (i); --Testcase 47: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL RIGHT JOIN J2_TBL USING (i); --Testcase 48: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL FULL OUTER JOIN J2_TBL USING (i) ORDER BY i, k, t; --Testcase 49: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL FULL JOIN J2_TBL USING (i) ORDER BY i, k, t; --Testcase 50: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (k = 1); --Testcase 51: -SELECT '' AS "xxx", * +SELECT * FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (i = 1); -- @@ -524,7 +555,9 @@ select count(*) from tenk1 x where -- try that with GEQO too begin; +--Testcase 499: set geqo = on; +--Testcase 500: set geqo_threshold = 2; --Testcase 93: select count(*) from tenk1 x where @@ -708,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; -- @@ -728,7 +762,9 @@ INSERT INTO tt2 VALUES (21, 11); --Testcase 124: INSERT INTO tt2 VALUES (22, 11); +--Testcase 501: set enable_hashjoin to off; +--Testcase 502: set enable_nestloop to off; -- these should give the same results @@ -739,15 +775,21 @@ select tt1.*, tt2.* from tt1 left join tt2 on tt1.joincol = tt2.joincol; --Testcase 126: select tt1.*, tt2.* from tt2 right join tt1 on tt1.joincol = tt2.joincol; +--Testcase 503: reset enable_hashjoin; +--Testcase 504: reset enable_nestloop; -- -- regression test for bug #13908 (hash join with skew tuples & nbatch increase) -- +--Testcase 505: set work_mem to '64kB'; +--Testcase 506: set enable_mergejoin to off; +--Testcase 507: +set enable_memoize to off; --Testcase 127: explain (costs off) @@ -757,8 +799,12 @@ select count(*) from tenk1 a, tenk1 b select count(*) from tenk1 a, tenk1 b where a.hundred = b.thousand and (b.fivethous % 10) < 10; +--Testcase 508: reset work_mem; +--Testcase 509: reset enable_mergejoin; +--Testcase 510: +reset enable_memoize; -- -- regression test for 8.2 bug with improper re-ordering of left joins @@ -889,6 +935,7 @@ select * from left join zv1 on (f3 = f1) where f2 = 53; +--Testcase 537: drop view zv1; -- @@ -921,8 +968,11 @@ execute foo(false); begin; +--Testcase 511: set enable_mergejoin = 1; +--Testcase 512: set enable_hashjoin = 0; +--Testcase 513: set enable_nestloop = 0; --Testcase 403: @@ -1188,6 +1238,35 @@ where 1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1) order by 1,2; +-- +-- variant where a PlaceHolderVar is needed at a join, but not above the join +-- + +--Testcase 514: +explain (costs off) +select * from + int4_tbl as i41, + lateral + (select 1 as x from + (select i41.f1 as lat, + i42.f1 as loc from + int8_tbl as i81, int4_tbl as i42) as ss1 + right join int4_tbl as i43 on (i43.f1 > 1) + where ss1.loc = ss1.lat) as ss2 +where i41.f1 > 0; + +--Testcase 515: +select * from + int4_tbl as i41, + lateral + (select 1 as x from + (select i41.f1 as lat, + i42.f1 as loc from + int8_tbl as i81, int4_tbl as i42) as ss1 + right join int4_tbl as i43 on (i43.f1 > 1) + where ss1.loc = ss1.lat) as ss2 +where i41.f1 > 0; + -- -- test the corner cases FULL JOIN ON TRUE and FULL JOIN ON FALSE -- @@ -1326,6 +1405,30 @@ select * from select * from (select key1 as x from sub_tbl as x) ss1 left join (select key6 as y from sub_tbl) ss2 on (true), lateral (select ss2.y as z limit 1) ss3; + +-- Test proper handling of appendrel PHVs during useless-RTE removal +--Testcase 516: +explain (costs off) +select * from + (select 0 as z) as t1 + left join + (select true as a) as t2 + on true, + lateral (select true as b + union all + select a as b) as t3 +where b; + +--Testcase 517: +select * from + (select 0 as z) as t1 + left join + (select true as a) as t2 + on true, + lateral (select true as b + union all + select a as b) as t3 +where b; -- -- test inlining of immutable functions @@ -1354,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; @@ -1820,7 +1927,9 @@ explain (costs off) -- we force a mergejoin so that coalesce(b.q1, 1) appears as a join input -- +--Testcase 518: set enable_hashjoin to off; +--Testcase 519: set enable_nestloop to off; --Testcase 231: @@ -1833,7 +1942,9 @@ select a.q2, b.q1 from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1) where coalesce(b.q1, 1) > 0; +--Testcase 520: reset enable_hashjoin; +--Testcase 521: reset enable_nestloop; -- @@ -2054,6 +2165,39 @@ where ss.stringu2 !~* ss.case1; rollback; +-- test case to expose miscomputation of required relid set for a PHV +--Testcase 522: +explain (verbose, costs off) +select i8.*, ss.v, t.unique2 + from int8_tbl i8 + left join int4_tbl i4 on i4.f1 = 1 + left join lateral (select i4.f1 + 1 as v) as ss on true + left join tenk1 t on t.unique2 = ss.v +where q2 = 456; + +--Testcase 523: +select i8.*, ss.v, t.unique2 + from int8_tbl i8 + left join int4_tbl i4 on i4.f1 = 1 + left join lateral (select i4.f1 + 1 as v) as ss on true + 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: @@ -2360,6 +2504,10 @@ select * from (select q1.v) ) as q2; +-- check the number of columns specified +--Testcase 539: +SELECT * FROM (int8_tbl i cross join int4_tbl j) ss(a,b,c,d); + -- check we don't try to do a unique-ified semijoin with LATERAL --Testcase 314: explain (verbose, costs off) @@ -2469,6 +2617,40 @@ delete from xx1 using lateral (select * from int4_tbl where f1 = x1) ss; --drop table join_pt1; --drop table join_ut1; +-- +-- test estimation behavior with multi-column foreign key and constant qual +-- + +begin; + +--Testcase 524: +create table fkest (x integer, x10 integer, x10b integer, x100 integer); +--Testcase 525: +insert into fkest select x, x/10, x/10, x/100 from generate_series(1,1000) x; +--Testcase 526: +create unique index on fkest(x, x10, x100); +analyze fkest; + +--Testcase 527: +explain (costs off) +select * from fkest f1 + join fkest f2 on (f1.x = f2.x and f1.x10 = f2.x10b and f1.x100 = f2.x100) + join fkest f3 on f1.x = f3.x + where f1.x100 = 2; + +--Testcase 528: +alter table fkest add constraint fk + foreign key (x, x10b, x100) references fkest (x, x10, x100); + +--Testcase 529: +explain (costs off) +select * from fkest f1 + join fkest f2 on (f1.x = f2.x and f1.x10 = f2.x10b and f1.x100 = f2.x100) + join fkest f3 on f1.x = f3.x + where f1.x100 = 2; + +rollback; + -- -- test that foreign key join estimation performs sanely for outer joins -- @@ -2625,8 +2807,11 @@ left join j22 on j12.id1 = j22.id1 where j12.id2 = 1; -- validate logic in merge joins which skips mark and restore. -- it should only do this if all quals which were used to detect the unique -- are present as join quals, and not plain quals. +--Testcase 530: set enable_nestloop to 0; +--Testcase 531: set enable_hashjoin to 0; +--Testcase 532: set enable_sort to 0; -- skip, cannot create index on foreign table -- create indexes that will be preferred over the PKs to perform the join @@ -2669,8 +2854,11 @@ select * from j12 inner join j22 on j12.id1 = j22.id1 and j12.id2 = j22.id2 where j12.id1 % 1000 = 1 and j22.id1 % 1000 = 1 and j22.id1 >= any (array[1,5]); +--Testcase 533: reset enable_nestloop; +--Testcase 534: reset enable_hashjoin; +--Testcase 535: reset enable_sort; --drop table j1; diff --git a/sql/14.0/extra/limit.sql b/sql/15beta2/extra/limit.sql similarity index 98% rename from sql/14.0/extra/limit.sql rename to sql/15beta2/extra/limit.sql index e698a7b1..0e7c004d 100644 --- a/sql/14.0/extra/limit.sql +++ b/sql/15beta2/extra/limit.sql @@ -388,6 +388,12 @@ SELECT thousand FROM onek WHERE thousand < 5 ORDER BY thousand FETCH FIRST 2 ROW ONLY; +-- SKIP LOCKED and WITH TIES are incompatible +--Testcase 104: +SELECT thousand + FROM onek WHERE thousand < 5 + ORDER BY thousand FETCH FIRST 1 ROW WITH TIES FOR UPDATE SKIP LOCKED; + -- should fail --Testcase 76: SELECT ''::text AS two, unique1, unique2, stringu1 diff --git a/sql/13.4/extra/numeric.sql b/sql/15beta2/extra/numeric.sql similarity index 70% rename from sql/13.4/extra/numeric.sql rename to sql/15beta2/extra/numeric.sql index d57f9878..eabb8bbe 100644 --- a/sql/13.4/extra/numeric.sql +++ b/sql/15beta2/extra/numeric.sql @@ -26,6 +26,9 @@ CREATE FOREIGN TABLE num_exp_log10 (id int4 OPTIONS (key 'true'), expected numer --Testcase 577: CREATE FOREIGN TABLE num_exp_power_10_ln (id int4 OPTIONS (key 'true'), expected numeric(210,10)) SERVER sqlite_svr; +--Testcase 1556: +CREATE FOREIGN TABLE num_variance (a numeric) SERVER sqlite_svr; + --Testcase 578: CREATE FOREIGN TABLE num_result (id1 int4 OPTIONS (key 'true'), id2 int4 OPTIONS (key 'true'), result numeric(210,10)) SERVER sqlite_svr; @@ -1136,12 +1139,406 @@ SELECT t1.id1, t1.result, t2.expected WHERE t1.id1 = t2.id AND t1.result != t2.expected; +-- ****************************** +-- * Check behavior with Inf and NaN inputs. It's easiest to handle these +-- * separately from the num_data framework used above, because some input +-- * combinations will throw errors. +-- ****************************** +--Testcase 1451: +CREATE FOREIGN TABLE v (id int4 OPTIONS (key 'true'), x numeric, val float8) SERVER sqlite_svr; + +BEGIN; +--Testcase 1452: +DELETE FROM v; +--Testcase 1453: +INSERT INTO v(x) VALUES ('0'::float8),('1'),('-1'),('4.2'),('inf'),('-inf'),('nan'); +--Testcase 1454: +SELECT x1, x2, + x1::numeric + x2::numeric AS sum, + x1::numeric - x2::numeric AS diff, + x1::numeric * x2::numeric AS prod +FROM v AS v1(id, x1), v AS v2(id, x2); + +--Testcase 1455: +SELECT x1, x2, + x1::numeric / x2::numeric AS quot, + x1::numeric % x2::numeric AS mod, + div(x1::numeric, x2::numeric) AS div +FROM v AS v1(id, x1), v AS v2(id, x2) WHERE x2 != 0; +ROLLBACK; + +BEGIN; +--Testcase 1286: +DELETE FROM v; +--Testcase 1287: +INSERT INTO v(x) VALUES ('inf':: float8); +--Testcase 1288: +SELECT x::numeric / '0' FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1289: +DELETE FROM v; +--Testcase 1290: +INSERT INTO v(x) VALUES ('-inf':: float8); +--Testcase 1291: +SELECT x::numeric / '0' FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1292: +DELETE FROM v; +--Testcase 1293: +INSERT INTO v(x) VALUES ('nan':: float8); +--Testcase 1294: +SELECT x::numeric / '0' FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1295: +DELETE FROM v; +--Testcase 1296: +INSERT INTO v(x) VALUES ('0':: float8); +--Testcase 1297: +SELECT x::numeric / '0' FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1298: +DELETE FROM v; +--Testcase 1299: +INSERT INTO v(x) VALUES ('inf':: float8); +--Testcase 1300: +SELECT x::numeric % '0' FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1301: +DELETE FROM v; +--Testcase 1302: +INSERT INTO v(x) VALUES ('-inf':: float8); +--Testcase 1303: +SELECT x::numeric % '0' FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1304: +DELETE FROM v; +--Testcase 1305: +INSERT INTO v(x) VALUES ('nan':: float8); +--Testcase 1306: +SELECT x::numeric % '0' FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1307: +DELETE FROM v; +--Testcase 1308: +INSERT INTO v(x) VALUES ('0':: float8); +--Testcase 1309: +SELECT x::numeric % '0' FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1310: +DELETE FROM v; +--Testcase 1311: +INSERT INTO v(x) VALUES ('inf':: float8); +--Testcase 1312: +SELECT div(x::numeric, '0') FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1313: +DELETE FROM v; +--Testcase 1314: +INSERT INTO v(x) VALUES ('-inf':: float8); +--Testcase 1315: +SELECT div(x::numeric, '0') FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1316: +DELETE FROM v; +--Testcase 1317: +INSERT INTO v(x) VALUES ('nan':: float8); +--Testcase 1318: +SELECT div(x::numeric, '0') FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1319: +DELETE FROM v; +--Testcase 1320: +INSERT INTO v(x) VALUES ('0':: float8); +--Testcase 1321: +SELECT div(x::numeric, '0') FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1456: +DELETE FROM v; +--Testcase 1457: +INSERT INTO v(x) VALUES('0'::numeric),('1'),('-1'),('4.2'),('-7.777'),('inf'),('-inf'),('nan'); +--Testcase 1458: +SELECT x, -x as minusx, abs(x::numeric), floor(x::numeric), ceil(x::numeric), sign(x::numeric), numeric_inc(x::numeric) as inc +FROM v; +ROLLBACK; + +BEGIN; +--Testcase 1459: +DELETE FROM v; +--Testcase 1460: +INSERT INTO v(x) VALUES('0'::numeric),('1'),('-1'),('4.2'),('-7.777'),('inf'),('-inf'),('nan'); +--Testcase 1461: +SELECT x, round(x::numeric), round(x::numeric,1) as round1, trunc(x::numeric), trunc(x::numeric,1) as trunc1 +FROM v; +ROLLBACK; + +-- the large values fall into the numeric abbreviation code's maximal classes +BEGIN; +--Testcase 1462: +INSERT INTO v(x) VALUES ('0'::numeric),('1'),('-1'),('4.2'),('-7.777'), + ('inf'),('-inf'),('nan'), + ('inf'),('-inf'),('nan'); +--Testcase 1463: +SELECT substring(x::text, 1, 32) FROM v ORDER BY x; +ROLLBACK; + +--Testcase 1464: +DELETE FROM v; +--Testcase 1465: +INSERT INTO v(x) VALUES('0'::numeric),('1'),('4.2'),('inf'),('nan'); +--Testcase 1466: +SELECT x, sqrt(x) FROM v; + +--Testcase 1333: +DELETE FROM v; +--Testcase 1334: +INSERT INTO v(x) VALUES ('-1'::float8); +--Testcase 1335: +SELECT sqrt(x::numeric) FROM v; +--Testcase 1336: +DELETE FROM v; +--Testcase 1337: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1338: +SELECT sqrt(x::numeric) FROM v; + +--Testcase 1467: +DELETE FROM v; +--Testcase 1468: +INSERT INTO v(x) VALUES ('1'::numeric),('4.2'),('inf'),('nan'); +--Testcase 1469: +SELECT x, + log(x::numeric), + log10(x::numeric), + ln(x::numeric) +FROM v; + +--Testcase 1342: +DELETE FROM v; +--Testcase 1343: +INSERT INTO v(x) VALUES ('0'::float8); +--Testcase 1344: +SELECT ln(x::numeric) FROM v; +--Testcase 1345: +DELETE FROM v; +--Testcase 1346: +INSERT INTO v(x) VALUES ('-1'::float8); +--Testcase 1347: +SELECT ln(x::numeric) FROM v; +--Testcase 1348: +DELETE FROM v; +--Testcase 1349: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1350: +SELECT ln(x::numeric) FROM v; +--Testcase 1470: +DELETE FROM v; +--Testcase 1471: +INSERT INTO v(x) VALUES ('2'::numeric),('4.2'),('inf'),('nan'); +--Testcase 1472: +SELECT x1, x2, + log(x1::numeric, x2::numeric) +FROM v AS v1(id, x1), v AS v2(id, x2); +--Testcase 1354: +DELETE FROM v; +--Testcase 1355: +INSERT INTO v(x) VALUES ('0'::float8); +--Testcase 1356: +SELECT log(x::numeric, '10') FROM v; +--Testcase 1357: +DELETE FROM v; +--Testcase 1358: +INSERT INTO v(x) VALUES ('10'::float8); +--Testcase 1359: +SELECT log(x::numeric, '0') FROM v; +--Testcase 1360: +DELETE FROM v; +--Testcase 1361: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1362: +SELECT log(x::numeric, '10') FROM v; +--Testcase 1363: +DELETE FROM v; +--Testcase 1364: +INSERT INTO v(x) VALUES ('10'::float8); +--Testcase 1365: +SELECT log(x::numeric, '-inf') FROM v; +--Testcase 1366: +DELETE FROM v; +--Testcase 1367: +INSERT INTO v(x) VALUES ('inf'::float8); +--Testcase 1368: +SELECT log(x::numeric, '0') FROM v; +--Testcase 1369: +DELETE FROM v; +--Testcase 1370: +INSERT INTO v(x) VALUES ('inf'::float8); +--Testcase 1371: +SELECT log(x::numeric, '-inf') FROM v; +--Testcase 1372: +DELETE FROM v; +--Testcase 1373: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1374: +SELECT log(x::numeric, 'inf') FROM v; + +--Testcase 1473: +DELETE FROM v; +--Testcase 1474: +INSERT INTO v(x) VALUES ('0'::numeric),('1'),('2'),('4.2'),('inf'),('nan'); +--Testcase 1475: +SELECT x1, x2, + power(x1::numeric, x2::numeric) +FROM v AS v1(id, x1), v AS v2(id, x2) WHERE x1 != 0 OR x2 >= 0; + +--Testcase 1378: +DELETE FROM v; +--Testcase 1379: +INSERT INTO v(x) VALUES ('0'::float8); +--Testcase 1380: +SELECT power(x::numeric, '-1') FROM v; +--Testcase 1381: +DELETE FROM v; +--Testcase 1382: +INSERT INTO v(x) VALUES ('0'::float8); +--Testcase 1383: +SELECT power(x::numeric, '-inf') FROM v; +--Testcase 1384: +DELETE FROM v; +--Testcase 1385: +INSERT INTO v(x) VALUES ('-1'::float8); +--Testcase 1386: +SELECT power(x::numeric, 'inf') FROM v; +--Testcase 1387: +DELETE FROM v; +--Testcase 1388: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1389: +SELECT power(x::numeric, '3') FROM v; +--Testcase 1390: +DELETE FROM v; +--Testcase 1391: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1392: +SELECT power(x::numeric, '3.3') FROM v; +--Testcase 1393: +DELETE FROM v; +--Testcase 1394: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1395: +SELECT power(x::numeric, '-1') FROM v; +--Testcase 1396: +DELETE FROM v; +--Testcase 1397: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1398: +SELECT power(x::numeric, '-1.5') FROM v; +--Testcase 1399: +DELETE FROM v; +--Testcase 1400: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1401: +SELECT power(x::numeric, 'inf') FROM v; +--Testcase 1402: +DELETE FROM v; +--Testcase 1403: +INSERT INTO v(x) VALUES ('-2'::float8); +--Testcase 1404: +SELECT power(x::numeric, '-inf') FROM v; +--Testcase 1405: +DELETE FROM v; +--Testcase 1406: +INSERT INTO v(x) VALUES ('inf'::float8); +--Testcase 1407: +SELECT power(x::numeric, '-2') FROM v; +--Testcase 1408: +DELETE FROM v; +--Testcase 1409: +INSERT INTO v(x) VALUES ('inf'::float8); +--Testcase 1410: +SELECT power(x::numeric, '-inf') FROM v; +--Testcase 1411: +DELETE FROM v; +--Testcase 1412: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1413: +SELECT power(x::numeric, '2') FROM v; +--Testcase 1414: +DELETE FROM v; +--Testcase 1415: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1416: +SELECT power(x::numeric, '3') FROM v; +--Testcase 1417: +DELETE FROM v; +--Testcase 1418: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1419: +SELECT power(x::numeric, '4.5') FROM v; +--Testcase 1420: +DELETE FROM v; +--Testcase 1421: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1422: +SELECT power(x::numeric, '-2') FROM v; +--Testcase 1423: +DELETE FROM v; +--Testcase 1424: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1425: +SELECT power(x::numeric, '-3') FROM v; +--Testcase 1426: +DELETE FROM v; +--Testcase 1427: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1428: +SELECT power(x::numeric, '0') FROM v; +--Testcase 1429: +DELETE FROM v; +--Testcase 1430: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1431: +SELECT power(x::numeric, 'inf') FROM v; +--Testcase 1432: +DELETE FROM v; +--Testcase 1433: +INSERT INTO v(x) VALUES ('-inf'::float8); +--Testcase 1434: +SELECT power(x::numeric, '-inf') FROM v; + -- ****************************** -- * miscellaneous checks for things that have been broken in the past... -- ****************************** -- numeric AVG used to fail on some platforms --Testcase 487: SELECT AVG(val) FROM num_data; +--Testcase 1137: +SELECT MAX(val) FROM num_data; +--Testcase 1138: +SELECT MIN(val) FROM num_data; --Testcase 488: SELECT STDDEV(val) FROM num_data; --Testcase 489: @@ -1166,11 +1563,114 @@ INSERT INTO fract_only VALUES (6, '0.99995'); -- should fail INSERT INTO fract_only VALUES (7, '0.00001'); --Testcase 497: INSERT INTO fract_only VALUES (8, '0.00017'); +--Testcase 1139: +INSERT INTO fract_only VALUES (9, 'NaN'); +--Testcase 1140: +INSERT INTO fract_only VALUES (10, 'Inf'); -- should fail +--Testcase 1141: +INSERT INTO fract_only VALUES (11, '-Inf'); -- should fail --Testcase 498: 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; @@ -1195,6 +1695,28 @@ INSERT INTO FLOAT8_TMP VALUES ('-Infinity'); --Testcase 590: SELECT f1::numeric FROM FLOAT8_TMP; +--Testcase 1142: +CREATE FOREIGN TABLE NUMERIC_TMP(f1 numeric, f2 numeric, id int OPTIONS (key 'true')) SERVER sqlite_svr; +--Testcase 1143: +DELETE FROM NUMERIC_TMP; +--Testcase 1144: +INSERT INTO NUMERIC_TMP VALUES ('NaN'); +--Testcase 1145: +SELECT f1::float8 FROM NUMERIC_TMP; + +--Testcase 1146: +DELETE FROM NUMERIC_TMP; +--Testcase 1147: +INSERT INTO NUMERIC_TMP VALUES ('Infinity'); +--Testcase 1148: +SELECT f1::float8 FROM NUMERIC_TMP; + +--Testcase 1149: +DELETE FROM NUMERIC_TMP; +--Testcase 1150: +INSERT INTO NUMERIC_TMP VALUES ('-Infinity'); +--Testcase 1151: +SELECT f1::float8 FROM NUMERIC_TMP; --Testcase 591: CREATE FOREIGN TABLE FLOAT4_TMP(f1 float4, id int OPTIONS (key 'true')) SERVER sqlite_svr; @@ -1219,6 +1741,97 @@ INSERT INTO FLOAT4_TMP VALUES ('-Infinity'); --Testcase 600: SELECT f1::numeric FROM FLOAT4_TMP; +--Testcase 1152: +DELETE FROM NUMERIC_TMP; +--Testcase 1153: +INSERT INTO NUMERIC_TMP VALUES ('NaN'); +--Testcase 1154: +SELECT f1::float4 FROM NUMERIC_TMP; + +--Testcase 1155: +DELETE FROM NUMERIC_TMP; +--Testcase 1156: +INSERT INTO NUMERIC_TMP VALUES ('Infinity'); +--Testcase 1157: +SELECT f1::float4 FROM NUMERIC_TMP; + +--Testcase 1158: +DELETE FROM NUMERIC_TMP; +--Testcase 1159: +INSERT INTO NUMERIC_TMP VALUES ('-Infinity'); +--Testcase 1160: +SELECT f1::float4 FROM NUMERIC_TMP; + +--Testcase 1161: +DELETE FROM NUMERIC_TMP; +--Testcase 1162: +INSERT INTO NUMERIC_TMP VALUES ('42'::int2); +--Testcase 1163: +SELECT f1::numeric FROM NUMERIC_TMP; + +--Testcase 1164: +DELETE FROM NUMERIC_TMP; +--Testcase 1165: +INSERT INTO NUMERIC_TMP VALUES ('NaN'); +--Testcase 1166: +SELECT f1::int2 FROM NUMERIC_TMP; + +--Testcase 1167: +DELETE FROM NUMERIC_TMP; +--Testcase 1168: +INSERT INTO NUMERIC_TMP VALUES ('Infinity'); +--Testcase 1169: +SELECT f1::int2 FROM NUMERIC_TMP; + +--Testcase 1170: +DELETE FROM NUMERIC_TMP; +--Testcase 1171: +INSERT INTO NUMERIC_TMP VALUES ('-Infinity'); +--Testcase 1172: +SELECT f1::int2 FROM NUMERIC_TMP; + +--Testcase 1173: +DELETE FROM NUMERIC_TMP; +--Testcase 1174: +INSERT INTO NUMERIC_TMP VALUES ('NaN'); +--Testcase 1175: +SELECT f1::int4 FROM NUMERIC_TMP; + +--Testcase 1176: +DELETE FROM NUMERIC_TMP; +--Testcase 1177: +INSERT INTO NUMERIC_TMP VALUES ('Infinity'); +--Testcase 1178: +SELECT f1::int4 FROM NUMERIC_TMP; + +--Testcase 1179: +DELETE FROM NUMERIC_TMP; +--Testcase 1180: +INSERT INTO NUMERIC_TMP VALUES ('-Infinity'); +--Testcase 1181: +SELECT f1::int4 FROM NUMERIC_TMP; + +--Testcase 1182: +DELETE FROM NUMERIC_TMP; +--Testcase 1183: +INSERT INTO NUMERIC_TMP VALUES ('NaN'); +--Testcase 1184: +SELECT f1::int8 FROM NUMERIC_TMP; + +--Testcase 1185: +DELETE FROM NUMERIC_TMP; +--Testcase 1186: +INSERT INTO NUMERIC_TMP VALUES ('Infinity'); +--Testcase 1187: +SELECT f1::int8 FROM NUMERIC_TMP; + +--Testcase 1188: +DELETE FROM NUMERIC_TMP; +--Testcase 1189: +INSERT INTO NUMERIC_TMP VALUES ('-Infinity'); +--Testcase 1190: +SELECT f1::int8 FROM NUMERIC_TMP; + -- Simple check that ceil(), floor(), and round() work correctly --Testcase 601: CREATE FOREIGN TABLE ceil_floor_round (a numeric OPTIONS (key 'true')) SERVER sqlite_svr; @@ -1324,6 +1937,19 @@ INSERT INTO width_bucket_tbl VALUES (0, 'NaN'::numeric, 4.0, 888); --Testcase 630: SELECT width_bucket(id1::float8, id2, id3::float8, id4) FROM width_bucket_tbl; +--Testcase 1191: +DELETE FROM width_bucket_tbl; +--Testcase 1192: +INSERT INTO width_bucket_tbl VALUES (2.0, 3.0, '-inf'::numeric, 888); +--Testcase 1193: +SELECT width_bucket(id1, id2, id3, id4) FROM width_bucket_tbl; + +--Testcase 1194: +DELETE FROM width_bucket_tbl; +--Testcase 1195: +INSERT INTO width_bucket_tbl VALUES (0, '-inf'::numeric, 4.0 , 888); +--Testcase 1196: +SELECT width_bucket(id1::float8, id2, id3::float8, id4) FROM width_bucket_tbl; -- normal operation --Testcase 631: @@ -1373,8 +1999,26 @@ SELECT width_bucket(operand_f8, -25, 25, 10) AS wb_5f FROM width_bucket_test; --- for float8 only, check positive and negative infinity: we require +-- Check positive and negative infinity: we require -- finite bucket bounds, but allow an infinite operand +--Testcase 1197: +DELETE FROM width_bucket_tbl; +--Testcase 1198: +INSERT INTO width_bucket_tbl VALUES (0.0, 'Infinity'::numeric , 5, 10); +--Testcase 1199: +SELECT width_bucket(id1::numeric, 'Infinity'::numeric, id3, id4) FROM width_bucket_tbl; -- error +--Testcase 1200: +DELETE FROM width_bucket_tbl; +--Testcase 1201: +INSERT INTO width_bucket_tbl VALUES (0.0, 5, '-Infinity'::numeric, 20); +--Testcase 1202: +SELECT width_bucket(id1::numeric, id2, '-Infinity'::numeric, id4) FROM width_bucket_tbl; -- error +--Testcase 1203: +DELETE FROM width_bucket_tbl; +--Testcase 1204: +INSERT INTO width_bucket_tbl VALUES ('Infinity'::numeric, 1, 10, 10), ('-Infinity'::numeric, 1, 10, 10); +--Testcase 1205: +SELECT width_bucket(id1::numeric, id2, id3, id4) FROM width_bucket_tbl; --Testcase 510: DELETE FROM width_bucket_tbl; -- postgres does not support insert 'Infinity' and '-Infinity' as numeric. @@ -1396,257 +2040,320 @@ INSERT INTO width_bucket_tbl VALUES (0.0, 1, 10, 10); --Testcase 637: SELECT width_bucket('Infinity'::float8, id2, id3, id4), width_bucket('-Infinity'::float8, id2, id3, id4) FROM width_bucket_tbl; +-- Simple test for roundoff error when results should be exact +--Testcase 1445: +DELETE FROM width_bucket_tbl; +--Testcase 1446: +INSERT INTO width_bucket_tbl SELECT x, 10, 100, 9 FROM generate_series(0, 110, 10) x; +--Testcase 1447: +SELECT id1, width_bucket(id1::float8, id2, id3, id4) as flt, + width_bucket(id1::numeric, id2, id3, id4) as num FROM width_bucket_tbl; + +--Testcase 1448: +DELETE FROM width_bucket_tbl; +--Testcase 1449: +INSERT INTO width_bucket_tbl SELECT x, 100, 10, 9 FROM generate_series(0, 110, 10) x; +--Testcase 1450: +SELECT id1, width_bucket(id1::float8, 100, 10, 9) as flt, + width_bucket(id1::numeric, id2, id3, id4) as num FROM width_bucket_tbl; + --Testcase 638: DROP FOREIGN TABLE width_bucket_test; + -- TO_CHAR() -- --Testcase 513: -SELECT '' AS to_char_1, to_char(val, '9G999G999G999G999G999') +SELECT to_char(val, '9G999G999G999G999G999') FROM num_data; --Testcase 514: -SELECT '' AS to_char_2, to_char(val, '9G999G999G999G999G999D999G999G999G999G999') +SELECT to_char(val, '9G999G999G999G999G999D999G999G999G999G999') FROM num_data; --Testcase 515: -SELECT '' AS to_char_3, to_char(val, '9999999999999999.999999999999999PR') +SELECT to_char(val, '9999999999999999.999999999999999PR') FROM num_data; --Testcase 516: -SELECT '' AS to_char_4, to_char(val, '9999999999999999.999999999999999S') +SELECT to_char(val, '9999999999999999.999999999999999S') FROM num_data; --Testcase 517: -SELECT '' AS to_char_5, to_char(val, 'MI9999999999999999.999999999999999') FROM num_data; +SELECT to_char(val, 'MI9999999999999999.999999999999999') FROM num_data; --Testcase 518: -SELECT '' AS to_char_6, to_char(val, 'FMS9999999999999999.999999999999999') FROM num_data; +SELECT to_char(val, 'FMS9999999999999999.999999999999999') FROM num_data; --Testcase 519: -SELECT '' AS to_char_7, to_char(val, 'FM9999999999999999.999999999999999THPR') FROM num_data; +SELECT to_char(val, 'FM9999999999999999.999999999999999THPR') FROM num_data; --Testcase 520: -SELECT '' AS to_char_8, to_char(val, 'SG9999999999999999.999999999999999th') FROM num_data; +SELECT to_char(val, 'SG9999999999999999.999999999999999th') FROM num_data; --Testcase 521: -SELECT '' AS to_char_9, to_char(val, '0999999999999999.999999999999999') FROM num_data; +SELECT to_char(val, '0999999999999999.999999999999999') FROM num_data; --Testcase 522: -SELECT '' AS to_char_10, to_char(val, 'S0999999999999999.999999999999999') FROM num_data; +SELECT to_char(val, 'S0999999999999999.999999999999999') FROM num_data; --Testcase 523: -SELECT '' AS to_char_11, to_char(val, 'FM0999999999999999.999999999999999') FROM num_data; +SELECT to_char(val, 'FM0999999999999999.999999999999999') FROM num_data; --Testcase 524: -SELECT '' AS to_char_12, to_char(val, 'FM9999999999999999.099999999999999') FROM num_data; +SELECT to_char(val, 'FM9999999999999999.099999999999999') FROM num_data; --Testcase 525: -SELECT '' AS to_char_13, to_char(val, 'FM9999999999990999.990999999999999') FROM num_data; +SELECT to_char(val, 'FM9999999999990999.990999999999999') FROM num_data; --Testcase 526: -SELECT '' AS to_char_14, to_char(val, 'FM0999999999999999.999909999999999') FROM num_data; +SELECT to_char(val, 'FM0999999999999999.999909999999999') FROM num_data; --Testcase 527: -SELECT '' AS to_char_15, to_char(val, 'FM9999999990999999.099999999999999') FROM num_data; +SELECT to_char(val, 'FM9999999990999999.099999999999999') FROM num_data; --Testcase 528: -SELECT '' AS to_char_16, to_char(val, 'L9999999999999999.099999999999999') FROM num_data; +SELECT to_char(val, 'L9999999999999999.099999999999999') FROM num_data; --Testcase 529: -SELECT '' AS to_char_17, to_char(val, 'FM9999999999999999.99999999999999') FROM num_data; +SELECT to_char(val, 'FM9999999999999999.99999999999999') FROM num_data; --Testcase 530: -SELECT '' AS to_char_18, to_char(val, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data; +SELECT to_char(val, 'S 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data; --Testcase 531: -SELECT '' AS to_char_19, to_char(val, 'FMS 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data; +SELECT to_char(val, 'FMS 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 . 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9') FROM num_data; --Testcase 532: -SELECT '' AS to_char_20, to_char(val, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM num_data; +SELECT to_char(val, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM num_data; --Testcase 533: -SELECT '' AS to_char_21, to_char(val, '999999SG9999999999') FROM num_data; +SELECT to_char(val, '999999SG9999999999') FROM num_data; --Testcase 534: -SELECT '' AS to_char_22, to_char(val, 'FM9999999999999999.999999999999999') FROM num_data; +SELECT to_char(val, 'FM9999999999999999.999999999999999') FROM num_data; --Testcase 535: -SELECT '' AS to_char_23, to_char(val, '9.999EEEE') FROM num_data; +SELECT to_char(val, '9.999EEEE') FROM num_data; + +--Testcase 1476: +DELETE FROM v; +--Testcase 1477: +INSERT INTO v(x) VALUES ('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan'); +--Testcase 1478: +SELECT x, + to_char(x, '9.999EEEE') as numeric, + to_char(x::float8, '9.999EEEE') as float8, + 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: +INSERT INTO v(x) VALUES ('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan'); +--Testcase 1481: +SELECT x, + to_char(x, 'MI9999999999.99') as numeric, + to_char(x::float8, 'MI9999999999.99') as float8, + to_char(x::float4, 'MI9999999999.99') as float4 +FROM v; + +--Testcase 1482: +DELETE FROM v; +--Testcase 1483: +INSERT INTO v(x) VALUES ('0'::numeric),('-4.2'),('4.2e9'),('1.2e-5'),('inf'),('-inf'),('nan'); +--Testcase 1484: +SELECT x, + to_char(x, 'MI99.99') as numeric, + to_char(x::float8, 'MI99.99') as float8, + to_char(x::float4, 'MI99.99') as float4 +FROM v; --Testcase 536: DELETE FROM ceil_floor_round; --Testcase 537: INSERT INTO ceil_floor_round VALUES ('100'::numeric); --Testcase 538: -SELECT '' AS to_char_24, to_char(a, 'FM999.9') FROM ceil_floor_round; +SELECT to_char(a, 'FM999.9') FROM ceil_floor_round; --Testcase 539: -SELECT '' AS to_char_25, to_char(a, 'FM999.') FROM ceil_floor_round; +SELECT to_char(a, 'FM999.') FROM ceil_floor_round; --Testcase 540: -SELECT '' AS to_char_26, to_char(a, 'FM999') FROM ceil_floor_round; +SELECT to_char(a, 'FM999') FROM ceil_floor_round; -- Check parsing of literal text in a format string --Testcase 541: -SELECT '' AS to_char_27, to_char(a, 'foo999') FROM ceil_floor_round; +SELECT to_char(a, 'foo999') FROM ceil_floor_round; --Testcase 542: -SELECT '' AS to_char_28, to_char(a, 'f\oo999') FROM ceil_floor_round; +SELECT to_char(a, 'f\oo999') FROM ceil_floor_round; --Testcase 543: -SELECT '' AS to_char_29, to_char(a, 'f\\oo999') FROM ceil_floor_round; +SELECT to_char(a, 'f\\oo999') FROM ceil_floor_round; --Testcase 544: -SELECT '' AS to_char_30, to_char(a, 'f\"oo999') FROM ceil_floor_round; +SELECT to_char(a, 'f\"oo999') FROM ceil_floor_round; --Testcase 545: -SELECT '' AS to_char_31, to_char(a, 'f\\"oo999') FROM ceil_floor_round; +SELECT to_char(a, 'f\\"oo999') FROM ceil_floor_round; --Testcase 546: -SELECT '' AS to_char_32, to_char(a, 'f"ool"999') FROM ceil_floor_round; +SELECT to_char(a, 'f"ool"999') FROM ceil_floor_round; --Testcase 547: -SELECT '' AS to_char_33, to_char(a, 'f"\ool"999') FROM ceil_floor_round; +SELECT to_char(a, 'f"\ool"999') FROM ceil_floor_round; --Testcase 548: -SELECT '' AS to_char_34, to_char(a, 'f"\\ool"999') FROM ceil_floor_round; +SELECT to_char(a, 'f"\\ool"999') FROM ceil_floor_round; --Testcase 549: -SELECT '' AS to_char_35, to_char(a, 'f"ool\"999') FROM ceil_floor_round; +SELECT to_char(a, 'f"ool\"999') FROM ceil_floor_round; --Testcase 550: -SELECT '' AS to_char_36, to_char(a, 'f"ool\\"999') FROM ceil_floor_round; +SELECT to_char(a, 'f"ool\\"999') FROM ceil_floor_round; -- TO_NUMBER() -- --Testcase 639: create foreign table to_number_tbl (a text, id int options (key 'true')) server sqlite_svr; +--Testcase 1211: SET lc_numeric = 'C'; --Testcase 640: DELETE FROM to_number_tbl; --Testcase 641: INSERT INTO to_number_tbl VALUES ('-34,338,492'); --Testcase 642: -SELECT '' AS to_number_1, to_number(a, '99G999G999') FROM to_number_tbl; +SELECT to_number(a, '99G999G999') FROM to_number_tbl; --Testcase 643: DELETE FROM to_number_tbl; --Testcase 644: INSERT INTO to_number_tbl VALUES ('-34,338,492.654,878'); --Testcase 645: -SELECT '' AS to_number_2, to_number(a, '99G999G999D999G999') FROM to_number_tbl; +SELECT to_number(a, '99G999G999D999G999') FROM to_number_tbl; --Testcase 646: DELETE FROM to_number_tbl; --Testcase 647: INSERT INTO to_number_tbl VALUES ('<564646.654564>'); --Testcase 648: -SELECT '' AS to_number_3, to_number(a, '999999.999999PR') FROM to_number_tbl; +SELECT to_number(a, '999999.999999PR') FROM to_number_tbl; --Testcase 649: DELETE FROM to_number_tbl; --Testcase 650: INSERT INTO to_number_tbl VALUES ('0.00001-'); --Testcase 651: -SELECT '' AS to_number_4, to_number(a, '9.999999S') FROM to_number_tbl; +SELECT to_number(a, '9.999999S') FROM to_number_tbl; --Testcase 652: DELETE FROM to_number_tbl; --Testcase 653: INSERT INTO to_number_tbl VALUES ('5.01-'); --Testcase 654: -SELECT '' AS to_number_5, to_number(a, 'FM9.999999S') FROM to_number_tbl; +SELECT to_number(a, 'FM9.999999S') FROM to_number_tbl; --Testcase 655: DELETE FROM to_number_tbl; --Testcase 656: INSERT INTO to_number_tbl VALUES ('5.01-'); --Testcase 657: -SELECT '' AS to_number_5, to_number(a, 'FM9.999999MI') FROM to_number_tbl; +SELECT to_number(a, 'FM9.999999MI') FROM to_number_tbl; --Testcase 658: DELETE FROM to_number_tbl; --Testcase 659: INSERT INTO to_number_tbl VALUES ('5 4 4 4 4 8 . 7 8'); --Testcase 660: -SELECT '' AS to_number_7, to_number(a, '9 9 9 9 9 9 . 9 9') FROM to_number_tbl; +SELECT to_number(a, '9 9 9 9 9 9 . 9 9') FROM to_number_tbl; --Testcase 661: DELETE FROM to_number_tbl; --Testcase 662: INSERT INTO to_number_tbl VALUES ('.01'); --Testcase 663: -SELECT '' AS to_number_8, to_number(a, 'FM9.99') FROM to_number_tbl; +SELECT to_number(a, 'FM9.99') FROM to_number_tbl; --Testcase 664: DELETE FROM to_number_tbl; --Testcase 665: INSERT INTO to_number_tbl VALUES ('.0'); --Testcase 666: -SELECT '' AS to_number_9, to_number(a, '99999999.99999999') FROM to_number_tbl; +SELECT to_number(a, '99999999.99999999') FROM to_number_tbl; --Testcase 667: DELETE FROM to_number_tbl; --Testcase 668: INSERT INTO to_number_tbl VALUES ('0'); --Testcase 669: -SELECT '' AS to_number_10, to_number(a, '99.99') FROM to_number_tbl; +SELECT to_number(a, '99.99') FROM to_number_tbl; --Testcase 670: DELETE FROM to_number_tbl; --Testcase 671: INSERT INTO to_number_tbl VALUES ('.-01'); --Testcase 672: -SELECT '' AS to_number_11, to_number(a, 'S99.99') FROM to_number_tbl; +SELECT to_number(a, 'S99.99') FROM to_number_tbl; --Testcase 673: DELETE FROM to_number_tbl; --Testcase 674: INSERT INTO to_number_tbl VALUES ('.01-'); --Testcase 675: -SELECT '' AS to_number_12, to_number(a, '99.99S') FROM to_number_tbl; +SELECT to_number(a, '99.99S') FROM to_number_tbl; --Testcase 676: DELETE FROM to_number_tbl; --Testcase 677: INSERT INTO to_number_tbl VALUES (' . 0 1-'); --Testcase 678: -SELECT '' AS to_number_13, to_number(a, ' 9 9 . 9 9 S') FROM to_number_tbl; +SELECT to_number(a, ' 9 9 . 9 9 S') FROM to_number_tbl; --Testcase 679: DELETE FROM to_number_tbl; --Testcase 680: INSERT INTO to_number_tbl VALUES ('34,50'); --Testcase 681: -SELECT '' AS to_number_14, to_number(a,'999,99') FROM to_number_tbl; +SELECT to_number(a,'999,99') FROM to_number_tbl; --Testcase 682: DELETE FROM to_number_tbl; --Testcase 683: INSERT INTO to_number_tbl VALUES ('123,000'); --Testcase 684: -SELECT '' AS to_number_15, to_number(a,'999G') FROM to_number_tbl; +SELECT to_number(a,'999G') FROM to_number_tbl; --Testcase 685: DELETE FROM to_number_tbl; --Testcase 686: INSERT INTO to_number_tbl VALUES ('123456'); --Testcase 687: -SELECT '' AS to_number_16, to_number(a,'999G999') FROM to_number_tbl; +SELECT to_number(a,'999G999') FROM to_number_tbl; --Testcase 688: DELETE FROM to_number_tbl; --Testcase 689: INSERT INTO to_number_tbl VALUES ('$1234.56'); --Testcase 690: -SELECT '' AS to_number_17, to_number(a,'L9,999.99') FROM to_number_tbl; +SELECT to_number(a,'L9,999.99') FROM to_number_tbl; --Testcase 691: DELETE FROM to_number_tbl; --Testcase 692: INSERT INTO to_number_tbl VALUES ('$1234.56'); --Testcase 693: -SELECT '' AS to_number_18, to_number(a,'L99,999.99') FROM to_number_tbl; +SELECT to_number(a,'L99,999.99') FROM to_number_tbl; --Testcase 694: DELETE FROM to_number_tbl; --Testcase 695: INSERT INTO to_number_tbl VALUES ('$1,234.56'); --Testcase 696: -SELECT '' AS to_number_19, to_number(a,'L99,999.99') FROM to_number_tbl; +SELECT to_number(a,'L99,999.99') FROM to_number_tbl; --Testcase 697: DELETE FROM to_number_tbl; --Testcase 698: INSERT INTO to_number_tbl VALUES ('1234.56'); --Testcase 699: -SELECT '' AS to_number_20, to_number(a,'L99,999.99') FROM to_number_tbl; +SELECT to_number(a,'L99,999.99') FROM to_number_tbl; --Testcase 700: DELETE FROM to_number_tbl; --Testcase 701: INSERT INTO to_number_tbl VALUES ('1,234.56'); --Testcase 702: -SELECT '' AS to_number_21, to_number(a,'L99,999.99') FROM to_number_tbl; +SELECT to_number(a,'L99,999.99') FROM to_number_tbl; --Testcase 703: DELETE FROM to_number_tbl; --Testcase 704: INSERT INTO to_number_tbl VALUES ('42nd'); --Testcase 705: -SELECT '' AS to_number_22, to_number(a, '99th') FROM to_number_tbl; +SELECT to_number(a, '99th') FROM to_number_tbl; +--Testcase 1212: RESET lc_numeric; -- -- Input syntax @@ -1670,6 +2377,18 @@ INSERT INTO num_input_test(n1) VALUES ('-555.50'); INSERT INTO num_input_test(n1) VALUES ('NaN '); --Testcase 557: INSERT INTO num_input_test(n1) VALUES (' nan'); +--Testcase 1213: +INSERT INTO num_input_test(n1) VALUES (' inf '); +--Testcase 1214: +INSERT INTO num_input_test(n1) VALUES (' +inf '); +--Testcase 1215: +INSERT INTO num_input_test(n1) VALUES (' -inf '); +--Testcase 1216: +INSERT INTO num_input_test(n1) VALUES (' Infinity '); +--Testcase 1217: +INSERT INTO num_input_test(n1) VALUES (' +inFinity '); +--Testcase 1218: +INSERT INTO num_input_test(n1) VALUES (' -INFINITY '); -- bad inputs --Testcase 558: @@ -1688,10 +2407,64 @@ INSERT INTO num_input_test(n1) VALUES ('5. 0 '); INSERT INTO num_input_test(n1) VALUES (''); --Testcase 565: INSERT INTO num_input_test(n1) VALUES (' N aN '); +--Testcase 1219: +INSERT INTO num_input_test(n1) VALUES ('+ infinity'); --Testcase 566: SELECT * FROM num_input_test; +-- +-- Test precision and scale typemods +-- + +--Testcase 1557: +CREATE FOREIGN TABLE num_typemod_test ( + millions numeric(3, -6), + thousands numeric(3, -3), + units numeric(3, 0), + thousandths numeric(3, 3), + millionths numeric(3, 6) +) SERVER sqlite_svr; +--Testcase 1558: +\d num_typemod_test + +-- rounding of valid inputs +--Testcase 1559: +INSERT INTO num_typemod_test VALUES (123456, 123, 0.123, 0.000123, 0.000000123); +--Testcase 1560: +INSERT INTO num_typemod_test VALUES (654321, 654, 0.654, 0.000654, 0.000000654); +--Testcase 1561: +INSERT INTO num_typemod_test VALUES (2345678, 2345, 2.345, 0.002345, 0.000002345); +--Testcase 1562: +INSERT INTO num_typemod_test VALUES (7654321, 7654, 7.654, 0.007654, 0.000007654); +--Testcase 1563: +INSERT INTO num_typemod_test VALUES (12345678, 12345, 12.345, 0.012345, 0.000012345); +--Testcase 1564: +INSERT INTO num_typemod_test VALUES (87654321, 87654, 87.654, 0.087654, 0.000087654); +--Testcase 1565: +INSERT INTO num_typemod_test VALUES (123456789, 123456, 123.456, 0.123456, 0.000123456); +--Testcase 1566: +INSERT INTO num_typemod_test VALUES (987654321, 987654, 987.654, 0.987654, 0.000987654); +--Testcase 1567: +INSERT INTO num_typemod_test VALUES ('NaN', 'NaN', 'NaN', 'NaN', 'NaN'); + +--Testcase 1568: +SELECT scale(millions), * FROM num_typemod_test ORDER BY millions; + +-- invalid inputs +--Testcase 1569: +INSERT INTO num_typemod_test (millions) VALUES ('inf'); +--Testcase 1570: +INSERT INTO num_typemod_test (millions) VALUES (999500000); +--Testcase 1571: +INSERT INTO num_typemod_test (thousands) VALUES (999500); +--Testcase 1572: +INSERT INTO num_typemod_test (units) VALUES (999.5); +--Testcase 1573: +INSERT INTO num_typemod_test (thousandths) VALUES (0.9995); +--Testcase 1574: +INSERT INTO num_typemod_test (millionths) VALUES (0.0009995); + -- -- Test some corner cases for multiplication -- @@ -1723,6 +2496,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 -- @@ -1869,28 +2649,49 @@ 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; + +--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; + +--Testcase 1575: +DELETE FROM num_tmp; +--Testcase 1576: +INSERT INTO num_tmp VALUES ((1 - 1.500012345678e-1000), 1.45e1003); +--Testcase 1577: +SELECT round(((1 - 1.500012345678e-1000) ^ 1.45e1003) * 1e1000) FROM num_tmp; -- cases that used to error out --Testcase 788: @@ -1898,14 +2699,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 @@ -2054,6 +2898,41 @@ INSERT INTO num_tmp VALUES (1.0::numeric(71,70)); --Testcase 850: select exp(n1) from num_tmp; +--Testcase 1223: +DELETE FROM num_tmp; +--Testcase 1224: +INSERT INTO num_tmp VALUES ('nan'::numeric); +--Testcase 1225: +select exp(n1) from num_tmp; + +--Testcase 1226: +DELETE FROM num_tmp; +--Testcase 1227: +INSERT INTO num_tmp VALUES ('inf'::numeric); +--Testcase 1228: +select exp(n1) from num_tmp; + +--Testcase 1229: +DELETE FROM num_tmp; +--Testcase 1230: +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; @@ -2143,6 +3022,28 @@ DELETE FROM num_tmp; INSERT INTO num_tmp select * from generate_series(0::numeric, 'nan'::numeric, 10::numeric); --Testcase 886: SELECT n2 FROM num_tmp; + +--Testcase 1232: +DELETE FROM num_tmp; +--Testcase 1233: +INSERT INTO num_tmp select * from generate_series('inf'::numeric, 'inf'::numeric, 10::numeric); +--Testcase 1234: +SELECT n2 FROM num_tmp; + +--Testcase 1235: +DELETE FROM num_tmp; +--Testcase 1236: +INSERT INTO num_tmp select * from generate_series(0::numeric, 'inf'::numeric, 10::numeric); +--Testcase 1237: +SELECT n2 FROM num_tmp; + +--Testcase 1238: +DELETE FROM num_tmp; +--Testcase 1239: +INSERT INTO num_tmp select * from generate_series(0::numeric, '42'::numeric, '-inf'::numeric); +--Testcase 1240: +SELECT n2 FROM num_tmp; + -- Checks maximum, output is truncated --Testcase 887: DELETE FROM num_tmp; @@ -2400,6 +3301,13 @@ INSERT INTO num_tmp VALUES (numeric 'NaN'); --Testcase 985: select scale(n1) from num_tmp; +--Testcase 1241: +DELETE FROM num_tmp; +--Testcase 1242: +INSERT INTO num_tmp VALUES (numeric 'inf'); +--Testcase 1243: +select scale(n1) from num_tmp; + --Testcase 986: DELETE FROM num_tmp; --Testcase 987: @@ -2466,6 +3374,13 @@ INSERT INTO num_tmp VALUES (numeric 'NaN'); --Testcase 1012: select min_scale(n1) is NULL from num_tmp; -- should be true +--Testcase 1244: +DELETE FROM num_tmp; +--Testcase 1245: +INSERT INTO num_tmp VALUES (numeric 'inf'); +--Testcase 1246: +select min_scale(n1) is NULL from num_tmp; -- should be true + --Testcase 1013: DELETE FROM num_tmp; --Testcase 1014: @@ -2546,6 +3461,13 @@ INSERT INTO num_tmp VALUES (numeric 'NaN'); --Testcase 1045: select trim_scale(n1) from num_tmp; +--Testcase 1247: +DELETE FROM num_tmp; +--Testcase 1248: +INSERT INTO num_tmp VALUES (numeric 'inf'); +--Testcase 1249: +select trim_scale(n1) from num_tmp; + --Testcase 1046: DELETE FROM num_tmp; --Testcase 1047: @@ -2616,6 +3538,49 @@ SELECT SUM(9999::numeric) FROM num_tmp; --Testcase 1073: SELECT SUM((-9999)::numeric) FROM num_tmp; +-- +-- Tests for VARIANCE() +-- +--Testcase 1578: +INSERT INTO num_variance VALUES (0); +--Testcase 1579: +INSERT INTO num_variance VALUES (3e-500); +--Testcase 1580: +INSERT INTO num_variance VALUES (-3e-500); +--Testcase 1581: +INSERT INTO num_variance VALUES (4e-500 - 1e-16383); +--Testcase 1582: +INSERT INTO num_variance VALUES (-4e-500 + 1e-16383); +-- variance is just under 12.5e-1000 and so should round down to 12e-1000 +--Testcase 1583: +SELECT trim_scale(variance(a) * 1e1000) FROM num_variance; + +-- check that parallel execution produces the same result +BEGIN; +-- ALTER TABLE num_variance SET (parallel_workers = 4); +SET LOCAL parallel_setup_cost = 0; +SET LOCAL max_parallel_workers_per_gather = 4; +--Testcase 1584: +SELECT trim_scale(variance(a) * 1e1000) FROM num_variance; +ROLLBACK; + +-- case where sum of squares would overflow but variance does not +--Testcase 1585: +DELETE FROM num_variance; +--Testcase 1586: +INSERT INTO num_variance SELECT 9e131071 + x FROM generate_series(1, 5) x; +--Testcase 1587: +SELECT variance(a) FROM num_variance; + +-- check that parallel execution produces the same result +BEGIN; +-- ALTER TABLE num_variance SET (parallel_workers = 4); +SET LOCAL parallel_setup_cost = 0; +SET LOCAL max_parallel_workers_per_gather = 4; +--Testcase 1588: +SELECT variance(a) FROM num_variance; +ROLLBACK; + -- -- Tests for GCD() -- @@ -2628,7 +3593,11 @@ INSERT INTO num_tmp VALUES (0::numeric, 46375::numeric), (433125::numeric, 46375::numeric), (43312.5::numeric, 4637.5::numeric), - (4331.250::numeric, 463.75000::numeric); + (4331.250::numeric, 463.75000::numeric), + ('Infinity', '0'), + ('Infinity', '42'), + ('Infinity', 'Infinity'); + --Testcase 1076: SELECT n1 as a, n2 as b, gcd(n1, n2), gcd(n1, -n2), gcd(-n2, n1), gcd(-n2, -n1) FROM num_tmp; -- @@ -2644,7 +3613,10 @@ INSERT INTO num_tmp VALUES (13272::numeric, 13272::numeric), (423282::numeric, 13272::numeric), (42328.2::numeric, 1327.2::numeric), - (4232.820::numeric, 132.72000::numeric); + (4232.820::numeric, 132.72000::numeric), + ('Infinity', '0'), + ('Infinity', '42'), + ('Infinity', 'Infinity'); --Testcase 1079: SELECT n1 as a, n2 as b, lcm(n1, n2), lcm(n1, -n2), lcm(-n2, n1), lcm(-n2, -n1) FROM num_tmp; @@ -2655,6 +3627,88 @@ INSERT INTO num_tmp VALUES (10::numeric, 131068); --Testcase 1082: SELECT lcm(9999 * (n1)^n2 + (n1^n2 - 1), 2) FROM num_tmp; -- overflow +-- +-- Tests for factorial +-- +--Testcase 1250: +DELETE FROM num_tmp; +--Testcase 1251: +INSERT INTO num_tmp VALUES (4); +--Testcase 1252: +SELECT factorial(n1::int4) FROM num_tmp; + +--Testcase 1253: +DELETE FROM num_tmp; +--Testcase 1254: +INSERT INTO num_tmp VALUES (15); +--Testcase 1255: +SELECT factorial(n1::int4) FROM num_tmp; + +--Testcase 1256: +DELETE FROM num_tmp; +--Testcase 1257: +INSERT INTO num_tmp VALUES (100000); +--Testcase 1258: +SELECT factorial(n1::int4) FROM num_tmp; + +--Testcase 1259: +DELETE FROM num_tmp; +--Testcase 1260: +INSERT INTO num_tmp VALUES (0); +--Testcase 1261: +SELECT factorial(n1::int4) FROM num_tmp; + +--Testcase 1262: +DELETE FROM num_tmp; +--Testcase 1263: +INSERT INTO num_tmp VALUES (-4); +--Testcase 1264: +SELECT factorial(n1::int4) FROM num_tmp; + +-- +-- Tests for pg_lsn() +-- +--Testcase 1265: +DELETE FROM num_tmp; +--Testcase 1266: +INSERT INTO num_tmp VALUES (23783416::numeric); +--Testcase 1267: +SELECT pg_lsn(n1) FROM num_tmp; + +--Testcase 1268: +DELETE FROM num_tmp; +--Testcase 1269: +INSERT INTO num_tmp VALUES (0::numeric); +--Testcase 1270: +SELECT pg_lsn(n1) FROM num_tmp; + +--Testcase 1271: +DELETE FROM num_tmp; +--Testcase 1272: +INSERT INTO num_tmp VALUES (18446744073709551615::numeric); +--Testcase 1273: +SELECT pg_lsn(n1) FROM num_tmp; + +--Testcase 1274: +DELETE FROM num_tmp; +--Testcase 1275: +INSERT INTO num_tmp VALUES (-1::numeric); +--Testcase 1276: +SELECT pg_lsn(n1) FROM num_tmp; + +--Testcase 1277: +DELETE FROM num_tmp; +--Testcase 1278: +INSERT INTO num_tmp VALUES (18446744073709551616::numeric); +--Testcase 1279: +SELECT pg_lsn(n1) FROM num_tmp; + +--Testcase 1280: +DELETE FROM num_tmp; +--Testcase 1281: +INSERT INTO num_tmp VALUES ('NaN'::numeric); +--Testcase 1282: +SELECT pg_lsn(n1) FROM num_tmp; DO $d$ declare diff --git a/sql/14.0/extra/prepare.sql b/sql/15beta2/extra/prepare.sql similarity index 100% rename from sql/14.0/extra/prepare.sql rename to sql/15beta2/extra/prepare.sql diff --git a/sql/14.0/extra/select.sql b/sql/15beta2/extra/select.sql similarity index 98% rename from sql/14.0/extra/select.sql rename to sql/15beta2/extra/select.sql index 2ce03b9f..2d63b355 100644 --- a/sql/14.0/extra/select.sql +++ b/sql/15beta2/extra/select.sql @@ -159,11 +159,6 @@ RESET enable_bitmapscan; RESET enable_sort; ---Testcase 11: -SELECT two, stringu1, ten, string4 - INTO TABLE tmp - FROM onek; - -- -- awk '{print $1,$2;}' person.data | -- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data | @@ -227,6 +222,11 @@ SELECT 2+2, 57 UNION ALL TABLE int8_tbl; +-- corner case: VALUES with no columns +-- CREATE TEMP TABLE nocols(); +-- INSERT INTO nocols DEFAULT VALUES; +-- SELECT * FROM nocols n, LATERAL (VALUES(n.*)) v; + -- -- Test ORDER BY options -- diff --git a/sql/14.0/extra/select_having.sql b/sql/15beta2/extra/select_having.sql similarity index 100% rename from sql/14.0/extra/select_having.sql rename to sql/15beta2/extra/select_having.sql diff --git a/sql/13.4/extra/sqlite_fdw_post.sql b/sql/15beta2/extra/sqlite_fdw_post.sql similarity index 73% rename from sql/13.4/extra/sqlite_fdw_post.sql rename to sql/15beta2/extra/sqlite_fdw_post.sql index eacde4fc..accb38e4 100644 --- a/sql/13.4/extra/sqlite_fdw_post.sql +++ b/sql/15beta2/extra/sqlite_fdw_post.sql @@ -11,6 +11,8 @@ DO $d$ OPTIONS (database '/tmp/sqlitefdw_test_post.db')$$; EXECUTE $$CREATE SERVER sqlite_svr2 FOREIGN DATA WRAPPER sqlite_fdw OPTIONS (database '/tmp/sqlitefdw_test_post.db')$$; + EXECUTE $$CREATE SERVER sqlite_svr3 FOREIGN DATA WRAPPER sqlite_fdw + OPTIONS (database '/tmp/sqlitefdw_test_post.db')$$; END; $d$; @@ -18,7 +20,8 @@ $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 -- =================================================================== @@ -79,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: @@ -93,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: @@ -116,9 +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+ @@ -128,6 +144,8 @@ 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 @@ -147,6 +165,12 @@ SELECT c3, c4 FROM ft1 ORDER BY c3, c1 LIMIT 1; -- should work again --ANALYZE ft1; --ALTER FOREIGN TABLE ft2 OPTIONS (use_remote_estimate 'true'); +-- =================================================================== +-- test error case for create publication on foreign table +-- =================================================================== +--Testcase 955: +CREATE PUBLICATION testpub_ftbl FOR TABLE ft1; -- should fail + -- =================================================================== -- simple queries -- =================================================================== @@ -198,7 +222,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: @@ -234,9 +260,27 @@ 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; + -- =================================================================== -- WHERE with remotely-executable conditions -- =================================================================== @@ -251,9 +295,9 @@ EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 IS NOT NULL; -- Nu --Testcase 41: EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE round(abs(c1), 0) = 1; -- FuncExpr --Testcase 42: + +--Testcase 956: EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE c1 = -c1; -- OpExpr(l) ---Testcase 43: -EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE 1 = c1!; -- OpExpr(r) --Testcase 44: EXPLAIN (VERBOSE, COSTS OFF) SELECT * FROM ft1 t1 WHERE (c1 IS NOT NULL) IS DISTINCT FROM (c1 IS NOT NULL); -- DistinctExpr --Testcase 45: @@ -340,7 +384,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'); @@ -363,6 +409,44 @@ EXPLAIN (VERBOSE, COSTS OFF) --Testcase 503: SELECT * FROM ft1 t1 WHERE t1.c1 === t1.c2 order by t1.c2 limit 1; +-- Test CASE pushdown +--Testcase 957: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT c1,c2,c3 FROM ft2 WHERE CASE WHEN c1 > 990 THEN c1 END < 1000 ORDER BY c1; +--Testcase 958: +SELECT c1,c2,c3 FROM ft2 WHERE CASE WHEN c1 > 990 THEN c1 END < 1000 ORDER BY c1; + +-- Nested CASE +--Testcase 959: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT c1,c2,c3 FROM ft2 WHERE CASE CASE WHEN c2 > 0 THEN c2 END WHEN 100 THEN 601 WHEN c2 THEN c2 ELSE 0 END > 600 ORDER BY c1; + +--Testcase 960: +SELECT c1,c2,c3 FROM ft2 WHERE CASE CASE WHEN c2 > 0 THEN c2 END WHEN 100 THEN 601 WHEN c2 THEN c2 ELSE 0 END > 600 ORDER BY c1; + +-- CASE arg WHEN +--Testcase 961: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + +-- CASE cannot be pushed down because of unshippable arg clause +--Testcase 962: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE c1 > (CASE random()::integer WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + +-- these are shippable +--Testcase 963: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 964: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + +-- but this is not because of collation +--Testcase 965: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + -- =================================================================== -- JOIN queries -- =================================================================== @@ -497,12 +581,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; +--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; +--Testcase 776: +RESET enable_memoize; -- left outer join + right outer join --Testcase 107: EXPLAIN (VERBOSE, COSTS OFF) @@ -524,6 +612,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 @@ -649,7 +738,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) @@ -658,7 +749,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; @@ -674,12 +767,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) @@ -692,12 +787,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 @@ -777,6 +874,8 @@ select count(c2) w, c2 x, 5 y, 7.0 z from ft1 group by 2, y, 9.0::int order by 2 -- GROUP BY clause referring to same column multiple times -- Also, ORDER BY contains an aggregate function --Testcase 170: + +--Testcase 966: explain (verbose, costs off) select c2, c2 from ft1 where c2 > 6 group by 1, 2 order by sum(c1); --Testcase 171: @@ -912,6 +1011,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 @@ -942,6 +1042,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); @@ -995,15 +1096,26 @@ create operator class my_op_class for type int using btree family my_op_family a explain (verbose, costs off) select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 and c1 < 100 group by c2; +-- This should not be pushed either. +--Testcase 967: +explain (verbose, costs off) +select * from ft2 order by c1 using operator(public.<^); + -- 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'); @@ -1014,12 +1126,24 @@ select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 --Testcase 538: select array_agg(c1 order by c1 using operator(public.<^)) from ft2 where c2 = 6 and c1 < 100 group by c2; +-- This should be pushed too. +-- Sqlite not support pushdown user defined operators +--Testcase 968: +explain (verbose, costs off) +select * from ft2 order by c1 using operator(public.<^); + -- 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'); @@ -1079,12 +1203,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 @@ -1246,6 +1372,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; @@ -1253,6 +1380,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: @@ -1316,19 +1444,74 @@ SELECT f_test(100); --Testcase 557: 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; +-- ANALYZE ft1; -- ERROR + +-- =================================================================== +-- local type can be different from remote type in some cases, +-- in particular if similarly-named operators do equivalent things +-- =================================================================== +--Testcase 811: ALTER FOREIGN TABLE ft1 ALTER COLUMN c8 TYPE text; +--Testcase 969: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE c8 = 'foo' LIMIT 1; +--Testcase 970: +SELECT * FROM ft1 WHERE c8 = 'foo' LIMIT 1; +--Testcase 971: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM ft1 WHERE 'foo' = c8 LIMIT 1; +--Testcase 972: +SELECT * FROM ft1 WHERE 'foo' = c8 LIMIT 1; +-- we declared c8 to be text locally, but it's still the same type on +-- the remote which will balk if we try to do anything incompatible +-- with that remote type +-- Can not create user define type in SqliteDB. +-- Type c8 of foreign table ft1 and remote table T1 are +-- match. These case below not error with sqlite_fdw. +-- with that remote type +--Testcase 973: +SELECT * FROM ft1 WHERE c8 LIKE 'foo' LIMIT 1; -- ERROR +--Testcase 974: +SELECT * FROM ft1 WHERE c8::text LIKE 'foo' LIMIT 1; -- ERROR; cast not pushed down -- =================================================================== -- subtransaction @@ -1503,6 +1686,16 @@ UPDATE ft2 AS target SET (c2) = ( WHERE target.c1 = src.c1 ) 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; +--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 -- user-defined operators/functions --ALTER SERVER loopback OPTIONS (DROP extensions); @@ -1689,41 +1882,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; -- =================================================================== @@ -1784,6 +1985,12 @@ 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); +-- Detach and re-attach once, to stress the concurrent detach case. +--Testcase 975: +ALTER TABLE parent_tbl DETACH PARTITION foreign_tbl CONCURRENTLY; +--Testcase 976: ALTER TABLE parent_tbl ATTACH PARTITION foreign_tbl FOR VALUES FROM (0) TO (100); --Testcase 616: @@ -1859,13 +2066,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 @@ -2194,6 +2432,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: @@ -2309,6 +2553,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) @@ -2391,7 +2636,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: @@ -2427,6 +2674,34 @@ select * from bar where f1 in (select f1 from foo) for share; --Testcase 450: 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 --Testcase 451: explain (verbose, costs off) @@ -2464,7 +2739,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); @@ -2485,7 +2762,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 @@ -2548,6 +2827,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: @@ -2927,6 +3207,141 @@ select * from rem3; drop foreign table rem3; 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 +-- FOR VALUES WITH (MODULUS 2, REMAINDER 0); +-- CREATE TABLE tru_rtable1 (id int primary key); +-- 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 +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 + +-- -- partitioned table with both local and foreign tables as partitions +-- SELECT sum(id) FROM tru_ptable; -- 155 +-- TRUNCATE tru_ptable; +-- SELECT count(*) FROM tru_ptable; -- 0 +-- SELECT count(*) FROM tru_ptable__p0; -- 0 +-- 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 +-- 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 +-- CREATE TABLE tru_rtable0_child () INHERITS (tru_rtable0); +-- INSERT INTO tru_rtable0 (SELECT x FROM generate_series(5,9) x); +-- INSERT INTO "S 1".tru_rtable0_child (SELECT x FROM generate_series(10,14) x); +-- SELECT sum(id) FROM tru_ftable; -- 95 + +-- -- Both parent and child tables in the foreign server are truncated +-- -- even though ONLY is specified because ONLY has no effect +-- -- when truncating a foreign table. +-- TRUNCATE ONLY tru_ftable; +-- SELECT count(*) FROM tru_ftable; -- 0 + +-- INSERT INTO tru_rtable0 (SELECT x FROM generate_series(21,25) x); +-- INSERT INTO tru_rtable0_child (SELECT x FROM generate_series(26,30) x); +-- SELECT sum(id) FROM tru_ftable; -- 255 +-- 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; + -- =================================================================== -- test IMPORT FOREIGN SCHEMA -- =================================================================== @@ -3109,8 +3524,8 @@ INSERT INTO pagg_tab_p3 SELECT i % 30, i % 50, to_char(i/30, 'FM0000') FROM gene -- Create foreign partitions CREATE FOREIGN TABLE fpagg_tab_p1 PARTITION OF pagg_tab FOR VALUES FROM (0) TO (10) SERVER loopback OPTIONS (table_name 'pagg_tab_p1'); -CREATE FOREIGN TABLE fpagg_tab_p2 PARTITION OF pagg_tab FOR VALUES FROM (10) TO (20) SERVER loopback OPTIONS (table_name 'pagg_tab_p2');; -CREATE FOREIGN TABLE fpagg_tab_p3 PARTITION OF pagg_tab FOR VALUES FROM (20) TO (30) SERVER loopback OPTIONS (table_name 'pagg_tab_p3');; +CREATE FOREIGN TABLE fpagg_tab_p2 PARTITION OF pagg_tab FOR VALUES FROM (10) TO (20) SERVER loopback OPTIONS (table_name 'pagg_tab_p2'); +CREATE FOREIGN TABLE fpagg_tab_p3 PARTITION OF pagg_tab FOR VALUES FROM (20) TO (30) SERVER loopback OPTIONS (table_name 'pagg_tab_p3'); ANALYZE pagg_tab; ANALYZE fpagg_tab_p1; @@ -3181,7 +3596,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. @@ -3199,13 +3614,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; @@ -3215,7 +3630,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 @@ -3229,13 +3644,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; @@ -3254,6 +3669,797 @@ SELECT count(*) FROM ft1; PREPARE TRANSACTION 'fdw_tpc'; ROLLBACK; +-- =================================================================== +-- reestablish new connection +-- =================================================================== +-- -- Test case relative with option application_name is not suitable for SQLite FDW. +-- -- Because this option is in libpq of postgres. +-- -- 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_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_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. +-- SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity +-- WHERE application_name = 'fdw_retry_check'; +-- -- This query should detect the broken connection when starting new remote +-- -- transaction, reestablish new connection, and then succeed. +-- BEGIN; +-- SELECT 1 FROM ft1 LIMIT 1; +-- -- If we detect the broken connection when starting a new remote +-- -- subtransaction, we should fail instead of establishing a new connection. +-- -- Terminate the remote connection and wait for the termination to complete. +-- SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity +-- WHERE application_name = 'fdw_retry_check'; +-- SAVEPOINT s; +-- -- The text of the error might vary across platforms, so only show SQLSTATE. +-- \set VERBOSITY sqlstate +-- SELECT 1 FROM ft1 LIMIT 1; -- should fail +-- \set VERBOSITY default +-- COMMIT; + +-- 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; + +-- ======================================================================= +-- test sqlite_fdw_disconnect and sqlite_fdw_disconnect_all functions +-- ======================================================================= +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; + +-- =================================================================== +-- 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; +-- 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'); + +-- =================================================================== +-- 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' +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 +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; + +-- Disable batch inserting into foreign tables with BEFORE ROW INSERT triggers +-- even if the batch_size option is enabled. +--Testcase 977: +ALTER FOREIGN TABLE ftable OPTIONS ( SET batch_size '10' ); +--Testcase 978: +CREATE TRIGGER trig_row_before BEFORE INSERT ON ftable +--Testcase 979: +FOR EACH ROW EXECUTE PROCEDURE trigger_data(23,'skidoo'); +--Testcase 980: +EXPLAIN (VERBOSE, COSTS OFF) INSERT INTO ftable VALUES (3), (4); +--Testcase 981: +INSERT INTO ftable VALUES (3), (4); +--Testcase 982: +SELECT COUNT(*) FROM ftable; + +-- Clean up +--Testcase 983: +DROP TRIGGER trig_row_before ON ftable; +--Testcase 953: +DROP FOREIGN TABLE ftable; +-- DROP TABLE batch_table; + +-- -- Use partitioning +-- CREATE TABLE batch_table ( x int ) PARTITION BY HASH (x); + +-- CREATE TABLE batch_table_p0 (LIKE batch_table); +-- CREATE FOREIGN TABLE batch_table_p0f + -- PARTITION OF batch_table + -- FOR VALUES WITH (MODULUS 3, REMAINDER 0) + -- SERVER sqlite_svr + -- OPTIONS (table 'batch_table_p0', batch_size '10'); + +-- CREATE TABLE batch_table_p1 (LIKE batch_table); +-- CREATE FOREIGN TABLE batch_table_p1f + -- PARTITION OF batch_table + -- FOR VALUES WITH (MODULUS 3, REMAINDER 1) +-- SERVER sqlite_svr +-- OPTIONS (table 'batch_table_p1', batch_size '1'); + +-- CREATE TABLE batch_table_p2 +-- PARTITION OF batch_table +-- FOR VALUES WITH (MODULUS 3, REMAINDER 2); + +-- INSERT INTO "S 1".batch_table SELECT * FROM generate_series(1, 66) i; +-- SELECT COUNT(*) FROM "S 1".batch_table; + +-- -- Check that enabling batched inserts doesn't interfere with cross-partition +-- -- updates +-- CREATE TABLE batch_cp_upd_test (a int) PARTITION BY LIST (a); +-- CREATE TABLE batch_cp_upd_test1 (LIKE batch_cp_upd_test); +-- CREATE FOREIGN TABLE batch_cp_upd_test1_f +-- PARTITION OF batch_cp_upd_test +-- FOR VALUES IN (1) +-- SERVER sqlite_svr +-- OPTIONS (table_name 'batch_cp_upd_test1', batch_size '10'); +-- CREATE TABLE batch_cp_up_test1 PARTITION OF batch_cp_upd_test +-- FOR VALUES IN (2); +-- INSERT INTO batch_cp_upd_test VALUES (1), (2); + +-- -- The following moves a row from the local partition to the foreign one +-- UPDATE batch_cp_upd_test t SET a = 1 FROM (VALUES (1), (2)) s(a) WHERE t.a = s.a; +-- SELECT tableoid::regclass, * FROM batch_cp_upd_test; + +-- -- Clean up +-- DROP TABLE batch_table, batch_cp_upd_test, batch_table_p0, batch_table_p1 CASCADE; + +-- -- Use partitioning +-- ALTER SERVER loopback OPTIONS (ADD batch_size '10'); + +-- CREATE TABLE batch_table ( x int, field1 text, field2 text) PARTITION BY HASH (x); + +-- CREATE TABLE batch_table_p0 (LIKE batch_table); +-- ALTER TABLE batch_table_p0 ADD CONSTRAINT p0_pkey PRIMARY KEY (x); +-- CREATE FOREIGN TABLE batch_table_p0f +-- PARTITION OF batch_table +-- FOR VALUES WITH (MODULUS 2, REMAINDER 0) +-- SERVER loopback +-- OPTIONS (table_name 'batch_table_p0'); + +-- CREATE TABLE batch_table_p1 (LIKE batch_table); +-- ALTER TABLE batch_table_p1 ADD CONSTRAINT p1_pkey PRIMARY KEY (x); +-- CREATE FOREIGN TABLE batch_table_p1f +-- PARTITION OF batch_table +-- FOR VALUES WITH (MODULUS 2, REMAINDER 1) +-- SERVER loopback +-- OPTIONS (table_name 'batch_table_p1'); + +-- INSERT INTO batch_table SELECT i, 'test'||i, 'test'|| i FROM generate_series(1, 50) i; +-- SELECT COUNT(*) FROM batch_table; +-- SELECT * FROM batch_table ORDER BY x; + +-- ALTER SERVER loopback OPTIONS (DROP batch_size); + +-- =================================================================== +-- test asynchronous execution +-- =================================================================== + +-- ALTER SERVER loopback OPTIONS (DROP extensions); +-- ALTER SERVER loopback OPTIONS (ADD async_capable 'true'); +-- ALTER SERVER loopback2 OPTIONS (ADD async_capable 'true'); + +-- CREATE TABLE async_pt (a int, b int, c text) PARTITION BY RANGE (a); +-- CREATE TABLE base_tbl1 (a int, b int, c text); +-- CREATE TABLE base_tbl2 (a int, b int, c text); +-- CREATE FOREIGN TABLE async_p1 PARTITION OF async_pt FOR VALUES FROM (1000) TO (2000) +-- SERVER loopback OPTIONS (table_name 'base_tbl1'); +-- CREATE FOREIGN TABLE async_p2 PARTITION OF async_pt FOR VALUES FROM (2000) TO (3000) +-- SERVER loopback2 OPTIONS (table_name 'base_tbl2'); +-- INSERT INTO async_p1 SELECT 1000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i; +-- INSERT INTO async_p2 SELECT 2000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i; +-- ANALYZE async_pt; + +-- -- simple queries +-- CREATE TABLE result_tbl (a int, b int, c text); + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b % 100 = 0; +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b % 100 = 0; + +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; + +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; + +-- -- Check case where multiple partitions use the same connection +-- CREATE TABLE base_tbl3 (a int, b int, c text); +-- CREATE FOREIGN TABLE async_p3 PARTITION OF async_pt FOR VALUES FROM (3000) TO (4000) +-- SERVER loopback2 OPTIONS (table_name 'base_tbl3'); +-- INSERT INTO async_p3 SELECT 3000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i; +-- ANALYZE async_pt; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; + +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; + +-- DROP FOREIGN TABLE async_p3; +-- DROP TABLE base_tbl3; + +-- -- Check case where the partitioned table has local/remote partitions +-- CREATE TABLE async_p3 PARTITION OF async_pt FOR VALUES FROM (3000) TO (4000); +-- INSERT INTO async_p3 SELECT 3000 + i, i, to_char(i, 'FM0000') FROM generate_series(0, 999, 5) i; +-- ANALYZE async_pt; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE b === 505; + +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; + +-- -- partitionwise joins +-- SET enable_partitionwise_join TO true; + +-- CREATE TABLE join_tbl (a1 int, b1 int, c1 text, a2 int, b2 int, c2 text); + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO join_tbl SELECT * FROM async_pt t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; +-- INSERT INTO join_tbl SELECT * FROM async_pt t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; + +-- SELECT * FROM join_tbl ORDER BY a1; +-- DELETE FROM join_tbl; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO join_tbl SELECT t1.a, t1.b, 'AAA' || t1.c, t2.a, t2.b, 'AAA' || t2.c FROM async_pt t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; +-- INSERT INTO join_tbl SELECT t1.a, t1.b, 'AAA' || t1.c, t2.a, t2.b, 'AAA' || t2.c FROM async_pt t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; + +-- SELECT * FROM join_tbl ORDER BY a1; +-- DELETE FROM join_tbl; + +-- RESET enable_partitionwise_join; + +-- -- Test rescan of an async Append node with do_exec_prune=false +-- SET enable_hashjoin TO false; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO join_tbl SELECT * FROM async_p1 t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; +-- INSERT INTO join_tbl SELECT * FROM async_p1 t1, async_pt t2 WHERE t1.a = t2.a AND t1.b = t2.b AND t1.b % 100 = 0; + +-- SELECT * FROM join_tbl ORDER BY a1; +-- DELETE FROM join_tbl; + +-- RESET enable_hashjoin; + +-- -- Test interaction of async execution with plan-time partition pruning +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM async_pt WHERE a < 3000; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM async_pt WHERE a < 2000; + +-- -- Test interaction of async execution with run-time partition pruning +-- SET plan_cache_mode TO force_generic_plan; + +-- PREPARE async_pt_query (int, int) AS +-- INSERT INTO result_tbl SELECT * FROM async_pt WHERE a < $1 AND b === $2; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- EXECUTE async_pt_query (3000, 505); +-- EXECUTE async_pt_query (3000, 505); + +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- EXECUTE async_pt_query (2000, 505); +-- EXECUTE async_pt_query (2000, 505); + +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; + +-- RESET plan_cache_mode; + +-- CREATE TABLE local_tbl(a int, b int, c text); +-- INSERT INTO local_tbl VALUES (1505, 505, 'foo'), (2505, 505, 'bar'); +-- ANALYZE local_tbl; + +-- CREATE INDEX base_tbl1_idx ON base_tbl1 (a); +-- CREATE INDEX base_tbl2_idx ON base_tbl2 (a); +-- CREATE INDEX async_p3_idx ON async_p3 (a); +-- ANALYZE base_tbl1; +-- ANALYZE base_tbl2; +-- ANALYZE async_p3; + +-- ALTER FOREIGN TABLE async_p1 OPTIONS (use_remote_estimate 'true'); +-- ALTER FOREIGN TABLE async_p2 OPTIONS (use_remote_estimate 'true'); + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM local_tbl, async_pt WHERE local_tbl.a = async_pt.a AND local_tbl.c = 'bar'; +-- EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +-- SELECT * FROM local_tbl, async_pt WHERE local_tbl.a = async_pt.a AND local_tbl.c = 'bar'; +-- SELECT * FROM local_tbl, async_pt WHERE local_tbl.a = async_pt.a AND local_tbl.c = 'bar'; + +-- ALTER FOREIGN TABLE async_p1 OPTIONS (DROP use_remote_estimate); +-- ALTER FOREIGN TABLE async_p2 OPTIONS (DROP use_remote_estimate); + +-- DROP TABLE local_tbl; +-- DROP INDEX base_tbl1_idx; +-- DROP INDEX base_tbl2_idx; +-- DROP INDEX async_p3_idx; + +-- -- UNION queries +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl +-- (SELECT a, b, 'AAA' || c FROM async_p1 ORDER BY a LIMIT 10) +-- UNION +-- (SELECT a, b, 'AAA' || c FROM async_p2 WHERE b < 10); +-- INSERT INTO result_tbl +-- (SELECT a, b, 'AAA' || c FROM async_p1 ORDER BY a LIMIT 10) +-- UNION +-- (SELECT a, b, 'AAA' || c FROM async_p2 WHERE b < 10); + +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO result_tbl +-- (SELECT a, b, 'AAA' || c FROM async_p1 ORDER BY a LIMIT 10) +-- UNION ALL +-- (SELECT a, b, 'AAA' || c FROM async_p2 WHERE b < 10); +-- INSERT INTO result_tbl +-- (SELECT a, b, 'AAA' || c FROM async_p1 ORDER BY a LIMIT 10) +-- UNION ALL +-- (SELECT a, b, 'AAA' || c FROM async_p2 WHERE b < 10); + +-- SELECT * FROM result_tbl ORDER BY a; +-- DELETE FROM result_tbl; + +-- -- Disable async execution if we use gating Result nodes for pseudoconstant +-- -- quals +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM async_pt WHERE CURRENT_USER = SESSION_USER; + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- (SELECT * FROM async_p1 WHERE CURRENT_USER = SESSION_USER) +-- UNION ALL +-- (SELECT * FROM async_p2 WHERE CURRENT_USER = SESSION_USER); + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT * FROM ((SELECT * FROM async_p1 WHERE b < 10) UNION ALL (SELECT * FROM async_p2 WHERE b < 10)) s WHERE CURRENT_USER = SESSION_USER; + +-- -- Test that pending requests are processed properly +-- SET enable_mergejoin TO false; +-- SET enable_hashjoin TO false; + +-- 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 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'); +-- INSERT INTO remote_tbl VALUES (2505, 505, 'bar'); + +-- CREATE TABLE base_tbl4 (a int, b int, c text); +-- CREATE FOREIGN TABLE insert_tbl (a int, b int, c text) +-- SERVER loopback OPTIONS (table_name 'base_tbl4'); + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- INSERT INTO insert_tbl (SELECT * FROM local_tbl UNION ALL SELECT * FROM remote_tbl); +-- INSERT INTO insert_tbl (SELECT * FROM local_tbl UNION ALL SELECT * FROM remote_tbl); + +-- SELECT * FROM insert_tbl ORDER BY a; + +-- -- Check with direct modify +-- EXPLAIN (VERBOSE, COSTS OFF) +-- WITH t AS (UPDATE remote_tbl SET c = c || c RETURNING *) +-- INSERT INTO join_tbl SELECT * FROM async_pt LEFT JOIN t ON (async_pt.a = t.a AND async_pt.b = t.b) WHERE async_pt.b === 505; +-- WITH t AS (UPDATE remote_tbl SET c = c || c RETURNING *) +-- INSERT INTO join_tbl SELECT * FROM async_pt LEFT JOIN t ON (async_pt.a = t.a AND async_pt.b = t.b) WHERE async_pt.b === 505; + +-- SELECT * FROM join_tbl ORDER BY a1; +-- DELETE FROM join_tbl; + +-- DROP TABLE local_tbl; +-- DROP FOREIGN TABLE remote_tbl; +-- DROP FOREIGN TABLE insert_tbl; +-- DROP TABLE base_tbl3; +-- DROP TABLE base_tbl4; + +-- RESET enable_mergejoin; +-- RESET enable_hashjoin; + +-- -- Test that UPDATE/DELETE with inherited target works with async_capable enabled +-- EXPLAIN (VERBOSE, COSTS OFF) +-- UPDATE async_pt SET c = c || c WHERE b = 0 RETURNING *; +-- UPDATE async_pt SET c = c || c WHERE b = 0 RETURNING *; +-- EXPLAIN (VERBOSE, COSTS OFF) +-- DELETE FROM async_pt WHERE b = 0 RETURNING *; +-- DELETE FROM async_pt WHERE b = 0 RETURNING *; + +-- -- Check EXPLAIN ANALYZE for a query that scans empty partitions asynchronously +-- DELETE FROM async_p1; +-- DELETE FROM async_p2; +-- DELETE FROM async_p3; + +-- EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF) +-- SELECT * FROM async_pt; + +-- -- Clean up +-- DROP TABLE async_pt; +-- DROP TABLE base_tbl1; +-- DROP TABLE base_tbl2; +-- DROP TABLE result_tbl; +-- DROP TABLE join_tbl; + +-- -- Test that an asynchronous fetch is processed before restarting the scan in +-- -- ReScanForeignScan +-- CREATE TABLE base_tbl (a int, b int); +-- INSERT INTO base_tbl VALUES (1, 11), (2, 22), (3, 33); +-- CREATE FOREIGN TABLE foreign_tbl (b int) +-- SERVER loopback OPTIONS (table_name 'base_tbl'); +-- CREATE FOREIGN TABLE foreign_tbl2 () INHERITS (foreign_tbl) +-- SERVER loopback OPTIONS (table_name 'base_tbl'); + +-- EXPLAIN (VERBOSE, COSTS OFF) +-- SELECT a FROM base_tbl WHERE a IN (SELECT a FROM foreign_tbl); +-- SELECT a FROM base_tbl WHERE a IN (SELECT a FROM foreign_tbl); + +-- -- Clean up +-- DROP FOREIGN TABLE foreign_tbl CASCADE; +-- DROP TABLE base_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$%$#$#'); + +-- -- No option is allowed to be specified at foreign data wrapper level +-- ALTER FOREIGN DATA WRAPPER postgres_fdw OPTIONS (nonexistent 'fdw'); + +-- -- =================================================================== +-- -- test postgres_fdw.application_name GUC +-- -- =================================================================== +-- --- Turn debug_discard_caches off for this test to make sure that +-- --- the remote connection is alive when checking its application_name. +-- SET debug_discard_caches = 0; + +-- -- Specify escape sequences in application_name option of a server +-- -- object so as to test that they are replaced with status information +-- -- expectedly. +-- -- +-- -- Since pg_stat_activity.application_name may be truncated to less than +-- -- NAMEDATALEN characters, note that substring() needs to be used +-- -- at the condition of test query to make sure that the string consisting +-- -- of database name and process ID is also less than that. +-- ALTER SERVER loopback2 OPTIONS (application_name 'fdw_%d%p'); +-- SELECT 1 FROM ft6 LIMIT 1; +-- SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity +-- WHERE application_name = +-- substring('fdw_' || current_database() || pg_backend_pid() for +-- current_setting('max_identifier_length')::int); + +-- -- postgres_fdw.application_name overrides application_name option +-- -- of a server object if both settings are present. +-- SET postgres_fdw.application_name TO 'fdw_%a%u%%'; +-- SELECT 1 FROM ft6 LIMIT 1; +-- SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity +-- WHERE application_name = +-- substring('fdw_' || current_setting('application_name') || +-- CURRENT_USER || '%' for current_setting('max_identifier_length')::int); + +-- -- Test %c (session ID) and %C (cluster name) escape sequences. +-- SET postgres_fdw.application_name TO 'fdw_%C%c'; +-- SELECT 1 FROM ft6 LIMIT 1; +-- SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity +-- WHERE application_name = +-- substring('fdw_' || current_setting('cluster_name') || +-- to_hex(trunc(EXTRACT(EPOCH FROM (SELECT backend_start FROM +-- pg_stat_get_activity(pg_backend_pid()))))::integer) || '.' || +-- to_hex(pg_backend_pid()) +-- for current_setting('max_identifier_length')::int); + +-- --Clean up +-- RESET postgres_fdw.application_name; +-- RESET debug_discard_caches; + +-- -- =================================================================== +-- -- test parallel commit +-- -- =================================================================== +-- ALTER SERVER loopback OPTIONS (ADD parallel_commit 'true'); +-- ALTER SERVER loopback2 OPTIONS (ADD parallel_commit 'true'); + +-- CREATE TABLE ploc1 (f1 int, f2 text); +-- CREATE FOREIGN TABLE prem1 (f1 int, f2 text) +-- SERVER loopback OPTIONS (table_name 'ploc1'); +-- CREATE TABLE ploc2 (f1 int, f2 text); +-- CREATE FOREIGN TABLE prem2 (f1 int, f2 text) +-- SERVER loopback2 OPTIONS (table_name 'ploc2'); + +-- BEGIN; +-- INSERT INTO prem1 VALUES (101, 'foo'); +-- INSERT INTO prem2 VALUES (201, 'bar'); +-- COMMIT; +-- SELECT * FROM prem1; +-- SELECT * FROM prem2; + +-- BEGIN; +-- SAVEPOINT s; +-- INSERT INTO prem1 VALUES (102, 'foofoo'); +-- INSERT INTO prem2 VALUES (202, 'barbar'); +-- RELEASE SAVEPOINT s; +-- COMMIT; +-- SELECT * FROM prem1; +-- SELECT * FROM prem2; + +-- -- This tests executing DEALLOCATE ALL against foreign servers in parallel +-- -- during pre-commit +-- BEGIN; +-- SAVEPOINT s; +-- INSERT INTO prem1 VALUES (103, 'baz'); +-- INSERT INTO prem2 VALUES (203, 'qux'); +-- ROLLBACK TO SAVEPOINT s; +-- RELEASE SAVEPOINT s; +-- INSERT INTO prem1 VALUES (104, 'bazbaz'); +-- INSERT INTO prem2 VALUES (204, 'quxqux'); +-- COMMIT; +-- SELECT * FROM prem1; +-- SELECT * FROM prem2; + +-- ALTER SERVER loopback OPTIONS (DROP parallel_commit); +-- ALTER SERVER loopback2 OPTIONS (DROP parallel_commit); -- Clean-up --Testcase 733: diff --git a/sql/14.0/extra/timestamp.sql b/sql/15beta2/extra/timestamp.sql similarity index 100% rename from sql/14.0/extra/timestamp.sql rename to sql/15beta2/extra/timestamp.sql diff --git a/sql/13.4/extra/update.sql b/sql/15beta2/extra/update.sql similarity index 91% rename from sql/13.4/extra/update.sql rename to sql/15beta2/extra/update.sql index c0bdf32e..6b510169 100644 --- a/sql/13.4/extra/update.sql +++ b/sql/15beta2/extra/update.sql @@ -144,17 +144,17 @@ SELECT a, b, char_length(c) FROM update_test; /* Skip, sqlite fdw does not support ON CONFLICT DO UPDATE -- Test ON CONFLICT DO UPDATE -INSERT INTO upsert_test VALUES(1, 'Boo'); +INSERT INTO upsert_test VALUES(1, 'Boo'), (3, 'Zoo'); -- uncorrelated sub-select: WITH aaa AS (SELECT 1 AS a, 'Foo' AS b) INSERT INTO upsert_test VALUES (1, 'Bar') ON CONFLICT(a) DO UPDATE SET (b, a) = (SELECT b, a FROM aaa) RETURNING *; -- correlated sub-select: -INSERT INTO upsert_test VALUES (1, 'Baz') ON CONFLICT(a) +INSERT INTO upsert_test VALUES (1, 'Baz'), (3, 'Zaz') ON CONFLICT(a) DO UPDATE SET (b, a) = (SELECT b || ', Correlated', a from upsert_test i WHERE i.a = upsert_test.a) RETURNING *; -- correlated sub-select (EXCLUDED.* alias): -INSERT INTO upsert_test VALUES (1, 'Bat') ON CONFLICT(a) +INSERT INTO upsert_test VALUES (1, 'Bat'), (3, 'Zot') ON CONFLICT(a) DO UPDATE SET (b, a) = (SELECT b || ', Excluded', a from upsert_test i WHERE i.a = excluded.a) RETURNING *; @@ -176,6 +176,29 @@ DROP FOREIGN TABLE upsert_test; */ /*Skip, sqlite fdw does not support create partition table +-- Test ON CONFLICT DO UPDATE with partitioned table and non-identical children + +CREATE TABLE upsert_test ( + a INT PRIMARY KEY, + b TEXT +) PARTITION BY LIST (a); + +CREATE TABLE upsert_test_1 PARTITION OF upsert_test FOR VALUES IN (1); +CREATE TABLE upsert_test_2 (b TEXT, a INT PRIMARY KEY); +ALTER TABLE upsert_test ATTACH PARTITION upsert_test_2 FOR VALUES IN (2); + +INSERT INTO upsert_test VALUES(1, 'Boo'), (2, 'Zoo'); +-- uncorrelated sub-select: +WITH aaa AS (SELECT 1 AS a, 'Foo' AS b) INSERT INTO upsert_test + VALUES (1, 'Bar') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT b, a FROM aaa) RETURNING *; +-- correlated sub-select: +WITH aaa AS (SELECT 1 AS ctea, ' Foo' AS cteb) INSERT INTO upsert_test + VALUES (1, 'Bar'), (2, 'Baz') ON CONFLICT(a) + DO UPDATE SET (b, a) = (SELECT upsert_test.b||cteb, upsert_test.a FROM aaa) RETURNING *; + +DROP TABLE upsert_test; + --------------------------- -- UPDATE with row movement --------------------------- @@ -547,6 +570,37 @@ UPDATE list_default set a = 'x' WHERE a = 'd'; DROP TABLE list_parted; +-- Test retrieval of system columns with non-consistent partition row types. +-- This is only partially supported, as seen in the results. + +create table utrtest (a int, b text) partition by list (a); +create table utr1 (a int check (a in (1)), q text, b text); +create table utr2 (a int check (a in (2)), b text); +alter table utr1 drop column q; +alter table utrtest attach partition utr1 for values in (1); +alter table utrtest attach partition utr2 for values in (2); + +insert into utrtest values (1, 'foo') + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok; +insert into utrtest values (2, 'bar') + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok; -- fails +insert into utrtest values (2, 'bar') + returning *, tableoid::regclass; + +update utrtest set b = b || b from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok; + +update utrtest set a = 3 - a from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass, xmin = pg_current_xact_id()::xid as xmin_ok; -- fails + +update utrtest set a = 3 - a from (values (1), (2)) s(x) where a = s.x + returning *, tableoid::regclass; + +delete from utrtest + returning *, tableoid::regclass, xmax = pg_current_xact_id()::xid as xmax_ok; + +drop table utrtest; + -------------- -- Some more update-partition-key test scenarios below. This time use list -- partitions. diff --git a/sql/15beta2/selectfunc.sql b/sql/15beta2/selectfunc.sql new file mode 100644 index 00000000..3db3d875 --- /dev/null +++ b/sql/15beta2/selectfunc.sql @@ -0,0 +1,415 @@ +SET datestyle=ISO; +SET timezone='Japan'; + +--Testcase 1: +CREATE EXTENSION sqlite_fdw; +--Testcase 2: +CREATE SERVER server1 FOREIGN DATA WRAPPER sqlite_fdw +OPTIONS (database '/tmp/sqlitefdw_test_selectfunc.db'); +--CREATE USER MAPPING FOR CURRENT_USER SERVER server1 OPTIONS(user 'user', password 'pass'); + +--IMPORT FOREIGN SCHEMA public FROM SERVER server1 INTO public OPTIONS(import_time_text 'false'); +--Testcase 3: +CREATE FOREIGN TABLE s3(id text OPTIONS (key 'true'), time timestamp, tag1 text, value1 float, value2 int, value3 float, value4 int, str1 text, str2 text) SERVER server1; + +-- s3 (value1 as float8, value2 as bigint) +--Testcase 4: +\d s3; +--Testcase 5: +SELECT * FROM s3; + +-- select float8() (not pushdown, remove float8, explain) +-- EXPLAIN VERBOSE +-- SELECT float8(value1), float8(value2), float8(value3), float8(value4) FROM s3; +-- sqlite fdw does not support + +-- select float8() (not pushdown, remove float8, result) +-- SELECT float8(value1), float8(value2), float8(value3), float8(value4) FROM s3; +-- sqlite fdw does not support + +-- select sqrt (builtin function, explain) +-- EXPLAIN VERBOSE +-- SELECT sqrt(value1), sqrt(value2) FROM s3; +-- sqlite fdw does not have sqrt() + +-- select sqrt (buitin function, result) +-- SELECT sqrt(value1), sqrt(value2) FROM s3; +-- sqlite fdw does not have sqrt() + +-- select sqrt (builtin function,, not pushdown constraints, explain) +-- EXPLAIN VERBOSE +-- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE to_hex(value2) != '64'; +-- sqlite fdw does not have sqrt() + +-- select sqrt (builtin function, not pushdown constraints, result) +-- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE to_hex(value2) != '64'; +-- sqlite fdw does not have sqrt() + +-- select sqrt (builtin function, pushdown constraints, explain) +-- EXPLAIN VERBOSE +-- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE value2 != 200; +-- sqlite fdw does not have sqrt() + +-- select sqrt (builtin function, pushdown constraints, result) +-- SELECT sqrt(value1), sqrt(value2) FROM s3 WHERE value2 != 200; +-- sqlite fdw does not have sqrt() + +-- select abs (builtin function, explain) +--Testcase 6: +EXPLAIN VERBOSE +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3; + +-- select abs (buitin function, result) +--Testcase 7: +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3; + +-- select abs (builtin function, not pushdown constraints, explain) +--Testcase 8: +EXPLAIN VERBOSE +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE to_hex(value2) != '64'; + +-- select abs (builtin function, not pushdown constraints, result) +--Testcase 9: +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE to_hex(value2) != '64'; + +-- select abs (builtin function, pushdown constraints, explain) +--Testcase 10: +EXPLAIN VERBOSE +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE value2 != 200; + +-- select abs (builtin function, pushdown constraints, result) +--Testcase 11: +SELECT abs(value1), abs(value2), abs(value3), abs(value4) FROM s3 WHERE value2 != 200; + +-- select log (builtin function, need to swap arguments, numeric cast, explain) +-- log_(v) : postgresql (base, v), sqlite (v, base) +-- EXPLAIN VERBOSE +-- SELECT log(value1::numeric, value2::numeric) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() + +-- select log (builtin function, need to swap arguments, numeric cast, result) +-- SELECT log(value1::numeric, value2::numeric) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() + +-- select log (stub function, need to swap arguments, float8, explain) +-- EXPLAIN VERBOSE +-- SELECT log(value1, 0.1) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() + +-- select log (stub function, need to swap arguments, float8, result) +-- SELECT log(value1, 0.1) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() + +-- select log (stub function, need to swap arguments, bigint, explain) +-- EXPLAIN VERBOSE +-- SELECT log(value2, 3) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() + +-- select log (stub function, need to swap arguments, bigint, result) +-- SELECT log(value2, 3) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() + +-- select log (stub function, need to swap arguments, mix type, explain) +-- EXPLAIN VERBOSE +-- SELECT log(value1, value2) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() + +-- select log (stub function, need to swap arguments, mix type, result) +-- SELECT log(value1, value2) FROM s3 WHERE value1 != 1; +-- sqlite fdw does not have log() + +-- select log2 (stub function, explain) +-- EXPLAIN VERBOSE +-- SELECT log2(value1),log2(value2) FROM s3; +-- sqlite fdw does not have log2() + +-- select log2 (stub function, result) +-- SELECT log2(value1),log2(value2) FROM s3; +-- sqlite fdw does not have log2() + +-- select spread (stub agg function, explain) +-- EXPLAIN VERBOSE +-- SELECT spread(value1),spread(value2),spread(value3),spread(value4) FROM s3; +-- sqlite fdw does not have spread() + +-- select spread (stub agg function, result) +-- SELECT spread(value1),spread(value2),spread(value3),spread(value4) FROM s3; +-- sqlite fdw does not have spread() + +-- select spread (stub agg function, raise exception if not expected type) +-- SELECT spread(value1::numeric),spread(value2::numeric),spread(value3::numeric),spread(value4::numeric) FROM s3; +-- sqlite fdw does not have spread() + +-- select abs as nest function with agg (pushdown, explain) +--Testcase 12: +EXPLAIN VERBOSE +SELECT sum(value3),abs(sum(value3)) FROM s3; + +-- select abs as nest function with agg (pushdown, result) +--Testcase 13: +SELECT sum(value3),abs(sum(value3)) FROM s3; + +-- select abs as nest with log2 (pushdown, explain) +-- EXPLAIN VERBOSE +-- SELECT abs(log2(value1)),abs(log2(1/value1)) FROM s3; +-- sqlite fdw does not have log2() + +-- select abs as nest with log2 (pushdown, result) +-- SELECT abs(log2(value1)),abs(log2(1/value1)) FROM s3; +-- sqlite fdw does not have log2() + +-- select abs with non pushdown func and explicit constant (explain) +--Testcase 14: +EXPLAIN VERBOSE +SELECT abs(value3), pi(), 4.1 FROM s3; + +-- select abs with non pushdown func and explicit constant (result) +--Testcase 15: +SELECT abs(value3), pi(), 4.1 FROM s3; + +-- select sqrt as nest function with agg and explicit constant (pushdown, explain) +-- EXPLAIN VERBOSE +-- SELECT sqrt(count(value1)), pi(), 4.1 FROM s3; +-- sqlite fdw does not have sqrt() + +-- select sqrt as nest function with agg and explicit constant (pushdown, result) +-- SELECT sqrt(count(value1)), pi(), 4.1 FROM s3; +-- sqlite fdw does not have sqrt() + +-- select sqrt as nest function with agg and explicit constant and tag (error, explain) +-- EXPLAIN VERBOSE +-- SELECT sqrt(count(value1)), pi(), 4.1, tag1 FROM s3; +-- sqlite fdw does not have sqrt() + +-- select spread (stub agg function and group by influx_time() and tag) (explain) +-- EXPLAIN VERBOSE +-- SELECT spread("value1"),influx_time(time, interval '1s'),tag1 FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY influx_time(time, interval '1s'), tag1; +-- sqlite fdw does not have spread() and influx_time() + +-- select spread (stub agg function and group by influx_time() and tag) (result) +-- SELECT spread("value1"),influx_time(time, interval '1s'),tag1 FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY influx_time(time, interval '1s'), tag1; +-- sqlite fdw does not have spread() and influx_time() + +-- select spread (stub agg function and group by tag only) (result) +-- SELECT tag1,spread("value1") FROM s3 WHERE time >= to_timestamp(0) and time <= to_timestamp(4) GROUP BY tag1; +-- sqlite fdw does not have spread() + +-- select spread (stub agg function and other aggs) (result) +-- SELECT sum("value1"),spread("value1"),count("value1") FROM s3; +-- sqlite fdw does not have spread() + +-- select abs with order by (explain) +--Testcase 16: +EXPLAIN VERBOSE +SELECT value1, abs(1-value1) FROM s3 order by abs(1-value1); + +-- select abs with order by (result) +--Testcase 17: +SELECT value1, abs(1-value1) FROM s3 order by abs(1-value1); + +-- select abs with order by index (result) +--Testcase 18: +SELECT value1, abs(1-value1) FROM s3 order by 2,1; + +-- select abs with order by index (result) +--Testcase 19: +SELECT value1, abs(1-value1) FROM s3 order by 1,2; + +-- select abs and as +--Testcase 20: +SELECT abs(value3) as abs1 FROM s3; + +-- select spread over join query (explain) +-- EXPLAIN VERBOSE +-- SELECT spread(t1.value1), spread(t2.value1) FROM s3 t1 INNER JOIN s3 t2 ON (t1.value1 = t2.value1) where t1.value1 = 0.1; +-- sqlite fdw does not have spread() + +-- select spread over join query (result, stub call error) +-- SELECT spread(t1.value1), spread(t2.value1) FROM s3 t1 INNER JOIN s3 t2 ON (t1.value1 = t2.value1) where t1.value1 = 0.1; +-- sqlite fdw does not have spread() + +-- select spread with having (explain) +-- EXPLAIN VERBOSE +-- SELECT spread(value1) FROM s3 HAVING spread(value1) > 100; +-- sqlite fdw does not have spread() + +-- select spread with having (explain, cannot pushdown, stub call error) +-- SELECT spread(value1) FROM s3 HAVING spread(value1) > 100; +-- sqlite fdw does not have spread() + +-- select abs with arithmetic and tag in the middle (explain) +--Testcase 21: +EXPLAIN VERBOSE +SELECT abs(value1) + 1, value2, tag1, sqrt(value2) FROM s3; + +-- select abs with arithmetic and tag in the middle (result) +--Testcase 22: +SELECT abs(value1) + 1, value2, tag1, sqrt(value2) FROM s3; + +-- select with order by limit (explain) +--Testcase 23: +EXPLAIN VERBOSE +SELECT abs(value1), abs(value3), sqrt(value2) FROM s3 ORDER BY abs(value3) LIMIT 1; + +-- select with order by limit (explain) +--Testcase 24: +SELECT abs(value1), abs(value3), sqrt(value2) FROM s3 ORDER BY abs(value3) LIMIT 1; + +-- select mixing with non pushdown func (all not pushdown, explain) +--Testcase 25: +EXPLAIN VERBOSE +SELECT abs(value1), sqrt(value2), upper(tag1) FROM s3; + +-- select mixing with non pushdown func (result) +--Testcase 26: +SELECT abs(value1), sqrt(value2), upper(tag1) FROM s3; + +-- sqlite data prep + +-- sqlite pushdown supported functions (explain) +--Testcase 27: +EXPLAIN VERBOSE +SELECT abs(value3), length(tag1), lower(str1), ltrim(str2), ltrim(str1, '-'), replace(str1, 'XYZ', 'ABC'), round(value3), rtrim(str1, '-'), rtrim(str2), substr(str1, 4), substr(str1, 4, 3) FROM s3; + +-- sqlite pushdown supported functions (result) +--Testcase 28: +SELECT abs(value3), length(tag1), lower(str1), ltrim(str2), ltrim(str1, '-'), replace(str1, 'XYZ', 'ABC'), round(value3), rtrim(str1, '-'), rtrim(str2), substr(str1, 4), substr(str1, 4, 3) FROM s3; + +-- sqlite pushdown nest functions (explain) +--Testcase 32: +EXPLAIN VERBOSE +SELECT round(abs(value2), 0) FROM s3; + +-- sqlite pushdown nest functions (result) +--Testcase 33: +SELECT round(abs(value2), 0) FROM s3; + +-- select mod (builtin function, explain) +--Testcase 34: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + +-- select mod (builtin function, result) +--Testcase 35: +SELECT value1, mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3; + +-- select mod (builtin function, not pushdown constraints, explain) +--Testcase 36: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + +-- select mod (builtin function, not pushdown constraints, result) +--Testcase 37: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE to_hex(value2) = '64'; + +-- select mod (builtin function, pushdown constraints, explain) +--Testcase 38: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + +-- select mod (builtin function, pushdown constraints, result) +--Testcase 39: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE value2 != 200; + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 40: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + +-- select mod (builtin function, mod in constraints, result) +--Testcase 41: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(value2, 2) != 1; + +-- select mod (builtin function, mod in constraints, explain) +--Testcase 42: +EXPLAIN VERBOSE +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + +-- select mod (builtin function, mod in constraints, result) +--Testcase 43: +SELECT mod(value2, 2), mod(value4, 2), mod(5, 2) FROM s3 WHERE mod(5, 2) > value1; + +-- select mod as nest function with agg (pushdown, explain) +--Testcase 44: +EXPLAIN VERBOSE +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + +-- select mod as nest function with agg (pushdown, result) +--Testcase 45: +SELECT sum(value3),mod(sum(value2), 2) FROM s3; + +-- select mod as nest with abs (pushdown, explain) +--Testcase 46: +EXPLAIN VERBOSE +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + +-- select mod as nest with abs (pushdown, result) +--Testcase 47: +SELECT value1, mod(abs(value2), 2),mod(abs(1/value2), 2) FROM s3; + +-- select mod with non pushdown func and explicit constant (explain) +--Testcase 48: +EXPLAIN VERBOSE +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + +-- select mod with non pushdown func and explicit constant (result) +--Testcase 49: +SELECT value1, mod(value2, 2), pi(), 4.1 FROM s3; + +-- select mod with order by (explain) +--Testcase 50: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + +-- select mod with order by (result) +--Testcase 51: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY mod((1-value2), 2); + +-- select mod with order by index (result) +--Testcase 52: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 2,1; + +-- select mod with order by index (result) +--Testcase 53: +SELECT value1, mod((1-value2), 2) FROM s3 ORDER BY 1,2; + +-- select mod with group by (explain) +--Testcase 54: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + +-- select mod with group by (result) +--Testcase 55: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2); + +-- select mod with group by index (result) +--Testcase 56: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 2,1; + +-- select mod with group by index (result) +--Testcase 57: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2; + +-- select mod with group by having (explain) +--Testcase 58: +EXPLAIN VERBOSE +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + +-- select mod with group by having (result) +--Testcase 59: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY value1, mod((1-value2), 2) HAVING avg(value1) > 0; + +-- select mod with group by index having (result) +--Testcase 60: +SELECT value1, mod((1-value2), 2) FROM s3 GROUP BY 1,2 HAVING value1 > 1; + +-- select mod and as +--Testcase 61: +SELECT value1, mod(value2, 2) as mod1 FROM s3; + +--Testcase 29: +DROP FOREIGN TABLE s3; +--Testcase 30: +DROP SERVER server1; +--Testcase 31: +DROP EXTENSION sqlite_fdw; diff --git a/sql/12.8/sqlite_fdw.sql b/sql/15beta2/sqlite_fdw.sql similarity index 89% rename from sql/12.8/sqlite_fdw.sql rename to sql/15beta2/sqlite_fdw.sql index 9c18231a..589782fc 100644 --- a/sql/12.8/sqlite_fdw.sql +++ b/sql/15beta2/sqlite_fdw.sql @@ -480,25 +480,21 @@ SELECT b, length(b) FROM numbers WHERE length(b) = 4 AND power(1, a) != 0 AND le --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; --- Aggregates in subquery are pushed down. ---Testcase 214: -explain (verbose, costs off) -select count(x.a), sum(x.a) from (select a a, sum(a) b from numbers group by a, abs(a) order by 1, 2) x; ---Testcase 215: -select count(x.a), sum(x.a) from (select a a, sum(a) b from numbers group by a, abs(a) order by 1, 2) x; - --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; @@ -551,6 +547,69 @@ 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; + +-- Executable test case for pushdown CASE expressions (results) +--Testcase 224: +CREATE FOREIGN TABLE case_exp(c1 int OPTIONS (key 'true'), c3 text, c6 varchar(10)) SERVER sqlite_svr; + +--Testcase 225: +INSERT INTO case_exp + SELECT id, + to_char(id, 'FM00000'), + id % 10 + FROM generate_series(1, 10) id; + +--Testcase 226: +SELECT * FROM case_exp; + +-- CASE arg WHEN +--Testcase 227: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); +--Testcase 228: +SELECT * FROM case_exp WHERE c1 > (CASE mod(c1, 4) WHEN 0 THEN 1 WHEN 2 THEN 50 ELSE 100 END); + +-- these are shippable +--Testcase 229: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 230: +SELECT * FROM case_exp WHERE CASE c6 WHEN 'foo' THEN true ELSE c3 < 'bar' END; +--Testcase 231: +EXPLAIN (VERBOSE, COSTS OFF) +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; +--Testcase 232: +SELECT * FROM case_exp WHERE CASE c3 WHEN c6 THEN true ELSE c3 < 'bar' END; + +-- but this is not because of collation +--Testcase 233: +SELECT * FROM case_exp WHERE CASE c3 COLLATE "C" WHEN c6 THEN true ELSE c3 < 'bar' END; + +--Testcase 234: +DELETE FROM case_exp; + --Testcase 142: DROP FUNCTION test_param_WHERE(); --Testcase 143: @@ -571,6 +630,12 @@ DROP FOREIGN TABLE columntest; 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 235: +DROP FOREIGN TABLE case_exp; --Testcase 151: DROP SERVER sqlite_svr; diff --git a/sql/14.0/type.sql b/sql/15beta2/type.sql similarity index 100% rename from sql/14.0/type.sql rename to sql/15beta2/type.sql diff --git a/sql/init_data/init.sql b/sql/init_data/init.sql index 3f969840..1527e6c7 100644 --- a/sql/init_data/init.sql +++ b/sql/init_data/init.sql @@ -6,6 +6,7 @@ DROP TABLE IF EXISTS numbers; DROP TABLE IF EXISTS limittest; DROP TABLE IF EXISTS grem1_1; DROP TABLE IF EXISTS grem1_2; +DROP TABLE IF EXISTS case_exp; 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); @@ -18,6 +19,7 @@ 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 case_exp(c1 int primary key, c3 text, c6 varchar(10)); CREATE TABLE "type_STRING" (col text primary key); CREATE TABLE "type_BOOLEAN" (col boolean primary key); diff --git a/sql/init_data/init_core.sql b/sql/init_data/init_core.sql index 48e8b0e1..a5c946c3 100644 --- a/sql/init_data/init_core.sql +++ b/sql/init_data/init_core.sql @@ -10,6 +10,8 @@ DROP TABLE IF EXISTS INT8_TBL; DROP TABLE IF EXISTS test_having; DROP TABLE IF EXISTS onek; DROP TABLE IF EXISTS tenk1; +DROP TABLE IF EXISTS btg; +DROP TABLE IF EXISTS num_typemod_test; CREATE TABLE FLOAT4_TBL (f1 REAL); CREATE TABLE FLOAT4_TMP (f1 REAL, id integer primary key autoincrement); @@ -156,6 +158,8 @@ CREATE TABLE dates ( date_as_number FLOAT8 ); +CREATE TABLE btg(id int primary key, p int, v text, c float, d float, e int); + .separator "\t" .import /tmp/onek.data onek .import /tmp/onek.data onek2 @@ -259,6 +263,7 @@ CREATE TABLE num_exp_sqrt (id int4, expected numeric, primary key (id)); CREATE TABLE num_exp_ln (id int4, expected numeric, primary key (id)); CREATE TABLE num_exp_log10 (id int4, expected numeric, primary key (id)); CREATE TABLE num_exp_power_10_ln (id int4, expected numeric, primary key (id)); +CREATE TABLE num_variance (a numeric); CREATE TABLE num_result (id1 int4, id2 int4, result numeric, primary key (id1, id2)); CREATE TABLE v (id int4, x numeric, val float8, primary key (id)); @@ -271,6 +276,13 @@ CREATE TABLE num_input_test (n1 numeric); CREATE TABLE num_tmp (n1 numeric, n2 numeric, id integer primary key autoincrement); CREATE TABLE to_number_tbl(a text, id integer primary key autoincrement); +CREATE TABLE num_typemod_test ( + millions numeric(3, -6), + thousands numeric(3, -3), + units numeric(3, 0), + thousandths numeric(3, 3), + millionths numeric(3, 6) +); -- FOR join.sql diff --git a/sqlite_fdw.c b/sqlite_fdw.c index bbfe1ed0..c23289d4 100644 --- a/sqlite_fdw.c +++ b/sqlite_fdw.c @@ -2,7 +2,7 @@ * * SQLite Foreign Data Wrapper for PostgreSQL * - * Portions Copyright (c) 2021, TOSHIBA CORPORATION + * Portions Copyright (c) 2018, TOSHIBA CORPORATION * * IDENTIFICATION * sqlite_fdw.c @@ -75,8 +75,10 @@ PG_MODULE_MAGIC; */ #define DEFAULT_ROW_ESTIMATE 1000000 #define DEFAULTE_NUM_ROWS 1000 -#define IS_KEY_COLUMN(A) ((strcmp(A->defname, "key") == 0) && \ - (strcmp(((Value *)(A->arg))->val.str, "true") == 0)) +#define IS_KEY_COLUMN(A) ((strcmp(A->defname, "key") == 0) && \ + (strcmp(strVal(A->arg), "true") == 0)) + + /* Default CPU cost to start up a foreign query. */ #define DEFAULT_FDW_STARTUP_COST 100.0 @@ -144,7 +146,7 @@ enum FdwModifyPrivateIndex FdwModifyPrivateUpdateSql, /* Integer list of target attribute numbers for INSERT/UPDATE */ FdwModifyPrivateTargetAttnums, - /* Length till the end of VALUES clause (as an integer Value node) */ + /* Length till the end of VALUES clause (as an Integer node) */ FdwModifyPrivateLen }; @@ -161,11 +163,11 @@ enum FdwDirectModifyPrivateIndex { /* SQL statement to execute remotely (as a String node) */ FdwDirectModifyPrivateUpdateSql, - /* has-returning flag (as an integer Value node) */ + /* has-returning flag (as a Boolean node) */ FdwDirectModifyPrivateHasReturning, /* Integer list of attribute numbers retrieved by RETURNING */ FdwDirectModifyPrivateRetrievedAttrs, - /* set-processed flag (as an integer Value node) */ + /* set-processed flag (as a Boolean node) */ FdwDirectModifyPrivateSetProcessed }; @@ -700,22 +702,14 @@ sqlite_get_useful_pathkeys_for_relation(PlannerInfo *root, RelOptInfo *rel) foreach(lc, root->query_pathkeys) { PathKey *pathkey = (PathKey *) lfirst(lc); - EquivalenceClass *pathkey_ec = pathkey->pk_eclass; - Expr *em_expr; - /* * The planner and executor don't have any clever strategy for * taking data sorted by a prefix of the query's pathkeys and * getting it to be sorted by all of those pathkeys. We'll just * end up resorting the entire data set. So, unless we can push * down all of the query pathkeys, forget it. - * - * is_foreign_expr would detect volatile expressions as well, but - * checking ec_has_volatile here saves some cycles. */ - if (pathkey_ec->ec_has_volatile || - !(em_expr = sqlite_find_em_expr_for_rel(pathkey_ec, rel)) || - !sqlite_is_foreign_expr(root, rel, em_expr)) + if (!sqlite_is_foreign_pathkey(root, rel, pathkey)) { query_pathkeys_ok = false; break; @@ -874,7 +868,11 @@ sqliteGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid * is not calling GetForeignUpperPaths */ if (limit_needed(root->parse) && !root->parse->limitOffset && !sqlite_all_baserels_are_foreign(root)) +#if PG_VERSION_NUM >= 150000 + fdw_private = list_make2(makeBoolean(false), makeBoolean(true)); +#else fdw_private = list_make2(makeInteger(false), makeInteger(true)); +#endif /* Create a ForeignPath node and add it as only possible path */ add_path(baserel, (Path *) @@ -1112,8 +1110,14 @@ sqliteGetForeignPlan(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid, */ if (best_path->fdw_private) { +#if PG_VERSION_NUM >= 150000 + has_final_sort = boolVal(list_nth(best_path->fdw_private, FdwPathPrivateHasFinalSort)); + has_limit = boolVal(list_nth(best_path->fdw_private, FdwPathPrivateHasLimit)); + +#else has_final_sort = intVal(list_nth(best_path->fdw_private, FdwPathPrivateHasFinalSort)); has_limit = intVal(list_nth(best_path->fdw_private, FdwPathPrivateHasLimit)); +#endif } /* @@ -2071,8 +2075,8 @@ sqliteExecForeignBatchInsert(EState *estate, * Determine the maximum number of tuples that can be inserted in bulk * * Returns the batch size specified for server or table. When batching is not - * allowed (e.g. for tables with AFTER ROW triggers or with RETURNING clause), - * returns 1. + * allowed (e.g. for tables with BEFORE/AFTER ROW triggers or with RETURNING + * clause), returns 1. */ static int sqliteGetForeignModifyBatchSize(ResultRelInfo *resultRelInfo) @@ -2105,6 +2109,24 @@ sqliteGetForeignModifyBatchSize(ResultRelInfo *resultRelInfo) else batch_size = sqlite_get_batch_size_option(resultRelInfo->ri_RelationDesc); + /* + * Disable batching when there are any BEFORE/AFTER ROW + * INSERT triggers on the foreign table. + * + * When there are any BEFORE ROW INSERT triggers on the table, we can't + * support it, because such triggers might query the table we're inserting + * into and act differently if the tuples that have already been processed + * and prepared for insertion are not there. + */ + if (resultRelInfo->ri_TrigDesc && +#if PG_VERSION_NUM >= 150000 + (resultRelInfo->ri_TrigDesc->trig_insert_before_row || + resultRelInfo->ri_TrigDesc->trig_insert_after_row)) +#else + resultRelInfo->ri_TrigDesc->trig_insert_after_row) +#endif + return 1; + /* * The batch size is used specified for server/table. Make sure we don't * exceed this limit by using the maximum batch_size possible. @@ -2410,9 +2432,15 @@ sqlitePlanDirectModify(PlannerInfo *root, * Items in the list must match enum FdwDirectModifyPrivateIndex, above. */ fscan->fdw_private = list_make4(makeString(sql.data), +#if PG_VERSION_NUM >= 150000 + makeBoolean((retrieved_attrs != NIL)), + retrieved_attrs, + makeBoolean(plan->canSetTag)); +#else makeInteger(0), retrieved_attrs, makeInteger(plan->canSetTag)); +#endif /* * Update the foreign-join-related fields. @@ -2501,12 +2529,19 @@ sqliteBeginDirectModify(ForeignScanState *node, int eflags) /* Get private info created by planner functions. */ dmstate->query = strVal(list_nth(fsplan->fdw_private, FdwDirectModifyPrivateUpdateSql)); +#if (PG_VERSION_NUM >= 150000) + dmstate->has_returning = boolVal(list_nth(fsplan->fdw_private, + FdwDirectModifyPrivateHasReturning)); + dmstate->set_processed = boolVal(list_nth(fsplan->fdw_private, + FdwDirectModifyPrivateSetProcessed)); +#else dmstate->has_returning = intVal(list_nth(fsplan->fdw_private, FdwDirectModifyPrivateHasReturning)); - dmstate->retrieved_attrs = (List *) list_nth(fsplan->fdw_private, - FdwDirectModifyPrivateRetrievedAttrs); dmstate->set_processed = intVal(list_nth(fsplan->fdw_private, FdwDirectModifyPrivateSetProcessed)); +#endif + dmstate->retrieved_attrs = (List *) list_nth(fsplan->fdw_private, + FdwDirectModifyPrivateRetrievedAttrs); /* Create context for per-tuple temp workspace. */ dmstate->temp_cxt = AllocSetContextCreate(estate->es_query_cxt, @@ -3618,7 +3653,7 @@ static bool sqlite_foreign_grouping_ok(PlannerInfo *root, RelOptInfo *grouped_rel) { Query *query = root->parse; - PathTarget *grouping_target = root->upper_targets[UPPERREL_GROUP_AGG]; + PathTarget *grouping_target; SqliteFdwRelationInfo *fpinfo = (SqliteFdwRelationInfo *) grouped_rel->fdw_private; SqliteFdwRelationInfo *ofpinfo; List *aggvars; @@ -3626,6 +3661,12 @@ sqlite_foreign_grouping_ok(PlannerInfo *root, RelOptInfo *grouped_rel) int i; List *tlist = NIL; +#if PG_VERSION_NUM < 110000 + grouping_target = root->upper_targets[UPPERREL_GROUP_AGG]; +#else + grouping_target = grouped_rel->reltarget; +#endif + /* Grouping Sets are not pushable */ if (query->groupingSets) return false; @@ -4093,9 +4134,6 @@ sqlite_add_foreign_ordered_paths(PlannerInfo *root, RelOptInfo *input_rel, { PathKey *pathkey = (PathKey *) lfirst(lc); EquivalenceClass *pathkey_ec = pathkey->pk_eclass; - Expr *sort_expr; - RelOptInfo *fallback_rel = (input_rel->reloptkind == RELOPT_UPPER_REL) ? - ifpinfo->outerrel : input_rel; /* * is_foreign_expr would detect volatile expressions as well, but @@ -4104,14 +4142,19 @@ sqlite_add_foreign_ordered_paths(PlannerInfo *root, RelOptInfo *input_rel, if (pathkey_ec->ec_has_volatile) return; - /* Get the sort expression for the pathkey_ec */ - sort_expr = sqlite_find_em_expr_for_input_target(root, - pathkey_ec, - input_rel->reltarget, - fallback_rel); + /* + * Can't push down the sort if pathkey's opfamily is not built-in. + */ + if (!sqlite_is_builtin(pathkey->pk_opfamily)) + return; - /* If it's unsafe to remote, we cannot push down the final sort */ - if (!sqlite_is_foreign_expr(root, input_rel, sort_expr)) + /* + * The EC must contain a shippable EM that is computed in input_rel's + * reltarget, else we can't push down the sort. + */ + if (sqlite_find_em_for_rel_target(root, + pathkey_ec, + input_rel) == NULL) return; } @@ -4130,7 +4173,11 @@ sqlite_add_foreign_ordered_paths(PlannerInfo *root, RelOptInfo *input_rel, * Build the fdw_private list that will be used by sqliteGetForeignPlan. * Items in the list must match order in enum FdwPathPrivateIndex. */ +#if (PG_VERSION_NUM >= 150000) + fdw_private = list_make2(makeBoolean(true), makeBoolean(false)); +#else fdw_private = list_make2(makeInteger(true), makeInteger(false)); +#endif #if (PG_VERSION_NUM >= 120000) /* Create foreign ordering path */ @@ -4322,7 +4369,10 @@ sqlite_add_foreign_final_paths(PlannerInfo *root, RelOptInfo *input_rel, * Build the fdw_private list that will be used by sqliteGetForeignPlan. * Items in the list must match order in enum FdwPathPrivateIndex. */ -#if (PG_VERSION_NUM >= 120000) +#if (PG_VERSION_NUM >= 150000) + fdw_private = list_make2(makeBoolean(has_final_sort), + makeBoolean(extra->limit_needed)); +#elif (PG_VERSION_NUM >= 120000) fdw_private = list_make2(makeInteger(has_final_sort), makeInteger(extra->limit_needed)); #else @@ -5308,47 +5358,57 @@ sqlite_execute_dml_stmt(ForeignScanState *node) } /* - * Find an equivalence class member expression, all of whose Vars, come from - * the indicated relation. + * Given an EquivalenceClass and a foreign relation, find an EC member + * that can be used to sort the relation remotely according to a pathkey + * using this EC. + * + * If there is more than one suitable candidate, return an arbitrary + * one of them. If there is none, return NULL. + * + * This checks that the EC member expression uses only Vars from the given + * rel and is shippable. Caller must separately verify that the pathkey's + * ordering operator is shippable. */ -Expr * -sqlite_find_em_expr_for_rel(EquivalenceClass *ec, RelOptInfo *rel) +EquivalenceMember * +sqlite_find_em_for_rel(PlannerInfo *root, EquivalenceClass *ec, RelOptInfo *rel) { - ListCell *lc_em; + ListCell *lc; - foreach(lc_em, ec->ec_members) + foreach(lc, ec->ec_members) { - EquivalenceMember *em = lfirst(lc_em); + EquivalenceMember *em = (EquivalenceMember *) lfirst(lc); + /* + * Note we require !bms_is_empty, else we'd accept constant + * expressions which are not suitable for the purpose. + */ if (bms_is_subset(em->em_relids, rel->relids) && - !bms_is_empty(em->em_relids)) - { - /* - * If there is more than one equivalence member whose Vars are - * taken entirely from this relation, we'll be content to choose - * any one of those. - */ - return em->em_expr; - } + !bms_is_empty(em->em_relids) && + sqlite_is_foreign_expr(root, rel, em->em_expr)) + return em; } - /* We didn't find any suitable equivalence class expression */ return NULL; } /* - * Find an equivalence class member expression to be computed as a sort column - * in the given target. + * Find an EquivalenceClass member that is to be computed as a sort column + * in the given rel's reltarget, and is shippable. + * + * If there is more than one suitable candidate, return an arbitrary + * one of them. If there is none, return NULL. + * + * This checks that the EC member expression uses only Vars from the given + * rel and is shippable. Caller must separately verify that the pathkey's + * ordering operator is shippable. */ -Expr * -sqlite_find_em_expr_for_input_target(PlannerInfo *root, - EquivalenceClass *ec, - PathTarget *target, - RelOptInfo *fallbackRel) +EquivalenceMember * +sqlite_find_em_for_rel_target(PlannerInfo *root, EquivalenceClass *ec, + RelOptInfo *rel) { + PathTarget *target = rel->reltarget; ListCell *lc1; int i; - Expr *fallback_expr; i = 0; foreach(lc1, target->exprs) @@ -5389,25 +5449,18 @@ sqlite_find_em_expr_for_input_target(PlannerInfo *root, while (em_expr && IsA(em_expr, RelabelType)) em_expr = ((RelabelType *) em_expr)->arg; - if (equal(em_expr, expr)) - return em->em_expr; + if (!equal(em_expr, expr)) + continue; + + /* Check that expression (including relabels!) is shippable */ + if (sqlite_is_foreign_expr(root, rel, em->em_expr)) + return em; } i++; } - /* - * We add this method as fallback in versions prior to PG11/12 because - * target->sortgrouprefs its not filled and this function always fails - * because cannot find sort expression. - */ - fallback_expr = sqlite_find_em_expr_for_rel(ec, fallbackRel); - - if (fallback_expr) - return fallback_expr; - - elog(ERROR, "could not find pathkey item to sort"); - return NULL; /* keep compiler quiet */ + return NULL; } #if PG_VERSION_NUM >= 140000 diff --git a/sqlite_fdw.h b/sqlite_fdw.h index b0abf47e..fe210ec6 100644 --- a/sqlite_fdw.h +++ b/sqlite_fdw.h @@ -2,7 +2,7 @@ * * SQLite Foreign Data Wrapper for PostgreSQL * - * Portions Copyright (c) 2021, TOSHIBA CORPORATION + * Portions Copyright (c) 2018, TOSHIBA CORPORATION * * IDENTIFICATION * sqlite_fdw.h @@ -50,7 +50,7 @@ #endif /* Code version is updated at new release. */ -#define CODE_VERSION 20101 +#define CODE_VERSION 20200 #if (PG_VERSION_NUM < 100000) /* @@ -288,14 +288,19 @@ extern bool sqlite_is_foreign_expr(PlannerInfo *root, extern bool sqlite_is_foreign_param(PlannerInfo *root, RelOptInfo *baserel, Expr *expr); +extern bool sqlite_is_foreign_pathkey(PlannerInfo *root, + RelOptInfo *baserel, + PathKey *pathkey); extern bool sqlite_is_foreign_function_tlist(PlannerInfo *root, RelOptInfo *baserel, List *tlist); +extern bool sqlite_is_builtin(Oid objectId); -extern Expr *sqlite_find_em_expr_for_rel(EquivalenceClass *ec, RelOptInfo *rel); -extern Expr *sqlite_find_em_expr_for_input_target(PlannerInfo *root, +extern EquivalenceMember *sqlite_find_em_for_rel(PlannerInfo *root, + EquivalenceClass *ec, + RelOptInfo *rel); +extern EquivalenceMember *sqlite_find_em_for_rel_target(PlannerInfo *root, EquivalenceClass *ec, - PathTarget *target, RelOptInfo *fallbackRel); /* in sqlite_fdw.c */ diff --git a/test.sh b/test.sh index 991ce7aa..54fffc83 100755 --- a/test.sh +++ b/test.sh @@ -11,5 +11,5 @@ sqlite3 /tmp/sqlitefdw_test_selectfunc.db < sql/init_data/init_selectfunc.sql sed -i 's/REGRESS =.*/REGRESS = extra\/sqlite_fdw_post extra\/float4 extra\/float8 extra\/int4 extra\/int8 extra\/numeric extra\/join extra\/limit extra\/aggregates extra\/prepare extra\/select_having extra\/select extra\/insert extra\/update extra\/timestamp sqlite_fdw type aggregate selectfunc /' Makefile make clean -make -make check | tee make_check.out +make $1 +make check $1 | tee make_check.out