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

Function expand_foreign_server_name_patterns

src/bin/pg_dump/pg_dump.c:1691–1736  ·  view source on GitHub ↗

* Find the OIDs of all foreign servers matching the given list of patterns, * and append them to the given OID list. */

Source from the content-addressed store, hash-verified

1689 * and append them to the given OID list.
1690 */
1691static void
1692expand_foreign_server_name_patterns(Archive *fout,
1693 SimpleStringList *patterns,
1694 SimpleOidList *oids)
1695{
1696 PQExpBuffer query;
1697 PGresult *res;
1698 SimpleStringListCell *cell;
1699 int i;
1700
1701 if (patterns->head == NULL)
1702 return; /* nothing to do */
1703
1704 query = createPQExpBuffer();
1705
1706 /*
1707 * The loop below runs multiple SELECTs might sometimes result in
1708 * duplicate entries in the OID list, but we don't care.
1709 */
1710
1711 for (cell = patterns->head; cell; cell = cell->next)
1712 {
1713 int dotcnt;
1714
1715 appendPQExpBufferStr(query,
1716 "SELECT oid FROM pg_catalog.pg_foreign_server s\n");
1717 processSQLNamePattern(GetConnection(fout), query, cell->val, false,
1718 false, NULL, "s.srvname", NULL, NULL, NULL,
1719 &dotcnt);
1720 if (dotcnt > 0)
1721 fatal("improper qualified name (too many dotted names): %s",
1722 cell->val);
1723
1724 res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
1725 if (PQntuples(res) == 0)
1726 fatal("no matching foreign servers were found for pattern \"%s\"", cell->val);
1727
1728 for (i = 0; i < PQntuples(res); i++)
1729 simple_oid_list_append(oids, atooid(PQgetvalue(res, i, 0)));
1730
1731 PQclear(res);
1732 resetPQExpBuffer(query);
1733 }
1734
1735 destroyPQExpBuffer(query);
1736}
1737
1738/*
1739 * Find the OIDs of all tables matching the given list of patterns,

Callers 1

mainFunction · 0.85

Calls 11

createPQExpBufferFunction · 0.85
appendPQExpBufferStrFunction · 0.85
processSQLNamePatternFunction · 0.85
ExecuteSqlQueryFunction · 0.85
PQntuplesFunction · 0.85
simple_oid_list_appendFunction · 0.85
PQgetvalueFunction · 0.85
PQclearFunction · 0.85
resetPQExpBufferFunction · 0.85
destroyPQExpBufferFunction · 0.85
GetConnectionFunction · 0.70

Tested by

no test coverage detected