pgsqODBC binding parameters II (fwd) - Mailing list pgsql-odbc
From | Ludek Finstrle |
---|---|
Subject | pgsqODBC binding parameters II (fwd) |
Date | |
Msg-id | 20010321095848.C21919@anxur.fi.muni.cz Whole thread Raw |
List | pgsql-odbc |
Hello, please, could some expert answer? Luf ----- Forwarded message from Ludek Finstrle <xfinstrl@informatics.muni.cz> ----- > From: Ludek Finstrle <xfinstrl@informatics.muni.cz> > Subject: [ODBC] pgsqODBC binding parameters II > Date: Fri, 9 Feb 2001 14:10:58 +0100 > To: pgsql-odbc@postgresql.org > Sender: pgsql-odbc-owner@postgresql.org > > Hello, > > now I try my problem with psqlODBC version 7.01.02 and I still have problem. > I resolve it (patch included) but I don't now if it is good problem solution. > So this is problem log: > > mylog_XXX.log: > ------ > SQLAllocStmt: entering... > **** SQLAllocStmt: hdbc = 21789560, stmt = 22872128 > CC_add_statement: self=21789560, stmt=22872128 > SQLPrepare: entering... > **** SQLPrepare: STMT_ALLOCATED, copy > SC_pre_execute: status = 1 > preprocess: status = READY > SQLExecute: entering... > SQLExecute: clear errors... > SQLExecute: copying statement params: trans_status=1, len=111, stmt='insert into category (mslink, cname, indextype, indexname,indexlevel) values (?, 'alfik', 'tiled', 'alfik', 1)' > stmt_with_params = 'insert into category (mslink, cname, indextype, indexname, indexlevel) values (' > it's NOT a select statement: stmt=22872128 > send_query(): conn=21789560, query='insert into category (mslink, cname, indextype, indexname, indexlevel) values (' > send_query: done sending query > send_query: got id = 'Z' > read 44, global_socket_buffersize=4096 > send_query: got id = 'E' > send_query: 'E' - ERROR: parser: parse error at or near "" > in QR_Constructor > exit QR_Constructor > STATEMENT ERROR: func=SC_execute, desc='', errnum=-1, errmsg='Error while executing the query (non-fatal)' > CONN ERROR: func=SC_execute, desc='', errnum=110, errmsg='ERROR: parser: parse error at or near ""' > preprocess: after status = FINISHED, so set PREMATURE > SQLNumResultCols: result = 21834240, status = 2, numcols = 0 > SQLBindParameter: entering... > SQLBindParamater: ipar=0, paramType=1, fCType=-16, fSqlType=4, cbColDef=10, ibScale=0, rgbValue=1, *pcbValue = -2, data_at_exec= 0 > SQLExecute: entering... > STATEMENT ERROR: func=SQLExecute, desc='', errnum=-1, errmsg='Error while executing the query (non-fatal)' > CONN ERROR: func=SQLExecute, desc='', errnum=110, errmsg='ERROR: parser: parse error at or near ""' > SQLExecute: premature statement so return SQL_ERROR > **** SQLError: henv=0, hdbc=0, hstmt=22872128 > SC_get_error: status = -1, msg = #Error while executing the query (non-fatal); > ERROR: parser: parse error at or near ""# > szSqlState = '00000', szError='Error while executing the query (non-fatal); > ERROR: parser: parse error at or near ""' > **** SQLError: henv=0, hdbc=0, hstmt=22872128 > returning NO_DATA_FOUND > SQLFreeStmt: entering...hstmt=22872128, fOption=1 > QResult: in DESTRUCTOR > QResult: free memory in, fcount=0 > QResult: free memory out > QResult: exit DESTRUCTOR > SC_Destructor: self=22872128, self->result=0, self->hdbc=21789560 > SC_free_params: ENTER, self=22872128 > SC_free_params: EXIT > SC_Destructor: EXIT > > psqlodbc_XXX.log: > ----- > > conn=21789560, query='insert into category (mslink, cname, indextype, indexname, indexlevel) values (' > ERROR from backend during send_query: 'ERROR: parser: parse error at or near ""' > STATEMENT ERROR: func=SC_execute, desc='', errnum=-1, errmsg='Error while executing the query (non-fatal)' > ------------------------------------------------------------ > hdbc=21789560, stmt=22872128, result=21834240 > manual_result=0, prepare=1, internal=0 > bindings=0, bindings_allocated=0 > parameters=0, parameters_allocated=0 > statement_type=1, statement='insert into category (mslink, cname, indextype, indexname, indexlevel) values(?, 'alfik', 'tiled', 'alfik', 1)' > stmt_with_params='insert into category (mslink, cname, indextype, indexname, indexlevel) values (' > data_at_exec=-1, current_exec_param=-1, put_data=0 > currTuple=-1, current_col=-1, lobj_fd=-1 > maxRows=0, rowset_size=1, keyset_size=0, cursor_type=0, scroll_concurrency=1 > cursor_name='SQL_CUR015D0040' > ----------------QResult Info ------------------------------- > fields=21830064, manual_tuples=0, backend_tuples=0, tupleField=0, conn=0 > fetch_count=0, fcount=0, num_fields=0, cursor='(NULL)' > message='(NULL)', command='(NULL)', notice='(NULL)' > status=6, inTuples=0 > CONN ERROR: func=SC_execute, desc='', errnum=110, errmsg='ERROR: parser: parse error at or near ""' > ------------------------------------------------------------ > henv=21823504, conn=21789560, status=1, num_stmts=16 > sock=21830208, stmts=21830128, lobj_type=-999 > ---------------- Socket Info ------------------------------- > socket=164, reverse=0, errornumber=0, errormsg='(NULL)' > buffer_in=21796032, buffer_out=21800136 > buffer_filled_in=44, buffer_filled_out=0, buffer_read_in=44 > STATEMENT ERROR: func=SQLExecute, desc='', errnum=-1, errmsg='Error while executing the query (non-fatal)' > ------------------------------------------------------------ > hdbc=21789560, stmt=22872128, result=21834240 > manual_result=0, prepare=1, internal=0 > bindings=0, bindings_allocated=0 > parameters=21834176, parameters_allocated=1 > statement_type=1, statement='insert into category (mslink, cname, indextype, indexname, indexlevel) values(?, 'alfik', 'tiled', 'alfik', 1)' > stmt_with_params='insert into category (mslink, cname, indextype, indexname, indexlevel) values (' > data_at_exec=-1, current_exec_param=-1, put_data=0 > currTuple=-1, current_col=-1, lobj_fd=-1 > maxRows=0, rowset_size=1, keyset_size=0, cursor_type=0, scroll_concurrency=1 > cursor_name='SQL_CUR015D0040' > ----------------QResult Info ------------------------------- > fields=21830064, manual_tuples=0, backend_tuples=0, tupleField=0, conn=0 > fetch_count=0, fcount=0, num_fields=0, cursor='(NULL)' > message='(NULL)', command='(NULL)', notice='(NULL)' > status=6, inTuples=0 > CONN ERROR: func=SQLExecute, desc='', errnum=110, errmsg='ERROR: parser: parse error at or near ""' > ------------------------------------------------------------ > henv=21823504, conn=21789560, status=1, num_stmts=16 > sock=21830208, stmts=21830128, lobj_type=-999 > ---------------- Socket Info ------------------------------- > socket=164, reverse=0, errornumber=0, errormsg='(NULL)' > buffer_in=21796032, buffer_out=21800136 > buffer_filled_in=44, buffer_filled_out=0, buffer_read_in=44 > > > End of logs. > > > So I try make a patch. Could someone check or try it? > Here is a patch created with 'diff -iwaru postsrc-orig postsrc-patched': > > -------------------------- diff begin -------------------------------- > diff -iwaru postsrc-orig/bind.c postsrc-patched/bind.c > --- postsrc-orig/bind.c Fri Feb 9 14:01:02 2001 > +++ postsrc-patched/bind.c Wed Feb 7 16:18:52 2001 > @@ -129,11 +129,10 @@ > stmt->parameters[ipar].EXEC_buffer = NULL; > } > > - /* Data at exec macro only valid for C char/binary data */ > - if ((fSqlType == SQL_LONGVARBINARY || fSqlType == SQL_LONGVARCHAR) && pcbValue && *pcbValue <= SQL_LEN_DATA_AT_EXEC_OFFSET) > + /* Luf Begin */ > stmt->parameters[ipar].data_at_exec = TRUE; > - else > - stmt->parameters[ipar].data_at_exec = FALSE; > + /* Luf End */ > + > > mylog("SQLBindParamater: ipar=%d, paramType=%d, fCType=%d, fSqlType=%d, cbColDef=%d, ibScale=%d, rgbValue=%d, *pcbValue= %d, data_at_exec = %d\n", ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, pcbValue ? *pcbValue:-777, stmt->parameters[ipar].data_at_exec); > > diff -iwaru postsrc-orig/execute.c postsrc-patched/execute.c > --- postsrc-orig/execute.c Fri Feb 9 14:01:03 2001 > +++ postsrc-patched/execute.c Wed Feb 7 16:35:06 2001 > @@ -190,6 +190,9 @@ > StatementClass *stmt = (StatementClass *) hstmt; > ConnectionClass *conn; > int i, retval; > +/* Luf Begin */ > +short ipar; > +/* Luf End */ > > > mylog("%s: entering...\n", func); > @@ -277,6 +280,18 @@ > if (stmt->data_at_exec > 0) > return SQL_NEED_DATA; > > + /* Luf - Begin */ > + /* Are there any data at execution parameters? (yes = return need data) */ > + SQLNumParams(stmt,&ipar); > + if (!((stmt->data_at_exec == -1) && (ipar == 0)) && (ipar > stmt->data_at_exec)) { > + stmt->data_at_exec = ipar; > + stmt->current_exec_param = 0; > + stmt->put_data = TRUE; > + mylog("SQL need data,\n"); > + return SQL_NEED_DATA; > + } > + /* Luf - End */ > > mylog("%s: copying statement params: trans_status=%d, len=%d, stmt='%s'\n", func, conn->transact_status, strlen(stmt->statement),stmt->statement); > > @@ -689,28 +704,43 @@ > mylog("lo_write: cbValue=%d, wrote %d bytes\n", cbValue, retval); > > } > - else { /* for handling text fields and small binaries */ > + /* Luf Begin */ > + else { /* for handling fields */ > + /* Luf End */ > > if (cbValue == SQL_NTS) { > current_param->EXEC_buffer = strdup(rgbValue); > if ( ! current_param->EXEC_buffer) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > - stmt->errormsg = "Out of memory in SQLPutData (2)"; > + stmt->errormsg = "Out of memory in SQLPutData (2-1)"; > SC_log_error(func, "", stmt); > return SQL_ERROR; > } > - } > - else { > + /* Luf Begin */ > + } else if (cbValue == SQL_NTSL) { > + /* Luf End */ > current_param->EXEC_buffer = malloc(cbValue + 1); > if ( ! current_param->EXEC_buffer) { > stmt->errornumber = STMT_NO_MEMORY_ERROR; > - stmt->errormsg = "Out of memory in SQLPutData (2)"; > + stmt->errormsg = "Out of memory in SQLPutData (2-2)"; > SC_log_error(func, "", stmt); > return SQL_ERROR; > } > memcpy(current_param->EXEC_buffer, rgbValue, cbValue); > current_param->EXEC_buffer[cbValue] = '\0'; > + /* Luf Begin */ > + } else { > + mylog("DataPut cbValue = %d, rgbValue = %ld\n",current_param->buflen,*((SDWORD *) rgbValue)); > + current_param->EXEC_buffer = malloc(current_param->buflen); > + if ( ! current_param->EXEC_buffer) { > + stmt->errornumber = STMT_NO_MEMORY_ERROR; > + stmt->errormsg = "Out of memory in SQLPutData (2-3)"; > + SC_log_error(func, "", stmt); > + return SQL_ERROR; > + } > + memcpy(current_param->EXEC_buffer, rgbValue, current_param->buflen); > } > + /* Luf End */ > } > } > > diff -iwaru postsrc-orig/parse.c postsrc-patched/parse.c > --- postsrc-orig/parse.c Fri Feb 9 14:01:04 2001 > +++ postsrc-patched/parse.c Wed Feb 7 16:29:20 2001 > @@ -691,6 +691,9 @@ > stmt->parse_status = STMT_PARSE_FATAL; > return FALSE; > } > + /* Luf Bug fix */ > + stmt->fi = fi; > + /* Luf End */ > } > > /*------------------------------------------------------------- */ > diff -iwaru postsrc-orig/results.c postsrc-patched/results.c > --- postsrc-orig/results.c Fri Feb 9 14:01:05 2001 > +++ postsrc-patched/results.c Wed Feb 7 16:33:36 2001 > @@ -136,19 +136,21 @@ > > if ( ! parse_ok) { > > + /* Luf - Begin > SC_pre_execute(stmt); > + /* Luf - End */ > result = SC_get_Result(stmt); > > mylog("SQLNumResultCols: result = %u, status = %d, numcols = %d\n", result, stmt->status, result != NULL ? QR_NumResultCols(result): -1); > if (( ! result) || ((stmt->status != STMT_FINISHED) && (stmt->status != STMT_PREMATURE)) ) { > /* no query has been executed on this statement */ > - stmt->errornumber = STMT_SEQUENCE_ERROR; > - stmt->errormsg = "No query has been executed with that handle"; > - SC_log_error(func, "", stmt); > - return SQL_ERROR; > - } > - > + /* Luf - Begin */ > + stmt->nfld = 0; > + *pccol = stmt->nfld; > + } else { > *pccol = QR_NumResultCols(result); > + } > + /* Luf End */ > } > > return SQL_SUCCESS; > --------------------------- diff end --------------------------------- > > Luf ----- End forwarded message -----
pgsql-odbc by date: