|
61 | 61 | #include "pg_backup_db.h"
|
62 | 62 | #include "pg_backup_utils.h"
|
63 | 63 | #include "pg_dump.h"
|
| 64 | +#include "fe_utils/connect.h" |
64 | 65 | #include "fe_utils/string_utils.h"
|
65 | 66 |
|
66 | 67 |
|
@@ -982,6 +983,9 @@ setup_connection(Archive *AH, const char *dumpencoding,
|
982 | 983 | PGconn *conn = GetConnection(AH);
|
983 | 984 | const char *std_strings;
|
984 | 985 |
|
| 986 | + if (AH->remoteVersion >= 70300) |
| 987 | + PQclear(ExecuteSqlQueryForSingleRow(AH, ALWAYS_SECURE_SEARCH_PATH_SQL)); |
| 988 | + |
985 | 989 | /*
|
986 | 990 | * Set the client encoding if requested.
|
987 | 991 | */
|
@@ -1280,18 +1284,28 @@ expand_table_name_patterns(Archive *fout,
|
1280 | 1284 |
|
1281 | 1285 | for (cell = patterns->head; cell; cell = cell->next)
|
1282 | 1286 | {
|
| 1287 | + /* |
| 1288 | + * Query must remain ABSOLUTELY devoid of unqualified names. This |
| 1289 | + * would be unnecessary given a pg_table_is_visible() variant taking a |
| 1290 | + * search_path argument. |
| 1291 | + */ |
1283 | 1292 | appendPQExpBuffer(query,
|
1284 | 1293 | "SELECT c.oid"
|
1285 | 1294 | "\nFROM pg_catalog.pg_class c"
|
1286 |
| - "\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace" |
1287 |
| - "\nWHERE c.relkind in ('%c', '%c', '%c', '%c', '%c')\n", |
| 1295 | + "\n LEFT JOIN pg_catalog.pg_namespace n" |
| 1296 | + "\n ON n.oid OPERATOR(pg_catalog.=) c.relnamespace" |
| 1297 | + "\nWHERE c.relkind OPERATOR(pg_catalog.=) ANY" |
| 1298 | + "\n (array['%c', '%c', '%c', '%c', '%c'])\n", |
1288 | 1299 | RELKIND_RELATION, RELKIND_SEQUENCE, RELKIND_VIEW,
|
1289 | 1300 | RELKIND_MATVIEW, RELKIND_FOREIGN_TABLE);
|
1290 | 1301 | processSQLNamePattern(GetConnection(fout), query, cell->val, true,
|
1291 | 1302 | false, "n.nspname", "c.relname", NULL,
|
1292 | 1303 | "pg_catalog.pg_table_is_visible(c.oid)");
|
1293 | 1304 |
|
| 1305 | + ExecuteSqlStatement(fout, "RESET search_path"); |
1294 | 1306 | res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
|
| 1307 | + PQclear(ExecuteSqlQueryForSingleRow(fout, |
| 1308 | + ALWAYS_SECURE_SEARCH_PATH_SQL)); |
1295 | 1309 | if (strict_names && PQntuples(res) == 0)
|
1296 | 1310 | exit_horribly(NULL, "no matching tables were found for pattern \"%s\"\n", cell->val);
|
1297 | 1311 |
|
|
0 commit comments