mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-18 04:17:00 +08:00
Previously, when selecting an usable index for update/delete for the REPLICA IDENTITY FULL table, in IsIndexOnlyExpression(), we used to check if all index fields are not expressions. However, it was not necessary, because it is enough to check if only the leftmost index field is not an expression (and references the remote table column) and this check has already been done by RemoteRelContainsLeftMostColumnOnIdx(). This commit removes IsIndexOnlyExpression() and RemoteRelContainsLeftMostColumnOnIdx() and all checks for usable indexes for REPLICA IDENTITY FULL tables are now performed by IsIndexUsableForReplicaIdentityFull(). Backpatch this to remain the code consistent. Reported-by: Peter Smith Reviewed-by: Amit Kapila, Önder Kalacı Discussion: https://postgr.es/m/CAHut%2BPsGRE5WSsY0jcLHJEoA17MrbP9yy8FxdjC_ZOAACxbt%2BQ%40mail.gmail.com Backpatch-through: 16
55 lines
1.9 KiB
C
55 lines
1.9 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* logicalrelation.h
|
|
* Relation definitions for logical replication relation mapping.
|
|
*
|
|
* Portions Copyright (c) 2016-2023, PostgreSQL Global Development Group
|
|
*
|
|
* src/include/replication/logicalrelation.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef LOGICALRELATION_H
|
|
#define LOGICALRELATION_H
|
|
|
|
#include "access/attmap.h"
|
|
#include "catalog/index.h"
|
|
#include "replication/logicalproto.h"
|
|
|
|
typedef struct LogicalRepRelMapEntry
|
|
{
|
|
LogicalRepRelation remoterel; /* key is remoterel.remoteid */
|
|
|
|
/*
|
|
* Validity flag -- when false, revalidate all derived info at next
|
|
* logicalrep_rel_open. (While the localrel is open, we assume our lock
|
|
* on that rel ensures the info remains good.)
|
|
*/
|
|
bool localrelvalid;
|
|
|
|
/* Mapping to local relation. */
|
|
Oid localreloid; /* local relation id */
|
|
Relation localrel; /* relcache entry (NULL when closed) */
|
|
AttrMap *attrmap; /* map of local attributes to remote ones */
|
|
bool updatable; /* Can apply updates/deletes? */
|
|
Oid localindexoid; /* which index to use, or InvalidOid if none */
|
|
|
|
/* Sync state. */
|
|
char state;
|
|
XLogRecPtr statelsn;
|
|
} LogicalRepRelMapEntry;
|
|
|
|
extern void logicalrep_relmap_update(LogicalRepRelation *remoterel);
|
|
extern void logicalrep_partmap_reset_relmap(LogicalRepRelation *remoterel);
|
|
|
|
extern LogicalRepRelMapEntry *logicalrep_rel_open(LogicalRepRelId remoteid,
|
|
LOCKMODE lockmode);
|
|
extern LogicalRepRelMapEntry *logicalrep_partition_open(LogicalRepRelMapEntry *root,
|
|
Relation partrel, AttrMap *map);
|
|
extern void logicalrep_rel_close(LogicalRepRelMapEntry *rel,
|
|
LOCKMODE lockmode);
|
|
extern bool IsIndexUsableForReplicaIdentityFull(IndexInfo *indexInfo, AttrMap *attrmap);
|
|
extern Oid GetRelationIdentityOrPK(Relation rel);
|
|
|
|
#endif /* LOGICALRELATION_H */
|