diff options
author | Pallavi Sontakke | 2015-08-18 07:58:05 +0000 |
---|---|---|
committer | Pallavi Sontakke | 2015-08-18 07:58:05 +0000 |
commit | 93c74cc3817b780238cbc46380cd726fd6ba51c2 (patch) | |
tree | 068292ad625e4f4fea9ba47c7d4f8f2c1990b76f | |
parent | d0ccee9a81e83af2612c37e3928f9e776302a0db (diff) |
Initial commit of tests for Major differences between XL and postgresql (Limitations)
-rwxr-xr-x[-rw-r--r--] | contrib/citext/Makefile | 2 | ||||
-rw-r--r-- | contrib/citext/expected/xl_citext.out | 13 | ||||
-rw-r--r-- | contrib/citext/sql/xl_citext.sql | 14 | ||||
-rwxr-xr-x[-rw-r--r--] | contrib/ltree/Makefile | 2 | ||||
-rw-r--r-- | contrib/ltree/expected/xl_ltree.out | 10 | ||||
-rw-r--r-- | contrib/ltree/sql/xl_ltree.sql | 10 | ||||
-rw-r--r-- | src/test/regress/expected/xl_alter_table.out | 113 | ||||
-rw-r--r-- | src/test/regress/expected/xl_distribution_column_types.out | 222 | ||||
-rw-r--r-- | src/test/regress/expected/xl_foreign_key.out | 109 | ||||
-rw-r--r-- | src/test/regress/expected/xl_primary_key.out | 30 | ||||
-rw-r--r-- | src/test/regress/serial_schedule | 4 | ||||
-rw-r--r-- | src/test/regress/sql/xl_alter_table.sql | 184 | ||||
-rw-r--r-- | src/test/regress/sql/xl_distribution_column_types.sql | 257 | ||||
-rw-r--r-- | src/test/regress/sql/xl_foreign_key.sql | 115 | ||||
-rw-r--r-- | src/test/regress/sql/xl_primary_key.sql | 35 |
15 files changed, 1118 insertions, 2 deletions
diff --git a/contrib/citext/Makefile b/contrib/citext/Makefile index 61e04bce7a..7222731f3a 100644..100755 --- a/contrib/citext/Makefile +++ b/contrib/citext/Makefile @@ -6,7 +6,7 @@ EXTENSION = citext DATA = citext--1.1.sql citext--1.0--1.1.sql citext--unpackaged--1.0.sql PGFILEDESC = "citext - case-insensitive character string data type" -REGRESS = citext +REGRESS = citext xl_citext ifdef USE_PGXS PG_CONFIG = pg_config diff --git a/contrib/citext/expected/xl_citext.out b/contrib/citext/expected/xl_citext.out new file mode 100644 index 0000000000..5da4257924 --- /dev/null +++ b/contrib/citext/expected/xl_citext.out @@ -0,0 +1,13 @@ +-- +-- Test citext datatype +-- +--Column of types “citext”, “ltree” cannot be used as distribution column +-- citext - case insensitive text +CREATE TABLE xl_dc26 ( + product_no integer, + product_id citext PRIMARY KEY, + name MONEY, + purchase_date TIMETZ, + price numeric +) DISTRIBUTE BY HASH (product_id); --fail +ERROR: Column product_id is not a hash distributable data type diff --git a/contrib/citext/sql/xl_citext.sql b/contrib/citext/sql/xl_citext.sql new file mode 100644 index 0000000000..0cd48314f3 --- /dev/null +++ b/contrib/citext/sql/xl_citext.sql @@ -0,0 +1,14 @@ +-- +-- Test citext datatype +-- + +--Column of types “citext”, “ltree” cannot be used as distribution column +-- citext - case insensitive text +CREATE TABLE xl_dc26 ( + product_no integer, + product_id citext PRIMARY KEY, + name MONEY, + purchase_date TIMETZ, + price numeric +) DISTRIBUTE BY HASH (product_id); --fail + diff --git a/contrib/ltree/Makefile b/contrib/ltree/Makefile index a41e45723d..342e75ee48 100644..100755 --- a/contrib/ltree/Makefile +++ b/contrib/ltree/Makefile @@ -9,7 +9,7 @@ EXTENSION = ltree DATA = ltree--1.0.sql ltree--unpackaged--1.0.sql PGFILEDESC = "ltree - hierarchical label data type" -REGRESS = ltree +REGRESS = ltree xl_ltree ifdef USE_PGXS PG_CONFIG = pg_config diff --git a/contrib/ltree/expected/xl_ltree.out b/contrib/ltree/expected/xl_ltree.out new file mode 100644 index 0000000000..75441a7e41 --- /dev/null +++ b/contrib/ltree/expected/xl_ltree.out @@ -0,0 +1,10 @@ +--Column of types “citext”, “ltree” cannot be used as distribution column +--ltree - labels of data stored in a hierarchical tree-like structure +CREATE TABLE xl_dc27 ( + product_no integer, + product_id ltree PRIMARY KEY, + name MONEY, + purchase_date TIMETZ, + price numeric +) DISTRIBUTE BY HASH (product_id); --fail +ERROR: Column product_id is not a hash distributable data type diff --git a/contrib/ltree/sql/xl_ltree.sql b/contrib/ltree/sql/xl_ltree.sql new file mode 100644 index 0000000000..2fc90b3d4d --- /dev/null +++ b/contrib/ltree/sql/xl_ltree.sql @@ -0,0 +1,10 @@ + +--Column of types “citext”, “ltree” cannot be used as distribution column +--ltree - labels of data stored in a hierarchical tree-like structure +CREATE TABLE xl_dc27 ( + product_no integer, + product_id ltree PRIMARY KEY, + name MONEY, + purchase_date TIMETZ, + price numeric +) DISTRIBUTE BY HASH (product_id); --fail diff --git a/src/test/regress/expected/xl_alter_table.out b/src/test/regress/expected/xl_alter_table.out new file mode 100644 index 0000000000..c3dd967af7 --- /dev/null +++ b/src/test/regress/expected/xl_alter_table.out @@ -0,0 +1,113 @@ +--Distribution column definition can be changed, however values should be within limits of the changed data type. Distribution column cannot be dropped. This works for HASH and not for MODULO now (bug). So failing test for now. +--integer - converting to varchar, to INT8, +CREATE TABLE xl_at ( + product_no integer, + product_id integer PRIMARY KEY +) DISTRIBUTE BY HASH (product_id); +ALTER TABLE xl_at ALTER COLUMN product_id TYPE INT2; +ALTER TABLE xl_at ALTER COLUMN product_id TYPE INT4; +ALTER TABLE xl_at ALTER COLUMN product_id TYPE varchar(80); +ALTER TABLE xl_at ALTER COLUMN product_id TYPE INT8 USING product_id::bigint; +ALTER TABLE xl_at ALTER COLUMN product_no TYPE INT2; +ALTER TABLE xl_at ALTER COLUMN product_no TYPE INT4; +ALTER TABLE xl_at ALTER COLUMN product_no TYPE varchar(80); +ALTER TABLE xl_at ALTER COLUMN product_no TYPE INT8 USING product_no::bigint; +INSERT into xl_at (product_no, product_id) VALUES (9223372036854775807, 9223372036854775807); +-- Value is beyond limit for below smaller integer conversions - so these fail +ALTER TABLE xl_at ALTER COLUMN product_id TYPE integer;--fail +ERROR: integer out of range +ALTER TABLE xl_at ALTER COLUMN product_id TYPE INT2;--fail +ERROR: smallint out of range +ALTER TABLE xl_at ALTER COLUMN product_id TYPE INT4;--fail +ERROR: integer out of range +ALTER TABLE xl_at ALTER COLUMN product_no TYPE integer;--fail +ERROR: integer out of range +ALTER TABLE xl_at ALTER COLUMN product_no TYPE INT2;--fail +ERROR: smallint out of range +ALTER TABLE xl_at ALTER COLUMN product_no TYPE INT4;--fail +ERROR: integer out of range +ALTER TABLE xl_at ALTER COLUMN product_id TYPE varchar(80); +ALTER TABLE xl_at ALTER COLUMN product_no TYPE varchar(80); +--INT8 - converting to varchar, to integer, +CREATE TABLE xl_at1 ( + product_no INT8, + product_id INT8 PRIMARY KEY +) DISTRIBUTE BY HASH (product_id); +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE INT2 USING product_id::smallint; +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE INT4 USING product_id::integer; +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE varchar(80); +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE integer USING product_id::integer; +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE INT2 USING product_no::smallint; +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE INT4 USING product_no::integer; +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE varchar(80); +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE integer USING product_no::integer; +INSERT into xl_at1 (product_no, product_id) VALUES (42, 42); +-- Value is within limit for smaller integer conversions - so these pass +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE INT8; +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE INT2; +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE INT4; +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE INT8; +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE INT2; +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE INT4; +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE varchar(80); +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE varchar(80); +-- HASH Distributed table: +-- Distribution column cannot be dropped. +CREATE TABLE xl_at2h ( + product_no INT8, + product_id INT2 +) DISTRIBUTE BY HASH (product_id); +ALTER TABLE xl_at2h DROP COLUMN product_id;--fail - distribution column cannot be dropped. +ERROR: Distribution column cannot be dropped +ALTER TABLE xl_at2h DISTRIBUTE BY MODULO(product_id); +ALTER TABLE xl_at2h DISTRIBUTE BY HASH(product_id); +ALTER TABLE xl_at2h DROP COLUMN product_no; +ALTER TABLE xl_at2h ADD COLUMN product_no INT8; +ALTER TABLE xl_at2h ALTER COLUMN product_no SET NOT NULL; +ALTER TABLE xl_at2h ALTER COLUMN product_id SET NOT NULL; +ALTER TABLE xl_at2h ALTER COLUMN product_no DROP NOT NULL; +ALTER TABLE xl_at2h ALTER COLUMN product_id DROP NOT NULL; +ALTER TABLE xl_at2h ALTER COLUMN product_no SET DEFAULT 0; +ALTER TABLE xl_at2h ALTER COLUMN product_id SET DEFAULT 0; +ALTER TABLE xl_at2h ALTER COLUMN product_no DROP DEFAULT; +ALTER TABLE xl_at2h ALTER COLUMN product_id DROP DEFAULT; +ALTER TABLE xl_at2h RENAME COLUMN product_no TO product_number; +ALTER TABLE xl_at2h RENAME COLUMN product_id TO product_identifier; +ALTER TABLE xl_at2h RENAME TO xl_at3h; +ALTER TABLE xl_at3h DELETE NODE (datanode2); +ALTER TABLE xl_at3h ADD NODE (datanode2); +ALTER TABLE xl_at3h DISTRIBUTE BY REPLICATION; +-- MODULO Distributed table: +-- Distribution column cannot be dropped (BUG: It can be dropped now. Test Fails). +CREATE TABLE xl_at2m ( + product_no INT8, + product_id INT2 +) DISTRIBUTE BY MODULO (product_id); +ALTER TABLE xl_at2m DISTRIBUTE BY HASH(product_id); +ALTER TABLE xl_at2m DISTRIBUTE BY MODULO(product_id); +ALTER TABLE xl_at2m DROP COLUMN product_no; +ALTER TABLE xl_at2m ADD COLUMN product_no INT8; +ALTER TABLE xl_at2m ALTER COLUMN product_no SET NOT NULL; +ALTER TABLE xl_at2m ALTER COLUMN product_id SET NOT NULL; +ALTER TABLE xl_at2m ALTER COLUMN product_no DROP NOT NULL; +ALTER TABLE xl_at2m ALTER COLUMN product_id DROP NOT NULL; +ALTER TABLE xl_at2m ALTER COLUMN product_no SET DEFAULT 0; +ALTER TABLE xl_at2m ALTER COLUMN product_id SET DEFAULT 0; +ALTER TABLE xl_at2m ALTER COLUMN product_no DROP DEFAULT; +ALTER TABLE xl_at2m ALTER COLUMN product_id DROP DEFAULT; +ALTER TABLE xl_at2m RENAME COLUMN product_no TO product_number; +ALTER TABLE xl_at2m RENAME COLUMN product_id TO product_identifier; +ALTER TABLE xl_at2m RENAME TO xl_at3m; +ALTER TABLE xl_at3m DELETE NODE (datanode2); +ALTER TABLE xl_at3m ADD NODE (datanode2); +ALTER TABLE xl_at3m DROP COLUMN product_identifier;--fail - distribution column cannot be dropped. +ERROR: Distribution column cannot be dropped +ALTER TABLE xl_at3m DISTRIBUTE BY REPLICATION; +DROP TABLE xl_at; +DROP TABLE xl_at1; +DROP TABLE xl_at2h; +ERROR: table "xl_at2h" does not exist +DROP TABLE xl_at3h; +DROP TABLE xl_at2m; +ERROR: table "xl_at2m" does not exist +DROP TABLE xl_at3m; diff --git a/src/test/regress/expected/xl_distribution_column_types.out b/src/test/regress/expected/xl_distribution_column_types.out new file mode 100644 index 0000000000..e372c4a27b --- /dev/null +++ b/src/test/regress/expected/xl_distribution_column_types.out @@ -0,0 +1,222 @@ +--Supported types for distribution column types - INT8, INT2, OID, INT4, BOOL, INT2VECTOR, OIDVECTOR, CHAR, NAME, TEXT, BPCHAR, BYTEA, VARCHAR, NUMERIC, MONEY, ABSTIME, RELTIME, DATE, TIME, TIMESTAMP, TIMESTAMPTZ, INTERVAL, and TIMETZ +--INT8, +CREATE TABLE xl_dc ( + product_no integer, + product_id INT8 PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_id); +--INT2, +CREATE TABLE xl_dc1 ( + product_no integer, + product_id INT2 PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_id); +--OID, +CREATE TABLE xl_dc2 ( + product_no integer, + product_id OID PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_id); +--INT4, +CREATE TABLE xl_dc3 ( + product_no integer, + product_id INT4 PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_id); +--BOOL, +CREATE TABLE xl_dc4 ( + product_no integer, + is_available BOOL PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (is_available); +--INT2VECTOR, +CREATE TABLE xl_dc5 ( + product_no integer, + product_id integer, + sub_product_ids INT2VECTOR PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (sub_product_ids); +--OIDVECTOR, +CREATE TABLE xl_dc6 ( + product_no integer, + product_id integer, + sub_product_ids OIDVECTOR PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (sub_product_ids); +--CHAR, +CREATE TABLE xl_dc7 ( + product_no integer, + product_group CHAR PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_group); +--NAME, +CREATE TABLE xl_dc8 ( + product_no integer, + product_name NAME PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_name); +--TEXT, +CREATE TABLE xl_dc9 ( + product_no integer, + product_name TEXT PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_name); +--BPCHAR - blank padded char, +CREATE TABLE xl_dc10 ( + product_no integer, + product_group BPCHAR PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_group); +--BYTEA - variable length binary string, +CREATE TABLE xl_dc11 ( + product_no integer, + product_group BYTEA PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_group); +--VARCHAR, +CREATE TABLE xl_dc12 ( + product_no integer, + product_group VARCHAR PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_group); +--NUMERIC, +CREATE TABLE xl_dc15 ( + product_no integer, + product_id NUMERIC PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_id); +--MONEY - String datatype, +CREATE TABLE xl_dc16 ( + product_no integer, + product_id NUMERIC , + name MONEY PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (name); +--ABSTIME, +CREATE TABLE xl_dc17 ( + product_no integer, + product_id NUMERIC , + purchase_date ABSTIME PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); +--RELTIME, +CREATE TABLE xl_dc18 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date RELTIME PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); +--DATE, +CREATE TABLE xl_dc19 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date DATE PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); +--TIME, +CREATE TABLE xl_dc20 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date TIME PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); +--TIMESTAMP, +CREATE TABLE xl_dc21 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date TIMESTAMP PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); +--TIMESTAMPTZ, +CREATE TABLE xl_dc22 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date TIMESTAMPTZ PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); +--INTERVAL, +CREATE TABLE xl_dc23 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date INTERVAL PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); +--and TIMETZ - time along with time zone +CREATE TABLE xl_dc24 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date TIMETZ PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); +--Distribution strategy can specify on a single column +CREATE TABLE xl_dc25 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date TIMETZ, + price numeric, + primary key(product_no, product_id) +) DISTRIBUTE BY HASH (product_no, product_id); --fail +ERROR: syntax error at or near "," +LINE 8: ) DISTRIBUTE BY HASH (product_no, product_id); + ^ +-- Distribution column value cannot be updated +-- default distributed on HASH by primary key column, i.e. city +CREATE TABLE xl_dc_weather ( + city varchar(80) PRIMARY KEY, + temp_lo int, -- low temperature + temp_hi int, -- high temperature + prcp real, -- precipitation + date date +); +INSERT INTO xl_dc_weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27'); +UPDATE xl_dc_weather SET city = 'SFO' where temp_lo=46 and temp_hi=50; -- fail +ERROR: could not plan this distributed update +DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL. +DROP TABLE xl_dc; +DROP TABLE xl_dc1; +DROP TABLE xl_dc2; +DROP TABLE xl_dc3; +DROP TABLE xl_dc4; +DROP TABLE xl_dc5; +DROP TABLE xl_dc6; +DROP TABLE xl_dc7; +DROP TABLE xl_dc8; +DROP TABLE xl_dc9; +DROP TABLE xl_dc10; +DROP TABLE xl_dc11; +DROP TABLE xl_dc12; +DROP TABLE xl_dc15; +DROP TABLE xl_dc16; +DROP TABLE xl_dc17; +DROP TABLE xl_dc18; +DROP TABLE xl_dc19; +DROP TABLE xl_dc20; +DROP TABLE xl_dc21; +DROP TABLE xl_dc22; +DROP TABLE xl_dc23; +DROP TABLE xl_dc24; +DROP TABLE xl_dc25; +ERROR: table "xl_dc25" does not exist +DROP TABLE xl_dc_weather; diff --git a/src/test/regress/expected/xl_foreign_key.out b/src/test/regress/expected/xl_foreign_key.out new file mode 100644 index 0000000000..5939bbb998 --- /dev/null +++ b/src/test/regress/expected/xl_foreign_key.out @@ -0,0 +1,109 @@ +--FOREIGN KEY +--For a distributed table, the REFERENCES clause must use the distribution column (product_no here). +-- As for ROUNDROBIN, primary key and unique index are not supported, this test does not include it. +-- default distributed by HASH on product_no +CREATE TABLE xl_fk_products ( + product_no integer PRIMARY KEY, + product_id integer, + name text, + price numeric +); +CREATE TABLE xl_fk_products01 ( + product_no integer, + product_id integer PRIMARY KEY, + name text, + price numeric +); +CREATE TABLE xl_fk_products1 ( + product_no integer PRIMARY KEY, + product_id integer , + name text, + price numeric +) DISTRIBUTE BY MODULO(product_no); +CREATE TABLE xl_fk_products11 ( + product_no integer , + product_id integer PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY MODULO(product_id); +CREATE TABLE xl_fk_orders ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_no), + quantity integer +) DISTRIBUTE BY HASH(product_no); +--pass +CREATE TABLE xl_fk_orders01 ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_no), + quantity integer +) DISTRIBUTE BY MODULO(product_no); +ERROR: Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table. +--fail - as xl_fk_products has product_no distributed by HASH +CREATE TABLE xl_fk_orders02 ( + order_id integer, + product_no integer REFERENCES xl_fk_products1 (product_no), + quantity integer +) DISTRIBUTE BY MODULO(product_no); +--pass - as source is also modulo distributed +CREATE TABLE xl_fk_orders1 ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_no), + quantity integer +) DISTRIBUTE BY HASH(order_id); -- fail +ERROR: Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table. +CREATE TABLE xl_fk_orders2 ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_no), + quantity integer +) DISTRIBUTE BY MODULO(order_id); -- fail +ERROR: Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table. +--This implies that PRIMARY KEY and REFERENCES cannot use different columns +CREATE TABLE xl_fk_orders3 ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_id), + quantity integer +) DISTRIBUTE BY HASH(order_id); +ERROR: Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table. +-- fail - as references is using a different column that primary key of referred table +CREATE TABLE xl_fk_orders4 ( + order_id integer, + product_no integer REFERENCES xl_fk_products1 (product_id), + quantity integer +) DISTRIBUTE BY MODULO(order_id); +ERROR: Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table. +-- fail- as references is using a different column that primary key of referred table +--This also implies that more than one FOREIGN KEY constraints cannot be specified +CREATE TABLE xl_fk_orders5 ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_no), + product_id integer REFERENCES xl_fk_products01 (product_id), + quantity integer +) DISTRIBUTE BY HASH(product_no); +ERROR: Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table. +CREATE TABLE xl_fk_orders6 ( + order_id integer, + product_no integer REFERENCES xl_fk_products1 (product_no), + product_id integer REFERENCES xl_fk_products11 (product_id), + quantity integer +) DISTRIBUTE BY MODULO(order_id); +ERROR: Hash/Modulo distribution column does not refer to hash/modulo distribution column in referenced table. +DROP TABLE xl_fk_orders; +DROP TABLE xl_fk_orders01; +ERROR: table "xl_fk_orders01" does not exist +DROP TABLE xl_fk_orders02; +DROP TABLE xl_fk_orders1; +ERROR: table "xl_fk_orders1" does not exist +DROP TABLE xl_fk_orders2; +ERROR: table "xl_fk_orders2" does not exist +DROP TABLE xl_fk_orders3; +ERROR: table "xl_fk_orders3" does not exist +DROP TABLE xl_fk_orders4; +ERROR: table "xl_fk_orders4" does not exist +DROP TABLE xl_fk_orders5; +ERROR: table "xl_fk_orders5" does not exist +DROP TABLE xl_fk_orders6; +ERROR: table "xl_fk_orders6" does not exist +DROP TABLE xl_fk_products; +DROP TABLE xl_fk_products01; +DROP TABLE xl_fk_products1; +DROP TABLE xl_fk_products11; diff --git a/src/test/regress/expected/xl_primary_key.out b/src/test/regress/expected/xl_primary_key.out new file mode 100644 index 0000000000..5e356dc8e6 --- /dev/null +++ b/src/test/regress/expected/xl_primary_key.out @@ -0,0 +1,30 @@ +--PRIMARY KEY/UNIQUE INDEX +--For hash or modulo distributed table, first column of the primary must be same as distribution column --?? - needs to be updated +-- default is to distribute to all nodes +-- this condition (distribution by second column of PRIMARY KEY ) is not erroneous. It is supported. + +CREATE TABLE xl_pk_products ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid, product_no) ) DISTRIBUTE BY HASH(product_no); +CREATE TABLE xl_pk_products1 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid, product_no) ) DISTRIBUTE BY HASH(product_uid); +CREATE TABLE xl_pk_products2 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid) ) DISTRIBUTE BY HASH(product_no); +ERROR: Unique index of partitioned table must contain the hash distribution column. +CREATE TABLE xl_pk_products3 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_no, product_uid) ) DISTRIBUTE BY MODULO(product_no); +CREATE TABLE xl_pk_products4 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid, product_no) ) DISTRIBUTE BY MODULO(product_no); +CREATE TABLE xl_pk_products5 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid) ) DISTRIBUTE BY MODULO(product_no); +ERROR: Unique index of partitioned table must contain the hash distribution column. +--For roundrobin distributed table, PRIMARY KEY or UNIQUE INDEX is not supported +CREATE TABLE xl_pk_products6 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid) ) DISTRIBUTE BY ROUNDROBIN; +ERROR: Cannot locally enforce a unique index on round robin distributed table. +CREATE TABLE xl_pk_products7 ( product_no integer, product_uid integer, name text, price numeric ) DISTRIBUTE BY ROUNDROBIN; +CREATE UNIQUE INDEX product_uuid ON xl_pk_products7 (product_uid, product_no); +ERROR: Cannot locally enforce a unique index on round robin distributed table. +DROP TABLE xl_pk_products; +DROP TABLE xl_pk_products1; +DROP TABLE xl_pk_products2; +ERROR: table "xl_pk_products2" does not exist +DROP TABLE xl_pk_products3; +DROP TABLE xl_pk_products4; +DROP TABLE xl_pk_products5; +ERROR: table "xl_pk_products5" does not exist +DROP TABLE xl_pk_products6; +ERROR: table "xl_pk_products6" does not exist +DROP TABLE xl_pk_products7; diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule index bcddee96cf..2edc25e237 100644 --- a/src/test/regress/serial_schedule +++ b/src/test/regress/serial_schedule @@ -176,3 +176,7 @@ test: xc_alter_table test: xc_sequence test: xc_prepared_xacts test: xc_notrans_block +test: xl_primary_key +test: xl_foreign_key +test: xl_distribution_column_types +test: xl_alter_table diff --git a/src/test/regress/sql/xl_alter_table.sql b/src/test/regress/sql/xl_alter_table.sql new file mode 100644 index 0000000000..4fc2948e90 --- /dev/null +++ b/src/test/regress/sql/xl_alter_table.sql @@ -0,0 +1,184 @@ +--Distribution column definition can be changed, however values should be within limits of the changed data type. Distribution column cannot be dropped. This works for HASH and not for MODULO now (bug). So failing test for now. + +--integer - converting to varchar, to INT8, + +CREATE TABLE xl_at ( + product_no integer, + product_id integer PRIMARY KEY +) DISTRIBUTE BY HASH (product_id); + +ALTER TABLE xl_at ALTER COLUMN product_id TYPE INT2; + +ALTER TABLE xl_at ALTER COLUMN product_id TYPE INT4; + +ALTER TABLE xl_at ALTER COLUMN product_id TYPE varchar(80); + +ALTER TABLE xl_at ALTER COLUMN product_id TYPE INT8 USING product_id::bigint; + +ALTER TABLE xl_at ALTER COLUMN product_no TYPE INT2; + +ALTER TABLE xl_at ALTER COLUMN product_no TYPE INT4; + +ALTER TABLE xl_at ALTER COLUMN product_no TYPE varchar(80); + +ALTER TABLE xl_at ALTER COLUMN product_no TYPE INT8 USING product_no::bigint; + +INSERT into xl_at (product_no, product_id) VALUES (9223372036854775807, 9223372036854775807); + +-- Value is beyond limit for below smaller integer conversions - so these fail +ALTER TABLE xl_at ALTER COLUMN product_id TYPE integer;--fail + +ALTER TABLE xl_at ALTER COLUMN product_id TYPE INT2;--fail + +ALTER TABLE xl_at ALTER COLUMN product_id TYPE INT4;--fail + +ALTER TABLE xl_at ALTER COLUMN product_no TYPE integer;--fail + +ALTER TABLE xl_at ALTER COLUMN product_no TYPE INT2;--fail + +ALTER TABLE xl_at ALTER COLUMN product_no TYPE INT4;--fail + +ALTER TABLE xl_at ALTER COLUMN product_id TYPE varchar(80); + +ALTER TABLE xl_at ALTER COLUMN product_no TYPE varchar(80); + + +--INT8 - converting to varchar, to integer, + +CREATE TABLE xl_at1 ( + product_no INT8, + product_id INT8 PRIMARY KEY +) DISTRIBUTE BY HASH (product_id); + +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE INT2 USING product_id::smallint; + +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE INT4 USING product_id::integer; + +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE varchar(80); + +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE integer USING product_id::integer; + +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE INT2 USING product_no::smallint; + +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE INT4 USING product_no::integer; + +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE varchar(80); + +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE integer USING product_no::integer; + +INSERT into xl_at1 (product_no, product_id) VALUES (42, 42); + +-- Value is within limit for smaller integer conversions - so these pass +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE INT8; + +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE INT2; + +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE INT4; + +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE INT8; + +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE INT2; + +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE INT4; + +ALTER TABLE xl_at1 ALTER COLUMN product_id TYPE varchar(80); + +ALTER TABLE xl_at1 ALTER COLUMN product_no TYPE varchar(80); + +-- HASH Distributed table: +-- Distribution column cannot be dropped. +CREATE TABLE xl_at2h ( + product_no INT8, + product_id INT2 +) DISTRIBUTE BY HASH (product_id); + +ALTER TABLE xl_at2h DROP COLUMN product_id;--fail - distribution column cannot be dropped. + +ALTER TABLE xl_at2h DISTRIBUTE BY MODULO(product_id); + +ALTER TABLE xl_at2h DISTRIBUTE BY HASH(product_id); + +ALTER TABLE xl_at2h DROP COLUMN product_no; + +ALTER TABLE xl_at2h ADD COLUMN product_no INT8; + +ALTER TABLE xl_at2h ALTER COLUMN product_no SET NOT NULL; + +ALTER TABLE xl_at2h ALTER COLUMN product_id SET NOT NULL; + +ALTER TABLE xl_at2h ALTER COLUMN product_no DROP NOT NULL; + +ALTER TABLE xl_at2h ALTER COLUMN product_id DROP NOT NULL; + +ALTER TABLE xl_at2h ALTER COLUMN product_no SET DEFAULT 0; + +ALTER TABLE xl_at2h ALTER COLUMN product_id SET DEFAULT 0; + +ALTER TABLE xl_at2h ALTER COLUMN product_no DROP DEFAULT; + +ALTER TABLE xl_at2h ALTER COLUMN product_id DROP DEFAULT; + +ALTER TABLE xl_at2h RENAME COLUMN product_no TO product_number; + +ALTER TABLE xl_at2h RENAME COLUMN product_id TO product_identifier; + +ALTER TABLE xl_at2h RENAME TO xl_at3h; + +ALTER TABLE xl_at3h DELETE NODE (datanode2); + +ALTER TABLE xl_at3h ADD NODE (datanode2); + +ALTER TABLE xl_at3h DISTRIBUTE BY REPLICATION; + +-- MODULO Distributed table: +-- Distribution column cannot be dropped (BUG: It can be dropped now. Test Fails). + +CREATE TABLE xl_at2m ( + product_no INT8, + product_id INT2 +) DISTRIBUTE BY MODULO (product_id); + +ALTER TABLE xl_at2m DISTRIBUTE BY HASH(product_id); + +ALTER TABLE xl_at2m DISTRIBUTE BY MODULO(product_id); + +ALTER TABLE xl_at2m DROP COLUMN product_no; + +ALTER TABLE xl_at2m ADD COLUMN product_no INT8; + +ALTER TABLE xl_at2m ALTER COLUMN product_no SET NOT NULL; + +ALTER TABLE xl_at2m ALTER COLUMN product_id SET NOT NULL; + +ALTER TABLE xl_at2m ALTER COLUMN product_no DROP NOT NULL; + +ALTER TABLE xl_at2m ALTER COLUMN product_id DROP NOT NULL; + +ALTER TABLE xl_at2m ALTER COLUMN product_no SET DEFAULT 0; + +ALTER TABLE xl_at2m ALTER COLUMN product_id SET DEFAULT 0; + +ALTER TABLE xl_at2m ALTER COLUMN product_no DROP DEFAULT; + +ALTER TABLE xl_at2m ALTER COLUMN product_id DROP DEFAULT; + +ALTER TABLE xl_at2m RENAME COLUMN product_no TO product_number; + +ALTER TABLE xl_at2m RENAME COLUMN product_id TO product_identifier; + +ALTER TABLE xl_at2m RENAME TO xl_at3m; + +ALTER TABLE xl_at3m DELETE NODE (datanode2); + +ALTER TABLE xl_at3m ADD NODE (datanode2); + +ALTER TABLE xl_at3m DROP COLUMN product_identifier;--fail - distribution column cannot be dropped. + +ALTER TABLE xl_at3m DISTRIBUTE BY REPLICATION; + +DROP TABLE xl_at; +DROP TABLE xl_at1; +DROP TABLE xl_at2h; +DROP TABLE xl_at3h; +DROP TABLE xl_at2m; +DROP TABLE xl_at3m; diff --git a/src/test/regress/sql/xl_distribution_column_types.sql b/src/test/regress/sql/xl_distribution_column_types.sql new file mode 100644 index 0000000000..486b730cf1 --- /dev/null +++ b/src/test/regress/sql/xl_distribution_column_types.sql @@ -0,0 +1,257 @@ +--Supported types for distribution column types - INT8, INT2, OID, INT4, BOOL, INT2VECTOR, OIDVECTOR, CHAR, NAME, TEXT, BPCHAR, BYTEA, VARCHAR, NUMERIC, MONEY, ABSTIME, RELTIME, DATE, TIME, TIMESTAMP, TIMESTAMPTZ, INTERVAL, and TIMETZ + +--INT8, + +CREATE TABLE xl_dc ( + product_no integer, + product_id INT8 PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_id); + +--INT2, + + +CREATE TABLE xl_dc1 ( + product_no integer, + product_id INT2 PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_id); + +--OID, +CREATE TABLE xl_dc2 ( + product_no integer, + product_id OID PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_id); + +--INT4, +CREATE TABLE xl_dc3 ( + product_no integer, + product_id INT4 PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_id); + +--BOOL, + +CREATE TABLE xl_dc4 ( + product_no integer, + is_available BOOL PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (is_available); + +--INT2VECTOR, +CREATE TABLE xl_dc5 ( + product_no integer, + product_id integer, + sub_product_ids INT2VECTOR PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (sub_product_ids); + +--OIDVECTOR, +CREATE TABLE xl_dc6 ( + product_no integer, + product_id integer, + sub_product_ids OIDVECTOR PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (sub_product_ids); + +--CHAR, +CREATE TABLE xl_dc7 ( + product_no integer, + product_group CHAR PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_group); + +--NAME, +CREATE TABLE xl_dc8 ( + product_no integer, + product_name NAME PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_name); + +--TEXT, +CREATE TABLE xl_dc9 ( + product_no integer, + product_name TEXT PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_name); + + +--BPCHAR - blank padded char, +CREATE TABLE xl_dc10 ( + product_no integer, + product_group BPCHAR PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_group); + +--BYTEA - variable length binary string, +CREATE TABLE xl_dc11 ( + product_no integer, + product_group BYTEA PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_group); + +--VARCHAR, +CREATE TABLE xl_dc12 ( + product_no integer, + product_group VARCHAR PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_group); + +--NUMERIC, +CREATE TABLE xl_dc15 ( + product_no integer, + product_id NUMERIC PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY HASH (product_id); + +--MONEY - String datatype, +CREATE TABLE xl_dc16 ( + product_no integer, + product_id NUMERIC , + name MONEY PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (name); + +--ABSTIME, +CREATE TABLE xl_dc17 ( + product_no integer, + product_id NUMERIC , + purchase_date ABSTIME PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); + +--RELTIME, +CREATE TABLE xl_dc18 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date RELTIME PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); + + +--DATE, +CREATE TABLE xl_dc19 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date DATE PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); + +--TIME, +CREATE TABLE xl_dc20 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date TIME PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); + +--TIMESTAMP, + +CREATE TABLE xl_dc21 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date TIMESTAMP PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); + +--TIMESTAMPTZ, + +CREATE TABLE xl_dc22 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date TIMESTAMPTZ PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); + +--INTERVAL, +CREATE TABLE xl_dc23 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date INTERVAL PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); + +--and TIMETZ - time along with time zone +CREATE TABLE xl_dc24 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date TIMETZ PRIMARY KEY, + price numeric +) DISTRIBUTE BY HASH (purchase_date); + +--Distribution strategy can specify on a single column +CREATE TABLE xl_dc25 ( + product_no integer, + product_id NUMERIC , + name MONEY, + purchase_date TIMETZ, + price numeric, + primary key(product_no, product_id) +) DISTRIBUTE BY HASH (product_no, product_id); --fail + +-- Distribution column value cannot be updated +-- default distributed on HASH by primary key column, i.e. city +CREATE TABLE xl_dc_weather ( + city varchar(80) PRIMARY KEY, + temp_lo int, -- low temperature + temp_hi int, -- high temperature + prcp real, -- precipitation + date date +); + +INSERT INTO xl_dc_weather VALUES ('San Francisco', 46, 50, 0.25, '1994-11-27'); + +UPDATE xl_dc_weather SET city = 'SFO' where temp_lo=46 and temp_hi=50; -- fail + + +DROP TABLE xl_dc; +DROP TABLE xl_dc1; +DROP TABLE xl_dc2; +DROP TABLE xl_dc3; +DROP TABLE xl_dc4; +DROP TABLE xl_dc5; +DROP TABLE xl_dc6; +DROP TABLE xl_dc7; +DROP TABLE xl_dc8; +DROP TABLE xl_dc9; +DROP TABLE xl_dc10; +DROP TABLE xl_dc11; +DROP TABLE xl_dc12; +DROP TABLE xl_dc15; +DROP TABLE xl_dc16; +DROP TABLE xl_dc17; +DROP TABLE xl_dc18; +DROP TABLE xl_dc19; +DROP TABLE xl_dc20; +DROP TABLE xl_dc21; +DROP TABLE xl_dc22; +DROP TABLE xl_dc23; +DROP TABLE xl_dc24; +DROP TABLE xl_dc25; +DROP TABLE xl_dc_weather; + + + + diff --git a/src/test/regress/sql/xl_foreign_key.sql b/src/test/regress/sql/xl_foreign_key.sql new file mode 100644 index 0000000000..edc81efc00 --- /dev/null +++ b/src/test/regress/sql/xl_foreign_key.sql @@ -0,0 +1,115 @@ +--FOREIGN KEY + +--For a distributed table, the REFERENCES clause must use the distribution column (product_no here). +-- As for ROUNDROBIN, primary key and unique index are not supported, this test does not include it. +-- default distributed by HASH on product_no +CREATE TABLE xl_fk_products ( + product_no integer PRIMARY KEY, + product_id integer, + name text, + price numeric +); + +CREATE TABLE xl_fk_products01 ( + product_no integer, + product_id integer PRIMARY KEY, + name text, + price numeric +); + +CREATE TABLE xl_fk_products1 ( + product_no integer PRIMARY KEY, + product_id integer , + name text, + price numeric +) DISTRIBUTE BY MODULO(product_no); + +CREATE TABLE xl_fk_products11 ( + product_no integer , + product_id integer PRIMARY KEY, + name text, + price numeric +) DISTRIBUTE BY MODULO(product_id); + +CREATE TABLE xl_fk_orders ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_no), + quantity integer +) DISTRIBUTE BY HASH(product_no); +--pass + +CREATE TABLE xl_fk_orders01 ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_no), + quantity integer +) DISTRIBUTE BY MODULO(product_no); +--fail - as xl_fk_products has product_no distributed by HASH + +CREATE TABLE xl_fk_orders02 ( + order_id integer, + product_no integer REFERENCES xl_fk_products1 (product_no), + quantity integer +) DISTRIBUTE BY MODULO(product_no); +--pass - as source is also modulo distributed + +CREATE TABLE xl_fk_orders1 ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_no), + quantity integer +) DISTRIBUTE BY HASH(order_id); -- fail + +CREATE TABLE xl_fk_orders2 ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_no), + quantity integer +) DISTRIBUTE BY MODULO(order_id); -- fail + +--This implies that PRIMARY KEY and REFERENCES cannot use different columns + +CREATE TABLE xl_fk_orders3 ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_id), + quantity integer +) DISTRIBUTE BY HASH(order_id); +-- fail - as references is using a different column that primary key of referred table + +CREATE TABLE xl_fk_orders4 ( + order_id integer, + product_no integer REFERENCES xl_fk_products1 (product_id), + quantity integer +) DISTRIBUTE BY MODULO(order_id); +-- fail- as references is using a different column that primary key of referred table + +--This also implies that more than one FOREIGN KEY constraints cannot be specified + + +CREATE TABLE xl_fk_orders5 ( + order_id integer, + product_no integer REFERENCES xl_fk_products (product_no), + product_id integer REFERENCES xl_fk_products01 (product_id), + quantity integer +) DISTRIBUTE BY HASH(product_no); + +CREATE TABLE xl_fk_orders6 ( + order_id integer, + product_no integer REFERENCES xl_fk_products1 (product_no), + product_id integer REFERENCES xl_fk_products11 (product_id), + quantity integer +) DISTRIBUTE BY MODULO(order_id); + + +DROP TABLE xl_fk_orders; +DROP TABLE xl_fk_orders01; +DROP TABLE xl_fk_orders02; +DROP TABLE xl_fk_orders1; +DROP TABLE xl_fk_orders2; +DROP TABLE xl_fk_orders3; +DROP TABLE xl_fk_orders4; +DROP TABLE xl_fk_orders5; +DROP TABLE xl_fk_orders6; +DROP TABLE xl_fk_products; +DROP TABLE xl_fk_products01; +DROP TABLE xl_fk_products1; +DROP TABLE xl_fk_products11; + + diff --git a/src/test/regress/sql/xl_primary_key.sql b/src/test/regress/sql/xl_primary_key.sql new file mode 100644 index 0000000000..e3564dab1b --- /dev/null +++ b/src/test/regress/sql/xl_primary_key.sql @@ -0,0 +1,35 @@ +--PRIMARY KEY/UNIQUE INDEX +--For hash or modulo distributed table, first column of the primary must be same as distribution column --?? - needs to be updated + +-- default is to distribute to all nodes + +-- this condition (distribution by second column of PRIMARY KEY ) is not erroneous. It is supported. + +CREATE TABLE xl_pk_products ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid, product_no) ) DISTRIBUTE BY HASH(product_no); + +CREATE TABLE xl_pk_products1 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid, product_no) ) DISTRIBUTE BY HASH(product_uid); + +CREATE TABLE xl_pk_products2 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid) ) DISTRIBUTE BY HASH(product_no); + +CREATE TABLE xl_pk_products3 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_no, product_uid) ) DISTRIBUTE BY MODULO(product_no); + +CREATE TABLE xl_pk_products4 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid, product_no) ) DISTRIBUTE BY MODULO(product_no); + +CREATE TABLE xl_pk_products5 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid) ) DISTRIBUTE BY MODULO(product_no); + +--For roundrobin distributed table, PRIMARY KEY or UNIQUE INDEX is not supported + +CREATE TABLE xl_pk_products6 ( product_no integer, product_uid integer, name text, price numeric, primary key (product_uid) ) DISTRIBUTE BY ROUNDROBIN; + +CREATE TABLE xl_pk_products7 ( product_no integer, product_uid integer, name text, price numeric ) DISTRIBUTE BY ROUNDROBIN; + +CREATE UNIQUE INDEX product_uuid ON xl_pk_products7 (product_uid, product_no); + +DROP TABLE xl_pk_products; +DROP TABLE xl_pk_products1; +DROP TABLE xl_pk_products2; +DROP TABLE xl_pk_products3; +DROP TABLE xl_pk_products4; +DROP TABLE xl_pk_products5; +DROP TABLE xl_pk_products6; +DROP TABLE xl_pk_products7; |