pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ludek Finstrle <luf@pzkagis.cz>
To: Andrus Moor <eetasoft@online.ee>
Cc: pgsql-odbc@postgresql.org
Subject: Re: Access violation C5 error on Visual FoxPro SQLEXEC() call after error
Date: Wed, 14 Dec 2005 02:11:28 +0100
Message-ID: <20051214011128.GC9345@soptik.pzkagis.cz> (raw)
In-Reply-To: <dngsq4$m5b$1@news.hub.org>
References: <dngsq4$m5b$1@news.hub.org>

Sun, Dec 11, 2005 at 11:50:33AM +0200, Andrus Moor napsal(a):
> Driver: psqlodbc-8_01_0104.zip ( I think)
> 
> Platform: Visual FoxPro 09.00.0000.3504 for Windows [Nov  4 2005 17:39:44]
> 
> Any idea how to fix this ?

I tried to fix it but this seems to me as VFP bad behaviour. I'm
againist add this code to official release unless we make new option
in configure DSN dialog.

Dave I propose to rollback your patch for the first Andrus's problem
as it breaks ODBC specification (if I understand this well):
| After SQLExecute or SQLExecDirect returns SQL_NEED_DATA and before
| data has been sent for all data-at-execution parameters,
| an application can call SQLCancel to cancel the statement execution.
| After the statement has been canceled, the application can call
| SQLExecute or SQLExecDirect again.

I think bind parameters can't be destroyed in SQLCancel.

I attach patch which may solve Andrus's problem and change a little
Dave's patch. I see application may call FreeStmt(SQL_CLOSE) and
FreeStmt(SQL_RESET_PARAMS). But VFP doesn't call it.

Andrus, I created bug in bug tracker. I attached compiled DLLs there
so you can try it. Link:
http://pgfoundry.org/tracker/index.php?func=detail&aid=1000481&group_id=1000125&atid=538

Regards,

Luf

Attachments:

psqlodbc-cancel_vfp_hack.diff (text/plain, 2.5K) download diff -c psqlodbc.orig\execute.c psqlodbc\execute.c *** psqlodbc.orig\execute.c Tue Dec 06 21:53:30 2005 --- psqlodbc\execute.c Wed Dec 14 01:18:40 2005 *************** *** 683,688 **** --- 711,717 ---- ConnectionClass *conn; RETCODE result; ConnInfo *ci; + STMT_Status old_status; #ifdef WIN32 HMODULE hmodule; *************** *** 719,724 **** --- 748,754 ---- * force method calls the driver manager's function on behalf of * the application. */ + old_status = stmt->status; #ifdef WIN32 if (ci->drivers.cancel_as_freestmt) *************** *** 733,739 **** result = PGAPI_FreeStmt(hstmt, SQL_CLOSE); #endif ! mylog("PGAPI_Cancel: PGAPI_FreeStmt returned %d\n", result); SC_clear_error(hstmt); return SQL_SUCCESS; --- 763,789 ---- result = PGAPI_FreeStmt(hstmt, SQL_CLOSE); #endif ! mylog("PGAPI_Cancel: PGAPI_FreeStmt(SQL_CLOSE) returned %d\n", result); ! ! #ifdef WIN32 ! /* ! * Brute force method calls SQLFreeStmt(SQL_RESET_PARAMS) as it seems ! * Microsoft Vistual FoxPro 9 needs it ! */ ! if (old_status != STMT_FINISHED) ! { ! if (ci->drivers.cancel_as_freestmt) ! { ! hmodule = GetModuleHandle("ODBC32"); ! addr = GetProcAddress(hmodule, "SQLFreeStmt"); ! result = addr((char *) (stmt->phstmt) - 96, SQL_RESET_PARAMS); ! } ! else ! result = PGAPI_FreeStmt(hstmt, SQL_RESET_PARAMS); ! ! mylog("PGAPI_Cancel: PGAPI_FreeStmt(SQL_RESET_PARAMS) returned %d\n", result); ! } ! #endif SC_clear_error(hstmt); return SQL_SUCCESS; *************** *** 741,750 **** /* In the middle of SQLParamData/SQLPutData, so cancel that. */ ! /* Free all previous data-at-exec buffers */ ! mylog("%s: Clearing parameters et al.\n", func); ! SC_free_params(stmt, STMT_FREE_PARAMS_ALL); stmt->data_at_exec = -1; stmt->current_exec_param = -1; stmt->put_data = FALSE; --- 791,812 ---- /* In the middle of SQLParamData/SQLPutData, so cancel that. */ ! #ifdef WIN32 ! /* ! * Brute force method calls SQLFreeStmt(SQL_RESET_PARAMS) as it seems ! * Microsoft Vistual FoxPro 9 needs it ! */ ! if (ci->drivers.cancel_as_freestmt) ! { ! hmodule = GetModuleHandle("ODBC32"); ! addr = GetProcAddress(hmodule, "SQLFreeStmt"); ! result = addr((char *) (stmt->phstmt) - 96, SQL_RESET_PARAMS); ! } ! else ! result = PGAPI_FreeStmt(hstmt, SQL_RESET_PARAMS); ! mylog("PGAPI_Cancel: PGAPI_FreeStmt(SQL_RESET_PARAMS) returned %d\n", result); ! #endif stmt->data_at_exec = -1; stmt->current_exec_param = -1; stmt->put_data = FALSE;

view thread (18+ messages)  latest in thread

Message-ID: <20051214011128.GC9345@soptik.pzkagis.cz>
Permalink:  ../20051214011128.GC9345@soptik.pzkagis.cz/
Also on:    postgresql.org/message-id/20051214011128.GC9345@soptik.pzkagis.cz

 ·  · 

reply

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, eetasoft@online.ee
  Subject: Re: Access violation C5 error on Visual FoxPro SQLEXEC() call after error
  In-Reply-To: <20051214011128.GC9345@soptik.pzkagis.cz>
  References: <dngsq4$m5b$1@news.hub.org> <20051214011128.GC9345@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