SDL/declarative (PostgreSQL): CREATE EXTENSION rejected by the SDL parser but required by the differ, so extension-owned functions get DROP FUNCTION · Issue #21111 · bytebase/bytebase · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SDL/declarative (PostgreSQL): CREATE EXTENSION rejected by the SDL parser but required by the differ, so extension-owned functions get DROP FUNCTION #21111
SDL/declarative (PostgreSQL): CREATE EXTENSION is rejected by the SDL parser but required by the SDL differ, so extension-owned functions get DROP FUNCTION
Summary
In declarative (SDL) mode against PostgreSQL, a database with an installed extension cannot be
managed at all. The two halves of the feature contradict each other:
Export Schema emits CREATE EXTENSION, but the SDL parser rejects it. The exported schema
is not round-trip-clean — feed Bytebase's own export back in as an SDL file and check fails.
Remove the CREATE EXTENSION statement and the differ then treats the extension's functions as
orphans, generating DROP FUNCTION for each. PostgreSQL refuses, because extension-owned
functions cannot be dropped individually.
There is no third configuration. Declaring the extension fails validation; not declaring it produces
DDL PostgreSQL will not execute.
{
"code": 239,
"ruleType": "PARSER_BASED",
"status": "ERROR",
"title": "Disallowed statement in SDL file",
"content": "Statement type 'CREATE_EXTENSION' is not allowed in SDL files.\n\nSDL files should only contain CREATE and COMMENT statements to declare the desired schema."
}
Remove the CREATE EXTENSION and COMMENT ON EXTENSION lines (and, in a further attempt, every
other reference to public). check now passes. Run bytebase-action rollout --declarative ...
against an empty database that has pgcrypto installed.
Result — case B, task fails during Command Execute:
ERROR: cannot drop function armor(bytea) because extension pgcrypto requires it (SQLSTATE 2BP01)
The transaction rolls back, so nothing is damaged — but the rollout can never succeed.
Removing COMMENT ON SCHEMA "public" as well does not help: the differ compares against the whole
database, not only the schemas named in the SDL file, so the extension's functions are still seen
as undeclared objects to drop.
Expected behaviour
Either:
the differ excludes extension-owned objects — they are identifiable via pg_depend
(deptype = 'e'), which is the conventional approach and what pgschema does; or
SDL accepts CREATE EXTENSION as a declarable object, so the differ knows the extension is
desired and leaves its objects alone.
The first seems more consistent with SDL only permitting CREATE/COMMENT. Either way, Export Schema output should be valid as an SDL file — currently it is not, for any database with an
extension.
Actual behaviour
Declarative mode is unusable on any PostgreSQL database with an installed extension. Since pgcrypto
and uuid-ossp are extremely common, this likely affects many real schemas.
Confirmed — tracked internally as BYT-10083. The fix models extension ownership in the schema catalog so the differ treats extensions as units; CREATE EXTENSION becomes declarable as part of it. Also covers #7882 and #10513.
Activity
rebelice commentedon Aug 20, 2026
Confirmed — tracked internally as BYT-10083. The fix models extension ownership in the schema catalog so the differ treats extensions as units; CREATE EXTENSION becomes declarable as part of it. Also covers #7882 and #10513.
jowinjestine commentedon Aug 24, 2026
Looking forward to seeing this bugfix so I can push to use this internal at my organization