Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to violate constraint for domain-based BLOB field raises message that does not relates to actual problem [CORE6297] #6539

Open
firebird-automations opened this issue May 5, 2020 · 1 comment

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

Consider script (i've checked on 2.5.9, 3.0.6 and 4.0.0 -- result the same):

-- set names utf8;
shell del c:\temp\tmp4t_blob.fdb 2>nul;
create database 'localhost:c:\temp\tmp4t_blob.fdb' user 'SYSDBA' password 'masterkey';
show version;

set blob all;
set list on;

create domain dm_char as varchar(1) default 'W' check( value in ('W', 'R') );
create domain dm_blob as blob sub_type text default 'W' check( value in ('W', 'R') );

recreate table t_char( fld_char dm_char );
recreate table t_blob( fld_blob dm_blob );
commit;

insert into t_char default values returning fld_char;
insert into t_blob default values returning fld_blob;
rollback;

alter domain dm_char set default 'A'; -- new default value VIOLATES domain constraint
alter domain dm_blob set default 'A'; -- new default value VIOLATES domain constraint

insert into t_char default values returning fld_char; -- [ 1 ]
insert into t_blob default values returning fld_blob; -- [ 2 ]
rollback;

Statement marked as [ 1 ] raises: "SQLSTATE = 23000 ... for column "T_CHAR"."FLD_CHAR", value "A", i.e. all OK
Statement marked as [ 2 ] raises: "SQLSTATE = 22018 / conversion error from string "BLOB"", but character 'A' belongs to the same ASCII-list as those which are in CHECK-list: 'W' , R'

IMO, it will be good if message in this case will be equal to [ 1 ].

@firebird-automations
Copy link
Collaborator Author

Commented by: @aafemt

It would require to implement implicit cast from BLOB to varchar. The error you see is exactly result of the attempt to show content of BLOB in message.

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

No branches or pull requests

1 participant