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

Function get_parallel_object_list

src/bin/scripts/reindexdb.c:648–760  ·  view source on GitHub ↗

* Prepare the list of objects to process by querying the catalogs. * * This function will return a SimpleStringList object containing the entire * list of tables in the given database that should be processed by a parallel * database-wide reindex (excluding system tables), or NULL if there's no such * table. */

Source from the content-addressed store, hash-verified

646 * table.
647 */
648static SimpleStringList *
649get_parallel_object_list(PGconn *conn, ReindexType type,
650 SimpleStringList *user_list, bool echo)
651{
652 PQExpBufferData catalog_query;
653 PQExpBufferData buf;
654 PGresult *res;
655 SimpleStringList *tables;
656 int ntups,
657 i;
658
659 initPQExpBuffer(&catalog_query);
660
661 /*
662 * The queries here are using a safe search_path, so there's no need to
663 * fully qualify everything.
664 */
665 switch (type)
666 {
667 case REINDEX_DATABASE:
668 Assert(user_list == NULL);
669 appendPQExpBufferStr(&catalog_query,
670 "SELECT c.relname, ns.nspname\n"
671 " FROM pg_catalog.pg_class c\n"
672 " JOIN pg_catalog.pg_namespace ns"
673 " ON c.relnamespace = ns.oid\n"
674 " WHERE ns.nspname != 'pg_catalog'\n"
675 " AND c.relkind IN ("
676 CppAsString2(RELKIND_RELATION) ", "
677 CppAsString2(RELKIND_DIRECTORY_TABLE) ", "
678 CppAsString2(RELKIND_MATVIEW) ")\n"
679 " ORDER BY c.relpages DESC;");
680 break;
681
682 case REINDEX_SCHEMA:
683 {
684 SimpleStringListCell *cell;
685 bool nsp_listed = false;
686
687 Assert(user_list != NULL);
688
689 /*
690 * All the tables from all the listed schemas are grabbed at
691 * once.
692 */
693 appendPQExpBufferStr(&catalog_query,
694 "SELECT c.relname, ns.nspname\n"
695 " FROM pg_catalog.pg_class c\n"
696 " JOIN pg_catalog.pg_namespace ns"
697 " ON c.relnamespace = ns.oid\n"
698 " WHERE c.relkind IN ("
699 CppAsString2(RELKIND_RELATION) ", "
700 CppAsString2(RELKIND_DIRECTORY_TABLE) ", "
701 CppAsString2(RELKIND_MATVIEW) ")\n"
702 " AND ns.nspname IN (");
703
704 for (cell = user_list->head; cell; cell = cell->next)
705 {

Callers 1

reindex_one_databaseFunction · 0.85

Calls 14

initPQExpBufferFunction · 0.85
appendPQExpBufferStrFunction · 0.85
appendStringLiteralConnFunction · 0.85
termPQExpBufferFunction · 0.85
PQntuplesFunction · 0.85
PQclearFunction · 0.85
PQfinishFunction · 0.85
pg_malloc0Function · 0.85
fmtQualifiedIdEncFunction · 0.85
PQgetvalueFunction · 0.85
PQclientEncodingFunction · 0.85

Tested by

no test coverage detected