select count(*) as add_col1 from pg_attribute pa, pg_class pc where pa.attrelid = pc.oid and pc.relname='alter_aoco_tab_utilitymode' and attname='add_col1';
-- @description AOCO multiple insert to create big table
DROP TABLE IF EXISTS large_aoco_table;
DROP TABLE
CREATE TABLE large_aoco_table (
c_custkey integer,
c_name character varying(25),
c_comment text,
c_rating float,
c_phone character(15),
c_acctbal numeric(15,2),
c_date date,
c_timestamp timestamp
)
WITH (checksum=true, appendonly=true, orientation=column, compresstype=quicklz, compresslevel=1) DISTRIBUTED BY (c_custkey);
CREATE TABLE
insert into large_aoco_table values( 1, 'aa','this is a looong text' , 3.5, '12121212',1000.34,'2015/10/10',now());
INSERT 0 1
insert into large_aoco_table values( 2, 'ab','this is also a looong text' , 4.5, '3456789',3000.45,'2014/08/10',now());
INSERT 0 1
insert into large_aoco_table values( 3, 'ac','this too is a looong text' , 1.5, '878787',500.54,'2014/04/04',now());
INSERT 0 1
insert into large_aoco_table (select i,'xx'||i, 'Can this be a long text please?',i+.5,'10'||i,100.23+i,cast(now() as date),cast(now() as timestamp) from generate_series(1,10000000) i);
INSERT 0 10000000
insert into large_aoco_table (select i,'xx'||i, 'Can this be a long text please?',i+.5,'10'||i,100.23+i,cast(now() as date),cast(now() as timestamp) from generate_series(1,10000000) i);
-- @description AOCO multiple insert/update to create multiple segfiles
DROP TABLE IF EXISTS multi_segfile_tab;
psql:/path/sql_file:1: NOTICE: table "multi_segfile_tab" does not exist, skipping
DROP TABLE
CREATE TABLE multi_segfile_tab (
c_custkey integer,
c_name character varying(25),
c_comment text,
c_rating float,
c_phone character(15),
c_acctbal numeric(15,2),
c_date date,
c_timestamp timestamp
)
WITH (checksum=true, appendonly=true, orientation=column, compresstype=quicklz, compresslevel=1) DISTRIBUTED BY (c_custkey);
CREATE TABLE
insert into multi_segfile_tab values( 1, 'aa','this is a looong text' , 3.5, '12121212',1000.34,'2015/10/10',now());
INSERT 0 1
insert into multi_segfile_tab values( 2, 'ab','this is also a looong text' , 4.5, '3456789',3000.45,'2014/08/10',now());
INSERT 0 1
insert into multi_segfile_tab values( 3, 'ac','this too is a looong text' , 1.5, '878787',500.54,'2014/04/04',now());
INSERT 0 1
insert into multi_segfile_tab (select i,'xx'||i, 'Can this be a long text please?',i+.5,'10'||i,100.23+i,cast(now() as date),cast(now() as timestamp) from generate_series(100,66900) i);
INSERT 0 66801
update multi_segfile_tab set c_name = 'bcx' where c_custkey % 5 = 0;
UPDATE 13361
vacuum multi_segfile_tab;
VACUUM
insert into multi_segfile_tab (select i,'yy'||i, 'Just another long string',i+.5,'10'||i,100.23+i,cast(now() as date),cast(now() as timestamp) from generate_series(100,6900) i);
-- @description AOCO multiple insert to create multiple var-block
DROP TABLE IF EXISTS multivarblock_tab;
psql:/path/sql_file:1: NOTICE: table "multivarblock_tab" does not exist, skipping
DROP TABLE
CREATE TABLE multivarblock_tab (
c_custkey integer,
c_name character varying(25),
c_comment text,
c_rating float,
c_phone character(15),
c_acctbal numeric(15,2),
c_date date,
c_timestamp timestamp
)
WITH (checksum=true, appendonly=true, orientation=column, compresstype=quicklz, compresslevel=1) DISTRIBUTED BY (c_custkey);
CREATE TABLE
insert into multivarblock_tab values( 1, 'aa','this is a looong text' , 3.5, '12121212',1000.34,'2015/10/10',now());
INSERT 0 1
insert into multivarblock_tab values( 2, 'ab','this is also a looong text' , 4.5, '3456789',3000.45,'2014/08/10',now());
INSERT 0 1
insert into multivarblock_tab values( 3, 'ac','this too is a looong text' , 1.5, '878787',500.54,'2014/04/04',now());
INSERT 0 1
insert into multivarblock_tab (select i,'xx'||i, 'Can this be a long text please?',i+.5,'10'||i,100.23+i,cast(now() as date),cast(now() as timestamp) from generate_series(100,66900) i);
-- @description AOCO Create table for Alter table add column in utility mode - Negative testcase
DROP TABLE IF EXISTS alter_aoco_tab_utilitymode;
psql:/path/sql_file:1: NOTICE: table "alter_aoco_tab_utilitymode" does not exist, skipping
DROP TABLE
CREATE TABLE alter_aoco_tab_utilitymode (
c_custkey integer,
c_name character varying(25),
c_comment text,
c_rating float,
c_phone character(15),
c_acctbal numeric(15,2),
c_date date,
c_timestamp timestamp
)
WITH (checksum=true, appendonly=true, orientation=column) DISTRIBUTED BY (c_custkey);
CREATE TABLE
insert into alter_aoco_tab_utilitymode (select i,'xx'||i, 'This is my long text ',i+.5,'10'||i,100.23+i,cast(now() as date),cast(now() as timestamp) from generate_series(1,1000) i);
-- @description AOCO table : drop all column one by one then add new col
DROP TABLE IF EXISTS foo;
DROP TABLE
CREATE TABLE foo (a INT, b INT, c CHAR(128)) WITH (appendonly=true, orientation=column);
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column 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.
CREATE TABLE
CREATE INDEX foo_index ON foo(b);
CREATE INDEX
INSERT INTO foo SELECT i as a, i as b, 'hello world' as c FROM generate_series(1,50) AS i;
INSERT 0 50
update foo set b=b+10 where a < 3;
UPDATE 2
vacuum foo;
VACUUM
INSERT INTO foo SELECT i as a, i as b, 'hello world again' as c FROM generate_series(51,90) AS i;
INSERT 0 40
select count(*) from foo ;
count
-------
90
(1 row)
ALTER TABLE foo DROP COLUMN c;
ALTER TABLE
select count(*) as c from pg_attribute pa, pg_class pc where pa.attrelid = pc.oid and pc.relname='foo' and attname='c';
c
---
0
(1 row)
select count(*) from foo ;
count
-------
90
(1 row)
ALTER TABLE foo DROP COLUMN b;
ALTER TABLE
select count(*) as b from pg_attribute pa, pg_class pc where pa.attrelid = pc.oid and pc.relname='foo' and attname='b';
b
---
0
(1 row)
select count(*) from foo ;
count
-------
90
(1 row)
ALTER TABLE foo DROP COLUMN a;
psql:/path/sql_file:1: NOTICE: Dropping a column that is part of the distribution policy forces a NULL distribution policy
ALTER TABLE
select count(*) as a from pg_attribute pa, pg_class pc where pa.attrelid = pc.oid and pc.relname='foo' and attname='a';
a
---
0
(1 row)
select count(*) from foo;
count
-------
90
(1 row)
ALTER TABLE foo ADD COLUMN a1 int default 10;
ALTER TABLE
select count(*) as a from pg_attribute pa, pg_class pc where pa.attrelid = pc.oid and pc.relname='foo' and attname='a';
-- @description AOCO table : drop all column one by one then add new col
DROP TABLE IF EXISTS foo;
DROP TABLE
CREATE TABLE foo (a INT, b INT, c CHAR(128)) WITH (appendonly=true, orientation=column);
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column 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.
CREATE TABLE
CREATE INDEX foo_index ON foo(b);
CREATE INDEX
INSERT INTO foo SELECT i as a, i as b, 'hello world' as c FROM generate_series(1,500) AS i;
INSERT 0 500
INSERT INTO foo SELECT i as a, i as b, 'hello world again' as c FROM generate_series(501,900) AS i;
INSERT 0 400
select count(*) from foo ;
count
-------
900
(1 row)
ALTER TABLE foo DROP COLUMN c;
ALTER TABLE
select count(*) as c from pg_attribute pa, pg_class pc where pa.attrelid = pc.oid and pc.relname='foo' and attname='c';
c
---
0
(1 row)
select count(*) from foo ;
count
-------
900
(1 row)
ALTER TABLE foo DROP COLUMN b;
ALTER TABLE
select count(*) as b from pg_attribute pa, pg_class pc where pa.attrelid = pc.oid and pc.relname='foo' and attname='b';
b
---
0
(1 row)
select count(*) from foo;
count
-------
900
(1 row)
ALTER TABLE foo DROP COLUMN a;
psql:/path/sql_file:1: NOTICE: Dropping a column that is part of the distribution policy forces a NULL distribution policy
ALTER TABLE
select count(*) as a from pg_attribute pa, pg_class pc where pa.attrelid = pc.oid and pc.relname='foo' and attname='a';
a
---
0
(1 row)
select count(*) from foo;
count
-------
900
(1 row)
ALTER TABLE foo ADD COLUMN a1 int default 10;
ALTER TABLE
select count(*) as a from pg_attribute pa, pg_class pc where pa.attrelid = pc.oid and pc.relname='foo' and attname='a';
alter table large_aoco_table add column add_text_col text default 'this is blah isflsdflsdf ddldl k sdkfmlksdfm lk flksdlslksdlsldkmslkdsdlsdf lskdmlsmfs lsdjlmdfdsfmlsdfkjdsfjn sjkd ksfksdfs lwioemdlksdlk lskdflk lksdfj lksd msdl slkmlmlklskf llwewoweop we dw skdkjsjdlwe wowe lskdl eiwemslksdlkfwiesklslk jsdfkhsdkjfhjh ksdkjdfkjshkjsfksdjfskd kjsdhfsdhfkjsdfksdjfjdskfhksdhfkksjdhfksjdhfksdjhksjdhfksjdkfsjdfhksdhfkjsdkjfhksdjfksdhfksh' ||now() ;
psql:/path/sql_file:1: WARNING: Releasing segworker groups since one or more segment connections failed. This will abort the transactions in the segments that did not get prepared.
psql:/path/sql_file:1: NOTICE: Retry of the distributed transaction 'Abort Prepared' broadcast succeeded to the segments for gid = 1402084958-0000000136.
psql:/path/sql_file:1: ERROR: The distributed transaction 'Prepare' broadcast failed to one or more segments for gid = 1402084958-0000000136. (cdbtm.c:631)
INSERTINTOaoco_allalter(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,a41,a42)values(generate_series(1,20),'M',2011,'t','a','This is news of today: Deadlock between Republicans and Democrats over how best to reduce the U.S. deficit, and over what period, has blocked an agreement to allow the raising of the $14.3 trillion debt ceiling','2001-12-24 02:26:11','U.S. House of Representatives Speaker John Boehner, the top Republican in Congress who has put forward a deficit reduction plan to be voted on later on Thursday said he had no control over whether his bill would avert a credit downgrade.',generate_series(2490,2505),'2011-10-11','The Republican-controlled House is tentatively scheduled to vote on Boehner proposal this afternoon at around 6 p.m. EDT (2200 GMT). The main Republican vote counter in the House, Kevin McCarthy, would not say if there were enough votes to pass the bill.','WASHINGTON:House Speaker John Boehner says his plan mixing spending cuts in exchange for raising the nations $14.3 trillion debt limit is not perfect but is as large a step that a divided government can take that is doable and signable by President Barack Obama.The Ohio Republican says the measure is an honest and sincere attempt at compromise and was negotiated with Democrats last weekend and that passing it would end the ongoing debt crisis. The plan blends $900 billion-plus in spending cuts with a companion increase in the nations borrowing cap.','1234.56',323453,generate_series(3452,3462),7845,'0011','2005-07-16 01:51:15+1359','2001-12-13 01:51:15','((1,2),(0,3),(2,1))','((2,3)(4,5))','08:00:2b:01:02:03','1-2','Republicans had been working throughout the day Thursday to lock down support for their plan to raise the nations debt ceiling, even as Senate Democrats vowed to swiftly kill it if passed.','((2,3)(4,5))','(6,7)',11.222,'((4,5),7)',32,3214,'(1,0,2,3)','2010-02-21',43564,'$1,000.00','192.168.1','126.1.3.4','12:30:45','Johnson & Johnsons McNeil Consumer Healthcare announced the voluntary dosage reduction today. Labels will carry new dosing instructions this fall.The company says it will cut the maximum dosage of Regular Strength Tylenol and other acetaminophen-containing products in 2012.Acetaminophen is safe when used as directed, says Edwin Kuffner, MD, McNeil vice president of over-the-counter medical affairs. But, when too much is taken, it can cause liver damage.The action is intended to cut the risk of such accidental overdoses, the company says in a news release.','1','0',12,23);
INSERTINTOaoco_allalter_uncompr(a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,a41,a42)values(generate_series(1,20),'M',2011,'t','a','This is news of today: Deadlock between Republicans and Democrats over how best to reduce the U.S. deficit, and over what period, has blocked an agreement to allow the raising of the $14.3 trillion debt ceiling','2001-12-24 02:26:11','U.S. House of Representatives Speaker John Boehner, the top Republican in Congress who has put forward a deficit reduction plan to be voted on later on Thursday said he had no control over whether his bill would avert a credit downgrade.',generate_series(2490,2505),'2011-10-11','The Republican-controlled House is tentatively scheduled to vote on Boehner proposal this afternoon at around 6 p.m. EDT (2200 GMT). The main Republican vote counter in the House, Kevin McCarthy, would not say if there were enough votes to pass the bill.','WASHINGTON:House Speaker John Boehner says his plan mixing spending cuts in exchange for raising the nations $14.3 trillion debt limit is not perfect but is as large a step that a divided government can take that is doable and signable by President Barack Obama.The Ohio Republican says the measure is an honest and sincere attempt at compromise and was negotiated with Democrats last weekend and that passing it would end the ongoing debt crisis. The plan blends $900 billion-plus in spending cuts with a companion increase in the nations borrowing cap.','1234.56',323453,generate_series(3452,3462),7845,'0011','2005-07-16 01:51:15+1359','2001-12-13 01:51:15','((1,2),(0,3),(2,1))','((2,3)(4,5))','08:00:2b:01:02:03','1-2','Republicans had been working throughout the day Thursday to lock down support for their plan to raise the nations debt ceiling, even as Senate Democrats vowed to swiftly kill it if passed.','((2,3)(4,5))','(6,7)',11.222,'((4,5),7)',32,3214,'(1,0,2,3)','2010-02-21',43564,'$1,000.00','192.168.1','126.1.3.4','12:30:45','Johnson & Johnsons McNeil Consumer Healthcare announced the voluntary dosage reduction today. Labels will carry new dosing instructions this fall.The company says it will cut the maximum dosage of Regular Strength Tylenol and other acetaminophen-containing products in 2012.Acetaminophen is safe when used as directed, says Edwin Kuffner, MD, McNeil vice president of over-the-counter medical affairs. But, when too much is taken, it can cause liver damage.The action is intended to cut the risk of such accidental overdoses, the company says in a news release.','1','0',12,23);
\d+aoco_allalter
--Select from pg_attribute_encoding to see the table entry
insertintolarge_aoco_tablevalues(1,'aa','this is a looong text',3.5,'12121212',1000.34,'2015/10/10',now());
insertintolarge_aoco_tablevalues(2,'ab','this is also a looong text',4.5,'3456789',3000.45,'2014/08/10',now());
insertintolarge_aoco_tablevalues(3,'ac','this too is a looong text',1.5,'878787',500.54,'2014/04/04',now());
insertintolarge_aoco_table(selecti,'xx'||i,'Can this be a long text please?',i+.5,'10'||i,100.23+i,cast(now()asdate),cast(now()astimestamp)fromgenerate_series(1,10000000)i);
insertintolarge_aoco_table(selecti,'xx'||i,'Can this be a long text please?',i+.5,'10'||i,100.23+i,cast(now()asdate),cast(now()astimestamp)fromgenerate_series(1,10000000)i);
insertintomulti_segfile_tabvalues(1,'aa','this is a looong text',3.5,'12121212',1000.34,'2015/10/10',now());
insertintomulti_segfile_tabvalues(2,'ab','this is also a looong text',4.5,'3456789',3000.45,'2014/08/10',now());
insertintomulti_segfile_tabvalues(3,'ac','this too is a looong text',1.5,'878787',500.54,'2014/04/04',now());
insertintomulti_segfile_tab(selecti,'xx'||i,'Can this be a long text please?',i+.5,'10'||i,100.23+i,cast(now()asdate),cast(now()astimestamp)fromgenerate_series(100,66900)i);
insertintomulti_segfile_tab(selecti,'yy'||i,'Just another long string',i+.5,'10'||i,100.23+i,cast(now()asdate),cast(now()astimestamp)fromgenerate_series(100,6900)i);
insertintomultivarblock_tabvalues(1,'aa','this is a looong text',3.5,'12121212',1000.34,'2015/10/10',now());
insertintomultivarblock_tabvalues(2,'ab','this is also a looong text',4.5,'3456789',3000.45,'2014/08/10',now());
insertintomultivarblock_tabvalues(3,'ac','this too is a looong text',1.5,'878787',500.54,'2014/04/04',now());
insertintomultivarblock_tab(selecti,'xx'||i,'Can this be a long text please?',i+.5,'10'||i,100.23+i,cast(now()asdate),cast(now()astimestamp)fromgenerate_series(100,66900)i);
insertintoalter_aoco_tab_utilitymode(selecti,'xx'||i,'This is my long text ',i+.5,'10'||i,100.23+i,cast(now()asdate),cast(now()astimestamp)fromgenerate_series(1,1000)i);