-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reference leak on AO/AOCS partition tables with unique index. (#649)
* Fix reference leak on AO/AOCS partition tables with unique index. Fix #557. This is introduced by GPDB commit ed364586b99. For AO/AOCS partition tables, it's possible to update across partitions. And it does have deleteDesc and uniqueCheckDesc if there were. The DeleteDesc and InsertDesc are not enough to decide if the partition has a update operation or not. Some partitions have visimap but some not, clean them if possible. Authored-by: Zhang Mingli [email protected]
- Loading branch information
Showing
7 changed files
with
346 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,3 +63,4 @@ | |
/directory_table.out | ||
/directory_table_optimizer.out | ||
/tag.out | ||
/ao_unique_index_partition.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
src/test/regress/input/ao_unique_index_partition.source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
-- | ||
-- Github issue: https://github.com/cloudberrydb/cloudberrydb/issues/557 | ||
-- Test update on ao partition tables with unique index. | ||
-- | ||
create schema t_issue_557; | ||
set search_path to t_issue_557; | ||
CREATE TABLE IF NOT EXISTS t_issue_557_ao | ||
( | ||
product_id INT, | ||
is_audited BOOLEAN DEFAULT FALSE, | ||
quantity SMALLINT, | ||
total_sales BIGINT, | ||
unit_price REAL, | ||
discount DOUBLE PRECISION, | ||
description TEXT, | ||
sale_date TIMESTAMP, | ||
order_date DATE, | ||
status CHAR(10), | ||
customer_name VARCHAR(20), | ||
price DECIMAL(20, 10) | ||
) | ||
DISTRIBUTED BY (product_id) | ||
PARTITION BY HASH(description); | ||
|
||
CREATE TABLE t_issue_557_ao_part1 | ||
PARTITION OF t_issue_557_ao | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 0) | ||
WITH (appendonly=true); | ||
|
||
CREATE TABLE t_issue_557_ao_part2 | ||
PARTITION OF t_issue_557_ao | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 1) | ||
WITH (appendonly=true); | ||
|
||
CREATE TABLE t_issue_557_ao_part3 | ||
PARTITION OF t_issue_557_ao | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 2) | ||
WITH (appendonly=true); | ||
-- Create Indexes | ||
|
||
-- Unique | ||
CREATE UNIQUE INDEX on t_issue_557_ao(product_id,description); | ||
|
||
INSERT INTO t_issue_557_ao ( | ||
product_id, | ||
is_audited, | ||
description, | ||
status | ||
) | ||
SELECT | ||
x.id, -- product_id | ||
FALSE, | ||
'Product description ' || x.id, -- description | ||
'Closed' | ||
FROM ( | ||
SELECT * FROM generate_series(1, 20) AS id | ||
) AS x; | ||
|
||
UPDATE t_issue_557_ao | ||
SET status = 'Closed', | ||
description = description || ' Audited'; | ||
|
||
DELETE FROM t_issue_557_ao; | ||
|
||
INSERT INTO t_issue_557_ao ( | ||
product_id, | ||
is_audited, | ||
description, | ||
status | ||
) | ||
SELECT | ||
x.id, -- product_id | ||
FALSE, | ||
'Product description ' || x.id, -- description | ||
'Closed' | ||
FROM ( | ||
SELECT * FROM generate_series(1, 20) AS id | ||
) AS x; | ||
|
||
UPDATE t_issue_557_ao | ||
SET status = 'Closed', | ||
description = description || ' Audited'; | ||
|
||
-- AOCO | ||
CREATE TABLE IF NOT EXISTS t_issue_557_aocs | ||
( | ||
product_id INT, | ||
is_audited BOOLEAN DEFAULT FALSE, | ||
quantity SMALLINT, | ||
total_sales BIGINT, | ||
unit_price REAL, | ||
discount DOUBLE PRECISION, | ||
description TEXT, | ||
sale_date TIMESTAMP, | ||
order_date DATE, | ||
status CHAR(10), | ||
customer_name VARCHAR(20), | ||
price DECIMAL(20, 10) | ||
) | ||
DISTRIBUTED BY (product_id) | ||
PARTITION BY HASH(description); | ||
|
||
CREATE TABLE t_issue_557_aocs_part1 | ||
PARTITION OF t_issue_557_aocs | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 0) | ||
WITH (appendonly=true, orientation=column); | ||
|
||
CREATE TABLE t_issue_557_aocs_part2 | ||
PARTITION OF t_issue_557_aocs | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 1) | ||
WITH (appendonly=true, orientation=column); | ||
|
||
CREATE TABLE t_issue_557_aocs_part3 | ||
PARTITION OF t_issue_557_aocs | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 2) | ||
WITH (appendonly=true, orientation=column); | ||
-- Create Indexes | ||
|
||
-- Unique | ||
CREATE UNIQUE INDEX on t_issue_557_aocs(product_id,description); | ||
|
||
INSERT INTO t_issue_557_aocs ( | ||
product_id, | ||
is_audited, | ||
description, | ||
status | ||
) | ||
SELECT | ||
x.id, -- product_id | ||
FALSE, | ||
'Product description ' || x.id, -- description | ||
'Closed' | ||
FROM ( | ||
SELECT * FROM generate_series(1, 20) AS id | ||
) AS x; | ||
|
||
UPDATE t_issue_557_aocs | ||
SET status = 'Closed', | ||
description = description || ' Audited'; | ||
|
||
DELETE FROM t_issue_557_aocs; | ||
|
||
INSERT INTO t_issue_557_aocs ( | ||
product_id, | ||
is_audited, | ||
description, | ||
status | ||
) | ||
SELECT | ||
x.id, -- product_id | ||
FALSE, | ||
'Product description ' || x.id, -- description | ||
'Closed' | ||
FROM ( | ||
SELECT * FROM generate_series(1, 20) AS id | ||
) AS x; | ||
|
||
UPDATE t_issue_557_aocs | ||
SET status = 'Closed', | ||
description = description || ' Audited'; | ||
|
||
-- start_ignore | ||
drop schema t_issue_557 cascade; | ||
-- end_ignore |
150 changes: 150 additions & 0 deletions
150
src/test/regress/output/ao_unique_index_partition.source
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
-- | ||
-- Github issue: https://github.com/cloudberrydb/cloudberrydb/issues/557 | ||
-- Test update on ao partition tables with unique index. | ||
-- | ||
create schema t_issue_557; | ||
set search_path to t_issue_557; | ||
CREATE TABLE IF NOT EXISTS t_issue_557_ao | ||
( | ||
product_id INT, | ||
is_audited BOOLEAN DEFAULT FALSE, | ||
quantity SMALLINT, | ||
total_sales BIGINT, | ||
unit_price REAL, | ||
discount DOUBLE PRECISION, | ||
description TEXT, | ||
sale_date TIMESTAMP, | ||
order_date DATE, | ||
status CHAR(10), | ||
customer_name VARCHAR(20), | ||
price DECIMAL(20, 10) | ||
) | ||
DISTRIBUTED BY (product_id) | ||
PARTITION BY HASH(description); | ||
CREATE TABLE t_issue_557_ao_part1 | ||
PARTITION OF t_issue_557_ao | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 0) | ||
WITH (appendonly=true); | ||
NOTICE: table has parent, setting distribution columns to match parent table | ||
CREATE TABLE t_issue_557_ao_part2 | ||
PARTITION OF t_issue_557_ao | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 1) | ||
WITH (appendonly=true); | ||
NOTICE: table has parent, setting distribution columns to match parent table | ||
CREATE TABLE t_issue_557_ao_part3 | ||
PARTITION OF t_issue_557_ao | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 2) | ||
WITH (appendonly=true); | ||
NOTICE: table has parent, setting distribution columns to match parent table | ||
-- Create Indexes | ||
-- Unique | ||
CREATE UNIQUE INDEX on t_issue_557_ao(product_id,description); | ||
INSERT INTO t_issue_557_ao ( | ||
product_id, | ||
is_audited, | ||
description, | ||
status | ||
) | ||
SELECT | ||
x.id, -- product_id | ||
FALSE, | ||
'Product description ' || x.id, -- description | ||
'Closed' | ||
FROM ( | ||
SELECT * FROM generate_series(1, 20) AS id | ||
) AS x; | ||
UPDATE t_issue_557_ao | ||
SET status = 'Closed', | ||
description = description || ' Audited'; | ||
DELETE FROM t_issue_557_ao; | ||
INSERT INTO t_issue_557_ao ( | ||
product_id, | ||
is_audited, | ||
description, | ||
status | ||
) | ||
SELECT | ||
x.id, -- product_id | ||
FALSE, | ||
'Product description ' || x.id, -- description | ||
'Closed' | ||
FROM ( | ||
SELECT * FROM generate_series(1, 20) AS id | ||
) AS x; | ||
UPDATE t_issue_557_ao | ||
SET status = 'Closed', | ||
description = description || ' Audited'; | ||
-- AOCO | ||
CREATE TABLE IF NOT EXISTS t_issue_557_aocs | ||
( | ||
product_id INT, | ||
is_audited BOOLEAN DEFAULT FALSE, | ||
quantity SMALLINT, | ||
total_sales BIGINT, | ||
unit_price REAL, | ||
discount DOUBLE PRECISION, | ||
description TEXT, | ||
sale_date TIMESTAMP, | ||
order_date DATE, | ||
status CHAR(10), | ||
customer_name VARCHAR(20), | ||
price DECIMAL(20, 10) | ||
) | ||
DISTRIBUTED BY (product_id) | ||
PARTITION BY HASH(description); | ||
CREATE TABLE t_issue_557_aocs_part1 | ||
PARTITION OF t_issue_557_aocs | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 0) | ||
WITH (appendonly=true, orientation=column); | ||
NOTICE: table has parent, setting distribution columns to match parent table | ||
CREATE TABLE t_issue_557_aocs_part2 | ||
PARTITION OF t_issue_557_aocs | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 1) | ||
WITH (appendonly=true, orientation=column); | ||
NOTICE: table has parent, setting distribution columns to match parent table | ||
CREATE TABLE t_issue_557_aocs_part3 | ||
PARTITION OF t_issue_557_aocs | ||
FOR VALUES WITH (MODULUS 3, REMAINDER 2) | ||
WITH (appendonly=true, orientation=column); | ||
NOTICE: table has parent, setting distribution columns to match parent table | ||
-- Create Indexes | ||
-- Unique | ||
CREATE UNIQUE INDEX on t_issue_557_aocs(product_id,description); | ||
INSERT INTO t_issue_557_aocs ( | ||
product_id, | ||
is_audited, | ||
description, | ||
status | ||
) | ||
SELECT | ||
x.id, -- product_id | ||
FALSE, | ||
'Product description ' || x.id, -- description | ||
'Closed' | ||
FROM ( | ||
SELECT * FROM generate_series(1, 20) AS id | ||
) AS x; | ||
UPDATE t_issue_557_aocs | ||
SET status = 'Closed', | ||
description = description || ' Audited'; | ||
DELETE FROM t_issue_557_aocs; | ||
INSERT INTO t_issue_557_aocs ( | ||
product_id, | ||
is_audited, | ||
description, | ||
status | ||
) | ||
SELECT | ||
x.id, -- product_id | ||
FALSE, | ||
'Product description ' || x.id, -- description | ||
'Closed' | ||
FROM ( | ||
SELECT * FROM generate_series(1, 20) AS id | ||
) AS x; | ||
UPDATE t_issue_557_aocs | ||
SET status = 'Closed', | ||
description = description || ' Audited'; | ||
-- start_ignore | ||
drop schema t_issue_557 cascade; | ||
-- end_ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,3 +60,4 @@ | |
/external_table_union_all.sql | ||
/directory_table.sql | ||
/tag.sql | ||
/ao_unique_index_partition.sql |