mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Preserve replica identity index across ALTER TABLE rewrite
If an index was explicitly set as replica identity index, this setting was lost when a table was rewritten by ALTER TABLE. Because this setting is part of pg_index but actually controlled by ALTER TABLE (not part of CREATE INDEX, say), we have to do some extra work to restore it. Based-on-patch-by: Quan Zongliang <quanzongliang@gmail.com> Reviewed-by: Euler Taveira <euler.taveira@2ndquadrant.com> Discussion: https://www.postgresql.org/message-id/flat/c70fcab2-4866-0d9f-1d01-e75e189db342@gmail.com
This commit is contained in:
23
src/backend/utils/cache/lsyscache.c
vendored
23
src/backend/utils/cache/lsyscache.c
vendored
@ -3228,6 +3228,29 @@ get_index_column_opclass(Oid index_oid, int attno)
|
||||
return opclass;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_index_isreplident
|
||||
*
|
||||
* Given the index OID, return pg_index.indisreplident.
|
||||
*/
|
||||
bool
|
||||
get_index_isreplident(Oid index_oid)
|
||||
{
|
||||
HeapTuple tuple;
|
||||
Form_pg_index rd_index;
|
||||
bool result;
|
||||
|
||||
tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
return false;
|
||||
|
||||
rd_index = (Form_pg_index) GETSTRUCT(tuple);
|
||||
result = rd_index->indisreplident;
|
||||
ReleaseSysCache(tuple);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_index_isvalid
|
||||
*
|
||||
|
Reference in New Issue
Block a user