Re: pgsqODBC binding parameters II (fwd) - Mailing list pgsql-odbc
From | Ludek Finstrle |
---|---|
Subject | Re: pgsqODBC binding parameters II (fwd) |
Date | |
Msg-id | 20010323112152.V21919@anxur.fi.muni.cz Whole thread Raw |
In response to | Re: pgsqODBC binding parameters II (fwd) (Hiroshi Inoue <Inoue@tpf.co.jp>) |
Responses |
Re: pgsqODBC binding parameters II (fwd)
RE: pgsqODBC binding parameters II (fwd) |
List | pgsql-odbc |
> > > Doesn't your patch change all parameters to data_at_exec ones ? > > > If so it doesn't seem good. > > > > Yes, it does. Any idea how recognize data_at_exec parameters? > > I see the following in your log. > > > SQLBindParameter: entering... > > SQLBindParamater: ipar=0, paramType=1, fCType=-16, fSqlType=4, > cbColDef=10, ibScale=0, rgbValue=1, *pcbValue = -2, data_at_exec = 0 > > '*pcbValue = -2' seems to mean SQL_DATA_AT_EXEC. Yes. It's true; > BTW I see the following in your patch. > Isn't SQL_NTSL -3L ? > If so what does 'malloc(cbValue + 1)' mean ? I want to detect char but this is wrong way. I apllied your tips and patch now looks: -------- Start patch (diff -iwaru postsrc-orig postsrc-patched) ------- diff -iwaru postsrc-orig/bind.c postsrc-patched/bind.c --- postsrc-orig/bind.c Fri Mar 23 10:37:45 2001 +++ postsrc-patched/bind.c Fri Mar 23 10:56:09 2001 @@ -143,8 +143,8 @@ 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) + /* Data at exec macro */ + if (((fSqlType == SQL_LONGVARBINARY || fSqlType == SQL_LONGVARCHAR) && pcbValue && *pcbValue <= SQL_LEN_DATA_AT_EXEC_OFFSET)|| *pcbValue == SQL_DATA_AT_EXEC) stmt->parameters[ipar].data_at_exec = TRUE; else stmt->parameters[ipar].data_at_exec = FALSE; diff -iwaru postsrc-orig/execute.c postsrc-patched/execute.c --- postsrc-orig/execute.c Fri Mar 23 10:37:47 2001 +++ postsrc-patched/execute.c Fri Mar 23 10:55:56 2001 @@ -778,33 +778,46 @@ } else - { /* for handling text fields and small - * binaries */ + { /* for handling fields */ if (cbValue == SQL_NTS) { + mylog("DataPut NTS cbValue = %d, rgbValue = %l d\n",current_param->buflen,*((SDWORD *) rgbValue)); 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 + else if (current_param->SQLType == SQL_CHAR || current_param->SQLType == SQL_VARCHAR) { { + mylog("DataPut CHAR cbValue = %d, rgbValue = %l d\n",current_param->buflen,*((SDWORD *) rgbValue)); 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'; } + else + { + mylog("DataPut other cbValue = %d, rgbValue = %l d\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, cbValue); } } diff -iwaru postsrc-orig/results.c postsrc-patched/results.c --- postsrc-orig/results.c Fri Mar 23 10:37:50 2001 +++ postsrc-patched/results.c Fri Mar 23 11:18:17 2001 @@ -154,20 +154,21 @@ if (!parse_ok) { + /* SC_pre_execute(stmt); + */ 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; + stmt->nfld = 0; + *pccol = stmt->nfld; } - + else + { *pccol = QR_NumResultCols(result); + } } return SQL_SUCCESS; -------- Start patch (diff -iwaru postsrc-orig postsrc-patched) ------- Do you see any other problems? Luf
pgsql-odbc by date: