Subject Re: Proposal to add SQLState to Vulcan
Author Bill Oliver
Hi all!

I've pushed my sqlstate changes to vulcan. You can try it for
yourself by getting these changes, going into ISQL and doing

SET SQLSTATE ON;

and then you will see sqlstate when you get an error.

I also took another big lift of ISQL from FB2 release back to
Vulcan, and some old FB2 changes of Claudio's that never made it
into Vulcan stream.

For you reference, I have uploaded file sqlstates.sql to src/msgs/,
same as msg.gbak directory. This file can be used as a starting
point for applying these changes to the FB2 message database.

Here are changes that I made since i first posted proposed sql
states, including Roman's suggestions:

UPDATE SYSTEM_ERRORS SET SQL_CLASS = '54', SQL_SUBCLASS = '011'
WHERE GDS_SYMBOL = 'dsql_max_sort_items';
UPDATE SYSTEM_ERRORS SET SQL_CLASS = '54', SQL_SUBCLASS = '011'
WHERE GDS_SYMBOL = 'dsql_max_group_items';
UPDATE SYSTEM_ERRORS SET SQL_CLASS = '54', SQL_SUBCLASS = '000'
WHERE GDS_SYMBOL = 'version_err';
UPDATE SYSTEM_ERRORS SET SQL_CLASS = '54', SQL_SUBCLASS = '000'
WHERE GDS_SYMBOL = 'index_root_page_full';
UPDATE SYSTEM_ERRORS SET SQL_CLASS = '42', SQL_SUBCLASS = '000'
WHERE GDS_SYMBOL = 'partner_idx_incompat_type ';
UPDATE SYSTEM_ERRORS SET SQL_CLASS = '42', SQL_SUBCLASS = '000'
WHERE GDS_SYMBOL = 'partner_idx_not_found';
UPDATE SYSTEM_ERRORS SET SQL_CLASS = '54', SQL_SUBCLASS = '000'
WHERE GDS_SYMBOL = 'blktoobig';
UPDATE SYSTEM_ERRORS SET SQL_CLASS = '08', SQL_SUBCLASS = '003'
WHERE GDS_SYMBOL = 'bad_trans_handle';
UPDATE SYSTEM_ERRORS SET SQL_CLASS = '22', SQL_SUBCLASS = '001'
WHERE GDS_SYMBOL = 'bad_msg_vec';

As always, let me know if you see something funny.

Finally, here are test case results from a new test case I ran
against SF Vulcan before I made this push:

C:\workspace\vj>
C:\workspace\vj>
C:\workspace\vj>isql -i ddl\vulcan\sqlstate1.sql -m -e
Use CONNECT or CREATE DATABASE to specify a database
-- new test cases for sqlstate
-- tests are not exhaustive, but hopefully provide good coverage
set names ascii;
set sqlstate on;
create database 'test.fdb';
create table test (i integer);
insert into test values (1);
insert into test values (2);
commit;
-- cardinality, 21000
select * from test where i = (select * from test) ;

I
============
Statement failed, SQLCODE = -811, SQLSTATE = 21000
multiple rows in singleton select
-- domain not found, 42000 - syntax error or access violation
drop domain NO_SUCH_DOMAIN;
Statement failed, SQLCODE = -607, SQLSTATE = 42000
unsuccessful metadata update
-Domain not found
-- generator not found, 42000
drop generator NO_SUCH_GEN;
Statement failed, SQLCODE = -607, SQLSTATE = 42000
unsuccessful metadata update
-Generator NO_SUCH_GEN not found
-- duplicate index, 42S11
create table idx_test (i integer);
create index i1 on idx_test (i);
create index i1 on idx_test (i);
Statement failed, SQLCODE = -607, SQLSTATE = 42S11
unsuccessful metadata update
-Index I1 already exists
-attempt to store duplicate value (visible to active transactions)
in unique ind
ex "RDB$INDEX_5"
-- column already exists, 42S21
create table test_add_column (i integer);
alter table test_add_column add i integer;
Statement failed, SQLCODE = -607, SQLSTATE = 42S21
unsuccessful metadata update
-Column I already exists
-attempt to store duplicate value (visible to active transactions)
in unique ind
ex "RDB$INDEX_15"
-- column not found, 42S22
select boogie from rdb$database;
Statement failed, SQLCODE = -206, SQLSTATE = 42S22
SQL error code = -206
-Column unknown
-BOOGIE
-At line 2, column 15.
create index i_nf on test(NO_COL) ;
Statement failed, SQLCODE = -607, SQLSTATE = 42S22
unsuccessful metadata update
-Unknown columns in index I_NF
alter table test drop NO_COL;
Statement failed, SQLCODE = -607, SQLSTATE = 42S22
unsuccessful metadata update
-Column NO_COL not found
-- table not found 42S02 - verify SQLCODE, too, please.
drop table NOSUCHTABLE;
Statement failed, SQLCODE = -607, SQLSTATE = 42S02
Table NOSUCHTABLE does not exist
-- view not found 42S02 - verify SQLCODE, too, please.
drop view NOSUCHVIEW;
Statement failed, SQLCODE = -607, SQLSTATE = 42S02
View NOSUCHVIEW does not exist
drop database;
quit;

C:\workspace\vj>