/* Bind parameters on a statement handle */
-RETCODE SQL_API
+RETCODE SQL_API
SQLBindParameter(
HSTMT hstmt,
UWORD ipar,
/* - - - - - - - - - */
/* Associate a user-supplied buffer with a database column. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLBindCol(
HSTMT hstmt,
UWORD icol,
/* If the bookmark column is being bound, then just save it */
if (icol == 0)
{
-
if (rgbValue == NULL)
{
stmt->bookmark.buffer = NULL;
/* it is best to say this function is not supported and let the application assume a */
/* data type (most likely varchar). */
-RETCODE SQL_API
+RETCODE SQL_API
SQLDescribeParam(
HSTMT hstmt,
UWORD ipar,
/* Sets multiple values (arrays) for the set of parameter markers. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLParamOptions(
HSTMT hstmt,
UDWORD crow,
/* like it does for SQLDescribeParam is that some applications don't care and try */
/* to call it anyway. */
/* If the statement does not have parameters, it should just return 0. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLNumParams(
HSTMT hstmt,
SWORD FAR * pcpar)
}
else
{
-
for (i = 0; i < strlen(stmt->statement); i++)
{
-
if (stmt->statement[i] == '?' && !in_quote)
(*pcpar)++;
else
/* entries into the new structure */
if (stmt->bindings_allocated < num_columns)
{
-
new_bindings = create_empty_bindings(num_columns);
if (!new_bindings)
{
stmt->bindings = new_bindings;
stmt->bindings_allocated = num_columns;
-
}
/* There is no reason to zero out extra bindings if there are */
/* more than needed. If an app has allocated extra bindings, */
/* now read in the descriptions */
for (lf = 0; lf < new_num_fields; lf++)
{
-
SOCK_get_string(sock, new_field_name, MAX_MESSAGE_LEN);
new_adtid = (Oid) SOCK_get_int(sock, 4);
new_adtsize = (Int2) SOCK_get_int(sock, 2);
/* If 6.4 protocol, then read the atttypmod field */
if (PG_VERSION_GE(conn, 6.4))
{
-
mylog("READING ATTTYPMOD\n");
new_atttypmod = (Int4) SOCK_get_int(sock, 4);
new_atttypmod -= 4;
if (new_atttypmod < 0)
new_atttypmod = -1;
-
}
mylog("CI_read_fields: fieldname='%s', adtid=%d, adtsize=%d, atttypmod=%d\n", new_field_name, new_adtid, new_adtsize, new_atttypmod);
CI_set_field_info(ColumnInfoClass * self, int field_num, char *new_name,
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
{
-
/* check bounds */
if ((field_num < 0) || (field_num >= self->num_fields))
return;
extern GLOBAL_VALUES globals;
-RETCODE SQL_API
+RETCODE SQL_API
SQLAllocConnect(
HENV henv,
HDBC FAR * phdbc)
/* - - - - - - - - - */
-RETCODE SQL_API
+RETCODE SQL_API
SQLConnect(
HDBC hdbc,
UCHAR FAR * szDSN,
/* - - - - - - - - - */
-RETCODE SQL_API
+RETCODE SQL_API
SQLBrowseConnect(
HDBC hdbc,
UCHAR FAR * szConnStrIn,
/* - - - - - - - - - */
/* Drop any hstmts open on hdbc and disconnect from database */
-RETCODE SQL_API
+RETCODE SQL_API
SQLDisconnect(
HDBC hdbc)
{
/* - - - - - - - - - */
-RETCODE SQL_API
+RETCODE SQL_API
SQLFreeConnect(
HDBC hdbc)
{
if (rv != NULL)
{
-
rv->henv = NULL; /* not yet associated with an environment */
rv->errormsg = NULL;
/* Statements under this conn will inherit these options */
InitializeStatementOptions(&rv->stmtOptions);
-
}
return rv;
}
char
CC_Destructor(ConnectionClass * self)
{
-
mylog("enter CC_Destructor, self=%u\n", self);
if (self->status == CONN_EXECUTING)
QR_Destructor(res);
else
return FALSE;
-
}
return TRUE;
mylog("%s: entering...\n", func);
if (do_password)
-
sock = self->sock; /* already connected, just authenticate */
else
{
-
qlog("Global Options: Version='%s', fetch=%d, socket=%d, unknown_sizes=%d, max_varchar_size=%d, max_longvarchar_size=%d\n",
POSTGRESDRIVERVERSION,
globals.fetch_max,
do
{
-
if (do_password)
beresp = 'R';
else
self->errornumber = CONN_INVALID_AUTHENTICATION;
return 0;
}
-
} while (areq != AUTH_REQ_OK);
CC_clear_error(self); /* clear any password error */
mylog("%s: returning...\n", func);
return 1;
-
}
char
}
else
{
-
char clear = 0;
mylog("send_query: ok - 'C' - %s\n", cmdbuffer);
for (i = 0; i < nargs; ++i)
{
-
mylog(" arg[%d]: len = %d, isint = %d, integer = %d, ptr = %u\n", i, args[i].len, args[i].isint, args[i].u.integer, args[i].u.ptr);
SOCK_put_int(sock, args[i].len, 4);
status = FALSE;
mylog("%s: result %d, status %d from set geqo\n", func, result, status);
-
}
/* KSQO */
status = FALSE;
mylog("%s: result %d, status %d from set ksqo\n", func, result, status);
-
}
/* Global settings */
/* pcbValueOffset is for computing any pcbValue location */
if (bind_size > 0)
- {
-
pcbValueOffset = rgbValueOffset = (bind_size * bind_row);
- }
else
{
-
pcbValueOffset = bind_row * sizeof(SDWORD);
rgbValueOffset = bind_row * cbValueMax;
-
}
memset(&st, 0, sizeof(SIMPLE_TIME));
*********************************************************************/
switch (field_type)
{
-
/*
* $$$ need to add parsing for date/time/timestamp strings in
* PG_TYPE_CHAR,VARCHAR $$$
case PG_TYPE_DATETIME:
case PG_TYPE_TIMESTAMP:
if (strnicmp(value, "invalid", 7) != 0)
- {
sscanf(value, "%4d-%2d-%2d %2d:%2d:%2d", &st.y, &st.m, &st.d, &st.hh, &st.mm, &st.ss);
-
- }
else
{ /* The timestamp is invalid so set
* something conspicuous, like the epoch */
if (fCType == SQL_C_CHAR)
{
-
-
/* Special character formatting as required */
/*
if (cbValueMax > 0)
{
-
copy_len = (len >= cbValueMax) ? cbValueMax - 1 : len;
/* Copy the data */
}
else
{
-
/*
* for SQL_C_CHAR, it's probably ok to leave currency symbols in.
* But to convert to numeric types, it is necessary to get rid of
if (stmt->current_col >= 0)
{
-
/* No more data left for this column */
if (stmt->bindings[stmt->current_col].data_left == 0)
return COPY_NO_DATA_FOUND;
/* First call to SQLGetData so initialize data_left */
else
stmt->bindings[stmt->current_col].data_left = len;
-
}
if (cbValueMax > 0)
*(SDWORD *) ((char *) pcbValue + pcbValueOffset) = len;
return result;
-
}
for (opos = 0; opos < oldstmtlen; opos++)
{
-
/* Squeeze carriage-return/linefeed pairs to linefeed only */
if (old_statement[opos] == '\r' && opos + 1 < oldstmtlen &&
old_statement[opos + 1] == '\n')
mylog("m=%d,d=%d,y=%d,hh=%d,mm=%d,ss=%d\n", st.m, st.d, st.y, st.hh, st.mm, st.ss);
break;
-
}
default:
/* error */
case SQL_LONGVARBINARY:
if (stmt->parameters[param_number].data_at_exec)
- {
-
lobj_oid = stmt->parameters[param_number].lobj_oid;
-
- }
else
{
-
/* begin transaction if needed */
if (!CC_is_in_trans(stmt->hdbc))
{
new_statement[npos++] = '\''; /* Close Quote */
break;
-
}
-
} /* end, for */
/* make sure new_statement is always null-terminated */
}
else if (strcmp(key, "fn") == 0)
{
-
/*
* Function invocation Separate off the func name, skipping
* trailing whitespace.
}
return escape;
-
}
y += (s[i] - 48) * (int) pow(8, 3 - i);
return y;
-
}
unsigned int
for (i = 1; i <= 2; i++)
{
-
if (s[i] >= 'a' && s[i] <= 'f')
val = s[i] - 'a' + 10;
else if (s[i] >= 'A' && s[i] <= 'F')
strcpy(&out[o], conv_to_octal(in[i]));
o += 5;
}
-
}
mylog("convert_to_pgbinary: returning %d, out='%.*s'\n", o, o, out);
if (!bindInfo || bindInfo->data_left == -1)
{
-
/* begin transaction if needed */
if (!CC_is_in_trans(stmt->hdbc))
{
retval = lo_lseek(stmt->hdbc, stmt->lobj_fd, 0L, SEEK_END);
if (retval >= 0)
{
-
left = lo_tell(stmt->hdbc, stmt->lobj_fd);
if (bindInfo)
bindInfo->data_left = left;
return result;
-
}
void
SetDlgStuff(HWND hdlg, ConnInfo * ci)
{
-
/*
* If driver attribute NOT present, then set the datasource name and
* description
-int CALLBACK
+int CALLBACK
driver_optionsProc(HWND hdlg,
WORD wMsg,
WPARAM wParam,
break;
}
-
}
return FALSE;
}
-int CALLBACK
+int CALLBACK
ds_optionsProc(HWND hdlg,
WORD wMsg,
WPARAM wParam,
void
copyAttributes(ConnInfo * ci, char *attribute, char *value)
{
-
if (stricmp(attribute, "DSN") == 0)
strcpy(ci->dsn, value);
}
mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s', conn_settings='%s')\n", ci->dsn, ci->server, ci->database, ci->username, ci->password, ci->port, ci->onlyread, ci->protocol, ci->conn_settings);
-
}
void
qlog(" translation_dll='%s',translation_option='%s'\n",
ci->translation_dll,
ci->translation_option);
-
}
/* Dont allow override of an override! */
if (!override)
{
-
/*
* ConnSettings is stored in the driver section and per datasource
* for override
strcpy(globals.protocol, temp);
else
strcpy(globals.protocol, DEFAULT_PROTOCOL);
-
}
}
extern GLOBAL_VALUES globals;
-RETCODE SQL_API
+RETCODE SQL_API
SQLDriverConnect(
HDBC hdbc,
HWND hwnd,
ci->port[0] == '\0' ||
password_required)
{
-
dialog_result = dconn_DoDialog(hwnd, ci);
if (dialog_result != SQL_SUCCESS)
return dialog_result;
if (szConnStrOut)
{
-
/*
* Return the completed string to the caller. The correct method
* is to only construct the connect string if a dialog was put up,
}
-BOOL FAR PASCAL
+BOOL FAR PASCAL
dconn_FDriverConnectProc(
HWND hdlg,
UINT wMsg,
/* Copy the appropriate value to the conninfo */
copyAttributes(ci, attribute, value);
-
}
ConnectionClass *conns[MAX_CONNECTIONS];
-RETCODE SQL_API
+RETCODE SQL_API
SQLAllocEnv(HENV FAR * phenv)
{
static char *func = "SQLAllocEnv";
return SQL_SUCCESS;
}
-RETCODE SQL_API
+RETCODE SQL_API
SQLFreeEnv(HENV henv)
{
static char *func = "SQLFreeEnv";
/* Returns the next SQL error information. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLError(
HENV henv,
HDBC hdbc,
}
mylog(" szSqlState = '%s', szError='%s'\n", szSqlState, szErrorMsg);
-
}
else
{
return SQL_NO_DATA_FOUND;
}
return SQL_SUCCESS;
-
}
else if (SQL_NULL_HDBC != hdbc)
{
/* general error */
break;
}
-
}
else
{
return SQL_NO_DATA_FOUND;
}
return SQL_SUCCESS;
-
}
else if (SQL_NULL_HENV != henv)
{
/* Perform a Prepare on the SQL statement */
-RETCODE SQL_API
+RETCODE SQL_API
SQLPrepare(HSTMT hstmt,
UCHAR FAR * szSqlStr,
SDWORD cbSqlStr)
/* Performs the equivalent of SQLPrepare, followed by SQLExecute. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLExecDirect(
HSTMT hstmt,
UCHAR FAR * szSqlStr,
}
/* Execute a prepared SQL statement */
-RETCODE SQL_API
+RETCODE SQL_API
SQLExecute(
HSTMT hstmt)
{
if ((stmt->prepare && stmt->status != STMT_READY) ||
(stmt->status != STMT_ALLOCATED && stmt->status != STMT_READY))
{
-
stmt->errornumber = STMT_STATUS_ERROR;
stmt->errormsg = "The handle does not point to a statement that is ready to be executed";
SC_log_error(func, "", stmt);
return SC_execute(stmt);
-
}
/* - - - - - - - - - */
-RETCODE SQL_API
+RETCODE SQL_API
SQLTransact(
HENV henv,
HDBC hdbc,
if (conn && conn->henv == henv)
if (SQLTransact(henv, (HDBC) conn, fType) != SQL_SUCCESS)
return SQL_ERROR;
-
}
return SQL_SUCCESS;
}
conn = (ConnectionClass *) hdbc;
if (fType == SQL_COMMIT)
- {
stmt_string = "COMMIT";
-
- }
else if (fType == SQL_ROLLBACK)
- {
stmt_string = "ROLLBACK";
-
- }
else
{
conn->errornumber = CONN_INVALID_ARGUMENT_NO;
/* 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);
res = CC_send_query(conn, stmt_string, NULL);
/* - - - - - - - - - */
-RETCODE SQL_API
+RETCODE SQL_API
SQLCancel(
HSTMT hstmt) /* Statement to cancel. */
{
*/
if (stmt->data_at_exec < 0)
{
-
-
/*
* MAJOR HACK for Windows to reset the driver manager's cursor
* state: Because of what seems like a bug in the Odbc driver
stmt->put_data = FALSE;
return SQL_SUCCESS;
-
}
/* - - - - - - - - - */
/* Returns the SQL string as modified by the driver. */
/* Currently, just copy the input string without modification */
/* observing buffer limits and truncation. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLNativeSql(
HDBC hdbc,
UCHAR FAR * szSqlStrIn,
/* Supplies parameter data at execution time. Used in conjuction with */
/* SQLPutData. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLParamData(
HSTMT hstmt,
PTR FAR * prgbValue)
/* Supplies parameter data at execution time. Used in conjunction with */
/* SQLParamData. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLPutData(
HSTMT hstmt,
PTR rgbValue,
/* Handle Long Var Binary with Large Objects */
if (current_param->SQLType == SQL_LONGVARBINARY)
{
-
/* begin transaction if needed */
if (!CC_is_in_trans(stmt->hdbc))
{
retval = lo_write(stmt->hdbc, stmt->lobj_fd, rgbValue, cbValue);
mylog("lo_write: cbValue=%d, wrote %d bytes\n", cbValue, retval);
-
}
else
{ /* for handling text fields and small
if (current_param->SQLType == SQL_LONGVARBINARY)
{
-
/* the large object fd is in EXEC_buffer */
retval = lo_write(stmt->hdbc, stmt->lobj_fd, rgbValue, cbValue);
mylog("lo_write(2): cbValue = %d, wrote %d bytes\n", cbValue, retval);
*current_param->EXEC_used += cbValue;
-
}
else
{
-
buffer = current_param->EXEC_buffer;
if (cbValue == SQL_NTS)
/* reassign buffer incase realloc moved it */
current_param->EXEC_buffer = buffer;
-
}
else if (cbValue > 0)
{
-
old_pos = *current_param->EXEC_used;
*current_param->EXEC_used += cbValue;
/* reassign buffer incase realloc moved it */
current_param->EXEC_buffer = buffer;
-
}
else
{
SC_log_error(func, "bad cbValue", stmt);
return SQL_ERROR;
}
-
}
}
/* - - - - - - - - - */
-RETCODE SQL_API
+RETCODE SQL_API
SQLGetInfo(
HDBC hdbc,
UWORD fInfoType,
if (rgbInfoValue)
{
-
if (len == 2)
*((WORD *) rgbInfoValue) = (WORD) value;
else if (len == 4)
/* - - - - - - - - - */
-RETCODE SQL_API
+RETCODE SQL_API
SQLGetTypeInfo(
HSTMT hstmt,
SWORD fSqlType)
/* - - - - - - - - - */
-RETCODE SQL_API
+RETCODE SQL_API
SQLGetFunctions(
HDBC hdbc,
UWORD fFunction,
if (fFunction == SQL_API_ALL_FUNCTIONS)
{
-
if (globals.lie)
{
int i;
}
else
{
-
if (globals.lie)
*pfExists = TRUE;
-
else
{
-
switch (fFunction)
{
case SQL_API_SQLALLOCCONNECT:
-RETCODE SQL_API
+RETCODE SQL_API
SQLTables(
HSTMT hstmt,
UCHAR FAR * szTableQualifier,
result = SQLFetch(htbl_stmt);
while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO))
{
-
/*
* Determine if this table name is a system table. If treating
* system tables as regular tables, then no need to do this test.
systable = FALSE;
if (!atoi(ci->show_system_tables))
{
-
if (strncmp(table_name, POSTGRES_SYS_PREFIX, strlen(POSTGRES_SYS_PREFIX)) == 0)
systable = TRUE;
(view && show_views) ||
(regular_table && show_regular_tables))
{
-
row = (TupleNode *) malloc(sizeof(TupleNode) + (5 - 1) * sizeof(TupleField));
set_tuplefield_string(&row->tuple[0], "");
-RETCODE SQL_API
+RETCODE SQL_API
SQLColumns(
HSTMT hstmt,
UCHAR FAR * szTableQualifier,
if (result != SQL_ERROR && !stmt->internal)
{
-
if (relhasrules[0] != '1' &&
(atoi(ci->show_oid_column) ||
strncmp(table_name, POSTGRES_SYS_PREFIX, strlen(POSTGRES_SYS_PREFIX)) == 0))
{
-
/* For OID fields */
the_type = PG_TYPE_OID;
row = (TupleNode *) malloc(sizeof(TupleNode) +
QR_add_tuple(stmt->result, row);
}
-
}
while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO))
if ((field_type == PG_TYPE_VARCHAR) ||
(field_type == PG_TYPE_BPCHAR))
{
-
useStaticPrecision = FALSE;
if (mod_length >= 4)
result = SQLFetch(hcol_stmt);
-
}
if (result != SQL_NO_DATA_FOUND)
{
return SQL_SUCCESS;
}
-RETCODE SQL_API
+RETCODE SQL_API
SQLSpecialColumns(
HSTMT hstmt,
UWORD fColType,
set_tuplefield_int2(&row->tuple[7], SQL_PC_PSEUDO);
QR_add_tuple(stmt->result, row);
-
}
else if (fColType == SQL_ROWVER)
{
-
Int2 the_type = PG_TYPE_INT4;
if (atoi(ci->row_versioning))
return SQL_SUCCESS;
}
-RETCODE SQL_API
+RETCODE SQL_API
SQLStatistics(
HSTMT hstmt,
UCHAR FAR * szTableQualifier,
stmt->errornumber = col_stmt->errornumber;
SQLFreeStmt(hcol_stmt, SQL_DROP);
goto SEEYA;
-
}
result = SQLFetch(hcol_stmt);
stmt->errornumber = col_stmt->errornumber;
SQLFreeStmt(hcol_stmt, SQL_DROP);
goto SEEYA;
-
}
SQLFreeStmt(hcol_stmt, SQL_DROP);
stmt->errormsg = "SQLAllocStmt failed in SQLStatistics for indices.";
stmt->errornumber = STMT_NO_MEMORY_ERROR;
goto SEEYA;
-
}
indx_stmt = (StatementClass *) hindx_stmt;
stmt->errornumber = indx_stmt->errornumber;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
-
}
/* bind the index name column */
stmt->errornumber = indx_stmt->errornumber;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
-
}
/* bind the vector column */
result = SQLBindCol(hindx_stmt, 2, SQL_C_DEFAULT,
stmt->errornumber = indx_stmt->errornumber;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
-
}
/* bind the "is unique" column */
result = SQLBindCol(hindx_stmt, 3, SQL_C_CHAR,
stmt->errornumber = indx_stmt->errornumber;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
-
}
result = SQLBindCol(hindx_stmt, 5, SQL_C_CHAR,
result = SQLFetch(hindx_stmt);
while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO))
{
-
/* If only requesting unique indexs, then just return those. */
if (fUnique == SQL_INDEX_ALL ||
(fUnique == SQL_INDEX_UNIQUE && atoi(isunique)))
/* add a row in this table for each field in the index */
while (i < 8 && fields_vector[i] != 0)
{
-
row = (TupleNode *) malloc(sizeof(TupleNode) +
(13 - 1) * sizeof(TupleField));
return SQL_SUCCESS;
}
-RETCODE SQL_API
+RETCODE SQL_API
SQLColumnPrivileges(
HSTMT hstmt,
UCHAR FAR * szTableQualifier,
/* SQLPrimaryKeys()
* Retrieve the primary key columns for the specified table.
*/
-RETCODE SQL_API
+RETCODE SQL_API
SQLPrimaryKeys(
HSTMT hstmt,
UCHAR FAR * szTableQualifier,
while ((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO))
{
-
row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField));
set_tuplefield_null(&row->tuple[0]);
return SQL_SUCCESS;
}
-RETCODE SQL_API
+RETCODE SQL_API
SQLForeignKeys(
HSTMT hstmt,
UCHAR FAR * szPkTableQualifier,
while (result == SQL_SUCCESS)
{
-
/* Compute the number of keyparts. */
num_keys = (trig_nargs - 4) / 2;
/* If there is a pk table specified, then check it. */
if (pk_table_needed[0] != '\0')
{
-
/* If it doesn't match, then continue */
if (strcmp(pk_table, pk_table_needed))
{
for (k = 0; k < num_keys; k++)
{
-
row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField));
mylog("%s: pk_table = '%s', pkey_ptr = '%s'\n", func, pk_table, pkey_ptr);
*/
else if (pk_table_needed[0] != '\0')
{
-
sprintf(tables_query, "SELECT pg_trigger.tgargs, "
" pg_trigger.tgnargs, "
" pg_trigger.tgdeferrable, "
while (result == SQL_SUCCESS)
{
-
/* Calculate the number of key parts */
num_keys = (trig_nargs - 4) / 2;;
for (k = 0; k < num_keys; k++)
{
-
mylog("pkey_ptr = '%s', fk_table = '%s', fkey_ptr = '%s'\n", pkey_ptr, fk_table, fkey_ptr);
row = (TupleNode *) malloc(sizeof(TupleNode) + (result_cols - 1) * sizeof(TupleField));
-RETCODE SQL_API
+RETCODE SQL_API
SQLProcedureColumns(
HSTMT hstmt,
UCHAR FAR * szProcQualifier,
return SQL_ERROR;
}
-RETCODE SQL_API
+RETCODE SQL_API
SQLProcedures(
HSTMT hstmt,
UCHAR FAR * szProcQualifier,
return SQL_ERROR;
}
-RETCODE SQL_API
+RETCODE SQL_API
SQLTablePrivileges(
HSTMT hstmt,
UCHAR FAR * szTableQualifier,
if (NULL != dst)
{
-
/* Just in case, check for special lengths */
if (len == SQL_NULL_DATA)
{
char *
my_strcat(char *buf, char *fmt, char *s, int len)
{
-
if (s && (len > 0 || (len == SQL_NTS && strlen(s) > 0)))
{
int length = (len > 0) ? len : strlen(s);
if (globals.lie)
{
-
if (conn)
conn->stmtOptions.cursor_type = vParam;
if (stmt)
stmt->options.cursor_type = vParam;
-
}
else
{
if (globals.use_declarefetch)
{
-
if (conn)
conn->stmtOptions.cursor_type = SQL_CURSOR_FORWARD_ONLY;
if (stmt)
{
if (vParam == SQL_CURSOR_FORWARD_ONLY || vParam == SQL_CURSOR_STATIC)
{
-
if (conn)
conn->stmtOptions.cursor_type = vParam; /* valid type */
if (stmt)
}
else
{
-
if (conn)
conn->stmtOptions.cursor_type = SQL_CURSOR_STATIC;
if (stmt)
/* Implements only SQL_AUTOCOMMIT */
-RETCODE SQL_API
+RETCODE SQL_API
SQLSetConnectOption(
HDBC hdbc,
UWORD fOption,
switch (fOption)
{
-
/*
* Statement Options (apply to all stmts on the connection and
* become defaults for new stmts)
CC_log_error(func, option, conn);
return SQL_ERROR;
}
-
}
if (changed)
/* - - - - - - - - - */
/* This function just can tell you whether you are in Autcommit mode or not */
-RETCODE SQL_API
+RETCODE SQL_API
SQLGetConnectOption(
HDBC hdbc,
UWORD fOption,
return SQL_ERROR;
break;
}
-
}
return SQL_SUCCESS;
/* - - - - - - - - - */
-RETCODE SQL_API
+RETCODE SQL_API
SQLSetStmtOption(
HSTMT hstmt,
UWORD fOption,
/* - - - - - - - - - */
-RETCODE SQL_API
+RETCODE SQL_API
SQLGetStmtOption(
HSTMT hstmt,
UWORD fOption,
while (!isspace((unsigned char) s[i]) && s[i] != ',' &&
s[i] != '\0' && out != smax)
{
-
/* Handle quoted stuff */
if (out == 0 && (s[i] == '\"' || s[i] == '\''))
{
while ((ptr = getNextToken(ptr, 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);
!stricmp(token, "group") ||
!stricmp(token, "having")))
{
-
in_select = FALSE;
in_from = FALSE;
in_where = TRUE;
if (in_select)
{
-
if (in_distinct)
{
mylog("in distinct\n");
if (!in_field)
{
-
if (!token[0])
continue;
fi[stmt->nfld - 1]->expr = TRUE;
fi[stmt->nfld - 1]->name[0] = '\0';
mylog("*** setting expression\n");
-
}
if (in_from)
{
-
if (!in_table)
{
if (!token[0])
/* Resolve field names with tables */
for (i = 0; i < stmt->nfld; i++)
{
-
if (fi[i]->func || fi[i]->expr || fi[i]->numeric)
{
fi[i]->ti = NULL;
/* Call SQLColumns for each table and store the result */
for (i = 0; i < stmt->ntab; i++)
{
-
/* See if already got it */
char found = FALSE;
if (!found)
{
-
mylog("PARSE: Getting SQLColumns for table[%d]='%s'\n", i, ti[i]->name);
result = SQLAllocStmt(stmt->hdbc, &hcol_stmt);
mylog(" Success\n");
if (!(conn->ntables % COL_INCR))
{
-
mylog("PARSE: Allocing col_info at ntables=%d\n", conn->ntables);
conn->col_info = (COL_INFO **) realloc(conn->col_info, (conn->ntables + COL_INCR) * sizeof(COL_INFO *));
for (i = 0; i < stmt->nfld;)
{
-
/* Dont worry about functions or quotes */
if (fi[i]->func || fi[i]->quote || fi[i]->numeric)
{
/* Stars get expanded to all fields in the table */
else if (fi[i]->name[0] == '*')
{
-
char do_all_tables;
int total_cols,
old_size,
for (k = 0; k < (do_all_tables ? stmt->ntab : 1); k++)
{
-
TABLE_INFO *the_ti = do_all_tables ? ti[k] : fi[i]->ti;
cols = QR_get_num_tuples(the_ti->col_info->result);
*/
else if (fi[i]->ti)
{
-
if (!searchColInfo(fi[i]->ti->col_info, fi[i]))
parse = FALSE;
switch (fSqlType)
{
-
case SQL_BINARY:
pgType = PG_TYPE_BYTEA;
break;
{
switch (type)
{
- case PG_TYPE_CHAR:
- case PG_TYPE_CHAR2:
- case PG_TYPE_CHAR4:
- case PG_TYPE_CHAR8:
- case PG_TYPE_NAME:return SQL_CHAR;
+ case PG_TYPE_CHAR:
+ case PG_TYPE_CHAR2:
+ case PG_TYPE_CHAR4:
+ case PG_TYPE_CHAR8:
+ case PG_TYPE_NAME:
+ return SQL_CHAR;
case PG_TYPE_BPCHAR:
return SQL_CHAR;
{
switch (type)
{
- case PG_TYPE_INT8:return SQL_C_CHAR;
+ case PG_TYPE_INT8:
+ return SQL_C_CHAR;
case PG_TYPE_NUMERIC:
return SQL_C_CHAR;
case PG_TYPE_INT2:
Int4
pgtype_precision(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as)
{
-
switch (type)
{
-
- case PG_TYPE_CHAR:return 1;
+ case PG_TYPE_CHAR:
+ return 1;
case PG_TYPE_CHAR2:
return 2;
case PG_TYPE_CHAR4:
Int4
pgtype_display_size(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as)
{
-
switch (type)
{
- case PG_TYPE_INT2:return 6;
+ case PG_TYPE_INT2:
+ return 6;
case PG_TYPE_OID:
case PG_TYPE_XID:
Int4
pgtype_length(StatementClass * stmt, Int4 type, int col, int handle_unknown_size_as)
{
-
switch (type)
{
-
- case PG_TYPE_INT2:return 2;
+ case PG_TYPE_INT2:
+ return 2;
case PG_TYPE_OID:
case PG_TYPE_XID:
{
switch (type)
{
-
- case PG_TYPE_INT2:
- case PG_TYPE_OID:
- case PG_TYPE_XID:
- case PG_TYPE_INT4:
- case PG_TYPE_INT8:
- case PG_TYPE_FLOAT4:
- case PG_TYPE_FLOAT8:
- case PG_TYPE_MONEY:
- case PG_TYPE_BOOL:
+ case PG_TYPE_INT2:
+ case PG_TYPE_OID:
+ case PG_TYPE_XID:
+ case PG_TYPE_INT4:
+ case PG_TYPE_INT8:
+ case PG_TYPE_FLOAT4:
+ case PG_TYPE_FLOAT8:
+ case PG_TYPE_MONEY:
+ case PG_TYPE_BOOL:
/*
* Number of digits to the right of the decimal point in
* "yyyy-mm=dd hh:mm:ss[.f...]"
*/
- case PG_TYPE_ABSTIME:
- case PG_TYPE_DATETIME:
- case PG_TYPE_TIMESTAMP:return 0;
+ case PG_TYPE_ABSTIME:
+ case PG_TYPE_DATETIME:
+ case PG_TYPE_TIMESTAMP:
+ return 0;
case PG_TYPE_NUMERIC:
return getNumericScale(stmt, type, col);
{
switch (type)
{
- case PG_TYPE_INT2:
- case PG_TYPE_OID:
- case PG_TYPE_INT4:
- case PG_TYPE_INT8:
- case PG_TYPE_NUMERIC:
- case PG_TYPE_FLOAT4:
- case PG_TYPE_MONEY:
- case PG_TYPE_FLOAT8:return 10;
+ case PG_TYPE_INT2:
+ case PG_TYPE_OID:
+ case PG_TYPE_INT4:
+ case PG_TYPE_INT8:
+ case PG_TYPE_NUMERIC:
+ case PG_TYPE_FLOAT4:
+ case PG_TYPE_MONEY:
+ case PG_TYPE_FLOAT8:
+ return 10;
default:
return -1;
{
switch (type)
{
+ case PG_TYPE_INT2:
+ case PG_TYPE_OID:
+ case PG_TYPE_XID:
+ case PG_TYPE_INT4:
+ case PG_TYPE_FLOAT4:
+ case PG_TYPE_MONEY:
+ case PG_TYPE_BOOL:
+ case PG_TYPE_FLOAT8:
+ case PG_TYPE_INT8:
+ case PG_TYPE_NUMERIC:
- case PG_TYPE_INT2:
- case PG_TYPE_OID:
- case PG_TYPE_XID:
- case PG_TYPE_INT4:
- case PG_TYPE_FLOAT4:
- case PG_TYPE_MONEY:
- case PG_TYPE_BOOL:
- case PG_TYPE_FLOAT8:
- case PG_TYPE_INT8:
- case PG_TYPE_NUMERIC:
-
- case PG_TYPE_DATE:
- case PG_TYPE_TIME:
- case PG_TYPE_ABSTIME:
- case PG_TYPE_DATETIME:
- case PG_TYPE_TIMESTAMP:return FALSE;
+ case PG_TYPE_DATE:
+ case PG_TYPE_TIME:
+ case PG_TYPE_ABSTIME:
+ case PG_TYPE_DATETIME:
+ case PG_TYPE_TIMESTAMP:
+ return FALSE;
default:
return -1;
{
switch (type)
{
- case PG_TYPE_CHAR:
+ case PG_TYPE_CHAR:
- case PG_TYPE_CHAR2:
- case PG_TYPE_CHAR4:
- case PG_TYPE_CHAR8:
+ case PG_TYPE_CHAR2:
+ case PG_TYPE_CHAR4:
+ case PG_TYPE_CHAR8:
- case PG_TYPE_VARCHAR:
- case PG_TYPE_BPCHAR:
- case PG_TYPE_TEXT:
- case PG_TYPE_NAME:return TRUE;
+ case PG_TYPE_VARCHAR:
+ case PG_TYPE_BPCHAR:
+ case PG_TYPE_TEXT:
+ case PG_TYPE_NAME:
+ return TRUE;
default:
return FALSE;
{
switch (type)
{
- case PG_TYPE_MONEY:return TRUE;
+ case PG_TYPE_MONEY:
+ return TRUE;
default:
return FALSE;
}
{
switch (type)
{
- case PG_TYPE_CHAR:
- case PG_TYPE_CHAR2:
- case PG_TYPE_CHAR4:
- case PG_TYPE_CHAR8:
+ case PG_TYPE_CHAR:
+ case PG_TYPE_CHAR2:
+ case PG_TYPE_CHAR4:
+ case PG_TYPE_CHAR8:
- case PG_TYPE_VARCHAR:
- case PG_TYPE_BPCHAR:
- case PG_TYPE_TEXT:
- case PG_TYPE_NAME:return SQL_SEARCHABLE;
+ case PG_TYPE_VARCHAR:
+ case PG_TYPE_BPCHAR:
+ case PG_TYPE_TEXT:
+ case PG_TYPE_NAME:
+ return SQL_SEARCHABLE;
default:
return SQL_ALL_EXCEPT_LIKE;
{
switch (type)
{
- case PG_TYPE_OID:
- case PG_TYPE_XID:return TRUE;
+ case PG_TYPE_OID:
+ case PG_TYPE_XID:
+ return TRUE;
case PG_TYPE_INT2:
case PG_TYPE_INT4:
{
switch (type)
{
-
case PG_TYPE_INT2:
case PG_TYPE_OID:
case PG_TYPE_XID:
{
switch (type)
{
-
case PG_TYPE_INT2:
case PG_TYPE_OID:
case PG_TYPE_XID:
/* (Appendix D) */
switch (sqltype)
{
- case SQL_CHAR:
- case SQL_VARCHAR:
- case SQL_LONGVARCHAR:
- case SQL_DECIMAL:
- case SQL_NUMERIC:
- case SQL_BIGINT:
+ case SQL_CHAR:
+ case SQL_VARCHAR:
+ case SQL_LONGVARCHAR:
+ case SQL_DECIMAL:
+ case SQL_NUMERIC:
+ case SQL_BIGINT:
return SQL_C_CHAR;
case SQL_BIT:
HINSTANCE NEAR s_hModule; /* Saved module handle. */
/* This is where the Driver Manager attaches to this Driver */
-BOOL WINAPI
+BOOL WINAPI
DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved)
{
WORD wVersionRequested;
if (LOBYTE(wsaData.wVersion) != 1 ||
HIBYTE(wsaData.wVersion) != 1)
{
-
WSACleanup();
return FALSE;
}
Driver Manager do this. Also, the ordinal values of the
functions must match the value of fFunction in SQLGetFunctions()
*/
-RETCODE SQL_API
+RETCODE SQL_API
SQLDummyOrdinal(void)
{
return SQL_SUCCESS;
rv->cache_size = globals.fetch_max;
rv->rowset_size = 1;
-
}
mylog("exit QR_Constructor\n");
free(self);
mylog("QResult: exit DESTRUCTOR\n");
-
}
void
if (self->backend_tuples)
{
-
for (row = 0; row < fcount; row++)
{
mylog("row = %d, num_fields = %d\n", row, num_fields);
}
else
{
-
/* Always have to read the field attributes. */
/* But we dont have to reallocate memory for them! */
return FALSE;
}
}
-
}
return TRUE;
}
else
{
-
/*
* See if we need to fetch another group of rows. We may be being
* called from send_query(), and if so, don't send another fetch,
if (!self->inTuples)
{
-
if (!globals.use_declarefetch)
{
mylog("next_tuple: ALL_ROWS: done, fcount = %d, fetch_count = %d\n", fcount, fetch_count);
offset = self->fetch_count;
self->fetch_count++;
-
}
for (;;)
{
-
id = SOCK_get_char(sock);
switch (id)
self->inTuples = FALSE;
if (self->fcount > 0)
{
-
qlog(" [ fetched %d rows ]\n", self->fcount);
mylog("_next_tuple: 'C' fetch_max && fcount = %d\n", self->fcount);
}
else
{
-
/*
* NO, the field is not null. so get at first the length of
* the field (four bytes)
-RETCODE SQL_API
+RETCODE SQL_API
SQLRowCount(
HSTMT hstmt,
SDWORD FAR * pcrow)
}
else
{
-
res = SC_get_Result(stmt);
if (res && pcrow)
{
/* attached to "hstmt". */
-RETCODE SQL_API
+RETCODE SQL_API
SQLNumResultCols(
HSTMT hstmt,
SWORD FAR * pccol)
parse_ok = FALSE;
if (globals.parse && stmt->statement_type == STMT_TYPE_SELECT)
{
-
if (stmt->parse_status == STMT_PARSE_NONE)
{
mylog("SQLNumResultCols: calling parse_statement on stmt=%u\n", stmt);
if (!parse_ok)
{
-
SC_pre_execute(stmt);
result = SC_get_Result(stmt);
/* Return information about the database column the user wants */
/* information about. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLDescribeCol(
HSTMT hstmt,
UWORD icol,
parse_ok = FALSE;
if (globals.parse && stmt->statement_type == STMT_TYPE_SELECT)
{
-
if (stmt->parse_status == STMT_PARSE_NONE)
{
mylog("SQLDescribeCol: calling parse_statement on stmt=%u\n", stmt);
if (stmt->parse_status != STMT_PARSE_FATAL && stmt->fi && stmt->fi[icol])
{
-
if (icol >= stmt->nfld)
{
stmt->errornumber = STMT_INVALID_COLUMN_NUMBER_ERROR;
/************************/
if (pcbColDef)
{
-
if (precision < 0)
precision = 0; /* "I dont know" */
/* Returns result column descriptor information for a result set. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLColAttributes(
HSTMT hstmt,
UWORD icol,
icol--;
unknown_sizes = globals.unknown_sizes; /* atoi(ci->unknown_sizes);
- * */
+ * */
if (unknown_sizes == UNKNOWNS_AS_DONTKNOW) /* not appropriate for
* SQLColAttributes() */
unknown_sizes = UNKNOWNS_AS_MAX;
parse_ok = FALSE;
if (globals.parse && stmt->statement_type == STMT_TYPE_SELECT)
{
-
if (stmt->parse_status == STMT_PARSE_NONE)
{
mylog("SQLColAttributes: calling parse_statement\n");
if (stmt->parse_status != STMT_PARSE_FATAL && stmt->fi && stmt->fi[icol])
{
-
if (icol >= cols)
{
stmt->errornumber = STMT_INVALID_COLUMN_NUMBER_ERROR;
mylog("SQLColAttr: COLUMN_LABEL = '%s'\n", p);
break;
-
} /* otherwise same as column name -- FALL
* THROUGH!!! */
if (pfDesc)
*pfDesc = value;
-
}
/* Returns result data for a single column in the current row. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLGetData(
HSTMT hstmt,
UWORD icol,
if (icol == 0)
{
-
if (stmt->options.use_bookmarks == SQL_UB_OFF)
{
stmt->errornumber = STMT_COLNUM_ERROR;
}
get_bookmark = TRUE;
-
}
else
{
-
/* use zero-based column numbers */
icol--;
/* Returns data for bound columns in the current row ("hstmt->iCursor"), */
/* advances the cursor. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLFetch(
HSTMT hstmt)
{
/* This fetchs a block of data (rowset). */
-RETCODE SQL_API
+RETCODE SQL_API
SQLExtendedFetch(
HSTMT hstmt,
UWORD fFetchType,
stmt->rowset_start = 0;
else
- {
-
stmt->rowset_start += (save_rowset_size > 0 ? save_rowset_size : stmt->options.rowset_size);
- }
mylog("SQL_FETCH_NEXT: num_tuples=%d, currtuple=%d\n", num_tuples, stmt->currTuple);
break;
*/
if (stmt->rowset_start >= num_tuples)
- {
stmt->rowset_start = num_tuples <= 0 ? 0 : (num_tuples - stmt->options.rowset_size);
-
- }
else
- {
-
stmt->rowset_start -= stmt->options.rowset_size;
- }
-
break;
case SQL_FETCH_FIRST:
default:
SC_log_error(func, "Unsupported SQLExtendedFetch Direction", stmt);
return SQL_ERROR;
-
}
truncated = error = FALSE;
for (i = 0; i < stmt->options.rowset_size; i++)
{
-
stmt->bind_row = i; /* set the binding location */
result = SC_fetch(stmt);
return SQL_SUCCESS_WITH_INFO;
else
return SQL_SUCCESS;
-
}
/* the "hstmt". */
/* CC: return SQL_NO_DATA_FOUND since we do not support multiple result sets */
-RETCODE SQL_API
+RETCODE SQL_API
SQLMoreResults(
HSTMT hstmt)
{
/* This positions the cursor within a rowset, that was positioned using SQLExtendedFetch. */
/* This will be useful (so far) only when using SQLGetData after SQLExtendedFetch. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLSetPos(
HSTMT hstmt,
UWORD irow,
stmt->currTuple = stmt->rowset_start + irow;
return SQL_SUCCESS;
-
}
/* Sets options that control the behavior of cursors. */
-RETCODE SQL_API
+RETCODE SQL_API
SQLSetScrollOptions(
HSTMT hstmt,
UWORD fConcurrency,
/* Set the cursor name on a statement handle */
-RETCODE SQL_API
+RETCODE SQL_API
SQLSetCursorName(
HSTMT hstmt,
UCHAR FAR * szCursor,
/* Return the cursor name for a statement handle */
-RETCODE SQL_API
+RETCODE SQL_API
SQLGetCursorName(
HSTMT hstmt,
UCHAR FAR * szCursor,
char szDSN[MAXDSNAME]; /* Original data source name */
BOOL fNewDSN; /* New data source flag */
BOOL fDefault; /* Default data source flag */
-
} SETUPDLG, FAR * LPSETUPDLG;
Output : TRUE success, FALSE otherwise
--------------------------------------------------------------------------*/
-BOOL CALLBACK
+BOOL CALLBACK
ConfigDSN(HWND hwnd,
WORD fRequest,
LPCSTR lpszDriver,
Input : hdlg -- Dialog window handle
Output : None
--------------------------------------------------------------------------*/
-void INTFUNC
+void INTFUNC
CenterDialog(HWND hdlg)
{
HWND hwndFrame;
--------------------------------------------------------------------------*/
-int CALLBACK
+int CALLBACK
ConfigDlgProc(HWND hdlg,
WORD wMsg,
WPARAM wParam,
LPARAM lParam)
{
-
switch (wMsg)
{
/* Initialize the dialog */
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
-
/*
* Ensure the OK button is enabled only when a data
* source name
Input : lpszAttributes - Pointer to attribute string
Output : None (global aAttr normally updated)
--------------------------------------------------------------------------*/
-void INTFUNC
+void INTFUNC
ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg)
{
LPCSTR lpsz;
cbKey = lpsz - lpszStart;
if (cbKey < sizeof(aszKey))
{
-
_fmemcpy(aszKey, lpszStart, cbKey);
aszKey[cbKey] = '\0';
}
Output : TRUE if successful, FALSE otherwise
--------------------------------------------------------------------------*/
-BOOL INTFUNC
+BOOL INTFUNC
SetDSNAttributes(HWND hwndParent, LPSETUPDLG lpsetupdlg)
{
LPCSTR lpszDSN; /* Pointer to data source name */
rv->reverse = FALSE;
}
return rv;
-
}
void
free(self->buffer_out);
free(self);
-
}
if (connect(self->socket, (struct sockaddr *) & (sadr),
sizeof(sadr)) < 0)
{
-
self->errornumber = SOCKET_COULD_NOT_CONNECT;
self->errormsg = "Could not connect to remote socket.";
closesocket(self->socket);
unsigned char
SOCK_get_next_byte(SocketClass * self)
{
-
if (self->buffer_read_in >= self->buffer_filled_in)
{
/* there are no more bytes left in the buffer -> */
self->errormsg = "Socket has been closed.";
self->buffer_filled_in = 0;
}
-
}
return self->buffer_in[self->buffer_read_in++];
}
};
-RETCODE SQL_API
+RETCODE SQL_API
SQLAllocStmt(HDBC hdbc,
HSTMT FAR * phstmt)
{
}
-RETCODE SQL_API
+RETCODE SQL_API
SQLFreeStmt(HSTMT hstmt,
UWORD fOption)
{
/* Destroy the statement and free any results, cursors, etc. */
SC_Destructor(stmt);
-
}
else if (fOption == SQL_UNBIND)
- {
SC_unbind_cols(stmt);
-
- }
else if (fOption == SQL_CLOSE)
{
/* this should discard all the results, but leave the statement */
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
-
}
else if (fOption == SQL_RESET_PARAMS)
- {
SC_free_params(stmt, STMT_FREE_PARAMS_ALL);
-
- }
else
{
stmt->errormsg = "Invalid option passed to SQLFreeStmt.";
char
SC_Destructor(StatementClass * self)
{
-
mylog("SC_Destructor: self=%u, self->result=%u, self->hdbc=%u\n", self, self->result, self->hdbc);
if (STMT_EXECUTING == self->status)
{
{
if (self->parameters[i].data_at_exec == TRUE)
{
-
if (self->parameters[i].EXEC_used)
{
free(self->parameters[i].EXEC_used);
conn = SC_get_conn(self);
if (!CC_is_in_autocommit(conn) && CC_is_in_trans(conn))
{
-
CC_send_query(conn, "ABORT", NULL);
CC_set_no_trans(conn);
}
void
SC_pre_execute(StatementClass * self)
{
-
mylog("SC_pre_execute: status = %d\n", self->status);
if (self->status == STMT_READY)
if (self->manual_result || !globals.use_declarefetch)
{
-
if (self->currTuple >= QR_get_num_tuples(res) - 1 ||
(self->options.maxRows > 0 && self->currTuple == self->options.maxRows - 1))
{
-
/*
* if at the end of the tuples, return "no data found" and set
* the cursor past the end of the result set
}
else
{
-
/* read from the cache or the physical next tuple */
retval = QR_next_tuple(res);
if (retval < 0)
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);
/* reset for SQLGetData */
if (!self->internal && !CC_is_in_trans(conn) &&
((globals.use_declarefetch && self->statement_type == STMT_TYPE_SELECT) || (!CC_is_in_autocommit(conn) && STMT_UPDATE(self))))
{
-
mylog(" about to begin a transaction on statement = %u\n", self);
res = CC_send_query(conn, "BEGIN", NULL);
if (!res)
/* in copy_statement... */
if (self->statement_type == STMT_TYPE_SELECT)
{
-
char fetch[128];
mylog(" Sending SELECT statement on stmt=%u, cursor_name='%s'\n", self, self->cursor_name);
if (globals.use_declarefetch && self->result != NULL &&
QR_command_successful(self->result))
{
-
QR_Destructor(self->result);
/*
/* Check the status of the result */
if (self->result)
{
-
was_ok = QR_command_successful(self->result);
was_nonfatal = QR_command_nonfatal(self->result);
rv = (TupleListClass *) malloc(sizeof(TupleListClass));
if (rv)
{
-
rv->num_fields = fieldcnt;
rv->num_tuples = 0;
rv->list_start = NULL;
}
else if (start_is_closer)
{
-
/*
* the shortest way is to start the search from the head of the
* list
char
TL_add_tuple(TupleListClass * self, TupleNode * new_field)
{
-
/*
* we append the tuple at the end of the doubly linked list of the
* tuples we have already read in
}
else
{
-
/*
* there is already an element in the list, so add the new one at
* the end of the list