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

Function DefineRange

src/backend/commands/typecmds.c:1450–1848  ·  view source on GitHub ↗

* DefineRange * Registers a new range type. * * Perhaps it might be worthwhile to set pg_type.typelem to the base type, * and likewise on multiranges to set it to the range type. But having a * non-zero typelem is treated elsewhere as a synonym for being an array, * and users might have queries with that same assumption. */

Source from the content-addressed store, hash-verified

1448 * and users might have queries with that same assumption.
1449 */
1450ObjectAddress
1451DefineRange(CreateRangeStmt *stmt)
1452{
1453 char *typeName;
1454 Oid typeNamespace;
1455 Oid typoid;
1456 char *rangeArrayName;
1457 char *multirangeTypeName = NULL;
1458 char *multirangeArrayName;
1459 Oid multirangeNamespace = InvalidOid;
1460 Oid rangeArrayOid;
1461 Oid multirangeOid;
1462 Oid multirangeArrayOid;
1463 Oid rangeSubtype = InvalidOid;
1464 List *rangeSubOpclassName = NIL;
1465 List *rangeCollationName = NIL;
1466 List *rangeCanonicalName = NIL;
1467 List *rangeSubtypeDiffName = NIL;
1468 Oid rangeSubOpclass;
1469 Oid rangeCollation;
1470 regproc rangeCanonical;
1471 regproc rangeSubtypeDiff;
1472 int16 subtyplen;
1473 bool subtypbyval;
1474 char subtypalign;
1475 char alignment;
1476 AclResult aclresult;
1477 ListCell *lc;
1478 ObjectAddress address;
1479 ObjectAddress mltrngaddress PG_USED_FOR_ASSERTS_ONLY;
1480 Oid castFuncOid;
1481
1482 /* Convert list of names to a name and namespace */
1483 typeNamespace = QualifiedNameGetCreationNamespace(stmt->typeName,
1484 &typeName);
1485
1486 /* Check we have creation rights in target namespace */
1487 aclresult = pg_namespace_aclcheck(typeNamespace, GetUserId(), ACL_CREATE);
1488 if (aclresult != ACLCHECK_OK)
1489 aclcheck_error(aclresult, OBJECT_SCHEMA,
1490 get_namespace_name(typeNamespace));
1491
1492 /*
1493 * Look to see if type already exists.
1494 */
1495 typoid = GetSysCacheOid2(TYPENAMENSP, Anum_pg_type_oid,
1496 CStringGetDatum(typeName),
1497 ObjectIdGetDatum(typeNamespace));
1498
1499 /*
1500 * If it's not a shell, see if it's an autogenerated array type, and if so
1501 * rename it out of the way.
1502 */
1503 if (OidIsValid(typoid) && get_typisdefined(typoid))
1504 {
1505 if (moveArrayTypeName(typoid, typeName, typeNamespace))
1506 typoid = InvalidOid;
1507 else

Callers 1

ProcessUtilitySlowFunction · 0.85

Calls 15

pg_namespace_aclcheckFunction · 0.85
GetUserIdFunction · 0.85
aclcheck_errorFunction · 0.85
get_namespace_nameFunction · 0.85
CStringGetDatumFunction · 0.85
ObjectIdGetDatumFunction · 0.85
get_typisdefinedFunction · 0.85
moveArrayTypeNameFunction · 0.85
typenameTypeIdFunction · 0.85
defGetTypeNameFunction · 0.85
defGetQualifiedNameFunction · 0.85

Tested by

no test coverage detected