X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id E61259DC82A for ; Tue, 13 Dec 2005 21:11:31 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 90718-04 for ; Tue, 13 Dec 2005 21:11:35 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from smtp.pzkagis.cz (gis6.netbox.cz [83.240.30.214]) by postgresql.org (Postfix) with ESMTP id 28C039DC813 for ; Tue, 13 Dec 2005 21:11:28 -0400 (AST) Received: (from luf@localhost) by smtp.pzkagis.cz (8.11.6/8.11.6) id jBE1BSv09562; Wed, 14 Dec 2005 02:11:28 +0100 Date: Wed, 14 Dec 2005 02:11:28 +0100 From: Ludek Finstrle To: Andrus Moor Cc: pgsql-odbc@postgresql.org Subject: Re: Access violation C5 error on Visual FoxPro SQLEXEC() call after error Message-ID: <20051214011128.GC9345@soptik.pzkagis.cz> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="OBd5C1Lgu00Gd/Tn" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200512/167 X-Sequence-Number: 6646 --OBd5C1Lgu00Gd/Tn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --OBd5C1Lgu00Gd/Tn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="psqlodbc-cancel_vfp_hack.diff" 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; --OBd5C1Lgu00Gd/Tn--