DEFAULT uncorrecly reported from system tables.

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for InterBase & Firebird in Delphi and C++Builder
Post Reply
u.masotti
Posts: 3
Joined: Sat 20 Feb 2010 12:04

DEFAULT uncorrecly reported from system tables.

Post by u.masotti » Sun 18 Apr 2010 18:04

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.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 19 Apr 2010 10:17

Thank you for information. We have reproduced this problem and fixed it. This fix will be included in the next DbxIda build.

Post Reply