* 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. */
| 646 | * table. |
| 647 | */ |
| 648 | static SimpleStringList * |
| 649 | get_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 | { |
no test coverage detected