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

Function RelationParseRelOptions

src/backend/utils/cache/relcache.c:479–533  ·  view source on GitHub ↗

* RelationParseRelOptions * Convert pg_class.reloptions into pre-parsed rd_options * * tuple is the real pg_class tuple (not rd_rel!) for relation * * Note: rd_rel and (if an index) rd_indam must be valid already */

Source from the content-addressed store, hash-verified

477 * Note: rd_rel and (if an index) rd_indam must be valid already
478 */
479static void
480RelationParseRelOptions(Relation relation, HeapTuple tuple)
481{
482 bytea *options;
483 reloption_function amoptsfn;
484
485 relation->rd_options = NULL;
486
487 /*
488 * Look up any AM-specific parse function; fall out if relkind should not
489 * have options.
490 */
491 switch (relation->rd_rel->relkind)
492 {
493 case RELKIND_RELATION:
494 case RELKIND_TOASTVALUE:
495 case RELKIND_MATVIEW:
496 case RELKIND_AOSEGMENTS:
497 case RELKIND_AOBLOCKDIR:
498 case RELKIND_AOVISIMAP:
499 amoptsfn = relation->rd_tableam->amoptions;
500 break;
501 case RELKIND_VIEW:
502 case RELKIND_PARTITIONED_TABLE:
503 amoptsfn = NULL;
504 break;
505 case RELKIND_INDEX:
506 case RELKIND_PARTITIONED_INDEX:
507 amoptsfn = relation->rd_indam->amoptions;
508 break;
509 default:
510 return;
511 }
512
513 /*
514 * Fetch reloptions from tuple; have to use a hardwired descriptor because
515 * we might not have any other for pg_class yet (consider executing this
516 * code for pg_class itself)
517 */
518 options = extractRelOptions(tuple, GetPgClassDescriptor(), amoptsfn);
519
520 /*
521 * Copy parsed data into CacheMemoryContext. To guard against the
522 * possibility of leaks in the reloptions code, we want to do the actual
523 * parsing in the caller's memory context and copy the results into
524 * CacheMemoryContext after the fact.
525 */
526 if (options)
527 {
528 relation->rd_options = MemoryContextAlloc(CacheMemoryContext,
529 VARSIZE(options));
530 memcpy(relation->rd_options, options, VARSIZE(options));
531 pfree(options);
532 }
533}
534
535/*
536 * RelationBuildTupleDesc

Callers 3

RelationBuildDescFunction · 0.85
RelationReloadIndexInfoFunction · 0.85

Calls 4

extractRelOptionsFunction · 0.85
GetPgClassDescriptorFunction · 0.85
MemoryContextAllocFunction · 0.85
pfreeFunction · 0.50

Tested by

no test coverage detected