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

Commit652f552

Browse files
committed
[PGPRO-4074] Logical decoding of updates without primary keys.
Writes full tuples on update/delete instead of logging nothing when noreasonable identity is found. Note that upcoming patch will try to useunique index as identity if it exists.(cherry picked from commit 33dca03a26599e392726d7874eea61b51d04d6a4)tags: multimaster(cherry picked from commit 5d068561e4c544d1a2b163a662b9bd166f92a56b)
1 parentc70b193 commit652f552

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

‎contrib/test_decoding/expected/ddl.out

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,16 +592,16 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
592592
table public.table_without_key: INSERT: id[integer]:2 data[integer]:2
593593
COMMIT
594594
BEGIN
595-
table public.table_without_key: DELETE:(no-tuple-data)
595+
table public.table_without_key: DELETE:id[integer]:1data[integer]:1
596596
COMMIT
597597
BEGIN
598-
table public.table_without_key: UPDATE: id[integer]:2 data[integer]:3
598+
table public.table_without_key: UPDATE:old-key: id[integer]:2 data[integer]:2 new-tuple:id[integer]:2 data[integer]:3
599599
COMMIT
600600
BEGIN
601-
table public.table_without_key: UPDATE: id[integer]:-2 data[integer]:3
601+
table public.table_without_key: UPDATE:old-key: id[integer]:2 data[integer]:3 new-tuple:id[integer]:-2 data[integer]:3
602602
COMMIT
603603
BEGIN
604-
table public.table_without_key: UPDATE: id[integer]:2 data[integer]:3
604+
table public.table_without_key: UPDATE:old-key: id[integer]:-2 data[integer]:3 new-tuple:id[integer]:2 data[integer]:3
605605
COMMIT
606606
BEGIN
607607
table public.table_without_key: UPDATE: old-key: id[integer]:2 data[integer]:3 new-tuple: id[integer]:-2 data[integer]:3
@@ -648,19 +648,19 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
648648
table public.table_with_unique_not_null: INSERT: id[integer]:2 data[integer]:2
649649
COMMIT
650650
BEGIN
651-
table public.table_with_unique_not_null: DELETE:(no-tuple-data)
651+
table public.table_with_unique_not_null: DELETE:id[integer]:1data[integer]:1
652652
COMMIT
653653
BEGIN
654-
table public.table_with_unique_not_null: UPDATE: id[integer]:2 data[integer]:3
654+
table public.table_with_unique_not_null: UPDATE:old-key: id[integer]:2 data[integer]:2 new-tuple:id[integer]:2 data[integer]:3
655655
COMMIT
656656
BEGIN
657-
table public.table_with_unique_not_null: UPDATE: id[integer]:-2 data[integer]:3
657+
table public.table_with_unique_not_null: UPDATE:old-key: id[integer]:2 data[integer]:3 new-tuple:id[integer]:-2 data[integer]:3
658658
COMMIT
659659
BEGIN
660-
table public.table_with_unique_not_null: UPDATE: id[integer]:2 data[integer]:3
660+
table public.table_with_unique_not_null: UPDATE:old-key: id[integer]:-2 data[integer]:3 new-tuple:id[integer]:2 data[integer]:3
661661
COMMIT
662662
BEGIN
663-
table public.table_with_unique_not_null: DELETE:(no-tuple-data)
663+
table public.table_with_unique_not_null: DELETE:id[integer]:2data[integer]:3
664664
COMMIT
665665
BEGIN
666666
table public.table_with_unique_not_null: INSERT: id[integer]:3 data[integer]:1

‎src/backend/access/heap/heapam.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,7 +2735,8 @@ heap_delete(Relation relation, ItemPointer tid,
27352735

27362736
if (old_key_tuple!=NULL)
27372737
{
2738-
if (relation->rd_rel->relreplident==REPLICA_IDENTITY_FULL)
2738+
if (relation->rd_rel->relreplident==REPLICA_IDENTITY_FULL
2739+
|| !OidIsValid(relation->rd_replidindex))
27392740
xlrec.flags |=XLH_DELETE_CONTAINS_OLD_TUPLE;
27402741
else
27412742
xlrec.flags |=XLH_DELETE_CONTAINS_OLD_KEY;
@@ -7393,7 +7394,8 @@ log_heap_update(Relation reln, Buffer oldbuf,
73937394
xlrec.flags |=XLH_UPDATE_CONTAINS_NEW_TUPLE;
73947395
if (old_key_tuple)
73957396
{
7396-
if (reln->rd_rel->relreplident==REPLICA_IDENTITY_FULL)
7397+
if (reln->rd_rel->relreplident==REPLICA_IDENTITY_FULL
7398+
|| !OidIsValid(reln->rd_replidindex))
73977399
xlrec.flags |=XLH_UPDATE_CONTAINS_OLD_TUPLE;
73987400
else
73997401
xlrec.flags |=XLH_UPDATE_CONTAINS_OLD_KEY;
@@ -7620,7 +7622,10 @@ ExtractReplicaIdentity(Relation relation, HeapTuple tp, bool key_changed,
76207622
if (replident==REPLICA_IDENTITY_NOTHING)
76217623
returnNULL;
76227624

7623-
if (replident==REPLICA_IDENTITY_FULL)
7625+
if (!relation->rd_indexvalid)
7626+
RelationGetIndexList(relation);
7627+
7628+
if (replident==REPLICA_IDENTITY_FULL|| !OidIsValid(relation->rd_replidindex))
76247629
{
76257630
/*
76267631
* When logging the entire old tuple, it very well could contain

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp