Fix corruption of pg_shdepend when copying deps from template database
authorMichael Paquier <michael@paquier.xyz>
Thu, 21 Oct 2021 01:39:07 +0000 (10:39 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 21 Oct 2021 01:39:07 +0000 (10:39 +0900)
commit5040c96415a062a1016e0a6b9a4dc9f26a7f356e
tree423df8e7a4cf4f7eff273a668ecf1e4c61ae4fe6
parent7182788552b7b7d7fca226af2ec281789b1abff3
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
src/backend/catalog/pg_shdepend.c