pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR
5+ messages / 1 participants
[nested] [flat]

* pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR
@ 2018-03-19 22:50  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-03-19 22:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURRENTLY.

refresh_by_match_merge() has some issues in the way it builds a SQL
query to construct the "diff" table:

1. It doesn't require the selected unique index(es) to be indimmediate.
2. It doesn't pay attention to the particular equality semantics enforced
by a given index, but just assumes that they must be those of the column
datatype's default btree opclass.
3. It doesn't check that the indexes are btrees.
4. It's insufficiently careful to ensure that the parser will pick the
intended operator when parsing the query.  (This would have been a
security bug before CVE-2018-1058.)
5. It's not careful about indexes on system columns.

The way to fix #4 is to make use of the existing code in ri_triggers.c
for generating an arbitrary binary operator clause.  I chose to move
that to ruleutils.c, since that seems a more reasonable place to be
exporting such functionality from than ri_triggers.c.

While #1, #3, and #5 are just latent given existing feature restrictions,
and #2 doesn't arise in the core system for lack of alternate opclasses
with different equality behaviors, #4 seems like an issue worth
back-patching.  That's the bulk of the change anyway, so just back-patch
the whole thing to 9.4 where this code was introduced.

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6497a18e6c1b5874566a77737ec3d381fded3ec2

Modified Files
--------------
src/backend/commands/matview.c      | 181 +++++++++++++++++++++++-------------
src/backend/utils/adt/ri_triggers.c |  69 ++------------
src/backend/utils/adt/ruleutils.c   |  80 ++++++++++++++++
src/include/utils/builtins.h        |   4 +
4 files changed, 207 insertions(+), 127 deletions(-)



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

* pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR
@ 2018-03-19 22:50  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-03-19 22:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURRENTLY.

refresh_by_match_merge() has some issues in the way it builds a SQL
query to construct the "diff" table:

1. It doesn't require the selected unique index(es) to be indimmediate.
2. It doesn't pay attention to the particular equality semantics enforced
by a given index, but just assumes that they must be those of the column
datatype's default btree opclass.
3. It doesn't check that the indexes are btrees.
4. It's insufficiently careful to ensure that the parser will pick the
intended operator when parsing the query.  (This would have been a
security bug before CVE-2018-1058.)
5. It's not careful about indexes on system columns.

The way to fix #4 is to make use of the existing code in ri_triggers.c
for generating an arbitrary binary operator clause.  I chose to move
that to ruleutils.c, since that seems a more reasonable place to be
exporting such functionality from than ri_triggers.c.

While #1, #3, and #5 are just latent given existing feature restrictions,
and #2 doesn't arise in the core system for lack of alternate opclasses
with different equality behaviors, #4 seems like an issue worth
back-patching.  That's the bulk of the change anyway, so just back-patch
the whole thing to 9.4 where this code was introduced.

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

Branch
------
REL_10_STABLE

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

Modified Files
--------------
src/backend/commands/matview.c      | 182 +++++++++++++++++++++++-------------
src/backend/utils/adt/ri_triggers.c |  69 ++------------
src/backend/utils/adt/ruleutils.c   |  80 ++++++++++++++++
src/include/utils/builtins.h        |   4 +
4 files changed, 208 insertions(+), 127 deletions(-)



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

* pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR
@ 2018-03-19 22:50  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-03-19 22:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURRENTLY.

refresh_by_match_merge() has some issues in the way it builds a SQL
query to construct the "diff" table:

1. It doesn't require the selected unique index(es) to be indimmediate.
2. It doesn't pay attention to the particular equality semantics enforced
by a given index, but just assumes that they must be those of the column
datatype's default btree opclass.
3. It doesn't check that the indexes are btrees.
4. It's insufficiently careful to ensure that the parser will pick the
intended operator when parsing the query.  (This would have been a
security bug before CVE-2018-1058.)
5. It's not careful about indexes on system columns.

The way to fix #4 is to make use of the existing code in ri_triggers.c
for generating an arbitrary binary operator clause.  I chose to move
that to ruleutils.c, since that seems a more reasonable place to be
exporting such functionality from than ri_triggers.c.

While #1, #3, and #5 are just latent given existing feature restrictions,
and #2 doesn't arise in the core system for lack of alternate opclasses
with different equality behaviors, #4 seems like an issue worth
back-patching.  That's the bulk of the change anyway, so just back-patch
the whole thing to 9.4 where this code was introduced.

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

Branch
------
REL9_4_STABLE

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

Modified Files
--------------
src/backend/commands/matview.c      | 161 +++++++++++++++++++++++++-----------
src/backend/utils/adt/ri_triggers.c |  69 ++--------------
src/backend/utils/adt/ruleutils.c   |  80 ++++++++++++++++++
src/include/utils/builtins.h        |   4 +
4 files changed, 203 insertions(+), 111 deletions(-)



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

* pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR
@ 2018-03-19 22:50  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-03-19 22:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURRENTLY.

refresh_by_match_merge() has some issues in the way it builds a SQL
query to construct the "diff" table:

1. It doesn't require the selected unique index(es) to be indimmediate.
2. It doesn't pay attention to the particular equality semantics enforced
by a given index, but just assumes that they must be those of the column
datatype's default btree opclass.
3. It doesn't check that the indexes are btrees.
4. It's insufficiently careful to ensure that the parser will pick the
intended operator when parsing the query.  (This would have been a
security bug before CVE-2018-1058.)
5. It's not careful about indexes on system columns.

The way to fix #4 is to make use of the existing code in ri_triggers.c
for generating an arbitrary binary operator clause.  I chose to move
that to ruleutils.c, since that seems a more reasonable place to be
exporting such functionality from than ri_triggers.c.

While #1, #3, and #5 are just latent given existing feature restrictions,
and #2 doesn't arise in the core system for lack of alternate opclasses
with different equality behaviors, #4 seems like an issue worth
back-patching.  That's the bulk of the change anyway, so just back-patch
the whole thing to 9.4 where this code was introduced.

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

Branch
------
REL9_5_STABLE

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

Modified Files
--------------
src/backend/commands/matview.c      | 161 +++++++++++++++++++++++++-----------
src/backend/utils/adt/ri_triggers.c |  69 ++--------------
src/backend/utils/adt/ruleutils.c   |  80 ++++++++++++++++++
src/include/utils/builtins.h        |   4 +
4 files changed, 203 insertions(+), 111 deletions(-)



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

* pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR
@ 2018-03-19 22:50  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-03-19 22:50 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURRENTLY.

refresh_by_match_merge() has some issues in the way it builds a SQL
query to construct the "diff" table:

1. It doesn't require the selected unique index(es) to be indimmediate.
2. It doesn't pay attention to the particular equality semantics enforced
by a given index, but just assumes that they must be those of the column
datatype's default btree opclass.
3. It doesn't check that the indexes are btrees.
4. It's insufficiently careful to ensure that the parser will pick the
intended operator when parsing the query.  (This would have been a
security bug before CVE-2018-1058.)
5. It's not careful about indexes on system columns.

The way to fix #4 is to make use of the existing code in ri_triggers.c
for generating an arbitrary binary operator clause.  I chose to move
that to ruleutils.c, since that seems a more reasonable place to be
exporting such functionality from than ri_triggers.c.

While #1, #3, and #5 are just latent given existing feature restrictions,
and #2 doesn't arise in the core system for lack of alternate opclasses
with different equality behaviors, #4 seems like an issue worth
back-patching.  That's the bulk of the change anyway, so just back-patch
the whole thing to 9.4 where this code was introduced.

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

Branch
------
REL9_6_STABLE

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

Modified Files
--------------
src/backend/commands/matview.c      | 182 +++++++++++++++++++++++-------------
src/backend/utils/adt/ri_triggers.c |  69 ++------------
src/backend/utils/adt/ruleutils.c   |  80 ++++++++++++++++
src/include/utils/builtins.h        |   4 +
4 files changed, 208 insertions(+), 127 deletions(-)



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


end of thread, other threads:[~2018-03-19 22:50 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-03-19 22:50 pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR Tom Lane <tgl@sss.pgh.pa.us>
2018-03-19 22:50 pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR Tom Lane <tgl@sss.pgh.pa.us>
2018-03-19 22:50 pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR Tom Lane <tgl@sss.pgh.pa.us>
2018-03-19 22:50 pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR Tom Lane <tgl@sss.pgh.pa.us>
2018-03-19 22:50 pgsql: Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURR 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