Hi all,
Server is Firebird 2.1.
Actually if I've a user DOMAIN defined as
CREATE DOMAIN TIPOPERC AS
NUMERIC(15,3)
DEFAULT 0;
and a table defined
CREATE TABLE TEST (
PK1 INTEGER NOT NULL,
PERCENTUALE_RATA TIPOPERC NOT NULL /* TIPOPERC = NUMERIC(15,3) DEFAULT 0 */,
);
As for Firebird definition, if in RDB$RELATION_FIELDS.RDB$DEFAULT_VALUE is NULL, then its value must be kept from underlying RDB$FIELDS.
In driver the query from system RDB$RELATION_FIELDS RF JOIN RDB$FIELDS F keeps only the first one, ignoring the latter when the first is not defined. This gives incorrect results my example, and don't keep the correct default value the field would keep.
Note that RF.DEFAULT_VALUE can redefine F.DEFAULT_VALUE, so in the query RF.RDB$DEFAULT_VALUE needs to be changed in
COALESCE ( RF.RDB$DEFAULT_VALUE, F.RDB$DEFAULT_VALUE)
Hth.