* flagInhIndexes - * Create IndexAttachInfo objects for partitioned indexes, and add * appropriate dependency links. */
| 389 | * appropriate dependency links. |
| 390 | */ |
| 391 | static void |
| 392 | flagInhIndexes(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); |
no test coverage detected