pgsql: Fix logic buglets in pg_dump's flagInhAttrs().

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix logic buglets in pg_dump's flagInhAttrs().
Дата
Msg-id E1pX93Z-001En8-2e@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix logic buglets in pg_dump's flagInhAttrs().

As it stands, flagInhAttrs() can make changes in table properties that
change decisions made at other tables during other iterations of its
loop.  This is a pretty bad idea, since we visit the tables in OID
order which is not necessarily related to inheritance relationships.
So far as I can tell, the consequences are just cosmetic: we might
dump DEFAULT or GENERATED expressions that we don't really need to
because they match properties of the parent.  Nonetheless, it's buggy,
and somebody might someday add functionality here that fails less
benignly when the traversal order varies.

One issue is that when we decide we needn't dump a particular
GENERATED expression, we physically unlink the struct for it,
so that it will now look like the table has no such expression,
causing the wrong choice to be made at any child visited later.
We can improve that by instead clearing the dobj.dump flag,
and taking care to check that flag when it comes time to dump
the expression or not.

The other problem is that if we decide we need to fake up a DEFAULT
NULL clause to override a default that would otherwise get inherited,
we modify the data structure in the reverse fashion, creating an
attrdefs entry where there hadn't been one.  It's harder to avoid
doing that, but since the backend won't report a plain "DEFAULT NULL"
property we can modify the code to recognize ones we just added.

Add some commentary to perhaps forestall future mistakes of the
same ilk.

Since the effects of this seem only cosmetic, no back-patch.

Discussion: https://postgr.es/m/1506298.1676323579@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/128dd9f9eca0b633b51ffcd5b0f798fbc48ec4c0

Modified Files
--------------
src/bin/pg_dump/common.c  | 29 +++++++++++++++++++++++------
src/bin/pg_dump/pg_dump.c | 10 ++++++----
2 files changed, 29 insertions(+), 10 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: pgsql: Remove unnecessary and problematic collate.windows.win1252 tests
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: doc: Fix description of pg_get_wal_stats_till_end_of_wal() in pg