Issue Details (XML | Word | Printable)

Key: CORE-2082
Type: Bug Bug
Status: Open Open
Priority: Trivial Trivial
Assignee: Unassigned
Reporter: Kovalenko Dmitry
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Firebird Core

BUG at gds__sqlcode

Created: 16/Sep/08 07:10 AM   Updated: 16/Sep/08 07:13 AM
Component/s: API / Client Library
Affects Version/s: 2.5 Alpha 1
Fix Version/s: None


 Description  « Hide
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



 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
There are no comments yet on this issue.