pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix crash when columns have been added to the end of a view.
7+ messages / 1 participants
[nested] [flat]

* pgsql: Fix crash when columns have been added to the end of a view.
@ 2017-10-27 21:29  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2017-10-27 21:29 UTC (permalink / raw)
  To: pgsql-committers

Fix crash when columns have been added to the end of a view.

expandRTE() supposed that an RTE_SUBQUERY subquery must have exactly
as many non-junk tlist items as the RTE has column aliases for it.
This was true at the time the code was written, and is still true so
far as parse analysis is concerned --- but when the function is used
during planning, the subquery might have appeared through insertion
of a view that now has more columns than it did when the outer query
was parsed.  This results in a core dump if, for instance, we have
to expand a whole-row Var that references the subquery.

To avoid crashing, we can either stop expanding the RTE when we run
out of aliases, or invent new aliases for the added columns.  While
the latter might be more useful, the former is consistent with what
expandRTE() does for composite-returning functions in the RTE_FUNCTION
case, so it seems like we'd better do it that way.

Per bug #14876 from Samuel Horwitz.  This has been busted since commit
ff1ea2173 allowed views to acquire more columns, so back-patch to all
supported branches.

Discussion: https://postgr.es/m/20171026184035.1471.82810@wrigleys.postgresql.org

Branch
------
REL_10_STABLE

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

Modified Files
--------------
src/backend/parser/parse_relation.c       | 12 ++++-
src/test/regress/expected/alter_table.out | 85 +++++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql      | 20 ++++++++
3 files changed, 116 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix crash when columns have been added to the end of a view.
@ 2017-10-27 21:29  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2017-10-27 21:29 UTC (permalink / raw)
  To: pgsql-committers

Fix crash when columns have been added to the end of a view.

expandRTE() supposed that an RTE_SUBQUERY subquery must have exactly
as many non-junk tlist items as the RTE has column aliases for it.
This was true at the time the code was written, and is still true so
far as parse analysis is concerned --- but when the function is used
during planning, the subquery might have appeared through insertion
of a view that now has more columns than it did when the outer query
was parsed.  This results in a core dump if, for instance, we have
to expand a whole-row Var that references the subquery.

To avoid crashing, we can either stop expanding the RTE when we run
out of aliases, or invent new aliases for the added columns.  While
the latter might be more useful, the former is consistent with what
expandRTE() does for composite-returning functions in the RTE_FUNCTION
case, so it seems like we'd better do it that way.

Per bug #14876 from Samuel Horwitz.  This has been busted since commit
ff1ea2173 allowed views to acquire more columns, so back-patch to all
supported branches.

Discussion: https://postgr.es/m/20171026184035.1471.82810@wrigleys.postgresql.org

Branch
------
REL9_2_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/80e79718d0ead9d4291ab320bea89ec8f24050ad

Modified Files
--------------
src/backend/parser/parse_relation.c       | 12 ++++-
src/test/regress/expected/alter_table.out | 78 +++++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql      | 20 ++++++++
3 files changed, 109 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix crash when columns have been added to the end of a view.
@ 2017-10-27 21:29  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2017-10-27 21:29 UTC (permalink / raw)
  To: pgsql-committers

Fix crash when columns have been added to the end of a view.

expandRTE() supposed that an RTE_SUBQUERY subquery must have exactly
as many non-junk tlist items as the RTE has column aliases for it.
This was true at the time the code was written, and is still true so
far as parse analysis is concerned --- but when the function is used
during planning, the subquery might have appeared through insertion
of a view that now has more columns than it did when the outer query
was parsed.  This results in a core dump if, for instance, we have
to expand a whole-row Var that references the subquery.

To avoid crashing, we can either stop expanding the RTE when we run
out of aliases, or invent new aliases for the added columns.  While
the latter might be more useful, the former is consistent with what
expandRTE() does for composite-returning functions in the RTE_FUNCTION
case, so it seems like we'd better do it that way.

Per bug #14876 from Samuel Horwitz.  This has been busted since commit
ff1ea2173 allowed views to acquire more columns, so back-patch to all
supported branches.

Discussion: https://postgr.es/m/20171026184035.1471.82810@wrigleys.postgresql.org

Branch
------
REL9_5_STABLE

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

Modified Files
--------------
src/backend/parser/parse_relation.c       | 12 ++++-
src/test/regress/expected/alter_table.out | 85 +++++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql      | 20 ++++++++
3 files changed, 116 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix crash when columns have been added to the end of a view.
@ 2017-10-27 21:29  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2017-10-27 21:29 UTC (permalink / raw)
  To: pgsql-committers

Fix crash when columns have been added to the end of a view.

expandRTE() supposed that an RTE_SUBQUERY subquery must have exactly
as many non-junk tlist items as the RTE has column aliases for it.
This was true at the time the code was written, and is still true so
far as parse analysis is concerned --- but when the function is used
during planning, the subquery might have appeared through insertion
of a view that now has more columns than it did when the outer query
was parsed.  This results in a core dump if, for instance, we have
to expand a whole-row Var that references the subquery.

To avoid crashing, we can either stop expanding the RTE when we run
out of aliases, or invent new aliases for the added columns.  While
the latter might be more useful, the former is consistent with what
expandRTE() does for composite-returning functions in the RTE_FUNCTION
case, so it seems like we'd better do it that way.

Per bug #14876 from Samuel Horwitz.  This has been busted since commit
ff1ea2173 allowed views to acquire more columns, so back-patch to all
supported branches.

Discussion: https://postgr.es/m/20171026184035.1471.82810@wrigleys.postgresql.org

Branch
------
REL9_3_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9d15b8b36a9185f9990309770f480900310c75d4

Modified Files
--------------
src/backend/parser/parse_relation.c       | 12 ++++-
src/test/regress/expected/alter_table.out | 85 +++++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql      | 20 ++++++++
3 files changed, 116 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix crash when columns have been added to the end of a view.
@ 2017-10-27 21:29  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2017-10-27 21:29 UTC (permalink / raw)
  To: pgsql-committers

Fix crash when columns have been added to the end of a view.

expandRTE() supposed that an RTE_SUBQUERY subquery must have exactly
as many non-junk tlist items as the RTE has column aliases for it.
This was true at the time the code was written, and is still true so
far as parse analysis is concerned --- but when the function is used
during planning, the subquery might have appeared through insertion
of a view that now has more columns than it did when the outer query
was parsed.  This results in a core dump if, for instance, we have
to expand a whole-row Var that references the subquery.

To avoid crashing, we can either stop expanding the RTE when we run
out of aliases, or invent new aliases for the added columns.  While
the latter might be more useful, the former is consistent with what
expandRTE() does for composite-returning functions in the RTE_FUNCTION
case, so it seems like we'd better do it that way.

Per bug #14876 from Samuel Horwitz.  This has been busted since commit
ff1ea2173 allowed views to acquire more columns, so back-patch to all
supported branches.

Discussion: https://postgr.es/m/20171026184035.1471.82810@wrigleys.postgresql.org

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/66104119e1fbcfd8c8d9fe0c016e0349ff977ba4

Modified Files
--------------
src/backend/parser/parse_relation.c       | 12 ++++-
src/test/regress/expected/alter_table.out | 85 +++++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql      | 20 ++++++++
3 files changed, 116 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix crash when columns have been added to the end of a view.
@ 2017-10-27 21:29  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2017-10-27 21:29 UTC (permalink / raw)
  To: pgsql-committers

Fix crash when columns have been added to the end of a view.

expandRTE() supposed that an RTE_SUBQUERY subquery must have exactly
as many non-junk tlist items as the RTE has column aliases for it.
This was true at the time the code was written, and is still true so
far as parse analysis is concerned --- but when the function is used
during planning, the subquery might have appeared through insertion
of a view that now has more columns than it did when the outer query
was parsed.  This results in a core dump if, for instance, we have
to expand a whole-row Var that references the subquery.

To avoid crashing, we can either stop expanding the RTE when we run
out of aliases, or invent new aliases for the added columns.  While
the latter might be more useful, the former is consistent with what
expandRTE() does for composite-returning functions in the RTE_FUNCTION
case, so it seems like we'd better do it that way.

Per bug #14876 from Samuel Horwitz.  This has been busted since commit
ff1ea2173 allowed views to acquire more columns, so back-patch to all
supported branches.

Discussion: https://postgr.es/m/20171026184035.1471.82810@wrigleys.postgresql.org

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/7e5e8b36d47891c1ffa9f6c592f02be850684d68

Modified Files
--------------
src/backend/parser/parse_relation.c       | 12 ++++-
src/test/regress/expected/alter_table.out | 85 +++++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql      | 20 ++++++++
3 files changed, 116 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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

* pgsql: Fix crash when columns have been added to the end of a view.
@ 2017-10-27 21:29  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2017-10-27 21:29 UTC (permalink / raw)
  To: pgsql-committers

Fix crash when columns have been added to the end of a view.

expandRTE() supposed that an RTE_SUBQUERY subquery must have exactly
as many non-junk tlist items as the RTE has column aliases for it.
This was true at the time the code was written, and is still true so
far as parse analysis is concerned --- but when the function is used
during planning, the subquery might have appeared through insertion
of a view that now has more columns than it did when the outer query
was parsed.  This results in a core dump if, for instance, we have
to expand a whole-row Var that references the subquery.

To avoid crashing, we can either stop expanding the RTE when we run
out of aliases, or invent new aliases for the added columns.  While
the latter might be more useful, the former is consistent with what
expandRTE() does for composite-returning functions in the RTE_FUNCTION
case, so it seems like we'd better do it that way.

Per bug #14876 from Samuel Horwitz.  This has been busted since commit
ff1ea2173 allowed views to acquire more columns, so back-patch to all
supported branches.

Discussion: https://postgr.es/m/20171026184035.1471.82810@wrigleys.postgresql.org

Branch
------
master

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

Modified Files
--------------
src/backend/parser/parse_relation.c       | 12 ++++-
src/test/regress/expected/alter_table.out | 85 +++++++++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql      | 20 ++++++++
3 files changed, 116 insertions(+), 1 deletion(-)


-- 
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers


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


end of thread, other threads:[~2017-10-27 21:29 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-10-27 21:29 pgsql: Fix crash when columns have been added to the end of a view. Tom Lane <tgl@sss.pgh.pa.us>
2017-10-27 21:29 pgsql: Fix crash when columns have been added to the end of a view. Tom Lane <tgl@sss.pgh.pa.us>
2017-10-27 21:29 pgsql: Fix crash when columns have been added to the end of a view. Tom Lane <tgl@sss.pgh.pa.us>
2017-10-27 21:29 pgsql: Fix crash when columns have been added to the end of a view. Tom Lane <tgl@sss.pgh.pa.us>
2017-10-27 21:29 pgsql: Fix crash when columns have been added to the end of a view. Tom Lane <tgl@sss.pgh.pa.us>
2017-10-27 21:29 pgsql: Fix crash when columns have been added to the end of a view. Tom Lane <tgl@sss.pgh.pa.us>
2017-10-27 21:29 pgsql: Fix crash when columns have been added to the end of a view. 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