Epic: CRDB-62146
Depends on #166933, #166934.
Summary
Implement the SET DEFAULT and DROP DEFAULT subcommands for ALTER DOMAIN in the declarative schema changer. These control the default value expression applied to columns using the domain type.
Implementation Plan
-
Create pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_domain_set_default.go:
alterDomainSetDefault handler: add or replace the DomainTypeDefault element with the new default expression
alterDomainDropDefault handler: transition the DomainTypeDefault element to ABSENT
-
Register both handlers in supportedAlterDomainStatements.
-
Type-check the default expression against the domain's base type.
-
Ensure the default expression is serialized correctly in the descriptor.
Key Reference Files
Testing
- Logic tests:
ALTER DOMAIN d SET DEFAULT 42, ALTER DOMAIN d DROP DEFAULT
- Verify default applies to subsequent INSERTs using the domain type
- Verify DROP DEFAULT removes the default
Jira issue: CRDB-62162
Epic: CRDB-62146
Depends on #166933, #166934.
Summary
Implement the
SET DEFAULTandDROP DEFAULTsubcommands forALTER DOMAINin the declarative schema changer. These control the default value expression applied to columns using the domain type.Implementation Plan
Create
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/alter_domain_set_default.go:alterDomainSetDefaulthandler: add or replace theDomainTypeDefaultelement with the new default expressionalterDomainDropDefaulthandler: transition theDomainTypeDefaultelement to ABSENTRegister both handlers in
supportedAlterDomainStatements.Type-check the default expression against the domain's base type.
Ensure the default expression is serialized correctly in the descriptor.
Key Reference Files
alter_table_alter_column_default.go(pattern for column defaults)Testing
ALTER DOMAIN d SET DEFAULT 42,ALTER DOMAIN d DROP DEFAULTJira issue: CRDB-62162