mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-11-27 07:21:09 +08:00
1) Change all internal SQL function calls from
SQLxxxx() to PGAPI_xxxx(). 2) Handle an escaped date/time format as a parameter. 3) Improve the tuple allocation a little. 4) The preparation of ODBC 3.0 a little. 5) Updatable cursors(may be deprecated before long).
This commit is contained in:
parent
58d4f951ea
commit
0c439e5ef6
@ -33,11 +33,12 @@
|
||||
#include "sql.h"
|
||||
#include "sqlext.h"
|
||||
#endif
|
||||
#include "pgapifunc.h"
|
||||
|
||||
|
||||
/* Bind parameters on a statement handle */
|
||||
RETCODE SQL_API
|
||||
SQLBindParameter(
|
||||
PGAPI_BindParameter(
|
||||
HSTMT hstmt,
|
||||
UWORD ipar,
|
||||
SWORD fParamType,
|
||||
@ -50,7 +51,7 @@ SQLBindParameter(
|
||||
SDWORD FAR *pcbValue)
|
||||
{
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
static char *func = "SQLBindParameter";
|
||||
static char *func = "PGAPI_BindParameter";
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
|
||||
@ -155,7 +156,7 @@ SQLBindParameter(
|
||||
if (stmt->status == STMT_PREMATURE)
|
||||
SC_recycle_statement(stmt);
|
||||
|
||||
mylog("SQLBindParamater: ipar=%d, paramType=%d, fCType=%d, fSqlType=%d, cbColDef=%d, ibScale=%d, rgbValue=%d, *pcbValue = %d, data_at_exec = %d\n", ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, pcbValue ? *pcbValue : -777, stmt->parameters[ipar].data_at_exec);
|
||||
mylog("PGAPI_BindParamater: ipar=%d, paramType=%d, fCType=%d, fSqlType=%d, cbColDef=%d, ibScale=%d, rgbValue=%d, *pcbValue = %d, data_at_exec = %d\n", ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, pcbValue ? *pcbValue : -777, stmt->parameters[ipar].data_at_exec);
|
||||
|
||||
return SQL_SUCCESS;
|
||||
}
|
||||
@ -163,7 +164,7 @@ SQLBindParameter(
|
||||
|
||||
/* Associate a user-supplied buffer with a database column. */
|
||||
RETCODE SQL_API
|
||||
SQLBindCol(
|
||||
PGAPI_BindCol(
|
||||
HSTMT hstmt,
|
||||
UWORD icol,
|
||||
SWORD fCType,
|
||||
@ -172,11 +173,12 @@ SQLBindCol(
|
||||
SDWORD FAR *pcbValue)
|
||||
{
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
static char *func = "SQLBindCol";
|
||||
static char *func = "PGAPI_BindCol";
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
|
||||
mylog("**** SQLBindCol: stmt = %u, icol = %d\n", stmt, icol);
|
||||
mylog("**** PGAPI_BindCol: stmt = %u, icol = %d\n", stmt, icol);
|
||||
mylog("**** : fCType=%d rgb=%x valusMax=%d pcb=%x\n", fCType, rgbValue, cbValueMax, pcbValue);
|
||||
|
||||
if (!stmt)
|
||||
{
|
||||
@ -275,7 +277,7 @@ SQLBindCol(
|
||||
* data type (most likely varchar).
|
||||
*/
|
||||
RETCODE SQL_API
|
||||
SQLDescribeParam(
|
||||
PGAPI_DescribeParam(
|
||||
HSTMT hstmt,
|
||||
UWORD ipar,
|
||||
SWORD FAR *pfSqlType,
|
||||
@ -284,7 +286,7 @@ SQLDescribeParam(
|
||||
SWORD FAR *pfNullable)
|
||||
{
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
static char *func = "SQLDescribeParam";
|
||||
static char *func = "PGAPI_DescribeParam";
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
|
||||
@ -297,7 +299,7 @@ SQLDescribeParam(
|
||||
|
||||
if ((ipar < 1) || (ipar > stmt->parameters_allocated))
|
||||
{
|
||||
stmt->errormsg = "Invalid parameter number for SQLDescribeParam.";
|
||||
stmt->errormsg = "Invalid parameter number for PGAPI_DescribeParam.";
|
||||
stmt->errornumber = STMT_BAD_PARAMETER_NUMBER_ERROR;
|
||||
SC_log_error(func, "", stmt);
|
||||
return SQL_ERROR;
|
||||
@ -328,15 +330,18 @@ SQLDescribeParam(
|
||||
|
||||
/* Sets multiple values (arrays) for the set of parameter markers. */
|
||||
RETCODE SQL_API
|
||||
SQLParamOptions(
|
||||
PGAPI_ParamOptions(
|
||||
HSTMT hstmt,
|
||||
UDWORD crow,
|
||||
UDWORD FAR *pirow)
|
||||
{
|
||||
static char *func = "SQLParamOptions";
|
||||
static char *func = "PGAPI_ParamOptions";
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
|
||||
stmt->errornumber = CONN_UNSUPPORTED_OPTION;
|
||||
stmt->errormsg = "Function not implemented";
|
||||
SC_log_error(func, "Function not implemented", (StatementClass *) hstmt);
|
||||
return SQL_ERROR;
|
||||
}
|
||||
@ -352,14 +357,14 @@ SQLParamOptions(
|
||||
* If the statement does not have parameters, it should just return 0.
|
||||
*/
|
||||
RETCODE SQL_API
|
||||
SQLNumParams(
|
||||
PGAPI_NumParams(
|
||||
HSTMT hstmt,
|
||||
SWORD FAR *pcpar)
|
||||
{
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
char in_quote = FALSE;
|
||||
unsigned int i;
|
||||
static char *func = "SQLNumParams";
|
||||
static char *func = "PGAPI_NumParams";
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
|
||||
@ -382,7 +387,7 @@ SQLNumParams(
|
||||
if (!stmt->statement)
|
||||
{
|
||||
/* no statement has been allocated */
|
||||
stmt->errormsg = "SQLNumParams called with no statement ready.";
|
||||
stmt->errormsg = "PGAPI_NumParams called with no statement ready.";
|
||||
stmt->errornumber = STMT_SEQUENCE_ERROR;
|
||||
SC_log_error(func, "", stmt);
|
||||
return SQL_ERROR;
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "socket.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "pgapifunc.h"
|
||||
|
||||
ColumnInfoClass *
|
||||
CI_Constructor()
|
||||
|
@ -36,6 +36,7 @@
|
||||
#ifdef WIN32
|
||||
#include <odbcinst.h>
|
||||
#endif
|
||||
#include "pgapifunc.h"
|
||||
|
||||
#define STMT_INCREMENT 16 /* how many statement holders to allocate
|
||||
* at a time */
|
||||
@ -46,13 +47,13 @@ extern GLOBAL_VALUES globals;
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLAllocConnect(
|
||||
PGAPI_AllocConnect(
|
||||
HENV henv,
|
||||
HDBC FAR *phdbc)
|
||||
{
|
||||
EnvironmentClass *env = (EnvironmentClass *) henv;
|
||||
ConnectionClass *conn;
|
||||
static char *func = "SQLAllocConnect";
|
||||
static char *func = "PGAPI_AllocConnect";
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
|
||||
@ -85,7 +86,7 @@ SQLAllocConnect(
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLConnect(
|
||||
PGAPI_Connect(
|
||||
HDBC hdbc,
|
||||
UCHAR FAR *szDSN,
|
||||
SWORD cbDSN,
|
||||
@ -96,7 +97,7 @@ SQLConnect(
|
||||
{
|
||||
ConnectionClass *conn = (ConnectionClass *) hdbc;
|
||||
ConnInfo *ci;
|
||||
static char *func = "SQLConnect";
|
||||
static char *func = "PGAPI_Connect";
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
|
||||
@ -141,7 +142,7 @@ SQLConnect(
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLBrowseConnect(
|
||||
PGAPI_BrowseConnect(
|
||||
HDBC hdbc,
|
||||
UCHAR FAR *szConnStrIn,
|
||||
SWORD cbConnStrIn,
|
||||
@ -149,7 +150,7 @@ SQLBrowseConnect(
|
||||
SWORD cbConnStrOutMax,
|
||||
SWORD FAR *pcbConnStrOut)
|
||||
{
|
||||
static char *func = "SQLBrowseConnect";
|
||||
static char *func = "PGAPI_BrowseConnect";
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
|
||||
@ -159,11 +160,11 @@ SQLBrowseConnect(
|
||||
|
||||
/* Drop any hstmts open on hdbc and disconnect from database */
|
||||
RETCODE SQL_API
|
||||
SQLDisconnect(
|
||||
PGAPI_Disconnect(
|
||||
HDBC hdbc)
|
||||
{
|
||||
ConnectionClass *conn = (ConnectionClass *) hdbc;
|
||||
static char *func = "SQLDisconnect";
|
||||
static char *func = "PGAPI_Disconnect";
|
||||
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
@ -197,11 +198,11 @@ SQLDisconnect(
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLFreeConnect(
|
||||
PGAPI_FreeConnect(
|
||||
HDBC hdbc)
|
||||
{
|
||||
ConnectionClass *conn = (ConnectionClass *) hdbc;
|
||||
static char *func = "SQLFreeConnect";
|
||||
static char *func = "PGAPI_FreeConnect";
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
mylog("**** in %s: hdbc=%u\n", func, hdbc);
|
||||
@ -272,6 +273,7 @@ CC_Constructor()
|
||||
rv->translation_handle = NULL;
|
||||
rv->DataSourceToDriver = NULL;
|
||||
rv->DriverToDataSource = NULL;
|
||||
rv->driver_version = ODBCVER;
|
||||
memset(rv->pg_version, 0, sizeof(rv->pg_version));
|
||||
rv->pg_version_number = .0;
|
||||
rv->pg_version_major = 0;
|
||||
@ -1409,7 +1411,7 @@ CC_send_settings(ConnectionClass *self)
|
||||
* has not transitioned to "connected" yet.
|
||||
*/
|
||||
|
||||
result = SQLAllocStmt(self, &hstmt);
|
||||
result = PGAPI_AllocStmt(self, &hstmt);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
return FALSE;
|
||||
stmt = (StatementClass *) hstmt;
|
||||
@ -1417,7 +1419,7 @@ CC_send_settings(ConnectionClass *self)
|
||||
stmt->internal = TRUE; /* ensure no BEGIN/COMMIT/ABORT stuff */
|
||||
|
||||
/* Set the Datestyle to the format the driver expects it to be in */
|
||||
result = SQLExecDirect(hstmt, "set DateStyle to 'ISO'", SQL_NTS);
|
||||
result = PGAPI_ExecDirect(hstmt, "set DateStyle to 'ISO'", SQL_NTS);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
status = FALSE;
|
||||
|
||||
@ -1426,7 +1428,7 @@ CC_send_settings(ConnectionClass *self)
|
||||
/* Disable genetic optimizer based on global flag */
|
||||
if (globals.disable_optimizer)
|
||||
{
|
||||
result = SQLExecDirect(hstmt, "set geqo to 'OFF'", SQL_NTS);
|
||||
result = PGAPI_ExecDirect(hstmt, "set geqo to 'OFF'", SQL_NTS);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
status = FALSE;
|
||||
|
||||
@ -1437,7 +1439,7 @@ CC_send_settings(ConnectionClass *self)
|
||||
/* KSQO */
|
||||
if (globals.ksqo)
|
||||
{
|
||||
result = SQLExecDirect(hstmt, "set ksqo to 'ON'", SQL_NTS);
|
||||
result = PGAPI_ExecDirect(hstmt, "set ksqo to 'ON'", SQL_NTS);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
status = FALSE;
|
||||
|
||||
@ -1452,7 +1454,7 @@ CC_send_settings(ConnectionClass *self)
|
||||
ptr = strtok(cs, ";");
|
||||
while (ptr)
|
||||
{
|
||||
result = SQLExecDirect(hstmt, ptr, SQL_NTS);
|
||||
result = PGAPI_ExecDirect(hstmt, ptr, SQL_NTS);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
status = FALSE;
|
||||
|
||||
@ -1471,7 +1473,7 @@ CC_send_settings(ConnectionClass *self)
|
||||
ptr = strtok(cs, ";");
|
||||
while (ptr)
|
||||
{
|
||||
result = SQLExecDirect(hstmt, ptr, SQL_NTS);
|
||||
result = PGAPI_ExecDirect(hstmt, ptr, SQL_NTS);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
status = FALSE;
|
||||
|
||||
@ -1484,7 +1486,7 @@ CC_send_settings(ConnectionClass *self)
|
||||
}
|
||||
|
||||
|
||||
SQLFreeStmt(hstmt, SQL_DROP);
|
||||
PGAPI_FreeStmt(hstmt, SQL_DROP);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -1509,36 +1511,36 @@ CC_lookup_lo(ConnectionClass *self)
|
||||
* This function must use the local odbc API functions since the odbc state
|
||||
* has not transitioned to "connected" yet.
|
||||
*/
|
||||
result = SQLAllocStmt(self, &hstmt);
|
||||
result = PGAPI_AllocStmt(self, &hstmt);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
return;
|
||||
stmt = (StatementClass *) hstmt;
|
||||
|
||||
result = SQLExecDirect(hstmt, "select oid from pg_type where typname='" PG_TYPE_LO_NAME "'", SQL_NTS);
|
||||
result = PGAPI_ExecDirect(hstmt, "select oid from pg_type where typname='" PG_TYPE_LO_NAME "'", SQL_NTS);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
{
|
||||
SQLFreeStmt(hstmt, SQL_DROP);
|
||||
PGAPI_FreeStmt(hstmt, SQL_DROP);
|
||||
return;
|
||||
}
|
||||
|
||||
result = SQLFetch(hstmt);
|
||||
result = PGAPI_Fetch(hstmt);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
{
|
||||
SQLFreeStmt(hstmt, SQL_DROP);
|
||||
PGAPI_FreeStmt(hstmt, SQL_DROP);
|
||||
return;
|
||||
}
|
||||
|
||||
result = SQLGetData(hstmt, 1, SQL_C_SLONG, &self->lobj_type, sizeof(self->lobj_type), NULL);
|
||||
result = PGAPI_GetData(hstmt, 1, SQL_C_SLONG, &self->lobj_type, sizeof(self->lobj_type), NULL);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
{
|
||||
SQLFreeStmt(hstmt, SQL_DROP);
|
||||
PGAPI_FreeStmt(hstmt, SQL_DROP);
|
||||
return;
|
||||
}
|
||||
|
||||
mylog("Got the large object oid: %d\n", self->lobj_type);
|
||||
qlog(" [ Large Object oid = %d ]\n", self->lobj_type);
|
||||
|
||||
result = SQLFreeStmt(hstmt, SQL_DROP);
|
||||
result = PGAPI_FreeStmt(hstmt, SQL_DROP);
|
||||
}
|
||||
|
||||
|
||||
@ -1594,30 +1596,30 @@ CC_lookup_pg_version(ConnectionClass *self)
|
||||
* This function must use the local odbc API functions since the odbc state
|
||||
* has not transitioned to "connected" yet.
|
||||
*/
|
||||
result = SQLAllocStmt(self, &hstmt);
|
||||
result = PGAPI_AllocStmt(self, &hstmt);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
return;
|
||||
stmt = (StatementClass *) hstmt;
|
||||
|
||||
/* get the server's version if possible */
|
||||
result = SQLExecDirect(hstmt, "select version()", SQL_NTS);
|
||||
result = PGAPI_ExecDirect(hstmt, "select version()", SQL_NTS);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
{
|
||||
SQLFreeStmt(hstmt, SQL_DROP);
|
||||
PGAPI_FreeStmt(hstmt, SQL_DROP);
|
||||
return;
|
||||
}
|
||||
|
||||
result = SQLFetch(hstmt);
|
||||
result = PGAPI_Fetch(hstmt);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
{
|
||||
SQLFreeStmt(hstmt, SQL_DROP);
|
||||
PGAPI_FreeStmt(hstmt, SQL_DROP);
|
||||
return;
|
||||
}
|
||||
|
||||
result = SQLGetData(hstmt, 1, SQL_C_CHAR, self->pg_version, MAX_INFO_STRING, NULL);
|
||||
result = PGAPI_GetData(hstmt, 1, SQL_C_CHAR, self->pg_version, MAX_INFO_STRING, NULL);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
{
|
||||
SQLFreeStmt(hstmt, SQL_DROP);
|
||||
PGAPI_FreeStmt(hstmt, SQL_DROP);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1639,7 +1641,7 @@ CC_lookup_pg_version(ConnectionClass *self)
|
||||
qlog(" [ PostgreSQL version string = '%s' ]\n", self->pg_version);
|
||||
qlog(" [ PostgreSQL version number = '%1.1f' ]\n", self->pg_version_number);
|
||||
|
||||
result = SQLFreeStmt(hstmt, SQL_DROP);
|
||||
result = PGAPI_FreeStmt(hstmt, SQL_DROP);
|
||||
}
|
||||
|
||||
|
||||
|
@ -264,6 +264,7 @@ struct ConnectionClass_
|
||||
HINSTANCE translation_handle;
|
||||
DataSourceToDriverProc DataSourceToDriver;
|
||||
DriverToDataSourceProc DriverToDataSource;
|
||||
Int2 driver_version; /* prepared for ODBC3.0 */
|
||||
char transact_status;/* Is a transaction is currently in
|
||||
* progress */
|
||||
char errormsg_created; /* has an informative error msg
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "pgtypes.h"
|
||||
#include "lobj.h"
|
||||
#include "connection.h"
|
||||
#include "pgapifunc.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef HAVE_STRICMP
|
||||
@ -973,6 +974,9 @@ copy_statement_with_parameters(StatementClass *stmt)
|
||||
retval;
|
||||
BOOL check_select_into = FALSE; /* select into check */
|
||||
unsigned int declare_pos;
|
||||
#ifdef DRIVER_CURSOR_IMPLEMENT
|
||||
BOOL ins_ctrl = FALSE;
|
||||
#endif /* DRIVER_CURSOR_IMPLEMENT */
|
||||
|
||||
|
||||
if (!old_statement)
|
||||
@ -1003,9 +1007,27 @@ copy_statement_with_parameters(StatementClass *stmt)
|
||||
check_select_into = TRUE;
|
||||
declare_pos = npos;
|
||||
}
|
||||
|
||||
param_number = -1;
|
||||
|
||||
#ifdef DRIVER_CURSOR_IMPLEMENT
|
||||
if (stmt->statement_type != STMT_TYPE_SELECT)
|
||||
{
|
||||
stmt->options.cursor_type = SQL_CURSOR_FORWARD_ONLY;
|
||||
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
|
||||
}
|
||||
else if (stmt->options.cursor_type == SQL_CURSOR_FORWARD_ONLY)
|
||||
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
|
||||
else if (stmt->options.scroll_concurrency != SQL_CONCUR_READ_ONLY)
|
||||
{
|
||||
if (stmt->parse_status == STMT_PARSE_NONE)
|
||||
parse_statement(stmt);
|
||||
if (stmt->parse_status != STMT_PARSE_COMPLETE)
|
||||
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
|
||||
else if (!stmt->ti || stmt->ntab != 1)
|
||||
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
|
||||
else ins_ctrl = TRUE;
|
||||
}
|
||||
#endif /* DRIVER_CURSOR_IMPLEMENT */
|
||||
#ifdef MULTIBYTE
|
||||
multibyte_init();
|
||||
#endif
|
||||
@ -1136,9 +1158,20 @@ copy_statement_with_parameters(StatementClass *stmt)
|
||||
into_table_from(&old_statement[opos]))
|
||||
{
|
||||
stmt->statement_type = STMT_TYPE_CREATE;
|
||||
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
|
||||
memmove(new_statement, new_statement + declare_pos, npos - declare_pos);
|
||||
npos -= declare_pos;
|
||||
}
|
||||
#ifdef DRIVER_CURSOR_IMPLEMENT
|
||||
else if (ins_ctrl && /* select into check */
|
||||
opos > 0 &&
|
||||
isspace((unsigned char) old_statement[opos - 1]) &&
|
||||
strnicmp(&old_statement[opos], "from", 4) == 0)
|
||||
{
|
||||
ins_ctrl = FALSE;
|
||||
CVT_APPEND_STR(", CTID, OID ");
|
||||
}
|
||||
#endif /* DRIVER_CURSOR_IMPLEMENT */
|
||||
CVT_APPEND_CHAR(oldchar);
|
||||
continue;
|
||||
}
|
||||
@ -1574,6 +1607,10 @@ copy_statement_with_parameters(StatementClass *stmt)
|
||||
NULL, 0, NULL);
|
||||
}
|
||||
|
||||
#ifdef DRIVER_CURSOR_IMPLEMENT
|
||||
if (ins_ctrl)
|
||||
stmt->options.scroll_concurrency = SQL_CONCUR_READ_ONLY;
|
||||
#endif /* DRIVER_CURSOR_IMPLEMENT */
|
||||
return SQL_SUCCESS;
|
||||
}
|
||||
|
||||
@ -1715,6 +1752,14 @@ parse_datetime(char *buf, SIMPLE_TIME *st)
|
||||
|
||||
y = m = d = hh = mm = ss = 0;
|
||||
|
||||
/* escape sequence ? */
|
||||
if (buf[0] == '{')
|
||||
{
|
||||
while (*(++buf) && *buf != '\'');
|
||||
if (!(*buf))
|
||||
return FALSE;
|
||||
buf++;
|
||||
}
|
||||
if (buf[4] == '-') /* year first */
|
||||
nf = sscanf(buf, "%4d-%2d-%2d %2d:%2d:%2d", &y, &m, &d, &hh, &mm, &ss);
|
||||
else
|
||||
@ -1835,13 +1880,18 @@ convert_special_chars(char *si, char *dst, int used)
|
||||
|
||||
for (i = 0; i < max; i++)
|
||||
{
|
||||
#ifdef MULTIBYTE
|
||||
if (multibyte_char_check(si[i]) != 0)
|
||||
{
|
||||
if (p)
|
||||
p[out] = si[i];
|
||||
out++;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (si[i] == '\r' && si[i + 1] == '\n')
|
||||
continue;
|
||||
#ifdef MULTIBYTE
|
||||
else if (multibyte_char_check(si[i]) == 0 && (si[i] == '\'' || si[i] == '\\'))
|
||||
#else
|
||||
else if (si[i] == '\'' || si[i] == '\\')
|
||||
#endif
|
||||
{
|
||||
if (p)
|
||||
p[out++] = '\\';
|
||||
|
@ -38,6 +38,7 @@
|
||||
#ifdef MULTIBYTE
|
||||
#include "multibyte.h"
|
||||
#endif
|
||||
#include "pgapifunc.h"
|
||||
|
||||
#ifndef BOOL
|
||||
#define BOOL int
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <odbcinst.h>
|
||||
#include "resource.h"
|
||||
#endif
|
||||
#include "pgapifunc.h"
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (BOOL)1
|
||||
@ -67,7 +68,7 @@ extern GLOBAL_VALUES globals;
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLDriverConnect(
|
||||
PGAPI_DriverConnect(
|
||||
HDBC hdbc,
|
||||
HWND hwnd,
|
||||
UCHAR FAR *szConnStrIn,
|
||||
@ -77,7 +78,7 @@ SQLDriverConnect(
|
||||
SWORD FAR *pcbConnStrOut,
|
||||
UWORD fDriverCompletion)
|
||||
{
|
||||
static char *func = "SQLDriverConnect";
|
||||
static char *func = "PGAPI_DriverConnect";
|
||||
ConnectionClass *conn = (ConnectionClass *) hdbc;
|
||||
ConnInfo *ci;
|
||||
|
||||
@ -103,8 +104,8 @@ SQLDriverConnect(
|
||||
|
||||
make_string(szConnStrIn, cbConnStrIn, connStrIn);
|
||||
|
||||
mylog("**** SQLDriverConnect: fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, connStrIn);
|
||||
qlog("conn=%u, SQLDriverConnect( in)='%s', fDriverCompletion=%d\n", conn, connStrIn, fDriverCompletion);
|
||||
mylog("**** PGAPI_DriverConnect: fDriverCompletion=%d, connStrIn='%s'\n", fDriverCompletion, connStrIn);
|
||||
qlog("conn=%u, PGAPI_DriverConnect( in)='%s', fDriverCompletion=%d\n", conn, connStrIn, fDriverCompletion);
|
||||
|
||||
ci = &(conn->connInfo);
|
||||
|
||||
@ -241,10 +242,10 @@ dialog:
|
||||
*pcbConnStrOut = len;
|
||||
|
||||
mylog("szConnStrOut = '%s'\n", szConnStrOut);
|
||||
qlog("conn=%u, SQLDriverConnect(out)='%s'\n", conn, szConnStrOut);
|
||||
qlog("conn=%u, PGAPI_DriverConnect(out)='%s'\n", conn, szConnStrOut);
|
||||
|
||||
|
||||
mylog("SQLDRiverConnect: returning %d\n", result);
|
||||
mylog("PGAPI_DRiverConnect: returning %d\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "statement.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "pgapifunc.h"
|
||||
|
||||
extern GLOBAL_VALUES globals;
|
||||
|
||||
@ -27,11 +28,11 @@ ConnectionClass *conns[MAX_CONNECTIONS];
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLAllocEnv(HENV FAR *phenv)
|
||||
PGAPI_AllocEnv(HENV FAR *phenv)
|
||||
{
|
||||
static char *func = "SQLAllocEnv";
|
||||
static char *func = "PGAPI_AllocEnv";
|
||||
|
||||
mylog("**** in SQLAllocEnv ** \n");
|
||||
mylog("**** in PGAPI_AllocEnv ** \n");
|
||||
|
||||
/*
|
||||
* Hack for systems on which none of the constructor-making techniques
|
||||
@ -51,18 +52,18 @@ SQLAllocEnv(HENV FAR *phenv)
|
||||
return SQL_ERROR;
|
||||
}
|
||||
|
||||
mylog("** exit SQLAllocEnv: phenv = %u **\n", *phenv);
|
||||
mylog("** exit PGAPI_AllocEnv: phenv = %u **\n", *phenv);
|
||||
return SQL_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLFreeEnv(HENV henv)
|
||||
PGAPI_FreeEnv(HENV henv)
|
||||
{
|
||||
static char *func = "SQLFreeEnv";
|
||||
static char *func = "PGAPI_FreeEnv";
|
||||
EnvironmentClass *env = (EnvironmentClass *) henv;
|
||||
|
||||
mylog("**** in SQLFreeEnv: env = %u ** \n", env);
|
||||
mylog("**** in PGAPI_FreeEnv: env = %u ** \n", env);
|
||||
|
||||
if (env && EN_Destructor(env))
|
||||
{
|
||||
@ -78,7 +79,7 @@ SQLFreeEnv(HENV henv)
|
||||
|
||||
/* Returns the next SQL error information. */
|
||||
RETCODE SQL_API
|
||||
SQLError(
|
||||
PGAPI_Error(
|
||||
HENV henv,
|
||||
HDBC hdbc,
|
||||
HSTMT hstmt,
|
||||
@ -91,7 +92,7 @@ SQLError(
|
||||
char *msg;
|
||||
int status;
|
||||
|
||||
mylog("**** SQLError: henv=%u, hdbc=%u, hstmt=%u <%d>\n", henv, hdbc, hstmt, cbErrorMsgMax);
|
||||
mylog("**** PGAPI_Error: henv=%u, hdbc=%u, hstmt=%u <%d>\n", henv, hdbc, hstmt, cbErrorMsgMax);
|
||||
|
||||
if (cbErrorMsgMax < 0)
|
||||
return SQL_ERROR;
|
||||
@ -140,6 +141,10 @@ SQLError(
|
||||
switch (status)
|
||||
{
|
||||
/* now determine the SQLSTATE to be returned */
|
||||
case STMT_ROW_VERSION_CHANGED:
|
||||
strcpy(szSqlState, "01001");
|
||||
/* data truncated */
|
||||
break;
|
||||
case STMT_TRUNCATED:
|
||||
strcpy(szSqlState, "01004");
|
||||
/* data truncated */
|
||||
@ -206,11 +211,14 @@ SQLError(
|
||||
strcpy(szSqlState, "07006");
|
||||
break;
|
||||
case STMT_INVALID_CURSOR_STATE_ERROR:
|
||||
strcpy(szSqlState, "24000");
|
||||
strcpy(szSqlState, "24000");
|
||||
break;
|
||||
case STMT_OPTION_VALUE_CHANGED:
|
||||
strcpy(szSqlState, "01S02");
|
||||
break;
|
||||
case STMT_POS_BEFORE_RECORDSET:
|
||||
strcpy(szSqlState, "01S06");
|
||||
break;
|
||||
case STMT_INVALID_CURSOR_NAME:
|
||||
strcpy(szSqlState, "34000");
|
||||
break;
|
||||
@ -230,6 +238,9 @@ SQLError(
|
||||
case STMT_OPERATION_INVALID:
|
||||
strcpy(szSqlState, "S1011");
|
||||
break;
|
||||
case STMT_INVALID_OPTION_IDENTIFIER:
|
||||
strcpy(szSqlState, "HY092");
|
||||
break;
|
||||
case STMT_EXEC_ERROR:
|
||||
default:
|
||||
strcpy(szSqlState, "S1000");
|
||||
|
@ -36,17 +36,18 @@
|
||||
#include "bind.h"
|
||||
#include "pgtypes.h"
|
||||
#include "lobj.h"
|
||||
#include "pgapifunc.h"
|
||||
|
||||
extern GLOBAL_VALUES globals;
|
||||
|
||||
|
||||
/* Perform a Prepare on the SQL statement */
|
||||
RETCODE SQL_API
|
||||
SQLPrepare(HSTMT hstmt,
|
||||
PGAPI_Prepare(HSTMT hstmt,
|
||||
UCHAR FAR *szSqlStr,
|
||||
SDWORD cbSqlStr)
|
||||
{
|
||||
static char *func = "SQLPrepare";
|
||||
static char *func = "PGAPI_Prepare";
|
||||
StatementClass *self = (StatementClass *) hstmt;
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
@ -66,31 +67,31 @@ SQLPrepare(HSTMT hstmt,
|
||||
switch (self->status)
|
||||
{
|
||||
case STMT_PREMATURE:
|
||||
mylog("**** SQLPrepare: STMT_PREMATURE, recycle\n");
|
||||
mylog("**** PGAPI_Prepare: STMT_PREMATURE, recycle\n");
|
||||
SC_recycle_statement(self); /* recycle the statement, but do
|
||||
* not remove parameter bindings */
|
||||
break;
|
||||
|
||||
case STMT_FINISHED:
|
||||
mylog("**** SQLPrepare: STMT_FINISHED, recycle\n");
|
||||
mylog("**** PGAPI_Prepare: STMT_FINISHED, recycle\n");
|
||||
SC_recycle_statement(self); /* recycle the statement, but do
|
||||
* not remove parameter bindings */
|
||||
break;
|
||||
|
||||
case STMT_ALLOCATED:
|
||||
mylog("**** SQLPrepare: STMT_ALLOCATED, copy\n");
|
||||
mylog("**** PGAPI_Prepare: STMT_ALLOCATED, copy\n");
|
||||
self->status = STMT_READY;
|
||||
break;
|
||||
|
||||
case STMT_READY:
|
||||
mylog("**** SQLPrepare: STMT_READY, change SQL\n");
|
||||
mylog("**** PGAPI_Prepare: STMT_READY, change SQL\n");
|
||||
break;
|
||||
|
||||
case STMT_EXECUTING:
|
||||
mylog("**** SQLPrepare: STMT_EXECUTING, error!\n");
|
||||
mylog("**** PGAPI_Prepare: STMT_EXECUTING, error!\n");
|
||||
|
||||
self->errornumber = STMT_SEQUENCE_ERROR;
|
||||
self->errormsg = "SQLPrepare(): The handle does not point to a statement that is ready to be executed";
|
||||
self->errormsg = "PGAPI_Prepare(): The handle does not point to a statement that is ready to be executed";
|
||||
SC_log_error(func, "", self);
|
||||
|
||||
return SQL_ERROR;
|
||||
@ -132,14 +133,14 @@ SQLPrepare(HSTMT hstmt,
|
||||
|
||||
/* Performs the equivalent of SQLPrepare, followed by SQLExecute. */
|
||||
RETCODE SQL_API
|
||||
SQLExecDirect(
|
||||
PGAPI_ExecDirect(
|
||||
HSTMT hstmt,
|
||||
UCHAR FAR *szSqlStr,
|
||||
SDWORD cbSqlStr)
|
||||
{
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
RETCODE result;
|
||||
static char *func = "SQLExecDirect";
|
||||
static char *func = "PGAPI_ExecDirect";
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
|
||||
@ -188,21 +189,21 @@ SQLExecDirect(
|
||||
return SQL_ERROR;
|
||||
}
|
||||
|
||||
mylog("%s: calling SQLExecute...\n", func);
|
||||
mylog("%s: calling PGAPI_Execute...\n", func);
|
||||
|
||||
result = SQLExecute(hstmt);
|
||||
result = PGAPI_Execute(hstmt);
|
||||
|
||||
mylog("%s: returned %hd from SQLExecute\n", func, result);
|
||||
mylog("%s: returned %hd from PGAPI_Execute\n", func, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* Execute a prepared SQL statement */
|
||||
RETCODE SQL_API
|
||||
SQLExecute(
|
||||
PGAPI_Execute(
|
||||
HSTMT hstmt)
|
||||
{
|
||||
static char *func = "SQLExecute";
|
||||
static char *func = "PGAPI_Execute";
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
ConnectionClass *conn;
|
||||
int i,
|
||||
@ -349,12 +350,12 @@ SQLExecute(
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLTransact(
|
||||
PGAPI_Transact(
|
||||
HENV henv,
|
||||
HDBC hdbc,
|
||||
UWORD fType)
|
||||
{
|
||||
static char *func = "SQLTransact";
|
||||
static char *func = "PGAPI_Transact";
|
||||
extern ConnectionClass *conns[];
|
||||
ConnectionClass *conn;
|
||||
QResultClass *res;
|
||||
@ -381,7 +382,7 @@ SQLTransact(
|
||||
conn = conns[lf];
|
||||
|
||||
if (conn && conn->henv == henv)
|
||||
if (SQLTransact(henv, (HDBC) conn, fType) != SQL_SUCCESS)
|
||||
if (PGAPI_Transact(henv, (HDBC) conn, fType) != SQL_SUCCESS)
|
||||
return SQL_ERROR;
|
||||
}
|
||||
return SQL_SUCCESS;
|
||||
@ -396,7 +397,7 @@ SQLTransact(
|
||||
else
|
||||
{
|
||||
conn->errornumber = CONN_INVALID_ARGUMENT_NO;
|
||||
conn->errormsg = "SQLTransact can only be called with SQL_COMMIT or SQL_ROLLBACK as parameter";
|
||||
conn->errormsg = "PGAPI_Transact can only be called with SQL_COMMIT or SQL_ROLLBACK as parameter";
|
||||
CC_log_error(func, "", conn);
|
||||
return SQL_ERROR;
|
||||
}
|
||||
@ -404,7 +405,7 @@ SQLTransact(
|
||||
/* If manual commit and in transaction, then proceed. */
|
||||
if (!CC_is_in_autocommit(conn) && CC_is_in_trans(conn))
|
||||
{
|
||||
mylog("SQLTransact: sending on conn %d '%s'\n", conn, stmt_string);
|
||||
mylog("PGAPI_Transact: sending on conn %d '%s'\n", conn, stmt_string);
|
||||
|
||||
res = CC_send_query(conn, stmt_string, NULL);
|
||||
CC_set_no_trans(conn);
|
||||
@ -430,10 +431,10 @@ SQLTransact(
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLCancel(
|
||||
PGAPI_Cancel(
|
||||
HSTMT hstmt) /* Statement to cancel. */
|
||||
{
|
||||
static char *func = "SQLCancel";
|
||||
static char *func = "PGAPI_Cancel";
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
RETCODE result;
|
||||
|
||||
@ -476,12 +477,12 @@ SQLCancel(
|
||||
result = addr((char *) (stmt->phstmt) - 96, SQL_CLOSE);
|
||||
}
|
||||
else
|
||||
result = SQLFreeStmt(hstmt, SQL_CLOSE);
|
||||
result = PGAPI_FreeStmt(hstmt, SQL_CLOSE);
|
||||
#else
|
||||
result = SQLFreeStmt(hstmt, SQL_CLOSE);
|
||||
result = PGAPI_FreeStmt(hstmt, SQL_CLOSE);
|
||||
#endif
|
||||
|
||||
mylog("SQLCancel: SQLFreeStmt returned %d\n", result);
|
||||
mylog("PGAPI_Cancel: PGAPI_FreeStmt returned %d\n", result);
|
||||
|
||||
SC_clear_error(hstmt);
|
||||
return SQL_SUCCESS;
|
||||
@ -509,7 +510,7 @@ SQLCancel(
|
||||
* observing buffer limits and truncation.
|
||||
*/
|
||||
RETCODE SQL_API
|
||||
SQLNativeSql(
|
||||
PGAPI_NativeSql(
|
||||
HDBC hdbc,
|
||||
UCHAR FAR *szSqlStrIn,
|
||||
SDWORD cbSqlStrIn,
|
||||
@ -517,7 +518,7 @@ SQLNativeSql(
|
||||
SDWORD cbSqlStrMax,
|
||||
SDWORD FAR *pcbSqlStr)
|
||||
{
|
||||
static char *func = "SQLNativeSql";
|
||||
static char *func = "PGAPI_NativeSql";
|
||||
int len = 0;
|
||||
char *ptr;
|
||||
ConnectionClass *conn = (ConnectionClass *) hdbc;
|
||||
@ -552,7 +553,8 @@ SQLNativeSql(
|
||||
if (pcbSqlStr)
|
||||
*pcbSqlStr = len;
|
||||
|
||||
free(ptr);
|
||||
if (cbSqlStrIn)
|
||||
free(ptr);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -563,11 +565,11 @@ SQLNativeSql(
|
||||
* Used in conjuction with SQLPutData.
|
||||
*/
|
||||
RETCODE SQL_API
|
||||
SQLParamData(
|
||||
PGAPI_ParamData(
|
||||
HSTMT hstmt,
|
||||
PTR FAR *prgbValue)
|
||||
{
|
||||
static char *func = "SQLParamData";
|
||||
static char *func = "PGAPI_ParamData";
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
int i,
|
||||
retval;
|
||||
@ -672,12 +674,12 @@ SQLParamData(
|
||||
* Used in conjunction with SQLParamData.
|
||||
*/
|
||||
RETCODE SQL_API
|
||||
SQLPutData(
|
||||
PGAPI_PutData(
|
||||
HSTMT hstmt,
|
||||
PTR rgbValue,
|
||||
SDWORD cbValue)
|
||||
{
|
||||
static char *func = "SQLPutData";
|
||||
static char *func = "PGAPI_PutData";
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
int old_pos,
|
||||
retval;
|
||||
@ -704,7 +706,7 @@ SQLPutData(
|
||||
|
||||
if (!stmt->put_data)
|
||||
{ /* first call */
|
||||
mylog("SQLPutData: (1) cbValue = %d\n", cbValue);
|
||||
mylog("PGAPI_PutData: (1) cbValue = %d\n", cbValue);
|
||||
|
||||
stmt->put_data = TRUE;
|
||||
|
||||
@ -712,7 +714,7 @@ SQLPutData(
|
||||
if (!current_param->EXEC_used)
|
||||
{
|
||||
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
||||
stmt->errormsg = "Out of memory in SQLPutData (1)";
|
||||
stmt->errormsg = "Out of memory in PGAPI_PutData (1)";
|
||||
SC_log_error(func, "", stmt);
|
||||
return SQL_ERROR;
|
||||
}
|
||||
@ -790,7 +792,7 @@ SQLPutData(
|
||||
if (!current_param->EXEC_buffer)
|
||||
{
|
||||
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
||||
stmt->errormsg = "Out of memory in SQLPutData (2)";
|
||||
stmt->errormsg = "Out of memory in PGAPI_PutData (2)";
|
||||
SC_log_error(func, "", stmt);
|
||||
return SQL_ERROR;
|
||||
}
|
||||
@ -807,7 +809,7 @@ SQLPutData(
|
||||
if (!current_param->EXEC_buffer)
|
||||
{
|
||||
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
||||
stmt->errormsg = "Out of memory in SQLPutData (2)";
|
||||
stmt->errormsg = "Out of memory in PGAPI_PutData (2)";
|
||||
SC_log_error(func, "", stmt);
|
||||
return SQL_ERROR;
|
||||
}
|
||||
@ -822,7 +824,7 @@ SQLPutData(
|
||||
if (!current_param->EXEC_buffer)
|
||||
{
|
||||
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
||||
stmt->errormsg = "Out of memory in SQLPutData (2)";
|
||||
stmt->errormsg = "Out of memory in PGAPI_PutData (2)";
|
||||
SC_log_error(func, "", stmt);
|
||||
return SQL_ERROR;
|
||||
}
|
||||
@ -834,7 +836,7 @@ SQLPutData(
|
||||
else
|
||||
{
|
||||
/* calling SQLPutData more than once */
|
||||
mylog("SQLPutData: (>1) cbValue = %d\n", cbValue);
|
||||
mylog("PGAPI_PutData: (>1) cbValue = %d\n", cbValue);
|
||||
|
||||
if (current_param->SQLType == SQL_LONGVARBINARY)
|
||||
{
|
||||
@ -854,7 +856,7 @@ SQLPutData(
|
||||
if (!buffer)
|
||||
{
|
||||
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
||||
stmt->errormsg = "Out of memory in SQLPutData (3)";
|
||||
stmt->errormsg = "Out of memory in PGAPI_PutData (3)";
|
||||
SC_log_error(func, "", stmt);
|
||||
return SQL_ERROR;
|
||||
}
|
||||
@ -880,7 +882,7 @@ SQLPutData(
|
||||
if (!buffer)
|
||||
{
|
||||
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
||||
stmt->errormsg = "Out of memory in SQLPutData (3)";
|
||||
stmt->errormsg = "Out of memory in PGAPI_PutData (3)";
|
||||
SC_log_error(func, "", stmt);
|
||||
return SQL_ERROR;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,6 +34,7 @@
|
||||
#include "connection.h"
|
||||
#include "statement.h"
|
||||
#include "qresult.h"
|
||||
#include "pgapifunc.h"
|
||||
|
||||
|
||||
extern GLOBAL_VALUES globals;
|
||||
@ -72,34 +73,23 @@ set_statement_option(ConnectionClass *conn,
|
||||
* positioned update isn't supported so cursor concurrency is
|
||||
* read-only
|
||||
*/
|
||||
if (conn)
|
||||
conn->stmtOptions.scroll_concurrency = vParam;
|
||||
if (stmt)
|
||||
stmt->options.scroll_concurrency = vParam;
|
||||
break;
|
||||
|
||||
/*----------
|
||||
* if (globals.lie)
|
||||
* {
|
||||
* if (conn)
|
||||
* conn->stmtOptions.scroll_concurrency = vParam;
|
||||
* if (stmt)
|
||||
* stmt->options.scroll_concurrency = vParam;
|
||||
* } else {
|
||||
* if (conn)
|
||||
* conn->stmtOptions.scroll_concurrency =
|
||||
* SQL_CONCUR_READ_ONLY;
|
||||
* if (stmt)
|
||||
* stmt->options.scroll_concurrency =
|
||||
* SQL_CONCUR_READ_ONLY;
|
||||
*
|
||||
* if (vParam != SQL_CONCUR_READ_ONLY)
|
||||
* changed = TRUE;
|
||||
* }
|
||||
* break;
|
||||
* }
|
||||
*----------
|
||||
*/
|
||||
mylog("SetStmtOption(): SQL_CONCURRENCY = %d\n", vParam);
|
||||
if (globals.lie || vParam == SQL_CONCUR_READ_ONLY || vParam == SQL_CONCUR_ROWVER)
|
||||
{
|
||||
if (conn)
|
||||
conn->stmtOptions.scroll_concurrency = vParam;
|
||||
if (stmt)
|
||||
stmt->options.scroll_concurrency = vParam;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (conn)
|
||||
conn->stmtOptions.scroll_concurrency = SQL_CONCUR_ROWVER;
|
||||
if (stmt)
|
||||
stmt->options.scroll_concurrency = SQL_CONCUR_ROWVER;
|
||||
changed = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case SQL_CURSOR_TYPE:
|
||||
|
||||
@ -296,19 +286,18 @@ set_statement_option(ConnectionClass *conn,
|
||||
|
||||
/* Implements only SQL_AUTOCOMMIT */
|
||||
RETCODE SQL_API
|
||||
SQLSetConnectOption(
|
||||
PGAPI_SetConnectOption(
|
||||
HDBC hdbc,
|
||||
UWORD fOption,
|
||||
UDWORD vParam)
|
||||
{
|
||||
static char *func = "SQLSetConnectOption";
|
||||
static char *func = "PGAPI_SetConnectOption";
|
||||
ConnectionClass *conn = (ConnectionClass *) hdbc;
|
||||
char changed = FALSE;
|
||||
RETCODE retval;
|
||||
int i;
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
|
||||
mylog("%s: entering fOption = %d vParam = %d\n", func, fOption, vParam);
|
||||
if (!conn)
|
||||
{
|
||||
CC_log_error(func, "", NULL);
|
||||
@ -372,7 +361,7 @@ SQLSetConnectOption(
|
||||
return SQL_ERROR;
|
||||
}
|
||||
|
||||
mylog("SQLSetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n", conn->transact_status, vParam);
|
||||
mylog("PGAPI_SetConnectOption: AUTOCOMMIT: transact_status=%d, vparam=%d\n", conn->transact_status, vParam);
|
||||
|
||||
switch (vParam)
|
||||
{
|
||||
@ -441,12 +430,12 @@ SQLSetConnectOption(
|
||||
|
||||
/* This function just can tell you whether you are in Autcommit mode or not */
|
||||
RETCODE SQL_API
|
||||
SQLGetConnectOption(
|
||||
PGAPI_GetConnectOption(
|
||||
HDBC hdbc,
|
||||
UWORD fOption,
|
||||
PTR pvParam)
|
||||
{
|
||||
static char *func = "SQLGetConnectOption";
|
||||
static char *func = "PGAPI_GetConnectOption";
|
||||
ConnectionClass *conn = (ConnectionClass *) hdbc;
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
@ -517,12 +506,12 @@ SQLGetConnectOption(
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLSetStmtOption(
|
||||
PGAPI_SetStmtOption(
|
||||
HSTMT hstmt,
|
||||
UWORD fOption,
|
||||
UDWORD vParam)
|
||||
{
|
||||
static char *func = "SQLSetStmtOption";
|
||||
static char *func = "PGAPI_SetStmtOption";
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
|
||||
mylog("%s: entering...\n", func);
|
||||
@ -543,12 +532,12 @@ SQLSetStmtOption(
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLGetStmtOption(
|
||||
PGAPI_GetStmtOption(
|
||||
HSTMT hstmt,
|
||||
UWORD fOption,
|
||||
PTR pvParam)
|
||||
{
|
||||
static char *func = "SQLGetStmtOption";
|
||||
static char *func = "PGAPI_GetStmtOption";
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
QResultClass *res;
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "connection.h"
|
||||
#include "qresult.h"
|
||||
#include "pgtypes.h"
|
||||
#include "pgapifunc.h"
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
#include "multibyte.h"
|
||||
@ -75,7 +76,7 @@ getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dqu
|
||||
i++;
|
||||
}
|
||||
|
||||
if (s[0] == '\0')
|
||||
if (s[i] == '\0')
|
||||
{
|
||||
token[0] = '\0';
|
||||
return NULL;
|
||||
@ -92,6 +93,13 @@ getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dqu
|
||||
while (!isspace((unsigned char) s[i]) && s[i] != ',' &&
|
||||
s[i] != '\0' && out != smax)
|
||||
{
|
||||
#ifdef MULTIBYTE
|
||||
if (multibyte_char_check(s[i]) != 0)
|
||||
{
|
||||
token[out++] = s[i++];
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
/* Handle quoted stuff */
|
||||
if (out == 0 && (s[i] == '\"' || s[i] == '\''))
|
||||
{
|
||||
@ -110,15 +118,17 @@ getNextToken(char *s, char *token, int smax, char *delim, char *quote, char *dqu
|
||||
i++; /* dont return the quote */
|
||||
while (s[i] != '\0' && out != smax)
|
||||
{
|
||||
#ifdef MULTIBYTE
|
||||
if (multibyte_char_check(s[i]) != 0)
|
||||
{
|
||||
token[out++] = s[i++];
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (s[i] == qc && !in_escape)
|
||||
break;
|
||||
#ifdef MULTIBYTE
|
||||
if (multibyte_char_check(s[i]) == 0 && s[i] == '\\' && !in_escape)
|
||||
{
|
||||
#else
|
||||
if (s[i] == '\\' && !in_escape)
|
||||
{
|
||||
#endif
|
||||
in_escape = TRUE;
|
||||
}
|
||||
else
|
||||
@ -269,11 +279,12 @@ parse_statement(StatementClass *stmt)
|
||||
dquote,
|
||||
numeric,
|
||||
unquoted;
|
||||
char *ptr;
|
||||
char *ptr, *pptr = NULL;
|
||||
char in_select = FALSE,
|
||||
in_distinct = FALSE,
|
||||
in_on = FALSE,
|
||||
in_from = FALSE,
|
||||
from_found = FALSE,
|
||||
in_where = FALSE,
|
||||
in_table = FALSE;
|
||||
char in_field = FALSE,
|
||||
@ -285,6 +296,7 @@ parse_statement(StatementClass *stmt)
|
||||
i,
|
||||
k = 0,
|
||||
n,
|
||||
first_where = 0,
|
||||
blevel = 0;
|
||||
FIELD_INFO **fi;
|
||||
TABLE_INFO **ti;
|
||||
@ -303,12 +315,107 @@ parse_statement(StatementClass *stmt)
|
||||
stmt->nfld = 0;
|
||||
stmt->ntab = 0;
|
||||
|
||||
while ((ptr = getNextToken(ptr, token, sizeof(token), &delim, "e, &dquote, &numeric)) != NULL)
|
||||
#ifdef MULTIBYTE
|
||||
multibyte_init();
|
||||
#endif
|
||||
while (pptr = ptr, (ptr = getNextToken(pptr, token, sizeof(token), &delim, "e, &dquote, &numeric)) != NULL)
|
||||
{
|
||||
unquoted = !(quote || dquote);
|
||||
|
||||
mylog("unquoted=%d, quote=%d, dquote=%d, numeric=%d, delim='%c', token='%s', ptr='%s'\n", unquoted, quote, dquote, numeric, delim, token, ptr);
|
||||
|
||||
if (in_select && unquoted && blevel == 0)
|
||||
{
|
||||
if (!stricmp(token, "distinct"))
|
||||
{
|
||||
in_distinct = TRUE;
|
||||
|
||||
mylog("DISTINCT\n");
|
||||
continue;
|
||||
}
|
||||
if (!stricmp(token, "into"))
|
||||
{
|
||||
in_select = FALSE;
|
||||
mylog("INTO\n");
|
||||
stmt->statement_type = STMT_TYPE_CREATE;
|
||||
stmt->parse_status = STMT_PARSE_FATAL;
|
||||
return FALSE;
|
||||
}
|
||||
if (!stricmp(token, "from"))
|
||||
{
|
||||
in_select = FALSE;
|
||||
in_from = TRUE;
|
||||
if (!from_found &&
|
||||
(!strnicmp(pptr, "from", 4)))
|
||||
{
|
||||
mylog("First ");
|
||||
from_found = TRUE;
|
||||
}
|
||||
|
||||
mylog("FROM\n");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (unquoted && blevel == 0)
|
||||
{
|
||||
if ((!stricmp(token, "where") ||
|
||||
!stricmp(token, "union") ||
|
||||
!stricmp(token, "intersect") ||
|
||||
!stricmp(token, "except") ||
|
||||
!stricmp(token, "order") ||
|
||||
!stricmp(token, "group") ||
|
||||
!stricmp(token, "having")))
|
||||
{
|
||||
in_select = FALSE;
|
||||
in_from = FALSE;
|
||||
in_where = TRUE;
|
||||
|
||||
if (!first_where &&
|
||||
(!stricmp(token, "where")))
|
||||
first_where = ptr - stmt->statement;
|
||||
|
||||
mylog("WHERE...\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (in_select && (in_expr || in_func))
|
||||
{
|
||||
/* just eat the expression */
|
||||
mylog("in_expr=%d or func=%d\n", in_expr, in_func);
|
||||
if (!unquoted)
|
||||
continue;
|
||||
|
||||
if (token[0] == '(')
|
||||
{
|
||||
blevel++;
|
||||
mylog("blevel++ = %d\n", blevel);
|
||||
}
|
||||
else if (token[0] == ')')
|
||||
{
|
||||
blevel--;
|
||||
mylog("blevel-- = %d\n", blevel);
|
||||
}
|
||||
if (blevel == 0)
|
||||
{
|
||||
if (delim == ',')
|
||||
{
|
||||
mylog("**** Got comma in_expr/func\n");
|
||||
in_func = FALSE;
|
||||
in_expr = FALSE;
|
||||
in_field = FALSE;
|
||||
}
|
||||
else if (!stricmp(token, "as"))
|
||||
{
|
||||
mylog("got AS in_expr\n");
|
||||
in_func = FALSE;
|
||||
in_expr = FALSE;
|
||||
in_as = TRUE;
|
||||
in_field = TRUE;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (unquoted && !stricmp(token, "select"))
|
||||
{
|
||||
in_select = TRUE;
|
||||
@ -316,46 +423,6 @@ parse_statement(StatementClass *stmt)
|
||||
mylog("SELECT\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (unquoted && in_select && !stricmp(token, "distinct"))
|
||||
{
|
||||
in_distinct = TRUE;
|
||||
|
||||
mylog("DISTINCT\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (unquoted && !stricmp(token, "into"))
|
||||
{
|
||||
in_select = FALSE;
|
||||
|
||||
mylog("INTO\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (unquoted && !stricmp(token, "from"))
|
||||
{
|
||||
in_select = FALSE;
|
||||
in_from = TRUE;
|
||||
|
||||
mylog("FROM\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (unquoted && (!stricmp(token, "where") ||
|
||||
!stricmp(token, "union") ||
|
||||
!stricmp(token, "order") ||
|
||||
!stricmp(token, "group") ||
|
||||
!stricmp(token, "having")))
|
||||
{
|
||||
in_select = FALSE;
|
||||
in_from = FALSE;
|
||||
in_where = TRUE;
|
||||
|
||||
mylog("WHERE...\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (in_select)
|
||||
{
|
||||
if (in_distinct)
|
||||
@ -378,41 +445,6 @@ parse_statement(StatementClass *stmt)
|
||||
in_distinct = FALSE;
|
||||
}
|
||||
|
||||
if (in_expr || in_func)
|
||||
{
|
||||
/* just eat the expression */
|
||||
mylog("in_expr=%d or func=%d\n", in_expr, in_func);
|
||||
if (quote || dquote)
|
||||
continue;
|
||||
|
||||
if (in_expr && blevel == 0 && delim == ',')
|
||||
{
|
||||
mylog("**** in_expr and Got comma\n");
|
||||
in_expr = FALSE;
|
||||
in_field = FALSE;
|
||||
}
|
||||
else if (token[0] == '(')
|
||||
{
|
||||
blevel++;
|
||||
mylog("blevel++ = %d\n", blevel);
|
||||
}
|
||||
else if (token[0] == ')')
|
||||
{
|
||||
blevel--;
|
||||
mylog("blevel-- = %d\n", blevel);
|
||||
}
|
||||
if (blevel == 0)
|
||||
{
|
||||
if (delim == ',')
|
||||
{
|
||||
in_func = FALSE;
|
||||
in_expr = FALSE;
|
||||
in_field = FALSE;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!in_field)
|
||||
{
|
||||
if (!token[0])
|
||||
@ -447,6 +479,7 @@ parse_statement(StatementClass *stmt)
|
||||
if (quote)
|
||||
{
|
||||
fi[stmt->nfld++]->quote = TRUE;
|
||||
in_expr = TRUE;
|
||||
continue;
|
||||
}
|
||||
else if (numeric)
|
||||
@ -619,8 +652,12 @@ parse_statement(StatementClass *stmt)
|
||||
else if (fi[i]->quote)
|
||||
{ /* handle as text */
|
||||
fi[i]->ti = NULL;
|
||||
/*
|
||||
fi[i]->type = PG_TYPE_TEXT;
|
||||
fi[i]->precision = 0;
|
||||
the following may be better */
|
||||
fi[i]->type = PG_TYPE_UNKNOWN;
|
||||
fi[i]->precision = 254;
|
||||
continue;
|
||||
}
|
||||
/* it's a dot, resolve to table or alias */
|
||||
@ -680,12 +717,12 @@ parse_statement(StatementClass *stmt)
|
||||
|
||||
if (!found)
|
||||
{
|
||||
mylog("PARSE: Getting SQLColumns for table[%d]='%s'\n", i, ti[i]->name);
|
||||
mylog("PARSE: Getting PG_Columns for table[%d]='%s'\n", i, ti[i]->name);
|
||||
|
||||
result = SQLAllocStmt(stmt->hdbc, &hcol_stmt);
|
||||
result = PGAPI_AllocStmt(stmt->hdbc, &hcol_stmt);
|
||||
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
|
||||
{
|
||||
stmt->errormsg = "SQLAllocStmt failed in parse_statement for columns.";
|
||||
stmt->errormsg = "PGAPI_AllocStmt failed in parse_statement for columns.";
|
||||
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
||||
stmt->parse_status = STMT_PARSE_FATAL;
|
||||
return FALSE;
|
||||
@ -694,10 +731,10 @@ parse_statement(StatementClass *stmt)
|
||||
col_stmt = (StatementClass *) hcol_stmt;
|
||||
col_stmt->internal = TRUE;
|
||||
|
||||
result = SQLColumns(hcol_stmt, "", 0, "", 0,
|
||||
result = PGAPI_Columns(hcol_stmt, "", 0, "", 0,
|
||||
ti[i]->name, (SWORD) strlen(ti[i]->name), "", 0);
|
||||
|
||||
mylog(" Past SQLColumns\n");
|
||||
mylog(" Past PG_Columns\n");
|
||||
if (result == SQL_SUCCESS)
|
||||
{
|
||||
mylog(" Success\n");
|
||||
@ -736,12 +773,12 @@ parse_statement(StatementClass *stmt)
|
||||
|
||||
conn->ntables++;
|
||||
|
||||
SQLFreeStmt(hcol_stmt, SQL_DROP);
|
||||
PGAPI_FreeStmt(hcol_stmt, SQL_DROP);
|
||||
mylog("Created col_info table='%s', ntables=%d\n", ti[i]->name, conn->ntables);
|
||||
}
|
||||
else
|
||||
{
|
||||
SQLFreeStmt(hcol_stmt, SQL_DROP);
|
||||
PGAPI_FreeStmt(hcol_stmt, SQL_DROP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -751,7 +788,7 @@ parse_statement(StatementClass *stmt)
|
||||
mylog("associate col_info: i=%d, k=%d\n", i, k);
|
||||
}
|
||||
|
||||
mylog("Done SQLColumns\n");
|
||||
mylog("Done PG_Columns\n");
|
||||
|
||||
/*
|
||||
* Now resolve the fields to point to column info
|
||||
|
@ -329,7 +329,8 @@ pgtype_to_name(StatementClass *stmt, Int4 type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case PG_TYPE_CHAR:return "char";
|
||||
case PG_TYPE_CHAR:
|
||||
return "char";
|
||||
case PG_TYPE_CHAR2:
|
||||
return "char2";
|
||||
case PG_TYPE_CHAR4:
|
||||
@ -399,7 +400,7 @@ getNumericScale(StatementClass *stmt, Int4 type, int col)
|
||||
QResultClass *result;
|
||||
ColumnInfoClass *flds;
|
||||
|
||||
mylog("getNumericScale: type=%d, col=%d, unknown = %d\n", type, col);
|
||||
mylog("getNumericScale: type=%d, col=%d\n", type, col);
|
||||
|
||||
if (col < 0)
|
||||
return PG_NUMERIC_MAX_SCALE;
|
||||
@ -436,7 +437,7 @@ getNumericPrecision(StatementClass *stmt, Int4 type, int col)
|
||||
QResultClass *result;
|
||||
ColumnInfoClass *flds;
|
||||
|
||||
mylog("getNumericPrecision: type=%d, col=%d, unknown = %d\n", type, col);
|
||||
mylog("getNumericPrecision: type=%d, col=%d\n", type, col);
|
||||
|
||||
if (col < 0)
|
||||
return PG_NUMERIC_MAX_PRECISION;
|
||||
@ -598,7 +599,8 @@ pgtype_precision(StatementClass *stmt, Int4 type, int col, int handle_unknown_si
|
||||
case PG_TYPE_ABSTIME:
|
||||
case PG_TYPE_DATETIME:
|
||||
case PG_TYPE_TIMESTAMP:
|
||||
return 19;
|
||||
/*return 19;*/
|
||||
return 21;
|
||||
|
||||
case PG_TYPE_BOOL:
|
||||
return 1;
|
||||
|
@ -53,6 +53,28 @@ SQLSetPos @68
|
||||
SQLSetScrollOptions @69
|
||||
SQLTablePrivileges @70
|
||||
SQLBindParameter @72
|
||||
|
||||
SQLAllocHandle @80
|
||||
SQLBindParam @81
|
||||
SQLCloseCursor @82
|
||||
SQLColAttribute @83
|
||||
SQLCopyDesc @84
|
||||
SQLEndTran @85
|
||||
SQLFetchScroll @86
|
||||
SQLFreeHandle @87
|
||||
SQLGetDescField @88
|
||||
SQLGetDescRec @89
|
||||
SQLGetDiagField @90
|
||||
SQLGetDiagRec @91
|
||||
SQLGetEnvAttr @92
|
||||
SQLGetConnectAttr @93
|
||||
SQLGetStmtAttr @94
|
||||
SQLSetConnectAttr @95
|
||||
SQLSetDescField @96
|
||||
SQLSetDescRec @97
|
||||
SQLSetEnvAttr @98
|
||||
SQLSetStmtAttr @99
|
||||
|
||||
SQLDummyOrdinal @199
|
||||
dconn_FDriverConnectProc @200
|
||||
DllMain @201
|
||||
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
* Comments: See "notice.txt" for copyright and license information.
|
||||
*
|
||||
* $Id: psqlodbc.h,v 1.44 2001/06/27 07:38:07 inoue Exp $
|
||||
* $Id: psqlodbc.h,v 1.45 2001/08/18 04:30:47 inoue Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
@ -163,6 +163,9 @@ typedef struct StatementOptions_
|
||||
int bind_size; /* size of each structure if using Row
|
||||
* Binding */
|
||||
int use_bookmarks;
|
||||
UInt4 *rowsFetched;
|
||||
UInt2 *rowStatusArray;
|
||||
void *bookmark_ptr;
|
||||
} StatementOptions;
|
||||
|
||||
/* Used to pass extra query info to send_query */
|
||||
|
@ -290,6 +290,7 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor)
|
||||
QR_set_message(self, "Could not get memory for tuple cache.");
|
||||
return FALSE;
|
||||
}
|
||||
self->count_allocated = tuple_size;
|
||||
|
||||
self->inTuples = TRUE;
|
||||
|
||||
@ -464,7 +465,8 @@ QR_next_tuple(QResultClass *self)
|
||||
self->fetch_count++;
|
||||
}
|
||||
|
||||
self->backend_tuples = (TupleField *) realloc(self->backend_tuples, self->num_fields * sizeof(TupleField) * self->cache_size);
|
||||
if (self->cache_size > self->count_allocated)
|
||||
self->backend_tuples = (TupleField *) realloc(self->backend_tuples, self->num_fields * sizeof(TupleField) * self->cache_size);
|
||||
if (!self->backend_tuples)
|
||||
{
|
||||
self->status = PGRES_FATAL_ERROR;
|
||||
@ -524,19 +526,21 @@ QR_next_tuple(QResultClass *self)
|
||||
case 'B': /* Tuples in binary format */
|
||||
case 'D': /* Tuples in ASCII format */
|
||||
|
||||
if (!globals.use_declarefetch && self->fcount > 0 && !(self->fcount % TUPLE_MALLOC_INC))
|
||||
if (!globals.use_declarefetch && self->fcount >= self->count_allocated)
|
||||
{
|
||||
size_t old_size = self->fcount * self->num_fields * sizeof(TupleField);
|
||||
int tuple_size = self->count_allocated;
|
||||
|
||||
mylog("REALLOC: old_size = %d\n", old_size);
|
||||
|
||||
self->backend_tuples = (TupleField *) realloc(self->backend_tuples, old_size + (self->num_fields * sizeof(TupleField) * TUPLE_MALLOC_INC));
|
||||
mylog("REALLOC: old_count = %d, size = %d\n", tuple_size, self->num_fields * sizeof(TupleField) * tuple_size);
|
||||
tuple_size *= 2;
|
||||
self->backend_tuples = (TupleField *) realloc(self->backend_tuples,
|
||||
tuple_size * self->num_fields * sizeof(TupleField));
|
||||
if (!self->backend_tuples)
|
||||
{
|
||||
self->status = PGRES_FATAL_ERROR;
|
||||
QR_set_message(self, "Out of memory while reading tuples.");
|
||||
return FALSE;
|
||||
}
|
||||
self->count_allocated = tuple_size;
|
||||
}
|
||||
|
||||
if (!QR_read_tuple(self, (char) (id == 0)))
|
||||
|
@ -46,6 +46,7 @@ struct QResultClass_
|
||||
* (backend) */
|
||||
|
||||
/* Stuff for declare/fetch tuples */
|
||||
int count_allocated; /* m(re)alloced count */
|
||||
int fetch_count; /* logical rows read so far */
|
||||
int fcount; /* actual rows read in the fetch */
|
||||
int currTuple;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,6 +34,7 @@
|
||||
#include <windows.h>
|
||||
#include <sql.h>
|
||||
#endif
|
||||
#include "pgapifunc.h"
|
||||
|
||||
extern GLOBAL_VALUES globals;
|
||||
|
||||
@ -91,10 +92,10 @@ static struct
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLAllocStmt(HDBC hdbc,
|
||||
PGAPI_AllocStmt(HDBC hdbc,
|
||||
HSTMT FAR *phstmt)
|
||||
{
|
||||
static char *func = "SQLAllocStmt";
|
||||
static char *func = "PGAPI_AllocStmt";
|
||||
ConnectionClass *conn = (ConnectionClass *) hdbc;
|
||||
StatementClass *stmt;
|
||||
|
||||
@ -108,7 +109,7 @@ SQLAllocStmt(HDBC hdbc,
|
||||
|
||||
stmt = SC_Constructor();
|
||||
|
||||
mylog("**** SQLAllocStmt: hdbc = %u, stmt = %u\n", hdbc, stmt);
|
||||
mylog("**** PGAPI_AllocStmt: hdbc = %u, stmt = %u\n", hdbc, stmt);
|
||||
|
||||
if (!stmt)
|
||||
{
|
||||
@ -143,10 +144,10 @@ SQLAllocStmt(HDBC hdbc,
|
||||
|
||||
|
||||
RETCODE SQL_API
|
||||
SQLFreeStmt(HSTMT hstmt,
|
||||
PGAPI_FreeStmt(HSTMT hstmt,
|
||||
UWORD fOption)
|
||||
{
|
||||
static char *func = "SQLFreeStmt";
|
||||
static char *func = "PGAPI_FreeStmt";
|
||||
StatementClass *stmt = (StatementClass *) hstmt;
|
||||
|
||||
mylog("%s: entering...hstmt=%u, fOption=%d\n", func, hstmt, fOption);
|
||||
@ -205,7 +206,7 @@ SQLFreeStmt(HSTMT hstmt,
|
||||
SC_free_params(stmt, STMT_FREE_PARAMS_ALL);
|
||||
else
|
||||
{
|
||||
stmt->errormsg = "Invalid option passed to SQLFreeStmt.";
|
||||
stmt->errormsg = "Invalid option passed to PGAPI_FreeStmt.";
|
||||
stmt->errornumber = STMT_OPTION_OUT_OF_RANGE_ERROR;
|
||||
SC_log_error(func, "", stmt);
|
||||
return SQL_ERROR;
|
||||
@ -570,7 +571,7 @@ SC_pre_execute(StatementClass *self)
|
||||
self->pre_executing = TRUE;
|
||||
self->inaccurate_result = FALSE;
|
||||
|
||||
SQLExecute(self);
|
||||
PGAPI_Execute(self);
|
||||
|
||||
self->pre_executing = old_pre_executing;
|
||||
|
||||
@ -713,13 +714,13 @@ SC_fetch(StatementClass *self)
|
||||
static char *func = "SC_fetch";
|
||||
QResultClass *res = self->result;
|
||||
int retval,
|
||||
result;
|
||||
result, updret;
|
||||
Int2 num_cols,
|
||||
lf;
|
||||
Oid type;
|
||||
char *value;
|
||||
ColumnInfoClass *ci;
|
||||
|
||||
extern WORD addrow;
|
||||
/* TupleField *tupleField; */
|
||||
|
||||
self->last_fetch_count = 0;
|
||||
@ -741,7 +742,7 @@ SC_fetch(StatementClass *self)
|
||||
return SQL_NO_DATA_FOUND;
|
||||
}
|
||||
|
||||
mylog("**** SQLFetch: manual_result\n");
|
||||
mylog("**** SC_fetch: manual_result\n");
|
||||
(self->currTuple)++;
|
||||
}
|
||||
else
|
||||
@ -750,14 +751,14 @@ SC_fetch(StatementClass *self)
|
||||
retval = QR_next_tuple(res);
|
||||
if (retval < 0)
|
||||
{
|
||||
mylog("**** SQLFetch: end_tuples\n");
|
||||
mylog("**** SC_fetch: end_tuples\n");
|
||||
return SQL_NO_DATA_FOUND;
|
||||
}
|
||||
else if (retval > 0)
|
||||
(self->currTuple)++;/* all is well */
|
||||
else
|
||||
{
|
||||
mylog("SQLFetch: error\n");
|
||||
mylog("SC_fetch: error\n");
|
||||
self->errornumber = STMT_EXEC_ERROR;
|
||||
self->errormsg = "Error fetching next row";
|
||||
SC_log_error(func, "", self);
|
||||
@ -785,6 +786,17 @@ SC_fetch(StatementClass *self)
|
||||
SQL_C_ULONG, self->bookmark.buffer, 0, self->bookmark.used);
|
||||
}
|
||||
|
||||
#ifdef DRIVER_CURSOR_IMPLEMENT
|
||||
updret = 0;
|
||||
if (self->options.scroll_concurrency != SQL_CONCUR_READ_ONLY)
|
||||
{
|
||||
if (!QR_get_value_backend_row(res, self->currTuple, num_cols - 1))
|
||||
updret = SQL_ROW_DELETED;
|
||||
num_cols -= 2;
|
||||
}
|
||||
if (!self->options.retrieve_data) /* data isn't required */
|
||||
return updret ? updret + 10 : SQL_SUCCESS;
|
||||
#endif /* DRIVER_CURSOR_IMPLEMENT */
|
||||
for (lf = 0; lf < num_cols; lf++)
|
||||
{
|
||||
mylog("fetch: cols=%d, lf=%d, self = %u, self->bindings = %u, buffer[] = %u\n", num_cols, lf, self, self->bindings, self->bindings[lf].buffer);
|
||||
@ -865,6 +877,10 @@ SC_fetch(StatementClass *self)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DRIVER_CURSOR_IMPLEMENT
|
||||
if (updret)
|
||||
result = updret + 10;
|
||||
#endif /* DRIVER_CURSOR_IMPLEMENT */
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -910,7 +926,7 @@ SC_execute(StatementClass *self)
|
||||
|
||||
ok = QR_command_successful(res);
|
||||
|
||||
mylog("SQLExecute: ok = %d, status = %d\n", ok, QR_get_status(res));
|
||||
mylog("SC_exec: begin ok = %d, status = %d\n", ok, QR_get_status(res));
|
||||
|
||||
QR_Destructor(res);
|
||||
|
||||
@ -1066,7 +1082,7 @@ SC_execute(StatementClass *self)
|
||||
{ /* 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);
|
||||
ret = PGAPI_BindCol(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
|
||||
@ -1075,7 +1091,7 @@ SC_execute(StatementClass *self)
|
||||
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);
|
||||
PGAPI_BindCol(hstmt, 1, self->parameters[0].CType, NULL, 0, NULL);
|
||||
else
|
||||
{
|
||||
self->errornumber = STMT_EXEC_ERROR;
|
||||
|
@ -49,6 +49,8 @@ typedef enum
|
||||
STMT_EXECUTING /* statement execution is still going on */
|
||||
} STMT_Status;
|
||||
|
||||
#define STMT_ROW_VERSION_CHANGED (-4)
|
||||
#define STMT_POS_BEFORE_RECORDSET (-3)
|
||||
#define STMT_TRUNCATED (-2)
|
||||
#define STMT_INFO_ONLY (-1) /* not an error message,
|
||||
* just a notification
|
||||
@ -83,6 +85,7 @@ typedef enum
|
||||
#define STMT_OPERATION_INVALID 25
|
||||
#define STMT_PROGRAM_TYPE_OUT_OF_RANGE 26
|
||||
#define STMT_BAD_ERROR 27
|
||||
#define STMT_INVALID_OPTION_IDENTIFIER 28
|
||||
|
||||
/* statement types */
|
||||
enum
|
||||
|
@ -83,6 +83,8 @@ CLEAN :
|
||||
-@erase "$(INTDIR)\statement.obj"
|
||||
-@erase "$(INTDIR)\tuple.obj"
|
||||
-@erase "$(INTDIR)\tuplelist.obj"
|
||||
-@erase "$(INTDIR)\odbcapi.obj"
|
||||
-@erase "$(INTDIR)\odbcapi30.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(OUTDIR)\psqlodbc.dll"
|
||||
-@erase "$(OUTDIR)\psqlodbc.exp"
|
||||
@ -166,6 +168,8 @@ LINK32_OBJS= \
|
||||
"$(INTDIR)\statement.obj" \
|
||||
"$(INTDIR)\tuple.obj" \
|
||||
"$(INTDIR)\tuplelist.obj" \
|
||||
"$(INTDIR)\odbcapi.obj" \
|
||||
"$(INTDIR)\odbcapi30.obj" \
|
||||
"$(INTDIR)\psqlodbc.res"
|
||||
|
||||
"$(OUTDIR)\psqlodbc.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
@ -214,6 +218,8 @@ CLEAN :
|
||||
-@erase "$(INTDIR)\statement.obj"
|
||||
-@erase "$(INTDIR)\tuple.obj"
|
||||
-@erase "$(INTDIR)\tuplelist.obj"
|
||||
-@erase "$(INTDIR)\odbcapi.obj"
|
||||
-@erase "$(INTDIR)\odbcapi30.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\psqlodbc.dll"
|
||||
@ -300,6 +306,8 @@ LINK32_OBJS= \
|
||||
"$(INTDIR)\statement.obj" \
|
||||
"$(INTDIR)\tuple.obj" \
|
||||
"$(INTDIR)\tuplelist.obj" \
|
||||
"$(INTDIR)\odbcapi.obj" \
|
||||
"$(INTDIR)\odbcapi30.obj" \
|
||||
"$(INTDIR)\psqlodbc.res"
|
||||
|
||||
"$(OUTDIR)\psqlodbc.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
@ -482,5 +490,17 @@ SOURCE=tuplelist.c
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=odbcapi.c
|
||||
|
||||
"$(INTDIR)\odbcapi.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=odbcapi30.c
|
||||
|
||||
"$(INTDIR)\odbcapi30.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
Loading…
Reference in New Issue
Block a user