Re: pgsql: Track total number of WAL records, FPIs and bytes generated in t

2020-12-08 Thread Fujii Masao




On 2020/12/08 3:56, Andres Freund wrote:

Hi,

On 2020-12-02 04:04:57 +, Fujii Masao wrote:

Track total number of WAL records, FPIs and bytes generated in the cluster.

Commit 6b466bf5f2 allowed pg_stat_statements to track the number of
WAL records, full page images and bytes that each statement generated.
Similarly this commit allows us to track the cluster-wide WAL statistics
counters.

New columns wal_records, wal_fpi and wal_bytes are added into the
pg_stat_wal view, and reports the total number of WAL records,
full page images and bytes generated in the , respectively.

Author: Masahiro Ikeda
Reviewed-by: Amit Kapila, Movead Li, Kyotaro Horiguchi, Fujii Masao
Discussion: https://postgr.es/m/[email protected]



This is missing a catversion bump, due to the changes in view
names. Noticed that because I got errors like
  -- There must be only one record
  select count(*) = 1 as ok from pg_stat_wal;
- ok
-
- t
-(1 row)
-
+ERROR:  function return row and query-specified return row do not match
+DETAIL:  Returned row contains 5 attributes, but query expects 2.
  -- This is to record the prevailing planner enable_foo settings during
  -- a regression test run.

when running tests against a pre-existing cluster after rebasing a
development tree.


Thanks for reporting this! You are right.
Sorry I forgot to bump that. I will do that.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION




pgsql: Bump catversion for pg_stat_wal changes.

2020-12-08 Thread Fujii Masao
Bump catversion for pg_stat_wal changes.

Oversight in 01469241b2.

Reported-by: Andres Freund
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/4e43ee88c28b725bb63e27609c1a717138fc7f39

Modified Files
--
src/include/catalog/catversion.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



pgsql: Speed up rechecking if relation needs to be vacuumed or analyze

2020-12-08 Thread Fujii Masao
Speed up rechecking if relation needs to be vacuumed or analyze in autovacuum.

After autovacuum collects the relations to vacuum or analyze, it rechecks
whether each relation still needs to be vacuumed or analyzed before actually
doing that. Previously this recheck could be a significant overhead
especially when there were a very large number of relations. This was
because each recheck forced the statistics to be refreshed, and the refresh
of the statistics for a very large number of relations could cause heavy
overhead. There was the report that this issue caused autovacuum workers
to have gotten “stuck” in a tight loop of table_recheck_autovac() that
rechecks whether a relation needs to be vacuumed or analyzed.

This commit speeds up the recheck by making autovacuum worker reuse
the previously-read statistics for the recheck if possible. Then if that
"stale" statistics says that a relation still needs to be vacuumed or analyzed,
autovacuum refreshes the statistics and does the recheck again.

The benchmark shows that the more relations exist and autovacuum workers
are running concurrently, the more this change reduces the autovacuum
execution time. For example, when there are 20,000 tables and 10 autovacuum
workers are running, the benchmark showed that the change improved
the performance of autovacuum more than three times. On the other hand,
even when there are only 1000 tables and only a single autovacuum worker
is running, the benchmark didn't show any big performance regression by
the change.

Firstly POC patch was proposed by Jim Nasby. As the result of discussion,
we used Tatsuhito Kasahara's version of the patch using the approach
suggested by Tom Lane.

Reported-by: Jim Nasby
Author: Tatsuhito Kasahara
Reviewed-by: Masahiko Sawada, Fujii Masao
Discussion: https://postgr.es/m/[email protected]

Branch
--
master

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

Modified Files
--
src/backend/postmaster/autovacuum.c | 108 +---
1 file changed, 89 insertions(+), 19 deletions(-)



pgsql: Doc: explain that the string types can't store \0 (ASCII NUL).

2020-12-08 Thread Tom Lane
Doc: explain that the string types can't store \0 (ASCII NUL).

This restriction was mentioned in connection with string literals,
but it wasn't made clear that it's a general restriction not just
a syntactic limitation in query strings.

Per unsigned documentation comment.

Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL_11_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/10c601578a25a1811e68c30d2775952858672a15

Modified Files
--
doc/src/sgml/datatype.sgml | 13 +
1 file changed, 9 insertions(+), 4 deletions(-)



pgsql: Doc: explain that the string types can't store \0 (ASCII NUL).

2020-12-08 Thread Tom Lane
Doc: explain that the string types can't store \0 (ASCII NUL).

This restriction was mentioned in connection with string literals,
but it wasn't made clear that it's a general restriction not just
a syntactic limitation in query strings.

Per unsigned documentation comment.

Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL_10_STABLE

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

Modified Files
--
doc/src/sgml/datatype.sgml | 13 +
1 file changed, 9 insertions(+), 4 deletions(-)



pgsql: Doc: explain that the string types can't store \0 (ASCII NUL).

2020-12-08 Thread Tom Lane
Doc: explain that the string types can't store \0 (ASCII NUL).

This restriction was mentioned in connection with string literals,
but it wasn't made clear that it's a general restriction not just
a syntactic limitation in query strings.

Per unsigned documentation comment.

Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/101c8ae02cc007101bec711563655727f14efb0b

Modified Files
--
doc/src/sgml/datatype.sgml | 13 +
1 file changed, 9 insertions(+), 4 deletions(-)



pgsql: Doc: explain that the string types can't store \0 (ASCII NUL).

2020-12-08 Thread Tom Lane
Doc: explain that the string types can't store \0 (ASCII NUL).

This restriction was mentioned in connection with string literals,
but it wasn't made clear that it's a general restriction not just
a syntactic limitation in query strings.

Per unsigned documentation comment.

Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL9_5_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/0921b86ca1e451c70642c3007feb25f7efb34f65

Modified Files
--
doc/src/sgml/datatype.sgml | 13 +
1 file changed, 9 insertions(+), 4 deletions(-)



pgsql: Doc: explain that the string types can't store \0 (ASCII NUL).

2020-12-08 Thread Tom Lane
Doc: explain that the string types can't store \0 (ASCII NUL).

This restriction was mentioned in connection with string literals,
but it wasn't made clear that it's a general restriction not just
a syntactic limitation in query strings.

Per unsigned documentation comment.

Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL9_6_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/3410a9b57062609ecd823532847f622d862ba9ec

Modified Files
--
doc/src/sgml/datatype.sgml | 13 +
1 file changed, 9 insertions(+), 4 deletions(-)



pgsql: Doc: explain that the string types can't store \0 (ASCII NUL).

2020-12-08 Thread Tom Lane
Doc: explain that the string types can't store \0 (ASCII NUL).

This restriction was mentioned in connection with string literals,
but it wasn't made clear that it's a general restriction not just
a syntactic limitation in query strings.

Per unsigned documentation comment.

Discussion: 
https://postgr.es/m/[email protected]

Branch
--
master

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

Modified Files
--
doc/src/sgml/datatype.sgml | 13 +
1 file changed, 9 insertions(+), 4 deletions(-)



pgsql: Doc: explain that the string types can't store \0 (ASCII NUL).

2020-12-08 Thread Tom Lane
Doc: explain that the string types can't store \0 (ASCII NUL).

This restriction was mentioned in connection with string literals,
but it wasn't made clear that it's a general restriction not just
a syntactic limitation in query strings.

Per unsigned documentation comment.

Discussion: 
https://postgr.es/m/[email protected]

Branch
--
REL_13_STABLE

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

Modified Files
--
doc/src/sgml/datatype.sgml | 13 +
1 file changed, 9 insertions(+), 4 deletions(-)



pgsql: Doc: clarify that CREATE TABLE discards redundant unique constra

2020-12-08 Thread Tom Lane
Doc: clarify that CREATE TABLE discards redundant unique constraints.

The SQL standard says that redundant unique constraints are disallowed,
but we long ago decided that throwing an error would be too
user-unfriendly, so we just drop redundant ones.  The docs weren't very
clear about that though, as this behavior was only explained for PRIMARY
KEY vs UNIQUE, not UNIQUE vs UNIQUE.

While here, I couldn't resist doing some copy-editing and markup-fixing
on the adjacent text about INCLUDE options.

Per bug #16767 from Matthias vd Meent.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL9_6_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/2bf5d1a74a33ed45939ed4c16054aee51ab65540

Modified Files
--
doc/src/sgml/ref/create_table.sgml | 22 +++---
1 file changed, 15 insertions(+), 7 deletions(-)



pgsql: Doc: clarify that CREATE TABLE discards redundant unique constra

2020-12-08 Thread Tom Lane
Doc: clarify that CREATE TABLE discards redundant unique constraints.

The SQL standard says that redundant unique constraints are disallowed,
but we long ago decided that throwing an error would be too
user-unfriendly, so we just drop redundant ones.  The docs weren't very
clear about that though, as this behavior was only explained for PRIMARY
KEY vs UNIQUE, not UNIQUE vs UNIQUE.

While here, I couldn't resist doing some copy-editing and markup-fixing
on the adjacent text about INCLUDE options.

Per bug #16767 from Matthias vd Meent.

Discussion: https://postgr.es/m/[email protected]

Branch
--
master

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

Modified Files
--
doc/src/sgml/ref/create_table.sgml | 58 +++---
1 file changed, 36 insertions(+), 22 deletions(-)



pgsql: Doc: clarify that CREATE TABLE discards redundant unique constra

2020-12-08 Thread Tom Lane
Doc: clarify that CREATE TABLE discards redundant unique constraints.

The SQL standard says that redundant unique constraints are disallowed,
but we long ago decided that throwing an error would be too
user-unfriendly, so we just drop redundant ones.  The docs weren't very
clear about that though, as this behavior was only explained for PRIMARY
KEY vs UNIQUE, not UNIQUE vs UNIQUE.

While here, I couldn't resist doing some copy-editing and markup-fixing
on the adjacent text about INCLUDE options.

Per bug #16767 from Matthias vd Meent.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL_11_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/5303706b320864332abd99b666a466863ffece22

Modified Files
--
doc/src/sgml/ref/create_table.sgml | 58 +++---
1 file changed, 36 insertions(+), 22 deletions(-)



pgsql: Doc: clarify that CREATE TABLE discards redundant unique constra

2020-12-08 Thread Tom Lane
Doc: clarify that CREATE TABLE discards redundant unique constraints.

The SQL standard says that redundant unique constraints are disallowed,
but we long ago decided that throwing an error would be too
user-unfriendly, so we just drop redundant ones.  The docs weren't very
clear about that though, as this behavior was only explained for PRIMARY
KEY vs UNIQUE, not UNIQUE vs UNIQUE.

While here, I couldn't resist doing some copy-editing and markup-fixing
on the adjacent text about INCLUDE options.

Per bug #16767 from Matthias vd Meent.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL9_5_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/14db9579222138b3fba2f73c285ff3f9e4bf9465

Modified Files
--
doc/src/sgml/ref/create_table.sgml | 22 +++---
1 file changed, 15 insertions(+), 7 deletions(-)



pgsql: Doc: clarify that CREATE TABLE discards redundant unique constra

2020-12-08 Thread Tom Lane
Doc: clarify that CREATE TABLE discards redundant unique constraints.

The SQL standard says that redundant unique constraints are disallowed,
but we long ago decided that throwing an error would be too
user-unfriendly, so we just drop redundant ones.  The docs weren't very
clear about that though, as this behavior was only explained for PRIMARY
KEY vs UNIQUE, not UNIQUE vs UNIQUE.

While here, I couldn't resist doing some copy-editing and markup-fixing
on the adjacent text about INCLUDE options.

Per bug #16767 from Matthias vd Meent.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL_13_STABLE

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

Modified Files
--
doc/src/sgml/ref/create_table.sgml | 58 +++---
1 file changed, 36 insertions(+), 22 deletions(-)



pgsql: Doc: clarify that CREATE TABLE discards redundant unique constra

2020-12-08 Thread Tom Lane
Doc: clarify that CREATE TABLE discards redundant unique constraints.

The SQL standard says that redundant unique constraints are disallowed,
but we long ago decided that throwing an error would be too
user-unfriendly, so we just drop redundant ones.  The docs weren't very
clear about that though, as this behavior was only explained for PRIMARY
KEY vs UNIQUE, not UNIQUE vs UNIQUE.

While here, I couldn't resist doing some copy-editing and markup-fixing
on the adjacent text about INCLUDE options.

Per bug #16767 from Matthias vd Meent.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL_10_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/567d6d1ff6173cae02a4b89b4283137bf56caf97

Modified Files
--
doc/src/sgml/ref/create_table.sgml | 22 +++---
1 file changed, 15 insertions(+), 7 deletions(-)



pgsql: Doc: clarify that CREATE TABLE discards redundant unique constra

2020-12-08 Thread Tom Lane
Doc: clarify that CREATE TABLE discards redundant unique constraints.

The SQL standard says that redundant unique constraints are disallowed,
but we long ago decided that throwing an error would be too
user-unfriendly, so we just drop redundant ones.  The docs weren't very
clear about that though, as this behavior was only explained for PRIMARY
KEY vs UNIQUE, not UNIQUE vs UNIQUE.

While here, I couldn't resist doing some copy-editing and markup-fixing
on the adjacent text about INCLUDE options.

Per bug #16767 from Matthias vd Meent.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL_12_STABLE

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

Modified Files
--
doc/src/sgml/ref/create_table.sgml | 58 +++---
1 file changed, 36 insertions(+), 22 deletions(-)



pgsql: Improve estimation of OR clauses using multiple extended statist

2020-12-08 Thread Dean Rasheed
Improve estimation of OR clauses using multiple extended statistics.

When estimating an OR clause using multiple extended statistics
objects, treat the estimates for each set of clauses for each
statistics object as independent of one another. The overlap estimates
produced for each statistics object do not apply to clauses covered by
other statistics objects.

Dean Rasheed, reviewed by Tomas Vondra.

Discussion: 
https://postgr.es/m/CAEZATCW=J65GUFm50RcPv-iASnS2mTXQbr=cfbvwrvhflj_...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/88b0898fe35a5a0325fca21bd4f3ed6dffb364c1

Modified Files
--
src/backend/statistics/extended_stats.c | 25 +
src/test/regress/expected/stats_ext.out |  2 +-
2 files changed, 18 insertions(+), 9 deletions(-)



pgsql: Improve estimation of ANDs under ORs using extended statistics.

2020-12-08 Thread Dean Rasheed
Improve estimation of ANDs under ORs using extended statistics.

Formerly, extended statistics only handled clauses that were
RestrictInfos. However, the restrictinfo machinery doesn't create
sub-AND RestrictInfos for AND clauses underneath OR clauses.
Therefore teach extended statistics to handle bare AND clauses,
looking for compatible RestrictInfo clauses underneath them.

Dean Rasheed, reviewed by Tomas Vondra.

Discussion: 
https://postgr.es/m/CAEZATCW=J65GUFm50RcPv-iASnS2mTXQbr=cfbvwrvhflj_...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/4f5760d4afa9423fe4d38e4cbec48bf5e793e7e5

Modified Files
--
src/backend/optimizer/path/clausesel.c  | 21 +
src/backend/statistics/extended_stats.c | 25 +
src/test/regress/expected/stats_ext.out |  4 ++--
3 files changed, 48 insertions(+), 2 deletions(-)



pgsql: Remove operator_precedence_warning.

2020-12-08 Thread Tom Lane
Remove operator_precedence_warning.

This GUC was always intended as a temporary solution to help with
finding 9.4-to-9.5 migration issues.  Now that all pre-9.5 branches
are out of support, and 9.5 will be too before v14 is released,
it seems like it's okay to drop it.  Doing so allows removal of
several hundred lines of poorly-tested code in parse_expr.c,
which have been a fertile source of bugs when people did use this.

Discussion: https://postgr.es/m/[email protected]

Branch
--
master

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

Modified Files
--
doc/src/sgml/config.sgml  |  23 --
doc/src/sgml/syntax.sgml  |   6 +-
src/backend/nodes/outfuncs.c  |   3 -
src/backend/parser/gram.y |  43 +--
src/backend/parser/parse_expr.c   | 450 +-
src/backend/parser/parse_target.c |   5 -
src/backend/utils/misc/guc.c  |  10 -
src/backend/utils/misc/postgresql.conf.sample |   1 -
src/include/nodes/parsenodes.h|   3 +-
src/include/parser/parse_expr.h   |   1 -
10 files changed, 10 insertions(+), 535 deletions(-)



pgsql: Teach contain_leaked_vars that assignment SubscriptingRefs are l

2020-12-08 Thread Tom Lane
Teach contain_leaked_vars that assignment SubscriptingRefs are leaky.

array_get_element and array_get_slice qualify as leakproof, since
they will silently return NULL for bogus subscripts.  But
array_set_element and array_set_slice throw errors for such cases,
making them clearly not leakproof.  contain_leaked_vars was evidently
written with only the former case in mind, as it gave the wrong answer
for assignment SubscriptingRefs (nee ArrayRefs).

This would be a live security bug, were it not that assignment
SubscriptingRefs can only occur in INSERT and UPDATE target lists,
while we only care about leakproofness for qual expressions; so the
wrong answer can't occur in practice.  Still, that's a rather shaky
answer for a security-related question; and maybe in future somebody
will want to ask about leakproofness of a tlist.  So it seems wise to
fix and even back-patch this correction.

(We would need some change here anyway for the upcoming
generic-subscripting patch, since extensions might make different
tradeoffs about whether to throw errors.  Commit 558d77f20 attempted
to lay groundwork for that by asking check_functions_in_node whether a
SubscriptingRef contains leaky functions; but that idea fails now that
the implementation methods of a SubscriptingRef are not SQL-visible
functions that could be marked leakproof or not.)

Back-patch to 9.6.  While 9.5 has the same issue, the code's a bit
different.  It seems quite unlikely that we'd introduce any actual bug
in the short time 9.5 has left to live, so the work/risk/reward balance
isn't attractive for changing 9.5.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL_11_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/1f229f4fdcf88d8fe7cb0b7442a4894cd4d1c47c

Modified Files
--
src/backend/optimizer/util/clauses.c | 18 +-
1 file changed, 17 insertions(+), 1 deletion(-)



pgsql: Teach contain_leaked_vars that assignment SubscriptingRefs are l

2020-12-08 Thread Tom Lane
Teach contain_leaked_vars that assignment SubscriptingRefs are leaky.

array_get_element and array_get_slice qualify as leakproof, since
they will silently return NULL for bogus subscripts.  But
array_set_element and array_set_slice throw errors for such cases,
making them clearly not leakproof.  contain_leaked_vars was evidently
written with only the former case in mind, as it gave the wrong answer
for assignment SubscriptingRefs (nee ArrayRefs).

This would be a live security bug, were it not that assignment
SubscriptingRefs can only occur in INSERT and UPDATE target lists,
while we only care about leakproofness for qual expressions; so the
wrong answer can't occur in practice.  Still, that's a rather shaky
answer for a security-related question; and maybe in future somebody
will want to ask about leakproofness of a tlist.  So it seems wise to
fix and even back-patch this correction.

(We would need some change here anyway for the upcoming
generic-subscripting patch, since extensions might make different
tradeoffs about whether to throw errors.  Commit 558d77f20 attempted
to lay groundwork for that by asking check_functions_in_node whether a
SubscriptingRef contains leaky functions; but that idea fails now that
the implementation methods of a SubscriptingRef are not SQL-visible
functions that could be marked leakproof or not.)

Back-patch to 9.6.  While 9.5 has the same issue, the code's a bit
different.  It seems quite unlikely that we'd introduce any actual bug
in the short time 9.5 has left to live, so the work/risk/reward balance
isn't attractive for changing 9.5.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL9_6_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/17c77c8c90f7c566a8f42e0809e425072d8f26b7

Modified Files
--
src/backend/optimizer/util/clauses.c | 18 +-
1 file changed, 17 insertions(+), 1 deletion(-)



pgsql: Teach contain_leaked_vars that assignment SubscriptingRefs are l

2020-12-08 Thread Tom Lane
Teach contain_leaked_vars that assignment SubscriptingRefs are leaky.

array_get_element and array_get_slice qualify as leakproof, since
they will silently return NULL for bogus subscripts.  But
array_set_element and array_set_slice throw errors for such cases,
making them clearly not leakproof.  contain_leaked_vars was evidently
written with only the former case in mind, as it gave the wrong answer
for assignment SubscriptingRefs (nee ArrayRefs).

This would be a live security bug, were it not that assignment
SubscriptingRefs can only occur in INSERT and UPDATE target lists,
while we only care about leakproofness for qual expressions; so the
wrong answer can't occur in practice.  Still, that's a rather shaky
answer for a security-related question; and maybe in future somebody
will want to ask about leakproofness of a tlist.  So it seems wise to
fix and even back-patch this correction.

(We would need some change here anyway for the upcoming
generic-subscripting patch, since extensions might make different
tradeoffs about whether to throw errors.  Commit 558d77f20 attempted
to lay groundwork for that by asking check_functions_in_node whether a
SubscriptingRef contains leaky functions; but that idea fails now that
the implementation methods of a SubscriptingRef are not SQL-visible
functions that could be marked leakproof or not.)

Back-patch to 9.6.  While 9.5 has the same issue, the code's a bit
different.  It seems quite unlikely that we'd introduce any actual bug
in the short time 9.5 has left to live, so the work/risk/reward balance
isn't attractive for changing 9.5.

Discussion: https://postgr.es/m/[email protected]

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/62ee70331336161cb44733b6c3e0811696d962aa

Modified Files
--
src/backend/optimizer/util/clauses.c | 18 +-
1 file changed, 17 insertions(+), 1 deletion(-)



pgsql: Teach contain_leaked_vars that assignment SubscriptingRefs are l

2020-12-08 Thread Tom Lane
Teach contain_leaked_vars that assignment SubscriptingRefs are leaky.

array_get_element and array_get_slice qualify as leakproof, since
they will silently return NULL for bogus subscripts.  But
array_set_element and array_set_slice throw errors for such cases,
making them clearly not leakproof.  contain_leaked_vars was evidently
written with only the former case in mind, as it gave the wrong answer
for assignment SubscriptingRefs (nee ArrayRefs).

This would be a live security bug, were it not that assignment
SubscriptingRefs can only occur in INSERT and UPDATE target lists,
while we only care about leakproofness for qual expressions; so the
wrong answer can't occur in practice.  Still, that's a rather shaky
answer for a security-related question; and maybe in future somebody
will want to ask about leakproofness of a tlist.  So it seems wise to
fix and even back-patch this correction.

(We would need some change here anyway for the upcoming
generic-subscripting patch, since extensions might make different
tradeoffs about whether to throw errors.  Commit 558d77f20 attempted
to lay groundwork for that by asking check_functions_in_node whether a
SubscriptingRef contains leaky functions; but that idea fails now that
the implementation methods of a SubscriptingRef are not SQL-visible
functions that could be marked leakproof or not.)

Back-patch to 9.6.  While 9.5 has the same issue, the code's a bit
different.  It seems quite unlikely that we'd introduce any actual bug
in the short time 9.5 has left to live, so the work/risk/reward balance
isn't attractive for changing 9.5.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL_10_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/3470caa21bf84e808ed9d28822e3692fe9d18c06

Modified Files
--
src/backend/optimizer/util/clauses.c | 18 +-
1 file changed, 17 insertions(+), 1 deletion(-)



pgsql: Teach contain_leaked_vars that assignment SubscriptingRefs are l

2020-12-08 Thread Tom Lane
Teach contain_leaked_vars that assignment SubscriptingRefs are leaky.

array_get_element and array_get_slice qualify as leakproof, since
they will silently return NULL for bogus subscripts.  But
array_set_element and array_set_slice throw errors for such cases,
making them clearly not leakproof.  contain_leaked_vars was evidently
written with only the former case in mind, as it gave the wrong answer
for assignment SubscriptingRefs (nee ArrayRefs).

This would be a live security bug, were it not that assignment
SubscriptingRefs can only occur in INSERT and UPDATE target lists,
while we only care about leakproofness for qual expressions; so the
wrong answer can't occur in practice.  Still, that's a rather shaky
answer for a security-related question; and maybe in future somebody
will want to ask about leakproofness of a tlist.  So it seems wise to
fix and even back-patch this correction.

(We would need some change here anyway for the upcoming
generic-subscripting patch, since extensions might make different
tradeoffs about whether to throw errors.  Commit 558d77f20 attempted
to lay groundwork for that by asking check_functions_in_node whether a
SubscriptingRef contains leaky functions; but that idea fails now that
the implementation methods of a SubscriptingRef are not SQL-visible
functions that could be marked leakproof or not.)

Back-patch to 9.6.  While 9.5 has the same issue, the code's a bit
different.  It seems quite unlikely that we'd introduce any actual bug
in the short time 9.5 has left to live, so the work/risk/reward balance
isn't attractive for changing 9.5.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL_12_STABLE

Details
---
https://git.postgresql.org/pg/commitdiff/2f1997b1551a417b52d75621817a813f5171c48f

Modified Files
--
src/backend/optimizer/util/clauses.c | 18 +-
1 file changed, 17 insertions(+), 1 deletion(-)



pgsql: Teach contain_leaked_vars that assignment SubscriptingRefs are l

2020-12-08 Thread Tom Lane
Teach contain_leaked_vars that assignment SubscriptingRefs are leaky.

array_get_element and array_get_slice qualify as leakproof, since
they will silently return NULL for bogus subscripts.  But
array_set_element and array_set_slice throw errors for such cases,
making them clearly not leakproof.  contain_leaked_vars was evidently
written with only the former case in mind, as it gave the wrong answer
for assignment SubscriptingRefs (nee ArrayRefs).

This would be a live security bug, were it not that assignment
SubscriptingRefs can only occur in INSERT and UPDATE target lists,
while we only care about leakproofness for qual expressions; so the
wrong answer can't occur in practice.  Still, that's a rather shaky
answer for a security-related question; and maybe in future somebody
will want to ask about leakproofness of a tlist.  So it seems wise to
fix and even back-patch this correction.

(We would need some change here anyway for the upcoming
generic-subscripting patch, since extensions might make different
tradeoffs about whether to throw errors.  Commit 558d77f20 attempted
to lay groundwork for that by asking check_functions_in_node whether a
SubscriptingRef contains leaky functions; but that idea fails now that
the implementation methods of a SubscriptingRef are not SQL-visible
functions that could be marked leakproof or not.)

Back-patch to 9.6.  While 9.5 has the same issue, the code's a bit
different.  It seems quite unlikely that we'd introduce any actual bug
in the short time 9.5 has left to live, so the work/risk/reward balance
isn't attractive for changing 9.5.

Discussion: https://postgr.es/m/[email protected]

Branch
--
REL_13_STABLE

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

Modified Files
--
src/backend/optimizer/util/clauses.c | 18 +-
1 file changed, 17 insertions(+), 1 deletion(-)



pgsql: jit: Reference function pointer types via llvmjit_types.c.

2020-12-08 Thread Andres Freund
jit: Reference function pointer types via llvmjit_types.c.

It is error prone (see 5da871bfa1b) and verbose to manually create function
types. Add a helper that can reference a function pointer type via
llvmjit_types.c and and convert existing instances of manual creation.

Author: Andres Freund 
Reviewed-By: Tom Lane 
Discussion: 
https://postgr.es/m/[email protected]

Branch
--
master

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

Modified Files
--
src/backend/jit/llvm/llvmjit.c   | 95 ++--
src/backend/jit/llvm/llvmjit_expr.c  | 33 +++--
src/backend/jit/llvm/llvmjit_types.c |  2 +
src/include/jit/llvmjit.h|  2 +
4 files changed, 69 insertions(+), 63 deletions(-)



pgsql: Simplify code for getting a unicode codepoint's canonical class.

2020-12-08 Thread Michael Paquier
Simplify code for getting a unicode codepoint's canonical class.

Three places of unicode_norm.c use a similar logic for getting the
combining class from a codepoint.  Commit 2991ac5 has added the function
get_canonical_class() for this purpose, but it was only called by the
backend.  This commit refactors the code to use this function in all
the places where the combining class is retrieved from a given
codepoint.

Author: John Naylor
Discussion: 
https://postgr.es/m/cafbsxshuv7s7yrom6hfz-jq8sc7k_yxtkfnzxsdv-dum-k-...@mail.gmail.com

Branch
--
master

Details
---
https://git.postgresql.org/pg/commitdiff/16c302f51235eaec05a1f85a11c1df04ef3a6785

Modified Files
--
src/common/unicode_norm.c | 47 ++-
1 file changed, 22 insertions(+), 25 deletions(-)