From: 'Ludek Finstrle' <luf@pzkagis.cz>
To: Hiroshi Inoue <inoue@tpf.co.jp>
Cc: 'Ludek Finstrle' <luf@pzkagis.cz>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Bug in clear_error in SQLExecute?
Date: Sat, 10 Jan 2004 15:12:36 +0100
Message-ID: <20040110141236.GA19067@soptik.pzkagis.cz> (raw)
In-Reply-To: <007d01c3d77c$dbce6900$3d283ddb@PbgX>
References: <20040109212710.GA16057@soptik.pzkagis.cz>
<007d01c3d77c$dbce6900$3d283ddb@PbgX>
> Hiroshi Inoue
>
> > Ludek Finstrle
> >
> > I think I found a bug in SQLExecute. IMHO SC_clean_error should be
> > called there only sometimes as you can see from my patch created
> > againist fresh CVS snapshot.
> >
> > Without this patch application fail becouse error is produced in Fetch
> > instead of in Execute.
>
> Could you explain the examples ?
I can. I attach part of mylog output where the problem is described.
I try explain it in english and I hope you can understand.
Application call select on non-exists table. It's allocate stmt then
it prepare stmt. Then it call NumResultCols. Error raise in this
function but it return SQL_SUCCESS (I think this is right) and set
stmt status to STMT_PREMATURE. Then it call Execute. There is
clean_error so it return SQL_SUCCES and I think this is wrong>.
After it app call Fetch and it fail.
Application doesn't expect failure in Fetch after success execute.
I don't have source for app because it's commercial one. So I can't
change it's behaviour. I tried create table but app fails later.
When I patch psqlodbc it's doing what I expect. But I'm not sure
if it's good for all situations. I don't see so far.
The opposite one situation which I think about is execute twice or
more times with different binding parameters. So I add test status
to STMT_FINISHED. As I said I'm not sure if it's correct.
Best regards
Luf
Attachments:mylog_clean_error.log (text/plain, 3.7K) download
[1080][[SQLAllocHandle]][1080]PGAPI_AllocStmt: entering...
[1080]**** PGAPI_AllocStmt: hdbc = 22773424, stmt = 22850256
[1080]CC_add_statement: self=22773424, stmt=22850256
[1080][[SQLGetStmtAttr]] Handle=22850256 10010
[1080]PGAPI_GetStmtAttr Handle=22850256 10010
[1080][[SQLGetStmtAttr]] Handle=22850256 10011
[1080]PGAPI_GetStmtAttr Handle=22850256 10011
[1080][[SQLGetStmtAttr]] Handle=22850256 10012
[1080]PGAPI_GetStmtAttr Handle=22850256 10012
[1080][[SQLGetStmtAttr]] Handle=22850256 10013
[1080]PGAPI_GetStmtAttr Handle=22850256 10013
[1080][SQLPrepare][1080]PGAPI_Prepare: entering...
[1080]**** PGAPI_Prepare: STMT_ALLOCATED, copy
[1080][SQLNumResultCols][1080]PGAPI_NumResultCols: entering...
[1080]SC_pre_execute: status = 1
[1080] preprocess: status = READY
[1080]PGAPI_Execute: entering...
[1080]PGAPI_Execute: clear errors...
[1080]recycle statement: self= 22850256
[1080]APD_free_params: ENTER, self=22850508
[1080]IPD_free_params: ENTER, self=22850572
[1080]IPD_free_params: EXIT
[1080]PDATA_free_params: ENTER, self=22850680
[1080]Exec_with_parameters_resolved: copying statement params: trans_status=1, len=105, stmt='select table_name,column_name,join_table,code_column,text_column,index_column,index_value from mscodelist'
[1080] stmt_with_params = 'declare SQL_CUR015CAAD0 cursor for select table_name,column_name,join_table,code_column,text_column,index_column,index_value from mscodelist'
[1080] about to begin a transaction on statement = 22850256
[1080] Sending SELECT statement on stmt=22850256, cursor_name='SQL_CUR015CAAD0'
[1080]send_query(): conn=22773424, query='declare SQL_CUR015CAAD0 cursor for select table_name,column_name,join_table,code_column,text_column,index_column,index_value from mscodelist'
[1080]send_query: done sending query
[1080]in QR_Constructor
[1080]exit QR_Constructor
[1080]read 54, global_socket_buffersize=4096
[1080]send_query: got id = 'C'
[1080]send_query: ok - 'C' - BEGIN
[1080]send_query: setting cmdbuffer = 'BEGIN'
[1080]send_query: got id = 'E'
[1080]send_query: 'E' - ERROR: Relation 'mscodelist' does not exist
[1080]read 1, global_socket_buffersize=4096
[1080]send_query: got id = 'Z'
[1080] done sending the query:
[1080]send_query(): conn=22773424, query='ROLLBACK'
[1080]send_query: done sending query
[1080]in QR_Constructor
[1080]exit QR_Constructor
[1080]read 11, global_socket_buffersize=4096
[1080]send_query: got id = 'C'
[1080]send_query: ok - 'C' - ROLLBACK
[1080]send_query: setting cmdbuffer = 'ROLLBACK'
[1080]send_query: returning res = 22849808
[1080]send_query: got id = 'Z'
[1080]CC_abort: sending ABORT!
[1080]QResult: in DESTRUCTOR
[1080]QResult: free memory in, fcount=0
[1080]QResult: free memory out
[1080]QResult: exit DESTRUCTOR
[1080]STATEMENT ERROR: func=SC_execute, desc='', errnum=7, errmsg='Error while executing the query'
[1080]CONN ERROR: func=SC_execute, desc='', errnum=110, errmsg='ERROR: Relation 'mscodelist' does not exist'
[1080] preprocess: after status = FINISHED, so set PREMATURE
[1080]PGAPI_NumResultCols: result = 22850000, status = 2, numcols = 0
[1080][SQLExecute][1080]PGAPI_Execute: entering...
[1080]PGAPI_Execute: premature statement but return SQL_SUCCESS
[1080][[SQLFetch]][1080]PGAPI_ExtendedFetch: stmt=22850256
[1080]STATEMENT ERROR: func=PGAPI_ExtendedFetch, desc='', errnum=15, errmsg='Bindings were not allocated properly.'
[1080]CONN ERROR: func=PGAPI_ExtendedFetch, desc='', errnum=110, errmsg='ERROR: Relation 'mscodelist' does not exist'
[1080][SQLDisconnect][1080]PGAPI_Disconnect: entering...
[1080]PGAPI_Disconnect: about to CC_cleanup
[1080]in CC_Cleanup, self=22773424
[1080]after CC_abort
[1080]SOCK_Destructor
[1080]after SOCK destructor
[1080]SC_Destructor: self=22818240, self->result=0, self->hdbc=0
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-odbc@postgresql.org
Cc: luf@pzkagis.cz, inoue@tpf.co.jp
Subject: Re: Bug in clear_error in SQLExecute?
In-Reply-To: <20040110141236.GA19067@soptik.pzkagis.cz>
References: <20040109212710.GA16057@soptik.pzkagis.cz> <007d01c3d77c$dbce6900$3d283ddb@PbgX> <20040110141236.GA19067@soptik.pzkagis.cz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox