-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add guide for removing foreign data wrappers
- Add comprehensive guide for removing FDWs - Cover both native and WASM wrapper cleanup - Include verification steps - Fixes #177 Co-Authored-By: [email protected] <[email protected]>
- Loading branch information
1 parent
054a42d
commit e3a6eb9
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
# Removing Foreign Data Wrappers | ||
|
||
This guide explains how to fully remove a foreign data wrapper from your PostgreSQL database. | ||
|
||
## Components to Remove | ||
|
||
When removing a foreign data wrapper, you need to remove several components in the correct order: | ||
|
||
1. Foreign Tables | ||
2. Foreign Servers | ||
3. Extension | ||
4. (For WASM wrappers only) Cache files | ||
|
||
## Step-by-Step Removal Process | ||
|
||
### 1. List and Remove Foreign Tables | ||
|
||
First, list all foreign tables associated with your wrapper: | ||
|
||
```sql | ||
SELECT foreign_table_schema, foreign_table_name | ||
FROM information_schema.foreign_tables; | ||
``` | ||
|
||
Remove each foreign table: | ||
|
||
```sql | ||
DROP FOREIGN TABLE IF EXISTS [schema_name.]table_name; | ||
``` | ||
|
||
### 2. Remove Foreign Servers | ||
|
||
List servers: | ||
|
||
```sql | ||
SELECT srvname, fdwname | ||
FROM pg_foreign_server fs | ||
JOIN pg_foreign_data_wrapper fdw ON fs.srvfdw = fdw.oid; | ||
``` | ||
|
||
Remove each server: | ||
|
||
```sql | ||
DROP SERVER IF EXISTS server_name CASCADE; | ||
``` | ||
|
||
### 3. Remove the Extension | ||
|
||
```sql | ||
DROP EXTENSION IF EXISTS wrappers CASCADE; | ||
``` | ||
|
||
### 4. Additional Steps for WASM Wrappers | ||
|
||
WASM wrappers cache their compiled code locally. To fully clean up: | ||
|
||
1. Stop the PostgreSQL server | ||
2. Remove cached WASM files: | ||
```bash | ||
rm -rf /var/lib/postgresql/[version]/wasm_cache/* | ||
``` | ||
3. Restart the PostgreSQL server | ||
|
||
## Verification | ||
|
||
After removal, verify that all components are gone: | ||
|
||
```sql | ||
-- Check for remaining foreign tables | ||
SELECT foreign_table_schema, foreign_table_name | ||
FROM information_schema.foreign_tables; | ||
|
||
-- Check for remaining servers | ||
SELECT srvname, fdwname | ||
FROM pg_foreign_server fs | ||
JOIN pg_foreign_data_wrapper fdw ON fs.srvfdw = fdw.oid; | ||
|
||
-- Check for the extension | ||
SELECT * FROM pg_extension WHERE extname = 'wrappers'; | ||
``` | ||
|
||
## Common Issues | ||
|
||
- Always use CASCADE when dropping servers if you're unsure about dependencies | ||
- For production environments, take a backup before removing components | ||
- Some wrappers might have additional cleanup steps; check wrapper-specific documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters