Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4bc772e

Browse files
committed
Ignore partitioned tables when processing ON COMMIT DELETE ROWS
Those tables have no physical storage, making this option unusable withpartition trees as at commit time an actual truncation was attempted.There are still issues with the way ON COMMIT actions are done whenmixing several action types, however this impacts as well inheritancetrees, so this issue will be dealt with later.Reported-by: Rajkumar RaghuwanshiAuthor: Amit LangoteReviewed-by: Michael Paquier, Tom LaneDiscussion:https://postgr.es/m/CAKcux6mhgcjSiB_egqEAEFgX462QZtncU8QCAJ2HZwM-wWGVew@mail.gmail.com
1 parentfa534b4 commit4bc772e

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

‎src/backend/catalog/heap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,6 +3181,13 @@ heap_truncate_one_rel(Relation rel)
31813181
{
31823182
Oidtoastrelid;
31833183

3184+
/*
3185+
* Truncate the relation. Partitioned tables have no storage, so there is
3186+
* nothing to do for them here.
3187+
*/
3188+
if (rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE)
3189+
return;
3190+
31843191
/* Truncate the actual file (and discard buffers) */
31853192
RelationTruncate(rel,0);
31863193

‎src/test/regress/expected/temp.out

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,20 @@ select pg_temp.whoami();
199199
(1 row)
200200

201201
drop table public.whereami;
202+
-- For partitioned temp tables, ON COMMIT actions ignore storage-less
203+
-- partitioned tables.
204+
begin;
205+
create temp table temp_parted_oncommit (a int)
206+
partition by list (a) on commit delete rows;
207+
create temp table temp_parted_oncommit_1
208+
partition of temp_parted_oncommit
209+
for values in (1) on commit delete rows;
210+
insert into temp_parted_oncommit values (1);
211+
commit;
212+
-- partitions are emptied by the previous commit
213+
select * from temp_parted_oncommit;
214+
a
215+
---
216+
(0 rows)
217+
218+
drop table temp_parted_oncommit;

‎src/test/regress/sql/temp.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,17 @@ select whoami();
151151
selectpg_temp.whoami();
152152

153153
droptablepublic.whereami;
154+
155+
-- For partitioned temp tables, ON COMMIT actions ignore storage-less
156+
-- partitioned tables.
157+
begin;
158+
create temp table temp_parted_oncommit (aint)
159+
partition by list (a)oncommitdelete rows;
160+
create temp table temp_parted_oncommit_1
161+
partition of temp_parted_oncommit
162+
forvaluesin (1)oncommitdelete rows;
163+
insert into temp_parted_oncommitvalues (1);
164+
commit;
165+
-- partitions are emptied by the previous commit
166+
select*from temp_parted_oncommit;
167+
droptable temp_parted_oncommit;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp