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

Commitad3ae64

Browse files
committed
Fill in extraUpdatedCols in logical replication
The extraUpdatedCols field of the target RTE records which generatedcolumns are affected by an update. This is used in a variety ofplaces, including per-column triggers and foreign data wrappers. Whenan update was initiated by a logical replication subscription, thisfield was not filled in, so such an update would not affect generatedcolumns in a way that is consistent with normal updates. To fix,factor out some code from analyze.c to fill in extraUpdatedCols in thelogical replication worker as well.Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/b05e781a-fa16-6b52-6738-761181204567@2ndquadrant.com
1 parentf4ae722 commitad3ae64

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

‎src/backend/parser/analyze.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,10 +2346,18 @@ transformUpdateTargetList(ParseState *pstate, List *origTlist)
23462346
if (orig_tl!=NULL)
23472347
elog(ERROR,"UPDATE target count mismatch --- internal error");
23482348

2349-
/*
2350-
* Record in extraUpdatedCols generated columns referencing updated base
2351-
* columns.
2352-
*/
2349+
fill_extraUpdatedCols(target_rte,tupdesc);
2350+
2351+
returntlist;
2352+
}
2353+
2354+
/*
2355+
* Record in extraUpdatedCols generated columns referencing updated base
2356+
* columns.
2357+
*/
2358+
void
2359+
fill_extraUpdatedCols(RangeTblEntry*target_rte,TupleDesctupdesc)
2360+
{
23532361
if (tupdesc->constr&&
23542362
tupdesc->constr->has_generated_stored)
23552363
{
@@ -2371,8 +2379,6 @@ transformUpdateTargetList(ParseState *pstate, List *origTlist)
23712379
defval.adnum-FirstLowInvalidHeapAttributeNumber);
23722380
}
23732381
}
2374-
2375-
returntlist;
23762382
}
23772383

23782384
/*

‎src/backend/replication/logical/worker.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include"miscadmin.h"
4343
#include"nodes/makefuncs.h"
4444
#include"optimizer/optimizer.h"
45+
#include"parser/analyze.h"
4546
#include"parser/parse_relation.h"
4647
#include"pgstat.h"
4748
#include"postmaster/bgworker.h"
@@ -737,6 +738,8 @@ apply_handle_update(StringInfo s)
737738
i+1-FirstLowInvalidHeapAttributeNumber);
738739
}
739740

741+
fill_extraUpdatedCols(target_rte,RelationGetDescr(rel->localrel));
742+
740743
PushActiveSnapshot(GetTransactionSnapshot());
741744
ExecOpenIndices(estate->es_result_relation_info, false);
742745

‎src/include/parser/analyze.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ extern void applyLockingClause(Query *qry, Index rtindex,
4646
externList*BuildOnConflictExcludedTargetlist(Relationtargetrel,
4747
IndexexclRelIndex);
4848

49+
externvoidfill_extraUpdatedCols(RangeTblEntry*target_rte,TupleDesctupdesc);
50+
4951
#endif/* ANALYZE_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp