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

Function flagInhIndexes

src/bin/pg_dump/common.c:391–454  ·  view source on GitHub ↗

* flagInhIndexes - * Create IndexAttachInfo objects for partitioned indexes, and add * appropriate dependency links. */

Source from the content-addressed store, hash-verified

389 * appropriate dependency links.
390 */
391static void
392flagInhIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
393{
394 int i,
395 j;
396
397 for (i = 0; i < numTables; i++)
398 {
399 if (!tblinfo[i].ispartition || tblinfo[i].numParents == 0)
400 continue;
401
402 Assert(tblinfo[i].numParents == 1);
403
404 for (j = 0; j < tblinfo[i].numIndexes; j++)
405 {
406 IndxInfo *index = &(tblinfo[i].indexes[j]);
407 IndxInfo *parentidx;
408 IndexAttachInfo *attachinfo;
409
410 if (index->parentidx == 0)
411 continue;
412
413 parentidx = findIndexByOid(index->parentidx);
414 if (parentidx == NULL)
415 continue;
416
417 attachinfo = (IndexAttachInfo *) pg_malloc(sizeof(IndexAttachInfo));
418
419 attachinfo->dobj.objType = DO_INDEX_ATTACH;
420 attachinfo->dobj.catId.tableoid = 0;
421 attachinfo->dobj.catId.oid = 0;
422 AssignDumpId(&attachinfo->dobj);
423 attachinfo->dobj.name = pg_strdup(index->dobj.name);
424 attachinfo->dobj.namespace = index->indextable->dobj.namespace;
425 attachinfo->parentIdx = parentidx;
426 attachinfo->partitionIdx = index;
427
428 /*
429 * We must state the DO_INDEX_ATTACH object's dependencies
430 * explicitly, since it will not match anything in pg_depend.
431 *
432 * Give it dependencies on both the partition index and the parent
433 * index, so that it will not be executed till both of those
434 * exist. (There's no need to care what order those are created
435 * in.)
436 *
437 * In addition, give it dependencies on the indexes' underlying
438 * tables. This does nothing of great value so far as serial
439 * restore ordering goes, but it ensures that a parallel restore
440 * will not try to run the ATTACH concurrently with other
441 * operations on those tables.
442 */
443 addObjectDependency(&attachinfo->dobj, index->dobj.dumpId);
444 addObjectDependency(&attachinfo->dobj, parentidx->dobj.dumpId);
445 addObjectDependency(&attachinfo->dobj,
446 index->indextable->dobj.dumpId);
447 addObjectDependency(&attachinfo->dobj,
448 parentidx->indextable->dobj.dumpId);

Callers 1

getSchemaDataFunction · 0.85

Calls 6

findIndexByOidFunction · 0.85
pg_mallocFunction · 0.85
AssignDumpIdFunction · 0.85
pg_strdupFunction · 0.85
addObjectDependencyFunction · 0.85
simple_ptr_list_appendFunction · 0.85

Tested by

no test coverage detected