mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-27 08:39:28 +08:00
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
This commit is contained in:
parent
f45dc59a38
commit
98ec35b0bb
@ -905,13 +905,13 @@ copyTemplateDependencies(Oid templateDbId, Oid newDbId)
|
||||
|
||||
shdep = (Form_pg_shdepend) GETSTRUCT(tup);
|
||||
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid] = ObjectIdGetDatum(newDbId);
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_classid] = shdep->classid;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objid] = shdep->objid;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objsubid] = shdep->objsubid;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refclassid] = shdep->refclassid;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refobjid] = shdep->refobjid;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_deptype] = shdep->deptype;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_dbid - 1] = ObjectIdGetDatum(newDbId);
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_classid - 1] = shdep->classid;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objid - 1] = shdep->objid;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_objsubid - 1] = shdep->objsubid;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refclassid - 1] = shdep->refclassid;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_refobjid - 1] = shdep->refobjid;
|
||||
slot[slot_stored_count]->tts_values[Anum_pg_shdepend_deptype - 1] = shdep->deptype;
|
||||
|
||||
ExecStoreVirtualTuple(slot[slot_stored_count]);
|
||||
slot_stored_count++;
|
||||
|
Loading…
Reference in New Issue
Block a user