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

Function dropTablespaces

src/bin/pg_dump/pg_dumpall.c:1585–1615  ·  view source on GitHub ↗

* Drop tablespaces. */

Source from the content-addressed store, hash-verified

1583 * Drop tablespaces.
1584 */
1585static void
1586dropTablespaces(PGconn *conn)
1587{
1588 PGresult *res;
1589 int i;
1590
1591 /*
1592 * Get all tablespaces except built-in ones (which we assume are named
1593 * pg_xxx)
1594 */
1595 res = executeQuery(conn, "SELECT spcname "
1596 "FROM pg_catalog.pg_tablespace "
1597 "WHERE spcname !~ '^pg_' "
1598 "ORDER BY 1");
1599
1600 if (PQntuples(res) > 0)
1601 fprintf(OPF, "--\n-- Drop tablespaces\n--\n\n");
1602
1603 for (i = 0; i < PQntuples(res); i++)
1604 {
1605 char *spcname = PQgetvalue(res, i, 0);
1606
1607 fprintf(OPF, "DROP TABLESPACE %s%s;\n",
1608 if_exists ? "IF EXISTS " : "",
1609 fmtId(spcname));
1610 }
1611
1612 PQclear(res);
1613
1614 fprintf(OPF, "\n\n");
1615}
1616
1617/*
1618 * Dump tablespaces.

Callers 1

mainFunction · 0.85

Calls 5

PQntuplesFunction · 0.85
PQgetvalueFunction · 0.85
fmtIdFunction · 0.85
PQclearFunction · 0.85
executeQueryFunction · 0.70

Tested by

no test coverage detected