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

BUG at gds__sqlcode [CORE2082] #962

Open
firebird-issue-importer opened this issue Sep 16, 2008 · 1 comment
Open

BUG at gds__sqlcode [CORE2082] #962

firebird-issue-importer opened this issue Sep 16, 2008 · 1 comment

Comments

@firebird-issue-importer

Submitted by: @ibprovider

gds.cpp [version 1.265]

gds__sqlcode

if (!have_sqlcode)
{
// Now check the hard-coded mapping table of gds_codes to sql_codes
const SLONG gdscode = *s; // instead a "= status_vector[1];"

if (gdscode) {

---
Also, I think, gds__sqlcode must have a control for status_vector bounds. For example:

if(status_vector==NULL)
return ISC_GENERIC_SQLCODE;

const ISC_STATUS* vec_cur=status_vector;
const ISC_STATUS* const vec_end=status_vector+ISC_STATUS_LENGTH;

structure::t_value_with_null<ISC_LONG> result;

try
{
for(;;)
{
assert(vec_cur<=vec_end);
assert(status_vector<=vec_cur);

if(vec_cur==vec_end)
break;

if((*vec_cur)==isc_arg_end)
break;

if((*vec_cur)==isc_arg_gds)
{
if((++vec_cur)==vec_end)
break;

if\(\(\*vec\_cur\)==isc\_sqlerr\) //status vector has the explicit SQL error code
\{    
 if\(\(\+\+vec\_cur\)==vec\_end\)
  break;

 if\(\(\*vec\_cur\)\!=isc\_arg\_number\)
  continue;
 
 if\(\(\+\+vec\_cur\)==vec\_end\)
  break;

 result=\*vec\_cur;

 break;
\}//if isc\_sqlerr

if\(result\.null\(\)\)
\{
 // Now check the hard\-coded mapping table of gds\_codes to sql\_codes
 const ISC\_LONG x=\(\*vec\_cur\)?ISC\_\_GetSqlCodeByGdsCode\(\*vec\_cur\):0;
 
 if\(x==0 \|\| x\!=ISC\_GENERIC\_SQLCODE\)
  result=x;
\}//if sqlcode\.null\(\)

\+\+vec\_cur; //<gds\_code\_id\>

continue;

}//if isc_arg_gds

if((*vec_cur)==isc_arg_cstring)
{
if(vec_end-vec_cur<3)
break;

vec\_cur\+=3; //isc\_arg\_cstring <len\> <str ptr\>

continue;

}//if isc_arg_cstring

//skip: isc_arg_* <item>
if(vec_end-vec_cur<2)
break;

vec_cur+=2;
}//for
}
catch(...)
{
result.reset();
}

return result.value_or_default(ISC_GENERIC_SQLCODE);

----
ISC_LONG ISC__GetSqlCodeByGdsCode(const ISC_STATUS GdsCode)
{
//decode original error code
USHORT status_fac = 0;
USHORT status_class = 0;

const ISC_STATUS status_err_num=
FB_Link_ISC_Err__DecodeStatus(GdsCode,&status_fac,&status_class);

if(status_fac==ISC_MSG_FAC__SQL_ERR || status_fac==ISC_MSG_FAC__SQL_WARN)
return status_err_num;

if(const TISC_MsgData*
const pX=ISC__GetMsgData(TFB_Link_ISC_MsgID(status_fac,status_err_num)))
{
return pX->SqlCode;
}

return ISC_GENERIC_SQLCODE;
}//ISC__GetSqlCodeByGdsCode

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Sep 16, 2008

Modified by: @ibprovider

priority: Major [ 3 ] => Trivial [ 5 ]

summary: BUG at isc_sqlcode => BUG at gds__sqlcode

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

Successfully merging a pull request may close this issue.

None yet
1 participant