You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
(28) |
Jun
(12) |
Jul
(11) |
Aug
(12) |
Sep
(5) |
Oct
(19) |
Nov
(14) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(18) |
Feb
(30) |
Mar
(115) |
Apr
(89) |
May
(50) |
Jun
(44) |
Jul
(22) |
Aug
(13) |
Sep
(11) |
Oct
(30) |
Nov
(28) |
Dec
(39) |
2012 |
Jan
(38) |
Feb
(18) |
Mar
(43) |
Apr
(91) |
May
(108) |
Jun
(46) |
Jul
(37) |
Aug
(44) |
Sep
(33) |
Oct
(29) |
Nov
(36) |
Dec
(15) |
2013 |
Jan
(35) |
Feb
(611) |
Mar
(5) |
Apr
(55) |
May
(30) |
Jun
(28) |
Jul
(458) |
Aug
(34) |
Sep
(9) |
Oct
(39) |
Nov
(22) |
Dec
(32) |
2014 |
Jan
(16) |
Feb
(16) |
Mar
(42) |
Apr
(179) |
May
(7) |
Jun
(6) |
Jul
(9) |
Aug
|
Sep
(4) |
Oct
|
Nov
(3) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
1
(3) |
2
(5) |
3
|
4
(4) |
5
|
6
|
7
(7) |
8
(10) |
9
(6) |
10
(5) |
11
(1) |
12
|
13
|
14
|
15
|
16
|
17
(4) |
18
(1) |
19
|
20
|
21
(5) |
22
(15) |
23
(18) |
24
(7) |
25
(4) |
26
|
27
|
28
(3) |
29
(2) |
30
(11) |
31
(4) |
|
|
From: Michael P. <mic...@us...> - 2011-03-22 17:51:57
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 0e51d7efa87f0d0011cee8927118080514d96228 (commit) from 5e0c62f09c4584c9918dca06e5a5770a2e7bd472 (commit) - Log ----------------------------------------------------------------- commit 0e51d7efa87f0d0011cee8927118080514d96228 Author: Michael P <mic...@us...> Date: Wed Mar 23 02:51:01 2011 +0900 Fix for regression test plancache PREPARE, EXECUTE and TEMP TABLE are not yet supported by Postgres-XC, so this output is correct. diff --git a/src/test/regress/expected/plancache_1.out b/src/test/regress/expected/plancache_1.out new file mode 100644 index 0000000..389d0da --- /dev/null +++ b/src/test/regress/expected/plancache_1.out @@ -0,0 +1,209 @@ +-- +-- Tests to exercise the plan caching/invalidation mechanism +-- +CREATE TEMP TABLE pcachetest AS SELECT * FROM int8_tbl; +ERROR: INTO clause not yet supported +-- create and use a cached plan +PREPARE prepstmt AS SELECT * FROM pcachetest ORDER BY q1, q2; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +EXECUTE prepstmt; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- and one with parameters +PREPARE prepstmt2(bigint) AS SELECT * FROM pcachetest WHERE q1 = $1 ORDER BY q1, q2; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +EXECUTE prepstmt2(123); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- invalidate the plans and see what happens +DROP TABLE pcachetest; +ERROR: table "pcachetest" does not exist +EXECUTE prepstmt; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +EXECUTE prepstmt2(123); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- recreate the temp table (this demonstrates that the raw plan is +-- purely textual and doesn't depend on OIDs, for instance) +CREATE TEMP TABLE pcachetest AS SELECT * FROM int8_tbl ORDER BY q1, q2; +ERROR: INTO clause not yet supported +EXECUTE prepstmt; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +EXECUTE prepstmt2(123); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- prepared statements should prevent change in output tupdesc, +-- since clients probably aren't expecting that to change on the fly +ALTER TABLE pcachetest ADD COLUMN q3 bigint; +ERROR: relation "pcachetest" does not exist +EXECUTE prepstmt; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +EXECUTE prepstmt2(123); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- but we're nice guys and will let you undo your mistake +ALTER TABLE pcachetest DROP COLUMN q3; +ERROR: relation "pcachetest" does not exist +EXECUTE prepstmt; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +EXECUTE prepstmt2(123); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- Try it with a view, which isn't directly used in the resulting plan +-- but should trigger invalidation anyway +CREATE TEMP VIEW pcacheview AS + SELECT * FROM pcachetest; +ERROR: relation "pcachetest" does not exist +LINE 2: SELECT * FROM pcachetest; + ^ +PREPARE vprep AS SELECT * FROM pcacheview ORDER BY q1, q2; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +EXECUTE vprep; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +CREATE OR REPLACE TEMP VIEW pcacheview AS + SELECT q1, q2/2 AS q2 FROM pcachetest ORDER BY q1, q2; +ERROR: relation "pcachetest" does not exist +LINE 2: SELECT q1, q2/2 AS q2 FROM pcachetest ORDER BY q1, q2; + ^ +EXECUTE vprep; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- Check basic SPI plan invalidation +create function cache_test(int) returns int as $$ +declare total int; +begin + create temp table t1(f1 int); + insert into t1 values($1); + insert into t1 values(11); + insert into t1 values(12); + insert into t1 values(13); + select sum(f1) into total from t1; + drop table t1; + return total; +end +$$ language plpgsql; +select cache_test(1); +ERROR: PG-XC does not yet support temporary tables +CONTEXT: SQL statement "create temp table t1(f1 int)" +PL/pgSQL function "cache_test" line 3 at SQL statement +select cache_test(2); +ERROR: PG-XC does not yet support temporary tables +CONTEXT: SQL statement "create temp table t1(f1 int)" +PL/pgSQL function "cache_test" line 3 at SQL statement +select cache_test(3); +ERROR: PG-XC does not yet support temporary tables +CONTEXT: SQL statement "create temp table t1(f1 int)" +PL/pgSQL function "cache_test" line 3 at SQL statement +-- Check invalidation of plpgsql "simple expression" +create temp view v1 as + select 2+2 as f1; +ERROR: PG-XC does not yet support temporary tables +create function cache_test_2() returns int as $$ +begin + return f1 from v1; +end$$ language plpgsql; +select cache_test_2(); +ERROR: relation "v1" does not exist +LINE 1: SELECT f1 from v1 + ^ +QUERY: SELECT f1 from v1 +CONTEXT: PL/pgSQL function "cache_test_2" line 2 at RETURN +create or replace temp view v1 as + select 2+2+4 as f1; +ERROR: PG-XC does not yet support temporary tables +select cache_test_2(); +ERROR: relation "v1" does not exist +LINE 1: SELECT f1 from v1 + ^ +QUERY: SELECT f1 from v1 +CONTEXT: PL/pgSQL function "cache_test_2" line 2 at RETURN +create or replace temp view v1 as + select 2+2+4+(select max(unique1) from tenk1) as f1; +ERROR: PG-XC does not yet support temporary tables +select cache_test_2(); +ERROR: relation "v1" does not exist +LINE 1: SELECT f1 from v1 + ^ +QUERY: SELECT f1 from v1 +CONTEXT: PL/pgSQL function "cache_test_2" line 2 at RETURN +--- Check that change of search_path is ignored by replans +create schema s1 + create table abc (f1 int); +create schema s2 + create table abc (f1 int); +insert into s1.abc values(123); +insert into s2.abc values(456); +set search_path = s1; +prepare p1 as select f1 from abc; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +execute p1; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +set search_path = s2; +select f1 from abc; +ERROR: relation "abc" does not exist +execute p1; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +alter table s1.abc add column f2 float8; -- force replan +execute p1; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +drop schema s1 cascade; +NOTICE: drop cascades to table s1.abc +drop schema s2 cascade; +NOTICE: drop cascades to table abc +reset search_path; +-- Check that invalidation deals with regclass constants +create temp sequence seq; +ERROR: Postgres-XC does not support TEMPORARY SEQUENCE yet +DETAIL: The feature is not currently supported +prepare p2 as select nextval('seq'); +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +execute p2; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +drop sequence seq; +ERROR: sequence "seq" does not exist +create temp sequence seq; +ERROR: Postgres-XC does not support TEMPORARY SEQUENCE yet +DETAIL: The feature is not currently supported +execute p2; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- Check DDL via SPI, immediately followed by SPI plan re-use +-- (bug in original coding) +create function cachebug() returns void as $$ +declare r int; +begin + drop table if exists temptable cascade; + create temp table temptable as select * from generate_series(1,3) as f1; + create temp view vv as select * from temptable; + for r in select * from vv loop + raise notice '%', r; + end loop; +end$$ language plpgsql; +select cachebug(); +NOTICE: table "temptable" does not exist, skipping +CONTEXT: SQL statement "drop table if exists temptable cascade" +PL/pgSQL function "cachebug" line 3 at SQL statement +ERROR: INTO clause not yet supported +CONTEXT: SQL statement "create temp table temptable as select * from generate_series(1,3) as f1" +PL/pgSQL function "cachebug" line 4 at SQL statement +select cachebug(); +NOTICE: table "temptable" does not exist, skipping +CONTEXT: SQL statement "drop table if exists temptable cascade" +PL/pgSQL function "cachebug" line 3 at SQL statement +ERROR: INTO clause not yet supported +CONTEXT: SQL statement "create temp table temptable as select * from generate_series(1,3) as f1" +PL/pgSQL function "cachebug" line 4 at SQL statement ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/plancache_1.out | 209 +++++++++++++++++++++++++++++ 1 files changed, 209 insertions(+), 0 deletions(-) create mode 100644 src/test/regress/expected/plancache_1.out hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 17:29:51
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 5e0c62f09c4584c9918dca06e5a5770a2e7bd472 (commit) from 9265ae6c81b0bf499ab010736125f7ffca812c0e (commit) - Log ----------------------------------------------------------------- commit 5e0c62f09c4584c9918dca06e5a5770a2e7bd472 Author: Michael P <mic...@us...> Date: Wed Mar 23 02:28:19 2011 +0900 Fix for regression test delete SERIAL is not supported yet by XC, so this output is correct. diff --git a/src/test/regress/expected/delete_1.out b/src/test/regress/expected/delete_1.out new file mode 100644 index 0000000..ec6d4a4 --- /dev/null +++ b/src/test/regress/expected/delete_1.out @@ -0,0 +1,37 @@ +CREATE TABLE delete_test ( + id SERIAL PRIMARY KEY, + a INT +); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +INSERT INTO delete_test (a) VALUES (10); +ERROR: relation "delete_test" does not exist +LINE 1: INSERT INTO delete_test (a) VALUES (10); + ^ +INSERT INTO delete_test (a) VALUES (50); +ERROR: relation "delete_test" does not exist +LINE 1: INSERT INTO delete_test (a) VALUES (50); + ^ +INSERT INTO delete_test (a) VALUES (100); +ERROR: relation "delete_test" does not exist +LINE 1: INSERT INTO delete_test (a) VALUES (100); + ^ +-- allow an alias to be specified for DELETE's target table +DELETE FROM delete_test AS dt WHERE dt.a > 75; +ERROR: relation "delete_test" does not exist +LINE 1: DELETE FROM delete_test AS dt WHERE dt.a > 75; + ^ +-- if an alias is specified, don't allow the original table name +-- to be referenced +DELETE FROM delete_test dt WHERE delete_test.a > 25; +ERROR: relation "delete_test" does not exist +LINE 1: DELETE FROM delete_test dt WHERE delete_test.a > 25; + ^ +SELECT * FROM delete_test; +ERROR: relation "delete_test" does not exist +LINE 1: SELECT * FROM delete_test; + ^ +DROP TABLE delete_test ORDER BY id; +ERROR: syntax error at or near "ORDER" +LINE 1: DROP TABLE delete_test ORDER BY id; + ^ ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/delete_1.out | 37 ++++++++++++++++++++++++++++++++ 1 files changed, 37 insertions(+), 0 deletions(-) create mode 100644 src/test/regress/expected/delete_1.out hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 17:10:00
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 9265ae6c81b0bf499ab010736125f7ffca812c0e (commit) from 894c0a4564c20ec339b6d9a098af8e19d439b81a (commit) - Log ----------------------------------------------------------------- commit 9265ae6c81b0bf499ab010736125f7ffca812c0e Author: Michael P <mic...@us...> Date: Wed Mar 23 02:08:59 2011 +0900 Fix for regression test update Distribution column cannot be updated in current version of Postgres-XC, so this output is correct. diff --git a/src/test/regress/expected/update_1.out b/src/test/regress/expected/update_1.out new file mode 100644 index 0000000..2227eaa --- /dev/null +++ b/src/test/regress/expected/update_1.out @@ -0,0 +1,94 @@ +-- +-- UPDATE syntax tests +-- +CREATE TABLE update_test ( + a INT DEFAULT 10, + b INT, + c TEXT +); +INSERT INTO update_test VALUES (5, 10, 'foo'); +INSERT INTO update_test(b, a) VALUES (15, 10); +SELECT * FROM update_test ORDER BY a, b, c; + a | b | c +----+----+----- + 5 | 10 | foo + 10 | 15 | +(2 rows) + +UPDATE update_test SET a = DEFAULT, b = DEFAULT; +ERROR: Partition column can't be updated in current version +SELECT * FROM update_test ORDER BY a, b, c; + a | b | c +----+----+----- + 5 | 10 | foo + 10 | 15 | +(2 rows) + +-- aliases for the UPDATE target table +UPDATE update_test AS t SET b = 10 WHERE t.a = 10; +SELECT * FROM update_test ORDER BY a, b, c; + a | b | c +----+----+----- + 5 | 10 | foo + 10 | 10 | +(2 rows) + +UPDATE update_test t SET b = t.b + 10 WHERE t.a = 10; +SELECT * FROM update_test ORDER BY a, b, c; + a | b | c +----+----+----- + 5 | 10 | foo + 10 | 20 | +(2 rows) + +-- +-- Test VALUES in FROM +-- +UPDATE update_test SET a=v.i FROM (VALUES(100, 20)) AS v(i, j) + WHERE update_test.b = v.j; +ERROR: Partition column can't be updated in current version +SELECT * FROM update_test ORDER BY a, b, c; + a | b | c +----+----+----- + 5 | 10 | foo + 10 | 20 | +(2 rows) + +-- +-- Test multiple-set-clause syntax +-- +UPDATE update_test SET (c,b,a) = ('bugle', b+11, DEFAULT) WHERE c = 'foo'; +ERROR: Partition column can't be updated in current version +SELECT * FROM update_test ORDER BY a, b, c; + a | b | c +----+----+----- + 5 | 10 | foo + 10 | 20 | +(2 rows) + +UPDATE update_test SET (c,b) = ('car', a+b), a = a + 1 WHERE a = 10; +ERROR: Partition column can't be updated in current version +SELECT * FROM update_test ORDER BY a, b, c; + a | b | c +----+----+----- + 5 | 10 | foo + 10 | 20 | +(2 rows) + +-- fail, multi assignment to same column: +UPDATE update_test SET (c,b) = ('car', a+b), b = a + 1 WHERE a = 10; +ERROR: multiple assignments to same column "b" +-- XXX this should work, but doesn't yet: +UPDATE update_test SET (a,b) = (select a,b FROM update_test where c = 'foo') + WHERE a = 10; +ERROR: syntax error at or near "select" +LINE 1: UPDATE update_test SET (a,b) = (select a,b FROM update_test ... + ^ +-- if an alias for the target table is specified, don't allow references +-- to the original table name +UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a = 10; +ERROR: invalid reference to FROM-clause entry for table "update_test" +LINE 1: UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a... + ^ +HINT: Perhaps you meant to reference the table alias "t". +DROP TABLE update_test; ----------------------------------------------------------------------- Summary of changes: .../regress/expected/{update.out => update_1.out} | 40 +++++++++++--------- 1 files changed, 22 insertions(+), 18 deletions(-) copy src/test/regress/expected/{update.out => update_1.out} (80%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 16:35:15
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 894c0a4564c20ec339b6d9a098af8e19d439b81a (commit) from 75bff5c22b1d721af3ef88268c5c15624ed0b1d3 (commit) - Log ----------------------------------------------------------------- commit 894c0a4564c20ec339b6d9a098af8e19d439b81a Author: Michael P <mic...@us...> Date: Wed Mar 23 01:34:26 2011 +0900 Fix for regression test guc SAVEPOINT and TEMP tables are not supported yet by XC, so this output is correct. diff --git a/src/test/regress/expected/guc_1.out b/src/test/regress/expected/guc_1.out new file mode 100644 index 0000000..d71a66c --- /dev/null +++ b/src/test/regress/expected/guc_1.out @@ -0,0 +1,610 @@ +-- pg_regress should ensure that this default value applies; however +-- we can't rely on any specific default value of vacuum_cost_delay +SHOW datestyle; + DateStyle +--------------- + Postgres, MDY +(1 row) + +-- SET to some nondefault value +SET vacuum_cost_delay TO 40; +SET datestyle = 'ISO, YMD'; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 40ms +(1 row) + +SHOW datestyle; + DateStyle +----------- + ISO, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +-- SET LOCAL has no effect outside of a transaction +SET LOCAL vacuum_cost_delay TO 50; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 40ms +(1 row) + +SET LOCAL datestyle = 'SQL'; +SHOW datestyle; + DateStyle +----------- + ISO, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +-- SET LOCAL within a transaction that commits +BEGIN; +SET LOCAL vacuum_cost_delay TO 50; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 50ms +(1 row) + +SET LOCAL datestyle = 'SQL'; +SHOW datestyle; + DateStyle +----------- + SQL, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------- + 08/13/2006 12:34:56 PDT +(1 row) + +COMMIT; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 40ms +(1 row) + +SHOW datestyle; + DateStyle +----------- + ISO, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +-- SET should be reverted after ROLLBACK +BEGIN; +SET vacuum_cost_delay TO 60; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 60ms +(1 row) + +SET datestyle = 'German'; +SHOW datestyle; + DateStyle +------------- + German, DMY +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------- + 13.08.2006 12:34:56 PDT +(1 row) + +ROLLBACK; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 40ms +(1 row) + +SHOW datestyle; + DateStyle +----------- + ISO, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +-- Some tests with subtransactions +BEGIN; +SET vacuum_cost_delay TO 70; +SET datestyle = 'MDY'; +SHOW datestyle; + DateStyle +----------- + ISO, MDY +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +SAVEPOINT first_sp; +ERROR: SAVEPOINT is not yet supported. +SET vacuum_cost_delay TO 80; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW vacuum_cost_delay; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SET datestyle = 'German, DMY'; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW datestyle; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT '2006-08-13 12:34:56'::timestamptz; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK TO first_sp; +ERROR: no such savepoint +SHOW datestyle; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT '2006-08-13 12:34:56'::timestamptz; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SAVEPOINT second_sp; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SET vacuum_cost_delay TO 90; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SET datestyle = 'SQL, YMD'; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW datestyle; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT '2006-08-13 12:34:56'::timestamptz; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SAVEPOINT third_sp; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SET vacuum_cost_delay TO 100; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW vacuum_cost_delay; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SET datestyle = 'Postgres, MDY'; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW datestyle; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT '2006-08-13 12:34:56'::timestamptz; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK TO third_sp; +ERROR: no such savepoint +SHOW vacuum_cost_delay; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW datestyle; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT '2006-08-13 12:34:56'::timestamptz; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK TO second_sp; +ERROR: no such savepoint +SHOW vacuum_cost_delay; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW datestyle; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT '2006-08-13 12:34:56'::timestamptz; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 40ms +(1 row) + +SHOW datestyle; + DateStyle +----------- + ISO, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +-- SET LOCAL with Savepoints +BEGIN; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 40ms +(1 row) + +SHOW datestyle; + DateStyle +----------- + ISO, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +SAVEPOINT sp; +ERROR: SAVEPOINT is not yet supported. +SET LOCAL vacuum_cost_delay TO 30; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW vacuum_cost_delay; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SET LOCAL datestyle = 'Postgres, MDY'; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW datestyle; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT '2006-08-13 12:34:56'::timestamptz; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK TO sp; +ERROR: no such savepoint +SHOW vacuum_cost_delay; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW datestyle; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT '2006-08-13 12:34:56'::timestamptz; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 40ms +(1 row) + +SHOW datestyle; + DateStyle +----------- + ISO, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +-- SET LOCAL persists through RELEASE (which was not true in 8.0-8.2) +BEGIN; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 40ms +(1 row) + +SHOW datestyle; + DateStyle +----------- + ISO, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +SAVEPOINT sp; +ERROR: SAVEPOINT is not yet supported. +SET LOCAL vacuum_cost_delay TO 30; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW vacuum_cost_delay; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SET LOCAL datestyle = 'Postgres, MDY'; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW datestyle; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT '2006-08-13 12:34:56'::timestamptz; +ERROR: current transaction is aborted, commands ignored until end of transaction block +RELEASE SAVEPOINT sp; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW vacuum_cost_delay; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SHOW datestyle; +ERROR: current transaction is aborted, commands ignored until end of transaction block +SELECT '2006-08-13 12:34:56'::timestamptz; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ROLLBACK; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 40ms +(1 row) + +SHOW datestyle; + DateStyle +----------- + ISO, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +-- SET followed by SET LOCAL +BEGIN; +SET vacuum_cost_delay TO 40; +SET LOCAL vacuum_cost_delay TO 50; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 50ms +(1 row) + +SET datestyle = 'ISO, DMY'; +SET LOCAL datestyle = 'Postgres, MDY'; +SHOW datestyle; + DateStyle +--------------- + Postgres, MDY +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------------ + Sun Aug 13 12:34:56 2006 PDT +(1 row) + +COMMIT; +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 40ms +(1 row) + +SHOW datestyle; + DateStyle +----------- + ISO, DMY +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +-- +-- Test RESET. We use datestyle because the reset value is forced by +-- pg_regress, so it doesn't depend on the installation's configuration. +-- +SET datestyle = iso, ymd; +SHOW datestyle; + DateStyle +----------- + ISO, YMD +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------ + 2006-08-13 12:34:56-07 +(1 row) + +RESET datestyle; +SHOW datestyle; + DateStyle +--------------- + Postgres, MDY +(1 row) + +SELECT '2006-08-13 12:34:56'::timestamptz; + timestamptz +------------------------------ + Sun Aug 13 12:34:56 2006 PDT +(1 row) + +-- +-- Test DISCARD TEMP +-- +CREATE TEMP TABLE reset_test ( data text ) ON COMMIT DELETE ROWS; +ERROR: PG-XC does not yet support temporary tables +SELECT relname FROM pg_class WHERE relname = 'reset_test'; + relname +--------- +(0 rows) + +DISCARD TEMP; +SELECT relname FROM pg_class WHERE relname = 'reset_test'; + relname +--------- +(0 rows) + +-- +-- Test DISCARD ALL +-- +-- do changes +DECLARE foo CURSOR WITH HOLD FOR SELECT 1; +PREPARE foo AS SELECT 1; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +LISTEN foo_event; +SET vacuum_cost_delay = 13; +CREATE TEMP TABLE tmp_foo (data text) ON COMMIT DELETE ROWS; +ERROR: PG-XC does not yet support temporary tables +CREATE ROLE temp_reset_user; +SET SESSION AUTHORIZATION temp_reset_user; +-- look changes +SELECT pg_listening_channels(); + pg_listening_channels +----------------------- + foo_event +(1 row) + +SELECT name FROM pg_prepared_statements; + name +------ +(0 rows) + +SELECT name FROM pg_cursors; + name +------ + foo +(1 row) + +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 13ms +(1 row) + +SELECT relname from pg_class where relname = 'tmp_foo'; + relname +--------- +(0 rows) + +SELECT current_user = 'temp_reset_user'; + ?column? +---------- + t +(1 row) + +-- discard everything +DISCARD ALL; +-- look again +SELECT pg_listening_channels(); + pg_listening_channels +----------------------- +(0 rows) + +SELECT name FROM pg_prepared_statements; + name +------ +(0 rows) + +SELECT name FROM pg_cursors; + name +------ +(0 rows) + +SHOW vacuum_cost_delay; + vacuum_cost_delay +------------------- + 0 +(1 row) + +SELECT relname from pg_class where relname = 'tmp_foo'; + relname +--------- +(0 rows) + +SELECT current_user = 'temp_reset_user'; + ?column? +---------- + f +(1 row) + +DROP ROLE temp_reset_user; +-- +-- Tests for function-local GUC settings +-- +set work_mem = '3MB'; +create function report_guc(text) returns text as +$$ select current_setting($1) $$ language sql +set work_mem = '1MB'; +select report_guc('work_mem'), current_setting('work_mem'); + report_guc | current_setting +------------+----------------- + 1MB | 3MB +(1 row) + +-- this should draw only a warning +alter function report_guc(text) set search_path = no_such_schema; +NOTICE: schema "no_such_schema" does not exist +-- with error occurring here +select report_guc('work_mem'), current_setting('work_mem'); +ERROR: schema "no_such_schema" does not exist +alter function report_guc(text) reset search_path set work_mem = '2MB'; +select report_guc('work_mem'), current_setting('work_mem'); + report_guc | current_setting +------------+----------------- + 2MB | 3MB +(1 row) + +alter function report_guc(text) reset all; +select report_guc('work_mem'), current_setting('work_mem'); + report_guc | current_setting +------------+----------------- + 3MB | 3MB +(1 row) + +-- SET LOCAL is restricted by a function SET option +create or replace function myfunc(int) returns text as $$ +begin + set local work_mem = '2MB'; + return current_setting('work_mem'); +end $$ +language plpgsql +set work_mem = '1MB'; +select myfunc(0), current_setting('work_mem'); + myfunc | current_setting +--------+----------------- + 2MB | 3MB +(1 row) + +alter function myfunc(int) reset all; +select myfunc(0), current_setting('work_mem'); + myfunc | current_setting +--------+----------------- + 2MB | 2MB +(1 row) + +set work_mem = '3MB'; +-- but SET isn't +create or replace function myfunc(int) returns text as $$ +begin + set work_mem = '2MB'; + return current_setting('work_mem'); +end $$ +language plpgsql +set work_mem = '1MB'; +select myfunc(0), current_setting('work_mem'); + myfunc | current_setting +--------+----------------- + 2MB | 2MB +(1 row) + +set work_mem = '3MB'; +-- it should roll back on error, though +create or replace function myfunc(int) returns text as $$ +begin + set work_mem = '2MB'; + perform 1/$1; + return current_setting('work_mem'); +end $$ +language plpgsql +set work_mem = '1MB'; +select myfunc(0); +ERROR: division by zero +CONTEXT: SQL statement "SELECT 1/$1" +PL/pgSQL function "myfunc" line 3 at PERFORM +select current_setting('work_mem'); + current_setting +----------------- + 3MB +(1 row) + +select myfunc(1), current_setting('work_mem'); + myfunc | current_setting +--------+----------------- + 2MB | 2MB +(1 row) + ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/{guc.out => guc_1.out} | 205 ++++++---------------- 1 files changed, 57 insertions(+), 148 deletions(-) copy src/test/regress/expected/{guc.out => guc_1.out} (72%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 16:23:00
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 75bff5c22b1d721af3ef88268c5c15624ed0b1d3 (commit) from e9b0fdc80dd5822b3b737fdd1c97891a8287c524 (commit) - Log ----------------------------------------------------------------- commit 75bff5c22b1d721af3ef88268c5c15624ed0b1d3 Author: Michael P <mic...@us...> Date: Wed Mar 23 01:21:33 2011 +0900 Fix for regression test case Partition column of a table cannot be updated, so this output is correct. diff --git a/src/test/regress/expected/case_1.out b/src/test/regress/expected/case_1.out new file mode 100644 index 0000000..f56285f --- /dev/null +++ b/src/test/regress/expected/case_1.out @@ -0,0 +1,314 @@ +-- +-- CASE +-- Test the case statement +-- +CREATE TABLE CASE_TBL ( + i integer, + f double precision +); +CREATE TABLE CASE2_TBL ( + i integer, + j integer +); +INSERT INTO CASE_TBL VALUES (1, 10.1); +INSERT INTO CASE_TBL VALUES (2, 20.2); +INSERT INTO CASE_TBL VALUES (3, -30.3); +INSERT INTO CASE_TBL VALUES (4, NULL); +INSERT INTO CASE2_TBL VALUES (1, -1); +INSERT INTO CASE2_TBL VALUES (2, -2); +INSERT INTO CASE2_TBL VALUES (3, -3); +INSERT INTO CASE2_TBL VALUES (2, -4); +INSERT INTO CASE2_TBL VALUES (1, NULL); +INSERT INTO CASE2_TBL VALUES (NULL, -6); +-- +-- Simplest examples without tables +-- +SELECT '3' AS "One", + CASE + WHEN 1 < 2 THEN 3 + END AS "Simple WHEN"; + One | Simple WHEN +-----+------------- + 3 | 3 +(1 row) + +SELECT '<NULL>' AS "One", + CASE + WHEN 1 > 2 THEN 3 + END AS "Simple default"; + One | Simple default +--------+---------------- + <NULL> | +(1 row) + +SELECT '3' AS "One", + CASE + WHEN 1 < 2 THEN 3 + ELSE 4 + END AS "Simple ELSE"; + One | Simple ELSE +-----+------------- + 3 | 3 +(1 row) + +SELECT '4' AS "One", + CASE + WHEN 1 > 2 THEN 3 + ELSE 4 + END AS "ELSE default"; + One | ELSE default +-----+-------------- + 4 | 4 +(1 row) + +SELECT '6' AS "One", + CASE + WHEN 1 > 2 THEN 3 + WHEN 4 < 5 THEN 6 + ELSE 7 + END AS "Two WHEN with default"; + One | Two WHEN with default +-----+----------------------- + 6 | 6 +(1 row) + +-- Constant-expression folding shouldn't evaluate unreachable subexpressions +SELECT CASE WHEN 1=0 THEN 1/0 WHEN 1=1 THEN 1 ELSE 2/0 END; + case +------ + 1 +(1 row) + +SELECT CASE 1 WHEN 0 THEN 1/0 WHEN 1 THEN 1 ELSE 2/0 END; + case +------ + 1 +(1 row) + +-- However we do not currently suppress folding of potentially +-- reachable subexpressions +SELECT CASE WHEN i > 100 THEN 1/0 ELSE 0 END FROM case_tbl; +ERROR: division by zero +-- Test for cases involving untyped literals in test expression +SELECT CASE 'a' WHEN 'a' THEN 1 ELSE 2 END; + case +------ + 1 +(1 row) + +-- +-- Examples of targets involving tables +-- +SELECT '' AS "Five", + CASE + WHEN i >= 3 THEN i + END AS ">= 3 or Null" + FROM CASE_TBL + ORDER BY 2; + Five | >= 3 or Null +------+-------------- + | 3 + | 4 + | + | +(4 rows) + +SELECT '' AS "Five", + CASE WHEN i >= 3 THEN (i + i) + ELSE i + END AS "Simplest Math" + FROM CASE_TBL + ORDER BY 2; + Five | Simplest Math +------+--------------- + | 1 + | 2 + | 6 + | 8 +(4 rows) + +SELECT '' AS "Five", i AS "Value", + CASE WHEN (i < 0) THEN 'small' + WHEN (i = 0) THEN 'zero' + WHEN (i = 1) THEN 'one' + WHEN (i = 2) THEN 'two' + ELSE 'big' + END AS "Category" + FROM CASE_TBL + ORDER BY 2, 3; + Five | Value | Category +------+-------+---------- + | 1 | one + | 2 | two + | 3 | big + | 4 | big +(4 rows) + +SELECT '' AS "Five", + CASE WHEN ((i < 0) or (i < 0)) THEN 'small' + WHEN ((i = 0) or (i = 0)) THEN 'zero' + WHEN ((i = 1) or (i = 1)) THEN 'one' + WHEN ((i = 2) or (i = 2)) THEN 'two' + ELSE 'big' + END AS "Category" + FROM CASE_TBL + ORDER BY 2; + Five | Category +------+---------- + | big + | big + | one + | two +(4 rows) + +-- +-- Examples of qualifications involving tables +-- +-- +-- NULLIF() and COALESCE() +-- Shorthand forms for typical CASE constructs +-- defined in the SQL92 standard. +-- +SELECT * FROM CASE_TBL WHERE COALESCE(f,i) = 4; + i | f +---+--- + 4 | +(1 row) + +SELECT * FROM CASE_TBL WHERE NULLIF(f,i) = 2; + i | f +---+--- +(0 rows) + +SELECT COALESCE(a.f, b.i, b.j) + FROM CASE_TBL a, CASE2_TBL b + ORDER BY coalesce; + coalesce +---------- + -30.3 + -30.3 + -30.3 + -30.3 + -30.3 + -30.3 + -6 + 1 + 1 + 2 + 2 + 3 + 10.1 + 10.1 + 10.1 + 10.1 + 10.1 + 10.1 + 20.2 + 20.2 + 20.2 + 20.2 + 20.2 + 20.2 +(24 rows) + +SELECT * + FROM CASE_TBL a, CASE2_TBL b + WHERE COALESCE(a.f, b.i, b.j) = 2 + ORDER BY a.i, a.f, b.i, b.j; + i | f | i | j +---+---+---+---- + 4 | | 2 | -4 + 4 | | 2 | -2 +(2 rows) + +SELECT '' AS Five, NULLIF(a.i,b.i) AS "NULLIF(a.i,b.i)", + NULLIF(b.i, 4) AS "NULLIF(b.i,4)" + FROM CASE_TBL a, CASE2_TBL b + ORDER BY 2, 3; + five | NULLIF(a.i,b.i) | NULLIF(b.i,4) +------+-----------------+--------------- + | 1 | 2 + | 1 | 2 + | 1 | 3 + | 1 | + | 2 | 1 + | 2 | 1 + | 2 | 3 + | 2 | + | 3 | 1 + | 3 | 1 + | 3 | 2 + | 3 | 2 + | 3 | + | 4 | 1 + | 4 | 1 + | 4 | 2 + | 4 | 2 + | 4 | 3 + | 4 | + | | 1 + | | 1 + | | 2 + | | 2 + | | 3 +(24 rows) + +SELECT '' AS "Two", * + FROM CASE_TBL a, CASE2_TBL b + WHERE COALESCE(f,b.i) = 2 + ORDER BY a.i, a.f, b.i, b.j; + Two | i | f | i | j +-----+---+---+---+---- + | 4 | | 2 | -4 + | 4 | | 2 | -2 +(2 rows) + +-- +-- Examples of updates involving tables +-- +UPDATE CASE_TBL + SET i = CASE WHEN i >= 3 THEN (- i) + ELSE (2 * i) END; +ERROR: Partition column can't be updated in current version +SELECT * FROM CASE_TBL ORDER BY i, f; + i | f +---+------- + 1 | 10.1 + 2 | 20.2 + 3 | -30.3 + 4 | +(4 rows) + +UPDATE CASE_TBL + SET i = CASE WHEN i >= 2 THEN (2 * i) + ELSE (3 * i) END; +ERROR: Partition column can't be updated in current version +SELECT * FROM CASE_TBL ORDER BY i, f; + i | f +---+------- + 1 | 10.1 + 2 | 20.2 + 3 | -30.3 + 4 | +(4 rows) + +UPDATE CASE_TBL + SET i = CASE WHEN b.i >= 2 THEN (2 * j) + ELSE (3 * j) END + FROM CASE2_TBL b + WHERE j = -CASE_TBL.i; +ERROR: Partition column can't be updated in current version +SELECT * FROM CASE_TBL ORDER BY i, f; + i | f +---+------- + 1 | 10.1 + 2 | 20.2 + 3 | -30.3 + 4 | +(4 rows) + +-- +-- Clean up +-- +DROP TABLE CASE_TBL; +DROP TABLE CASE2_TBL; ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/{case.out => case_1.out} | 39 +++++++++++--------- 1 files changed, 21 insertions(+), 18 deletions(-) copy src/test/regress/expected/{case.out => case_1.out} (94%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 15:49:56
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via e9b0fdc80dd5822b3b737fdd1c97891a8287c524 (commit) from 6bc68eefd4558dedc4228335f3f693727dbf47bc (commit) - Log ----------------------------------------------------------------- commit e9b0fdc80dd5822b3b737fdd1c97891a8287c524 Author: Michael P <mic...@us...> Date: Wed Mar 23 00:48:36 2011 +0900 Fix for regression test prepare PREPARE and EXECUTE are not supported yet by Postgres-XC, so this output is suited. diff --git a/src/test/regress/expected/prepare_1.out b/src/test/regress/expected/prepare_1.out new file mode 100644 index 0000000..06f1e73 --- /dev/null +++ b/src/test/regress/expected/prepare_1.out @@ -0,0 +1,126 @@ +-- Regression tests for prepareable statements. We query the content +-- of the pg_prepared_statements view as prepared statements are +-- created and removed. +SELECT name, statement, parameter_types FROM pg_prepared_statements; + name | statement | parameter_types +------+-----------+----------------- +(0 rows) + +PREPARE q1 AS SELECT 1 AS a; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +EXECUTE q1; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +SELECT name, statement, parameter_types FROM pg_prepared_statements; + name | statement | parameter_types +------+-----------+----------------- +(0 rows) + +-- should fail +PREPARE q1 AS SELECT 2; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +-- should succeed +DEALLOCATE q1; +ERROR: prepared statement "q1" does not exist +PREPARE q1 AS SELECT 2; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +EXECUTE q1; +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +PREPARE q2 AS SELECT 2 AS b; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +SELECT name, statement, parameter_types FROM pg_prepared_statements ORDER BY name; + name | statement | parameter_types +------+-----------+----------------- +(0 rows) + +-- sql92 syntax +DEALLOCATE PREPARE q1; +ERROR: prepared statement "q1" does not exist +SELECT name, statement, parameter_types FROM pg_prepared_statements; + name | statement | parameter_types +------+-----------+----------------- +(0 rows) + +DEALLOCATE PREPARE q2; +ERROR: prepared statement "q2" does not exist +-- the view should return the empty set again +SELECT name, statement, parameter_types FROM pg_prepared_statements; + name | statement | parameter_types +------+-----------+----------------- +(0 rows) + +-- parameterized queries +PREPARE q2(text) AS + SELECT datname, datistemplate, datallowconn + FROM pg_database WHERE datname = $1; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +EXECUTE q2('postgres'); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +PREPARE q3(text, int, float, boolean, oid, smallint) AS + SELECT * FROM tenk1 WHERE string4 = $1 AND (four = $2 OR + ten = $3::bigint OR true = $4 OR oid = $5 OR odd = $6::int) + ORDER BY unique1; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +EXECUTE q3('AAAAxx', 5::smallint, 10.5::float, false, 500::oid, 4::bigint); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- too few params +EXECUTE q3('bool'); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- too many params +EXECUTE q3('bytea', 5::smallint, 10.5::float, false, 500::oid, 4::bigint, true); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- wrong param types +EXECUTE q3(5::smallint, 10.5::float, false, 500::oid, 4::bigint, 'bytea'); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +-- invalid type +PREPARE q4(nonexistenttype) AS SELECT $1; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +-- create table as execute +PREPARE q5(int, text) AS + SELECT * FROM tenk1 WHERE unique1 = $1 OR stringu1 = $2 + ORDER BY unique1; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +CREATE TEMPORARY TABLE q5_prep_results AS EXECUTE q5(200, 'DTAAAA'); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +SELECT * FROM q5_prep_results; +ERROR: relation "q5_prep_results" does not exist +LINE 1: SELECT * FROM q5_prep_results; + ^ +-- unknown or unspecified parameter types: should succeed +PREPARE q6 AS + SELECT * FROM tenk1 WHERE unique1 = $1 AND stringu1 = $2; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +PREPARE q7(unknown) AS + SELECT * FROM road WHERE thepath = $1; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +SELECT name, statement, parameter_types FROM pg_prepared_statements + ORDER BY name; + name | statement | parameter_types +------+-----------+----------------- +(0 rows) + +-- test DEALLOCATE ALL; +DEALLOCATE ALL; +SELECT name, statement, parameter_types FROM pg_prepared_statements + ORDER BY name; + name | statement | parameter_types +------+-----------+----------------- +(0 rows) + ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/prepare_1.out | 126 +++++++++++++++++++++++++++++++ 1 files changed, 126 insertions(+), 0 deletions(-) create mode 100644 src/test/regress/expected/prepare_1.out hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-22 15:15:11
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 6bc68eefd4558dedc4228335f3f693727dbf47bc (commit) from 0bd6f5672708a47b72c76a642ce335f1d7663d52 (commit) - Log ----------------------------------------------------------------- commit 6bc68eefd4558dedc4228335f3f693727dbf47bc Author: Abbas <abb...@en...> Date: Tue Mar 22 20:14:43 2011 +0500 Fix for server crash as mentioned in bug ID 3170715 diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 2aacf47..a361186 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -1518,6 +1518,12 @@ ExplainScanTarget(Scan *plan, ExplainState *es) if (plan->scanrelid <= 0) /* Is this still possible? */ return; + +#ifdef PGXC + if (es->rtable == NULL || plan->scanrelid >= es->rtable->length || plan->scanrelid < 0) + return; +#endif + rte = rt_fetch(plan->scanrelid, es->rtable); switch (nodeTag(plan)) ----------------------------------------------------------------------- Summary of changes: src/backend/commands/explain.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 15:06:04
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 0bd6f5672708a47b72c76a642ce335f1d7663d52 (commit) from b8593ff58077e29c21c5f1ed50e622b0cf882b8c (commit) - Log ----------------------------------------------------------------- commit 0bd6f5672708a47b72c76a642ce335f1d7663d52 Author: Michael P <mic...@us...> Date: Wed Mar 23 00:05:03 2011 +0900 Fix for regression test triggers Triggers are not yet supported by XC, so this output is OK. diff --git a/src/test/regress/expected/triggers_1.out b/src/test/regress/expected/triggers_1.out new file mode 100644 index 0000000..5528c66 --- /dev/null +++ b/src/test/regress/expected/triggers_1.out @@ -0,0 +1,747 @@ +-- +-- TRIGGERS +-- +create table pkeys (pkey1 int4 not null, pkey2 text not null); +create table fkeys (fkey1 int4, fkey2 text, fkey3 int); +create table fkeys2 (fkey21 int4, fkey22 text, pkey23 int not null); +create index fkeys_i on fkeys (fkey1, fkey2); +create index fkeys2_i on fkeys2 (fkey21, fkey22); +create index fkeys2p_i on fkeys2 (pkey23); +insert into pkeys values (10, '1'); +insert into pkeys values (20, '2'); +insert into pkeys values (30, '3'); +insert into pkeys values (40, '4'); +insert into pkeys values (50, '5'); +insert into pkeys values (60, '6'); +create unique index pkeys_i on pkeys (pkey1, pkey2); +-- +-- For fkeys: +-- (fkey1, fkey2) --> pkeys (pkey1, pkey2) +-- (fkey3) --> fkeys2 (pkey23) +-- +create trigger check_fkeys_pkey_exist + before insert or update on fkeys + for each row + execute procedure + check_primary_key ('fkey1', 'fkey2', 'pkeys', 'pkey1', 'pkey2'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +create trigger check_fkeys_pkey2_exist + before insert or update on fkeys + for each row + execute procedure check_primary_key ('fkey3', 'fkeys2', 'pkey23'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +-- +-- For fkeys2: +-- (fkey21, fkey22) --> pkeys (pkey1, pkey2) +-- +create trigger check_fkeys2_pkey_exist + before insert or update on fkeys2 + for each row + execute procedure + check_primary_key ('fkey21', 'fkey22', 'pkeys', 'pkey1', 'pkey2'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +-- Test comments +COMMENT ON TRIGGER check_fkeys2_pkey_bad ON fkeys2 IS 'wrong'; +ERROR: trigger "check_fkeys2_pkey_bad" for table "fkeys2" does not exist +COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS 'right'; +ERROR: trigger "check_fkeys2_pkey_exist" for table "fkeys2" does not exist +COMMENT ON TRIGGER check_fkeys2_pkey_exist ON fkeys2 IS NULL; +ERROR: trigger "check_fkeys2_pkey_exist" for table "fkeys2" does not exist +-- +-- For pkeys: +-- ON DELETE/UPDATE (pkey1, pkey2) CASCADE: +-- fkeys (fkey1, fkey2) and fkeys2 (fkey21, fkey22) +-- +create trigger check_pkeys_fkey_cascade + before delete or update on pkeys + for each row + execute procedure + check_foreign_key (2, 'cascade', 'pkey1', 'pkey2', + 'fkeys', 'fkey1', 'fkey2', 'fkeys2', 'fkey21', 'fkey22'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +-- +-- For fkeys2: +-- ON DELETE/UPDATE (pkey23) RESTRICT: +-- fkeys (fkey3) +-- +create trigger check_fkeys2_fkey_restrict + before delete or update on fkeys2 + for each row + execute procedure check_foreign_key (1, 'restrict', 'pkey23', 'fkeys', 'fkey3'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +insert into fkeys2 values (10, '1', 1); +insert into fkeys2 values (30, '3', 2); +insert into fkeys2 values (40, '4', 5); +insert into fkeys2 values (50, '5', 3); +-- no key in pkeys +insert into fkeys2 values (70, '5', 3); +insert into fkeys values (10, '1', 2); +insert into fkeys values (30, '3', 3); +insert into fkeys values (40, '4', 2); +insert into fkeys values (50, '5', 2); +-- no key in pkeys +insert into fkeys values (70, '5', 1); +-- no key in fkeys2 +insert into fkeys values (60, '6', 4); +delete from pkeys where pkey1 = 30 and pkey2 = '3'; +delete from pkeys where pkey1 = 40 and pkey2 = '4'; +update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 50 and pkey2 = '5'; +ERROR: Partition column can't be updated in current version +update pkeys set pkey1 = 7, pkey2 = '70' where pkey1 = 10 and pkey2 = '1'; +ERROR: Partition column can't be updated in current version +DROP TABLE pkeys; +DROP TABLE fkeys; +DROP TABLE fkeys2; +-- -- I've disabled the funny_dup17 test because the new semantics +-- -- of AFTER ROW triggers, which get now fired at the end of a +-- -- query always, cause funny_dup17 to enter an endless loop. +-- -- +-- -- Jan +-- +-- create table dup17 (x int4); +-- +-- create trigger dup17_before +-- before insert on dup17 +-- for each row +-- execute procedure +-- funny_dup17 () +-- ; +-- +-- insert into dup17 values (17); +-- select count(*) from dup17; +-- insert into dup17 values (17); +-- select count(*) from dup17; +-- +-- drop trigger dup17_before on dup17; +-- +-- create trigger dup17_after +-- after insert on dup17 +-- for each row +-- execute procedure +-- funny_dup17 () +-- ; +-- insert into dup17 values (13); +-- select count(*) from dup17 where x = 13; +-- insert into dup17 values (13); +-- select count(*) from dup17 where x = 13; +-- +-- DROP TABLE dup17; +create sequence ttdummy_seq increment 10 start 0 minvalue 0; +create table tttest ( + price_id int4, + price_val int4, + price_on int4, + price_off int4 default 999999 +); +create trigger ttdummy + before delete or update on tttest + for each row + execute procedure + ttdummy (price_on, price_off); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +create trigger ttserial + before insert or update on tttest + for each row + execute procedure + autoinc (price_on, ttdummy_seq); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +insert into tttest values (1, 1, null); +insert into tttest values (2, 2, null); +insert into tttest values (3, 3, 0); +select * from tttest order by 1,2,3,4; + price_id | price_val | price_on | price_off +----------+-----------+----------+----------- + 1 | 1 | | 999999 + 2 | 2 | | 999999 + 3 | 3 | 0 | 999999 +(3 rows) + +delete from tttest where price_id = 2; +select * from tttest order by 1,2,3,4; + price_id | price_val | price_on | price_off +----------+-----------+----------+----------- + 1 | 1 | | 999999 + 3 | 3 | 0 | 999999 +(2 rows) + +-- what do we see ? +-- get current prices +select * from tttest where price_off = 999999 order by 1,2,3,4; + price_id | price_val | price_on | price_off +----------+-----------+----------+----------- + 1 | 1 | | 999999 + 3 | 3 | 0 | 999999 +(2 rows) + +-- change price for price_id == 3 +update tttest set price_val = 30 where price_id = 3; +select * from tttest order by 1,2,3,4; + price_id | price_val | price_on | price_off +----------+-----------+----------+----------- + 1 | 1 | | 999999 + 3 | 30 | 0 | 999999 +(2 rows) + +-- now we want to change pric_id in ALL tuples +-- this gets us not what we need +update tttest set price_id = 5 where price_id = 3; +ERROR: Partition column can't be updated in current version +select * from tttest order by 1,2,3,4; + price_id | price_val | price_on | price_off +----------+-----------+----------+----------- + 1 | 1 | | 999999 + 3 | 30 | 0 | 999999 +(2 rows) + +-- restore data as before last update: +select set_ttdummy(0); + set_ttdummy +------------- + 1 +(1 row) + +delete from tttest where price_id = 5; +update tttest set price_off = 999999 where price_val = 30; +select * from tttest order by 1,2,3,4; + price_id | price_val | price_on | price_off +----------+-----------+----------+----------- + 1 | 1 | | 999999 + 3 | 30 | 0 | 999999 +(2 rows) + +-- and try change price_id now! +update tttest set price_id = 5 where price_id = 3; +ERROR: Partition column can't be updated in current version +select * from tttest order by 1,2,3,4; + price_id | price_val | price_on | price_off +----------+-----------+----------+----------- + 1 | 1 | | 999999 + 3 | 30 | 0 | 999999 +(2 rows) + +-- isn't it what we need ? +select set_ttdummy(1); + set_ttdummy +------------- + 0 +(1 row) + +-- we want to correct some "date" +update tttest set price_on = -1 where price_id = 1; +-- but this doesn't work +-- try in this way +select set_ttdummy(0); + set_ttdummy +------------- + 1 +(1 row) + +update tttest set price_on = -1 where price_id = 1; +select * from tttest order by 1,2,3,4; + price_id | price_val | price_on | price_off +----------+-----------+----------+----------- + 1 | 1 | -1 | 999999 + 3 | 30 | 0 | 999999 +(2 rows) + +-- isn't it what we need ? +-- get price for price_id == 5 as it was @ "date" 35 +select * from tttest where price_on <= 35 and price_off > 35 and price_id = 5 order by 1,2,3,4; + price_id | price_val | price_on | price_off +----------+-----------+----------+----------- +(0 rows) + +drop table tttest; +drop sequence ttdummy_seq; +-- +-- tests for per-statement triggers +-- +CREATE TABLE log_table (tstamp timestamp default timeofday()::timestamp); +CREATE TABLE main_table (a int, b int); +COPY main_table (a,b) FROM stdin; +CREATE FUNCTION trigger_func() RETURNS trigger LANGUAGE plpgsql AS ' +BEGIN + RAISE NOTICE ''trigger_func(%) called: action = %, when = %, level = %'', TG_ARGV[0], TG_OP, TG_WHEN, TG_LEVEL; + RETURN NULL; +END;'; +CREATE TRIGGER before_ins_stmt_trig BEFORE INSERT ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('before_ins_stmt'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER after_ins_stmt_trig AFTER INSERT ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('after_ins_stmt'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +-- +-- if neither 'FOR EACH ROW' nor 'FOR EACH STATEMENT' was specified, +-- CREATE TRIGGER should default to 'FOR EACH STATEMENT' +-- +CREATE TRIGGER after_upd_stmt_trig AFTER UPDATE ON main_table +EXECUTE PROCEDURE trigger_func('after_upd_stmt'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER after_upd_row_trig AFTER UPDATE ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_row'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +INSERT INTO main_table DEFAULT VALUES; +UPDATE main_table SET a = a + 1 WHERE b < 30; +ERROR: Partition column can't be updated in current version +-- UPDATE that effects zero rows should still call per-statement trigger +UPDATE main_table SET a = a + 2 WHERE b > 100; +ERROR: Partition column can't be updated in current version +-- COPY should fire per-row and per-statement INSERT triggers +COPY main_table (a, b) FROM stdin; +SELECT * FROM main_table ORDER BY a, b; + a | b +----+---- + 5 | 10 + 20 | 20 + 30 | 10 + 30 | 40 + 50 | 35 + 50 | 60 + 80 | 15 + | +(8 rows) + +-- +-- test triggers with WHEN clause +-- +CREATE TRIGGER modified_a BEFORE UPDATE OF a ON main_table +FOR EACH ROW WHEN (OLD.a <> NEW.a) EXECUTE PROCEDURE trigger_func('modified_a'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER modified_any BEFORE UPDATE OF a ON main_table +FOR EACH ROW WHEN (OLD.* IS DISTINCT FROM NEW.*) EXECUTE PROCEDURE trigger_func('modified_any'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER insert_a AFTER INSERT ON main_table +FOR EACH ROW WHEN (NEW.a = 123) EXECUTE PROCEDURE trigger_func('insert_a'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER delete_a AFTER DELETE ON main_table +FOR EACH ROW WHEN (OLD.a = 123) EXECUTE PROCEDURE trigger_func('delete_a'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER insert_when BEFORE INSERT ON main_table +FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE trigger_func('insert_when'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER delete_when AFTER DELETE ON main_table +FOR EACH STATEMENT WHEN (true) EXECUTE PROCEDURE trigger_func('delete_when'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +INSERT INTO main_table (a) VALUES (123), (456); +COPY main_table FROM stdin; +DELETE FROM main_table WHERE a IN (123, 456); +UPDATE main_table SET a = 50, b = 60; +ERROR: Partition column can't be updated in current version +SELECT * FROM main_table ORDER BY a, b; + a | b +----+---- + 5 | 10 + 20 | 20 + 30 | 10 + 30 | 40 + 50 | 35 + 50 | 60 + 80 | 15 + | +(8 rows) + +SELECT pg_get_triggerdef(oid, true) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_a'; + pg_get_triggerdef +------------------- +(0 rows) + +SELECT pg_get_triggerdef(oid, false) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_a'; + pg_get_triggerdef +------------------- +(0 rows) + +SELECT pg_get_triggerdef(oid, true) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'modified_any'; + pg_get_triggerdef +------------------- +(0 rows) + +DROP TRIGGER modified_a ON main_table; +ERROR: trigger "modified_a" for table "main_table" does not exist +DROP TRIGGER modified_any ON main_table; +ERROR: trigger "modified_any" for table "main_table" does not exist +DROP TRIGGER insert_a ON main_table; +ERROR: trigger "insert_a" for table "main_table" does not exist +DROP TRIGGER delete_a ON main_table; +ERROR: trigger "delete_a" for table "main_table" does not exist +DROP TRIGGER insert_when ON main_table; +ERROR: trigger "insert_when" for table "main_table" does not exist +DROP TRIGGER delete_when ON main_table; +ERROR: trigger "delete_when" for table "main_table" does not exist +-- Test column-level triggers +DROP TRIGGER after_upd_row_trig ON main_table; +ERROR: trigger "after_upd_row_trig" for table "main_table" does not exist +CREATE TRIGGER before_upd_a_row_trig BEFORE UPDATE OF a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('before_upd_a_row'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER after_upd_b_row_trig AFTER UPDATE OF b ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_b_row'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER after_upd_a_b_row_trig AFTER UPDATE OF a, b ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('after_upd_a_b_row'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER before_upd_a_stmt_trig BEFORE UPDATE OF a ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('before_upd_a_stmt'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER after_upd_b_stmt_trig AFTER UPDATE OF b ON main_table +FOR EACH STATEMENT EXECUTE PROCEDURE trigger_func('after_upd_b_stmt'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +SELECT pg_get_triggerdef(oid) FROM pg_trigger WHERE tgrelid = 'main_table'::regclass AND tgname = 'after_upd_a_b_row_trig'; + pg_get_triggerdef +------------------- +(0 rows) + +UPDATE main_table SET a = 50; +ERROR: Partition column can't be updated in current version +UPDATE main_table SET b = 10; +-- bogus cases +CREATE TRIGGER error_upd_and_col BEFORE UPDATE OR UPDATE OF a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('error_upd_and_col'); +ERROR: duplicate trigger events specified at or near "ON" +LINE 1: ...ER error_upd_and_col BEFORE UPDATE OR UPDATE OF a ON main_ta... + ^ +CREATE TRIGGER error_upd_a_a BEFORE UPDATE OF a, a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('error_upd_a_a'); +ERROR: column "a" specified more than once +CREATE TRIGGER error_ins_a BEFORE INSERT OF a ON main_table +FOR EACH ROW EXECUTE PROCEDURE trigger_func('error_ins_a'); +ERROR: syntax error at or near "OF" +LINE 1: CREATE TRIGGER error_ins_a BEFORE INSERT OF a ON main_table + ^ +CREATE TRIGGER error_ins_when BEFORE INSERT OR UPDATE ON main_table +FOR EACH ROW WHEN (OLD.a <> NEW.a) +EXECUTE PROCEDURE trigger_func('error_ins_old'); +ERROR: INSERT trigger's WHEN condition cannot reference OLD values +LINE 2: FOR EACH ROW WHEN (OLD.a <> NEW.a) + ^ +CREATE TRIGGER error_del_when BEFORE DELETE OR UPDATE ON main_table +FOR EACH ROW WHEN (OLD.a <> NEW.a) +EXECUTE PROCEDURE trigger_func('error_del_new'); +ERROR: DELETE trigger's WHEN condition cannot reference NEW values +LINE 2: FOR EACH ROW WHEN (OLD.a <> NEW.a) + ^ +CREATE TRIGGER error_del_when BEFORE INSERT OR UPDATE ON main_table +FOR EACH ROW WHEN (NEW.tableoid <> 0) +EXECUTE PROCEDURE trigger_func('error_when_sys_column'); +ERROR: BEFORE trigger's WHEN condition cannot reference NEW system columns +LINE 2: FOR EACH ROW WHEN (NEW.tableoid <> 0) + ^ +CREATE TRIGGER error_stmt_when BEFORE UPDATE OF a ON main_table +FOR EACH STATEMENT WHEN (OLD.* IS DISTINCT FROM NEW.*) +EXECUTE PROCEDURE trigger_func('error_stmt_when'); +ERROR: statement trigger's WHEN condition cannot reference column values +LINE 2: FOR EACH STATEMENT WHEN (OLD.* IS DISTINCT FROM NEW.*) + ^ +-- check dependency restrictions +ALTER TABLE main_table DROP COLUMN b; +-- this should succeed, but we'll roll it back to keep the triggers around +begin; +DROP TRIGGER after_upd_a_b_row_trig ON main_table; +ERROR: trigger "after_upd_a_b_row_trig" for table "main_table" does not exist +DROP TRIGGER after_upd_b_row_trig ON main_table; +ERROR: current transaction is aborted, commands ignored until end of transaction block +DROP TRIGGER after_upd_b_stmt_trig ON main_table; +ERROR: current transaction is aborted, commands ignored until end of transaction block +ALTER TABLE main_table DROP COLUMN b; +ERROR: current transaction is aborted, commands ignored until end of transaction block +rollback; +-- Test enable/disable triggers +create table trigtest (i serial primary key); +ERROR: Postgres-XC does not support SERIAL yet +DETAIL: The feature is not currently supported +-- test that disabling RI triggers works +create table trigtest2 (i int references trigtest(i) on delete cascade); +ERROR: relation "trigtest" does not exist +create function trigtest() returns trigger as $$ +begin + raise notice '% % % %', TG_RELNAME, TG_OP, TG_WHEN, TG_LEVEL; + return new; +end;$$ language plpgsql; +create trigger trigtest_b_row_tg before insert or update or delete on trigtest +for each row execute procedure trigtest(); +ERROR: relation "trigtest" does not exist +create trigger trigtest_a_row_tg after insert or update or delete on trigtest +for each row execute procedure trigtest(); +ERROR: relation "trigtest" does not exist +create trigger trigtest_b_stmt_tg before insert or update or delete on trigtest +for each statement execute procedure trigtest(); +ERROR: relation "trigtest" does not exist +create trigger trigtest_a_stmt_tg after insert or update or delete on trigtest +for each statement execute procedure trigtest(); +ERROR: relation "trigtest" does not exist +insert into trigtest default values; +ERROR: relation "trigtest" does not exist +LINE 1: insert into trigtest default values; + ^ +alter table trigtest disable trigger trigtest_b_row_tg; +ERROR: relation "trigtest" does not exist +insert into trigtest default values; +ERROR: relation "trigtest" does not exist +LINE 1: insert into trigtest default values; + ^ +alter table trigtest disable trigger user; +ERROR: relation "trigtest" does not exist +insert into trigtest default values; +ERROR: relation "trigtest" does not exist +LINE 1: insert into trigtest default values; + ^ +alter table trigtest enable trigger trigtest_a_stmt_tg; +ERROR: relation "trigtest" does not exist +insert into trigtest default values; +ERROR: relation "trigtest" does not exist +LINE 1: insert into trigtest default values; + ^ +insert into trigtest2 values(1); +ERROR: relation "trigtest2" does not exist +LINE 1: insert into trigtest2 values(1); + ^ +insert into trigtest2 values(2); +ERROR: relation "trigtest2" does not exist +LINE 1: insert into trigtest2 values(2); + ^ +delete from trigtest where i=2; +ERROR: relation "trigtest" does not exist +LINE 1: delete from trigtest where i=2; + ^ +select * from trigtest2 order by 1; +ERROR: relation "trigtest2" does not exist +LINE 1: select * from trigtest2 order by 1; + ^ +alter table trigtest disable trigger all; +ERROR: relation "trigtest" does not exist +delete from trigtest where i=1; +ERROR: relation "trigtest" does not exist +LINE 1: delete from trigtest where i=1; + ^ +select * from trigtest2 order by 1; +ERROR: relation "trigtest2" does not exist +LINE 1: select * from trigtest2 order by 1; + ^ +-- ensure we still insert, even when all triggers are disabled +insert into trigtest default values; +ERROR: relation "trigtest" does not exist +LINE 1: insert into trigtest default values; + ^ +select * from trigtest order by 1; +ERROR: relation "trigtest" does not exist +LINE 1: select * from trigtest order by 1; + ^ +drop table trigtest2; +ERROR: table "trigtest2" does not exist +drop table trigtest; +ERROR: table "trigtest" does not exist +-- dump trigger data +CREATE TABLE trigger_test ( + i int, + v varchar +); +CREATE OR REPLACE FUNCTION trigger_data() RETURNS trigger +LANGUAGE plpgsql AS $$ + +declare + + argstr text; + relid text; + +begin + + relid := TG_relid::regclass; + + -- plpgsql can't discover its trigger data in a hash like perl and python + -- can, or by a sort of reflection like tcl can, + -- so we have to hard code the names. + raise NOTICE 'TG_NAME: %', TG_name; + raise NOTICE 'TG_WHEN: %', TG_when; + raise NOTICE 'TG_LEVEL: %', TG_level; + raise NOTICE 'TG_OP: %', TG_op; + raise NOTICE 'TG_RELID::regclass: %', relid; + raise NOTICE 'TG_RELNAME: %', TG_relname; + raise NOTICE 'TG_TABLE_NAME: %', TG_table_name; + raise NOTICE 'TG_TABLE_SCHEMA: %', TG_table_schema; + raise NOTICE 'TG_NARGS: %', TG_nargs; + + argstr := '['; + for i in 0 .. TG_nargs - 1 loop + if i > 0 then + argstr := argstr || ', '; + end if; + argstr := argstr || TG_argv[i]; + end loop; + argstr := argstr || ']'; + raise NOTICE 'TG_ARGV: %', argstr; + + if TG_OP != 'INSERT' then + raise NOTICE 'OLD: %', OLD; + end if; + + if TG_OP != 'DELETE' then + raise NOTICE 'NEW: %', NEW; + end if; + + if TG_OP = 'DELETE' then + return OLD; + else + return NEW; + end if; + +end; +$$; +CREATE TRIGGER show_trigger_data_trig +BEFORE INSERT OR UPDATE OR DELETE ON trigger_test +FOR EACH ROW EXECUTE PROCEDURE trigger_data(23,'skidoo'); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +insert into trigger_test values(1,'insert'); +update trigger_test set v = 'update' where i = 1; +delete from trigger_test; + +DROP TRIGGER show_trigger_data_trig on trigger_test; +ERROR: trigger "show_trigger_data_trig" for table "trigger_test" does not exist + +DROP FUNCTION trigger_data(); +DROP TABLE trigger_test; +-- +-- Test use of row comparisons on OLD/NEW +-- +CREATE TABLE trigger_test (f1 int, f2 text, f3 text); +-- this is the obvious (and wrong...) way to compare rows +CREATE FUNCTION mytrigger() RETURNS trigger LANGUAGE plpgsql as $$ +begin + if row(old.*) = row(new.*) then + raise notice 'row % not changed', new.f1; + else + raise notice 'row % changed', new.f1; + end if; + return new; +end$$; +CREATE TRIGGER t +BEFORE UPDATE ON trigger_test +FOR EACH ROW EXECUTE PROCEDURE mytrigger(); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +INSERT INTO trigger_test VALUES(1, 'foo', 'bar'); +INSERT INTO trigger_test VALUES(2, 'baz', 'quux'); +UPDATE trigger_test SET f3 = 'bar'; +UPDATE trigger_test SET f3 = NULL; +-- this demonstrates that the above isn't really working as desired: +UPDATE trigger_test SET f3 = NULL; +-- the right way when considering nulls is +CREATE OR REPLACE FUNCTION mytrigger() RETURNS trigger LANGUAGE plpgsql as $$ +begin + if row(old.*) is distinct from row(new.*) then + raise notice 'row % changed', new.f1; + else + raise notice 'row % not changed', new.f1; + end if; + return new; +end$$; +UPDATE trigger_test SET f3 = 'bar'; +UPDATE trigger_test SET f3 = NULL; +UPDATE trigger_test SET f3 = NULL; +DROP TABLE trigger_test; +DROP FUNCTION mytrigger(); +-- Test snapshot management in serializable transactions involving triggers +-- per bug report in 6bc...@ma... +CREATE FUNCTION serializable_update_trig() RETURNS trigger LANGUAGE plpgsql AS +$$ +declare + rec record; +begin + new.description = 'updated in trigger'; + return new; +end; +$$; +CREATE TABLE serializable_update_tab ( + id int, + filler text, + description text +); +CREATE TRIGGER serializable_update_trig BEFORE UPDATE ON serializable_update_tab + FOR EACH ROW EXECUTE PROCEDURE serializable_update_trig(); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +INSERT INTO serializable_update_tab SELECT a, repeat('xyzxz', 100), 'new' + FROM generate_series(1, 50) a; +BEGIN; +SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; +UPDATE serializable_update_tab SET description = 'no no', id = 1 WHERE id = 1; +ERROR: Partition column can't be updated in current version +COMMIT; +SELECT description FROM serializable_update_tab WHERE id = 1; + description +------------- +(0 rows) + +DROP TABLE serializable_update_tab; +-- minimal update trigger +CREATE TABLE min_updates_test ( + f1 text, + f2 int, + f3 int); +CREATE TABLE min_updates_test_oids ( + f1 text, + f2 int, + f3 int) WITH OIDS; +INSERT INTO min_updates_test VALUES ('a',1,2),('b','2',null); +INSERT INTO min_updates_test_oids VALUES ('a',1,2),('b','2',null); +CREATE TRIGGER z_min_update +BEFORE UPDATE ON min_updates_test +FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger(); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +CREATE TRIGGER z_min_update +BEFORE UPDATE ON min_updates_test_oids +FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger(); +ERROR: Postgres-XC does not support TRIGGER yet +DETAIL: The feature is not currently supported +\set QUIET false +UPDATE min_updates_test SET f1 = f1; +UPDATE 2 +UPDATE min_updates_test SET f2 = f2 + 1; +ERROR: Partition column can't be updated in current version +UPDATE min_updates_test SET f3 = 2 WHERE f3 is null; +UPDATE 1 +UPDATE min_updates_test_oids SET f1 = f1; +UPDATE 2 +UPDATE min_updates_test_oids SET f2 = f2 + 1; +ERROR: Partition column can't be updated in current version +UPDATE min_updates_test_oids SET f3 = 2 WHERE f3 is null; +UPDATE 1 +\set QUIET true +SELECT * FROM min_updates_test ORDER BY 1,2,3; + f1 | f2 | f3 +----+----+---- + a | 1 | 2 + b | 2 | 2 +(2 rows) + +SELECT * FROM min_updates_test_oids ORDER BY 1,2,3; + f1 | f2 | f3 +----+----+---- + a | 1 | 2 + b | 2 | 2 +(2 rows) + +DROP TABLE min_updates_test; +DROP TABLE min_updates_test_oids; ----------------------------------------------------------------------- Summary of changes: .../expected/{triggers.out => triggers_1.out} | 406 +++++++++----------- 1 files changed, 180 insertions(+), 226 deletions(-) copy src/test/regress/expected/{triggers.out => triggers_1.out} (61%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 14:47:45
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via b8593ff58077e29c21c5f1ed50e622b0cf882b8c (commit) from 171d5e3b22a1b5b15ad09712fe829d8bf61e3d13 (commit) - Log ----------------------------------------------------------------- commit b8593ff58077e29c21c5f1ed50e622b0cf882b8c Author: Michael P <mic...@us...> Date: Tue Mar 22 23:46:22 2011 +0900 Fix for regression test box box is not a type that can use ORDER BY, so its table is replicated for regression tests diff --git a/src/test/regress/expected/box_1.out b/src/test/regress/expected/box_1.out index 7bd428a..7ff6017 100644 --- a/src/test/regress/expected/box_1.out +++ b/src/test/regress/expected/box_1.out @@ -15,7 +15,9 @@ -- 0 1 2 3 -- -- boxes are specified by two points, given by four floats x1,y1,x2,y2 -CREATE TABLE BOX_TBL (f1 box); +-- Postgres-XC case: box type cannot use ORDER BY so its table +-- is replicated for regression tests +CREATE TABLE BOX_TBL (f1 box) DISTRIBUTE BY REPLICATION; INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)'); INSERT INTO BOX_TBL (f1) VALUES ('(1.0,1.0,3.0,3.0)'); -- degenerate cases where the box is a line or a point @@ -34,10 +36,10 @@ LINE 1: INSERT INTO BOX_TBL (f1) VALUES ('asdfasdf(ad'); SELECT '' AS four, * FROM BOX_TBL; four | f1 ------+--------------------- - | (3,3),(1,1) - | (3,3),(3,3) | (2,2),(0,0) + | (3,3),(1,1) | (2.5,3.5),(2.5,2.5) + | (3,3),(3,3) (4 rows) SELECT '' AS four, b.*, area(b.f1) as barea diff --git a/src/test/regress/sql/box.sql b/src/test/regress/sql/box.sql index baf86ae..8c17383 100644 --- a/src/test/regress/sql/box.sql +++ b/src/test/regress/sql/box.sql @@ -18,8 +18,9 @@ -- boxes are specified by two points, given by four floats x1,y1,x2,y2 - -CREATE TABLE BOX_TBL (f1 box); +-- Postgres-XC case: box type cannot use ORDER BY so its table +-- is replicated for regression tests +CREATE TABLE BOX_TBL (f1 box) DISTRIBUTE BY REPLICATION; INSERT INTO BOX_TBL (f1) VALUES ('(2.0,2.0,0.0,0.0)'); ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/box_1.out | 8 +++++--- src/test/regress/sql/box.sql | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 13:57:51
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 171d5e3b22a1b5b15ad09712fe829d8bf61e3d13 (commit) from 33b9889d7cc947a702f2d4ff7cb147abdd606666 (commit) - Log ----------------------------------------------------------------- commit 171d5e3b22a1b5b15ad09712fe829d8bf61e3d13 Author: Michael P <mic...@us...> Date: Tue Mar 22 22:55:37 2011 +0900 Fix for regression test point point is a type that cannot be ordered with ORDER BY, so create its table as DISTRIBUTE BY REPLICATION for regressions. diff --git a/src/test/regress/expected/point_1.out b/src/test/regress/expected/point_1.out new file mode 100644 index 0000000..472930c --- /dev/null +++ b/src/test/regress/expected/point_1.out @@ -0,0 +1,249 @@ +-- +-- POINT +-- +-- Postgres-XC case: point type cannot be ordered so table +-- is replicated for regression tests whatever the cluster configuration +CREATE TABLE POINT_TBL(f1 point) DISTRIBUTE BY REPLICATION; +INSERT INTO POINT_TBL(f1) VALUES ('(0.0,0.0)'); +INSERT INTO POINT_TBL(f1) VALUES ('(-10.0,0.0)'); +INSERT INTO POINT_TBL(f1) VALUES ('(-3.0,4.0)'); +INSERT INTO POINT_TBL(f1) VALUES ('(5.1, 34.5)'); +INSERT INTO POINT_TBL(f1) VALUES ('(-5.0,-12.0)'); +-- bad format points +INSERT INTO POINT_TBL(f1) VALUES ('asdfasdf'); +ERROR: invalid input syntax for type point: "asdfasdf" +LINE 1: INSERT INTO POINT_TBL(f1) VALUES ('asdfasdf'); + ^ +INSERT INTO POINT_TBL(f1) VALUES ('10.0,10.0'); +INSERT INTO POINT_TBL(f1) VALUES ('(10.0 10.0)'); +ERROR: invalid input syntax for type point: "(10.0 10.0)" +LINE 1: INSERT INTO POINT_TBL(f1) VALUES ('(10.0 10.0)'); + ^ +INSERT INTO POINT_TBL(f1) VALUES ('(10.0,10.0'); +ERROR: invalid input syntax for type point: "(10.0,10.0" +LINE 1: INSERT INTO POINT_TBL(f1) VALUES ('(10.0,10.0'); + ^ +SELECT '' AS six, * FROM POINT_TBL; + six | f1 +-----+------------ + | (0,0) + | (-10,0) + | (-3,4) + | (5.1,34.5) + | (-5,-12) + | (10,10) +(6 rows) + +-- left of +SELECT '' AS three, p.* FROM POINT_TBL p WHERE p.f1 << '(0.0, 0.0)' ORDER BY p.f1[0], p.f1[1]; + three | f1 +-------+---------- + | (-10,0) + | (-5,-12) + | (-3,4) +(3 rows) + +-- right of +SELECT '' AS three, p.* FROM POINT_TBL p WHERE '(0.0,0.0)' >> p.f1 ORDER BY p.f1[0], p.f1[1]; + three | f1 +-------+---------- + | (-10,0) + | (-5,-12) + | (-3,4) +(3 rows) + +-- above +SELECT '' AS one, p.* FROM POINT_TBL p WHERE '(0.0,0.0)' >^ p.f1 ORDER BY p.f1[0], p.f1[1]; + one | f1 +-----+---------- + | (-5,-12) +(1 row) + +-- below +SELECT '' AS one, p.* FROM POINT_TBL p WHERE p.f1 <^ '(0.0, 0.0)' ORDER BY p.f1[0], p.f1[1]; + one | f1 +-----+---------- + | (-5,-12) +(1 row) + +-- equal +SELECT '' AS one, p.* FROM POINT_TBL p WHERE p.f1 ~= '(5.1, 34.5)' ORDER BY p.f1[0], p.f1[1]; + one | f1 +-----+------------ + | (5.1,34.5) +(1 row) + +-- point in box +SELECT '' AS three, p.* FROM POINT_TBL p + WHERE p.f1 <@ box '(0,0,100,100)' ORDER BY p.f1[0], p.f1[1]; + three | f1 +-------+------------ + | (0,0) + | (5.1,34.5) + | (10,10) +(3 rows) + +SELECT '' AS three, p.* FROM POINT_TBL p + WHERE box '(0,0,100,100)' @> p.f1; + three | f1 +-------+------------ + | (0,0) + | (5.1,34.5) + | (10,10) +(3 rows) + +SELECT '' AS three, p.* FROM POINT_TBL p + WHERE not p.f1 <@ box '(0,0,100,100)'; + three | f1 +-------+---------- + | (-10,0) + | (-3,4) + | (-5,-12) +(3 rows) + +SELECT '' AS two, p.* FROM POINT_TBL p + WHERE p.f1 <@ path '[(0,0),(-10,0),(-10,10)]' ORDER BY p.f1[0], p.f1[1]; + two | f1 +-----+--------- + | (-10,0) + | (0,0) +(2 rows) + +SELECT '' AS three, p.* FROM POINT_TBL p + WHERE not box '(0,0,100,100)' @> p.f1; + three | f1 +-------+---------- + | (-10,0) + | (-3,4) + | (-5,-12) +(3 rows) + +SELECT '' AS six, p.f1, p.f1 <-> point '(0,0)' AS dist + FROM POINT_TBL p + ORDER BY dist, p.f1[0], p.f1[1]; + six | f1 | dist +-----+------------+------------------ + | (0,0) | 0 + | (-3,4) | 5 + | (-10,0) | 10 + | (-5,-12) | 13 + | (10,10) | 14.142135623731 + | (5.1,34.5) | 34.8749193547455 +(6 rows) + +SELECT '' AS thirtysix, p1.f1 AS point1, p2.f1 AS point2, p1.f1 <-> p2.f1 AS dist + FROM POINT_TBL p1, POINT_TBL p2 + ORDER BY dist, p1.f1[0], p2.f1[0]; + thirtysix | point1 | point2 | dist +-----------+------------+------------+------------------ + | (-10,0) | (-10,0) | 0 + | (-5,-12) | (-5,-12) | 0 + | (-3,4) | (-3,4) | 0 + | (0,0) | (0,0) | 0 + | (5.1,34.5) | (5.1,34.5) | 0 + | (10,10) | (10,10) | 0 + | (-3,4) | (0,0) | 5 + | (0,0) | (-3,4) | 5 + | (-10,0) | (-3,4) | 8.06225774829855 + | (-3,4) | (-10,0) | 8.06225774829855 + | (-10,0) | (0,0) | 10 + | (0,0) | (-10,0) | 10 + | (-10,0) | (-5,-12) | 13 + | (-5,-12) | (-10,0) | 13 + | (-5,-12) | (0,0) | 13 + | (0,0) | (-5,-12) | 13 + | (0,0) | (10,10) | 14.142135623731 + | (10,10) | (0,0) | 14.142135623731 + | (-3,4) | (10,10) | 14.3178210632764 + | (10,10) | (-3,4) | 14.3178210632764 + | (-5,-12) | (-3,4) | 16.1245154965971 + | (-3,4) | (-5,-12) | 16.1245154965971 + | (-10,0) | (10,10) | 22.3606797749979 + | (10,10) | (-10,0) | 22.3606797749979 + | (5.1,34.5) | (10,10) | 24.9851956166046 + | (10,10) | (5.1,34.5) | 24.9851956166046 + | (-5,-12) | (10,10) | 26.6270539113887 + | (10,10) | (-5,-12) | 26.6270539113887 + | (-3,4) | (5.1,34.5) | 31.5572495632937 + | (5.1,34.5) | (-3,4) | 31.5572495632937 + | (0,0) | (5.1,34.5) | 34.8749193547455 + | (5.1,34.5) | (0,0) | 34.8749193547455 + | (-10,0) | (5.1,34.5) | 37.6597928831267 + | (5.1,34.5) | (-10,0) | 37.6597928831267 + | (-5,-12) | (5.1,34.5) | 47.5842410888311 + | (5.1,34.5) | (-5,-12) | 47.5842410888311 +(36 rows) + +SELECT '' AS thirty, p1.f1 AS point1, p2.f1 AS point2 + FROM POINT_TBL p1, POINT_TBL p2 + WHERE (p1.f1 <-> p2.f1) > 3 ORDER BY p1.f1[0], p1.f1[1], p2.f1[0], p2.f1[1]; + thirty | point1 | point2 +--------+------------+------------ + | (-10,0) | (-5,-12) + | (-10,0) | (-3,4) + | (-10,0) | (0,0) + | (-10,0) | (5.1,34.5) + | (-10,0) | (10,10) + | (-5,-12) | (-10,0) + | (-5,-12) | (-3,4) + | (-5,-12) | (0,0) + | (-5,-12) | (5.1,34.5) + | (-5,-12) | (10,10) + | (-3,4) | (-10,0) + | (-3,4) | (-5,-12) + | (-3,4) | (0,0) + | (-3,4) | (5.1,34.5) + | (-3,4) | (10,10) + | (0,0) | (-10,0) + | (0,0) | (-5,-12) + | (0,0) | (-3,4) + | (0,0) | (5.1,34.5) + | (0,0) | (10,10) + | (5.1,34.5) | (-10,0) + | (5.1,34.5) | (-5,-12) + | (5.1,34.5) | (-3,4) + | (5.1,34.5) | (0,0) + | (5.1,34.5) | (10,10) + | (10,10) | (-10,0) + | (10,10) | (-5,-12) + | (10,10) | (-3,4) + | (10,10) | (0,0) + | (10,10) | (5.1,34.5) +(30 rows) + +-- put distance result into output to allow sorting with GEQ optimizer - tgl 97/05/10 +SELECT '' AS fifteen, p1.f1 AS point1, p2.f1 AS point2, (p1.f1 <-> p2.f1) AS distance + FROM POINT_TBL p1, POINT_TBL p2 + WHERE (p1.f1 <-> p2.f1) > 3 and p1.f1 << p2.f1 + ORDER BY distance, p1.f1[0], p2.f1[0]; + fifteen | point1 | point2 | distance +---------+------------+------------+------------------ + | (-3,4) | (0,0) | 5 + | (-10,0) | (-3,4) | 8.06225774829855 + | (-10,0) | (0,0) | 10 + | (-10,0) | (-5,-12) | 13 + | (-5,-12) | (0,0) | 13 + | (0,0) | (10,10) | 14.142135623731 + | (-3,4) | (10,10) | 14.3178210632764 + | (-5,-12) | (-3,4) | 16.1245154965971 + | (-10,0) | (10,10) | 22.3606797749979 + | (5.1,34.5) | (10,10) | 24.9851956166046 + | (-5,-12) | (10,10) | 26.6270539113887 + | (-3,4) | (5.1,34.5) | 31.5572495632937 + | (0,0) | (5.1,34.5) | 34.8749193547455 + | (-10,0) | (5.1,34.5) | 37.6597928831267 + | (-5,-12) | (5.1,34.5) | 47.5842410888311 +(15 rows) + +-- put distance result into output to allow sorting with GEQ optimizer - tgl 97/05/10 +SELECT '' AS three, p1.f1 AS point1, p2.f1 AS point2, (p1.f1 <-> p2.f1) AS distance + FROM POINT_TBL p1, POINT_TBL p2 + WHERE (p1.f1 <-> p2.f1) > 3 and p1.f1 << p2.f1 and p1.f1 >^ p2.f1 + ORDER BY distance, p1.f1[0], p1.f1[1], p2.f1[0], p2.f1[1]; + three | point1 | point2 | distance +-------+------------+----------+------------------ + | (-3,4) | (0,0) | 5 + | (-10,0) | (-5,-12) | 13 + | (5.1,34.5) | (10,10) | 24.9851956166046 +(3 rows) + diff --git a/src/test/regress/sql/point.sql b/src/test/regress/sql/point.sql index f991b4a..faa6b9e 100644 --- a/src/test/regress/sql/point.sql +++ b/src/test/regress/sql/point.sql @@ -2,7 +2,9 @@ -- POINT -- -CREATE TABLE POINT_TBL(f1 point); +-- Postgres-XC case: point type cannot use ORDER BY so table +-- is replicated for regression tests whatever the cluster configuration +CREATE TABLE POINT_TBL(f1 point) DISTRIBUTE BY REPLICATION; INSERT INTO POINT_TBL(f1) VALUES ('(0.0,0.0)'); ----------------------------------------------------------------------- Summary of changes: .../regress/expected/{point.out => point_1.out} | 8 +++++--- src/test/regress/sql/point.sql | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) copy src/test/regress/expected/{point.out => point_1.out} (97%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 13:40:46
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 33b9889d7cc947a702f2d4ff7cb147abdd606666 (commit) from f8d599dc12fe06669f4aadc5dddda3fc2c1109b8 (commit) - Log ----------------------------------------------------------------- commit 33b9889d7cc947a702f2d4ff7cb147abdd606666 Author: Michael P <mic...@us...> Date: Tue Mar 22 22:39:33 2011 +0900 Fix for regression test tablespace Correct output file used as source. diff --git a/src/test/regress/expected/tablespace_1.out b/src/test/regress/output/tablespace_1.source similarity index 97% rename from src/test/regress/expected/tablespace_1.out rename to src/test/regress/output/tablespace_1.source index 725ad23..18bd4d1 100644 --- a/src/test/regress/expected/tablespace_1.out +++ b/src/test/regress/output/tablespace_1.source @@ -1,5 +1,5 @@ -- create a tablespace we can use -CREATE TABLESPACE testspace LOCATION '/home/abbas/pgxc/postgres-xc/src/test/regress/testtablespace'; +CREATE TABLESPACE testspace LOCATION '@testtablespace@'; ERROR: Postgres-XC does not support TABLESPACE yet DETAIL: The feature is not currently supported -- try setting and resetting some properties for the new tablespace ----------------------------------------------------------------------- Summary of changes: .../tablespace_1.source} | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) rename src/test/regress/{expected/tablespace_1.out => output/tablespace_1.source} (97%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 09:46:25
|
Project "Postgres-XC". The branch, ha_support has been updated via 4d3f0a48a979044c6b741f9cd7d4dc37c32548e2 (commit) via 490c08dd37fa44af57cd3a2b3e931ef4f3a94853 (commit) from 5aec41aca3a30aa21948daa4326465fc1157023f (commit) - Log ----------------------------------------------------------------- commit 4d3f0a48a979044c6b741f9cd7d4dc37c32548e2 Merge: 5aec41a 490c08d Author: Michael P <mic...@us...> Date: Tue Mar 22 18:43:21 2011 +0900 Merge branch 'master' into ha_support ----------------------------------------------------------------------- Summary of changes: src/backend/Makefile | 2 - src/bin/initdb/initdb.c | 28 ------------ src/bin/scripts/Makefile | 2 - src/pgxc/bin/pgxc_ddl/README | 47 ++++++++++++++++++++ .../misc => pgxc/bin/pgxc_ddl}/pgxc.conf.sample | 0 src/{bin/scripts => pgxc/bin/pgxc_ddl}/pgxc_ddl | 0 6 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 src/pgxc/bin/pgxc_ddl/README rename src/{backend/utils/misc => pgxc/bin/pgxc_ddl}/pgxc.conf.sample (100%) rename src/{bin/scripts => pgxc/bin/pgxc_ddl}/pgxc_ddl (100%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 09:42:39
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via f8d599dc12fe06669f4aadc5dddda3fc2c1109b8 (commit) via 490c08dd37fa44af57cd3a2b3e931ef4f3a94853 (commit) from 55433e8be6a7b51568e4d727605b45e911c19f75 (commit) - Log ----------------------------------------------------------------- commit f8d599dc12fe06669f4aadc5dddda3fc2c1109b8 Merge: 55433e8 490c08d Author: Michael P <mic...@us...> Date: Tue Mar 22 18:29:42 2011 +0900 Merge branch 'master' into merge_postgres_9_0_3 Conflicts: src/backend/Makefile src/bin/scripts/Makefile diff --cc src/backend/Makefile index 23a9181,10e67c6..218639d --- a/src/backend/Makefile +++ b/src/backend/Makefile @@@ -283,13 -247,11 +280,12 @@@ endi endif $(MAKE) -C catalog uninstall-data $(MAKE) -C tsearch uninstall-data +# PGXC BEGIN rm -f '$(DESTDIR)$(datadir)/pg_hba.conf.sample' \ - '$(DESTDIR)$(datadir)/pgxc.conf.sample' \ '$(DESTDIR)$(datadir)/pg_ident.conf.sample' \ - '$(DESTDIR)$(datadir)/postgresql.conf.sample' \ + '$(DESTDIR)$(datadir)/postgresql.conf.sample' \ '$(DESTDIR)$(datadir)/recovery.conf.sample' - +# PGXC END ########################################################################## diff --cc src/bin/scripts/Makefile index 87430d2,c28a066..4248f3b --- a/src/bin/scripts/Makefile +++ b/src/bin/scripts/Makefile @@@ -54,12 -52,9 +54,9 @@@ install: all installdir $(INSTALL_PROGRAM) clusterdb$(X) '$(DESTDIR)$(bindir)'/clusterdb$(X) $(INSTALL_PROGRAM) vacuumdb$(X) '$(DESTDIR)$(bindir)'/vacuumdb$(X) $(INSTALL_PROGRAM) reindexdb$(X) '$(DESTDIR)$(bindir)'/reindexdb$(X) - # PGXC_BEGIN - $(INSTALL_PROGRAM) pgxc_ddl$(X) '$(DESTDIR)$(bindir)'/pgxc_ddl$(X) - chmod 555 '$(DESTDIR)$(bindir)'/pgxc_ddl$(X) - # PGXC_END + installdirs: - $(mkinstalldirs) '$(DESTDIR)$(bindir)' + $(MKDIR_P) '$(DESTDIR)$(bindir)' uninstall: rm -f $(addprefix '$(DESTDIR)$(bindir)'/, $(addsuffix $(X), $(PROGRAMS))) ----------------------------------------------------------------------- Summary of changes: src/backend/Makefile | 4 -- src/bin/initdb/initdb.c | 28 ------------ src/bin/scripts/Makefile | 5 +-- src/pgxc/bin/pgxc_ddl/README | 47 ++++++++++++++++++++ .../misc => pgxc/bin/pgxc_ddl}/pgxc.conf.sample | 0 src/{bin/scripts => pgxc/bin/pgxc_ddl}/pgxc_ddl | 0 6 files changed, 48 insertions(+), 36 deletions(-) create mode 100644 src/pgxc/bin/pgxc_ddl/README rename src/{backend/utils/misc => pgxc/bin/pgxc_ddl}/pgxc.conf.sample (100%) rename src/{bin/scripts => pgxc/bin/pgxc_ddl}/pgxc_ddl (100%) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-22 09:24:24
|
Project "Postgres-XC". The branch, master has been updated via 490c08dd37fa44af57cd3a2b3e931ef4f3a94853 (commit) from fbb0afd7b8858b13dc1f1f212742ffafcf4b7d8f (commit) - Log ----------------------------------------------------------------- commit 490c08dd37fa44af57cd3a2b3e931ef4f3a94853 Author: Michael P <mic...@us...> Date: Tue Mar 22 18:04:21 2011 +0900 Clean up of pgxc_ddl This script was used up to version 0.9.2 to make a cold synchronization of Coordinator catalogs when running a DDL. At this point, it was necessary to stop the cluster each time a DDL was launched, resulting in an unefficient process. This commit removes the dependencies between pgxc_ddl and XC (initdb). It is now not installed by default and moved to a new repository called src/pgxc/bin/pgxc_ddl. A README is also added. diff --git a/src/backend/Makefile b/src/backend/Makefile index 984c951..10e67c6 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -195,7 +195,6 @@ endif $(INSTALL_DATA) $(srcdir)/libpq/pg_hba.conf.sample '$(DESTDIR)$(datadir)/pg_hba.conf.sample' $(INSTALL_DATA) $(srcdir)/libpq/pg_ident.conf.sample '$(DESTDIR)$(datadir)/pg_ident.conf.sample' $(INSTALL_DATA) $(srcdir)/utils/misc/postgresql.conf.sample '$(DESTDIR)$(datadir)/postgresql.conf.sample' - $(INSTALL_DATA) $(srcdir)/utils/misc/pgxc.conf.sample '$(DESTDIR)$(datadir)/pgxc.conf.sample' $(INSTALL_DATA) $(srcdir)/access/transam/recovery.conf.sample '$(DESTDIR)$(datadir)/recovery.conf.sample' install-bin: postgres $(POSTGRES_IMP) installdirs @@ -249,7 +248,6 @@ endif $(MAKE) -C catalog uninstall-data $(MAKE) -C tsearch uninstall-data rm -f '$(DESTDIR)$(datadir)/pg_hba.conf.sample' \ - '$(DESTDIR)$(datadir)/pgxc.conf.sample' \ '$(DESTDIR)$(datadir)/pg_ident.conf.sample' \ '$(DESTDIR)$(datadir)/postgresql.conf.sample' \ '$(DESTDIR)$(datadir)/recovery.conf.sample' diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 67aa3e5..00c4126 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -100,9 +100,6 @@ static char *shdesc_file; static char *hba_file; static char *ident_file; static char *conf_file; -#ifdef PGXC -static char *pgxc_conf_file; -#endif static char *conversion_file; static char *dictionary_file; static char *info_schema_file; @@ -1299,19 +1296,6 @@ setup_config(void) free(conflines); -#ifdef PGXC - /* pgxc.conf */ - - conflines = readfile(pgxc_conf_file); - - snprintf(path, sizeof(path), "%s/pgxc.conf", pg_data); - - writefile(path, conflines); - chmod(path, 0600); - - free(conflines); -#endif - check_ok(); } @@ -2826,9 +2810,6 @@ main(int argc, char *argv[]) set_input(&hba_file, "pg_hba.conf.sample"); set_input(&ident_file, "pg_ident.conf.sample"); set_input(&conf_file, "postgresql.conf.sample"); -#ifdef PGXC - set_input(&pgxc_conf_file, "pgxc.conf.sample"); -#endif set_input(&conversion_file, "conversion_create.sql"); set_input(&dictionary_file, "snowball_create.sql"); set_input(&info_schema_file, "information_schema.sql"); @@ -2845,18 +2826,12 @@ main(int argc, char *argv[]) "POSTGRES_SUPERUSERNAME=%s\nPOSTGRES_BKI=%s\n" "POSTGRES_DESCR=%s\nPOSTGRES_SHDESCR=%s\n" "POSTGRESQL_CONF_SAMPLE=%s\n" -#ifdef PGXC - "PGXC_CONF_SAMPLE=%s\n" -#endif "PG_HBA_SAMPLE=%s\nPG_IDENT_SAMPLE=%s\n", PG_VERSION, pg_data, share_path, bin_path, username, bki_file, desc_file, shdesc_file, conf_file, -#ifdef PGXC - pgxc_conf_file, -#endif hba_file, ident_file); if (show_setting) exit(0); @@ -2867,9 +2842,6 @@ main(int argc, char *argv[]) check_input(shdesc_file); check_input(hba_file); check_input(ident_file); -#ifdef PGXC - check_input(pgxc_conf_file); -#endif check_input(conf_file); check_input(conversion_file); check_input(dictionary_file); diff --git a/src/bin/scripts/Makefile b/src/bin/scripts/Makefile index 48f9c20..c28a066 100644 --- a/src/bin/scripts/Makefile +++ b/src/bin/scripts/Makefile @@ -52,8 +52,6 @@ install: all installdirs $(INSTALL_PROGRAM) clusterdb$(X) '$(DESTDIR)$(bindir)'/clusterdb$(X) $(INSTALL_PROGRAM) vacuumdb$(X) '$(DESTDIR)$(bindir)'/vacuumdb$(X) $(INSTALL_PROGRAM) reindexdb$(X) '$(DESTDIR)$(bindir)'/reindexdb$(X) - $(INSTALL_PROGRAM) pgxc_ddl$(X) '$(DESTDIR)$(bindir)'/pgxc_ddl$(X) - chmod 555 '$(DESTDIR)$(bindir)'/pgxc_ddl$(X) installdirs: $(mkinstalldirs) '$(DESTDIR)$(bindir)' diff --git a/src/pgxc/bin/pgxc_ddl/README b/src/pgxc/bin/pgxc_ddl/README new file mode 100644 index 0000000..0a2c440 --- /dev/null +++ b/src/pgxc/bin/pgxc_ddl/README @@ -0,0 +1,47 @@ +Postgres-XC - pgxc_ddl +===================================== + +This directory contains pgxc_ddl, an application used to make a cold synchronization of DDL +in a Postgres-XC cluster by launching DDL and then copy Coordinator catalog file +data from a remote Coordinator (where DDL has been launched) to other Coordinators. + +pgxc_ddl can also be used to synchronize catalog files. + +pgxc_ddl was put in the default install repository before DDL synchronizing was implemented +(prior to version Postgres-XC 0.9.3). + +pgxc_ddl can be used with a configuration file called pgxc.conf. +This file is kept with the name pgxc.conf.sample to stick with PostgreSQL format. +Up to v0.9.3, pgxc.conf was by default installed by initdb in a data folder, +but this is not really necessary since DDL Synchronization is implemented in Postgres-XC. + +So it is kept in a separate repository src/pgxc/bin/pgxc_ddl/. + +===================================== +pgxc_ddl +===================================== +This script uses the following options: +- D to locate the data folder, necessary to find pgxc.conf, + containing the characteristics of all the coordinators +- l to locate the folder where applications are +- f for a DDL file used as input +- d for a Database name on which to launch DDL +- n coordinator number where to launch DDL, + number based on the one written in pgxc.conf +- t base name of folder where to save configuration files, + by default /tmp/pgxc_config, completed by $$ (process number for folder name uniqueness) + +===================================== +pgxc.conf.sample +===================================== +Same format as for GUC files is used. + +This configuration file contains the list of following parameters: +- coordinator_hosts, list of Coordinator hosts + This is an array and format is 'host_name_1,host_name_2'. +- coordinator_ports, list of Coordinator ports + This is an array and format is 'port_1,port_2' +- coordinator_folders + This is an array and format is 'data_folder_1,data_folder_2' + +All the arrays need to have the same size equal to the number of Coordinators. diff --git a/src/backend/utils/misc/pgxc.conf.sample b/src/pgxc/bin/pgxc_ddl/pgxc.conf.sample similarity index 100% rename from src/backend/utils/misc/pgxc.conf.sample rename to src/pgxc/bin/pgxc_ddl/pgxc.conf.sample diff --git a/src/bin/scripts/pgxc_ddl b/src/pgxc/bin/pgxc_ddl/pgxc_ddl similarity index 100% rename from src/bin/scripts/pgxc_ddl rename to src/pgxc/bin/pgxc_ddl/pgxc_ddl ----------------------------------------------------------------------- Summary of changes: src/backend/Makefile | 2 - src/bin/initdb/initdb.c | 28 ------------ src/bin/scripts/Makefile | 2 - src/pgxc/bin/pgxc_ddl/README | 47 ++++++++++++++++++++ .../misc => pgxc/bin/pgxc_ddl}/pgxc.conf.sample | 0 src/{bin/scripts => pgxc/bin/pgxc_ddl}/pgxc_ddl | 0 6 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 src/pgxc/bin/pgxc_ddl/README rename src/{backend/utils/misc => pgxc/bin/pgxc_ddl}/pgxc.conf.sample (100%) rename src/{bin/scripts => pgxc/bin/pgxc_ddl}/pgxc_ddl (100%) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-21 17:13:10
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 55433e8be6a7b51568e4d727605b45e911c19f75 (commit) from 9e3f4ae484fd7d8403fe59fecc95d065c3c839bf (commit) - Log ----------------------------------------------------------------- commit 55433e8be6a7b51568e4d727605b45e911c19f75 Author: Abbas <abb...@en...> Date: Mon Mar 21 22:08:01 2011 +0500 Fix for server crash 3148037 : does not fix WHERE CURRENT OF, only fixes server crash diff --git a/src/backend/pgxc/pool/pgxcnode.c b/src/backend/pgxc/pool/pgxcnode.c index 7baddd3..e93ee7f 100644 --- a/src/backend/pgxc/pool/pgxcnode.c +++ b/src/backend/pgxc/pool/pgxcnode.c @@ -1476,7 +1476,12 @@ get_handles(List *datanodelist, List *coordlist, bool is_coord_only_query) { int node = lfirst_int(node_list_item); - Assert(node > 0 && node <= NumDataNodes); + if (node <= 0 || node > NumDataNodes) + { + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("Invalid data node number"))); + } result->datanode_handles[i++] = &dn_handles[node - 1]; if (dn_handles[node - 1].sock == NO_SOCKET) @@ -1535,7 +1540,12 @@ get_handles(List *datanodelist, List *coordlist, bool is_coord_only_query) { int node = lfirst_int(node_list_item); - Assert(node > 0 && node <= NumCoords); + if (node <= 0 || node > NumCoords) + { + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("Invalid coordinator number"))); + } result->coord_handles[i++] = &co_handles[node - 1]; if (co_handles[node - 1].sock == NO_SOCKET) @@ -1579,6 +1589,13 @@ get_handles(List *datanodelist, List *coordlist, bool is_coord_only_query) int node = lfirst_int(node_list_item); int fdsock = fds[j++]; + if (node <= 0 || node > NumDataNodes) + { + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("Invalid data node number"))); + } + pgxc_node_init(&dn_handles[node - 1], fdsock, node); datanode_count++; } @@ -1591,6 +1608,13 @@ get_handles(List *datanodelist, List *coordlist, bool is_coord_only_query) int node = lfirst_int(node_list_item); int fdsock = fds[j++]; + if (node <= 0 || node > NumCoords) + { + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("Invalid coordinator number"))); + } + pgxc_node_init(&co_handles[node - 1], fdsock, node); coord_count++; } @@ -1610,7 +1634,6 @@ get_handles(List *datanodelist, List *coordlist, bool is_coord_only_query) return result; } - /* * Return handles involved into current transaction, to run commit or rollback * on them, as requested. ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/pgxcnode.c | 29 ++++++++++++++++++++++++++--- 1 files changed, 26 insertions(+), 3 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-21 16:19:57
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 9e3f4ae484fd7d8403fe59fecc95d065c3c839bf (commit) from 0f0f1798b83b01d3323cd0a9e63e5069e4fb1d4c (commit) - Log ----------------------------------------------------------------- commit 9e3f4ae484fd7d8403fe59fecc95d065c3c839bf Author: Michael P <mic...@us...> Date: Tue Mar 22 01:18:24 2011 +0900 Fix for bug 3205043: pg_dump support for MODULO table A new extension of CREATE TABLE distribution type has been added recently but pg_dump didn't support it. diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 0077aab..1cc688c 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -10809,6 +10809,12 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) appendPQExpBuffer(q, "\nDISTRIBUTE BY HASH (%s)", fmtId(tbinfo->attnames[hashkey - 1])); } + else if (tbinfo->pgxclocatortype == 'M') + { + int hashkey = tbinfo->pgxcattnum; + appendPQExpBuffer(q, "\nDISTRIBUTE BY MODULO (%s)", + fmtId(tbinfo->attnames[hashkey - 1])); + } } #endif ----------------------------------------------------------------------- Summary of changes: src/bin/pg_dump/pg_dump.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-21 14:49:16
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 0f0f1798b83b01d3323cd0a9e63e5069e4fb1d4c (commit) from 476f70fbc5292378da7d7e70283b2f44aa0d9d05 (commit) - Log ----------------------------------------------------------------- commit 0f0f1798b83b01d3323cd0a9e63e5069e4fb1d4c Author: Michael P <mic...@us...> Date: Mon Mar 21 23:22:37 2011 +0900 Fix for bugs 3124253 and 3202554: Unique remote query node Postgres-XC has been implemented in a way that allowed the creation of multiple RemoteQuery nodes having the same query. This was resulting in launching several times the same query on backend nodes, making an error for queries that are internally transformed several times as a CREATE first and then ALTER for constraint treatments. In this commit, only top-level queries are allowed to create a RemoteQuery node, assuring the uniqueness of what is sent to backend nodes. Here are a couple of cases solved. For example REFERENCES: CREATE TABLE truncate_a (col1 integer primary key); CREATE TABLE trunc_b (a int REFERENCES truncate_a); or multiple schema queries: CREATE SCHEMA temp_view_test CREATE TABLE base_table (a int, id int) CREATE TABLE base_table2 (a int, id int); diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c index 0b7344f..09ae5c3 100644 --- a/src/backend/commands/schemacmds.c +++ b/src/backend/commands/schemacmds.c @@ -41,7 +41,11 @@ static void AlterSchemaOwner_internal(HeapTuple tup, Relation rel, Oid newOwnerI * CREATE SCHEMA */ void +#ifdef PGXC +CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString, bool is_top_level) +#else CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString) +#endif { const char *schemaName = stmt->schemaname; const char *authId = stmt->authid; @@ -122,6 +126,14 @@ CreateSchemaCommand(CreateSchemaStmt *stmt, const char *queryString) */ parsetree_list = transformCreateSchemaStmt(stmt); +#ifdef PGXC + /* + * Add a RemoteQuery node for a query at top level on a remote Coordinator + */ + if (is_top_level) + parsetree_list = AddRemoteQueryNode(parsetree_list, queryString); +#endif + /* * Execute each command contained in the CREATE SCHEMA. Since the grammar * allows only utility commands in CREATE SCHEMA, there is no need to pass diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 0ed66ed..6cfc1e6 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -278,17 +278,8 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString) stmt->distributeby->disttype = DISTTYPE_HASH; stmt->distributeby->colname = cxt.fallback_dist_col; } - /* Only a remote Coordinator is allowed to send a query to backend nodes */ - if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) - { - RemoteQuery *step = makeNode(RemoteQuery); - step->combine_type = COMBINE_TYPE_SAME; - step->sql_statement = queryString; - /* This query is a DDL, Launch it on both Datanodes and Coordinators. */ - step->exec_type = EXEC_ON_ALL_NODES; - result = lappend(result, step); - } #endif + return result; } @@ -2224,17 +2215,7 @@ transformAlterTableStmt(AlterTableStmt *stmt, const char *queryString) result = lappend(cxt.blist, stmt); result = list_concat(result, cxt.alist); result = list_concat(result, save_alist); -#ifdef PGXC - if (IS_PGXC_COORDINATOR) - { - RemoteQuery *step = makeNode(RemoteQuery); - step->combine_type = COMBINE_TYPE_SAME; - step->sql_statement = queryString; - /* This query is a DDl, it is launched on both Coordinators and Datanodes. */ - step->exec_type = EXEC_ON_ALL_NODES; - result = lappend(result, step); - } -#endif + return result; } @@ -2637,4 +2618,30 @@ checkLocalFKConstraints(CreateStmtContext *cxt) } } } + +/* + * AddRemoteQueryNode + * + * Add a Remote Query node to launch on Datanodes. + * This can only be done for a query a Top Level to avoid + * duplicated queries on Datanodes. + */ +List * +AddRemoteQueryNode(List *stmts, const char *queryString) +{ + List *result = stmts; + + /* Only a remote Coordinator is allowed to send a query to backend nodes */ + if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) + { + RemoteQuery *step = makeNode(RemoteQuery); + step->combine_type = COMBINE_TYPE_SAME; + step->sql_statement = queryString; + /* This query is a DDL, Launch it on both Datanodes and Coordinators. */ + step->exec_type = EXEC_ON_ALL_NODES; + result = lappend(result, step); + } + + return result; +} #endif diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index c278ea0..d06fdb2 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -592,11 +592,12 @@ standard_ProcessUtility(Node *parsetree, */ case T_CreateSchemaStmt: #ifdef PGXC - if (IS_PGXC_COORDINATOR) - ExecUtilityStmtOnNodes(queryString, NULL, false, EXEC_ON_ALL_NODES); -#endif + CreateSchemaCommand((CreateSchemaStmt *) parsetree, + queryString, isTopLevel); +#else CreateSchemaCommand((CreateSchemaStmt *) parsetree, queryString); +#endif break; case T_CreateStmt: @@ -605,11 +606,18 @@ standard_ProcessUtility(Node *parsetree, ListCell *l; Oid relOid; - /* PGXC transformCreateStmt also adds T_RemoteQuery node */ /* Run parse analysis ... */ stmts = transformCreateStmt((CreateStmt *) parsetree, queryString); +#ifdef PGXC + /* + * Add a RemoteQuery node for a query at top level on a remote Coordinator + */ + if (isTopLevel) + stmts = AddRemoteQueryNode(stmts, queryString); +#endif + /* ... and do it */ foreach(l, stmts) { @@ -879,10 +887,16 @@ standard_ProcessUtility(Node *parsetree, List *stmts; ListCell *l; - /* PGXC transformCreateStmt also adds T_RemoteQuery node */ /* Run parse analysis ... */ stmts = transformAlterTableStmt((AlterTableStmt *) parsetree, queryString); +#ifdef PGXC + /* + * Add a RemoteQuery node for a query at top level on a remote Coordinator + */ + if (isTopLevel) + stmts = AddRemoteQueryNode(stmts, queryString); +#endif /* ... and do it */ foreach(l, stmts) diff --git a/src/include/commands/schemacmds.h b/src/include/commands/schemacmds.h index 760d147..008fe41 100644 --- a/src/include/commands/schemacmds.h +++ b/src/include/commands/schemacmds.h @@ -17,9 +17,13 @@ #include "nodes/parsenodes.h" +#ifdef PGXC +extern void CreateSchemaCommand(CreateSchemaStmt *parsetree, + const char *queryString, bool is_top_level); +#else extern void CreateSchemaCommand(CreateSchemaStmt *parsetree, const char *queryString); - +#endif extern void RemoveSchemas(DropStmt *drop); extern void RemoveSchemaById(Oid schemaOid); diff --git a/src/include/parser/parse_utilcmd.h b/src/include/parser/parse_utilcmd.h index 3f9b8f9..256c583 100644 --- a/src/include/parser/parse_utilcmd.h +++ b/src/include/parser/parse_utilcmd.h @@ -27,6 +27,7 @@ extern void transformRuleStmt(RuleStmt *stmt, const char *queryString, extern List *transformCreateSchemaStmt(CreateSchemaStmt *stmt); #ifdef PGXC extern bool CheckLocalIndexColumn (char loctype, char *partcolname, char *indexcolname); +extern List *AddRemoteQueryNode(List *stmts, const char *queryString); #endif #endif /* PARSE_UTILCMD_H */ ----------------------------------------------------------------------- Summary of changes: src/backend/commands/schemacmds.c | 12 +++++++++ src/backend/parser/parse_utilcmd.c | 49 ++++++++++++++++++++--------------- src/backend/tcop/utility.c | 24 ++++++++++++++--- src/include/commands/schemacmds.h | 6 +++- src/include/parser/parse_utilcmd.h | 1 + 5 files changed, 65 insertions(+), 27 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-21 10:22:27
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 476f70fbc5292378da7d7e70283b2f44aa0d9d05 (commit) from 7aaee8d89ad4f9dd211042e65ecad68edbc1e9bc (commit) - Log ----------------------------------------------------------------- commit 476f70fbc5292378da7d7e70283b2f44aa0d9d05 Author: Michael P <mic...@us...> Date: Mon Mar 21 19:19:12 2011 +0900 Fix for bug 3141640: non column select This query was crashing: create table aa(); select * from aa; This permits to check if the target list of a table for a SELECT query is empty and if it is the case send down to Datanodes a query containing "*". Patch written by Benny Wang diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index 7f53a22..d517899 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -2800,6 +2800,11 @@ ExecInitRemoteQuery(RemoteQuery *node, EState *estate, int eflags) TupleDesc typeInfo = ExecCleanTypeFromTL(node->scan.plan.targetlist, false); ExecSetSlotDescriptor(remotestate->ss.ps.ps_ResultTupleSlot, typeInfo); } + else + { + /* In case there is no target list, force its creation */ + ExecAssignResultTypeFromTL(&remotestate->ss.ps); + } ExecInitScanTupleSlot(estate, &remotestate->ss); diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 514abdb..1da8609 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3010,6 +3010,9 @@ get_target_list(List *targetList, deparse_context *context, char *sep; int colno; ListCell *l; +#ifdef PGXC + bool no_targetlist = true; +#endif sep = " "; colno = 0; @@ -3022,6 +3025,12 @@ get_target_list(List *targetList, deparse_context *context, if (tle->resjunk) continue; /* ignore junk entries */ +#ifdef PGXC + /* Found at least one element in the target list */ + if (no_targetlist) + no_targetlist = false; +#endif + appendStringInfoString(buf, sep); sep = ", "; colno++; @@ -3063,6 +3072,17 @@ get_target_list(List *targetList, deparse_context *context, appendStringInfo(buf, " AS %s", quote_identifier(colname)); } } + +#ifdef PGXC + /* + * Because the empty target list can generate invalid SQL + * clause. Here, just fill a '*' to process a table without + * any columns, this statement will be sent to data nodes + * and treated correctly on remote nodes. + */ + if (no_targetlist) + appendStringInfo(buf, " *"); +#endif } static void ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/execRemote.c | 5 +++++ src/backend/utils/adt/ruleutils.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-21 09:14:52
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 7aaee8d89ad4f9dd211042e65ecad68edbc1e9bc (commit) from c739272f73a860a1c1a07ea085c47e8d4e292420 (commit) - Log ----------------------------------------------------------------- commit 7aaee8d89ad4f9dd211042e65ecad68edbc1e9bc Author: Michael P <mic...@us...> Date: Mon Mar 21 18:10:47 2011 +0900 Fix for bugs 3148479, 3140473: COPY FROM CVS HEADER, COPY TO WITH CSV QUOTE When using a CVS HEADER for COPY FROM, only data rows should be sent to Datanodes. QUOTE problem was resulting in a incorrect output for data rows using quotes. Patches written by Benny Wang diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index c4643be..15f97a1 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -3968,19 +3968,17 @@ build_copy_statement(CopyState cstate, List *attnamelist, appendStringInfoString(&cstate->query_buf, " CSV"); /* - * Only rewrite the header part for COPY FROM, - * doing that for COPY TO results in multiple headers in output + * It is not necessary to send the HEADER part to Datanodes. + * Sending data is sufficient. */ - if (cstate->header_line && is_from) - appendStringInfoString(&cstate->query_buf, " HEADER"); - if (cstate->quote && cstate->quote[0] == '"') + if (cstate->quote && cstate->quote[0] != '"') { appendStringInfoString(&cstate->query_buf, " QUOTE AS "); CopyQuoteStr(&cstate->query_buf, cstate->quote); } - if (cstate->escape && cstate->quote && cstate->escape[0] == cstate->quote[0]) + if (cstate->escape && cstate->quote && cstate->escape[0] != cstate->quote[0]) { appendStringInfoString(&cstate->query_buf, " ESCAPE AS "); CopyQuoteStr(&cstate->query_buf, cstate->escape); ----------------------------------------------------------------------- Summary of changes: src/backend/commands/copy.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-) hooks/post-receive -- Postgres-XC |
From: Pavan D. <pa...@us...> - 2011-03-18 05:43:14
|
Project "Postgres-XC". The branch, pgxc-barrier has been created at df86ba5f78e6f0a350a229ef565536ca4b5826f8 (commit) - Log ----------------------------------------------------------------- commit df86ba5f78e6f0a350a229ef565536ca4b5826f8 Author: Pavan Deolasee <pav...@gm...> Date: Tue Mar 8 16:45:12 2011 +0530 First cut implementation of BARRIER for PITR and global consistent recovery diff --git a/src/backend/access/transam/rmgr.c b/src/backend/access/transam/rmgr.c index 0273b0e..70f2e42 100644 --- a/src/backend/access/transam/rmgr.c +++ b/src/backend/access/transam/rmgr.c @@ -20,9 +20,11 @@ #include "commands/dbcommands.h" #include "commands/sequence.h" #include "commands/tablespace.h" +#ifdef PGXC +#include "pgxc/barrier.h" +#endif #include "storage/freespace.h" - const RmgrData RmgrTable[RM_MAX_ID + 1] = { {"XLOG", xlog_redo, xlog_desc, NULL, NULL, NULL}, {"Transaction", xact_redo, xact_desc, NULL, NULL, NULL}, @@ -40,4 +42,8 @@ const RmgrData RmgrTable[RM_MAX_ID + 1] = { {"Gin", gin_redo, gin_desc, gin_xlog_startup, gin_xlog_cleanup, gin_safe_restartpoint}, {"Gist", gist_redo, gist_desc, gist_xlog_startup, gist_xlog_cleanup, gist_safe_restartpoint}, {"Sequence", seq_redo, seq_desc, NULL, NULL, NULL} +#ifdef PGXC + , + {"Barrier", barrier_redo, barrier_desc, NULL, NULL, NULL} +#endif }; diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 8ff88dd..1f3b218 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -38,6 +38,7 @@ #include "funcapi.h" #include "libpq/pqsignal.h" #include "miscadmin.h" +#include "pgxc/barrier.h" #include "pgstat.h" #include "postmaster/bgwriter.h" #include "storage/bufmgr.h" @@ -166,6 +167,7 @@ static bool recoveryTargetInclusive = true; static TransactionId recoveryTargetXid; static TimestampTz recoveryTargetTime; static TimestampTz recoveryLastXTime = 0; +static char *recoveryTargetBarrierId; /* if recoveryStopsHere returns true, it saves actual stop xid/time here */ static TransactionId recoveryStopXid; @@ -4927,6 +4929,13 @@ readRecoveryCommandFile(void) ereport(LOG, (errmsg("recovery_target_inclusive = %s", tok2))); } +#ifdef PGXC + else if (strcmp(tok1, "recovery_barrier_id") == 0) + { + recoveryTarget = true; + recoveryTargetBarrierId = pstrdup(tok2); + } +#endif else ereport(FATAL, (errmsg("unrecognized recovery parameter \"%s\"", @@ -5109,11 +5118,20 @@ static bool recoveryStopsHere(XLogRecord *record, bool *includeThis) { bool stopsHere; +#ifdef PGXC + bool stopsAtThisBarrier; + char *recordBarrierId; +#endif uint8 record_info; TimestampTz recordXtime; +#ifdef PGXC + /* We only consider stoppping at COMMIT, ABORT or BARRIER records */ + if ((record->xl_rmid != RM_XACT_ID) && (record->xl_rmid != RM_BARRIER_ID)) +#else /* We only consider stopping at COMMIT or ABORT records */ if (record->xl_rmid != RM_XACT_ID) +#endif return false; record_info = record->xl_info & ~XLR_INFO_MASK; if (record_info == XLOG_XACT_COMMIT) @@ -5130,6 +5148,12 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) recordXactAbortData = (xl_xact_abort *) XLogRecGetData(record); recordXtime = recordXactAbortData->xact_time; } +#ifdef PGXC + else if (record_info == XLOG_BARRIER_CREATE) + { + recordBarrierId = (char *) XLogRecGetData(record); + } +#endif else return false; @@ -5155,6 +5179,13 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) if (stopsHere) *includeThis = recoveryTargetInclusive; } +#ifdef PGXC + else if (recoveryTargetBarrierId) + { + if (strcmp(recoveryTargetBarrierId, recordBarrierId) == 0) + stopsAtThisBarrier = true; + } +#endif else { /* @@ -5206,6 +5237,17 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis) if (recoveryStopAfter) recoveryLastXTime = recordXtime; } +#ifdef PGXC + else if (stopsAtThisBarrier) + { + recoveryStopTime = recordXtime; + ereport(LOG, + (errmsg("recovery stopping at barrier %s, time %s", + recoveryTargetBarrierId, + timestamptz_to_str(recoveryStopTime)))); + return true; + } +#endif else recoveryLastXTime = recordXtime; diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 13e47e9..d980e5f 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -3592,6 +3592,18 @@ _copyValue(Value *from) return newnode; } +#ifdef PGXC +static BarrierStmt * +_copyBarrierStmt(BarrierStmt *from) +{ + BarrierStmt *newnode = makeNode(BarrierStmt); + + COPY_STRING_FIELD(id); + + return newnode; +} +#endif + /* * copyObject * @@ -4152,6 +4164,11 @@ copyObject(void *from) case T_CheckPointStmt: retval = (void *) makeNode(CheckPointStmt); break; +#ifdef PGXC + case T_BarrierStmt: + retval = _copyBarrierStmt(from); + break; +#endif case T_CreateSchemaStmt: retval = _copyCreateSchemaStmt(from); break; diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 32ac010..fbe5074 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -2306,6 +2306,16 @@ _equalValue(Value *a, Value *b) return true; } +#ifdef PGXC + +static bool +_equalBarrierStmt(BarrierStmt *a, BarrierStmt *b) +{ + COMPARE_STRING_FIELD(id); + return true; +} +#endif + /* * equal * returns whether two nodes are equal @@ -2744,6 +2754,11 @@ equal(void *a, void *b) case T_CheckPointStmt: retval = true; break; +#ifdef PGXC + case T_BarrierStmt: + retval = _equalBarrierStmt(a, b); + break; +#endif case T_CreateSchemaStmt: retval = _equalCreateSchemaStmt(a, b); break; diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index e1266ed..6df0582 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -215,6 +215,7 @@ static TypeName *TableFuncTypeName(List *columns); DeallocateStmt PrepareStmt ExecuteStmt DropOwnedStmt ReassignOwnedStmt AlterTSConfigurationStmt AlterTSDictionaryStmt + BarrierStmt %type <node> select_no_parens select_with_parens select_clause simple_select values_clause @@ -424,6 +425,7 @@ static TypeName *TableFuncTypeName(List *columns); %type <str> opt_existing_window_name %type <ival> opt_frame_clause frame_extent frame_bound /* PGXC_BEGIN */ +%type <str> opt_barrier_id %type <distby> OptDistributeBy /* PGXC_END */ @@ -436,12 +438,12 @@ static TypeName *TableFuncTypeName(List *columns); */ /* ordinary key words in alphabetical order */ -/* PGXC - added REPLICATION, DISTRIBUTE, MODULO and HASH */ +/* PGXC - added REPLICATION, DISTRIBUTE, MODULO, BARRIER and HASH */ %token <keyword> ABORT_P ABSOLUTE_P ACCESS ACTION ADD_P ADMIN AFTER AGGREGATE ALL ALSO ALTER ALWAYS ANALYSE ANALYZE AND ANY ARRAY AS ASC ASSERTION ASSIGNMENT ASYMMETRIC AT AUTHORIZATION - BACKWARD BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT + BACKWARD BARRIER BEFORE BEGIN_P BETWEEN BIGINT BINARY BIT BOOLEAN_P BOTH BY CACHE CALLED CASCADE CASCADED CASE CAST CATALOG_P CHAIN CHAR_P @@ -636,6 +638,7 @@ stmt : | AlterUserSetStmt | AlterUserStmt | AnalyzeStmt + | BarrierStmt | CheckPointStmt | CleanConnStmt | ClosePortalStmt @@ -6506,6 +6509,28 @@ opt_name_list: ; +/* PGXC_BEGIN */ +BarrierStmt: CREATE BARRIER opt_barrier_id + { + BarrierStmt *n = makeNode(BarrierStmt); + n->id = $3; + $$ = (Node *)n; + } + ; + +opt_barrier_id: + Sconst + { + $$ = pstrdup($1); + } + | /* EMPTY */ + { + $$ = NULL; + } + ; + +/* PGXC_END */ + /***************************************************************************** * * QUERY: @@ -10289,7 +10314,7 @@ ColLabel: IDENT { $$ = $1; } /* "Unreserved" keywords --- available for use as any kind of name. */ -/* PGXC - added DISTRIBUTE, HASH, REPLICATION, MODULO */ +/* PGXC - added DISTRIBUTE, HASH, REPLICATION, MODULO, BARRIER */ unreserved_keyword: ABORT_P | ABSOLUTE_P @@ -10306,6 +10331,9 @@ unreserved_keyword: | ASSIGNMENT | AT | BACKWARD +/* PGXC_BEGIN */ + | BARRIER +/* PGXC_END */ | BEFORE | BEGIN_P | BY diff --git a/src/backend/pgxc/Makefile b/src/backend/pgxc/Makefile index eecac20..ad6bb64 100644 --- a/src/backend/pgxc/Makefile +++ b/src/backend/pgxc/Makefile @@ -11,6 +11,6 @@ subdir = src/backend/pgxc top_builddir = ../../.. include $(top_builddir)/src/Makefile.global -SUBDIRS = locator plan pool +SUBDIRS = locator plan pool barrier include $(top_srcdir)/src/backend/common.mk diff --git a/src/backend/pgxc/barrier/Makefile b/src/backend/pgxc/barrier/Makefile new file mode 100644 index 0000000..d80bbec --- /dev/null +++ b/src/backend/pgxc/barrier/Makefile @@ -0,0 +1,19 @@ +#------------------------------------------------------------------------- +# +# Makefile-- +# Makefile for pool +# +# Portions Copyright (c) 2010-2011 Nippon Telegraph and Telephone Corporation +# +# IDENTIFICATION +# $PostgreSQL$ +# +#------------------------------------------------------------------------- + +subdir = src/backend/pgxc/barrier +top_builddir = ../../../.. +include $(top_builddir)/src/Makefile.global + +OBJS = barrier.o + +include $(top_srcdir)/src/backend/common.mk diff --git a/src/backend/pgxc/barrier/barrier.c b/src/backend/pgxc/barrier/barrier.c new file mode 100644 index 0000000..3e1d7cc --- /dev/null +++ b/src/backend/pgxc/barrier/barrier.c @@ -0,0 +1,493 @@ +/*------------------------------------------------------------------------- + * + * barrier.c + * + * Barrier handling for PITR + * + * + * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group + * Portions Copyright (c) 2010-2011 Nippon Telegraph and Telephone Corporation + * + * IDENTIFICATION + * $$ + * + *------------------------------------------------------------------------- + */ + +#include "postgres.h" +#include "libpq/libpq.h" +#include "libpq/pqformat.h" +#include "pgxc/barrier.h" +#include "pgxc/execRemote.h" +#include "pgxc/locator.h" +#include "pgxc/pgxc.h" +#include "pgxc/pgxcnode.h" +#include "storage/lwlock.h" +#include "tcop/dest.h" + +static const char *generate_barrier_id(const char *id); +static PGXCNodeAllHandles *PrepareBarrier(const char *id); +static void ExecuteBarrier(const char *id); +static void EndBarrier(PGXCNodeAllHandles *handles, const char *id); + +extern void ProcessCreateBarrierPrepare(const char *id); +extern void ProcessCreateBarrierEnd(const char *id); +extern void ProcessCreateBarrierExecute(const char *id); + +/* + * Prepare ourselves for an incoming BARRIER. We must disable all new 2PC + * commits and let the ongoing commits to finish. We then remember the + * barrier id (so that it can be matched with the final END message) and + * tell the driving coordinator to proceed with the next step. + * + * A simple way to implement this is to grab a lock in an exclusive mode + * while all other backend starting a 2PC will grab the lock in shared + * mode. So as long as we hold the exclusive lock, no other backend start a + * new 2PC and there can not be any 2PC in-progress. This technique would + * rely on assumption that an exclsuive lock requester is not starved by + * share lock requesters. + * + * Note: To ensure that the 2PC are not blocked for a long time, we should + * set a timeout. The lock should be release after the timeout and the + * barrier should be canceled. + */ +void +ProcessCreateBarrierPrepare(const char *id) +{ + StringInfoData buf; + + if (!IS_PGXC_COORDINATOR || !IsConnFromCoord()) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("The CREATE BARRIER PREPARE message is expected to " + "arrive at a coordinator from another coordinator"))); + + LWLockAcquire(BarrierLock, LW_EXCLUSIVE); + + pq_beginmessage(&buf, 'b'); + pq_sendstring(&buf, id); + pq_endmessage(&buf); + pq_flush(); + + /* + * TODO Start a timer to terminate the pending barrier after a specified + * timeout + */ +} + +/* + * Mark the completetion of an on-going barrier. We must have remembered the + * barrier ID when we received the CREATE BARRIER PREPARE command + */ +void +ProcessCreateBarrierEnd(const char *id) +{ + StringInfoData buf; + + if (!IS_PGXC_COORDINATOR || !IsConnFromCoord()) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("The CREATE BARRIER END message is expected to " + "arrive at a coordinator from another coordinator"))); + + LWLockRelease(BarrierLock); + + pq_beginmessage(&buf, 'b'); + pq_sendstring(&buf, id); + pq_endmessage(&buf); + pq_flush(); + + /* + * TODO Stop the timer + */ +} + +/* + * Execute the CREATE BARRIER comamnd. Write a BARRIER WAL record and flush the + * WAL buffers to disk before returning to the caller. Writing the WAL record + * does not guarantee successful completion of the barrier command. + */ +void +ProcessCreateBarrierExecute(const char *id) +{ + StringInfoData buf; + + if (!IsConnFromCoord()) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("The CREATE BARRIER EXECUTE message is expected to " + "arrive from a coordinator"))); + { + XLogRecData rdata[1]; + XLogRecPtr recptr; + + rdata[0].data = (char *) id; + rdata[0].len = strlen(id) + 1; + rdata[0].buffer = InvalidBuffer; + rdata[0].next = NULL; + + recptr = XLogInsert(RM_BARRIER_ID, XLOG_BARRIER_CREATE, rdata); + XLogFlush(recptr); + } + + pq_beginmessage(&buf, 'b'); + pq_sendstring(&buf, id); + pq_endmessage(&buf); + pq_flush(); +} + +static const char * +generate_barrier_id(const char *id) +{ + /* + * TODO If the caller can passeed a NULL value, generate an id which is + * guaranteed to be unique across the cluster. We can use a combination of + * the coordinator node id and a timestamp. This may not be complete if we + * support changing coordinator ids without initdb or the system clocks are + * modified. + * + * Another option would be to let the GTM issue globally unique barrier + * IDs. For the time being, we leave it to the user to come up with an + * unique identifier + */ + return id ? id : pstrdup("dummy_barrier_id"); +} + +static PGXCNodeAllHandles * +SendBarrierPrepareRequest(List *coords, const char *id) +{ + PGXCNodeAllHandles *coord_handles; + int conn; + int msglen; + int barrier_idlen; + + coord_handles = get_handles(NIL, coords, true); + + for (conn = 0; conn < coord_handles->co_conn_count; conn++) + { + PGXCNodeHandle *handle = coord_handles->coord_handles[conn]; + + /* Invalid connection state, return error */ + if (handle->state != DN_CONNECTION_STATE_IDLE) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to send CREATE BARRIER PREPARE request " + "to the node"))); + + barrier_idlen = strlen(id) + 1; + + msglen = 4; /* for the length itself */ + msglen += barrier_idlen; + msglen += 1; /* for barrier command itself */ + + /* msgType + msgLen */ + if (ensure_out_buffer_capacity(handle->outEnd + 1 + msglen, handle) != 0) + { + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Out of memory"))); + } + + handle->outBuffer[handle->outEnd++] = 'b'; + msglen = htonl(msglen); + memcpy(handle->outBuffer + handle->outEnd, &msglen, 4); + handle->outEnd += 4; + + handle->outBuffer[handle->outEnd++] = CREATE_BARRIER_PREPARE; + + memcpy(handle->outBuffer + handle->outEnd, id, barrier_idlen); + handle->outEnd += barrier_idlen; + + handle->state = DN_CONNECTION_STATE_QUERY; + + pgxc_node_flush(handle); + + /* FIXME Use the right context */ + handle->barrier_id = strdup(id); + } + + return coord_handles; +} + +static void +CheckBarrierCommandStatus(PGXCNodeAllHandles *conn_handles, const char *id, + const char *command) +{ + int conn; + int count = conn_handles->co_conn_count + conn_handles->dn_conn_count; + + elog(DEBUG2, "Check CREATE BARRIER <%s> %s command status", id, command); + + for (conn = 0; conn < count; conn++) + { + PGXCNodeHandle *handle; + + if (conn < conn_handles->co_conn_count) + handle = conn_handles->coord_handles[conn]; + else + handle = conn_handles->datanode_handles[conn - conn_handles->co_conn_count]; + + if (pgxc_node_receive(1, &handle, NULL)) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to receive response from the remote side"))); + + if (handle_response(handle, NULL) != RESPONSE_BARRIER_OK) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("CREATE BARRIER PREPARE command failed " + "with error %s", handle->error))); + } + + elog(DEBUG2, "Successfully completed CREATE BARRIER <%s> %s command on " + "all nodes", id, command); +} + +static void +SendBarrierEndRequest(PGXCNodeAllHandles *coord_handles, const char *id) +{ + int conn; + int msglen; + int barrier_idlen; + + elog(DEBUG2, "Sending CREATE BARRIER <%s> END command to all coordinators", id); + + for (conn = 0; conn < coord_handles->co_conn_count; conn++) + { + PGXCNodeHandle *handle = coord_handles->coord_handles[conn]; + + /* Invalid connection state, return error */ + if (handle->state != DN_CONNECTION_STATE_IDLE) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to send CREATE BARRIER PREPARE request " + "to the node"))); + + barrier_idlen = strlen(id) + 1; + + msglen = 4; /* for the length itself */ + msglen += barrier_idlen; + msglen += 1; /* for barrier command itself */ + + /* msgType + msgLen */ + if (ensure_out_buffer_capacity(handle->outEnd + 1 + msglen, handle) != 0) + { + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Out of memory"))); + } + + handle->outBuffer[handle->outEnd++] = 'b'; + msglen = htonl(msglen); + memcpy(handle->outBuffer + handle->outEnd, &msglen, 4); + handle->outEnd += 4; + + handle->outBuffer[handle->outEnd++] = CREATE_BARRIER_END; + + memcpy(handle->outBuffer + handle->outEnd, id, barrier_idlen); + handle->outEnd += barrier_idlen; + + handle->state = DN_CONNECTION_STATE_QUERY; + pgxc_node_flush(handle); + + /* FIXME Use the right context */ + handle->barrier_id = strdup(id); + } + +} + +/* + * Prepare all coordinators for barrier. During this step all the coordinators + * are informed to suspend any new 2PC transactions. The coordinators should + * disable new 2PC transactions and then wait for the existing transactions to + * complete. Once all "in-flight" 2PC transactions are over, the coordinators + * respond back. + * + * That completes the first step in barrier generation + * + * Any errors will be reported via ereport. + */ +static PGXCNodeAllHandles * +PrepareBarrier(const char *id) +{ + PGXCNodeAllHandles *coord_handles; + + elog(DEBUG2, "Preparing coordinators for BARRIER"); + + /* + * Send a CREATE BARRIER PREPARE message to all the coordinators. We should + * send an asynchronous request so that we can disable local commits and + * then wait for the remote coordinators to finish the work + */ + coord_handles = SendBarrierPrepareRequest(GetAllCoordNodes(), id); + + /* + * Disable local commits + */ + LWLockAcquire(BarrierLock, LW_EXCLUSIVE); + + elog(DEBUG2, "Disabled 2PC commits origniating at the diriving coordinator"); + + /* + * TODO Start a timer to cancel the barrier request in case of a timeout + */ + + /* + * Local in-flight commits are now over. Check status of the remote + * coordinators + */ + CheckBarrierCommandStatus(coord_handles, id, "PREPARE"); + + return coord_handles; +} + +/* + * Execute the barrier command on all the components, including data nodes and + * coordinators. + */ +static void +ExecuteBarrier(const char *id) +{ + List *barrierDataNodeList = GetAllDataNodes(); + List *barrierCoordList = GetAllCoordNodes(); + PGXCNodeAllHandles *conn_handles; + int conn; + int msglen; + int barrier_idlen; + + conn_handles = get_handles(barrierDataNodeList, barrierCoordList, false); + + elog(DEBUG2, "Sending CREATE BARRIER <%s> EXECUTE message to " + "data nodes and coordinator", id); + /* + * Send a CREATE BARRIER request to all the data nodes and the coordinators + */ + for (conn = 0; conn < conn_handles->co_conn_count + conn_handles->dn_conn_count; conn++) + { + PGXCNodeHandle *handle; + + if (conn < conn_handles->co_conn_count) + handle = conn_handles->coord_handles[conn]; + else + handle = conn_handles->datanode_handles[conn - conn_handles->co_conn_count]; + + /* Invalid connection state, return error */ + if (handle->state != DN_CONNECTION_STATE_IDLE) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Failed to send CREATE BARRIER PREPARE request " + "to the node"))); + + barrier_idlen = strlen(id) + 1; + + msglen = 4; /* for the length itself */ + msglen += barrier_idlen; + msglen += 1; /* for barrier command itself */ + + /* msgType + msgLen */ + if (ensure_out_buffer_capacity(handle->outEnd + 1 + msglen, handle) != 0) + { + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Out of memory"))); + } + + handle->outBuffer[handle->outEnd++] = 'b'; + msglen = htonl(msglen); + memcpy(handle->outBuffer + handle->outEnd, &msglen, 4); + handle->outEnd += 4; + + handle->outBuffer[handle->outEnd++] = CREATE_BARRIER_EXECUTE; + + memcpy(handle->outBuffer + handle->outEnd, id, barrier_idlen); + handle->outEnd += barrier_idlen; + + handle->state = DN_CONNECTION_STATE_QUERY; + pgxc_node_flush(handle); + + /* FIXME Use the right context */ + handle->barrier_id = strdup(id); + } + + CheckBarrierCommandStatus(conn_handles, id, "EXECUTE"); + + /* + * Also WAL log the BARRIER locally and flush the WAL buffers to disk + */ +} + +/* + * Resume 2PC commits on the local as well as remote coordinators. + */ +static void +EndBarrier(PGXCNodeAllHandles *prepared_handles, const char *id) +{ + /* Resume 2PC locally */ + LWLockRelease(BarrierLock); + + SendBarrierEndRequest(prepared_handles, id); + + CheckBarrierCommandStatus(prepared_handles, id, "END"); +} + +void +RequestBarrier(const char *id, char *completionTag) +{ + PGXCNodeAllHandles *prepared_handles; + const char *barrier_id; + + elog(DEBUG2, "CREATE BARRIER request received"); + /* + * Ensure that we are a coordinator and the request is not from another + * coordinator + */ + if (!IS_PGXC_COORDINATOR) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("CREATE BARRIER command must be sent to a coordinator"))); + + if (IsConnFromCoord()) + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("CREATE BARRIER command is not expected from another coordinator"))); + + /* + * Get a barrier id if the user has not supplied it + */ + barrier_id = generate_barrier_id(id); + + elog(DEBUG2, "CREATE BARRIER <%s>", barrier_id); + + /* + * Step One. Prepare all coordinators for upcoming barrier request + */ + prepared_handles = PrepareBarrier(barrier_id); + + /* + * Step two. Issue BARRIER command to all involved components, including + * coordinators and data nodes + */ + ExecuteBarrier(barrier_id); + + /* + * Step three. Inform coordinators about a successfully completed barrier + */ + EndBarrier(prepared_handles, barrier_id); + + if (completionTag) + snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "BARRIER %s", barrier_id); +} + +void +barrier_redo(XLogRecPtr lsn, XLogRecord *record) +{ + /* Nothing to do */ + return; +} + +void +barrier_desc(StringInfo buf, uint8 xl_info, char *rec) +{ + Assert(xl_info == XLOG_BARRIER_CREATE); + appendStringInfo(buf, "BARRIER %s", rec); +} diff --git a/src/backend/pgxc/pool/execRemote.c b/src/backend/pgxc/pool/execRemote.c index 711cd1f..849f36b 100644 --- a/src/backend/pgxc/pool/execRemote.c +++ b/src/backend/pgxc/pool/execRemote.c @@ -1347,6 +1347,7 @@ pgxc_node_receive_responses(const int conn_count, PGXCNodeHandle ** connections, * RESPONSE_TUPLEDESC - got tuple description * RESPONSE_DATAROW - got data row * RESPONSE_COPY - got copy response + * RESPONSE_BARRIER_OK - barrier command completed successfully */ int handle_response(PGXCNodeHandle * conn, RemoteQueryState *combiner) @@ -1458,6 +1459,16 @@ handle_response(PGXCNodeHandle * conn, RemoteQueryState *combiner) #endif return result; } + +#ifdef PGXC + case 'b': + { + Assert((strncmp(msg, conn->barrier_id, msg_len) == 0)); + conn->state = DN_CONNECTION_STATE_IDLE; + return RESPONSE_BARRIER_OK; + } +#endif + case 'I': /* EmptyQuery */ default: /* sync lost? */ diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 9615b52..b06b7bf 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -78,6 +78,7 @@ #include "access/gtm.h" /* PGXC_COORD */ #include "pgxc/execRemote.h" +#include "pgxc/barrier.h" #include "pgxc/planner.h" #include "pgxc/pgxcnode.h" #include "commands/copy.h" @@ -430,6 +431,7 @@ SocketBackend(StringInfo inBuf) case 'g': /* GXID */ case 's': /* Snapshot */ case 't': /* Timestamp */ + case 'b': /* Barrier */ break; #endif @@ -4031,6 +4033,37 @@ PostgresMain(int argc, char *argv[], const char *username) */ SetCurrentGTMDeltaTimestamp(timestamp); break; + + case 'b': /* barrier */ + { + int command; + char *id; + + command = pq_getmsgbyte(&input_message); + id = pq_getmsgstring(&input_message); + pq_getmsgend(&input_message); + + switch (command) + { + case CREATE_BARRIER_PREPARE: + ProcessCreateBarrierPrepare(id); + break; + + case CREATE_BARRIER_END: + ProcessCreateBarrierEnd(id); + break; + + case CREATE_BARRIER_EXECUTE: + ProcessCreateBarrierExecute(id); + break; + + default: + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("Invalid command received"))); + } + } + break; #endif /* PGXC */ default: diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 065d880..bd13ce3 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -58,6 +58,7 @@ #include "utils/syscache.h" #ifdef PGXC +#include "pgxc/barrier.h" #include "pgxc/locator.h" #include "pgxc/pgxc.h" #include "pgxc/planner.h" @@ -1347,6 +1348,12 @@ ProcessUtility(Node *parsetree, #endif break; +#ifdef PGXC + case T_BarrierStmt: + RequestBarrier(((BarrierStmt *) parsetree)->id, completionTag); + break; +#endif + case T_ReindexStmt: { ReindexStmt *stmt = (ReindexStmt *) parsetree; @@ -2320,6 +2327,12 @@ CreateCommandTag(Node *parsetree) tag = "CHECKPOINT"; break; +#ifdef PGXC + case T_BarrierStmt: + tag = "BARRIER"; + break; +#endif + case T_ReindexStmt: tag = "REINDEX"; break; diff --git a/src/include/access/rmgr.h b/src/include/access/rmgr.h index 5702f5f..a46e7fe 100644 --- a/src/include/access/rmgr.h +++ b/src/include/access/rmgr.h @@ -30,6 +30,11 @@ typedef uint8 RmgrId; #define RM_GIN_ID 13 #define RM_GIST_ID 14 #define RM_SEQ_ID 15 +#ifdef PGXC +#define RM_BARRIER_ID 16 +#define RM_MAX_ID RM_BARRIER_ID +#else #define RM_MAX_ID RM_SEQ_ID +#endif #endif /* RMGR_H */ diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 6776c25..e4ff851 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -319,6 +319,9 @@ typedef enum NodeTag T_ConstraintsSetStmt, T_ReindexStmt, T_CheckPointStmt, +#ifdef PGXC + T_BarrierStmt, +#endif T_CreateSchemaStmt, T_AlterDatabaseStmt, T_AlterDatabaseSetStmt, diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 951484c..7398649 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -2201,6 +2201,19 @@ typedef struct VacuumStmt List *va_cols; /* list of column names, or NIL for all */ } VacuumStmt; +#ifdef PGXC +/* + * ---------------------- + * Barrier Statement + */ +typedef struct BarrierStmt +{ + NodeTag type; + const char *id; /* User supplied barrier id, if any */ +} BarrierStmt; + +#endif + /* ---------------------- * Explain Statement * ---------------------- diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h index 2c84923..6993eee 100644 --- a/src/include/parser/kwlist.h +++ b/src/include/parser/kwlist.h @@ -52,6 +52,9 @@ PG_KEYWORD("asymmetric", ASYMMETRIC, RESERVED_KEYWORD) PG_KEYWORD("at", AT, UNRESERVED_KEYWORD) PG_KEYWORD("authorization", AUTHORIZATION, TYPE_FUNC_NAME_KEYWORD) PG_KEYWORD("backward", BACKWARD, UNRESERVED_KEYWORD) +#ifdef PGXC +PG_KEYWORD("barrier", BARRIER, UNRESERVED_KEYWORD) +#endif PG_KEYWORD("before", BEFORE, UNRESERVED_KEYWORD) PG_KEYWORD("begin", BEGIN_P, UNRESERVED_KEYWORD) PG_KEYWORD("between", BETWEEN, TYPE_FUNC_NAME_KEYWORD) diff --git a/src/include/pgxc/barrier.h b/src/include/pgxc/barrier.h new file mode 100644 index 0000000..37b5067 --- /dev/null +++ b/src/include/pgxc/barrier.h @@ -0,0 +1,40 @@ +/*------------------------------------------------------------------------- + * + * barrier.h + * + * Definitions for the PITR barrier handling + * + * + * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group + * Portions Copyright (c) 2010-2011 Nippon Telegraph and Telephone Corporation + * + * IDENTIFICATION + * $$ + * + *------------------------------------------------------------------------- + */ + +#ifndef BARRIER_H +#define BARRIER_H + +#include "access/xlog.h" +#include "access/xlogdefs.h" + +#define CREATE_BARRIER_PREPARE 'P' +#define CREATE_BARRIER_EXECUTE 'X' +#define CREATE_BARRIER_END 'E' + +#define CREATE_BARRIER_PREPARE_DONE 'p' +#define CREATE_BARRIER_EXECUTE_DONE 'x' + +typedef struct xl_barrier +{ + char barrier_id[1]; /* variable length data follows */ +} xl_barrier; + +#define XLOG_BARRIER_CREATE 0x00 + +extern void RequestBarrier(const char *id, char *completionTag); +extern void barrier_redo(XLogRecPtr lsn, XLogRecord *record); +extern void barrier_desc(StringInfo buf, uint8 xl_info, char *rec); +#endif diff --git a/src/include/pgxc/execRemote.h b/src/include/pgxc/execRemote.h index 23ea4a8..e9f000f 100644 --- a/src/include/pgxc/execRemote.h +++ b/src/include/pgxc/execRemote.h @@ -36,6 +36,7 @@ #define RESPONSE_TUPDESC 2 #define RESPONSE_DATAROW 3 #define RESPONSE_COPY 4 +#define RESPONSE_BARRIER_OK 5 typedef enum { diff --git a/src/include/pgxc/pgxcnode.h b/src/include/pgxc/pgxcnode.h index f8ac7c6..38fe895 100644 --- a/src/include/pgxc/pgxcnode.h +++ b/src/include/pgxc/pgxcnode.h @@ -66,6 +66,7 @@ struct pgxc_node_handle #ifdef DN_CONNECTION_DEBUG bool have_row_desc; #endif + char *barrier_id; char *error; /* Output buffer */ char *outBuffer; diff --git a/src/include/storage/lwlock.h b/src/include/storage/lwlock.h index 0548159..398ebd9 100644 --- a/src/include/storage/lwlock.h +++ b/src/include/storage/lwlock.h @@ -69,6 +69,7 @@ typedef enum LWLockId SyncScanLock, #ifdef PGXC AnalyzeProcArrayLock, + BarrierLock, #endif /* Individual lock IDs end here */ FirstBufMappingLock, ----------------------------------------------------------------------- hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-17 16:25:19
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via c739272f73a860a1c1a07ea085c47e8d4e292420 (commit) from 0115aacecb33438da33b51e7761498de6a854ba3 (commit) - Log ----------------------------------------------------------------- commit c739272f73a860a1c1a07ea085c47e8d4e292420 Author: Abbas <abb...@en...> Date: Thu Mar 17 21:23:30 2011 +0500 Add alternate expected output file to fix regression falilure of numeric.sql diff --git a/src/test/regress/expected/numeric_1.out b/src/test/regress/expected/numeric_1.out new file mode 100644 index 0000000..89c19c9 --- /dev/null +++ b/src/test/regress/expected/numeric_1.out @@ -0,0 +1,1357 @@ +-- +-- NUMERIC +-- +CREATE TABLE num_data (id int4, val numeric(210,10)); +CREATE TABLE num_exp_add (id1 int4, id2 int4, expected numeric(210,10)); +CREATE TABLE num_exp_sub (id1 int4, id2 int4, expected numeric(210,10)); +CREATE TABLE num_exp_div (id1 int4, id2 int4, expected numeric(210,10)); +CREATE TABLE num_exp_mul (id1 int4, id2 int4, expected numeric(210,10)); +CREATE TABLE num_exp_sqrt (id int4, expected numeric(210,10)); +CREATE TABLE num_exp_ln (id int4, expected numeric(210,10)); +CREATE TABLE num_exp_log10 (id int4, expected numeric(210,10)); +CREATE TABLE num_exp_power_10_ln (id int4, expected numeric(210,10)); +CREATE TABLE num_result (id1 int4, id2 int4, result numeric(210,10)); +-- ****************************** +-- * The following EXPECTED results are computed by bc(1) +-- * with a scale of 200 +-- ****************************** +BEGIN TRANSACTION; +INSERT INTO num_exp_add VALUES (0,0,'0'); +INSERT INTO num_exp_sub VALUES (0,0,'0'); +INSERT INTO num_exp_mul VALUES (0,0,'0'); +INSERT INTO num_exp_div VALUES (0,0,'NaN'); +INSERT INTO num_exp_add VALUES (0,1,'0'); +INSERT INTO num_exp_sub VALUES (0,1,'0'); +INSERT INTO num_exp_mul VALUES (0,1,'0'); +INSERT INTO num_exp_div VALUES (0,1,'NaN'); +INSERT INTO num_exp_add VALUES (0,2,'-34338492.215397047'); +INSERT INTO num_exp_sub VALUES (0,2,'34338492.215397047'); +INSERT INTO num_exp_mul VALUES (0,2,'0'); +INSERT INTO num_exp_div VALUES (0,2,'0'); +INSERT INTO num_exp_add VALUES (0,3,'4.31'); +INSERT INTO num_exp_sub VALUES (0,3,'-4.31'); +INSERT INTO num_exp_mul VALUES (0,3,'0'); +INSERT INTO num_exp_div VALUES (0,3,'0'); +INSERT INTO num_exp_add VALUES (0,4,'7799461.4119'); +INSERT INTO num_exp_sub VALUES (0,4,'-7799461.4119'); +INSERT INTO num_exp_mul VALUES (0,4,'0'); +INSERT INTO num_exp_div VALUES (0,4,'0'); +INSERT INTO num_exp_add VALUES (0,5,'16397.038491'); +INSERT INTO num_exp_sub VALUES (0,5,'-16397.038491'); +INSERT INTO num_exp_mul VALUES (0,5,'0'); +INSERT INTO num_exp_div VALUES (0,5,'0'); +INSERT INTO num_exp_add VALUES (0,6,'93901.57763026'); +INSERT INTO num_exp_sub VALUES (0,6,'-93901.57763026'); +INSERT INTO num_exp_mul VALUES (0,6,'0'); +INSERT INTO num_exp_div VALUES (0,6,'0'); +INSERT INTO num_exp_add VALUES (0,7,'-83028485'); +INSERT INTO num_exp_sub VALUES (0,7,'83028485'); +INSERT INTO num_exp_mul VALUES (0,7,'0'); +INSERT INTO num_exp_div VALUES (0,7,'0'); +INSERT INTO num_exp_add VALUES (0,8,'74881'); +INSERT INTO num_exp_sub VALUES (0,8,'-74881'); +INSERT INTO num_exp_mul VALUES (0,8,'0'); +INSERT INTO num_exp_div VALUES (0,8,'0'); +INSERT INTO num_exp_add VALUES (0,9,'-24926804.045047420'); +INSERT INTO num_exp_sub VALUES (0,9,'24926804.045047420'); +INSERT INTO num_exp_mul VALUES (0,9,'0'); +INSERT INTO num_exp_div VALUES (0,9,'0'); +INSERT INTO num_exp_add VALUES (1,0,'0'); +INSERT INTO num_exp_sub VALUES (1,0,'0'); +INSERT INTO num_exp_mul VALUES (1,0,'0'); +INSERT INTO num_exp_div VALUES (1,0,'NaN'); +INSERT INTO num_exp_add VALUES (1,1,'0'); +INSERT INTO num_exp_sub VALUES (1,1,'0'); +INSERT INTO num_exp_mul VALUES (1,1,'0'); +INSERT INTO num_exp_div VALUES (1,1,'NaN'); +INSERT INTO num_exp_add VALUES (1,2,'-34338492.215397047'); +INSERT INTO num_exp_sub VALUES (1,2,'34338492.215397047'); +INSERT INTO num_exp_mul VALUES (1,2,'0'); +INSERT INTO num_exp_div VALUES (1,2,'0'); +INSERT INTO num_exp_add VALUES (1,3,'4.31'); +INSERT INTO num_exp_sub VALUES (1,3,'-4.31'); +INSERT INTO num_exp_mul VALUES (1,3,'0'); +INSERT INTO num_exp_div VALUES (1,3,'0'); +INSERT INTO num_exp_add VALUES (1,4,'7799461.4119'); +INSERT INTO num_exp_sub VALUES (1,4,'-7799461.4119'); +INSERT INTO num_exp_mul VALUES (1,4,'0'); +INSERT INTO num_exp_div VALUES (1,4,'0'); +INSERT INTO num_exp_add VALUES (1,5,'16397.038491'); +INSERT INTO num_exp_sub VALUES (1,5,'-16397.038491'); +INSERT INTO num_exp_mul VALUES (1,5,'0'); +INSERT INTO num_exp_div VALUES (1,5,'0'); +INSERT INTO num_exp_add VALUES (1,6,'93901.57763026'); +INSERT INTO num_exp_sub VALUES (1,6,'-93901.57763026'); +INSERT INTO num_exp_mul VALUES (1,6,'0'); +INSERT INTO num_exp_div VALUES (1,6,'0'); +INSERT INTO num_exp_add VALUES (1,7,'-83028485'); +INSERT INTO num_exp_sub VALUES (1,7,'83028485'); +INSERT INTO num_exp_mul VALUES (1,7,'0'); +INSERT INTO num_exp_div VALUES (1,7,'0'); +INSERT INTO num_exp_add VALUES (1,8,'74881'); +INSERT INTO num_exp_sub VALUES (1,8,'-74881'); +INSERT INTO num_exp_mul VALUES (1,8,'0'); +INSERT INTO num_exp_div VALUES (1,8,'0'); +INSERT INTO num_exp_add VALUES (1,9,'-24926804.045047420'); +INSERT INTO num_exp_sub VALUES (1,9,'24926804.045047420'); +INSERT INTO num_exp_mul VALUES (1,9,'0'); +INSERT INTO num_exp_div VALUES (1,9,'0'); +INSERT INTO num_exp_add VALUES (2,0,'-34338492.215397047'); +INSERT INTO num_exp_sub VALUES (2,0,'-34338492.215397047'); +INSERT INTO num_exp_mul VALUES (2,0,'0'); +INSERT INTO num_exp_div VALUES (2,0,'NaN'); +INSERT INTO num_exp_add VALUES (2,1,'-34338492.215397047'); +INSERT INTO num_exp_sub VALUES (2,1,'-34338492.215397047'); +INSERT INTO num_exp_mul VALUES (2,1,'0'); +INSERT INTO num_exp_div VALUES (2,1,'NaN'); +INSERT INTO num_exp_add VALUES (2,2,'-68676984.430794094'); +INSERT INTO num_exp_sub VALUES (2,2,'0'); +INSERT INTO num_exp_mul VALUES (2,2,'1179132047626883.596862135856320209'); +INSERT INTO num_exp_div VALUES (2,2,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (2,3,'-34338487.905397047'); +INSERT INTO num_exp_sub VALUES (2,3,'-34338496.525397047'); +INSERT INTO num_exp_mul VALUES (2,3,'-147998901.44836127257'); +INSERT INTO num_exp_div VALUES (2,3,'-7967167.56737750510440835266'); +INSERT INTO num_exp_add VALUES (2,4,'-26539030.803497047'); +INSERT INTO num_exp_sub VALUES (2,4,'-42137953.627297047'); +INSERT INTO num_exp_mul VALUES (2,4,'-267821744976817.8111137106593'); +INSERT INTO num_exp_div VALUES (2,4,'-4.40267480046830116685'); +INSERT INTO num_exp_add VALUES (2,5,'-34322095.176906047'); +INSERT INTO num_exp_sub VALUES (2,5,'-34354889.253888047'); +INSERT INTO num_exp_mul VALUES (2,5,'-563049578578.769242506736077'); +INSERT INTO num_exp_div VALUES (2,5,'-2094.18866914563535496429'); +INSERT INTO num_exp_add VALUES (2,6,'-34244590.637766787'); +INSERT INTO num_exp_sub VALUES (2,6,'-34432393.793027307'); +INSERT INTO num_exp_mul VALUES (2,6,'-3224438592470.18449811926184222'); +INSERT INTO num_exp_div VALUES (2,6,'-365.68599891479766440940'); +INSERT INTO num_exp_add VALUES (2,7,'-117366977.215397047'); +INSERT INTO num_exp_sub VALUES (2,7,'48689992.784602953'); +INSERT INTO num_exp_mul VALUES (2,7,'2851072985828710.485883795'); +INSERT INTO num_exp_div VALUES (2,7,'.41357483778485235518'); +INSERT INTO num_exp_add VALUES (2,8,'-34263611.215397047'); +INSERT INTO num_exp_sub VALUES (2,8,'-34413373.215397047'); +INSERT INTO num_exp_mul VALUES (2,8,'-2571300635581.146276407'); +INSERT INTO num_exp_div VALUES (2,8,'-458.57416721727870888476'); +INSERT INTO num_exp_add VALUES (2,9,'-59265296.260444467'); +INSERT INTO num_exp_sub VALUES (2,9,'-9411688.170349627'); +INSERT INTO num_exp_mul VALUES (2,9,'855948866655588.453741509242968740'); +INSERT INTO num_exp_div VALUES (2,9,'1.37757299946438931811'); +INSERT INTO num_exp_add VALUES (3,0,'4.31'); +INSERT INTO num_exp_sub VALUES (3,0,'4.31'); +INSERT INTO num_exp_mul VALUES (3,0,'0'); +INSERT INTO num_exp_div VALUES (3,0,'NaN'); +INSERT INTO num_exp_add VALUES (3,1,'4.31'); +INSERT INTO num_exp_sub VALUES (3,1,'4.31'); +INSERT INTO num_exp_mul VALUES (3,1,'0'); +INSERT INTO num_exp_div VALUES (3,1,'NaN'); +INSERT INTO num_exp_add VALUES (3,2,'-34338487.905397047'); +INSERT INTO num_exp_sub VALUES (3,2,'34338496.525397047'); +INSERT INTO num_exp_mul VALUES (3,2,'-147998901.44836127257'); +INSERT INTO num_exp_div VALUES (3,2,'-.00000012551512084352'); +INSERT INTO num_exp_add VALUES (3,3,'8.62'); +INSERT INTO num_exp_sub VALUES (3,3,'0'); +INSERT INTO num_exp_mul VALUES (3,3,'18.5761'); +INSERT INTO num_exp_div VALUES (3,3,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (3,4,'7799465.7219'); +INSERT INTO num_exp_sub VALUES (3,4,'-7799457.1019'); +INSERT INTO num_exp_mul VALUES (3,4,'33615678.685289'); +INSERT INTO num_exp_div VALUES (3,4,'.00000055260225961552'); +INSERT INTO num_exp_add VALUES (3,5,'16401.348491'); +INSERT INTO num_exp_sub VALUES (3,5,'-16392.728491'); +INSERT INTO num_exp_mul VALUES (3,5,'70671.23589621'); +INSERT INTO num_exp_div VALUES (3,5,'.00026285234387695504'); +INSERT INTO num_exp_add VALUES (3,6,'93905.88763026'); +INSERT INTO num_exp_sub VALUES (3,6,'-93897.26763026'); +INSERT INTO num_exp_mul VALUES (3,6,'404715.7995864206'); +INSERT INTO num_exp_div VALUES (3,6,'.00004589912234457595'); +INSERT INTO num_exp_add VALUES (3,7,'-83028480.69'); +INSERT INTO num_exp_sub VALUES (3,7,'83028489.31'); +INSERT INTO num_exp_mul VALUES (3,7,'-357852770.35'); +INSERT INTO num_exp_div VALUES (3,7,'-.00000005190989574240'); +INSERT INTO num_exp_add VALUES (3,8,'74885.31'); +INSERT INTO num_exp_sub VALUES (3,8,'-74876.69'); +INSERT INTO num_exp_mul VALUES (3,8,'322737.11'); +INSERT INTO num_exp_div VALUES (3,8,'.00005755799201399553'); +INSERT INTO num_exp_add VALUES (3,9,'-24926799.735047420'); +INSERT INTO num_exp_sub VALUES (3,9,'24926808.355047420'); +INSERT INTO num_exp_mul VALUES (3,9,'-107434525.43415438020'); +INSERT INTO num_exp_div VALUES (3,9,'-.00000017290624149854'); +INSERT INTO num_exp_add VALUES (4,0,'7799461.4119'); +INSERT INTO num_exp_sub VALUES (4,0,'7799461.4119'); +INSERT INTO num_exp_mul VALUES (4,0,'0'); +INSERT INTO num_exp_div VALUES (4,0,'NaN'); +INSERT INTO num_exp_add VALUES (4,1,'7799461.4119'); +INSERT INTO num_exp_sub VALUES (4,1,'7799461.4119'); +INSERT INTO num_exp_mul VALUES (4,1,'0'); +INSERT INTO num_exp_div VALUES (4,1,'NaN'); +INSERT INTO num_exp_add VALUES (4,2,'-26539030.803497047'); +INSERT INTO num_exp_sub VALUES (4,2,'42137953.627297047'); +INSERT INTO num_exp_mul VALUES (4,2,'-267821744976817.8111137106593'); +INSERT INTO num_exp_div VALUES (4,2,'-.22713465002993920385'); +INSERT INTO num_exp_add VALUES (4,3,'7799465.7219'); +INSERT INTO num_exp_sub VALUES (4,3,'7799457.1019'); +INSERT INTO num_exp_mul VALUES (4,3,'33615678.685289'); +INSERT INTO num_exp_div VALUES (4,3,'1809619.81714617169373549883'); +INSERT INTO num_exp_add VALUES (4,4,'15598922.8238'); +INSERT INTO num_exp_sub VALUES (4,4,'0'); +INSERT INTO num_exp_mul VALUES (4,4,'60831598315717.14146161'); +INSERT INTO num_exp_div VALUES (4,4,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (4,5,'7815858.450391'); +INSERT INTO num_exp_sub VALUES (4,5,'7783064.373409'); +INSERT INTO num_exp_mul VALUES (4,5,'127888068979.9935054429'); +INSERT INTO num_exp_div VALUES (4,5,'475.66281046305802686061'); +INSERT INTO num_exp_add VALUES (4,6,'7893362.98953026'); +INSERT INTO num_exp_sub VALUES (4,6,'7705559.83426974'); +INSERT INTO num_exp_mul VALUES (4,6,'732381731243.745115764094'); +INSERT INTO num_exp_div VALUES (4,6,'83.05996138436129499606'); +INSERT INTO num_exp_add VALUES (4,7,'-75229023.5881'); +INSERT INTO num_exp_sub VALUES (4,7,'90827946.4119'); +INSERT INTO num_exp_mul VALUES (4,7,'-647577464846017.9715'); +INSERT INTO num_exp_div VALUES (4,7,'-.09393717604145131637'); +INSERT INTO num_exp_add VALUES (4,8,'7874342.4119'); +INSERT INTO num_exp_sub VALUES (4,8,'7724580.4119'); +INSERT INTO num_exp_mul VALUES (4,8,'584031469984.4839'); +INSERT INTO num_exp_div VALUES (4,8,'104.15808298366741897143'); +INSERT INTO num_exp_add VALUES (4,9,'-17127342.633147420'); +INSERT INTO num_exp_sub VALUES (4,9,'32726265.456947420'); +INSERT INTO num_exp_mul VALUES (4,9,'-194415646271340.1815956522980'); +INSERT INTO num_exp_div VALUES (4,9,'-.31289456112403769409'); +INSERT INTO num_exp_add VALUES (5,0,'16397.038491'); +INSERT INTO num_exp_sub VALUES (5,0,'16397.038491'); +INSERT INTO num_exp_mul VALUES (5,0,'0'); +INSERT INTO num_exp_div VALUES (5,0,'NaN'); +INSERT INTO num_exp_add VALUES (5,1,'16397.038491'); +INSERT INTO num_exp_sub VALUES (5,1,'16397.038491'); +INSERT INTO num_exp_mul VALUES (5,1,'0'); +INSERT INTO num_exp_div VALUES (5,1,'NaN'); +INSERT INTO num_exp_add VALUES (5,2,'-34322095.176906047'); +INSERT INTO num_exp_sub VALUES (5,2,'34354889.253888047'); +INSERT INTO num_exp_mul VALUES (5,2,'-563049578578.769242506736077'); +INSERT INTO num_exp_div VALUES (5,2,'-.00047751189505192446'); +INSERT INTO num_exp_add VALUES (5,3,'16401.348491'); +INSERT INTO num_exp_sub VALUES (5,3,'16392.728491'); +INSERT INTO num_exp_mul VALUES (5,3,'70671.23589621'); +INSERT INTO num_exp_div VALUES (5,3,'3804.41728329466357308584'); +INSERT INTO num_exp_add VALUES (5,4,'7815858.450391'); +INSERT INTO num_exp_sub VALUES (5,4,'-7783064.373409'); +INSERT INTO num_exp_mul VALUES (5,4,'127888068979.9935054429'); +INSERT INTO num_exp_div VALUES (5,4,'.00210232958726897192'); +INSERT INTO num_exp_add VALUES (5,5,'32794.076982'); +INSERT INTO num_exp_sub VALUES (5,5,'0'); +INSERT INTO num_exp_mul VALUES (5,5,'268862871.275335557081'); +INSERT INTO num_exp_div VALUES (5,5,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (5,6,'110298.61612126'); +INSERT INTO num_exp_sub VALUES (5,6,'-77504.53913926'); +INSERT INTO num_exp_mul VALUES (5,6,'1539707782.76899778633766'); +INSERT INTO num_exp_div VALUES (5,6,'.17461941433576102689'); +INSERT INTO num_exp_add VALUES (5,7,'-83012087.961509'); +INSERT INTO num_exp_sub VALUES (5,7,'83044882.038491'); +INSERT INTO num_exp_mul VALUES (5,7,'-1361421264394.416135'); +INSERT INTO num_exp_div VALUES (5,7,'-.00019748690453643710'); +INSERT INTO num_exp_add VALUES (5,8,'91278.038491'); +INSERT INTO num_exp_sub VALUES (5,8,'-58483.961509'); +INSERT INTO num_exp_mul VALUES (5,8,'1227826639.244571'); +INSERT INTO num_exp_div VALUES (5,8,'.21897461960978085228'); +INSERT INTO num_exp_add VALUES (5,9,'-24910407.006556420'); +INSERT INTO num_exp_sub VALUES (5,9,'24943201.083538420'); +INSERT INTO num_exp_mul VALUES (5,9,'-408725765384.257043660243220'); +INSERT INTO num_exp_div VALUES (5,9,'-.00065780749354660427'); +INSERT INTO num_exp_add VALUES (6,0,'93901.57763026'); +INSERT INTO num_exp_sub VALUES (6,0,'93901.57763026'); +INSERT INTO num_exp_mul VALUES (6,0,'0'); +INSERT INTO num_exp_div VALUES (6,0,'NaN'); +INSERT INTO num_exp_add VALUES (6,1,'93901.57763026'); +INSERT INTO num_exp_sub VALUES (6,1,'93901.57763026'); +INSERT INTO num_exp_mul VALUES (6,1,'0'); +INSERT INTO num_exp_div VALUES (6,1,'NaN'); +INSERT INTO num_exp_add VALUES (6,2,'-34244590.637766787'); +INSERT INTO num_exp_sub VALUES (6,2,'34432393.793027307'); +INSERT INTO num_exp_mul VALUES (6,2,'-3224438592470.18449811926184222'); +INSERT INTO num_exp_div VALUES (6,2,'-.00273458651128995823'); +INSERT INTO num_exp_add VALUES (6,3,'93905.88763026'); +INSERT INTO num_exp_sub VALUES (6,3,'93897.26763026'); +INSERT INTO num_exp_mul VALUES (6,3,'404715.7995864206'); +INSERT INTO num_exp_div VALUES (6,3,'21786.90896293735498839907'); +INSERT INTO num_exp_add VALUES (6,4,'7893362.98953026'); +INSERT INTO num_exp_sub VALUES (6,4,'-7705559.83426974'); +INSERT INTO num_exp_mul VALUES (6,4,'732381731243.745115764094'); +INSERT INTO num_exp_div VALUES (6,4,'.01203949512295682469'); +INSERT INTO num_exp_add VALUES (6,5,'110298.61612126'); +INSERT INTO num_exp_sub VALUES (6,5,'77504.53913926'); +INSERT INTO num_exp_mul VALUES (6,5,'1539707782.76899778633766'); +INSERT INTO num_exp_div VALUES (6,5,'5.72674008674192359679'); +INSERT INTO num_exp_add VALUES (6,6,'187803.15526052'); +INSERT INTO num_exp_sub VALUES (6,6,'0'); +INSERT INTO num_exp_mul VALUES (6,6,'8817506281.4517452372676676'); +INSERT INTO num_exp_div VALUES (6,6,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (6,7,'-82934583.42236974'); +INSERT INTO num_exp_sub VALUES (6,7,'83122386.57763026'); +INSERT INTO num_exp_mul VALUES (6,7,'-7796505729750.37795610'); +INSERT INTO num_exp_div VALUES (6,7,'-.00113095617281538980'); +INSERT INTO num_exp_add VALUES (6,8,'168782.57763026'); +INSERT INTO num_exp_sub VALUES (6,8,'19020.57763026'); +INSERT INTO num_exp_mul VALUES (6,8,'7031444034.53149906'); +INSERT INTO num_exp_div VALUES (6,8,'1.25401073209839612184'); +INSERT INTO num_exp_add VALUES (6,9,'-24832902.467417160'); +INSERT INTO num_exp_sub VALUES (6,9,'25020705.622677680'); +INSERT INTO num_exp_mul VALUES (6,9,'-2340666225110.29929521292692920'); +INSERT INTO num_exp_div VALUES (6,9,'-.00376709254265256789'); +INSERT INTO num_exp_add VALUES (7,0,'-83028485'); +INSERT INTO num_exp_sub VALUES (7,0,'-83028485'); +INSERT INTO num_exp_mul VALUES (7,0,'0'); +INSERT INTO num_exp_div VALUES (7,0,'NaN'); +INSERT INTO num_exp_add VALUES (7,1,'-83028485'); +INSERT INTO num_exp_sub VALUES (7,1,'-83028485'); +INSERT INTO num_exp_mul VALUES (7,1,'0'); +INSERT INTO num_exp_div VALUES (7,1,'NaN'); +INSERT INTO num_exp_add VALUES (7,2,'-117366977.215397047'); +INSERT INTO num_exp_sub VALUES (7,2,'-48689992.784602953'); +INSERT INTO num_exp_mul VALUES (7,2,'2851072985828710.485883795'); +INSERT INTO num_exp_div VALUES (7,2,'2.41794207151503385700'); +INSERT INTO num_exp_add VALUES (7,3,'-83028480.69'); +INSERT INTO num_exp_sub VALUES (7,3,'-83028489.31'); +INSERT INTO num_exp_mul VALUES (7,3,'-357852770.35'); +INSERT INTO num_exp_div VALUES (7,3,'-19264149.65197215777262180974'); +INSERT INTO num_exp_add VALUES (7,4,'-75229023.5881'); +INSERT INTO num_exp_sub VALUES (7,4,'-90827946.4119'); +INSERT INTO num_exp_mul VALUES (7,4,'-647577464846017.9715'); +INSERT INTO num_exp_div VALUES (7,4,'-10.64541262725136247686'); +INSERT INTO num_exp_add VALUES (7,5,'-83012087.961509'); +INSERT INTO num_exp_sub VALUES (7,5,'-83044882.038491'); +INSERT INTO num_exp_mul VALUES (7,5,'-1361421264394.416135'); +INSERT INTO num_exp_div VALUES (7,5,'-5063.62688881730941836574'); +INSERT INTO num_exp_add VALUES (7,6,'-82934583.42236974'); +INSERT INTO num_exp_sub VALUES (7,6,'-83122386.57763026'); +INSERT INTO num_exp_mul VALUES (7,6,'-7796505729750.37795610'); +INSERT INTO num_exp_div VALUES (7,6,'-884.20756174009028770294'); +INSERT INTO num_exp_add VALUES (7,7,'-166056970'); +INSERT INTO num_exp_sub VALUES (7,7,'0'); +INSERT INTO num_exp_mul VALUES (7,7,'6893729321395225'); +INSERT INTO num_exp_div VALUES (7,7,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (7,8,'-82953604'); +INSERT INTO num_exp_sub VALUES (7,8,'-83103366'); +INSERT INTO num_exp_mul VALUES (7,8,'-6217255985285'); +INSERT INTO num_exp_div VALUES (7,8,'-1108.80577182462841041118'); +INSERT INTO num_exp_add VALUES (7,9,'-107955289.045047420'); +INSERT INTO num_exp_sub VALUES (7,9,'-58101680.954952580'); +INSERT INTO num_exp_mul VALUES (7,9,'2069634775752159.035758700'); +INSERT INTO num_exp_div VALUES (7,9,'3.33089171198810413382'); +INSERT INTO num_exp_add VALUES (8,0,'74881'); +INSERT INTO num_exp_sub VALUES (8,0,'74881'); +INSERT INTO num_exp_mul VALUES (8,0,'0'); +INSERT INTO num_exp_div VALUES (8,0,'NaN'); +INSERT INTO num_exp_add VALUES (8,1,'74881'); +INSERT INTO num_exp_sub VALUES (8,1,'74881'); +INSERT INTO num_exp_mul VALUES (8,1,'0'); +INSERT INTO num_exp_div VALUES (8,1,'NaN'); +INSERT INTO num_exp_add VALUES (8,2,'-34263611.215397047'); +INSERT INTO num_exp_sub VALUES (8,2,'34413373.215397047'); +INSERT INTO num_exp_mul VALUES (8,2,'-2571300635581.146276407'); +INSERT INTO num_exp_div VALUES (8,2,'-.00218067233500788615'); +INSERT INTO num_exp_add VALUES (8,3,'74885.31'); +INSERT INTO num_exp_sub VALUES (8,3,'74876.69'); +INSERT INTO num_exp_mul VALUES (8,3,'322737.11'); +INSERT INTO num_exp_div VALUES (8,3,'17373.78190255220417633410'); +INSERT INTO num_exp_add VALUES (8,4,'7874342.4119'); +INSERT INTO num_exp_sub VALUES (8,4,'-7724580.4119'); +INSERT INTO num_exp_mul VALUES (8,4,'584031469984.4839'); +INSERT INTO num_exp_div VALUES (8,4,'.00960079113741758956'); +INSERT INTO num_exp_add VALUES (8,5,'91278.038491'); +INSERT INTO num_exp_sub VALUES (8,5,'58483.961509'); +INSERT INTO num_exp_mul VALUES (8,5,'1227826639.244571'); +INSERT INTO num_exp_div VALUES (8,5,'4.56673929509287019456'); +INSERT INTO num_exp_add VALUES (8,6,'168782.57763026'); +INSERT INTO num_exp_sub VALUES (8,6,'-19020.57763026'); +INSERT INTO num_exp_mul VALUES (8,6,'7031444034.53149906'); +INSERT INTO num_exp_div VALUES (8,6,'.79744134113322314424'); +INSERT INTO num_exp_add VALUES (8,7,'-82953604'); +INSERT INTO num_exp_sub VALUES (8,7,'83103366'); +INSERT INTO num_exp_mul VALUES (8,7,'-6217255985285'); +INSERT INTO num_exp_div VALUES (8,7,'-.00090187120721280172'); +INSERT INTO num_exp_add VALUES (8,8,'149762'); +INSERT INTO num_exp_sub VALUES (8,8,'0'); +INSERT INTO num_exp_mul VALUES (8,8,'5607164161'); +INSERT INTO num_exp_div VALUES (8,8,'1.00000000000000000000'); +INSERT INTO num_exp_add VALUES (8,9,'-24851923.045047420'); +INSERT INTO num_exp_sub VALUES (8,9,'25001685.045047420'); +INSERT INTO num_exp_mul VALUES (8,9,'-1866544013697.195857020'); +INSERT INTO num_exp_div VALUES (8,9,'-.00300403532938582735'); +INSERT INTO num_exp_add VALUES (9,0,'-24926804.045047420'); +INSERT INTO num_exp_sub VALUES (9,0,'-24926804.045047420'); +INSERT INTO num_exp_mul VALUES (9,0,'0'); +INSERT INTO num_exp_div VALUES (9,0,'NaN'); +INSERT INTO num_exp_add VALUES (9,1,'-24926804.045047420'); +INSERT INTO num_exp_sub VALUES (9,1,'-24926804.045047420'); +INSERT INTO num_exp_mul VALUES (9,1,'0'); +INSERT INTO num_exp_div VALUES (9,1,'NaN'); +INSERT INTO num_exp_add VALUES (9,2,'-59265296.260444467'); +INSERT INTO num_exp_sub VALUES (9,2,'9411688.170349627'); +INSERT INTO num_exp_mul VALUES (9,2,'855948866655588.453741509242968740'); +INSERT INTO num_exp_div VALUES (9,2,'.72591434384152961526'); +INSERT INTO num_exp_add VALUES (9,3,'-24926799.735047420'); +INSERT INTO num_exp_sub VALUES (9,3,'-24926808.355047420'); +INSERT INTO num_exp_mul VALUES (9,3,'-107434525.43415438020'); +INSERT INTO num_exp_div VALUES (9,3,'-5783481.21694835730858468677'); +INSERT INTO num_exp_add VALUES (9,4,'-17127342.633147420'); +INSERT INTO num_exp_sub VALUES (9,4,'-32726265.456947420'); +INSERT INTO num_exp_mul VALUES (9,4,'-194415646271340.1815956522980'); +INSERT INTO num_exp_div VALUES (9,4,'-3.19596478892958416484'); +INSERT INTO num_exp_add VALUES (9,5,'-24910407.006556420'); +INSERT INTO num_exp_sub VALUES (9,5,'-24943201.083538420'); +INSERT INTO num_exp_mul VALUES (9,5,'-408725765384.257043660243220'); +INSERT INTO num_exp_div VALUES (9,5,'-1520.20159364322004505807'); +INSERT INTO num_exp_add VALUES (9,6,'-24832902.467417160'); +INSERT INTO num_exp_sub VALUES (9,6,'-25020705.622677680'); +INSERT INTO num_exp_mul VALUES (9,6,'-2340666225110.29929521292692920'); +INSERT INTO num_exp_div VALUES (9,6,'-265.45671195426965751280'); +INSERT INTO num_exp_add VALUES (9,7,'-107955289.045047420'); +INSERT INTO num_exp_sub VALUES (9,7,'58101680.954952580'); +INSERT INTO num_exp_mul VALUES (9,7,'2069634775752159.035758700'); +INSERT INTO num_exp_div VALUES (9,7,'.30021990699995814689'); +INSERT INTO num_exp_add VALUES (9,8,'-24851923.045047420'); +INSERT INTO num_exp_sub VALUES (9,8,'-25001685.045047420'); +INSERT INTO num_exp_mul VALUES (9,8,'-1866544013697.195857020'); +INSERT INTO num_exp_div VALUES (9,8,'-332.88556569820675471748'); +INSERT INTO num_exp_add VALUES (9,9,'-49853608.090094840'); +INSERT INTO num_exp_sub VALUES (9,9,'0'); +INSERT INTO num_exp_mul VALUES (9,9,'621345559900192.420120630048656400'); +INSERT INTO num_exp_div VALUES (9,9,'1.00000000000000000000'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +INSERT INTO num_exp_sqrt VALUES (0,'0'); +INSERT INTO num_exp_sqrt VALUES (1,'0'); +INSERT INTO num_exp_sqrt VALUES (2,'5859.90547836712524903505'); +INSERT INTO num_exp_sqrt VALUES (3,'2.07605394920266944396'); +INSERT INTO num_exp_sqrt VALUES (4,'2792.75158435189147418923'); +INSERT INTO num_exp_sqrt VALUES (5,'128.05092147657509145473'); +INSERT INTO num_exp_sqrt VALUES (6,'306.43364311096782703406'); +INSERT INTO num_exp_sqrt VALUES (7,'9111.99676251039939975230'); +INSERT INTO num_exp_sqrt VALUES (8,'273.64392922189960397542'); +INSERT INTO num_exp_sqrt VALUES (9,'4992.67503899937593364766'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +INSERT INTO num_exp_ln VALUES (0,'NaN'); +INSERT INTO num_exp_ln VALUES (1,'NaN'); +INSERT INTO num_exp_ln VALUES (2,'17.35177750493897715514'); +INSERT INTO num_exp_ln VALUES (3,'1.46093790411565641971'); +INSERT INTO num_exp_ln VALUES (4,'15.86956523951936572464'); +INSERT INTO num_exp_ln VALUES (5,'9.70485601768871834038'); +INSERT INTO num_exp_ln VALUES (6,'11.45000246622944403127'); +INSERT INTO num_exp_ln VALUES (7,'18.23469429965478772991'); +INSERT INTO num_exp_ln VALUES (8,'11.22365546576315513668'); +INSERT INTO num_exp_ln VALUES (9,'17.03145425013166006962'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +INSERT INTO num_exp_log10 VALUES (0,'NaN'); +INSERT INTO num_exp_log10 VALUES (1,'NaN'); +INSERT INTO num_exp_log10 VALUES (2,'7.53578122160797276459'); +INSERT INTO num_exp_log10 VALUES (3,'.63447727016073160075'); +INSERT INTO num_exp_log10 VALUES (4,'6.89206461372691743345'); +INSERT INTO num_exp_log10 VALUES (5,'4.21476541614777768626'); +INSERT INTO num_exp_log10 VALUES (6,'4.97267288886207207671'); +INSERT INTO num_exp_log10 VALUES (7,'7.91922711353275546914'); +INSERT INTO num_exp_log10 VALUES (8,'4.87437163556421004138'); +INSERT INTO num_exp_log10 VALUES (9,'7.39666659961986567059'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +INSERT INTO num_exp_power_10_ln VALUES (0,'NaN'); +INSERT INTO num_exp_power_10_ln VALUES (1,'NaN'); +INSERT INTO num_exp_power_10_ln VALUES (2,'224790267919917955.13261618583642653184'); +INSERT INTO num_exp_power_10_ln VALUES (3,'28.90266599445155957393'); +INSERT INTO num_exp_power_10_ln VALUES (4,'7405685069594999.07733999469386277636'); +INSERT INTO num_exp_power_10_ln VALUES (5,'5068226527.32127265408584640098'); +INSERT INTO num_exp_power_10_ln VALUES (6,'281839893606.99372343357047819067'); +INSERT INTO num_exp_power_10_ln VALUES (7,'1716699575118597095.42330819910640247627'); +INSERT INTO num_exp_power_10_ln VALUES (8,'167361463828.07491320069016125952'); +INSERT INTO num_exp_power_10_ln VALUES (9,'107511333880052007.04141124673540337457'); +COMMIT TRANSACTION; +BEGIN TRANSACTION; +INSERT INTO num_data VALUES (0, '0'); +INSERT INTO num_data VALUES (1, '0'); +INSERT INTO num_data VALUES (2, '-34338492.215397047'); +INSERT INTO num_data VALUES (3, '4.31'); +INSERT INTO num_data VALUES (4, '7799461.4119'); +INSERT INTO num_data VALUES (5, '16397.038491'); +INSERT INTO num_data VALUES (6, '93901.57763026'); +INSERT INTO num_data VALUES (7, '-83028485'); +INSERT INTO num_data VALUES (8, '74881'); +INSERT INTO num_data VALUES (9, '-24926804.045047420'); +COMMIT TRANSACTION; +-- ****************************** +-- * Create indices for faster checks +-- ****************************** +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 +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, t1.val + t2.val + FROM num_data t1, num_data t2; +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 ORDER BY t1.id1, t1.id2, t2.expected; + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val + t2.val, 10) + FROM num_data t1, num_data t2; +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) ORDER BY t1.id1, t1.id2; + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +-- ****************************** +-- * Subtraction check +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, t1.val - t2.val + FROM num_data t1, num_data t2; +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 ORDER BY t1.id1, t1.id2, t2.expected; + id1 | id2 | result | expected +-----+-----+--------+---------- +(0 rows) + +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val - t2.val, 40) + FROM num_data t1, num_data t2; +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 +-----+-----+--------+------- +(0 rows) + +-- ****************************** +-- * Multiply check +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, t1.val * t2.val + FROM num_data t1, num_data t2; +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 +-----+-----+--------+---------- +(0 rows) + +DELETE FROM num_result; +INSERT INTO num_result SELECT t1.id, t2.id, round(t1.val * t2.val, 30) + FROM num_data t1, num_data t2; +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 +-----+-----+--------+---------- +(0 rows) + +-- ****************************** +-- * Division check +-- ****************************** +DELETE FROM num_result; +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'; +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) + +DELETE FROM num_result; +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'; +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 +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT id, 0, SQRT(ABS(val)) + FROM num_data; +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 +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT id, 0, LN(ABS(val)) + FROM num_data + WHERE val != '0.0'; +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 +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT id, 0, LOG(numeric '10', ABS(val)) + FROM num_data + WHERE val != '0.0'; +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 +-- ****************************** +DELETE FROM num_result; +INSERT INTO num_result SELECT id, 0, POWER(numeric '10', LN(ABS(round(val,200)))) + FROM num_data + WHERE val != '0.0'; +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 +-----+--------+---------- +(0 rows) + +-- ****************************** +-- * miscellaneous checks for things that have been broken in the past... +-- ****************************** +-- numeric AVG used to fail on some platforms +SELECT AVG(val) FROM num_data; + avg +------------------------ + -13430913.592242320700 +(1 row) + +SELECT STDDEV(val) FROM num_data; + stddev +------------------------------- + 27791203.28758835329805617386 +(1 row) + +SELECT VARIANCE(val) FROM num_data; + variance +-------------------------------------- + 772350980172061.69659105821915863601 +(1 row) + +-- Check for appropriate rounding and overflow +CREATE TABLE fract_only (id int, val numeric(4,4)); +INSERT INTO fract_only VALUES (1, '0.0'); +INSERT INTO fract_only VALUES (2, '0.1'); +INSERT INTO fract_only VALUES (3, '1.0'); -- should fail +ERROR: numeric field overflow +INSERT INTO fract_only VALUES (4, '-0.9999'); +INSERT INTO fract_only VALUES (5, '0.99994'); +INSERT INTO fract_only VALUES (6, '0.99995'); -- should fail +ERROR: numeric field overflow +INSERT INTO fract_only VALUES (7, '0.00001'); +INSERT INTO fract_only VALUES (8, '0.00017'); +SELECT * FROM fract_only ORDER BY id; + id | val +----+--------- + 1 | 0.0000 + 2 | 0.1000 + 4 | -0.9999 + 5 | 0.9999 + 7 | 0.0000 + 8 | 0.0002 +(6 rows) + +DROP TABLE fract_only; +-- Simple check that ceil(), floor(), and round() work correctly +CREATE TABLE ceil_floor_round (a numeric); +INSERT INTO ceil_floor_round VALUES ('-5.5'); +INSERT INTO ceil_floor_round VALUES ('-5.499999'); +INSERT INTO ceil_floor_round VALUES ('9.5'); +INSERT INTO ceil_floor_round VALUES ('9.4999999'); +INSERT INTO ceil_floor_round VALUES ('0.0'); +INSERT INTO ceil_floor_round VALUES ('0.0000001'); +INSERT INTO ceil_floor_round VALUES ('-0.000001'); +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 + 0.0000001 | 1 | 1 | 0 | 0 + 9.4999999 | 10 | 10 | 9 | 9 + 9.5 | 10 | 10 | 9 | 10 +(7 rows) + +DROP TABLE ceil_floor_round; +-- Testing for width_bucket(). For convenience, we test both the +-- numeric and float8 versions of the function in this file. +-- errors +SELECT width_bucket(5.0, 3.0, 4.0, 0); +ERROR: count must be greater than zero +SELECT width_bucket(5.0, 3.0, 4.0, -5); +ERROR: count must be greater than zero +SELECT width_bucket(3.5, 3.0, 3.0, 888); +ERROR: lower bound cannot equal upper bound +SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, 0); +ERROR: count must be greater than zero +SELECT width_bucket(5.0::float8, 3.0::float8, 4.0::float8, -5); +ERROR: count must be greater than zero +SELECT width_bucket(3.5::float8, 3.0::float8, 3.0::float8, 888); +ERROR: lower bound cannot equal upper bound +SELECT width_bucket('NaN', 3.0, 4.0, 888); +ERROR: operand, lower bound and upper bound cannot be NaN +SELECT width_bucket(0::float8, 'NaN', 4.0::float8, 888); +ERROR: operand, lower bound and upper bound cannot be NaN +-- normal operation +CREATE TABLE width_bucket_test (operand_num numeric, operand_f8 float8); +COPY width_bucket_test (operand_num) FROM stdin; +UPDATE width_bucket_test SET operand_f8 = operand_num::float8; +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 ORDER BY operand_num; + 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 +SELECT width_bucket(0.0::float8, 'Infinity'::float8, 5, 10); -- error +ERROR: lower and upper bounds must be finite +SELECT width_bucket(0.0::float8, 5, '-Infinity'::float8, 20); -- error +ERROR: lower and upper bounds must be finite +SELECT width_bucket('Infinity'::float8, 1, 10, 10), + width_bucket('-Infinity'::float8, 1, 10, 10); + width_bucket | width_bucket +--------------+-------------- + 11 | 0 +(1 row) + +DROP TABLE width_bucket_test; +-- TO_CHAR() +-- +SELECT '' AS to_char_1, to_char(val, '9G999G999G999G999G999') + FROM num_data ORDER BY val; + to_char_1 | to_char +-----------+------------------------ + | -83,028,485 + | -34,338,492 + | -24,926,804 + | 0 + | 0 + | 4 + | 16,397 + | 74,881 + | 93,902 + | 7,799,461 +(10 rows) + +SELECT '' AS to_char_2, to_char(val, '9G999G999G999G999G999D999G999G999G999G999') + FROM num_data ORDER BY val; + to_char_2 | to_char +-----------+-------------------------------------------- + | -83,028,485.000,000,000,000,000 + | -34,338,492.215,397,047,000,000 + | -24,926,804.045,047,420,000,000 + | .000,000,000,000,000 + | .000,000,000,000,000 + | 4.310,000,000,000,000 + | 16,397.038,491,000,000,000 + | 74,881.000,000,000,000,000 + | 93,901.577,630,260,000,000 + | 7,799,461.411,900,000,000,000 +(10 rows) + +SELECT '' AS to_char_3, to_char(val, '9999999999999999.999999999999999PR') + FROM num_data ORDER BY val; + to_char_3 | to_char +-----------+------------------------------------ + | <83028485.000000000000000> + | <34338492.215397047000000> + | <24926804.045047420000000> + | .000000000000000 + | .000000000000000 + | 4.310000000000000 + | 16397.038491000000000 + | 74881.000000000000000 + | 93901.577630260000000 + | 7799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_4, to_char(val, '9999999999999999.999999999999999S') + FROM num_data ORDER BY val; + to_char_4 | to_char +-----------+----------------------------------- + | 83028485.000000000000000- + | 34338492.215397047000000- + | 24926804.045047420000000- + | .000000000000000+ + | .000000000000000+ + | 4.310000000000000+ + | 16397.038491000000000+ + | 74881.000000000000000+ + | 93901.577630260000000+ + | 7799461.411900000000000+ +(10 rows) + +SELECT '' AS to_char_5, to_char(val, 'MI9999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_5 | to_char +-----------+----------------------------------- + | - 83028485.000000000000000 + | - 34338492.215397047000000 + | - 24926804.045047420000000 + | .000000000000000 + | .000000000000000 + | 4.310000000000000 + | 16397.038491000000000 + | 74881.000000000000000 + | 93901.577630260000000 + | 7799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_6, to_char(val, 'FMS9999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_6 | to_char +-----------+--------------------- + | -83028485. + | -34338492.215397047 + | -24926804.04504742 + | +0. + | +0. + | +4.31 + | +16397.038491 + | +74881. + | +93901.57763026 + | +7799461.4119 +(10 rows) + +SELECT '' AS to_char_7, to_char(val, 'FM9999999999999999.999999999999999THPR') FROM num_data ORDER BY val; + to_char_7 | to_char +-----------+---------------------- + | <83028485.> + | <34338492.215397047> + | <24926804.04504742> + | 0. + | 0. + | 4.31 + | 16397.038491 + | 74881. + | 93901.57763026 + | 7799461.4119 +(10 rows) + +SELECT '' AS to_char_8, to_char(val, 'SG9999999999999999.999999999999999th') FROM num_data ORDER BY val; + to_char_8 | to_char +-----------+----------------------------------- + | - 83028485.000000000000000 + | - 34338492.215397047000000 + | - 24926804.045047420000000 + | + .000000000000000 + | + .000000000000000 + | + 4.310000000000000 + | + 16397.038491000000000 + | + 74881.000000000000000 + | + 93901.577630260000000 + | + 7799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_9, to_char(val, '0999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_9 | to_char +-----------+----------------------------------- + | -0000000083028485.000000000000000 + | -0000000034338492.215397047000000 + | -0000000024926804.045047420000000 + | 0000000000000000.000000000000000 + | 0000000000000000.000000000000000 + | 0000000000000004.310000000000000 + | 0000000000016397.038491000000000 + | 0000000000074881.000000000000000 + | 0000000000093901.577630260000000 + | 0000000007799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_10, to_char(val, 'S0999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_10 | to_char +------------+----------------------------------- + | -0000000083028485.000000000000000 + | -0000000034338492.215397047000000 + | -0000000024926804.045047420000000 + | +0000000000000000.000000000000000 + | +0000000000000000.000000000000000 + | +0000000000000004.310000000000000 + | +0000000000016397.038491000000000 + | +0000000000074881.000000000000000 + | +0000000000093901.577630260000000 + | +0000000007799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_11, to_char(val, 'FM0999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_11 | to_char +------------+----------------------------- + | -0000000083028485. + | -0000000034338492.215397047 + | -0000000024926804.04504742 + | 0000000000000000. + | 0000000000000000. + | 0000000000000004.31 + | 0000000000016397.038491 + | 0000000000074881. + | 0000000000093901.57763026 + | 0000000007799461.4119 +(10 rows) + +SELECT '' AS to_char_12, to_char(val, 'FM9999999999999999.099999999999999') FROM num_data ORDER BY val; + to_char_12 | to_char +------------+--------------------- + | -83028485.0 + | -34338492.215397047 + | -24926804.04504742 + | .0 + | .0 + | 4.31 + | 16397.038491 + | 74881.0 + | 93901.57763026 + | 7799461.4119 +(10 rows) + +SELECT '' AS to_char_13, to_char(val, 'FM9999999999990999.990999999999999') FROM num_data ORDER BY val; + to_char_13 | to_char +------------+--------------------- + | -83028485.000 + | -34338492.215397047 + | -24926804.04504742 + | 0000.000 + | 0000.000 + | 0004.310 + | 16397.038491 + | 74881.000 + | 93901.57763026 + | 7799461.4119 +(10 rows) + +SELECT '' AS to_char_14, to_char(val, 'FM0999999999999999.999909999999999') FROM num_data ORDER BY val; + to_char_14 | to_char +------------+----------------------------- + | -0000000083028485.00000 + | -0000000034338492.215397047 + | -0000000024926804.04504742 + | 0000000000000000.00000 + | 0000000000000000.00000 + | 0000000000000004.31000 + | 0000000000016397.038491 + | 0000000000074881.00000 + | 0000000000093901.57763026 + | 0000000007799461.41190 +(10 rows) + +SELECT '' AS to_char_15, to_char(val, 'FM9999999990999999.099999999999999') FROM num_data ORDER BY val; + to_char_15 | to_char +------------+--------------------- + | -83028485.0 + | -34338492.215397047 + | -24926804.04504742 + | 0000000.0 + | 0000000.0 + | 0000004.31 + | 0016397.038491 + | 0074881.0 + | 0093901.57763026 + | 7799461.4119 +(10 rows) + +SELECT '' AS to_char_16, to_char(val, 'L9999999999999999.099999999999999') FROM num_data ORDER BY val; + to_char_16 | to_char +------------+------------------------------------ + | $ -83028485.000000000000000 + | -34338492.215397047000000 + | $ -24926804.045047420000000 + | $ .000000000000000 + | $ .000000000000000 + | 4.310000000000000 + | 16397.038491000000000 + | 74881.000000000000000 + | $ 93901.577630260000000 + | $ 7799461.411900000000000 +(10 rows) + +SELECT '' AS to_char_17, to_char(val, 'FM9999999999999999.99999999999999') FROM num_data ORDER BY val; + to_char_17 | to_char +------------+--------------------- + | -83028485. + | -34338492.215397047 + | -24926804.04504742 + | 0. + | 0. + | 4.31 + | 16397.038491 + | 74881. + | 93901.57763026 + | 7799461.4119 +(10 rows) + +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 ORDER BY val; + to_char_18 | to_char +------------+----------------------------------------------------------------------- + | -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 + | -3 4 3 3 8 4 9 2 . 2 1 5 3 9 7 0 4 7 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 + | +. 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 + | +4 . 3 1 0 0 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 + | +7 4 8 8 1 . 0 0 0 0 0 0 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 + | +7 7 9 9 4 6 1 . 4 1 1 9 0 0 0 0 0 0 0 0 0 0 0 0 0 +(10 rows) + +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 ORDER BY val; + to_char_19 | to_char +------------+------------------------------------------------------- + | -8 3 0 2 8 4 8 5 . + | -3 4 3 3 8 4 9 2 . 2 1 5 3 9 7 0 4 7 + | -2 4 9 2 6 8 0 4 . 0 4 5 0 4 7 4 2 + | +0 . + | +0 . + | +4 . 3 1 + | +1 6 3 9 7 . 0 3 8 4 9 1 + | +7 4 8 8 1 . + | +9 3 9 0 1 . 5 7 7 6 3 0 2 6 + | +7 7 9 9 4 6 1 . 4 1 1 9 +(10 rows) + +SELECT '' AS to_char_20, to_char(val, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM num_data ORDER BY val; + to_char_20 | to_char +------------+----------------------------------------------------------- + | text -8 9999 302 "text between quote marks" 8485 + | text -3 9999 433 "text between quote marks" 8492 + | text -2 9999 492 "text between quote marks" 6804 + | text 9999 "text between quote marks" 0 + | text 9999 "text between quote marks" 0 + | text 9999 "text between quote marks" 4 + | text 9999 1 "text between quote marks" 6397 + | text 9999 7 "text between quote marks" 4881 + | text 9999 9 "text between quote marks" 3902 + | text 9999 779 "text between quote marks" 9461 +(10 rows) + +SELECT '' AS to_char_21, to_char(val, '999999SG9999999999') FROM num_data ORDER BY val; + to_char_21 | to_char +------------+------------------- + | - 83028485 + | - 34338492 + | - 24926804 + | + 0 + | + 0 + | + 4 + | + 16397 + | + 74881 + | + 93902 + | + 7799461 +(10 rows) + +SELECT '' AS to_char_22, to_char(val, 'FM9999999999999999.999999999999999') FROM num_data ORDER BY val; + to_char_22 | to_char +------------+--------------------- + | -83028485. + | -34338492.215397047 + | -24926804.04504742 + | 0. + | 0. + | 4.31 + | 16397.038491 + | 74881. + | 93901.57763026 + | 7799461.4119 +(10 rows) + +-- TO_NUMBER() +-- +SELECT '' AS to_number_1, to_number('-34,338,492', '99G999G999'); + to_number_1 | to_number +-------------+----------- + | -34338492 +(1 row) + +SELECT '' AS to_number_2, to_number('-34,338,492.654,878', '99G999G999D999G999'); + to_number_2 | to_number +-------------+------------------ + | -34338492.654878 +(1 row) + +SELECT '' AS to_number_3, to_number('<564646.654564>', '999999.999999PR'); + to_number_3 | to_number +-------------+---------------- + | -564646.654564 +(1 row) + +SELECT '' AS to_number_4, to_number('0.00001-', '9.999999S'); + to_number_4 | to_number +-------------+----------- + | -0.00001 +(1 row) + +SELECT '' AS to_number_5, to_number('5.01-', 'FM9.999999S'); + to_number_5 | to_number +-------------+----------- + | -5.01 +(1 row) + +SELECT '' AS to_number_5, to_number('5.01-', 'FM9.999999MI'); + to_number_5 | to_number +-------------+----------- + | -5.01 +(1 row) + +SELECT '' AS to_number_7, to_number('5 4 4 4 4 8 . 7 8', '9 9 9 9 9 9 . 9 9'); + to_number_7 | to_number +-------------+----------- + | 544448.78 +(1 row) + +SELECT '' AS to_number_8, to_number('.01', 'FM9.99'); + to_number_8 | to_number +-------------+----------- + | 0.01 +(1 row) + +SELECT '' AS to_number_9, to_number('.0', '99999999.99999999'); + to_number_9 | to_number +-------------+----------- + | 0.0 +(1 row) + +SELECT '' AS to_number_10, to_number('0', '99.99'); + to_number_10 | to_number +--------------+----------- + | 0 +(1 row) + +SELECT '' AS to_number_11, to_number('.-01', 'S99.99'); + to_number_11 | to_number +--------------+----------- + | -0.01 +(1 row) + +SELECT '' AS to_number_12, to_number('.01-', '99.99S'); + to_number_12 | to_number +--------------+----------- + | -0.01 +(1 row) + +SELECT '' AS to_number_13, to_number(' . 0 1-', ' 9 9 . 9 9 S'); + to_number_13 | to_number +--------------+----------- + | -0.01 +(1 row) + +-- +-- Input syntax +-- +CREATE TABLE num_input_test (n1 numeric); +-- good inputs +INSERT INTO num_input_test(n1) VALUES (' 123'); +INSERT INTO num_input_test(n1) VALUES (' 3245874 '); +INSERT INTO num_input_test(n1) VALUES (' -93853'); +INSERT INTO num_input_test(n1) VALUES ('555.50'); +INSERT INTO num_input_test(n1) VALUES ('-555.50'); +INSERT INTO num_input_test(n1) VALUES ('NaN '); +INSERT INTO num_input_test(n1) VALUES (' nan'); +-- bad inputs +INSERT INTO num_input_test(n1) VALUES (' '); +ERROR: invalid input syntax for type numeric: " " +LINE 1: INSERT INTO num_input_test(n1) VALUES (' '); + ^ +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 %'); + ^ +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'); + ^ +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'); + ^ +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'); + ^ +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 '); + ^ +INSERT INTO num_input_test(n1) VALUES (''); +ERROR: invalid input syntax for type numeric: "" +LINE 1: INSERT INTO num_input_test(n1) VALUES (''); + ^ +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 '); + ^ +SELECT * FROM num_input_test ORDER BY n1; + n1 +--------- + -93853 + -555.50 + 123 + 555.50 + 3245874 + NaN + NaN +(7 rows) + +-- +-- Test some corner cases for division +-- +select 999999999999999999999::numeric/1000000000000000000000; + ?column? +------------------------ + 1.00000000000000000000 +(1 row) + +select div(999999999999999999999::numeric,1000000000000000000000); + div +----- + 0 +(1 row) + +select mod(999999999999999999999::numeric,1000000000000000000000); + mod +----------------------- + 999999999999999999999 +(1 row) + +select div(-9999999999999999999999::numeric,1000000000000000000000); + div +----- + -9 +(1 row) + +select mod(-9999999999999999999999::numeric,1000000000000000000000); + mod +------------------------ + -999999999999999999999 +(1 row) + +select div(-9999999999999999999999::numeric,1000000000000000000000)*1000000000000000000000 + mod(-9999999999999999999999::numeric,1000000000000000000000); + ?column? +------------------------- + -9999999999999999999999 +(1 row) + +select mod (70.0,70) ; + mod +----- + 0.0 +(1 row) + +select div (70.0,70) ; + div +----- + 1 +(1 row) + +select 70.0 / 70 ; + ?column? +------------------------ + 1.00000000000000000000 +(1 row) + +select 12345678901234567890 % 123; + ?column? +---------- + 78 +(1 row) + +select 12345678901234567890 / 123; + ?column? +-------------------- + 100371373180768845 +(1 row) + +select div(12345678901234567890, 123); + div +-------------------- + 100371373180768844 +(1 row) + +select div(12345678901234567890, 123) * 123 + 12345678901234567890 % 123; + ?column? +---------------------- + 12345678901234567... [truncated message content] |
From: Abbas B. <ga...@us...> - 2011-03-17 16:15:20
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 0115aacecb33438da33b51e7761498de6a854ba3 (commit) from e62b497522fbf7b3ac361b3aef0e8ca23cdda675 (commit) - Log ----------------------------------------------------------------- commit 0115aacecb33438da33b51e7761498de6a854ba3 Author: Abbas <abb...@en...> Date: Thu Mar 17 21:13:35 2011 +0500 Expected output changed to fix regression failure diff --git a/src/test/regress/expected/float8_1.out b/src/test/regress/expected/float8_1.out index 1f79f66..65fe187 100644 --- a/src/test/regress/expected/float8_1.out +++ b/src/test/regress/expected/float8_1.out @@ -381,8 +381,7 @@ SELECT '' AS five, * FROM FLOAT8_TBL ORDER BY f1; UPDATE FLOAT8_TBL SET f1 = FLOAT8_TBL.f1 * '-1' WHERE FLOAT8_TBL.f1 > '0.0'; - -SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f ORDER BY f1; +SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f ORDER BY f1; ERROR: value out of range: overflow SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f ORDER BY f1; ERROR: value out of range: overflow ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/float8_1.out | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-17 16:09:43
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via e62b497522fbf7b3ac361b3aef0e8ca23cdda675 (commit) from bce5904c777b305c7706146077c2a692e7dad52e (commit) - Log ----------------------------------------------------------------- commit e62b497522fbf7b3ac361b3aef0e8ca23cdda675 Author: Abbas <abb...@en...> Date: Thu Mar 17 21:07:24 2011 +0500 Add alternate expected output files to take care of regression failures diff --git a/src/test/regress/expected/int8_1.out b/src/test/regress/expected/int8_1.out new file mode 100644 index 0000000..ce06501 --- /dev/null +++ b/src/test/regress/expected/int8_1.out @@ -0,0 +1,804 @@ +-- +-- INT8 +-- Test int8 64-bit integers. +-- +CREATE TABLE INT8_TBL(q1 int8, q2 int8); +INSERT INTO INT8_TBL VALUES(' 123 ',' 456'); +INSERT INTO INT8_TBL VALUES('123 ','4567890123456789'); +INSERT INTO INT8_TBL VALUES('4567890123456789','123'); +INSERT INTO INT8_TBL VALUES(+4567890123456789,'4567890123456789'); +INSERT INTO INT8_TBL VALUES('+4567890123456789','-4567890123456789'); +-- bad inputs +INSERT INTO INT8_TBL(q1) VALUES (' '); +ERROR: invalid input syntax for integer: " " +LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' '); + ^ +INSERT INTO INT8_TBL(q1) VALUES ('xxx'); +ERROR: invalid input syntax for integer: "xxx" +LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('xxx'); + ^ +INSERT INTO INT8_TBL(q1) VALUES ('3908203590239580293850293850329485'); +ERROR: value "3908203590239580293850293850329485" is out of range for type bigint +LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('39082035902395802938502938... + ^ +INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340329840934'); +ERROR: value "-1204982019841029840928340329840934" is out of range for type bigint +LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340... + ^ +INSERT INTO INT8_TBL(q1) VALUES ('- 123'); +ERROR: invalid input syntax for integer: "- 123" +LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('- 123'); + ^ +INSERT INTO INT8_TBL(q1) VALUES (' 345 5'); +ERROR: invalid input syntax for integer: " 345 5" +LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' 345 5'); + ^ +INSERT INTO INT8_TBL(q1) VALUES (''); +ERROR: invalid input syntax for integer: "" +LINE 1: INSERT INTO INT8_TBL(q1) VALUES (''); + ^ +SELECT * FROM INT8_TBL ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(5 rows) + +-- int8/int8 cmp +SELECT * FROM INT8_TBL WHERE q2 = 4567890123456789 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(2 rows) + +SELECT * FROM INT8_TBL WHERE q2 <> 4567890123456789 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(3 rows) + +SELECT * FROM INT8_TBL WHERE q2 < 4567890123456789 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(3 rows) + +SELECT * FROM INT8_TBL WHERE q2 > 4567890123456789 ORDER BY q1,q2; + q1 | q2 +----+---- +(0 rows) + +SELECT * FROM INT8_TBL WHERE q2 <= 4567890123456789 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(5 rows) + +SELECT * FROM INT8_TBL WHERE q2 >= 4567890123456789 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(2 rows) + +-- int8/int4 cmp +SELECT * FROM INT8_TBL WHERE q2 = 456 ORDER BY q1,q2; + q1 | q2 +-----+----- + 123 | 456 +(1 row) + +SELECT * FROM INT8_TBL WHERE q2 <> 456 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(4 rows) + +SELECT * FROM INT8_TBL WHERE q2 < 456 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(2 rows) + +SELECT * FROM INT8_TBL WHERE q2 > 456 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(2 rows) + +SELECT * FROM INT8_TBL WHERE q2 <= 456 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(3 rows) + +SELECT * FROM INT8_TBL WHERE q2 >= 456 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(3 rows) + +-- int4/int8 cmp +SELECT * FROM INT8_TBL WHERE 123 = q1 ORDER BY q1,q2; + q1 | q2 +-----+------------------ + 123 | 456 + 123 | 4567890123456789 +(2 rows) + +SELECT * FROM INT8_TBL WHERE 123 <> q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(3 rows) + +SELECT * FROM INT8_TBL WHERE 123 < q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(3 rows) + +SELECT * FROM INT8_TBL WHERE 123 > q1 ORDER BY q1,q2; + q1 | q2 +----+---- +(0 rows) + +SELECT * FROM INT8_TBL WHERE 123 <= q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(5 rows) + +SELECT * FROM INT8_TBL WHERE 123 >= q1 ORDER BY q1,q2; + q1 | q2 +-----+------------------ + 123 | 456 + 123 | 4567890123456789 +(2 rows) + +-- int8/int2 cmp +SELECT * FROM INT8_TBL WHERE q2 = '456'::int2 ORDER BY q1,q2; + q1 | q2 +-----+----- + 123 | 456 +(1 row) + +SELECT * FROM INT8_TBL WHERE q2 <> '456'::int2 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(4 rows) + +SELECT * FROM INT8_TBL WHERE q2 < '456'::int2 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(2 rows) + +SELECT * FROM INT8_TBL WHERE q2 > '456'::int2 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(2 rows) + +SELECT * FROM INT8_TBL WHERE q2 <= '456'::int2 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 +(3 rows) + +SELECT * FROM INT8_TBL WHERE q2 >= '456'::int2 ORDER BY q1,q2; + q1 | q2 +------------------+------------------ + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(3 rows) + +-- int2/int8 cmp +SELECT * FROM INT8_TBL WHERE '123'::int2 = q1 ORDER BY q1,q2; + q1 | q2 +-----+------------------ + 123 | 456 + 123 | 4567890123456789 +(2 rows) + +SELECT * FROM INT8_TBL WHERE '123'::int2 <> q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(3 rows) + +SELECT * FROM INT8_TBL WHERE '123'::int2 < q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(3 rows) + +SELECT * FROM INT8_TBL WHERE '123'::int2 > q1 ORDER BY q1,q2; + q1 | q2 +----+---- +(0 rows) + +SELECT * FROM INT8_TBL WHERE '123'::int2 <= q1 ORDER BY q1,q2; + q1 | q2 +------------------+------------------- + 123 | 456 + 123 | 4567890123456789 + 4567890123456789 | -4567890123456789 + 4567890123456789 | 123 + 4567890123456789 | 4567890123456789 +(5 rows) + +SELECT * FROM INT8_TBL WHERE '123'::int2 >= q1 ORDER BY q1,q2; + q1 | q2 +-----+------------------ + 123 | 456 + 123 | 4567890123456789 +(2 rows) + +SELECT '' AS five, q1 AS plus, -q1 AS minus FROM INT8_TBL ORDER BY q1; + five | plus | minus +------+------------------+------------------- + | 123 | -123 + | 123 | -123 + | 4567890123456789 | -4567890123456789 + | 4567890123456789 | -4567890123456789 + | 4567890123456789 | -4567890123456789 +(5 rows) + +SELECT '' AS five, q1, q2, q1 + q2 AS plus FROM INT8_TBL ORDER BY q1,q2; + five | q1 | q2 | plus +------+------------------+-------------------+------------------ + | 123 | 456 | 579 + | 123 | 4567890123456789 | 4567890123456912 + | 4567890123456789 | -4567890123456789 | 0 + | 4567890123456789 | 123 | 4567890123456912 + | 4567890123456789 | 4567890123456789 | 9135780246913578 +(5 rows) + +SELECT '' AS five, q1, q2, q1 - q2 AS minus FROM INT8_TBL ORDER BY q1,q2; + five | q1 | q2 | minus +------+------------------+-------------------+------------------- + | 123 | 456 | -333 + | 123 | 4567890123456789 | -4567890123456666 + | 4567890123456789 | -4567890123456789 | 9135780246913578 + | 4567890123456789 | 123 | 4567890123456666 + | 4567890123456789 | 4567890123456789 | 0 +(5 rows) + +SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL ORDER BY q1,q2; +ERROR: bigint out of range +SELECT '' AS three, q1, q2, q1 * q2 AS multiply FROM INT8_TBL + WHERE q1 < 1000 or (q2 > 0 and q2 < 1000) ORDER BY q1,q2; + three | q1 | q2 | multiply +-------+------------------+------------------+-------------------- + | 123 | 456 | 56088 + | 123 | 4567890123456789 | 561850485185185047 + | 4567890123456789 | 123 | 561850485185185047 +(3 rows) + +SELECT '' AS five, q1, q2, q1 / q2 AS divide, q1 % q2 AS mod FROM INT8_TBL ORDER BY q1,q2; + five | q1 | q2 | divide | mod +------+------------------+-------------------+----------------+----- + | 123 | 456 | 0 | 123 + | 123 | 4567890123456789 | 0 | 123 + | 4567890123456789 | -4567890123456789 | -1 | 0 + | 4567890123456789 | 123 | 37137318076884 | 57 + | 4567890123456789 | 4567890123456789 | 1 | 0 +(5 rows) + +SELECT '' AS five, q1, float8(q1) FROM INT8_TBL ORDER BY q1; + five | q1 | float8 +------+------------------+---------------------- + | 123 | 123 + | 123 | 123 + | 4567890123456789 | 4.56789012345679e+15 + | 4567890123456789 | 4.56789012345679e+15 + | 4567890123456789 | 4.56789012345679e+15 +(5 rows) + +SELECT '' AS five, q2, float8(q2) FROM INT8_TBL ORDER BY q2; + five | q2 | float8 +------+-------------------+----------------------- + | -4567890123456789 | -4.56789012345679e+15 + | 123 | 123 + | 456 | 456 + | 4567890123456789 | 4.56789012345679e+15 + | 4567890123456789 | 4.56789012345679e+15 +(5 rows) + +SELECT 37 + q1 AS plus4 FROM INT8_TBL ORDER BY q1; + plus4 +------------------ + 160 + 160 + 4567890123456826 + 4567890123456826 + 4567890123456826 +(5 rows) + +SELECT 37 - q1 AS minus4 FROM INT8_TBL ORDER BY q1; + minus4 +------------------- + -86 + -86 + -4567890123456752 + -4567890123456752 + -4567890123456752 +(5 rows) + +SELECT '' AS five, 2 * q1 AS "twice int4" FROM INT8_TBL ORDER BY q1; + five | twice int4 +------+------------------ + | 246 + | 246 + | 9135780246913578 + | 9135780246913578 + | 9135780246913578 +(5 rows) + +SELECT '' AS five, q1 * 2 AS "twice int4" FROM INT8_TBL ORDER BY q1; + five | twice int4 +------+------------------ + | 246 + | 246 + | 9135780246913578 + | 9135780246913578 + | 9135780246913578 +(5 rows) + +-- int8 op int4 +SELECT q1 + 42::int4 AS "8plus4", q1 - 42::int4 AS "8minus4", q1 * 42::int4 AS "8mul4", q1 / 42::int4 AS "8div4" FROM INT8_TBL ORDER BY q1; + 8plus4 | 8minus4 | 8mul4 | 8div4 +------------------+------------------+--------------------+----------------- + 165 | 81 | 5166 | 2 + 165 | 81 | 5166 | 2 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 +(5 rows) + +-- int4 op int8 +SELECT 246::int4 + q1 AS "4plus8", 246::int4 - q1 AS "4minus8", 246::int4 * q1 AS "4mul8", 246::int4 / q1 AS "4div8" FROM INT8_TBL ORDER BY q1; + 4plus8 | 4minus8 | 4mul8 | 4div8 +------------------+-------------------+---------------------+------- + 369 | 123 | 30258 | 2 + 369 | 123 | 30258 | 2 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 +(5 rows) + +-- int8 op int2 +SELECT q1 + 42::int2 AS "8plus2", q1 - 42::int2 AS "8minus2", q1 * 42::int2 AS "8mul2", q1 / 42::int2 AS "8div2" FROM INT8_TBL ORDER BY q1; + 8plus2 | 8minus2 | 8mul2 | 8div2 +------------------+------------------+--------------------+----------------- + 165 | 81 | 5166 | 2 + 165 | 81 | 5166 | 2 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 + 4567890123456831 | 4567890123456747 | 191851385185185138 | 108759288653733 +(5 rows) + +-- int2 op int8 +SELECT 246::int2 + q1 AS "2plus8", 246::int2 - q1 AS "2minus8", 246::int2 * q1 AS "2mul8", 246::int2 / q1 AS "2div8" FROM INT8_TBL ORDER BY q1; + 2plus8 | 2minus8 | 2mul8 | 2div8 +------------------+-------------------+---------------------+------- + 369 | 123 | 30258 | 2 + 369 | 123 | 30258 | 2 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 + 4567890123457035 | -4567890123456543 | 1123700970370370094 | 0 +(5 rows) + +SELECT q2, abs(q2) FROM INT8_TBL ORDER BY q2; + q2 | abs +-------------------+------------------ + -4567890123456789 | 4567890123456789 + 123 | 123 + 456 | 456 + 4567890123456789 | 4567890123456789 + 4567890123456789 | 4567890123456789 +(5 rows) + +SELECT min(q1), min(q2) FROM INT8_TBL; + min | min +-----+------------------- + 123 | -4567890123456789 +(1 row) + +SELECT max(q1), max(q2) FROM INT8_TBL; + max | max +------------------+------------------ + 4567890123456789 | 4567890123456789 +(1 row) + +-- TO_CHAR() +-- +SELECT '' AS to_char_1, to_char(q1, '9G999G999G999G999G999'), to_char(q2, '9,999,999,999,999,999') + FROM INT8_TBL ORDER BY q1,q2; + to_char_1 | to_char | to_char +-----------+------------------------+------------------------ + | 123 | 456 + | 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 | 123 + | 4,567,890,123,456,789 | 4,567,890,123,456,789 +(5 rows) + +SELECT '' AS to_char_2, to_char(q1, '9G999G999G999G999G999D999G999'), to_char(q2, '9,999,999,999,999,999.999,999') + FROM INT8_TBL ORDER BY q1,q2; + 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 | -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 +(5 rows) + +SELECT '' AS to_char_3, to_char( (q1 * -1), '9999999999999999PR'), to_char( (q2 * -1), '9999999999999999.999PR') + FROM INT8_TBL ORDER BY q1,q2; + to_char_3 | to_char | to_char +-----------+--------------------+------------------------ + | <123> | <456.000> + | <123> | <4567890123456789.000> + | <4567890123456789> | 4567890123456789.000 + | <4567890123456789> | <123.000> + | <4567890123456789> | <4567890123456789.000> +(5 rows) + +SELECT '' AS to_char_4, to_char( (q1 * -1), '9999999999999999S'), to_char( (q2 * -1), 'S9999999999999999') + FROM INT8_TBL ORDER BY q1,q2; + to_char_4 | to_char | to_char +-----------+-------------------+------------------- + | 123- | -456 + | 123- | -4567890123456789 + | 4567890123456789- | +4567890123456789 + | 4567890123456789- | -123 + | 4567890123456789- | -4567890123456789 +(5 rows) + +SELECT '' AS to_char_5, to_char(q2, 'MI9999999999999999') FROM INT8_TBL ORDER BY q2; + to_char_5 | to_char +-----------+------------------- + | -4567890123456789 + | 123 + | 456 + | 4567890123456789 + | 4567890123456789 +(5 rows) + +SELECT '' AS to_char_6, to_char(q2, 'FMS9999999999999999') FROM INT8_TBL ORDER BY q2; + to_char_6 | to_char +-----------+------------------- + | -4567890123456789 + | +123 + | +456 + | +4567890123456789 + | +4567890123456789 +(5 rows) + +SELECT '' AS to_char_7, to_char(q2, 'FM9999999999999999THPR') FROM INT8_TBL ORDER BY q2; + to_char_7 | to_char +-----------+-------------------- + | <4567890123456789> + | 123RD + | 456TH + | 4567890123456789TH + | 4567890123456789TH +(5 rows) + +SELECT '' AS to_char_8, to_char(q2, 'SG9999999999999999th') FROM INT8_TBL ORDER BY q2; + to_char_8 | to_char +-----------+--------------------- + | -4567890123456789 + | + 123rd + | + 456th + | +4567890123456789th + | +4567890123456789th +(5 rows) + +SELECT '' AS to_char_9, to_char(q2, '0999999999999999') FROM INT8_TBL ORDER BY q2; + to_char_9 | to_char +-----------+------------------- + | -4567890123456789 + | 0000000000000123 + | 0000000000000456 + | 4567890123456789 + | 4567890123456789 +(5 rows) + +SELECT '' AS to_char_10, to_char(q2, 'S0999999999999999') FROM INT8_TBL ORDER BY q2; + to_char_10 | to_char +------------+------------------- + | -4567890123456789 + | +0000000000000123 + | +0000000000000456 + | +4567890123456789 + | +4567890123456789 +(5 rows) + +SELECT '' AS to_char_11, to_char(q2, 'FM0999999999999999') FROM INT8_TBL ORDER BY q2; + to_char_11 | to_char +------------+------------------- + | -4567890123456789 + | 0000000000000123 + | 0000000000000456 + | 4567890123456789 + | 4567890123456789 +(5 rows) + +SELECT '' AS to_char_12, to_char(q2, 'FM9999999999999999.000') FROM INT8_TBL ORDER BY q2; + to_char_12 | to_char +------------+----------------------- + | -4567890123456789.000 + | 123.000 + | 456.000 + | 4567890123456789.000 + | 4567890123456789.000 +(5 rows) + +SELECT '' AS to_char_13, to_char(q2, 'L9999999999999999.000') FROM INT8_TBL ORDER BY q2; + to_char_13 | to_char +------------+------------------------ + | -4567890123456789.000 + | 123.000 + | 456.000 + | $ 4567890123456789.000 + | $ 4567890123456789.000 +(5 rows) + +SELECT '' AS to_char_14, to_char(q2, 'FM9999999999999999.999') FROM INT8_TBL ORDER BY q2; + to_char_14 | to_char +------------+-------------------- + | -4567890123456789. + | 123. + | 456. + | 4567890123456789. + | 4567890123456789. +(5 rows) + +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 ORDER BY q2; + to_char_15 | to_char +------------+------------------------------------------- + | -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 . 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) + +SELECT '' AS to_char_16, to_char(q2, E'99999 "text" 9999 "9999" 999 "\\"text between quote marks\\"" 9999') FROM INT8_TBL ORDER BY q2; + to_char_16 | to_char +------------+----------------------------------------------------------- + | -45678 text 9012 9999 345 "text between quote marks" 6789 + | text 9999 "text between quote marks" 123 + | text 9999 "text between quote marks" 456 + | 45678 text 9012 9999 345 "text between quote marks" 6789 + | 45678 text 9012 9999 345 "text between quote marks" 6789 +(5 rows) + +SELECT '' AS to_char_17, to_char(q2, '999999SG9999999999') FROM INT8_TBL ORDER BY q2; + to_char_17 | to_char +------------+------------------- + | 456789-0123456789 + | + 123 + | + 456 + | 456789+0123456789 + | 456789+0123456789 +(5 rows) + +-- check min/max values and overflow behavior +select '-9223372036854775808'::int8; + int8 +---------------------- + -9223372036854775808 +(1 row) + +select '-9223372036854775809'::int8; +ERROR: value "-9223372036854775809" is out of range for type bigint +LINE 1: select '-9223372036854775809'::int8; + ^ +select '9223372036854775807'::int8; + int8 +--------------------- + 9223372036854775807 +(1 row) + +select '9223372036854775808'::int8; +ERROR: value "9223372036854775808" is out of range for type bigint +LINE 1: select '9223372036854775808'::int8; + ^ +select -('-9223372036854775807'::int8); + ?column? +--------------------- + 9223372036854775807 +(1 row) + +select -('-9223372036854775808'::int8); +ERROR: bigint out of range +select '9223372036854775800'::int8 + '9223372036854775800'::int8; +ERROR: bigint out of range +select '-9223372036854775800'::int8 + '-9223372036854775800'::int8; +ERROR: bigint out of range +select '9223372036854775800'::int8 - '-9223372036854775800'::int8; +ERROR: bigint out of range +select '-9223372036854775800'::int8 - '9223372036854775800'::int8; +ERROR: bigint out of range +select '9223372036854775800'::int8 * '9223372036854775800'::int8; +ERROR: bigint out of range +select '9223372036854775800'::int8 / '0'::int8; +ERROR: division by zero +select '9223372036854775800'::int8 % '0'::int8; +ERROR: division by zero +select abs('-9223372036854775808'::int8); +ERROR: bigint out of range +select '9223372036854775800'::int8 + '100'::int4; +ERROR: bigint out of range +select '-9223372036854775800'::int8 - '100'::int4; +ERROR: bigint out of range +select '9223372036854775800'::int8 * '100'::int4; +ERROR: bigint out of range +select '100'::int4 + '9223372036854775800'::int8; +ERROR: bigint out of range +select '-100'::int4 - '9223372036854775800'::int8; +ERROR: bigint out of range +select '100'::int4 * '9223372036854775800'::int8; +ERROR: bigint out of range +select '9223372036854775800'::int8 + '100'::int2; +ERROR: bigint out of range +select '-9223372036854775800'::int8 - '100'::int2; +ERROR: bigint out of range +select '9223372036854775800'::int8 * '100'::int2; +ERROR: bigint out of range +select '-9223372036854775808'::int8 / '0'::int2; +ERROR: division by zero +select '100'::int2 + '9223372036854775800'::int8; +ERROR: bigint out of range +select '-100'::int2 - '9223372036854775800'::int8; +ERROR: bigint out of range +select '100'::int2 * '9223372036854775800'::int8; +ERROR: bigint out of range +select '100'::int2 / '0'::int8; +ERROR: division by zero +SELECT CAST(q1 AS int4) FROM int8_tbl WHERE q2 = 456 ORDER BY q1; + q1 +----- + 123 +(1 row) + +SELECT CAST(q1 AS int4) FROM int8_tbl WHERE q2 <> 456 ORDER BY q1; +ERROR: integer out of range +SELECT CAST(q1 AS int2) FROM int8_tbl WHERE q2 = 456 ORDER BY q1; + q1 +----- + 123 +(1 row) + +SELECT CAST(q1 AS int2) FROM int8_tbl WHERE q2 <> 456 ORDER BY q1; +ERROR: smallint out of range +SELECT CAST('42'::int2 AS int8), CAST('-37'::int2 AS int8); + int8 | int8 +------+------ + 42 | -37 +(1 row) + +SELECT CAST(q1 AS float4), CAST(q2 AS float8) FROM INT8_TBL ORDER BY q1,q2; + q1 | q2 +-------------+----------------------- + 123 | 456 + 123 | 4.56789012345679e+15 + 4.56789e+15 | -4.56789012345679e+15 + 4.56789e+15 | 123 + 4.56789e+15 | 4.56789012345679e+15 +(5 rows) + +SELECT CAST('36854775807.0'::float4 AS int8); + int8 +------------- + 36854775808 +(1 row) + +SELECT CAST('922337203685477580700.0'::float8 AS int8); +ERROR: bigint out of range +SELECT CAST(q1 AS oid) FROM INT8_TBL ORDER BY q1; +ERROR: OID out of range +SELECT oid::int8 FROM pg_class WHERE relname = 'pg_class' ORDER BY oid; + oid +------ + 1259 +(1 row) + +-- bit operations +SELECT q1, q2, q1 & q2 AS "and", q1 | q2 AS "or", q1 # q2 AS "xor", ~q1 AS "not" FROM INT8_TBL ORDER BY q1,q2; + q1 | q2 | and | or | xor | not +------------------+-------------------+------------------+------------------+------------------+------------------- + 123 | 456 | 72 | 507 | 435 | -124 + 123 | 4567890123456789 | 17 | 4567890123456895 | 4567890123456878 | -124 + 4567890123456789 | -4567890123456789 | 1 | -1 | -2 | -4567890123456790 + 4567890123456789 | 123 | 17 | 4567890123456895 | 4567890123456878 | -4567890123456790 + 4567890123456789 | 4567890123456789 | 4567890123456789 | 4567890123456789 | 0 | -4567890123456790 +(5 rows) + +SELECT q1, q1 << 2 AS "shl", q1 >> 3 AS "shr" FROM INT8_TBL ORDER BY q1; + q1 | shl | shr +------------------+-------------------+----------------- + 123 | 492 | 15 + 123 | 492 | 15 + 4567890123456789 | 18271560493827156 | 570986265432098 + 4567890123456789 | 18271560493827156 | 570986265432098 + 4567890123456789 | 18271560493827156 | 570986265432098 +(5 rows) + +-- generate_series +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8); + generate_series +------------------ + 4567890123456789 + 4567890123456790 + 4567890123456791 + 4567890123456792 + 4567890123456793 + 4567890123456794 + 4567890123456795 + 4567890123456796 + 4567890123456797 + 4567890123456798 + 4567890123456799 +(11 rows) + +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8, 0); +ERROR: step size cannot equal zero +SELECT * FROM generate_series('+4567890123456789'::int8, '+4567890123456799'::int8, 2); + generate_series +------------------ + 4567890123456789 + 4567890123456791 + 4567890123456793 + 4567890123456795 + 4567890123456797 + 4567890123456799 +(6 rows) + diff --git a/src/test/regress/expected/tablespace_1.out b/src/test/regress/expected/tablespace_1.out new file mode 100644 index 0000000..725ad23 --- /dev/null +++ b/src/test/regress/expected/tablespace_1.out @@ -0,0 +1,98 @@ +-- create a tablespace we can use +CREATE TABLESPACE testspace LOCATION '/home/abbas/pgxc/postgres-xc/src/test/regress/testtablespace'; +ERROR: Postgres-XC does not support TABLESPACE yet +DETAIL: The feature is not currently supported +-- try setting and resetting some properties for the new tablespace +ALTER TABLESPACE testspace SET (random_page_cost = 1.0); +ERROR: tablespace "testspace" does not exist +ALTER TABLESPACE testspace SET (some_nonexistent_parameter = true); -- fail +ERROR: tablespace "testspace" does not exist +ALTER TABLESPACE testspace RESET (random_page_cost = 2.0); -- fail +ERROR: tablespace "testspace" does not exist +ALTER TABLESPACE testspace RESET (random_page_cost, seq_page_cost); -- ok +ERROR: tablespace "testspace" does not exist +-- create a schema we can use +CREATE SCHEMA testschema; +-- try a table +CREATE TABLE testschema.foo (i int) TABLESPACE testspace; +ERROR: tablespace "testspace" does not exist +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'foo'; + relname | spcname +---------+--------- +(0 rows) + +INSERT INTO testschema.foo VALUES(1); +ERROR: relation "testschema.foo" does not exist +LINE 1: INSERT INTO testschema.foo VALUES(1); + ^ +INSERT INTO testschema.foo VALUES(2); +ERROR: relation "testschema.foo" does not exist +LINE 1: INSERT INTO testschema.foo VALUES(2); + ^ +-- tables from dynamic sources +CREATE TABLE testschema.asselect TABLESPACE testspace AS SELECT 1; +ERROR: INTO clause not yet supported +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'asselect'; + relname | spcname +---------+--------- +(0 rows) + +PREPARE selectsource(int) AS SELECT $1; +ERROR: Postgres-XC does not support PREPARE yet +DETAIL: The feature is not currently supported +CREATE TABLE testschema.asexecute TABLESPACE testspace + AS EXECUTE selectsource(2); +ERROR: Postgres-XC does not support EXECUTE yet +DETAIL: The feature is not currently supported +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'asexecute'; + relname | spcname +---------+--------- +(0 rows) + +-- index +CREATE INDEX foo_idx on testschema.foo(i) TABLESPACE testspace; +ERROR: relation "testschema.foo" does not exist +SELECT relname, spcname FROM pg_catalog.pg_tablespace t, pg_catalog.pg_class c + where c.reltablespace = t.oid AND c.relname = 'foo_idx'; + relname | spcname +---------+--------- +(0 rows) + +-- let's try moving a table from one place to another +CREATE TABLE testschema.atable AS VALUES (1), (2); +ERROR: INTO clause not yet supported +CREATE UNIQUE INDEX anindex ON testschema.atable(column1); +ERROR: relation "testschema.atable" does not exist +ALTER TABLE testschema.atable SET TABLESPACE testspace; +ERROR: relation "testschema.atable" does not exist +ALTER INDEX testschema.anindex SET TABLESPACE testspace; +ERROR: relation "testschema.anindex" does not exist +INSERT INTO testschema.atable VALUES(3); -- ok +ERROR: relation "testschema.atable" does not exist +LINE 1: INSERT INTO testschema.atable VALUES(3); + ^ +INSERT INTO testschema.atable VALUES(1); -- fail (checks index) +ERROR: relation "testschema.atable" does not exist +LINE 1: INSERT INTO testschema.atable VALUES(1); + ^ +SELECT COUNT(*) FROM testschema.atable; -- checks heap +ERROR: relation "testschema.atable" does not exist +LINE 1: SELECT COUNT(*) FROM testschema.atable; + ^ +-- Will fail with bad path +CREATE TABLESPACE badspace LOCATION '/no/such/location'; +ERROR: Postgres-XC does not support TABLESPACE yet +DETAIL: The feature is not currently supported +-- No such tablespace +CREATE TABLE bar (i int) TABLESPACE nosuchspace; +ERROR: tablespace "nosuchspace" does not exist +-- Fail, not empty +DROP TABLESPACE testspace; +ERROR: tablespace "testspace" does not exist +DROP SCHEMA testschema CASCADE; +-- Should succeed +DROP TABLESPACE testspace; +ERROR: tablespace "testspace" does not exist ----------------------------------------------------------------------- Summary of changes: src/test/regress/expected/{int8.out => int8_1.out} | 4 +- .../tablespace_1.out} | 82 ++++++++++++-------- 2 files changed, 51 insertions(+), 35 deletions(-) copy src/test/regress/expected/{int8.out => int8_1.out} (99%) copy src/test/regress/{output/tablespace.source => expected/tablespace_1.out} (53%) hooks/post-receive -- Postgres-XC |
From: Abbas B. <ga...@us...> - 2011-03-17 15:57:27
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via bce5904c777b305c7706146077c2a692e7dad52e (commit) from 2f96f59952551d1644c3176e5a23483308e9c810 (commit) - Log ----------------------------------------------------------------- commit bce5904c777b305c7706146077c2a692e7dad52e Author: Abbas <abb...@en...> Date: Thu Mar 17 20:55:15 2011 +0500 Fixing a few expected output files and changed a warning message to make the output independent of the cluster configuration diff --git a/src/backend/pgxc/pool/pgxcnode.c b/src/backend/pgxc/pool/pgxcnode.c index 58a089e..7baddd3 100644 --- a/src/backend/pgxc/pool/pgxcnode.c +++ b/src/backend/pgxc/pool/pgxcnode.c @@ -6,7 +6,7 @@ * Datanodes and Coordinators * * - * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group + * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 2010-2011 Nippon Telegraph and Telephone Corporation * * IDENTIFICATION @@ -607,7 +607,7 @@ release_handles(void) dn_discard[dn_ndisc++] = handle->nodenum; else if (handle->state != DN_CONNECTION_STATE_IDLE) { - elog(WARNING, "Connection to Datanode %d has unexpected state %d and will be dropped", handle->nodenum, handle->state); + elog(DEBUG1, "Connection to Datanode %d has unexpected state %d and will be dropped", handle->nodenum, handle->state); dn_discard[dn_ndisc++] = handle->nodenum; } pgxc_node_free(handle); @@ -625,7 +625,7 @@ release_handles(void) co_discard[co_ndisc++] = handle->nodenum; else if (handle->state != DN_CONNECTION_STATE_IDLE) { - elog(WARNING, "Connection to Coordinator %d has unexpected state %d and will be dropped", handle->nodenum, handle->state); + elog(DEBUG1, "Connection to Coordinator %d has unexpected state %d and will be dropped", handle->nodenum, handle->state); co_discard[co_ndisc++] = handle->nodenum; } pgxc_node_free(handle); diff --git a/src/test/regress/expected/char_1.out b/src/test/regress/expected/char_1.out index 4cc081d..1c38b33 100644 --- a/src/test/regress/expected/char_1.out +++ b/src/test/regress/expected/char_1.out @@ -25,28 +25,28 @@ INSERT INTO CHAR_TBL (f1) VALUES (''); INSERT INTO CHAR_TBL (f1) VALUES ('cd'); ERROR: value too long for type character(1) INSERT INTO CHAR_TBL (f1) VALUES ('c '); -SELECT '' AS seven, * FROM CHAR_TBL; +SELECT '' AS seven, * FROM CHAR_TBL ORDER BY f1; seven | f1 -------+---- - | a - | A + | | 1 | 2 | 3 - | + | a + | A | c (7 rows) SELECT '' AS six, c.* FROM CHAR_TBL c - WHERE c.f1 <> 'a'; + WHERE c.f1 <> 'a' ORDER BY f1; six | f1 -----+---- - | A + | | 1 | 2 | 3 - | + | A | c (6 rows) @@ -60,30 +60,30 @@ SELECT '' AS one, c.* SELECT '' AS five, c.* FROM CHAR_TBL c - WHERE c.f1 < 'a'; + WHERE c.f1 < 'a' ORDER BY f1; five | f1 ------+---- + | | 1 | 2 | 3 - | (4 rows) SELECT '' AS six, c.* FROM CHAR_TBL c - WHERE c.f1 <= 'a'; + WHERE c.f1 <= 'a' ORDER BY f1; six | f1 -----+---- - | a + | | 1 | 2 | 3 - | + | a (5 rows) SELECT '' AS one, c.* FROM CHAR_TBL c - WHERE c.f1 > 'a'; + WHERE c.f1 > 'a' ORDER BY f1; one | f1 -----+---- | A @@ -92,7 +92,7 @@ SELECT '' AS one, c.* SELECT '' AS two, c.* FROM CHAR_TBL c - WHERE c.f1 >= 'a'; + WHERE c.f1 >= 'a' ORDER BY f1; two | f1 -----+---- | a @@ -111,7 +111,7 @@ INSERT INTO CHAR_TBL (f1) VALUES ('abcd'); INSERT INTO CHAR_TBL (f1) VALUES ('abcde'); ERROR: value too long for type character(4) INSERT INTO CHAR_TBL (f1) VALUES ('abcd '); -SELECT '' AS four, * FROM CHAR_TBL; +SELECT '' AS four, * FROM CHAR_TBL ORDER BY f1; four | f1 ------+------ | a diff --git a/src/test/regress/expected/float8.out b/src/test/regress/expected/float8.out index d3e60cd..98a4d26 100644 --- a/src/test/regress/expected/float8.out +++ b/src/test/regress/expected/float8.out @@ -175,15 +175,6 @@ SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1 ORDER BY f1; | 1004.3 (4 rows) -SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3' ORDER BY f1; - four | f1 -------+---------------------- - | -34.84 - | 0 - | 1.2345678901234e-200 - | 1004.3 -(4 rows) - SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3'; four | f1 ------+---------------------- diff --git a/src/test/regress/expected/varchar_1.out b/src/test/regress/expected/varchar_1.out index d726e4c..29e7481 100644 --- a/src/test/regress/expected/varchar_1.out +++ b/src/test/regress/expected/varchar_1.out @@ -14,28 +14,28 @@ INSERT INTO VARCHAR_TBL (f1) VALUES (''); INSERT INTO VARCHAR_TBL (f1) VALUES ('cd'); ERROR: value too long for type character varying(1) INSERT INTO VARCHAR_TBL (f1) VALUES ('c '); -SELECT '' AS seven, * FROM VARCHAR_TBL; +SELECT '' AS seven, * FROM VARCHAR_TBL ORDER BY f1; seven | f1 -------+---- - | a - | A + | | 1 | 2 | 3 - | + | a + | A | c (7 rows) SELECT '' AS six, c.* FROM VARCHAR_TBL c - WHERE c.f1 <> 'a'; + WHERE c.f1 <> 'a' ORDER BY f1; six | f1 -----+---- - | A + | | 1 | 2 | 3 - | + | A | c (6 rows) @@ -49,25 +49,25 @@ SELECT '' AS one, c.* SELECT '' AS five, c.* FROM VARCHAR_TBL c - WHERE c.f1 < 'a'; + WHERE c.f1 < 'a' ORDER BY f1; five | f1 ------+---- + | | 1 | 2 | 3 - | (4 rows) SELECT '' AS six, c.* FROM VARCHAR_TBL c - WHERE c.f1 <= 'a'; + WHERE c.f1 <= 'a' ORDER BY f1; six | f1 -----+---- - | a + | | 1 | 2 | 3 - | + | a (5 rows) SELECT '' AS one, c.* @@ -81,7 +81,7 @@ SELECT '' AS one, c.* SELECT '' AS two, c.* FROM VARCHAR_TBL c - WHERE c.f1 >= 'a'; + WHERE c.f1 >= 'a' ORDER BY f1; two | f1 -----+---- | a @@ -100,7 +100,7 @@ INSERT INTO VARCHAR_TBL (f1) VALUES ('abcd'); INSERT INTO VARCHAR_TBL (f1) VALUES ('abcde'); ERROR: value too long for type character varying(4) INSERT INTO VARCHAR_TBL (f1) VALUES ('abcd '); -SELECT '' AS four, * FROM VARCHAR_TBL; +SELECT '' AS four, * FROM VARCHAR_TBL ORDER BY f1; four | f1 ------+------ | a ----------------------------------------------------------------------- Summary of changes: src/backend/pgxc/pool/pgxcnode.c | 6 +++--- src/test/regress/expected/char_1.out | 30 +++++++++++++++--------------- src/test/regress/expected/float8.out | 9 --------- src/test/regress/expected/varchar_1.out | 28 ++++++++++++++-------------- 4 files changed, 32 insertions(+), 41 deletions(-) hooks/post-receive -- Postgres-XC |
From: Michael P. <mic...@us...> - 2011-03-11 05:45:57
|
Project "Postgres-XC". The branch, merge_postgres_9_0_3 has been updated via 2f96f59952551d1644c3176e5a23483308e9c810 (commit) from 861f5131ddadd10fcd88f3653862601cddf0b255 (commit) - Log ----------------------------------------------------------------- commit 2f96f59952551d1644c3176e5a23483308e9c810 Author: Michael P <mic...@us...> Date: Fri Mar 11 14:36:32 2011 +0900 Stabilize code for pg_regress tests This commits enables FOREIGN constraints and solves a couple of issues found with pg_regress tests when assertions are enabled. diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index bdb026d..a3956ae 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -32,7 +32,9 @@ #include "utils/builtins.h" #include "utils/lsyscache.h" #include "utils/syscache.h" - +#ifdef PGXC +#include "pgxc/pgxc.h" +#endif typedef struct convert_testexpr_context { @@ -342,6 +344,11 @@ make_subplan(PlannerInfo *root, Query *orig_subquery, SubLinkType subLinkType, result = build_subplan(root, plan, subroot->parse->rtable, subroot->rowMarks, subLinkType, testexpr, true, isTopQual); +#ifdef PGXC + /* This is not necessary for a PGXC Coordinator, we just need one plan */ + if (IS_PGXC_COORDINATOR && !IsConnFromCoord()) + return result; +#endif /* * If it's a correlated EXISTS with an unimportant targetlist, we might be diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index 3ffc570..0ed66ed 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -1595,12 +1595,6 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt, constraint->skip_validation = true; #ifdef PGXC - if (constraint->contype == CONSTR_FOREIGN) - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("Postgres-XC does not support FOREIGN constraints yet"), - errdetail("The feature is not currently supported"))); - /* * Set fallback distribution column. * If not yet set, set it to first column in FK constraint @@ -1611,7 +1605,8 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt, Oid pk_rel_id = RangeVarGetRelid(constraint->pktable, false); /* make sure it is a partitioned column */ - if (IsHashColumnForRelId(pk_rel_id, strVal(list_nth(constraint->pk_attrs,0)))) + if (list_length(constraint->pk_attrs) != 0 + && IsHashColumnForRelId(pk_rel_id, strVal(list_nth(constraint->pk_attrs,0)))) { /* take first column */ char *colstr = strdup(strVal(list_nth(constraint->fk_attrs,0))); @@ -2147,12 +2142,6 @@ transformAlterTableStmt(AlterTableStmt *stmt, const char *queryString) if (((Constraint *) cmd->def)->contype == CONSTR_FOREIGN) { skipValidation = false; -#ifdef PGXC - ereport(ERROR, - (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("Postgres-XC does not support FOREIGN constraints yet"), - errdetail("The feature is not currently supported"))); -#endif } } else @@ -2557,8 +2546,8 @@ CheckLocalIndexColumn (char loctype, char *partcolname, char *indexcolname) * check to see if the constraint can be enforced locally * if not, an error will be thrown */ -void -static checkLocalFKConstraints(CreateStmtContext *cxt) +static void +checkLocalFKConstraints(CreateStmtContext *cxt) { ListCell *fkclist; @@ -2621,7 +2610,7 @@ static checkLocalFKConstraints(CreateStmtContext *cxt) { char *attrname = (char *) strVal(lfirst(attritem)); - if (strcmp(cxt->rel->rd_locator_info->partAttrName, attrname) == 0) + if (strcmp(checkcolname, attrname) == 0) { /* Found the ordinal position in constraint */ break; @@ -2631,14 +2620,20 @@ static checkLocalFKConstraints(CreateStmtContext *cxt) if (pos >= list_length(fkconstraint->fk_attrs)) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Hash/Modulo distributed table must include distribution column in index"))); + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("Hash/Modulo distributed table must include distribution column in index"))); + + /* Manage the error when the list of new constraints is empty */ + if (!fkconstraint->pk_attrs) + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("Hash/Modulo distribution column list of attributes is empty"))); /* Verify that the referenced table is partitioned at the same position in the index */ if (!IsDistColumnForRelId(pk_rel_id, strVal(list_nth(fkconstraint->pk_attrs,pos)))) ereport(ERROR, - (errcode(ERRCODE_SYNTAX_ERROR), - errmsg("Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table."))); + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table."))); } } } ----------------------------------------------------------------------- Summary of changes: src/backend/optimizer/plan/subselect.c | 9 +++++++- src/backend/parser/parse_utilcmd.c | 35 +++++++++++++------------------ 2 files changed, 23 insertions(+), 21 deletions(-) hooks/post-receive -- Postgres-XC |