postgresql/src/backend/utils/adt
Dean Rasheed 01256815a6 Use checkAsUser for selectivity estimator checks, if it's set.
In examine_variable() and examine_simple_variable(), when checking the
user's table and column privileges to determine whether to grant
access to the pg_statistic data, use checkAsUser for the privilege
checks, if it's set. This will be the case if we're accessing the
table via a view, to indicate that we should perform privilege checks
as the view owner rather than the current user.

This change makes this planner check consistent with the check in the
executor, so the planner will be able to make use of statistics if the
table is accessible via the view. This fixes a performance regression
introduced by commit e2d4ef8de8, which affects queries against
non-security barrier views in the case where the user doesn't have
privileges on the underlying table, but the view owner does.

Note that it continues to provide the same safeguards controlling
access to pg_statistic for direct table access (in which case
checkAsUser won't be set) and for security barrier views, because of
the nearby checks on rte->security_barrier and rte->securityQuals.

Back-patch to all supported branches because e2d4ef8de8 was.

Dean Rasheed, reviewed by Jonathan Katz and Stephen Frost.
2019-05-06 12:01:44 +01:00
..
acl.c Fix corner-case failures in has_foo_privilege() family of functions. 2018-10-02 11:54:13 -04:00
array_expanded.c Support "expanded" objects, particularly arrays, for better performance. 2015-05-14 12:08:49 -04:00
array_selfuncs.c Add security checks to selectivity estimation functions 2017-05-08 09:19:07 -04:00
array_typanalyze.c Collection of typo fixes. 2015-05-20 16:56:22 +03:00
array_userfuncs.c Fix crasher bug in array_position(s) 2016-12-09 12:42:17 -03:00
arrayfuncs.c Fix over-allocation of space for array_out()'s result string. 2018-09-24 11:30:51 -04:00
arrayutils.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
ascii.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
bool.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
cash.c Fix precision and rounding issues in money multiplication and division. 2017-05-21 13:05:17 -04:00
char.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
date.c Fix incorrect translation of minus-infinity datetimes for json/jsonb. 2015-10-20 11:07:05 -07:00
datetime.c Update time zone data files to tzdata release 2018e. 2018-05-09 13:55:54 -04:00
datum.c Support "expanded" objects, particularly arrays, for better performance. 2015-05-14 12:08:49 -04:00
dbsize.c Fix new warnings from GCC 7 2017-05-16 08:43:55 -04:00
domains.c Fix handling of expanded objects in CoerceToDomain and CASE execution. 2016-12-22 15:01:39 -05:00
encode.c Rename base64 routines to avoid conflict with Solaris built-in functions. 2018-02-28 18:33:45 -05:00
enum.c Remove enum-related special cases for catalog scans. 2015-04-29 15:48:44 -04:00
expandeddatum.c Support "expanded" objects, particularly arrays, for better performance. 2015-05-14 12:08:49 -04:00
float.c Fix float-to-integer coercions to handle edge cases correctly. 2018-11-24 12:45:50 -05:00
format_type.c Allow on-the-fly capture of DDL event details 2015-05-11 19:14:31 -03:00
formatting.c Fix typos in comments. 2017-02-06 11:34:18 +02:00
genfile.c Add missing_ok option to the SQL functions for reading files. 2015-06-28 21:35:46 +03:00
geo_ops.c Fix crash in close_ps() for NaN input coordinates. 2016-07-16 14:42:37 -04:00
geo_selfuncs.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
inet_cidr_ntop.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
inet_net_pton.c Fix validation of overly-long IPv6 addresses. 2016-06-16 17:16:40 -04:00
int.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
int8.c Fix float-to-integer coercions to handle edge cases correctly. 2018-11-24 12:45:50 -05:00
json.c Process variadic arguments consistently in json functions 2017-10-25 07:49:13 -04:00
jsonb.c Process variadic arguments consistently in json functions 2017-10-25 07:49:13 -04:00
jsonb_gin.c Fix erroneous hash calculations in gin_extract_jsonb_path(). 2015-11-05 18:15:48 -05:00
jsonb_op.c Use JsonbIteratorToken consistently in automatic variable declarations. 2015-10-12 10:10:51 -04:00
jsonb_util.c Use JsonbIteratorToken consistently in automatic variable declarations. 2015-10-12 10:10:51 -04:00
jsonfuncs.c Make json{b}_populate_recordset() use the right tuple descriptor. 2017-11-06 10:29:40 -05:00
levenshtein.c Remove new coupling between NAMEDATALEN and MAX_LEVENSHTEIN_STRLEN. 2016-01-22 11:53:06 -05:00
like.c Add recursion depth protection to LIKE matching. 2015-10-02 15:00:52 -04:00
like_match.c Add recursion depth protection to LIKE matching. 2015-10-02 15:00:52 -04:00
lockfuncs.c pgindent run for 9.5 2015-05-23 21:35:49 -04:00
mac.c Allow input format xxxx-xxxx-xxxx for macaddr type 2014-10-21 16:16:39 -04:00
Makefile Support "expanded" objects, particularly arrays, for better performance. 2015-05-14 12:08:49 -04:00
misc.c Message style improvements 2015-10-28 20:23:53 -04:00
nabstime.c Avoid statically allocating gmtsub()'s timezone workspace. 2018-10-16 11:50:19 -04:00
name.c Add new OID alias type regrole 2015-05-09 13:06:49 -04:00
network.c Fix assorted issues in convert_to_scalar(). 2018-03-03 20:31:35 -05:00
network_gist.c pgindent run for 9.5 2015-05-23 21:35:49 -04:00
network_selfuncs.c Provide real selectivity estimators for inet/cidr operators. 2015-04-01 17:11:21 -04:00
numeric.c Fix behavior when converting a float infinity to numeric. 2017-09-27 17:05:53 -04:00
numutils.c Define integer limits independently from the system definitions. 2015-04-02 17:43:35 +02:00
oid.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
oracle_compat.c Remove spurious semicolons. 2015-03-31 15:12:27 +03:00
orderedsetaggs.c Fix actual and potential double-frees around tuplesort usage. 2018-03-28 13:26:43 -04:00
pg_locale.c Repair assorted issues in locale data extraction. 2019-04-23 18:51:31 -04:00
pg_lsn.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
pg_upgrade_support.c Guard against null arguments in binary_upgrade_create_empty_extension(). 2016-01-03 16:26:38 -05:00
pgstatfuncs.c Fix miserable coding in pg_stat_get_activity(). 2016-09-10 13:49:04 -04:00
pseudotypes.c Redesign tablesample method API, and do extensive code review. 2015-07-25 14:39:00 -04:00
quote.c Fix off-by-one in memory allocation for quote_literal_cstr(). 2016-12-16 12:53:12 +02:00
rangetypes.c Prevent stack overflow in container-type functions. 2015-10-05 10:06:33 -04:00
rangetypes_gist.c Move strategy numbers to include/access/stratnum.h 2015-05-15 17:03:16 -03:00
rangetypes_selfuncs.c Further patch rangetypes_selfuncs.c's statistics slot management. 2017-05-08 15:02:58 -04:00
rangetypes_spgist.c pgindent run for 9.5 2015-05-23 21:35:49 -04:00
rangetypes_typanalyze.c Fix misestimation of n_distinct for a nearly-unique column with many nulls. 2016-08-07 18:52:02 -04:00
regexp.c Repair bug in regexp split performance improvements. 2018-09-12 19:52:10 +01:00
regproc.c Tighten checks for whitespace in functions that parse identifiers etc. 2017-05-24 15:28:35 -04:00
ri_triggers.c Fix some corner-case issues in REFRESH MATERIALIZED VIEW CONCURRENTLY. 2018-03-19 18:49:53 -04:00
rowtypes.c Prevent stack overflow in container-type functions. 2015-10-05 10:06:33 -04:00
ruleutils.c Further fixes for quoted-list GUC values in pg_dump and ruleutils.c. 2018-07-31 13:00:08 -04:00
selfuncs.c Use checkAsUser for selectivity estimator checks, if it's set. 2019-05-06 12:01:44 +01:00
tid.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
timestamp.c Avoid statically allocating gmtsub()'s timezone workspace. 2018-10-16 11:50:19 -04:00
trigfuncs.c Use FLEXIBLE_ARRAY_MEMBER for HeapTupleHeaderData.t_bits[]. 2015-02-21 15:13:06 -05:00
tsginidx.c Move strategy numbers to include/access/stratnum.h 2015-05-15 17:03:16 -03:00
tsgistidx.c Reorganize our CRC source files again. 2015-04-14 17:03:42 +03:00
tsquery.c Reorganize our CRC source files again. 2015-04-14 17:03:42 +03:00
tsquery_cleanup.c Prevent stack overflow in query-type functions. 2015-10-05 10:06:33 -04:00
tsquery_gist.c Move strategy numbers to include/access/stratnum.h 2015-05-15 17:03:16 -03:00
tsquery_op.c pgindent run for 9.5 2015-05-23 21:35:49 -04:00
tsquery_rewrite.c Prevent crash when ts_rewrite() replaces a non-top-level subtree with null. 2016-12-11 13:09:57 -05:00
tsquery_util.c Fix bogus tree-flattening logic in QTNTernary(). 2016-10-30 15:24:40 -04:00
tsrank.c Fix typos in comments. 2017-02-06 11:34:18 +02:00
tsvector.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
tsvector_op.c Ensure that a tsquery like '!foo' matches empty tsvectors. 2017-01-26 12:17:47 -05:00
tsvector_parser.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
txid.c Fix a number of places that produced XX000 errors in the regression tests. 2015-08-02 23:49:19 -04:00
uuid.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
varbit.c Fix assorted integer-overflow hazards in varbit.c. 2016-10-14 16:28:34 -04:00
varchar.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
varlena.c Further fixes for quoted-list GUC values in pg_dump and ruleutils.c. 2018-07-31 13:00:08 -04:00
version.c Update copyright for 2015 2015-01-06 11:43:47 -05:00
windowfuncs.c Fix typos in comments. 2017-02-06 11:34:18 +02:00
xid.c Fix cidin() to handle values above 2^31 platform-independently. 2016-10-18 12:24:58 -04:00
xml.c Remove inadequate check for duplicate "xml" PI. 2019-03-23 17:40:19 -04:00