On 24-4-2017 20:50, Maxi [email protected] [firebird-support] wrote: > > > Hi everyone, > > I encountered strange behavior droping a column definition with default > value. > > The environment is Ubuntu 16.04 LTS 64 bits, Firebird version > LI-V2.5.6.27020 (Firebird 2.5 SuperClassic) > > > I'll try to explain with an example. The statement sequence is: > > 1. Create the table > CREATE TABLE "SCHEMA_AUTHOR" ("ID" integer NOT NULL PRIMARY KEY, "NAME" > varchar(255) NOT NULL, "HEIGHT" integer CHECK ("HEIGHT" >= 0)) > > 2. Popultate with some data > INSERT INTO SCHEMA_AUTHOR (ID, NAME, HEIGHT) VALUES ('1', 'Anonimus1', > NULL); > > 3. Alter the table > ALTER TABLE "SCHEMA_AUTHOR" ADD "SURNAME" varchar(15) DEFAULT 'surname > default' NOT NULL > > After step 3, I have a record with a new column with 'surname default' > value into SURNAME field. > > 4. Drop default definition > ALTER TABLE "SCHEMA_AUTHOR" ALTER COLUMN "SURNAME" DROP DEFAULT > > After step 4, the SURNAME field value is setting to empty string ('') > > Is that the correct behavior ?
Yes and no. Yes this is how Firebird works, and no it doesn't conform to the behavior expected by the SQL standard. Firebird 3 does it better, but some people consider that to be a bug (see CORE-5507 and the accompanying discussion on firebird-devel). Mark -- Mark Rotteveel
