MCPcopy Create free account
hub / github.com/apache/cloudberry / AlterOperator

Function AlterOperator

src/backend/commands/operatorcmds.c:441–585  ·  view source on GitHub ↗

* AlterOperator * routine implementing ALTER OPERATOR SET (option = ...). * * Currently, only RESTRICT and JOIN estimator functions can be changed. */

Source from the content-addressed store, hash-verified

439 * Currently, only RESTRICT and JOIN estimator functions can be changed.
440 */
441ObjectAddress
442AlterOperator(AlterOperatorStmt *stmt)
443{
444 ObjectAddress address;
445 Oid oprId;
446 Relation catalog;
447 HeapTuple tup;
448 Form_pg_operator oprForm;
449 int i;
450 ListCell *pl;
451 Datum values[Natts_pg_operator];
452 bool nulls[Natts_pg_operator];
453 bool replaces[Natts_pg_operator];
454 List *restrictionName = NIL; /* optional restrict. sel. function */
455 bool updateRestriction = false;
456 Oid restrictionOid;
457 List *joinName = NIL; /* optional join sel. function */
458 bool updateJoin = false;
459 Oid joinOid;
460
461 /* Look up the operator */
462 oprId = LookupOperWithArgs(stmt->opername, false);
463 catalog = table_open(OperatorRelationId, RowExclusiveLock);
464 tup = SearchSysCacheCopy1(OPEROID, ObjectIdGetDatum(oprId));
465 if (!HeapTupleIsValid(tup))
466 elog(ERROR, "cache lookup failed for operator %u", oprId);
467 oprForm = (Form_pg_operator) GETSTRUCT(tup);
468
469 /* Process options */
470 foreach(pl, stmt->options)
471 {
472 DefElem *defel = (DefElem *) lfirst(pl);
473 List *param;
474
475 if (defel->arg == NULL)
476 param = NIL; /* NONE, removes the function */
477 else
478 param = defGetQualifiedName(defel);
479
480 if (strcmp(defel->defname, "restrict") == 0)
481 {
482 restrictionName = param;
483 updateRestriction = true;
484 }
485 else if (strcmp(defel->defname, "join") == 0)
486 {
487 joinName = param;
488 updateJoin = true;
489 }
490
491 /*
492 * The rest of the options that CREATE accepts cannot be changed.
493 * Check for them so that we can give a meaningful error message.
494 */
495 else if (strcmp(defel->defname, "leftarg") == 0 ||
496 strcmp(defel->defname, "rightarg") == 0 ||
497 strcmp(defel->defname, "function") == 0 ||
498 strcmp(defel->defname, "procedure") == 0 ||

Callers 1

ProcessUtilitySlowFunction · 0.85

Calls 15

LookupOperWithArgsFunction · 0.85
table_openFunction · 0.85
ObjectIdGetDatumFunction · 0.85
defGetQualifiedNameFunction · 0.85
pg_oper_ownercheckFunction · 0.85
GetUserIdFunction · 0.85
aclcheck_errorFunction · 0.85
ValidateJoinEstimatorFunction · 0.85
heap_modify_tupleFunction · 0.85
CatalogTupleUpdateFunction · 0.85
makeOperatorDependenciesFunction · 0.85

Tested by

no test coverage detected