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

Function appendonly_fetch_init

src/backend/access/appendonly/appendonlyam.c:2365–2514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2363}
2364
2365AppendOnlyFetchDesc
2366appendonly_fetch_init(Relation relation,
2367 Snapshot snapshot,
2368 Snapshot appendOnlyMetaDataSnapshot)
2369{
2370 AppendOnlyFetchDesc aoFetchDesc;
2371 AppendOnlyStorageAttributes *attr;
2372 PGFunction *fns;
2373 StringInfoData titleBuf;
2374 FormData_pg_appendonly aoFormData;
2375 int segno;
2376
2377 GetAppendOnlyEntry(relation, &aoFormData);
2378
2379 /*
2380 * increment relation ref count while scanning relation
2381 *
2382 * This is just to make really sure the relcache entry won't go away while
2383 * the scan has a pointer to it. Caller should be holding the rel open
2384 * anyway, so this is redundant in all normal scenarios...
2385 */
2386 RelationIncrementReferenceCount(relation);
2387
2388 /*
2389 * allocate scan descriptor
2390 */
2391 aoFetchDesc = (AppendOnlyFetchDesc) palloc0(sizeof(AppendOnlyFetchDescData));
2392
2393 aoFetchDesc->relation = relation;
2394 aoFetchDesc->appendOnlyMetaDataSnapshot = appendOnlyMetaDataSnapshot;
2395 aoFetchDesc->snapshot = snapshot;
2396
2397 aoFetchDesc->initContext = CurrentMemoryContext;
2398
2399 aoFetchDesc->segmentFileNameMaxLen = AOSegmentFilePathNameLen(relation) + 1;
2400 aoFetchDesc->segmentFileName =
2401 (char *) palloc(aoFetchDesc->segmentFileNameMaxLen);
2402 aoFetchDesc->segmentFileName[0] = '\0';
2403
2404 initStringInfo(&titleBuf);
2405 appendStringInfo(&titleBuf, "Fetch of Append-Only Row-Oriented relation '%s'",
2406 RelationGetRelationName(relation));
2407 aoFetchDesc->title = titleBuf.data;
2408
2409 /*
2410 * Fill in Append-Only Storage layer attributes.
2411 */
2412 attr = &aoFetchDesc->storageAttributes;
2413
2414 /*
2415 * These attributes describe the AppendOnly format to be scanned.
2416 */
2417 if (strcmp(NameStr(aoFormData.compresstype), "") == 0 ||
2418 pg_strcasecmp(NameStr(aoFormData.compresstype), "none") == 0)
2419 {
2420 attr->compress = false;
2421 attr->compressType = "none";
2422 }

Calls 15

GetAppendOnlyEntryFunction · 0.85
AOSegmentFilePathNameLenFunction · 0.85
initStringInfoFunction · 0.85
appendStringInfoFunction · 0.85
pg_strcasecmpFunction · 0.85
GetAllFileSegInfoFunction · 0.85
ReadLastSequenceFunction · 0.85

Tested by

no test coverage detected