pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co
6+ messages / 1 participants
[nested] [flat]

* pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co
@ 2019-06-24 20:43  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2019-06-24 20:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fix ALTER COLUMN TYPE's handling of indexes and index constraints.

This patch reverts all the code changes of commit e76de8861, which turns
out to have been seriously misguided.  We can't wait till later to compute
the definition string for an index; we must capture that before applying
the data type change for any column it depends on, else ruleutils.c will
deliverr wrong/misleading results.  (This fine point was documented
nowhere, of course.)

I'd also managed to forget that ATExecAlterColumnType executes once per
ALTER COLUMN TYPE clause, not once per statement; which resulted in the
code being basically completely broken for any case in which multiple ALTER
COLUMN TYPE clauses are applied to a table having non-constraint indexes
that must be rebuilt.  Through very bad luck, none of the existing test
cases nor the ones added by e76de8861 caught that, but of course it was
soon found in the field.

The previous patch also had an implicit assumption that if a constraint's
index had a dependency on a table column, so would the constraint --- but
that isn't actually true, so it didn't fix such cases.

Instead of trying to delete unneeded index dependencies later, do the
is-there-a-constraint lookup immediately on seeing an index dependency,
and switch to remembering the constraint if so.  In the unusual case of
multiple column dependencies for a constraint index, this will result in
duplicate constraint lookups, but that's not that horrible compared to all
the other work that happens here.  Besides, such cases did not work at all
before, so it's hard to argue that they're performance-critical for anyone.

Per bug #15865 from Keith Fiske.  As before, back-patch to all supported
branches.

Discussion: https://postgr.es/m/15865-17940eacc8f8b081@postgresql.org

Branch
------
REL9_6_STABLE

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

Modified Files
--------------
src/backend/commands/tablecmds.c          | 184 +++++++++++++++---------------
src/test/regress/expected/alter_table.out |  22 +++-
src/test/regress/sql/alter_table.sql      |  12 +-
3 files changed, 125 insertions(+), 93 deletions(-)



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

* pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co
@ 2019-06-24 20:43  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2019-06-24 20:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fix ALTER COLUMN TYPE's handling of indexes and index constraints.

This patch reverts all the code changes of commit e76de8861, which turns
out to have been seriously misguided.  We can't wait till later to compute
the definition string for an index; we must capture that before applying
the data type change for any column it depends on, else ruleutils.c will
deliverr wrong/misleading results.  (This fine point was documented
nowhere, of course.)

I'd also managed to forget that ATExecAlterColumnType executes once per
ALTER COLUMN TYPE clause, not once per statement; which resulted in the
code being basically completely broken for any case in which multiple ALTER
COLUMN TYPE clauses are applied to a table having non-constraint indexes
that must be rebuilt.  Through very bad luck, none of the existing test
cases nor the ones added by e76de8861 caught that, but of course it was
soon found in the field.

The previous patch also had an implicit assumption that if a constraint's
index had a dependency on a table column, so would the constraint --- but
that isn't actually true, so it didn't fix such cases.

Instead of trying to delete unneeded index dependencies later, do the
is-there-a-constraint lookup immediately on seeing an index dependency,
and switch to remembering the constraint if so.  In the unusual case of
multiple column dependencies for a constraint index, this will result in
duplicate constraint lookups, but that's not that horrible compared to all
the other work that happens here.  Besides, such cases did not work at all
before, so it's hard to argue that they're performance-critical for anyone.

Per bug #15865 from Keith Fiske.  As before, back-patch to all supported
branches.

Discussion: https://postgr.es/m/15865-17940eacc8f8b081@postgresql.org

Branch
------
REL9_5_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/316f6893282450b5a748550d922aa72141f97d1c

Modified Files
--------------
src/backend/commands/tablecmds.c          | 184 +++++++++++++++---------------
src/test/regress/expected/alter_table.out |  22 +++-
src/test/regress/sql/alter_table.sql      |  12 +-
3 files changed, 125 insertions(+), 93 deletions(-)



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

* pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co
@ 2019-06-24 20:43  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2019-06-24 20:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fix ALTER COLUMN TYPE's handling of indexes and index constraints.

This patch reverts all the code changes of commit e76de8861, which turns
out to have been seriously misguided.  We can't wait till later to compute
the definition string for an index; we must capture that before applying
the data type change for any column it depends on, else ruleutils.c will
deliverr wrong/misleading results.  (This fine point was documented
nowhere, of course.)

I'd also managed to forget that ATExecAlterColumnType executes once per
ALTER COLUMN TYPE clause, not once per statement; which resulted in the
code being basically completely broken for any case in which multiple ALTER
COLUMN TYPE clauses are applied to a table having non-constraint indexes
that must be rebuilt.  Through very bad luck, none of the existing test
cases nor the ones added by e76de8861 caught that, but of course it was
soon found in the field.

The previous patch also had an implicit assumption that if a constraint's
index had a dependency on a table column, so would the constraint --- but
that isn't actually true, so it didn't fix such cases.

Instead of trying to delete unneeded index dependencies later, do the
is-there-a-constraint lookup immediately on seeing an index dependency,
and switch to remembering the constraint if so.  In the unusual case of
multiple column dependencies for a constraint index, this will result in
duplicate constraint lookups, but that's not that horrible compared to all
the other work that happens here.  Besides, such cases did not work at all
before, so it's hard to argue that they're performance-critical for anyone.

Per bug #15865 from Keith Fiske.  As before, back-patch to all supported
branches.

Discussion: https://postgr.es/m/15865-17940eacc8f8b081@postgresql.org

Branch
------
master

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

Modified Files
--------------
src/backend/commands/tablecmds.c          | 141 ++++++++++++++++--------------
src/test/regress/expected/alter_table.out |  22 ++++-
src/test/regress/sql/alter_table.sql      |  12 ++-
3 files changed, 103 insertions(+), 72 deletions(-)



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

* pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co
@ 2019-06-24 20:43  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2019-06-24 20:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fix ALTER COLUMN TYPE's handling of indexes and index constraints.

This patch reverts all the code changes of commit e76de8861, which turns
out to have been seriously misguided.  We can't wait till later to compute
the definition string for an index; we must capture that before applying
the data type change for any column it depends on, else ruleutils.c will
deliverr wrong/misleading results.  (This fine point was documented
nowhere, of course.)

I'd also managed to forget that ATExecAlterColumnType executes once per
ALTER COLUMN TYPE clause, not once per statement; which resulted in the
code being basically completely broken for any case in which multiple ALTER
COLUMN TYPE clauses are applied to a table having non-constraint indexes
that must be rebuilt.  Through very bad luck, none of the existing test
cases nor the ones added by e76de8861 caught that, but of course it was
soon found in the field.

The previous patch also had an implicit assumption that if a constraint's
index had a dependency on a table column, so would the constraint --- but
that isn't actually true, so it didn't fix such cases.

Instead of trying to delete unneeded index dependencies later, do the
is-there-a-constraint lookup immediately on seeing an index dependency,
and switch to remembering the constraint if so.  In the unusual case of
multiple column dependencies for a constraint index, this will result in
duplicate constraint lookups, but that's not that horrible compared to all
the other work that happens here.  Besides, such cases did not work at all
before, so it's hard to argue that they're performance-critical for anyone.

Per bug #15865 from Keith Fiske.  As before, back-patch to all supported
branches.

Discussion: https://postgr.es/m/15865-17940eacc8f8b081@postgresql.org

Branch
------
REL_11_STABLE

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

Modified Files
--------------
src/backend/commands/tablecmds.c          | 141 ++++++++++++++++--------------
src/test/regress/expected/alter_table.out |  22 ++++-
src/test/regress/sql/alter_table.sql      |  12 ++-
3 files changed, 103 insertions(+), 72 deletions(-)



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

* pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co
@ 2019-06-24 20:43  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2019-06-24 20:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fix ALTER COLUMN TYPE's handling of indexes and index constraints.

This patch reverts all the code changes of commit e76de8861, which turns
out to have been seriously misguided.  We can't wait till later to compute
the definition string for an index; we must capture that before applying
the data type change for any column it depends on, else ruleutils.c will
deliverr wrong/misleading results.  (This fine point was documented
nowhere, of course.)

I'd also managed to forget that ATExecAlterColumnType executes once per
ALTER COLUMN TYPE clause, not once per statement; which resulted in the
code being basically completely broken for any case in which multiple ALTER
COLUMN TYPE clauses are applied to a table having non-constraint indexes
that must be rebuilt.  Through very bad luck, none of the existing test
cases nor the ones added by e76de8861 caught that, but of course it was
soon found in the field.

The previous patch also had an implicit assumption that if a constraint's
index had a dependency on a table column, so would the constraint --- but
that isn't actually true, so it didn't fix such cases.

Instead of trying to delete unneeded index dependencies later, do the
is-there-a-constraint lookup immediately on seeing an index dependency,
and switch to remembering the constraint if so.  In the unusual case of
multiple column dependencies for a constraint index, this will result in
duplicate constraint lookups, but that's not that horrible compared to all
the other work that happens here.  Besides, such cases did not work at all
before, so it's hard to argue that they're performance-critical for anyone.

Per bug #15865 from Keith Fiske.  As before, back-patch to all supported
branches.

Discussion: https://postgr.es/m/15865-17940eacc8f8b081@postgresql.org

Branch
------
REL9_4_STABLE

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

Modified Files
--------------
src/backend/commands/tablecmds.c          | 184 +++++++++++++++---------------
src/test/regress/expected/alter_table.out |  22 +++-
src/test/regress/sql/alter_table.sql      |  12 +-
3 files changed, 125 insertions(+), 93 deletions(-)



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

* pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co
@ 2019-06-24 20:43  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2019-06-24 20:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Further fix ALTER COLUMN TYPE's handling of indexes and index constraints.

This patch reverts all the code changes of commit e76de8861, which turns
out to have been seriously misguided.  We can't wait till later to compute
the definition string for an index; we must capture that before applying
the data type change for any column it depends on, else ruleutils.c will
deliverr wrong/misleading results.  (This fine point was documented
nowhere, of course.)

I'd also managed to forget that ATExecAlterColumnType executes once per
ALTER COLUMN TYPE clause, not once per statement; which resulted in the
code being basically completely broken for any case in which multiple ALTER
COLUMN TYPE clauses are applied to a table having non-constraint indexes
that must be rebuilt.  Through very bad luck, none of the existing test
cases nor the ones added by e76de8861 caught that, but of course it was
soon found in the field.

The previous patch also had an implicit assumption that if a constraint's
index had a dependency on a table column, so would the constraint --- but
that isn't actually true, so it didn't fix such cases.

Instead of trying to delete unneeded index dependencies later, do the
is-there-a-constraint lookup immediately on seeing an index dependency,
and switch to remembering the constraint if so.  In the unusual case of
multiple column dependencies for a constraint index, this will result in
duplicate constraint lookups, but that's not that horrible compared to all
the other work that happens here.  Besides, such cases did not work at all
before, so it's hard to argue that they're performance-critical for anyone.

Per bug #15865 from Keith Fiske.  As before, back-patch to all supported
branches.

Discussion: https://postgr.es/m/15865-17940eacc8f8b081@postgresql.org

Branch
------
REL_10_STABLE

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

Modified Files
--------------
src/backend/commands/tablecmds.c          | 184 +++++++++++++++---------------
src/test/regress/expected/alter_table.out |  22 +++-
src/test/regress/sql/alter_table.sql      |  12 +-
3 files changed, 125 insertions(+), 93 deletions(-)



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


end of thread, other threads:[~2019-06-24 20:43 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24 20:43 pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co Tom Lane <tgl@sss.pgh.pa.us>
2019-06-24 20:43 pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co Tom Lane <tgl@sss.pgh.pa.us>
2019-06-24 20:43 pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co Tom Lane <tgl@sss.pgh.pa.us>
2019-06-24 20:43 pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co Tom Lane <tgl@sss.pgh.pa.us>
2019-06-24 20:43 pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co Tom Lane <tgl@sss.pgh.pa.us>
2019-06-24 20:43 pgsql: Further fix ALTER COLUMN TYPE's handling of indexes and index co 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