Skip site navigation (1) Skip section navigation (2)

Re: More strict bind param count checking

From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Ludek Finstrle <luf(at)pzkagis(dot)cz>
Cc: pgsql-odbc(at)postgresql(dot)org
Subject: Re: More strict bind param count checking
Date: 2005-12-16 21:22:34
Message-ID: 43A3301A.5070406@tpf.co.jp (view raw or flat)
Thread:
Lists: 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, &param_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.


In response to

Responses

pgsql-odbc by date

Next:From: Jim C. NasbyDate: 2005-12-16 21:51:25
Subject: Re: Does postgresql-odbc work on 64-bit platforms?
Previous:From: Ludek FinstrleDate: 2005-12-16 17:35:34
Subject: Re: Access violation C5 error on Visual FoxPro SQLEXEC() call after error

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group