summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane2023-10-20 16:28:38 +0000
committerTom Lane2023-10-20 16:28:46 +0000
commit2b5154beab794eae6e624c162d497df927ec9d27 (patch)
tree0b5dc8a146130bb47be791ecce3d174b1d81e341 /src/include
parentdcd4454590e77dc90c28ce4b4a4b62369bbc03e2 (diff)
Extend ALTER OPERATOR to allow setting more optimization attributes.
Allow the COMMUTATOR, NEGATOR, MERGES, and HASHES attributes to be set by ALTER OPERATOR. However, we don't allow COMMUTATOR/NEGATOR to be changed once set, nor allow the MERGES/HASHES flags to be unset once set. Changes like that might invalidate plans already made, and dealing with the consequences seems like more trouble than it's worth. The main use-case we foresee for this is to allow addition of missed properties in extension update scripts, such as extending an existing operator to support hashing. So only transitions from not-set to set states seem very useful. This patch also causes us to reject some incorrect cases that formerly resulted in inconsistent catalog state, such as trying to set the commutator of an operator to be some other operator that already has a (different) commutator. While at it, move the InvokeObjectPostCreateHook call for CREATE OPERATOR to not occur until after we've fixed up commutator or negator links as needed. The previous ordering could only be justified by thinking of the OperatorUpd call as a kind of ALTER OPERATOR step; but we don't call InvokeObjectPostAlterHook therein. It seems better to let the hook see the final state of the operator object. In the documentation, move the discussion of how to establish commutator pairs from xoper.sgml to the CREATE OPERATOR ref page. Tommy Pavlicek, reviewed and editorialized a bit by me Discussion: https://postgr.es/m/CAEhP-W-vGVzf4udhR5M8Bdv88UYnPrhoSkj3ieR3QNrsGQoqdg@mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/pg_operator.h15
-rw-r--r--src/include/parser/parse_oper.h3
2 files changed, 18 insertions, 0 deletions
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h
index aff372b4bb3..e890cee2df3 100644
--- a/src/include/catalog/pg_operator.h
+++ b/src/include/catalog/pg_operator.h
@@ -86,6 +86,11 @@ DECLARE_UNIQUE_INDEX_PKEY(pg_operator_oid_index, 2688, OperatorOidIndexId, pg_op
DECLARE_UNIQUE_INDEX(pg_operator_oprname_l_r_n_index, 2689, OperatorNameNspIndexId, pg_operator, btree(oprname name_ops, oprleft oid_ops, oprright oid_ops, oprnamespace oid_ops));
+extern Oid OperatorLookup(List *operatorName,
+ Oid leftObjectId,
+ Oid rightObjectId,
+ bool *defined);
+
extern ObjectAddress OperatorCreate(const char *operatorName,
Oid operatorNamespace,
Oid leftTypeId,
@@ -102,6 +107,16 @@ extern ObjectAddress makeOperatorDependencies(HeapTuple tuple,
bool makeExtensionDep,
bool isUpdate);
+extern void OperatorValidateParams(Oid leftTypeId,
+ Oid rightTypeId,
+ Oid operResultType,
+ bool hasCommutator,
+ bool hasNegator,
+ bool hasRestrictionSelectivity,
+ bool hasJoinSelectivity,
+ bool canMerge,
+ bool canHash);
+
extern void OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete);
#endif /* PG_OPERATOR_H */
diff --git a/src/include/parser/parse_oper.h b/src/include/parser/parse_oper.h
index 5768a1ce87a..c756caa360d 100644
--- a/src/include/parser/parse_oper.h
+++ b/src/include/parser/parse_oper.h
@@ -42,6 +42,9 @@ extern Operator compatible_oper(ParseState *pstate, List *op,
/* currently no need for compatible_left_oper/compatible_right_oper */
+/* Error reporting support */
+extern const char *op_signature_string(List *op, Oid arg1, Oid arg2);
+
/* Routines for identifying "<", "=", ">" operators for a type */
extern void get_sort_group_operators(Oid argtype,
bool needLT, bool needEQ, bool needGT,