Skip to content

Support setting a database's default character set and collation on create - #176

Closed
MartinKoeditz wants to merge 3 commits into
asfernandes:masterfrom
MartinKoeditz:master
Closed

MartinKoeditz wants to merge 3 commits into
asfernandes:masterfrom
MartinKoeditz:master

Conversation

@MartinKoeditz

Copy link
Copy Markdown
Contributor

CreateDatabaseOptions gains defaultCharSet, defaultCollation and pageSize. The existing DPB-based creation path (isc_dpb_lc_ctype etc.) has no DPB item for a database's default character set/collation — that can only be expressed through a full CREATE DATABASE statement, the same way isql does it. When defaultCharSet is set, AttachmentImpl.createDatabase() now builds that statement and executes it via IUtil::executeCreateDatabase instead of going through the dispatcher's DPB-based createDatabase. The DPB path is kept as the default for callers who don't need this (it also supports forcedWrite/role/setDatabaseReadWriteMode, which the bare CREATE DATABASE grammar has no clause for).

Includes a test verifying both that the default character set is persisted and that the default collation is genuinely in effect (case/accent-insensitive comparison without an explicit COLLATE clause).

…reate

CreateDatabaseOptions gained defaultCharSet, defaultCollation and pageSize.
The existing DPB-based creation path (isc_dpb_lc_ctype etc.) has no DPB item
for a database's default character set/collation - that can only be
expressed through a full CREATE DATABASE statement, the same way isql does
it. When defaultCharSet is set, AttachmentImpl.createDatabase() now builds
that statement and executes it via IUtil::executeCreateDatabase instead of
going through the dispatcher's DPB-based createDatabase.
Verifies both that the database's default character set is actually
persisted (via rdb$database.rdb$character_set_name) and, more importantly,
that the default collation is genuinely in effect: a column created without
any explicit COLLATE clause is compared against a differently cased,
unaccented literal, which only matches under UNICODE_CI_AI.
…ing executeCreateDatabase

executeCreateDatabase takes a bare CREATE DATABASE statement with no DPB, and that
statement's grammar has no clause for forcedWrite/role/setDatabaseReadWriteMode -
those are DPB-only. Switching unconditionally would silently drop them for every
caller (e.g. the shared test suite's default forcedWrite: false).
@MartinKoeditz

Copy link
Copy Markdown
Contributor Author

Closing this — it turned out the same result can be achieved after creation with plain SQL (ALTER DATABASE SET DEFAULT CHARACTER SET … / ALTER CHARACTER SET … SET DEFAULT COLLATION …, Firebird 3+), so no driver change is needed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant