* Drop tablespaces. */
| 1583 | * Drop tablespaces. |
| 1584 | */ |
| 1585 | static void |
| 1586 | dropTablespaces(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. |
no test coverage detected