Re: More strict bind param count checking - Mailing list pgsql-odbc

From Hiroshi Inoue
Subject Re: More strict bind param count checking
Date
Msg-id 43A3301A.5070406@tpf.co.jp
Whole thread Raw
In response to Re: More strict bind param count checking  (Ludek Finstrle <luf@pzkagis.cz>)
Responses Re: More strict bind param count checking  (Ludek Finstrle <luf@pzkagis.cz>)
List pgsql-odbc
Ludek Finstrle wrote:

>>>We have problems with Visual FoxPro. It calls SQLCancel without
>>>FreeStmt(SQL_RESET_PARAMS). It leads to failure becouse next
>>>ExecDirect with fewer parameters in some cases think that it
>>>has data_at_exec (which was parameters from previous).
>>>
>>>
>>Isn't it the right solution for the problem to check data_at_exec
>>appropriately ?
>>
>>
>
>Please Hiroshi could you take a look on solution for data_at_exec check?
>I see no problem but I didn't see it in previous patch also.
>
>Thanks a lot
>
>Luf
>
>
>------------------------------------------------------------------------
>
>diff -c psqlodbc.orig\execute.c psqlodbc\execute.c
>*** psqlodbc.orig\execute.c    Tue Dec 06 21:53:30 2005
>--- psqlodbc\execute.c    Fri Dec 16 18:11:16 2005
>***************
>*** 542,547 ****
>--- 542,548 ----
>          UInt4    offset = apdopts->param_offset_ptr ? *apdopts->param_offset_ptr : 0;
>          Int4    bind_size = apdopts->param_bind_type;
>          Int4    current_row = stmt->exec_current_row < 0 ? 0 : stmt->exec_current_row;
>+         SWORD    param_count;
>
>          /*
>           *    Increment the  number of currently processed rows
>***************
>*** 549,555 ****
>          if (ipdopts->param_processed_ptr)
>              (*ipdopts->param_processed_ptr)++;
>          stmt->data_at_exec = -1;
>!         for (i = 0; i < apdopts->allocated; i++)
>          {
>              Int4       *pcVal = apdopts->parameters[i].used;
>
>--- 550,559 ----
>          if (ipdopts->param_processed_ptr)
>              (*ipdopts->param_processed_ptr)++;
>          stmt->data_at_exec = -1;
>!         /* Check bind parameters count */
>!         if (SQL_SUCCESS != PGAPI_NumParams(stmt, ¶m_count))
>!             return SQL_ERROR;
>!         for (i = 0; i < param_count; i++)
>
>

Looks pretty good to me.
It's more safe to adjust the param_count in case of apdopts->allocated <
param_count.
Also it's safe to change the following code in PGAPI_ParamData.

/* At least 1 data at execution parameter, so Fill in the token value */
        for (; i < apdopts->allocated; i++)

regars, Hiroshi Inoue.


pgsql-odbc by date:

Previous
From: Ludek Finstrle
Date:
Subject: Re: Access violation C5 error on Visual FoxPro SQLEXEC() call after error
Next
From: "Jim C. Nasby"
Date:
Subject: Re: Does postgresql-odbc work on 64-bit platforms?