提交 7c18e3f7 编写于 作者: H Heikki Linnakangas

Move tests on DML on tables with OIDs from TINC.

Aside from being a good thing that we should do sooner or later anyway,
this silences some current test failures that were caused by the error
message differences by commit ec3370b0.
上级 5fa3014b
create schema qp_dml_oids;
set search_path='qp_dml_oids';
DROP TABLE IF EXISTS dml_ao;
NOTICE: table "dml_ao" does not exist, skipping
CREATE TABLE dml_ao (a int , b int default -1, c text) WITH (appendonly = true, oids = true) DISTRIBUTED BY (a);
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
INSERT INTO dml_ao VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_ao VALUES(NULL,NULL,NULL);
--
-- DDL on AO/CO tables with OIDS(Negative Test)
--
DROP TABLE IF EXISTS tempoid;
NOTICE: table "tempoid" does not exist, skipping
CREATE TABLE tempoid as SELECT oid,a FROM dml_ao ORDER BY 1;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
UPDATE dml_ao SET a = 100;
ERROR: Cannot parallelize an UPDATE statement that updates the distribution columns
SELECT * FROM ( (SELECT COUNT(*) FROM dml_ao) UNION (SELECT COUNT(*) FROM tempoid, dml_ao WHERE tempoid.oid = dml_ao.oid AND tempoid.gp_segment_id = dml_ao.gp_segment_id))foo;
count
-------
3
(1 row)
DROP TABLE IF EXISTS dml_heap_check_r;
NOTICE: table "dml_heap_check_r" does not exist, skipping
CREATE TABLE dml_heap_check_r (
a int default 100 CHECK( a between 1 and 105),
b float8 CONSTRAINT rcheck_b CHECK( b <> 0.00 and b IS NOT NULL),
c text,
d numeric NOT NULL)
WITH OIDS DISTRIBUTED BY (a);
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
--
-- DML on table with constraints and OIDS(Negative Test)
--
INSERT INTO dml_heap_check_r SELECT i, i ,'r', i FROM generate_series(1,2)i;
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
sum | sum
-----+-----
3 | 3
(1 row)
SELECT COUNT(*) FROM dml_heap_check_r;
count
-------
2
(1 row)
INSERT INTO dml_heap_check_r VALUES(DEFAULT,DEFAULT,'rn',0);
ERROR: new row for relation "dml_heap_check_r" violates check constraint "rcheck_b" (seg2 127.0.0.1:40002 pid=24286)
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
sum | sum
-----+-----
3 | 3
(1 row)
SELECT COUNT(*) FROM dml_heap_check_r;
count
-------
2
(1 row)
INSERT INTO dml_heap_check_r VALUES(110,NULL,'rn',0);
ERROR: new row for relation "dml_heap_check_r" violates check constraint "rcheck_b" (seg1 127.0.0.1:40001 pid=24284)
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
sum | sum
-----+-----
3 | 3
(1 row)
SELECT COUNT(*) FROM dml_heap_check_r;
count
-------
2
(1 row)
SELECT SUM(a) FROM dml_heap_check_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_heap_check_r DISTRIBUTED BY (a);
UPDATE dml_heap_check_r set a = 110;
ERROR: Cannot parallelize an UPDATE statement that updates the distribution columns
SELECT SUM(a) FROM dml_heap_check_r;
sum
-----
3
(1 row)
-- THIS SQL CONFIRMS THAT POST UPDATE THE OID OF THE TUPLE REMAINS THE SAME
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_check_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_check_r WHERE tempoid.oid = dml_heap_check_r.oid AND tempoid.gp_segment_id = dml_heap_check_r.gp_segment_id))foo;
count
-------
2
(1 row)
DROP TABLE IF EXISTS dml_heap_r;
NOTICE: table "dml_heap_r" does not exist, skipping
CREATE TABLE dml_heap_r (a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
INSERT INTO dml_heap_r VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
count
-------
3
(1 row)
--
-- DELETE on table with OIDS
--
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_heap_r DISTRIBUTED BY (a);
DELETE FROM dml_heap_r WHERE a is NULL;
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.gp_segment_id = dml_heap_r.gp_segment_id AND tempoid.a is NOT NULL))foo;
count
-------
2
(1 row)
DROP TABLE IF EXISTS dml_heap_r;
CREATE TABLE dml_heap_r (col1 serial, a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
NOTICE: CREATE TABLE will create implicit sequence "dml_heap_r_col1_seq" for serial column "dml_heap_r.col1"
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
INSERT INTO dml_heap_r(a,b,c) VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r(a,b,c) VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
count
-------
3
(1 row)
--
-- UPDATE to constant value on table with OIDS
--
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,col1,a FROM dml_heap_r ORDER BY 1;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
UPDATE dml_heap_r SET a = 1;
ERROR: Cannot parallelize an UPDATE statement that updates the distribution columns
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1))foo;
count
-------
3
(1 row)
DROP TABLE IF EXISTS dml_heap_r;
DROP TABLE IF EXISTS dml_heap_p;
NOTICE: table "dml_heap_p" does not exist, skipping
CREATE TABLE dml_heap_r (a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
CREATE TABLE dml_heap_p (col1 serial, a numeric, b decimal) WITH OIDS DISTRIBUTED BY (a,b);
NOTICE: CREATE TABLE will create implicit sequence "dml_heap_p_col1_seq" for serial column "dml_heap_p.col1"
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
INSERT INTO dml_heap_p(a,b) SELECT id as a, id as b FROM (SELECT * FROM generate_series(1,2) as id) AS x;
INSERT INTO dml_heap_p(a,b) VALUES(NULL,NULL);
INSERT INTO dml_heap_r VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
count
-------
3
(1 row)
SELECT COUNT(*) FROM dml_heap_p;
count
-------
3
(1 row)
--
-- UPDATE with SELECT on table with OIDS
--
SELECT SUM(a), SUM(b) FROM dml_heap_p;
sum | sum
-----+-----
3 | 3
(1 row)
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,col1,a,b FROM dml_heap_p ORDER BY 1;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a, b' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
UPDATE dml_heap_p SET a = (SELECT a FROM dml_heap_r ORDER BY 1 LIMIT 1), b = ((SELECT b FROM dml_heap_r ORDER BY 1 LIMIT 1));
ERROR: Cannot parallelize an UPDATE statement that updates the distribution columns
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_p) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_p WHERE tempoid.oid = dml_heap_p.oid AND tempoid.col1 = dml_heap_p.col1))foo;
count
-------
3
(1 row)
SELECT SUM(a), SUM(b) FROM dml_heap_p;
sum | sum
-----+-----
3 | 3
(1 row)
DROP TABLE IF EXISTS dml_heap_r;
DROP TABLE IF EXISTS dml_heap_p;
CREATE TABLE dml_heap_r (col1 serial,a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
NOTICE: CREATE TABLE will create implicit sequence "dml_heap_r_col1_seq" for serial column "dml_heap_r.col1"
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
CREATE TABLE dml_heap_p (col1 serial, a numeric, b decimal) WITH OIDS DISTRIBUTED BY (a,b);
NOTICE: CREATE TABLE will create implicit sequence "dml_heap_p_col1_seq" for serial column "dml_heap_p.col1"
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
INSERT INTO dml_heap_p(a,b) SELECT id as a, id as b FROM (SELECT * FROM generate_series(1,2) as id) AS x;
INSERT INTO dml_heap_p(a,b) VALUES(NULL,NULL);
INSERT INTO dml_heap_r(a,b,c) VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r(a,b,c) VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
count
-------
3
(1 row)
SELECT COUNT(*) FROM dml_heap_p;
count
-------
3
(1 row)
--
-- UPDATE with joins on table with OIDS
--
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,col1,a FROM dml_heap_r ORDER BY 1;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT SUM(dml_heap_r.a) FROM dml_heap_p, dml_heap_r WHERE dml_heap_r.b = dml_heap_p.a;
sum
-----
3
(1 row)
-- FIXME: This currently trips an assertion, see
-- https://github.com/greenplum-db/gpdb/issues/3611
-- Re-enable once that's fixed!
--UPDATE dml_heap_r SET a = dml_heap_r.a FROM dml_heap_p WHERE dml_heap_r.b = dml_heap_p.a;
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1))foo;
count
-------
3
(1 row)
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
create schema qp_dml_oids;
set search_path='qp_dml_oids';
DROP TABLE IF EXISTS dml_ao;
CREATE TABLE dml_ao (a int , b int default -1, c text) WITH (appendonly = true, oids = true) DISTRIBUTED BY (a);
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
INSERT INTO dml_ao VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_ao VALUES(NULL,NULL,NULL);
--
-- DDL on AO/CO tables with OIDS(Negative Test)
--
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_ao ORDER BY 1;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
UPDATE dml_ao SET a = 100;
SELECT * FROM ( (SELECT COUNT(*) FROM dml_ao) UNION (SELECT COUNT(*) FROM tempoid, dml_ao WHERE tempoid.oid = dml_ao.oid AND tempoid.gp_segment_id = dml_ao.gp_segment_id))foo;
count
-------
0
3
(2 rows)
DROP TABLE IF EXISTS dml_heap_check_r;
CREATE TABLE dml_heap_check_r (
a int default 100 CHECK( a between 1 and 105),
b float8 CONSTRAINT rcheck_b CHECK( b <> 0.00 and b IS NOT NULL),
c text,
d numeric NOT NULL)
WITH OIDS DISTRIBUTED BY (a);
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
--
-- DML on table with constraints and OIDS(Negative Test)
--
INSERT INTO dml_heap_check_r SELECT i, i ,'r', i FROM generate_series(1,2)i;
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
sum | sum
-----+-----
3 | 3
(1 row)
SELECT COUNT(*) FROM dml_heap_check_r;
count
-------
2
(1 row)
INSERT INTO dml_heap_check_r VALUES(DEFAULT,DEFAULT,'rn',0);
ERROR: new row for relation "dml_heap_check_r" violates check constraint "rcheck_b"
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
sum | sum
-----+-----
3 | 3
(1 row)
SELECT COUNT(*) FROM dml_heap_check_r;
count
-------
2
(1 row)
INSERT INTO dml_heap_check_r VALUES(110,NULL,'rn',0);
ERROR: new row for relation "dml_heap_check_r" violates check constraint "rcheck_b"
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
sum | sum
-----+-----
3 | 3
(1 row)
SELECT COUNT(*) FROM dml_heap_check_r;
count
-------
2
(1 row)
SELECT SUM(a) FROM dml_heap_check_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_heap_check_r DISTRIBUTED BY (a);
UPDATE dml_heap_check_r set a = 110;
ERROR: new row for relation "dml_heap_check_r" violates check constraint "dml_heap_check_r_a_check"
SELECT SUM(a) FROM dml_heap_check_r;
sum
-----
3
(1 row)
-- THIS SQL CONFIRMS THAT POST UPDATE THE OID OF THE TUPLE REMAINS THE SAME
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_check_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_check_r WHERE tempoid.oid = dml_heap_check_r.oid AND tempoid.gp_segment_id = dml_heap_check_r.gp_segment_id))foo;
count
-------
2
(1 row)
DROP TABLE IF EXISTS dml_heap_r;
CREATE TABLE dml_heap_r (a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
INSERT INTO dml_heap_r VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
count
-------
3
(1 row)
--
-- DELETE on table with OIDS
--
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_heap_r DISTRIBUTED BY (a);
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
DELETE FROM dml_heap_r WHERE a is NULL;
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.gp_segment_id = dml_heap_r.gp_segment_id AND tempoid.a is NOT NULL))foo;
count
-------
2
(1 row)
DROP TABLE IF EXISTS dml_heap_r;
CREATE TABLE dml_heap_r (col1 serial, a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
NOTICE: CREATE TABLE will create implicit sequence "dml_heap_r_col1_seq" for serial column "dml_heap_r.col1"
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
INSERT INTO dml_heap_r(a,b,c) VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r(a,b,c) VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
count
-------
3
(1 row)
--
-- UPDATE to constant value on table with OIDS
--
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
NOTICE: table "tempoid" does not exist, skipping
CREATE TABLE tempoid as SELECT oid,col1,a FROM dml_heap_r ORDER BY 1;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
UPDATE dml_heap_r SET a = 1;
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1))foo;
count
-------
3
(1 row)
DROP TABLE IF EXISTS dml_heap_r;
DROP TABLE IF EXISTS dml_heap_p;
CREATE TABLE dml_heap_r (a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
CREATE TABLE dml_heap_p (col1 serial, a numeric, b decimal) WITH OIDS DISTRIBUTED BY (a,b);
NOTICE: CREATE TABLE will create implicit sequence "dml_heap_p_col1_seq" for serial column "dml_heap_p.col1"
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
INSERT INTO dml_heap_p(a,b) SELECT id as a, id as b FROM (SELECT * FROM generate_series(1,2) as id) AS x;
INSERT INTO dml_heap_p(a,b) VALUES(NULL,NULL);
INSERT INTO dml_heap_r VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
count
-------
3
(1 row)
SELECT COUNT(*) FROM dml_heap_p;
count
-------
3
(1 row)
--
-- UPDATE with SELECT on table with OIDS
--
SELECT SUM(a), SUM(b) FROM dml_heap_p;
sum | sum
-----+-----
3 | 3
(1 row)
DROP TABLE IF EXISTS tempoid;
NOTICE: table "tempoid" does not exist, skipping
CREATE TABLE tempoid as SELECT oid,col1,a,b FROM dml_heap_p ORDER BY 1;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a, b' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
UPDATE dml_heap_p SET a = (SELECT a FROM dml_heap_r ORDER BY 1 LIMIT 1), b = ((SELECT b FROM dml_heap_r ORDER BY 1 LIMIT 1));
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_p) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_p WHERE tempoid.oid = dml_heap_p.oid AND tempoid.col1 = dml_heap_p.col1))foo;
count
-------
3
(1 row)
SELECT SUM(a), SUM(b) FROM dml_heap_p;
sum | sum
-----+-----
3 | 3
(1 row)
DROP TABLE IF EXISTS dml_heap_r;
DROP TABLE IF EXISTS dml_heap_p;
CREATE TABLE dml_heap_r (col1 serial,a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
NOTICE: CREATE TABLE will create implicit sequence "dml_heap_r_col1_seq" for serial column "dml_heap_r.col1"
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
CREATE TABLE dml_heap_p (col1 serial, a numeric, b decimal) WITH OIDS DISTRIBUTED BY (a,b);
NOTICE: CREATE TABLE will create implicit sequence "dml_heap_p_col1_seq" for serial column "dml_heap_p.col1"
NOTICE: OIDS=TRUE is not recommended for user-created tables. Use OIDS=FALSE to prevent wrap-around of the OID counter
INSERT INTO dml_heap_p(a,b) SELECT id as a, id as b FROM (SELECT * FROM generate_series(1,2) as id) AS x;
INSERT INTO dml_heap_p(a,b) VALUES(NULL,NULL);
INSERT INTO dml_heap_r(a,b,c) VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r(a,b,c) VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
count
-------
3
(1 row)
SELECT COUNT(*) FROM dml_heap_p;
count
-------
3
(1 row)
--
-- UPDATE with joins on table with OIDS
--
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
NOTICE: table "tempoid" does not exist, skipping
CREATE TABLE tempoid as SELECT oid,col1,a FROM dml_heap_r ORDER BY 1;
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT SUM(dml_heap_r.a) FROM dml_heap_p, dml_heap_r WHERE dml_heap_r.b = dml_heap_p.a;
sum
-----
3
(1 row)
-- FIXME: This currently trips an assertion, see
-- https://github.com/greenplum-db/gpdb/issues/3611
-- Re-enable once that's fixed!
--UPDATE dml_heap_r SET a = dml_heap_r.a FROM dml_heap_p WHERE dml_heap_r.b = dml_heap_p.a;
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1))foo;
count
-------
3
(1 row)
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
......@@ -112,7 +112,7 @@ test: tuple_serialization
# temp tables
test: bfv_cte bfv_joins bfv_subquery bfv_planner bfv_legacy bfv_temp bfv_dml
test: qp_olap_mdqa qp_misc gp_recursive_cte qp_dml_joins
test: qp_olap_mdqa qp_misc gp_recursive_cte qp_dml_joins qp_dml_oids
test: qp_misc_jiras qp_with_clause qp_executor qp_olap_windowerr qp_olap_window qp_derived_table qp_bitmapscan session_level_memory_consumption qp_dropped_cols
test: qp_with_functional_inlining qp_with_functional_noinlining
......
create schema qp_dml_oids;
set search_path='qp_dml_oids';
DROP TABLE IF EXISTS dml_ao;
CREATE TABLE dml_ao (a int , b int default -1, c text) WITH (appendonly = true, oids = true) DISTRIBUTED BY (a);
INSERT INTO dml_ao VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_ao VALUES(NULL,NULL,NULL);
--
-- DDL on AO/CO tables with OIDS(Negative Test)
--
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_ao ORDER BY 1;
UPDATE dml_ao SET a = 100;
SELECT * FROM ( (SELECT COUNT(*) FROM dml_ao) UNION (SELECT COUNT(*) FROM tempoid, dml_ao WHERE tempoid.oid = dml_ao.oid AND tempoid.gp_segment_id = dml_ao.gp_segment_id))foo;
DROP TABLE IF EXISTS dml_heap_check_r;
CREATE TABLE dml_heap_check_r (
a int default 100 CHECK( a between 1 and 105),
b float8 CONSTRAINT rcheck_b CHECK( b <> 0.00 and b IS NOT NULL),
c text,
d numeric NOT NULL)
WITH OIDS DISTRIBUTED BY (a);
--
-- DML on table with constraints and OIDS(Negative Test)
--
INSERT INTO dml_heap_check_r SELECT i, i ,'r', i FROM generate_series(1,2)i;
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
SELECT COUNT(*) FROM dml_heap_check_r;
INSERT INTO dml_heap_check_r VALUES(DEFAULT,DEFAULT,'rn',0);
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
SELECT COUNT(*) FROM dml_heap_check_r;
INSERT INTO dml_heap_check_r VALUES(110,NULL,'rn',0);
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
SELECT COUNT(*) FROM dml_heap_check_r;
SELECT SUM(a) FROM dml_heap_check_r;
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_heap_check_r DISTRIBUTED BY (a);
UPDATE dml_heap_check_r set a = 110;
SELECT SUM(a) FROM dml_heap_check_r;
-- THIS SQL CONFIRMS THAT POST UPDATE THE OID OF THE TUPLE REMAINS THE SAME
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_check_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_check_r WHERE tempoid.oid = dml_heap_check_r.oid AND tempoid.gp_segment_id = dml_heap_check_r.gp_segment_id))foo;
DROP TABLE IF EXISTS dml_heap_r;
CREATE TABLE dml_heap_r (a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
INSERT INTO dml_heap_r VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
--
-- DELETE on table with OIDS
--
SELECT SUM(a) FROM dml_heap_r;
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_heap_r DISTRIBUTED BY (a);
DELETE FROM dml_heap_r WHERE a is NULL;
SELECT SUM(a) FROM dml_heap_r;
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.gp_segment_id = dml_heap_r.gp_segment_id AND tempoid.a is NOT NULL))foo;
DROP TABLE IF EXISTS dml_heap_r;
CREATE TABLE dml_heap_r (col1 serial, a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
INSERT INTO dml_heap_r(a,b,c) VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r(a,b,c) VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
--
-- UPDATE to constant value on table with OIDS
--
SELECT SUM(a) FROM dml_heap_r;
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,col1,a FROM dml_heap_r ORDER BY 1;
UPDATE dml_heap_r SET a = 1;
SELECT SUM(a) FROM dml_heap_r;
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1))foo;
DROP TABLE IF EXISTS dml_heap_r;
DROP TABLE IF EXISTS dml_heap_p;
CREATE TABLE dml_heap_r (a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
CREATE TABLE dml_heap_p (col1 serial, a numeric, b decimal) WITH OIDS DISTRIBUTED BY (a,b);
INSERT INTO dml_heap_p(a,b) SELECT id as a, id as b FROM (SELECT * FROM generate_series(1,2) as id) AS x;
INSERT INTO dml_heap_p(a,b) VALUES(NULL,NULL);
INSERT INTO dml_heap_r VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
SELECT COUNT(*) FROM dml_heap_p;
--
-- UPDATE with SELECT on table with OIDS
--
SELECT SUM(a), SUM(b) FROM dml_heap_p;
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,col1,a,b FROM dml_heap_p ORDER BY 1;
UPDATE dml_heap_p SET a = (SELECT a FROM dml_heap_r ORDER BY 1 LIMIT 1), b = ((SELECT b FROM dml_heap_r ORDER BY 1 LIMIT 1));
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_p) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_p WHERE tempoid.oid = dml_heap_p.oid AND tempoid.col1 = dml_heap_p.col1))foo;
SELECT SUM(a), SUM(b) FROM dml_heap_p;
DROP TABLE IF EXISTS dml_heap_r;
DROP TABLE IF EXISTS dml_heap_p;
CREATE TABLE dml_heap_r (col1 serial,a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
CREATE TABLE dml_heap_p (col1 serial, a numeric, b decimal) WITH OIDS DISTRIBUTED BY (a,b);
INSERT INTO dml_heap_p(a,b) SELECT id as a, id as b FROM (SELECT * FROM generate_series(1,2) as id) AS x;
INSERT INTO dml_heap_p(a,b) VALUES(NULL,NULL);
INSERT INTO dml_heap_r(a,b,c) VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r(a,b,c) VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
SELECT COUNT(*) FROM dml_heap_p;
--
-- UPDATE with joins on table with OIDS
--
SELECT SUM(a) FROM dml_heap_r;
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,col1,a FROM dml_heap_r ORDER BY 1;
SELECT SUM(dml_heap_r.a) FROM dml_heap_p, dml_heap_r WHERE dml_heap_r.b = dml_heap_p.a;
-- FIXME: This currently trips an assertion, see
-- https://github.com/greenplum-db/gpdb/issues/3611
-- Re-enable once that's fixed!
--UPDATE dml_heap_r SET a = dml_heap_r.a FROM dml_heap_p WHERE dml_heap_r.b = dml_heap_p.a;
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1))foo;
SELECT SUM(a) FROM dml_heap_r;
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description DDL on AO/CO tables with OIDS(Negative Test)
DROP TABLE IF EXISTS tempoid;
DROP TABLE
CREATE TABLE tempoid as SELECT oid,a FROM dml_ao ORDER BY 1;
psql:../sql/dml_oids_ao.sql:8: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 3
UPDATE dml_ao SET a = 100;
UPDATE 3
SELECT * FROM ( (SELECT COUNT(*) FROM dml_ao) UNION (SELECT COUNT(*) FROM tempoid, dml_ao WHERE tempoid.oid = dml_ao.oid AND tempoid.gp_segment_id = dml_ao.gp_segment_id))foo;
count
-------
0
3
(2 rows)
-- start_ignore
SET optimizer=on;
SET
SET optimizer_log=on;
SET
-- end_ignore
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description DML on table with constraints and OIDS(Negative Test)
\echo --start_ignore
--start_ignore
set gp_enable_column_oriented_table=on;
psql:dml_oids_constraint_orca.sql:14: ERROR: unrecognized configuration parameter "gp_enable_column_oriented_table"
\echo --end_ignore
--end_ignore
INSERT INTO dml_heap_check_r SELECT i, i ,'r', i FROM generate_series(1,2)i;
INSERT 0 2
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
sum | sum
-----+-----
3 | 3
(1 row)
SELECT COUNT(*) FROM dml_heap_check_r;
count
-------
2
(1 row)
INSERT INTO dml_heap_check_r VALUES(DEFAULT,DEFAULT,'rn',0);
psql:dml_oids_constraint_orca.sql:20: ERROR: One or more assertions failed (seg1 antova-mbp.local:40011 pid=32564)
DETAIL: Check constraint rcheck_b for table dml_heap_check_r was violated
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
sum | sum
-----+-----
3 | 3
(1 row)
SELECT COUNT(*) FROM dml_heap_check_r;
count
-------
2
(1 row)
INSERT INTO dml_heap_check_r VALUES(110,NULL,'rn',0);
psql:dml_oids_constraint_orca.sql:24: ERROR: One or more assertions failed (seg1 antova-mbp.local:40011 pid=32564)
DETAIL:
Check constraint rcheck_b for table dml_heap_check_r was violated
Check constraint dml_heap_check_r_a_check for table dml_heap_check_r was violated
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
sum | sum
-----+-----
3 | 3
(1 row)
SELECT COUNT(*) FROM dml_heap_check_r;
count
-------
2
(1 row)
SELECT SUM(a) FROM dml_heap_check_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
DROP TABLE
CREATE TABLE tempoid as SELECT oid,a FROM dml_heap_check_r DISTRIBUTED BY (a);
SELECT 2
UPDATE dml_heap_check_r set a = 110;
psql:dml_oids_constraint_orca.sql:32: ERROR: One or more assertions failed (seg1 slice1 antova-mbp.local:40011 pid=32567)
DETAIL: Check constraint dml_heap_check_r_a_check for table dml_heap_check_r was violated
SELECT SUM(a) FROM dml_heap_check_r;
sum
-----
3
(1 row)
-- THIS SQL CONFIRMS THAT POST UPDATE THE OID OF THE TUPLE REMAINS THE SAME
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_check_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_check_r WHERE tempoid.oid = dml_heap_check_r.oid AND tempoid.gp_segment_id = dml_heap_check_r.gp_segment_id))foo;
count
-------
2
(1 row)
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description DELETE on table with OIDS
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
DROP TABLE
CREATE TABLE tempoid as SELECT oid,a FROM dml_heap_r DISTRIBUTED BY (a);
psql:dml_oids_delete.sql:10: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 3
DELETE FROM dml_heap_r WHERE a is NULL;
DELETE 1
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.gp_segment_id = dml_heap_r.gp_segment_id AND tempoid.a is NOT NULL))foo;
count
-------
2
(1 row)
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description UPDATE to constant value on table with OIDS
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
psql:sql/dml_oids_update_1.sql:10: NOTICE: table "tempoid" does not exist, skipping
DROP TABLE
CREATE TABLE tempoid as SELECT oid,col1,a FROM dml_heap_r ORDER BY 1;
psql:dml_oids_update_1.sql:11: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 3
UPDATE dml_heap_r SET a = 1;
UPDATE 3
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1))foo;
count
-------
3
(1 row)
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description UPDATE with SELECT on table with OIDS
SELECT SUM(a), SUM(b) FROM dml_heap_p;
sum | sum
-----+-----
3 | 3
(1 row)
DROP TABLE IF EXISTS tempoid;
psql:sql/dml_oids_update_2.sql:10: NOTICE: table "tempoid" does not exist, skipping
DROP TABLE
CREATE TABLE tempoid as SELECT oid,col1,a,b FROM dml_heap_p ORDER BY 1;
psql:dml_oids_update_2.sql:11: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a, b' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 3
UPDATE dml_heap_p SET a = (SELECT a FROM dml_heap_r ORDER BY 1 LIMIT 1), b = ((SELECT b FROM dml_heap_r ORDER BY 1 LIMIT 1));
UPDATE 3
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_p) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_p WHERE tempoid.oid = dml_heap_p.oid AND tempoid.col1 = dml_heap_p.col1))foo;
count
-------
3
(1 row)
SELECT SUM(a), SUM(b) FROM dml_heap_p;
sum | sum
-----+-----
3 | 3
(1 row)
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description UPDATE with joins on table with OIDS
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
DROP TABLE IF EXISTS tempoid;
psql:sql/dml_oids_update_3.sql:10: NOTICE: table "tempoid" does not exist, skipping
DROP TABLE
CREATE TABLE tempoid as SELECT oid,col1,a FROM dml_heap_r ORDER BY 1;
psql:dml_oids_update_3.sql:11: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 3
SELECT SUM(dml_heap_r.a) FROM dml_heap_p, dml_heap_r WHERE dml_heap_r.b = dml_heap_p.a;
sum
-----
3
(1 row)
UPDATE dml_heap_r SET a = dml_heap_r.a FROM dml_heap_p WHERE dml_heap_r.b = dml_heap_p.a;
UPDATE 2
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1))foo;
count
-------
3
(1 row)
SELECT SUM(a) FROM dml_heap_r;
sum
-----
3
(1 row)
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description DDL on AO/CO tables with OIDS(Negative Test)
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_ao ORDER BY 1;
UPDATE dml_ao SET a = 100;
SELECT * FROM ( (SELECT COUNT(*) FROM dml_ao) UNION (SELECT COUNT(*) FROM tempoid, dml_ao WHERE tempoid.oid = dml_ao.oid AND tempoid.gp_segment_id = dml_ao.gp_segment_id))foo;
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
DROP TABLE IF EXISTS dml_ao;
CREATE TABLE dml_ao (a int , b int default -1, c text) WITH (appendonly = true, oids = true) DISTRIBUTED BY (a);
INSERT INTO dml_ao VALUES(generate_series(1,2),generate_series(1,2),'r');
SELECT SUM(a),SUM(b) FROM dml_ao;
SELECT COUNT(*) FROM dml_ao;
INSERT INTO dml_ao VALUES(NULL,NULL,NULL);
SELECT SUM(a),SUM(b) FROM dml_ao;
SELECT COUNT(*) FROM dml_ao;
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @gpopt 1.532
-- @description DML on table with constraints and OIDS(Negative Test)
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
INSERT INTO dml_heap_check_r SELECT i, i ,'r', i FROM generate_series(1,2)i;
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
SELECT COUNT(*) FROM dml_heap_check_r;
INSERT INTO dml_heap_check_r VALUES(DEFAULT,DEFAULT,'rn',0);
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
SELECT COUNT(*) FROM dml_heap_check_r;
INSERT INTO dml_heap_check_r VALUES(110,NULL,'rn',0);
SELECT SUM(a),SUM(b) FROM dml_heap_check_r;
SELECT COUNT(*) FROM dml_heap_check_r;
SELECT SUM(a) FROM dml_heap_check_r;
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_heap_check_r DISTRIBUTED BY (a);
UPDATE dml_heap_check_r set a = 110;
SELECT SUM(a) FROM dml_heap_check_r;
-- THIS SQL CONFIRMS THAT POST UPDATE THE OID OF THE TUPLE REMAINS THE SAME
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_check_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_check_r WHERE tempoid.oid = dml_heap_check_r.oid AND tempoid.gp_segment_id = dml_heap_check_r.gp_segment_id))foo;
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
DROP TABLE IF EXISTS dml_heap_check_r;
CREATE TABLE dml_heap_check_r (
a int default 100 CHECK( a between 1 and 105),
b float8 CONSTRAINT rcheck_b CHECK( b <> 0.00 and b IS NOT NULL),
c text,
d numeric NOT NULL)
WITH OIDS DISTRIBUTED BY (a);
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description DELETE on table with OIDS
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
SELECT SUM(a) FROM dml_heap_r;
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,a FROM dml_heap_r DISTRIBUTED BY (a);
DELETE FROM dml_heap_r WHERE a is NULL;
SELECT SUM(a) FROM dml_heap_r;
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.gp_segment_id = dml_heap_r.gp_segment_id AND tempoid.a is NOT NULL))foo;
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
DROP TABLE IF EXISTS dml_heap_r;
CREATE TABLE dml_heap_r (a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
INSERT INTO dml_heap_r VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description UPDATE to constant value on table with OIDS
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
SELECT SUM(a) FROM dml_heap_r;
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,col1,a FROM dml_heap_r ORDER BY 1;
UPDATE dml_heap_r SET a = 1;
SELECT SUM(a) FROM dml_heap_r;
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1))foo;
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
DROP TABLE IF EXISTS dml_heap_r;
CREATE TABLE dml_heap_r (col1 serial, a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
INSERT INTO dml_heap_r(a,b,c) VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r(a,b,c) VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description UPDATE with SELECT on table with OIDS
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
SELECT SUM(a), SUM(b) FROM dml_heap_p;
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,col1,a,b FROM dml_heap_p ORDER BY 1;
UPDATE dml_heap_p SET a = (SELECT a FROM dml_heap_r ORDER BY 1 LIMIT 1), b = ((SELECT b FROM dml_heap_r ORDER BY 1 LIMIT 1));
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_p) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_p WHERE tempoid.oid = dml_heap_p.oid AND tempoid.col1 = dml_heap_p.col1))foo;
SELECT SUM(a), SUM(b) FROM dml_heap_p;
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
DROP TABLE IF EXISTS dml_heap_r;
DROP TABLE IF EXISTS dml_heap_p;
CREATE TABLE dml_heap_r (a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
CREATE TABLE dml_heap_p (col1 serial, a numeric, b decimal) WITH OIDS DISTRIBUTED BY (a,b);
INSERT INTO dml_heap_p(a,b) SELECT id as a, id as b FROM (SELECT * FROM generate_series(1,2) as id) AS x;
INSERT INTO dml_heap_p(a,b) VALUES(NULL,NULL);
INSERT INTO dml_heap_r VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
SELECT COUNT(*) FROM dml_heap_p;
-- @author prabhd
-- @created 2013-07-08 12:00:00
-- @modified 2013-07-08 12:00:00
-- @tags dml
-- @db_name dmldb
-- @description UPDATE with joins on table with OIDS
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
SELECT SUM(a) FROM dml_heap_r;
DROP TABLE IF EXISTS tempoid;
CREATE TABLE tempoid as SELECT oid,col1,a FROM dml_heap_r ORDER BY 1;
SELECT SUM(dml_heap_r.a) FROM dml_heap_p, dml_heap_r WHERE dml_heap_r.b = dml_heap_p.a;
UPDATE dml_heap_r SET a = dml_heap_r.a FROM dml_heap_p WHERE dml_heap_r.b = dml_heap_p.a;
-- The query checks that the tuple oids remain the remain pre and post update .
-- SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1 is a join on the tuple oids before update and after update. If the oids remain the same the below query should return 1 row which is equivalent to the number of rows in the table
SELECT * FROM ( (SELECT COUNT(*) FROM dml_heap_r) UNION (SELECT COUNT(*) FROM tempoid, dml_heap_r WHERE tempoid.oid = dml_heap_r.oid AND tempoid.col1 = dml_heap_r.col1))foo;
SELECT SUM(a) FROM dml_heap_r;
\echo --start_ignore
set gp_enable_column_oriented_table=on;
\echo --end_ignore
DROP TABLE IF EXISTS dml_heap_r;
DROP TABLE IF EXISTS dml_heap_p;
CREATE TABLE dml_heap_r (col1 serial,a int , b int default -1, c text) WITH OIDS DISTRIBUTED BY (a);
CREATE TABLE dml_heap_p (col1 serial, a numeric, b decimal) WITH OIDS DISTRIBUTED BY (a,b);
INSERT INTO dml_heap_p(a,b) SELECT id as a, id as b FROM (SELECT * FROM generate_series(1,2) as id) AS x;
INSERT INTO dml_heap_p(a,b) VALUES(NULL,NULL);
INSERT INTO dml_heap_r(a,b,c) VALUES(generate_series(1,2),generate_series(1,2),'r');
INSERT INTO dml_heap_r(a,b,c) VALUES(NULL,NULL,NULL);
SELECT COUNT(*) FROM dml_heap_r;
SELECT COUNT(*) FROM dml_heap_p;
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册