From a1396612886314ba447952560c2281f447fddd87 Mon Sep 17 00:00:00 2001 From: Shigeru Hanada Date: Thu, 24 Feb 2011 20:05:01 +0900 Subject: [PATCH] Add regression tests for postgresql_fdw, about prepared statement. --- .../postgresql_fdw/expected/postgresql_fdw.out | 16 ++++++++++++++++ contrib/postgresql_fdw/sql/postgresql_fdw.sql | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/contrib/postgresql_fdw/expected/postgresql_fdw.out b/contrib/postgresql_fdw/expected/postgresql_fdw.out index 058627f9cc..91cd6c10c7 100644 --- a/contrib/postgresql_fdw/expected/postgresql_fdw.out +++ b/contrib/postgresql_fdw/expected/postgresql_fdw.out @@ -117,6 +117,22 @@ EXPLAIN (COSTS FALSE) SELECT * FROM ft1 WHERE c1 = 1 AND c2 = lower('FOO') AND c Remote SQL: SELECT c1, c2, c3 FROM public.t1 WHERE ((c3 < now()) AND (c1 = 1) AND (c2 = 'foo'::text)) (3 rows) +-- prepared statement +PREPARE st(int) AS SELECT * FROM ft1 WHERE c1 > $1 ORDER BY c1; +EXECUTE st(1); + c1 | c2 | c3 +----+-----+------------ + 2 | bar | 01-02-1970 + 3 | buz | 01-03-1970 +(2 rows) + +EXECUTE st(2); + c1 | c2 | c3 +----+-----+------------ + 3 | buz | 01-03-1970 +(1 row) + +DEALLOCATE st; -- clean up DROP FOREIGN DATA WRAPPER postgresql_fdw CASCADE; NOTICE: drop cascades to 6 other objects diff --git a/contrib/postgresql_fdw/sql/postgresql_fdw.sql b/contrib/postgresql_fdw/sql/postgresql_fdw.sql index 23edc534a0..a9632078cb 100644 --- a/contrib/postgresql_fdw/sql/postgresql_fdw.sql +++ b/contrib/postgresql_fdw/sql/postgresql_fdw.sql @@ -79,6 +79,11 @@ SELECT * FROM ft1 t1 LEFT JOIN ft2 t2 ON (t1.c1 = t2.c1) ORDER BY 1,2,3,4,5,6; -- WHERE clause push-down SELECT * FROM ft1 WHERE c1 = 1 AND c2 = lower('FOO') AND c3 < now() and c3 < clock_timestamp(); EXPLAIN (COSTS FALSE) SELECT * FROM ft1 WHERE c1 = 1 AND c2 = lower('FOO') AND c3 < now() and c3 < clock_timestamp(); +-- prepared statement +PREPARE st(int) AS SELECT * FROM ft1 WHERE c1 > $1 ORDER BY c1; +EXECUTE st(1); +EXECUTE st(2); +DEALLOCATE st; -- clean up DROP FOREIGN DATA WRAPPER postgresql_fdw CASCADE; -- 2.39.5