| Line | Hits | Source | Commit |
|---|---|---|---|
| 1827 | - | expand_table_name_patterns(Archive *fout, | - |
| 1828 | - | SimpleStringList *patterns, SimpleOidList *oids, | - |
| 1829 | - | bool strict_names, bool with_child_tables) | - |
| 1830 | - | { | - |
| 1831 | - | PQExpBuffer query; | - |
| 1832 | - | PGresult *res; | - |
| 1833 | - | SimpleStringListCell *cell; | - |
| 1834 | - | int i; | - |
| 1835 | - | - | |
| 1836 | - | if (patterns->head == NULL) | - |
| 1837 | - | return; /* nothing to do */ | - |
| 1838 | - | - | |
| 1839 | - | query = createPQExpBuffer(); | - |
| 1840 | - | - | |
| 1841 | - | /* | - |
| 1842 | - | * this might sometimes result in duplicate entries in the OID list, but | - |
| 1843 | - | * we don't care. | - |
| 1844 | - | */ | - |
| 1845 | - | - | |
| 1846 | - | for (cell = patterns->head; cell; cell = cell->next) | - |
| 1847 | - | { | - |
| 1848 | - | PQExpBufferData dbbuf; | - |
| 1849 | - | int dotcnt; | - |
| 1850 | - | - | |
| 1851 | - | /* | - |
| 1852 | - | * Query must remain ABSOLUTELY devoid of unqualified names. This | - |
| 1853 | - | * would be unnecessary given a pg_table_is_visible() variant taking a | - |
| 1854 | - | * search_path argument. | - |
| 1855 | - | * | - |
| 1856 | - | * For with_child_tables, we start with the basic query's results and | - |
| 1857 | - | * recursively search the inheritance tree to add child tables. | - |
| 1858 | - | */ | - |
| 1859 | - | if (with_child_tables) | - |
| 1860 | - | { | - |
| 1861 | - | appendPQExpBufferStr(query, "WITH RECURSIVE partition_tree (relid) AS (\n"); | - |
| 1862 | - | } | - |
| 1863 | - | - | |
| 1864 | - | appendPQExpBuffer(query, | - |
| 1865 | - | "SELECT c.oid" | - |
| 1866 | - | "\nFROM pg_catalog.pg_class c" | - |
| 1867 | - | "\n LEFT JOIN pg_catalog.pg_namespace n" | - |
| 1868 | - | "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace" | - |
| 1869 | - | "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY" | - |
| 1870 | - | "\n (array['%c', '%c', '%c', '%c', '%c', '%c', '%c'])\n", | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1871 | - | RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW, | - |
| 1872 | - | RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE, | - |
| 1873 | - | RELKIND_PARTITIONED_TABLE, RELKIND_PROPGRAPH); | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 1874 | - | initPQExpBuffer(&dbbuf); | - |
| 1875 | - | processSQLNamePattern(GetConnection(fout), query, cell->val, true, | - |
| 1876 | - | false, "n.nspname", "c.relname", NULL, | - |
| 1877 | - | "pg_catalog.pg_table_is_visible(c.oid)", &dbbuf, | - |
| 1878 | - | &dotcnt); | - |
| 1879 | - | if (dotcnt > 2) | - |
| 1880 | - | pg_fatal("improper relation name (too many dotted names): %s", | - |
| 1881 | - | cell->val); | - |
| 1882 | - | else if (dotcnt == 2) | - |
| 1883 | - | prohibit_crossdb_refs(GetConnection(fout), dbbuf.data, cell->val); | - |
| 1884 | - | termPQExpBuffer(&dbbuf); | - |
| 1885 | - | - | |
| 1886 | - | if (with_child_tables) | - |
| 1887 | - | { | - |
| 1888 | - | appendPQExpBufferStr(query, "UNION" | - |
| 1889 | - | "\nSELECT i.inhrelid" | - |
| 1890 | - | "\nFROM partition_tree p" | - |
| 1891 | - | "\n JOIN pg_catalog.pg_inherits i" | - |
| 1892 | - | "\n ON p.relid OPERATOR(pg_catalog.=) i.inhparent" | - |
| 1893 | - | "\n)" | - |
| 1894 | - | "\nSELECT relid FROM partition_tree"); | - |
| 1895 | - | } | - |
| 1896 | - | - | |
| 1897 | - | ExecuteSqlStatement(fout, "RESET search_path"); | - |
| 1898 | - | res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK); | - |
| 1899 | - | PQclear(ExecuteSqlQueryForSingleRow(fout, | - |
| 1900 | - | ALWAYS_SECURE_SEARCH_PATH_SQL)); | - |
| 1901 | - | if (strict_names && PQntuples(res) == 0) | - |
| 1902 | - | pg_fatal("no matching tables were found for pattern \"%s\"", cell->val); | - |
| 1903 | - | - | |
| 1904 | - | for (i = 0; i < PQntuples(res); i++) | - |
| 1905 | - | { | - |
| 1906 | - | simple_oid_list_append(oids, atooid(PQgetvalue(res, i, 0))); | - |
| 1907 | - | } | - |
| 1908 | - | - | |
| 1909 | - | PQclear(res); | - |
| 1910 | - | resetPQExpBuffer(query); | - |
| 1911 | - | } | - |
| 1912 | - | - | |
| 1913 | - | destroyPQExpBuffer(query); | - |
| 1914 | - | } | - |
| Line | Hits | Source | Commit |
|---|---|---|---|
| 3039 | - | makeTableDataInfo(DumpOptions *dopt, TableInfo *tbinfo) | - |
| 3040 | - | { | - |
| 3041 | - | TableDataInfo *tdinfo; | - |
| 3042 | - | - | |
| 3043 | - | /* | - |
| 3044 | - | * Nothing to do if we already decided to dump the table. This will | - |
| 3045 | - | * happen for "config" tables. | - |
| 3046 | - | */ | - |
| 3047 | - | if (tbinfo->dataObj != NULL) | - |
| 3048 | - | return; | - |
| 3049 | - | - | |
| 3050 | - | /* Skip property graphs (no data to dump) */ | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 3051 | 6328 | if (tbinfo->relkind == RELKIND_PROPGRAPH) | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 3052 | - | return; | 86c14eaWIP: SQL Property Graph Queries (SQL/PGQ) |
| 3053 | - | /* Skip VIEWs (no data to dump) */ | - |
| 3054 | - | if (tbinfo->relkind == RELKIND_VIEW) | - |
| 3055 | - | return; | - |
| 3056 | - | /* Skip FOREIGN TABLEs (no data to dump) unless requested explicitly */ | - |
| 3057 | - | if (tbinfo->relkind == RELKIND_FOREIGN_TABLE && | - |
| 3058 | - | (foreign_servers_include_oids.head == NULL || | - |
| 3059 | - | !simple_oid_list_member(&foreign_servers_include_oids, | - |
| 3060 | - | tbinfo->foreign_server))) | - |
| 3061 | - | return; | - |
| 3062 | - | /* Skip partitioned tables (data in partitions) */ | - |
| 3063 | - | if (tbinfo->relkind == RELKIND_PARTITIONED_TABLE) | - |
| 3064 | - | return; | - |
| 3065 | - | - | |
| 3066 | - | /* Don't dump data in unlogged tables, if so requested */ | - |
| 3067 | - | if (tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED && | - |
| 3068 | - | dopt->no_unlogged_table_data) | - |
| 3069 | - | return; | - |
| 3070 | - | - | |
| 3071 | - | /* Check that the data is not explicitly excluded */ | - |
| 3072 | - | if (simple_oid_list_member(&tabledata_exclude_oids, | - |
| 3073 | - | tbinfo->dobj.catId.oid)) | - |
| 3074 | - | return; | - |
| 3075 | - | - | |
| 3076 | - | /* OK, let's dump it */ | - |
| 3077 | - | tdinfo = (TableDataInfo *) pg_malloc(sizeof(TableDataInfo)); | - |
| 3078 | - | - | |
| 3079 | - | if (tbinfo->relkind == RELKIND_MATVIEW) | - |
| 3080 | - | tdinfo->dobj.objType = DO_REFRESH_MATVIEW; | - |
| 3081 | - | else if (tbinfo->relkind == RELKIND_SEQUENCE) | - |
| 3082 | - | tdinfo->dobj.objType = DO_SEQUENCE_SET; | - |
| 3083 | - | else | - |
| 3084 | - | tdinfo->dobj.objType = DO_TABLE_DATA; | - |
| 3085 | - | - | |
| 3086 | - | /* | - |
| 3087 | - | * Note: use tableoid 0 so that this object won't be mistaken for | - |
| 3088 | - | * something that pg_depend entries apply to. | - |
| 3089 | - | */ | - |
| 3090 | - | tdinfo->dobj.catId.tableoid = 0; | - |
| 3091 | - | tdinfo->dobj.catId.oid = tbinfo->dobj.catId.oid; | - |
| 3092 | - | AssignDumpId(&tdinfo->dobj); | - |
| 3093 | - | tdinfo->dobj.name = tbinfo->dobj.name; | - |
| 3094 | - | tdinfo->dobj.namespace = tbinfo->dobj.namespace; | - |
| 3095 | - | tdinfo->tdtable = tbinfo; | - |
| 3096 | - | tdinfo->filtercond = NULL; /* might get set later */ | - |
| 3097 | - | addObjectDependency(&tdinfo->dobj, tbinfo->dobj.dumpId); | - |
| 3098 | - | - | |
| 3099 | - | /* A TableDataInfo contains data, of course */ | - |
| 3100 | - | tdinfo->dobj.components |= DUMP_COMPONENT_DATA; | - |
| 3101 | - | - | |
| 3102 | - | tbinfo->dataObj = tdinfo; | - |
| 3103 | - | - | |
| 3104 | - | /* | - |
| 3105 | - | * Materialized view statistics must be restored after the data, because | - |
| 3106 | - | * REFRESH MATERIALIZED VIEW replaces the storage and resets the stats. | - |
| 3107 | - | * | - |
| 3108 | - | * The dependency is added here because the statistics objects are created | - |
| 3109 | - | * first. | - |
| 3110 | - | */ | - |
| 3111 | - | if (tbinfo->relkind == RELKIND_MATVIEW && tbinfo->stats != NULL) | - |
| 3112 | - | { | - |
| 3113 | - | tbinfo->stats->section = SECTION_POST_DATA; | - |
| 3114 | - | addObjectDependency(&tbinfo->stats->dobj, tdinfo->dobj.dumpId); | - |
| 3115 | - | } | - |
| 3116 | - | - | |
| 3117 | - | /* Make sure that we'll collect per-column info for this table. */ | - |
| 3118 | - | tbinfo->interesting = true; | - |
| 3119 | - | } | - |