Skip to content

Commit 98ec35b

Browse files
committed
Fix corruption of pg_shdepend when copying deps from template database
Using for a new database a template database with shared dependencies that need to be copied over was causing a corruption of pg_shdepend because of an off-by-one computation error of the index number used for the values inserted with a slot. Issue introduced by e3931d0. Monitoring the rest of the code, there are no similar mistakes. Reported-by: Sven Klemm Author: Aleksander Alekseev Reviewed-by: Daniel Gustafsson, Michael Paquier Discussion: https://postgr.es/m/CAJ7c6TP0AowkUgNL6zcAK-s5HYsVHVBRWfu69FRubPpfwZGM9A@mail.gmail.com Backpatch-through: 14
1 parent f45dc59 commit 98ec35b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/backend/catalog/pg_shdepend.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -905,13 +905,13 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId)
905905

906906
shdep = (Form_pg_shdepend) GETSTRUCT(tup);
907907

908-
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid] = ObjectIdGetDatum(newDbId);
909-
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_classid] = shdep->classid;
910-
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objid] = shdep->objid;
911-
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objsubid] = shdep->objsubid;
912-
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refclassid] = shdep->refclassid;
913-
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refobjid] = shdep->refobjid;
914-
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_deptype] = shdep->deptype;
908+
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId);
909+
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_classid - 1] = shdep->classid;
910+
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objid - 1] = shdep->objid;
911+
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objsubid - 1] = shdep->objsubid;
912+
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refclassid - 1] = shdep->refclassid;
913+
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refobjid - 1] = shdep->refobjid;
914+
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_deptype - 1] = shdep->deptype;
915915

916916
ExecStoreVirtualTuple(slot[slot_stored_count]);
917917
slot_stored_count++;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy