summaryrefslogtreecommitdiff
path: root/src/include/utils/builtins.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-03-19 18:49:53 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-03-19 18:49:53 -0400
commit7d7b59aa65918f59e3c122318b31e0f77f12f2cd (patch)
tree07eac559504eaf987d41917c25727bbb25b0062d /src/include/utils/builtins.h
parentebcf34d4628e175a7f35714ccec561b596fe6d0f (diff)
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
Diffstat (limited to 'src/include/utils/builtins.h')
-rw-r--r--src/include/utils/builtins.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index b6711df31d4..22cb3a68592 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -744,6 +744,10 @@ extern Datum pg_get_function_arg_default(PG_FUNCTION_ARGS);
extern const char *quote_identifier(const char *ident);
extern char *quote_qualified_identifier(const char *qualifier,
const char *ident);
+extern void generate_operator_clause(fmStringInfo buf,
+ const char *leftop, Oid leftoptype,
+ Oid opoid,
+ const char *rightop, Oid rightoptype);
/* tid.c */