From bbca11bf3bb33d5853ca83b1252d17c9df3ebe6f Mon Sep 17 00:00:00 2001 From: Hiroshi Inoue Date: Wed, 27 Jun 2001 07:38:07 +0000 Subject: [PATCH] Handle Procedure calls. Now the version is 7.01.0006. --- src/interfaces/odbc/convert.c | 28 +++++++++++++++++++++++++++- src/interfaces/odbc/info.c | 2 +- src/interfaces/odbc/psqlodbc.h | 4 ++-- src/interfaces/odbc/psqlodbc.rc | 8 ++++---- src/interfaces/odbc/statement.c | 28 ++++++++++++++++++++++++++++ src/interfaces/odbc/statement.h | 1 + 6 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/interfaces/odbc/convert.c b/src/interfaces/odbc/convert.c index 09c6ca81f5..69d3043b95 100644 --- a/src/interfaces/odbc/convert.c +++ b/src/interfaces/odbc/convert.c @@ -1056,7 +1056,30 @@ copy_statement_with_parameters(StatementClass *stmt) if (!end) continue; - + /* procedure calls */ + if (stmt->statement_type == STMT_TYPE_PROCCALL) + { + while (isspace((unsigned char) old_statement[++opos])); + if (old_statement[opos] == '?') + { + param_number++; + while (isspace((unsigned char) old_statement[++opos])); + if (old_statement[opos] != '=') + { + opos--; + continue; + } + while (isspace((unsigned char) old_statement[++opos])); + } + if (strnicmp(&old_statement[opos], "call", 4)) + { + opos--; + continue; + } + opos += (4 - 1); + CVT_APPEND_STR("SELECT"); + continue; + } *end = '\0'; esc = convert_escape(begin); @@ -1075,6 +1098,9 @@ copy_statement_with_parameters(StatementClass *stmt) *end = '}'; continue; } + /* End of a procedure call */ + else if (oldchar == '}' && stmt->statement_type == STMT_TYPE_PROCCALL) + continue; /* * Can you have parameter markers inside of quotes? I dont think diff --git a/src/interfaces/odbc/info.c b/src/interfaces/odbc/info.c index 39a0a49a98..a18778cedd 100644 --- a/src/interfaces/odbc/info.c +++ b/src/interfaces/odbc/info.c @@ -802,7 +802,7 @@ SQLGetFunctions( { static char *func = "SQLGetFunctions"; - mylog("%s: entering...\n", func); + mylog("%s: entering...%u\n", func); if (fFunction == SQL_API_ALL_FUNCTIONS) { diff --git a/src/interfaces/odbc/psqlodbc.h b/src/interfaces/odbc/psqlodbc.h index c14b32045b..156ec458c2 100644 --- a/src/interfaces/odbc/psqlodbc.h +++ b/src/interfaces/odbc/psqlodbc.h @@ -5,7 +5,7 @@ * * Comments: See "notice.txt" for copyright and license information. * - * $Id: psqlodbc.h,v 1.43 2001/05/17 02:56:37 inoue Exp $ + * $Id: psqlodbc.h,v 1.44 2001/06/27 07:38:07 inoue Exp $ * */ @@ -42,7 +42,7 @@ typedef UInt4 Oid; #define DRIVERNAME "PostgreSQL ODBC" #define DBMS_NAME "PostgreSQL" -#define POSTGRESDRIVERVERSION "07.01.0005" +#define POSTGRESDRIVERVERSION "07.01.0006" #ifdef WIN32 #define DRIVER_FILE_NAME "PSQLODBC.DLL" diff --git a/src/interfaces/odbc/psqlodbc.rc b/src/interfaces/odbc/psqlodbc.rc index 6f42f402da..85bfcdb289 100644 --- a/src/interfaces/odbc/psqlodbc.rc +++ b/src/interfaces/odbc/psqlodbc.rc @@ -342,8 +342,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,1,0,5 - PRODUCTVERSION 7,1,0,5 + FILEVERSION 7,1,0,6 + PRODUCTVERSION 7,1,0,6 FILEFLAGSMASK 0x3L #ifdef _DEBUG FILEFLAGS 0x1L @@ -365,14 +365,14 @@ BEGIN VALUE "CompanyName", "Insight Distribution Systems\0" #endif VALUE "FileDescription", "PostgreSQL Driver\0" - VALUE "FileVersion", " 07.01.0005\0" + VALUE "FileVersion", " 07.01.0006\0" VALUE "InternalName", "psqlodbc\0" VALUE "LegalCopyright", "\0" VALUE "LegalTrademarks", "ODBC(TM) is a trademark of Microsoft Corporation. Microsoft® is a registered trademark of Microsoft Corporation. Windows(TM) is a trademark of Microsoft Corporation.\0" VALUE "OriginalFilename", "psqlodbc.dll\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "Microsoft Open Database Connectivity\0" - VALUE "ProductVersion", " 07.01.0005\0" + VALUE "ProductVersion", " 07.01.0006\0" VALUE "SpecialBuild", "\0" END END diff --git a/src/interfaces/odbc/statement.c b/src/interfaces/odbc/statement.c index 473d570988..165700dc09 100644 --- a/src/interfaces/odbc/statement.c +++ b/src/interfaces/odbc/statement.c @@ -81,6 +81,9 @@ static struct { STMT_TYPE_REVOKE, "REVOKE" }, + { + STMT_TYPE_PROCCALL, "{" + }, { 0, NULL } @@ -1054,6 +1057,31 @@ SC_execute(StatementClass *self) CC_abort(conn); } + if (self->statement_type == STMT_TYPE_PROCCALL && + (self->errornumber == STMT_OK || + self->errornumber == STMT_INFO_ONLY) && + self->parameters && + self->parameters[0].buflen > 0 && + self->parameters[0].paramType == SQL_PARAM_OUTPUT) + { /* get the return value of the procedure call */ + RETCODE ret; + HSTMT hstmt = (HSTMT) self; + ret = SQLBindCol(hstmt, 1, self->parameters[0].CType, self->parameters[0].buffer, self->parameters[0].buflen, self->parameters[0].used); + if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) + SC_fetch(hstmt); + else + { + self->errornumber = STMT_EXEC_ERROR; + self->errormsg = "BindCol to Procedure return failed."; + } + if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) + SQLBindCol(hstmt, 1, self->parameters[0].CType, NULL, 0, NULL); + else + { + self->errornumber = STMT_EXEC_ERROR; + self->errormsg = "SC_fetch to get a Procedure return failed."; + } + } if (self->errornumber == STMT_OK) return SQL_SUCCESS; else if (self->errornumber == STMT_INFO_ONLY) diff --git a/src/interfaces/odbc/statement.h b/src/interfaces/odbc/statement.h index 3f2fef5db7..f27c4cc138 100644 --- a/src/interfaces/odbc/statement.h +++ b/src/interfaces/odbc/statement.h @@ -98,6 +98,7 @@ enum STMT_TYPE_DROP, STMT_TYPE_GRANT, STMT_TYPE_REVOKE, + STMT_TYPE_PROCCALL }; #define STMT_UPDATE(stmt) (stmt->statement_type > STMT_TYPE_SELECT) -- 2.40.0