mirror of https://github.com/citusdata/citus.git
Clean-up old metadata on TRUNCATE
parent
2e47bf5172
commit
b72a4d8d19
|
@ -825,6 +825,7 @@ FdwNewRelFileNode(Relation relation)
|
|||
if (OidIsValid(relation->rd_rel->relfilenode))
|
||||
{
|
||||
RelationDropStorage(relation);
|
||||
DeleteDataFileMetadataRowIfExists(relation->rd_rel->relfilenode);
|
||||
}
|
||||
|
||||
if (OidIsValid(relation->rd_rel->reltablespace))
|
||||
|
|
|
@ -445,6 +445,9 @@ cstore_relation_set_new_filenode(Relation rel,
|
|||
SMgrRelation srel;
|
||||
CStoreOptions *options = CStoreTableAMGetOptions();
|
||||
|
||||
/* delete old relfilenode metadata */
|
||||
DeleteDataFileMetadataRowIfExists(rel->rd_node.relNode);
|
||||
|
||||
Assert(persistence == RELPERSISTENCE_PERMANENT);
|
||||
*freezeXid = RecentXmin;
|
||||
*minmulti = GetOldestMultiXactId();
|
||||
|
|
|
@ -15,6 +15,7 @@ CREATE TABLE cstore_truncate_test_second (a int, b int) USING cstore_tableam;
|
|||
-- COMPRESSED
|
||||
CREATE TABLE cstore_truncate_test_compressed (a int, b int) USING cstore_tableam;
|
||||
CREATE TABLE cstore_truncate_test_regular (a int, b int);
|
||||
SELECT count(*) AS cstore_data_files_before_truncate FROM cstore.cstore_data_files \gset
|
||||
INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
||||
set cstore.compression = 'pglz';
|
||||
INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1, 10) a;
|
||||
|
@ -145,6 +146,13 @@ SELECT * from cstore_truncate_test;
|
|||
---+---
|
||||
(0 rows)
|
||||
|
||||
-- make sure TRUNATE deletes metadata for old relfilenode
|
||||
SELECT :cstore_data_files_before_truncate - count(*) FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
-- test if a cached truncate from a pl/pgsql function works
|
||||
CREATE FUNCTION cstore_truncate_test_regular_func() RETURNS void AS $$
|
||||
BEGIN
|
||||
|
|
|
@ -14,6 +14,7 @@ CREATE FOREIGN TABLE cstore_truncate_test (a int, b int) SERVER cstore_server;
|
|||
CREATE FOREIGN TABLE cstore_truncate_test_second (a int, b int) SERVER cstore_server;
|
||||
CREATE FOREIGN TABLE cstore_truncate_test_compressed (a int, b int) SERVER cstore_server OPTIONS (compression 'pglz');
|
||||
CREATE TABLE cstore_truncate_test_regular (a int, b int);
|
||||
SELECT count(*) AS cstore_data_files_before_truncate FROM cstore.cstore_data_files \gset
|
||||
INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
||||
INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1, 10) a;
|
||||
INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1, 10) a;
|
||||
|
@ -142,6 +143,13 @@ SELECT * from cstore_truncate_test;
|
|||
---+---
|
||||
(0 rows)
|
||||
|
||||
-- make sure TRUNATE deletes metadata for old relfilenode
|
||||
SELECT :cstore_data_files_before_truncate - count(*) FROM cstore.cstore_data_files;
|
||||
?column?
|
||||
----------
|
||||
0
|
||||
(1 row)
|
||||
|
||||
-- test if a cached truncate from a pl/pgsql function works
|
||||
CREATE FUNCTION cstore_truncate_test_regular_func() RETURNS void AS $$
|
||||
BEGIN
|
||||
|
|
|
@ -13,6 +13,8 @@ CREATE TABLE cstore_truncate_test_second (a int, b int) USING cstore_tableam;
|
|||
CREATE TABLE cstore_truncate_test_compressed (a int, b int) USING cstore_tableam;
|
||||
CREATE TABLE cstore_truncate_test_regular (a int, b int);
|
||||
|
||||
SELECT count(*) AS cstore_data_files_before_truncate FROM cstore.cstore_data_files \gset
|
||||
|
||||
INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
||||
|
||||
set cstore.compression = 'pglz';
|
||||
|
@ -60,6 +62,9 @@ SELECT * from cstore_truncate_test_regular;
|
|||
TRUNCATE TABLE cstore_truncate_test;
|
||||
SELECT * from cstore_truncate_test;
|
||||
|
||||
-- make sure TRUNATE deletes metadata for old relfilenode
|
||||
SELECT :cstore_data_files_before_truncate - count(*) FROM cstore.cstore_data_files;
|
||||
|
||||
-- test if a cached truncate from a pl/pgsql function works
|
||||
CREATE FUNCTION cstore_truncate_test_regular_func() RETURNS void AS $$
|
||||
BEGIN
|
||||
|
|
|
@ -12,6 +12,8 @@ CREATE FOREIGN TABLE cstore_truncate_test_second (a int, b int) SERVER cstore_se
|
|||
CREATE FOREIGN TABLE cstore_truncate_test_compressed (a int, b int) SERVER cstore_server OPTIONS (compression 'pglz');
|
||||
CREATE TABLE cstore_truncate_test_regular (a int, b int);
|
||||
|
||||
SELECT count(*) AS cstore_data_files_before_truncate FROM cstore.cstore_data_files \gset
|
||||
|
||||
INSERT INTO cstore_truncate_test select a, a from generate_series(1, 10) a;
|
||||
|
||||
INSERT INTO cstore_truncate_test_compressed select a, a from generate_series(1, 10) a;
|
||||
|
@ -57,6 +59,9 @@ SELECT * from cstore_truncate_test_regular;
|
|||
TRUNCATE TABLE cstore_truncate_test;
|
||||
SELECT * from cstore_truncate_test;
|
||||
|
||||
-- make sure TRUNATE deletes metadata for old relfilenode
|
||||
SELECT :cstore_data_files_before_truncate - count(*) FROM cstore.cstore_data_files;
|
||||
|
||||
-- test if a cached truncate from a pl/pgsql function works
|
||||
CREATE FUNCTION cstore_truncate_test_regular_func() RETURNS void AS $$
|
||||
BEGIN
|
||||
|
|
Loading…
Reference in New Issue