42 Oid operatorNamespace,
48 Oid operatorNamespace,
53 Oid otherLeftTypeId,
Oid otherRightTypeId,
54 const char *operatorName,
Oid operatorNamespace,
55 Oid leftTypeId,
Oid rightTypeId);
78 if (strspn(
name,
"~!@#^&|`?+-*/%<>=") !=
len)
82 if (strstr(
name,
"/*") || strstr(
name,
"--"))
98 for (ic =
len - 2; ic >= 0; ic--)
100 if (strchr(
"~!@#^&|`?%",
name[ic]))
108 if (strcmp(
name,
"!=") == 0)
125 Oid operatorNamespace,
131 Oid operatorObjectId;
142 operatorObjectId = oprform->oid;
152 return operatorObjectId;
169 Oid operatorObjectId;
173 leftObjectId, rightObjectId,
184 return operatorObjectId;
194 Oid operatorNamespace,
199 Oid operatorObjectId;
203 bool nulls[Natts_pg_operator];
212 (
errcode(ERRCODE_INVALID_NAME),
213 errmsg(
"\"%s\" is not a valid operator name",
220 tupDesc = pg_operator_desc->
rd_att;
225 for (
i = 0;
i < Natts_pg_operator; ++
i)
236 Anum_pg_operator_oid);
282 return operatorObjectId;
322 Oid operatorNamespace,
326 List *commutatorName,
336 bool nulls[Natts_pg_operator];
337 bool replaces[Natts_pg_operator];
339 Oid operatorObjectId;
340 bool operatorAlreadyDefined;
344 bool selfCommutator =
false;
354 (
errcode(ERRCODE_INVALID_NAME),
355 errmsg(
"\"%s\" is not a valid operator name",
363 commutatorName !=
NIL,
374 &operatorAlreadyDefined);
376 if (operatorAlreadyDefined)
378 (
errcode(ERRCODE_DUPLICATE_FUNCTION),
379 errmsg(
"operator %s already exists",
401 rightTypeId, leftTypeId,
402 operatorName, operatorNamespace,
403 leftTypeId, rightTypeId);
417 selfCommutator =
true;
426 leftTypeId, rightTypeId,
427 operatorName, operatorNamespace,
428 leftTypeId, rightTypeId);
442 if (!
OidIsValid(negatorId) || negatorId == operatorObjectId)
444 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
445 errmsg(
"operator cannot be its own negator")));
454 for (
i = 0;
i < Natts_pg_operator; ++
i)
482 if (operatorObjectId)
489 elog(
ERROR,
"cache lookup failed for operator %u",
492 replaces[Anum_pg_operator_oid - 1] =
false;
507 Anum_pg_operator_oid);
531 commutatorId = operatorObjectId;
534 OperatorUpd(operatorObjectId, commutatorId, negatorId,
false);
561 bool hasRestrictionSelectivity,
562 bool hasJoinSelectivity,
571 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
572 errmsg(
"only binary operators can have commutators")));
573 if (hasJoinSelectivity)
575 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
576 errmsg(
"only binary operators can have join selectivity")));
579 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
580 errmsg(
"only binary operators can merge join")));
583 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
584 errmsg(
"only binary operators can hash")));
587 if (operResultType != BOOLOID)
592 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
593 errmsg(
"only boolean operators can have negators")));
594 if (hasRestrictionSelectivity)
596 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
597 errmsg(
"only boolean operators can have restriction selectivity")));
598 if (hasJoinSelectivity)
600 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
601 errmsg(
"only boolean operators can have join selectivity")));
604 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
605 errmsg(
"only boolean operators can merge join")));
608 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
609 errmsg(
"only boolean operators can hash")));
623 const char *operatorName,
Oid operatorNamespace,
624 Oid leftTypeId,
Oid rightTypeId)
646 if (strcmp(otherName, operatorName) == 0 &&
647 otherNamespace == operatorNamespace &&
648 otherLeftTypeId == leftTypeId &&
649 otherRightTypeId == rightTypeId)
711 bool update_commutator =
false;
721 update_commutator =
true;
723 else if (!isDelete && t->oprcom != baseId)
738 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
739 errmsg(
"commutator operator %s is already the commutator of operator %s",
740 NameStr(t->oprname), thirdop)));
743 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
744 errmsg(
"commutator operator %s is already the commutator of operator %u",
745 NameStr(t->oprname), t->oprcom)));
749 update_commutator =
true;
753 if (update_commutator)
779 bool update_negator =
false;
789 update_negator =
true;
791 else if (!isDelete && t->oprnegate != baseId)
806 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
807 errmsg(
"negator operator %s is already the negator of operator %s",
808 NameStr(t->oprname), thirdop)));
811 (
errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
812 errmsg(
"negator operator %s is already the negator of operator %u",
813 NameStr(t->oprname), t->oprnegate)));
816 t->oprnegate = baseId;
817 update_negator =
true;
854 bool makeExtensionDep,
941 if (makeExtensionDep)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
static Datum values[MAXATTR]
#define RegProcedureIsValid(p)
#define OidIsValid(objectId)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
void record_object_address_dependencies(const ObjectAddress *depender, ObjectAddresses *referenced, DependencyType behavior)
ObjectAddresses * new_object_addresses(void)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
void free_object_addresses(ObjectAddresses *addrs)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
char * get_opname(Oid opno)
char * get_namespace_name(Oid nspid)
RegProcedure get_opcode(Oid opno)
Oid get_func_rettype(Oid funcid)
void namestrcpy(Name name, const char *str)
Oid QualifiedNameGetCreationNamespace(const List *names, char **objname_p)
char * NameListToString(const List *names)
#define InvokeObjectPostCreateHook(classId, objectId, subId)
#define ObjectAddressSet(addr, class_id, object_id)
Oid LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright, bool noError, int location)
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
long deleteDependencyRecordsFor(Oid classId, Oid objectId, bool skipExtensionDeps)
void recordDependencyOnCurrentExtension(const ObjectAddress *object, bool isReplace)
static Oid get_other_operator(List *otherOp, Oid otherLeftTypeId, Oid otherRightTypeId, const char *operatorName, Oid operatorNamespace, Oid leftTypeId, Oid rightTypeId)
static Oid OperatorShellMake(const char *operatorName, Oid operatorNamespace, Oid leftTypeId, Oid rightTypeId)
static Oid OperatorGet(const char *operatorName, Oid operatorNamespace, Oid leftObjectId, Oid rightObjectId, bool *defined)
static bool validOperatorName(const char *name)
ObjectAddress OperatorCreate(const char *operatorName, Oid operatorNamespace, Oid leftTypeId, Oid rightTypeId, Oid procedureId, List *commutatorName, List *negatorName, Oid restrictionId, Oid joinId, bool canMerge, bool canHash)
void OperatorValidateParams(Oid leftTypeId, Oid rightTypeId, Oid operResultType, bool hasCommutator, bool hasNegator, bool hasRestrictionSelectivity, bool hasJoinSelectivity, bool canMerge, bool canHash)
Oid OperatorLookup(List *operatorName, Oid leftObjectId, Oid rightObjectId, bool *defined)
ObjectAddress makeOperatorDependencies(HeapTuple tuple, bool makeExtensionDep, bool isUpdate)
void OperatorUpd(Oid baseId, Oid commId, Oid negId, bool isDelete)
FormData_pg_operator * Form_pg_operator
void deleteSharedDependencyRecordsFor(Oid classId, Oid objectId, int32 objectSubId)
void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner)
static Datum PointerGetDatum(const void *X)
static Datum BoolGetDatum(bool X)
static Datum ObjectIdGetDatum(Oid X)
static Datum NameGetDatum(const NameData *X)
static Datum CharGetDatum(char X)
#define RelationGetDescr(relation)
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
#define SearchSysCacheCopy1(cacheId, key1)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
void CommandCounterIncrement(void)