Subject | Attempting to create too large PK corrupts database |
---|---|
Author | |
Post date | 2018-11-23T01:26:27Z |
Under Firebird 2.5.8 on Windows, when I create a database (with the default page size of 4k) like this:
CREATE DATABASE 'LOCALHOST/3050:MYDB'
USER 'SYSDBA'
PASSWORD 'masterkey'
DEFAULT CHARACTER SET UTF8 COLLATION UNICODE_CI_AI;
And then execute the following script:
CONNECT 'LOCALHOST/3050:MYDB'
USER 'SYSDBA'
PASSWORD 'masterkey';
CREATE TABLE MYTABLE (
MYCOLUMN VARCHAR(254) NOT NULL PRIMARY KEY
);
I get an error as expected:
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-key size exceeds implementation restriction for index "RDB$PRIMARY1"
What is not expected, is that the database has become corrupted. At that point it's not possible to create any PK anymore, even if it should fit (e.g. VARCHAR(80)). Firebird stops complaining about the size, but still gives an error:
Statement failed, SQLSTATE = 42000
unsuccessful metadata update
-cannot create index RDB$PRIMARY2
This is the output of gfix -validate -full:
Summary of validation errors
Number of database page errors : 2
I suppose this is a bug...?