\! rm -fr '@testtablespace@/hw_cstore_tablespace_4'
\! mkdir '@testtablespace@/hw_cstore_tablespace_4'
create tablespace hw_cstore_tablespace_4 location '@testtablespace@/hw_cstore_tablespace_4';
-- 3 test internal mask
create table t_hw_cstore_tablespace_4(c_int int,c_tsvector tsvector,c_tsquery tsquery);
create index idx_1t_hw_cstore_tablespace_4 on t_hw_cstore_tablespace_4 using gist(c_tsvector);
create index idx_2t_hw_cstore_tablespace_4 on t_hw_cstore_tablespace_4 using gin(c_tsvector);
alter index idx_1t_hw_cstore_tablespace_4 reset(fillfactor);
alter index idx_2t_hw_cstore_tablespace_4 set (fastupdate=false);
drop table t_hw_cstore_tablespace_4 cascade;
-- 4. test temp table
CREATE TABLE set_tblspc_lineitem_4
(
L_ORDERKEY BIGINT NOT NULL
, L_PARTKEY BIGINT NOT NULL
, L_SUPPKEY BIGINT NOT NULL
, L_LINENUMBER BIGINT NOT NULL
, L_QUANTITY DECIMAL(15,2) NOT NULL
, L_EXTENDEDPRICE DECIMAL(15,2) NOT NULL
, L_DISCOUNT DECIMAL(15,2) NOT NULL
, L_TAX DECIMAL(15,2) NOT NULL
, L_RETURNFLAG CHAR(1) NOT NULL
, L_LINESTATUS CHAR(1) NOT NULL
, L_SHIPDATE DATE NOT NULL
, L_COMMITDATE DATE NOT NULL
, L_RECEIPTDATE DATE NOT NULL
, L_SHIPINSTRUCT CHAR(25) NOT NULL
, L_SHIPMODE CHAR(10) NOT NULL
, L_COMMENT VARCHAR(44) NOT NULL
--, primary key (L_ORDERKEY, L_LINENUMBER)
)
with (orientation = column) tablespace hw_cstore_tablespace_4;
COPY set_tblspc_lineitem_4 FROM '@abs_srcdir@/data/lineitem_index.data' DELIMITER '|';
create index idx3_set_tblspc_lineitem_4 on set_tblspc_lineitem_4(L_LINENUMBER) tablespace hw_cstore_tablespace_4;
ALTER TABLE set_tblspc_lineitem_4 SET TABLESPACE pg_default;
ALTER index idx3_set_tblspc_lineitem_4 SET TABLESPACE pg_default;
SELECT COUNT(*) FROM pg_class WHERE reltablespace = ( SELECT OID FROM PG_TABLESPACE WHERE SPCNAME = 'hw_cstore_tablespace_4' );
drop tablespace hw_cstore_tablespace_4;
drop table set_tblspc_lineitem_4;
-- 5. test relfilenode.spcNode
-- 5.1 test partitioned table
create tablespace hw_cstore_tablespace_4 location '@testtablespace@/hw_cstore_tablespace_4';
CREATE TABLE test_cstore_tablespace01(id int, info text) with(orientation=column)
partition by range(id)
(
partition p1 values less than(5) tablespace hw_cstore_tablespace_4,
partition p2 values less than(10)
);
INSERT INTO test_cstore_tablespace01 values(-10), (-9), (-7), (0), (1), (2), (3), (4);
VACUUM FULL test_cstore_tablespace01 partition (p1);
-- rewrite this table and test tablespace oid valid.
ALTER TABLE test_cstore_tablespace01 ADD COLUMN c_char char(5);
SELECT * FROM test_cstore_tablespace01 partition (p1) ORDER BY 1;
DROP TABLE test_cstore_tablespace01;
-- 5.2 test ordinary table
CREATE TABLE test_cstore_tablespace02(id int, info text) with(orientation=column) tablespace hw_cstore_tablespace_4;
INSERT INTO test_cstore_tablespace02 values(-10), (-9), (-7), (0), (1), (2), (3), (4);
VACUUM FULL test_cstore_tablespace02;
-- rewrite this table and test tablespace oid valid.
ALTER TABLE test_cstore_tablespace02 ADD COLUMN c_char char(5), set tablespace pg_default;
SELECT * FROM test_cstore_tablespace02 ORDER BY 1;
DROP TABLE test_cstore_tablespace02;
-- 5.3 test failed Assert()
create table test_cstore_tablespace03(
id int,
info text
) -- row relation
partition by range(id)
(
partition p1 values less than(3000) tablespace pg_default,
partition p2 values less than(6000),
partition p3 values less than(maxvalue)
);
insert into test_cstore_tablespace03 values(generate_series(1,10000),generate_series(1,10000)||'python GaussUpgrade.py -t full-upgrade -l ./new.log');
-- 5.3.1 Add Column Quickly, so rewrite is false and lock is 8. And Assert() fails.
alter table test_cstore_tablespace03 move partition p1 tablespace hw_cstore_tablespace_4, add column c_char2 char(5);
-- check data right
SELECT COUNT(*) FROM test_cstore_tablespace03;
DROP TABLE test_cstore_tablespace03;
drop tablespace hw_cstore_tablespace_4;