Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit bbca11b

Browse files
author
Hiroshi Inoue
committed
Handle Procedure calls.
Now the version is 7.01.0006.
1 parent ef20f0c commit bbca11b

File tree

6 files changed

+63
-8
lines changed

6 files changed

+63
-8
lines changed

src/interfaces/odbc/convert.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,30 @@ copy_statement_with_parameters(StatementClass *stmt)
10561056

10571057
if (!end)
10581058
continue;
1059-
1059+
/* procedure calls */
1060+
if (stmt->statement_type == STMT_TYPE_PROCCALL)
1061+
{
1062+
while (isspace((unsigned char) old_statement[++opos]));
1063+
if (old_statement[opos] == '?')
1064+
{
1065+
param_number++;
1066+
while (isspace((unsigned char) old_statement[++opos]));
1067+
if (old_statement[opos] != '=')
1068+
{
1069+
opos--;
1070+
continue;
1071+
}
1072+
while (isspace((unsigned char) old_statement[++opos]));
1073+
}
1074+
if (strnicmp(&old_statement[opos], "call", 4))
1075+
{
1076+
opos--;
1077+
continue;
1078+
}
1079+
opos += (4 - 1);
1080+
CVT_APPEND_STR("SELECT");
1081+
continue;
1082+
}
10601083
*end = '\0';
10611084

10621085
esc = convert_escape(begin);
@@ -1075,6 +1098,9 @@ copy_statement_with_parameters(StatementClass *stmt)
10751098
*end = '}';
10761099
continue;
10771100
}
1101+
/* End of a procedure call */
1102+
else if (oldchar == '}' && stmt->statement_type == STMT_TYPE_PROCCALL)
1103+
continue;
10781104

10791105
/*
10801106
* Can you have parameter markers inside of quotes? I dont think

src/interfaces/odbc/info.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ SQLGetFunctions(
802802
{
803803
static char *func = "SQLGetFunctions";
804804

805-
mylog("%s: entering...\n", func);
805+
mylog("%s: entering...%u\n", func);
806806

807807
if (fFunction == SQL_API_ALL_FUNCTIONS)
808808
{

src/interfaces/odbc/psqlodbc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Comments: See "notice.txt" for copyright and license information.
77
*
8-
* $Id: psqlodbc.h,v 1.43 2001/05/17 02:56:37 inoue Exp $
8+
* $Id: psqlodbc.h,v 1.44 2001/06/27 07:38:07 inoue Exp $
99
*
1010
*/
1111

@@ -42,7 +42,7 @@ typedef UInt4 Oid;
4242
#define DRIVERNAME "PostgreSQL ODBC"
4343
#define DBMS_NAME "PostgreSQL"
4444

45-
#define POSTGRESDRIVERVERSION "07.01.0005"
45+
#define POSTGRESDRIVERVERSION "07.01.0006"
4646

4747
#ifdef WIN32
4848
#define DRIVER_FILE_NAME "PSQLODBC.DLL"

src/interfaces/odbc/psqlodbc.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ END
342342
//
343343

344344
VS_VERSION_INFO VERSIONINFO
345-
FILEVERSION 7,1,0,5
346-
PRODUCTVERSION 7,1,0,5
345+
FILEVERSION 7,1,0,6
346+
PRODUCTVERSION 7,1,0,6
347347
FILEFLAGSMASK 0x3L
348348
#ifdef _DEBUG
349349
FILEFLAGS 0x1L
@@ -365,14 +365,14 @@ BEGIN
365365
VALUE "CompanyName", "Insight Distribution Systems\0"
366366
#endif
367367
VALUE "FileDescription", "PostgreSQL Driver\0"
368-
VALUE "FileVersion", " 07.01.0005\0"
368+
VALUE "FileVersion", " 07.01.0006\0"
369369
VALUE "InternalName", "psqlodbc\0"
370370
VALUE "LegalCopyright", "\0"
371371
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"
372372
VALUE "OriginalFilename", "psqlodbc.dll\0"
373373
VALUE "PrivateBuild", "\0"
374374
VALUE "ProductName", "Microsoft Open Database Connectivity\0"
375-
VALUE "ProductVersion", " 07.01.0005\0"
375+
VALUE "ProductVersion", " 07.01.0006\0"
376376
VALUE "SpecialBuild", "\0"
377377
END
378378
END

src/interfaces/odbc/statement.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ static struct
8181
{
8282
STMT_TYPE_REVOKE, "REVOKE"
8383
},
84+
{
85+
STMT_TYPE_PROCCALL, "{"
86+
},
8487
{
8588
0, NULL
8689
}
@@ -1054,6 +1057,31 @@ SC_execute(StatementClass *self)
10541057
CC_abort(conn);
10551058
}
10561059

1060+
if (self->statement_type == STMT_TYPE_PROCCALL &&
1061+
(self->errornumber == STMT_OK ||
1062+
self->errornumber == STMT_INFO_ONLY) &&
1063+
self->parameters &&
1064+
self->parameters[0].buflen > 0 &&
1065+
self->parameters[0].paramType == SQL_PARAM_OUTPUT)
1066+
{ /* get the return value of the procedure call */
1067+
RETCODE ret;
1068+
HSTMT hstmt = (HSTMT) self;
1069+
ret = SQLBindCol(hstmt, 1, self->parameters[0].CType, self->parameters[0].buffer, self->parameters[0].buflen, self->parameters[0].used);
1070+
if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
1071+
SC_fetch(hstmt);
1072+
else
1073+
{
1074+
self->errornumber = STMT_EXEC_ERROR;
1075+
self->errormsg = "BindCol to Procedure return failed.";
1076+
}
1077+
if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO)
1078+
SQLBindCol(hstmt, 1, self->parameters[0].CType, NULL, 0, NULL);
1079+
else
1080+
{
1081+
self->errornumber = STMT_EXEC_ERROR;
1082+
self->errormsg = "SC_fetch to get a Procedure return failed.";
1083+
}
1084+
}
10571085
if (self->errornumber == STMT_OK)
10581086
return SQL_SUCCESS;
10591087
else if (self->errornumber == STMT_INFO_ONLY)

src/interfaces/odbc/statement.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ enum
9898
STMT_TYPE_DROP,
9999
STMT_TYPE_GRANT,
100100
STMT_TYPE_REVOKE,
101+
STMT_TYPE_PROCCALL
101102
};
102103

103104
#define STMT_UPDATE(stmt) (stmt->statement_type > STMT_TYPE_SELECT)

0 commit comments

Comments
 (0)