@@ -42,6 +42,7 @@ extern "C" {
42
42
#include " catalog/namespace.h"
43
43
#include " catalog/pg_namespace.h"
44
44
#include " catalog/pg_extension.h"
45
+ #include " catalog/pg_foreign_server.h"
45
46
#include " utils/acl.h"
46
47
#include " utils/guc.h"
47
48
#include " utils/memutils.h"
@@ -918,7 +919,7 @@ CreateSchemaIfNotExists(const char *postgres_schema_name, bool is_default_db) {
918
919
if (!is_default_db) {
919
920
/*
920
921
* For ddb$ schemas we need to record a dependency between the schema
921
- * and the extension , so that DROP EXTENSION also drops these schemas.
922
+ * and the FDW , so that DROP SERVER motherduck also drops these schemas.
922
923
*/
923
924
schema_oid = get_namespace_oid (postgres_schema_name, true );
924
925
if (schema_oid == InvalidOid) {
@@ -932,12 +933,12 @@ CreateSchemaIfNotExists(const char *postgres_schema_name, bool is_default_db) {
932
933
.objectId = schema_oid,
933
934
.objectSubId = 0 ,
934
935
};
935
- ObjectAddress extension_address = {
936
- .classId = ExtensionRelationId ,
937
- .objectId = pgduckdb::ExtensionOid (),
936
+ ObjectAddress server_address = {
937
+ .classId = ForeignServerRelationId ,
938
+ .objectId = GetMotherduckForeignServerOid (), // pgduckdb::ExtensionOid(),
938
939
.objectSubId = 0 ,
939
940
};
940
- recordDependencyOn (&schema_address, &extension_address , DEPENDENCY_NORMAL);
941
+ recordDependencyOn (&schema_address, &server_address , DEPENDENCY_NORMAL);
941
942
}
942
943
943
944
/* Success, so we commit the subtransaction */
0 commit comments