pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Install dependencies to prevent dropping partition key columns.
4+ messages / 1 participants
[nested] [flat]

* pgsql: Install dependencies to prevent dropping partition key columns.
@ 2019-07-22 18:55  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2019-07-22 18:55 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Install dependencies to prevent dropping partition key columns.

The logic in ATExecDropColumn that rejects dropping partition key
columns is quite an inadequate defense, because it doesn't execute
in cases where a column needs to be dropped due to cascade from
something that only the column, not the whole partitioned table,
depends on.  That leaves us with a badly broken partitioned table;
even an attempt to load its relcache entry will fail.

We really need to have explicit pg_depend entries that show that the
column can't be dropped without dropping the whole table.  Hence,
add those entries.  In v12 and HEAD, bump catversion to ensure that
partitioned tables will have such entries.  We can't do that in
released branches of course, so in v10 and v11 this patch affords
protection only to partitioned tables created after the patch is
installed.  Given the lack of field complaints (this bug was found
by fuzz-testing not by end users), that's probably good enough.

In passing, fix ATExecDropColumn and ATPrepAlterColumnType
messages to be more specific about which partition key column
they're complaining about.

Per report from Manuel Rigger.  Back-patch to v10 where partitioned
tables were added.

Discussion: https://postgr.es/m/CA+u7OA4JKCPFrdrAbOs7XBiCyD61XJxeNav4LefkSmBLQ-Vobg@mail.gmail.com
Discussion: https://postgr.es/m/31920.1562526703@sss.pgh.pa.us

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/79e573fa4986be54c30d1313709c26c2a34488c8

Modified Files
--------------
src/backend/catalog/dependency.c           | 53 ++++++++++++++++++++++++++----
src/backend/catalog/heap.c                 | 28 +++++++++++++---
src/backend/commands/tablecmds.c           | 39 ++++++++++------------
src/bin/pg_dump/pg_dump_sort.c             | 10 +++++-
src/include/catalog/catversion.h           |  2 +-
src/include/catalog/dependency.h           |  2 +-
src/test/regress/expected/alter_table.out  | 12 +++----
src/test/regress/expected/create_table.out | 36 ++++++++++++++++++++
src/test/regress/sql/create_table.sql      | 33 +++++++++++++++++++
9 files changed, 174 insertions(+), 41 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: Install dependencies to prevent dropping partition key columns.
@ 2019-07-22 18:55  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2019-07-22 18:55 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Install dependencies to prevent dropping partition key columns.

The logic in ATExecDropColumn that rejects dropping partition key
columns is quite an inadequate defense, because it doesn't execute
in cases where a column needs to be dropped due to cascade from
something that only the column, not the whole partitioned table,
depends on.  That leaves us with a badly broken partitioned table;
even an attempt to load its relcache entry will fail.

We really need to have explicit pg_depend entries that show that the
column can't be dropped without dropping the whole table.  Hence,
add those entries.  In v12 and HEAD, bump catversion to ensure that
partitioned tables will have such entries.  We can't do that in
released branches of course, so in v10 and v11 this patch affords
protection only to partitioned tables created after the patch is
installed.  Given the lack of field complaints (this bug was found
by fuzz-testing not by end users), that's probably good enough.

In passing, fix ATExecDropColumn and ATPrepAlterColumnType
messages to be more specific about which partition key column
they're complaining about.

Per report from Manuel Rigger.  Back-patch to v10 where partitioned
tables were added.

Discussion: https://postgr.es/m/CA+u7OA4JKCPFrdrAbOs7XBiCyD61XJxeNav4LefkSmBLQ-Vobg@mail.gmail.com
Discussion: https://postgr.es/m/31920.1562526703@sss.pgh.pa.us

Branch
------
REL_10_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0e1deaa4c4247ad89d0d3d4226a2eb85a894c778

Modified Files
--------------
src/backend/catalog/dependency.c           | 53 ++++++++++++++++++++++++++----
src/backend/catalog/heap.c                 | 28 +++++++++++++---
src/backend/commands/tablecmds.c           | 39 ++++++++++------------
src/bin/pg_dump/pg_dump_sort.c             | 18 ++++++++++
src/include/catalog/dependency.h           |  2 +-
src/test/regress/expected/alter_table.out  | 12 +++----
src/test/regress/expected/create_table.out | 36 ++++++++++++++++++++
src/test/regress/sql/create_table.sql      | 33 +++++++++++++++++++
8 files changed, 182 insertions(+), 39 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: Install dependencies to prevent dropping partition key columns.
@ 2019-07-22 18:55  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2019-07-22 18:55 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Install dependencies to prevent dropping partition key columns.

The logic in ATExecDropColumn that rejects dropping partition key
columns is quite an inadequate defense, because it doesn't execute
in cases where a column needs to be dropped due to cascade from
something that only the column, not the whole partitioned table,
depends on.  That leaves us with a badly broken partitioned table;
even an attempt to load its relcache entry will fail.

We really need to have explicit pg_depend entries that show that the
column can't be dropped without dropping the whole table.  Hence,
add those entries.  In v12 and HEAD, bump catversion to ensure that
partitioned tables will have such entries.  We can't do that in
released branches of course, so in v10 and v11 this patch affords
protection only to partitioned tables created after the patch is
installed.  Given the lack of field complaints (this bug was found
by fuzz-testing not by end users), that's probably good enough.

In passing, fix ATExecDropColumn and ATPrepAlterColumnType
messages to be more specific about which partition key column
they're complaining about.

Per report from Manuel Rigger.  Back-patch to v10 where partitioned
tables were added.

Discussion: https://postgr.es/m/CA+u7OA4JKCPFrdrAbOs7XBiCyD61XJxeNav4LefkSmBLQ-Vobg@mail.gmail.com
Discussion: https://postgr.es/m/31920.1562526703@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/a0555ddab9b672a04681ce0d9f6c94104c01b15f

Modified Files
--------------
src/backend/catalog/dependency.c           | 53 ++++++++++++++++++++++++++----
src/backend/catalog/heap.c                 | 28 +++++++++++++---
src/backend/commands/tablecmds.c           | 39 ++++++++++------------
src/bin/pg_dump/pg_dump_sort.c             | 10 +++++-
src/include/catalog/catversion.h           |  2 +-
src/include/catalog/dependency.h           |  2 +-
src/test/regress/expected/alter_table.out  | 12 +++----
src/test/regress/expected/create_table.out | 36 ++++++++++++++++++++
src/test/regress/sql/create_table.sql      | 33 +++++++++++++++++++
9 files changed, 174 insertions(+), 41 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* pgsql: Install dependencies to prevent dropping partition key columns.
@ 2019-07-22 18:55  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2019-07-22 18:55 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Install dependencies to prevent dropping partition key columns.

The logic in ATExecDropColumn that rejects dropping partition key
columns is quite an inadequate defense, because it doesn't execute
in cases where a column needs to be dropped due to cascade from
something that only the column, not the whole partitioned table,
depends on.  That leaves us with a badly broken partitioned table;
even an attempt to load its relcache entry will fail.

We really need to have explicit pg_depend entries that show that the
column can't be dropped without dropping the whole table.  Hence,
add those entries.  In v12 and HEAD, bump catversion to ensure that
partitioned tables will have such entries.  We can't do that in
released branches of course, so in v10 and v11 this patch affords
protection only to partitioned tables created after the patch is
installed.  Given the lack of field complaints (this bug was found
by fuzz-testing not by end users), that's probably good enough.

In passing, fix ATExecDropColumn and ATPrepAlterColumnType
messages to be more specific about which partition key column
they're complaining about.

Per report from Manuel Rigger.  Back-patch to v10 where partitioned
tables were added.

Discussion: https://postgr.es/m/CA+u7OA4JKCPFrdrAbOs7XBiCyD61XJxeNav4LefkSmBLQ-Vobg@mail.gmail.com
Discussion: https://postgr.es/m/31920.1562526703@sss.pgh.pa.us

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6cdefc82ba9db66e9a9e185bd4b1dc52a0ffc708

Modified Files
--------------
src/backend/catalog/dependency.c           | 53 ++++++++++++++++++++++++++----
src/backend/catalog/heap.c                 | 28 +++++++++++++---
src/backend/commands/tablecmds.c           | 39 ++++++++++------------
src/bin/pg_dump/pg_dump_sort.c             | 18 ++++++++++
src/include/catalog/dependency.h           |  2 +-
src/test/regress/expected/alter_table.out  | 12 +++----
src/test/regress/expected/create_table.out | 36 ++++++++++++++++++++
src/test/regress/sql/create_table.sql      | 33 +++++++++++++++++++
8 files changed, 182 insertions(+), 39 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2019-07-22 18:55 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-07-22 18:55 pgsql: Install dependencies to prevent dropping partition key columns. Tom Lane <tgl@sss.pgh.pa.us>
2019-07-22 18:55 pgsql: Install dependencies to prevent dropping partition key columns. Tom Lane <tgl@sss.pgh.pa.us>
2019-07-22 18:55 pgsql: Install dependencies to prevent dropping partition key columns. Tom Lane <tgl@sss.pgh.pa.us>
2019-07-22 18:55 pgsql: Install dependencies to prevent dropping partition key columns. Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox