mirror of
https://github.com/postgres/postgres.git
synced 2025-09-11 00:12:06 +03:00
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
This commit is contained in:
@@ -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 */
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user