/* Data at exec macro only valid for C char/binary data */
if (pcbValue && (*pcbValue == SQL_DATA_AT_EXEC ||
- *pcbValue <= SQL_LEN_DATA_AT_EXEC_OFFSET))
+ *pcbValue <= SQL_LEN_DATA_AT_EXEC_OFFSET))
stmt->parameters[ipar].data_at_exec = TRUE;
else
stmt->parameters[ipar].data_at_exec = FALSE;
}
-/* Associate a user-supplied buffer with a database column. */
+/* Associate a user-supplied buffer with a database column. */
RETCODE SQL_API
SQLBindCol(
HSTMT hstmt,
}
/*
- * Allocate enough bindings if not already done.
- * Most likely, execution of a statement would have setup the
- * necessary bindings. But some apps call BindCol before any
- * statement is executed.
+ * Allocate enough bindings if not already done. Most likely,
+ * execution of a statement would have setup the necessary bindings.
+ * But some apps call BindCol before any statement is executed.
*/
if (icol > stmt->bindings_allocated)
extend_bindings(stmt, icol);
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,
- * let it worry about it by unbinding those columns.
+ * There is no reason to zero out extra bindings if there are more
+ * than needed. If an app has allocated extra bindings, let it worry
+ * about it by unbinding those columns.
*/
/* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */
Oid new_adtid;
Int2 new_adtsize;
Int4 new_atttypmod = -1;
- /* MAX_COLUMN_LEN may be sufficient but for safety */
+
+ /* MAX_COLUMN_LEN may be sufficient but for safety */
char new_field_name[2 * MAX_COLUMN_LEN + 1];
SocketClass *sock;
ConnInfo *ci;
self->num_fields = new_num_fields;
self->name = (char **) malloc(sizeof(char *) * self->num_fields);
- memset(self->name, 0, sizeof(char *) * self->num_fields);
+ memset(self->name, 0, sizeof(char *) * self->num_fields);
self->adtid = (Oid *) malloc(sizeof(Oid) * self->num_fields);
self->adtsize = (Int2 *) malloc(sizeof(Int2) * self->num_fields);
self->display_size = (Int2 *) malloc(sizeof(Int2) * self->num_fields);
CC_set_translation(self);
/*
- * Send any initial settings
+ * Send any initial settings
*/
/*
char swallow;
int id;
SocketClass *sock = self->sock;
+
/* ERROR_MSG_LENGTH is suffcient */
static char msgbuffer[ERROR_MSG_LENGTH + 1];
+
/* QR_set_command() dups this string so doesn't need static */
char cmdbuffer[ERROR_MSG_LENGTH + 1];
c,
done;
SocketClass *sock = self->sock;
+
/* ERROR_MSG_LENGTH is sufficient */
static char msgbuffer[ERROR_MSG_LENGTH + 1];
int i;
}
/*
- * Extract the Major and Minor numbers from the string.
- * This assumes the string starts 'Postgresql X.X'
+ * Extract the Major and Minor numbers from the string. This assumes
+ * the string starts 'Postgresql X.X'
*/
strcpy(szVersion, "0.0");
if (sscanf(self->pg_version, "%*s %d.%d", &major, &minor) >= 2)
* How to map ODBC scalar functions {fn func(args)} to Postgres.
* This is just a simple substitution. List augmented from:
* http://www.merant.com/datadirect/download/docs/odbc16/Odbcref/rappc.htm
- * - thomas 2000-04-03
+ * - thomas 2000-04-03
*/
char *mapFuncs[][2] = {
/* { "ASCII", "ascii" }, */
*/
if (bind_size > 0)
- {
pcbValueOffset = rgbValueOffset = (bind_size * bind_row);
- }
else
{
pcbValueOffset = bind_row * sizeof(SDWORD);
if (!value)
{
+
/*
- * handle a null just by returning SQL_NULL_DATA in pcbValue,
- * and doing nothing to the buffer.
+ * handle a null just by returning SQL_NULL_DATA in pcbValue, and
+ * doing nothing to the buffer.
*/
if (pcbValue)
*(SDWORD *) ((char *) pcbValue + pcbValueOffset) = SQL_NULL_DATA;
}
/*
- * First convert any specific postgres types into more
- * useable data.
+ * First convert any specific postgres types into more useable data.
*
- * NOTE: Conversions from PG char/varchar of a date/time/timestamp
- * value to SQL_C_DATE,SQL_C_TIME, SQL_C_TIMESTAMP not supported
+ * NOTE: Conversions from PG char/varchar of a date/time/timestamp value
+ * to SQL_C_DATE,SQL_C_TIME, SQL_C_TIMESTAMP not supported
*/
switch (field_type)
{
- /*
- * $$$ need to add parsing for date/time/timestamp strings in
- * PG_TYPE_CHAR,VARCHAR $$$
- */
+
+ /*
+ * $$$ need to add parsing for date/time/timestamp strings in
+ * PG_TYPE_CHAR,VARCHAR $$$
+ */
case PG_TYPE_DATE:
sscanf(value, "%4d-%2d-%2d", &st.y, &st.m, &st.d);
break;
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
+ * The timestamp is invalid so set something conspicuous,
+ * like the epoch
*/
t = 0;
tim = localtime(&t);
}
break;
- /* This is for internal use by SQLStatistics() */
+ /* This is for internal use by SQLStatistics() */
case PG_TYPE_INT2VECTOR:
{
int nval,
if (fCType == SQL_C_CHAR)
{
/* Special character formatting as required */
+
/*
* These really should return error if cbValueMax is not big
* enough.
}
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
#ifdef MULTIBYTE
char *end = multibyte_strchr(begin, '}');
+
#else
char *end = strchr(begin, '}');
+
#endif
if (!end)
*end = '}';
continue;
}
+
/*
* Can you have parameter markers inside of quotes? I dont think
* so. All the queries I've seen expect the driver to put quotes
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 ((strcmp(key, "d") == 0) ||
(strcmp(key, "t") == 0) ||
- (strcmp(key, "oj") == 0) || /* {oj syntax support for 7.1 servers */
+ (strcmp(key, "oj") == 0) || /* {oj syntax support for 7.1
+ * servers */
(strcmp(key, "ts") == 0))
{
/* Literal; return the escape part as-is */
}
else if (strcmp(key, "fn") == 0)
{
+
/*
* Function invocation Separate off the func name, skipping
* trailing whitespace.
BindInfoClass *bindInfo = NULL;
- /* If using SQLGetData, then current_col will be set */
+ /* If using SQLGetData, then current_col will be set */
if (stmt->current_col >= 0)
{
bindInfo = &stmt->bindings[stmt->current_col];
void
SetDlgStuff(HWND hdlg, ConnInfo *ci)
{
+
/*
* If driver attribute NOT present, then set the datasource name and
* description
else
/* latest */
CheckDlgButton(hdlg, DS_PG64, 1);
-
+
CheckDlgButton(hdlg, DS_SHOWOIDCOLUMN, atoi(ci->show_oid_column));
CheckDlgButton(hdlg, DS_FAKEOIDINDEX, atoi(ci->fake_oid_index));
CheckDlgButton(hdlg, DS_ROWVERSIONING, atoi(ci->row_versioning));
/* Dont allow override of an override! */
if (!override)
{
+
/*
* ConnSettings is stored in the driver section and per datasource
* for override
dconn_get_connect_attributes(connStrIn, ci);
/*
- * If the ConnInfo in the hdbc is missing anything,
- * this function will fill them in from the registry (assuming
- * of course there is a DSN given -- if not, it does nothing!)
+ * If the ConnInfo in the hdbc is missing anything, this function will
+ * fill them in from the registry (assuming of course there is a DSN
+ * given -- if not, it does nothing!)
*/
getDSNinfo(ci, CONN_DONT_OVERWRITE);
ci->database[0] == '\0' ||
ci->port[0] == '\0')
{
- /* (password_required && ci->password[0] == '\0')) */
+ /* (password_required && ci->password[0] == '\0')) */
return SQL_NO_DATA_FOUND;
}
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,
break;
case CONN_TRANSACT_IN_PROGRES:
strcpy(szSqlState, "S1010");
+
/*
* when the user tries to switch commit mode in a
* transaction
mylog("in EN_Destructor, self=%u\n", self);
/*
- * the error messages are static strings distributed throughout
- * the source--they should not be freed
+ * the error messages are static strings distributed throughout the
+ * source--they should not be freed
*/
/* Free any connections belonging to this environment */
free(stmt->statement);
/*
- * keep a copy of the un-parametrized statement, in case
- * they try to execute this statement again
+ * keep a copy of the un-parametrized statement, in case they try to
+ * execute this statement again
*/
stmt->statement = make_string(szSqlStr, cbSqlStr, NULL);
if (!stmt->statement)
stmt->prepare = FALSE;
/*
- * If an SQLPrepare was performed prior to this, but was left in
- * the premature state because an error occurred prior to SQLExecute
- * then set the statement to finished so it can be recycled.
+ * If an SQLPrepare was performed prior to this, but was left in the
+ * premature state because an error occurred prior to SQLExecute then
+ * set the statement to finished so it can be recycled.
*/
if (stmt->status == STMT_PREMATURE)
stmt->status = STMT_FINISHED;
return SQL_ERROR;
}
- /* Check if statement has any data-at-execute parameters when it is not in SC_pre_execute. */
+ /*
+ * Check if statement has any data-at-execute parameters when it is
+ * not in SC_pre_execute.
+ */
if (!stmt->pre_executing)
{
/*
* The bound parameters could have possibly changed since the last
- * execute of this statement? Therefore check for params and re-copy.
+ * execute of this statement? Therefore check for params and
+ * re-copy.
*/
stmt->data_at_exec = -1;
for (i = 0; i < stmt->parameters_allocated; i++)
{
- Int4 *pcVal = stmt->parameters[i].used;
+ Int4 *pcVal = stmt->parameters[i].used;
+
if (pcVal && (*pcVal == SQL_DATA_AT_EXEC || *pcVal <= SQL_LEN_DATA_AT_EXEC_OFFSET))
stmt->parameters[i].data_at_exec = TRUE;
else
stmt->data_at_exec++;
}
}
- /* If there are some data at execution parameters, return need data */
/*
- * SQLParamData and SQLPutData will be used to send params and execute
- * the statement.
+ * If there are some data at execution parameters, return need
+ * data
+ */
+
+ /*
+ * SQLParamData and SQLPutData will be used to send params and
+ * execute the statement.
*/
if (stmt->data_at_exec > 0)
return SQL_NEED_DATA;
*/
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
}
/*
- * major hack -- to allow convert to see somethings there
- * have to modify convert to handle this better
+ * major hack -- to allow convert to see somethings there have
+ * to modify convert to handle this better
*/
current_param->EXEC_buffer = (char *) ¤t_param->lobj_oid;
}
else
{
- Int2 ctype = current_param->CType;
+ Int2 ctype = current_param->CType;
+
if (ctype == SQL_C_DEFAULT)
ctype = sqltype_to_default_ctype(current_param->SQLType);
if (ctype == SQL_C_CHAR || ctype == SQL_C_BINARY)
}
else
{
- Int4 used = ctype_length(ctype);
+ Int4 used = ctype_length(ctype);
+
current_param->EXEC_buffer = malloc(used);
if (!current_param->EXEC_buffer)
{
DWORD
GetPrivateProfileString(char *theSection, /* section name */
- char *theKey, /* search key name */
+ char *theKey, /* search key name */
char *theDefault, /* default value if not
* found */
char *theReturnBuffer, /* return value stored
DWORD
WritePrivateProfileString(char *theSection, /* section name */
- char *theKey, /* write key name */
+ char *theKey, /* write key name */
char *theBuffer, /* input buffer */
char *theIniFileName) /* pathname of ini file to
* write */
*/
DWORD
WritePrivateProfileString(char *theSection, /* section name */
- char *theKey, /* write key name */
+ char *theKey, /* write key name */
char *theBuffer, /* input buffer */
char *theIniFileName) /* pathname of ini file to
* write */
/*
* This doesn't make it so we find an ini file but allows normal
- * processing to continue further on down. The likelihood is that
- * the file won't be found and thus the default value will be
- * returned.
+ * processing to continue further on down. The likelihood is that the
+ * file won't be found and thus the default value will be returned.
*/
if (MAXPGPATH - 1 < strlen(ptr) + j)
{
sprintf(buf, "%s/%s", ptr, theIniFileName);
/*
- * This code makes it so that a file in the users home dir
- * overrides a the "default" file as passed in
+ * This code makes it so that a file in the users home dir overrides a
+ * the "default" file as passed in
*/
aFile = (FILE *) (buf ? fopen(buf, "r+") : NULL);
if (!aFile)
aLength = strlen(theBuffer);
/*
- * We have to search for theKey, because if it already
- * exists we have to overwrite it. If it doesn't exist
- * we just write a new line to the file.
+ * We have to search for theKey, because if it already exists we have
+ * to overwrite it. If it doesn't exist we just write a new line to
+ * the file.
*/
while (fgets(aLine, sizeof(aLine), aFile) != NULL)
{
break;
case SQL_CORRELATION_NAME: /* ODBC 1.0 */
+
/*
* Saying no correlation name makes Query not work right.
* value = SQL_CN_NONE;
break;
case SQL_DATABASE_NAME:/* Support for old ODBC 1.0 Apps */
+
/*
* Returning the database name causes problems in MS Query. It
* generates query like: "SELECT DISTINCT a FROM byronnbad3
break;
case SQL_DBMS_VER: /* ODBC 1.0 */
+
/*
* The ODBC spec wants ##.##.#### ...whatever... so prepend
* the driver
break;
case SQL_IDENTIFIER_CASE: /* ODBC 1.0 */
+
/*
* are identifiers case-sensitive (yes, but only when quoted.
* If not quoted, they default to lowercase)
break;
case SQL_LIKE_ESCAPE_CLAUSE: /* ODBC 2.0 */
+
/*
* is there a character that escapes '%' and '_' in a LIKE
* clause? not as far as I can tell
break;
case SQL_MAX_ROW_SIZE_INCLUDES_LONG: /* ODBC 2.0 */
+
/*
* does the preceding value include LONGVARCHAR and
* LONGVARBINARY fields? Well, it does include longvarchar,
if (PG_VERSION_GE(conn, 7.0))
value = MAX_STATEMENT_LEN;
/* Prior to 7.0 we used 2*BLCKSZ */
- else if (PG_VERSION_GE(conn, 6.5))
+ else if (PG_VERSION_GE(conn, 6.5))
value = (2 * BLCKSZ);
else
/* Prior to 6.5 we used BLCKSZ */
break;
case SQL_NEED_LONG_DATA_LEN: /* ODBC 2.0 */
+
/*
* Don't need the length, SQLPutData can handle any size and
* multiple calls
break;
case SQL_ROW_UPDATES: /* ODBC 1.0 */
+
/*
* Driver doesn't support keyset-driven or mixed cursors, so
* not much point in saying row updates are supported
break;
case SQL_TXN_CAPABLE: /* ODBC 1.0 */
+
/*
* Postgres can deal with create or drop table statements in a
* transaction
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.
/*
* I have to hide the table owner from Access, otherwise it
- * insists on referring to the table as 'owner.table'.
- * (this is valid according to the ODBC SQL grammar, but
- * Postgres won't support it.)
+ * insists on referring to the table as 'owner.table'. (this
+ * is valid according to the ODBC SQL grammar, but Postgres
+ * won't support it.)
*
* set_tuplefield_string(&row->tuple[1], table_owner);
*/
}
/*
- * also, things need to think that this statement is finished so
- * the results can be retrieved.
+ * also, things need to think that this statement is finished so the
+ * results can be retrieved.
*/
stmt->status = STMT_FINISHED;
my_strcat(columns_query, " and a.attname like '%.*s'", szColumnName, cbColumnName);
/*
- * give the output in the order the columns were defined
- * when the table was created
+ * give the output in the order the columns were defined when the
+ * table was created
*/
strcat(columns_query, " order by attnum");
}
/*
- * Put the row version column at the end so it might not be
- * mistaken for a key field.
+ * Put the row version column at the end so it might not be mistaken
+ * for a key field.
*/
if (relhasrules[0] != '1' && !stmt->internal && atoi(ci->row_versioning))
{
}
/*
- * also, things need to think that this statement is finished so
- * the results can be retrieved.
+ * also, things need to think that this statement is finished so the
+ * results can be retrieved.
*/
stmt->status = STMT_FINISHED;
QR_set_field_info(stmt->result, 12, "FILTER_CONDITION", PG_TYPE_TEXT, MAX_INFO_STRING);
/*
- * only use the table name... the owner should be redundant, and
- * we never use qualifiers.
+ * only use the table name... the owner should be redundant, and we
+ * never use qualifiers.
*/
table_name = make_string(szTableName, cbTableName, NULL);
if (!table_name)
}
/*
- * we need to get a list of the field names first,
- * so we can return them later.
+ * we need to get a list of the field names first, so we can return
+ * them later.
*/
result = SQLAllocStmt(stmt->hdbc, &hcol_stmt);
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
result = SQLExecDirect(hindx_stmt, index_query, strlen(index_query));
if ((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO))
{
+
/*
- * "Couldn't execute index query (w/SQLExecDirect) in
- * SQLStatistics.";
+ * "Couldn't execute index query (w/SQLExecDirect) in
+ * SQLStatistics.";
*/
stmt->errormsg = SC_create_errormsg(hindx_stmt);
-
+
stmt->errornumber = indx_stmt->errornumber;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
if (result != SQL_NO_DATA_FOUND)
{
/* "SQLFetch failed in SQLStatistics."; */
- stmt->errormsg = SC_create_errormsg(hindx_stmt);
+ stmt->errormsg = SC_create_errormsg(hindx_stmt);
stmt->errornumber = indx_stmt->errornumber;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
SQLFreeStmt(hindx_stmt, SQL_DROP);
/*
- * also, things need to think that this statement is finished so
- * the results can be retrieved.
+ * also, things need to think that this statement is finished so the
+ * results can be retrieved.
*/
stmt->status = STMT_FINISHED;
mylog("%s: entering...\n", func);
- /* Neither Access or Borland care about this. */
+ /* Neither Access or Borland care about this. */
SC_log_error(func, "Function not implemented", (StatementClass *) hstmt);
return SQL_ERROR;
/*
- * also, things need to think that this statement is finished so
- * the results can be retrieved.
+ * also, things need to think that this statement is finished so the
+ * results can be retrieved.
*/
stmt->status = STMT_FINISHED;
#if (ODBCVER >= 0x0300)
SWORD defer_type;
+
#endif
char pkey[MAX_INFO_STRING];
Int2 result_cols;
- mylog("%s: entering...stmt=%u\n", func, stmt);
+ mylog("%s: entering...stmt=%u\n", func, stmt);
if (!stmt)
{
#endif /* ODBCVER >= 0x0300 */
/*
- * also, things need to think that this statement is finished so
- * the results can be retrieved.
+ * also, things need to think that this statement is finished so the
+ * results can be retrieved.
*/
stmt->status = STMT_FINISHED;
int fd;
int result_len;
LO_ARG argv[2];
-
+
argv[0].isint = 1;
argv[0].len = 4;
argv[0].u.integer = lobjId;
va_end(args);
}
}
+
#endif
va_end(args);
}
}
+
#endif
/* Undefine these because windows.h will redefine and cause a warning */
break;
/* Chinese Big5(CP950) Support. */
- case BIG5:
- {
- if (multibyte_status < 2 && s > 0xA0)
- multibyte_status = 2;
- else if (multibyte_status == 2)
- multibyte_status = 1;
- else
- multibyte_status = 0;
- }
- break;
- default:
- multibyte_status = 0;
+ case BIG5:
+ {
+ if (multibyte_status < 2 && s > 0xA0)
+ multibyte_status = 2;
+ else if (multibyte_status == 2)
+ multibyte_status = 1;
+ else
+ multibyte_status = 0;
+ }
+ break;
+ default:
+ multibyte_status = 0;
}
#ifdef _DEBUG
qlog("multibyte_client_encoding = %d s = 0x%02X multibyte_stat = %d\n", multibyte_client_encoding, s, multibyte_status);
break;
case SQL_CONCURRENCY:
+
/*
* positioned update isn't supported so cursor concurrency is
* read-only
* if (globals.lie)
* {
* if (conn)
- * conn->stmtOptions.scroll_concurrency = vParam;
+ * conn->stmtOptions.scroll_concurrency = vParam;
* if (stmt)
- * stmt->options.scroll_concurrency = vParam;
+ * stmt->options.scroll_concurrency = vParam;
* } else {
- * if (conn)
+ * if (conn)
* conn->stmtOptions.scroll_concurrency =
- * SQL_CONCUR_READ_ONLY;
+ * SQL_CONCUR_READ_ONLY;
* if (stmt)
- * stmt->options.scroll_concurrency =
+ * stmt->options.scroll_concurrency =
* SQL_CONCUR_READ_ONLY;
*
- * if (vParam != SQL_CONCUR_READ_ONLY)
+ * if (vParam != SQL_CONCUR_READ_ONLY)
* changed = TRUE;
* }
* break;
*/
case SQL_CURSOR_TYPE:
+
/*
* if declare/fetch, then type can only be forward. otherwise,
* it can only be forward or static.
*-------
*/
- case SQL_MAX_LENGTH: /* ignored, but saved */
+ case SQL_MAX_LENGTH: /* ignored, but saved */
mylog("SetStmtOption(): SQL_MAX_LENGTH, vParam = %d\n", vParam);
if (conn)
conn->stmtOptions.maxLength = vParam;
stmt->options.maxLength = vParam;
break;
- case SQL_MAX_ROWS: /* ignored, but saved */
+ case SQL_MAX_ROWS: /* ignored, but saved */
mylog("SetStmtOption(): SQL_MAX_ROWS, vParam = %d\n", vParam);
if (conn)
conn->stmtOptions.maxRows = vParam;
stmt->options.maxRows = vParam;
break;
- case SQL_NOSCAN: /* ignored */
+ case SQL_NOSCAN: /* ignored */
mylog("SetStmtOption: SQL_NOSCAN, vParam = %d\n", vParam);
break;
- case SQL_QUERY_TIMEOUT: /* ignored */
+ case SQL_QUERY_TIMEOUT:/* ignored */
mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", vParam);
/* "0" returned in SQLGetStmtOption */
break;
- case SQL_RETRIEVE_DATA: /* ignored, but saved */
+ case SQL_RETRIEVE_DATA:/* ignored, but saved */
mylog("SetStmtOption(): SQL_RETRIEVE_DATA, vParam = %d\n", vParam);
if (conn)
conn->stmtOptions.retrieve_data = vParam;
switch (fOption)
{
- /*
- * Statement Options (apply to all stmts on the connection and
- * become defaults for new stmts)
- */
+
+ /*
+ * Statement Options (apply to all stmts on the connection and
+ * become defaults for new stmts)
+ */
case SQL_ASYNC_ENABLE:
case SQL_BIND_TYPE:
case SQL_CONCURRENCY:
break;
- /*
- * Connection Options
- */
+ /*
+ * Connection Options
+ */
case SQL_ACCESS_MODE: /* ignored */
break;
case SQL_CURRENT_QUALIFIER: /* ignored */
break;
- case SQL_LOGIN_TIMEOUT: /* ignored */
+ case SQL_LOGIN_TIMEOUT:/* ignored */
break;
case SQL_PACKET_SIZE: /* ignored */
case SQL_QUIET_MODE: /* ignored */
break;
- case SQL_TXN_ISOLATION: /* ignored */
+ case SQL_TXN_ISOLATION:/* ignored */
break;
- /* These options should be handled by driver manager */
+ /* These options should be handled by driver manager */
case SQL_ODBC_CURSORS:
case SQL_OPT_TRACE:
case SQL_OPT_TRACEFILE:
switch (fOption)
{
- case SQL_ACCESS_MODE: /* NOT SUPPORTED */
+ case SQL_ACCESS_MODE: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = SQL_MODE_READ_WRITE;
break;
break;
- case SQL_LOGIN_TIMEOUT: /* NOT SUPPORTED */
+ case SQL_LOGIN_TIMEOUT:/* NOT SUPPORTED */
*((UDWORD *) pvParam) = 0;
break;
- case SQL_PACKET_SIZE: /* NOT SUPPORTED */
+ case SQL_PACKET_SIZE: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = globals.socket_buffersize;
break;
- case SQL_QUIET_MODE: /* NOT SUPPORTED */
+ case SQL_QUIET_MODE: /* NOT SUPPORTED */
*((UDWORD *) pvParam) = (UDWORD) NULL;
break;
- case SQL_TXN_ISOLATION: /* NOT SUPPORTED */
+ case SQL_TXN_ISOLATION:/* NOT SUPPORTED */
*((UDWORD *) pvParam) = SQL_TXN_SERIALIZABLE;
break;
- /* These options should be handled by driver manager */
+ /* These options should be handled by driver manager */
case SQL_ODBC_CURSORS:
case SQL_OPT_TRACE:
case SQL_OPT_TRACEFILE:
mylog("%s: entering...\n", func);
/*
- * Though we could fake Access out by just returning SQL_SUCCESS
- * all the time, but it tries to set a huge value for SQL_MAX_LENGTH
- * and expects the driver to reduce it to the real value.
+ * Though we could fake Access out by just returning SQL_SUCCESS all
+ * the time, but it tries to set a huge value for SQL_MAX_LENGTH and
+ * expects the driver to reduce it to the real value.
*/
if (!stmt)
{
mylog("%s: entering...\n", func);
/*
- * thought we could fake Access out by just returning SQL_SUCCESS
- * all the time, but it tries to set a huge value for SQL_MAX_LENGTH
- * and expects the driver to reduce it to the real value
+ * thought we could fake Access out by just returning SQL_SUCCESS all
+ * the time, but it tries to set a huge value for SQL_MAX_LENGTH and
+ * expects the driver to reduce it to the real value
*/
if (!stmt)
{
char
searchColInfo(COL_INFO *col_info, FIELD_INFO *fi)
{
- int k, cmp;
- char *col;
+ int k,
+ cmp;
+ char *col;
for (k = 0; k < QR_get_num_tuples(col_info->result); k++)
{
strcpy(ti[stmt->ntab]->name, token);
if (!dquote)
{
- char *ptr;
+ char *ptr;
+
/* lower case table name */
for (ptr = ti[stmt->ntab]->name; *ptr; ptr++)
*ptr = tolower((unsigned char) *ptr);
/*
* ALL THESE TYPES ARE NO LONGER REPORTED in SQLGetTypeInfo. Instead, all
- * the SQL TYPES are reported and mapped to a corresponding Postgres Type
+ * the SQL TYPES are reported and mapped to a corresponding Postgres Type
*/
/*
case PG_TYPE_INT4:
return SQL_INTEGER;
- /* Change this to SQL_BIGINT for ODBC v3 bjm 2001-01-23 */
+ /* Change this to SQL_BIGINT for ODBC v3 bjm 2001-01-23 */
case PG_TYPE_INT8:
return SQL_CHAR;
return globals.bools_as_char ? SQL_CHAR : SQL_BIT;
default:
+
/*
* first, check to see if 'type' is in list. If not, look up
* with query. Add oid, name to list. If it's already in
* list, just return.
*/
/* hack until permanent type is available */
- if (type == stmt->hdbc->lobj_type)
+ if (type == stmt->hdbc->lobj_type)
return SQL_LONGVARBINARY;
return globals.unknowns_as_longvarchar ? SQL_LONGVARCHAR : SQL_VARCHAR;
{
switch (type)
{
- case PG_TYPE_CHAR:return "char";
+ case PG_TYPE_CHAR:return "char";
case PG_TYPE_CHAR2:
return "char2";
case PG_TYPE_CHAR4:
return PG_TYPE_LO_NAME;
default:
- /* hack until permanent type is available */
- if (type == stmt->hdbc->lobj_type)
+ /* hack until permanent type is available */
+ if (type == stmt->hdbc->lobj_type)
return PG_TYPE_LO_NAME;
/*
case PG_TYPE_FLOAT8:
return 22;
- /* Character types use regular precision */
+ /* Character types use regular precision */
default:
return pgtype_precision(stmt, type, col, handle_unknown_size_as);
}
case PG_TYPE_TIMESTAMP:
return 16;
- /* Character types (and NUMERIC) use the default precision */
+ /* Character types (and NUMERIC) use the default precision */
default:
return pgtype_precision(stmt, type, col, handle_unknown_size_as);
}
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...]"
- */
+ /*
+ * 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:
{
switch (type)
{
- case PG_TYPE_CHAR:
- case PG_TYPE_VARCHAR:return "max. length";
+ case PG_TYPE_CHAR:
+ case PG_TYPE_VARCHAR:return "max. length";
default:
return NULL;
}
Int2
sqltype_to_default_ctype(Int2 sqltype)
{
+
/*
- * from the table on page 623 of ODBC 2.0 Programmer's Reference
- * (Appendix D)
+ * from the table on page 623 of ODBC 2.0 Programmer's Reference
+ * (Appendix D)
*/
switch (sqltype)
{
* Description: This module contains functions related to
* managing result information (i.e, fetching rows
* from the backend, managing the tuple cache, etc.)
- * and retrieving it. Depending on the situation, a
+ * and retrieving it. Depending on the situation, a
* QResultClass will hold either data from the backend
* or a manually built result (see "qresult.h" to
* see which functions/macros are for manual or backend
TL_Destructor(self->manual_tuples);
/*
- * If conn is defined, then we may have used "backend_tuples",
- * so in case we need to, free it up. Also, close the cursor.
+ * If conn is defined, then we may have used "backend_tuples", so in
+ * case we need to, free it up. Also, close the cursor.
*/
if (self->conn && self->conn->sock && CC_is_in_trans(self->conn))
QR_close(self); /* close the cursor if there is one */
int tuple_size;
/*
- * If called from send_query the first time (conn != NULL),
- * then set the inTuples state,
- * and read the tuples. If conn is NULL,
- * it implies that we are being called from next_tuple(),
- * like to get more rows so don't call next_tuple again!
+ * If called from send_query the first time (conn != NULL), then set
+ * the inTuples state, and read the tuples. If conn is NULL, it
+ * implies that we are being called from next_tuple(), like to get
+ * more rows so don't call next_tuple again!
*/
if (conn != NULL)
{
}
else
{
+
/*
- * Always have to read the field attributes.
- * But we dont have to reallocate memory for them!
+ * Always have to read the field attributes. But we dont have to
+ * reallocate memory for them!
*/
if (!CI_read_fields(NULL, self->conn))
int end_tuple = self->rowset_size + self->base;
char corrected = FALSE;
TupleField *the_tuples = self->backend_tuples;
+
/* ERROR_MSG_LENGTH is sufficient */
static char msgbuffer[ERROR_MSG_LENGTH + 1];
+
/* QR_set_command() dups this string so doesn't need static */
char cmdbuffer[ERROR_MSG_LENGTH + 1];
char fetch[128];
self->tupleField = NULL;
self->status = PGRES_END_TUPLES;
/* end of tuples */
- return -1;
+ return -1;
}
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,
switch (id)
{
-
+
case 'T': /* Tuples within tuples cannot be handled */
self->status = PGRES_BAD_RESPONSE;
QR_set_message(self, "Tuples within tuples cannot be handled");
}
else
{
+
/*
* NO, the field is not null. so get at first the length of
* the field (four bytes)
SC_clear_error(stmt);
/*
- * Dont check for bookmark column. This is the responsibility of the
- * driver manager.
+ * Dont check for bookmark column. This is the responsibility of the
+ * driver manager.
*/
icol--; /* use zero based column numbers */
}
/*
- * If couldn't parse it OR the field being described was not parsed
- * (i.e., because it was a function or expression, etc, then do it the
- * old fashioned way.
+ * If couldn't parse it OR the field being described was not parsed
+ * (i.e., because it was a function or expression, etc, then do it the
+ * old fashioned way.
*/
if (!parse_ok)
{
/* atoi(ci->unknown_sizes) */
precision = pgtype_precision(stmt, fieldtype, icol, globals.unknown_sizes);
- }
+ }
mylog("describeCol: col %d fieldname = '%s'\n", icol, col_name);
mylog("describeCol: col %d fieldtype = %d\n", icol, fieldtype);
icol--;
/* atoi(ci->unknown_sizes); */
- unknown_sizes = globals.unknown_sizes;
+ unknown_sizes = globals.unknown_sizes;
/* not appropriate for SQLColAttributes() */
- if (unknown_sizes == UNKNOWNS_AS_DONTKNOW)
+ if (unknown_sizes == UNKNOWNS_AS_DONTKNOW)
unknown_sizes = UNKNOWNS_AS_MAX;
parse_ok = FALSE;
value = pgtype_case_sensitive(stmt, field_type);
break;
- /*
- * This special case is handled above.
- *
- * case SQL_COLUMN_COUNT:
- */
+ /*
+ * This special case is handled above.
+ *
+ * case SQL_COLUMN_COUNT:
+ */
case SQL_COLUMN_DISPLAY_SIZE:
value = (parse_ok) ? stmt->fi[icol]->display_size : pgtype_display_size(stmt, field_type, icol, unknown_sizes);
break;
case SQL_COLUMN_UPDATABLE:
+
/*
* Neither Access or Borland care about this.
*
switch (fFetchType)
{
case SQL_FETCH_NEXT:
+
/*
* From the odbc spec... If positioned before the start of the
* RESULT SET, then this should be equivalent to
case SQL_FETCH_PRIOR:
mylog("SQL_FETCH_PRIOR: num_tuples=%d, currtuple=%d\n", num_tuples, stmt->currTuple);
+
/*
* From the odbc spec... If positioned after the end of the
* RESULT SET, then this should be equivalent to
break;
case SQL_FETCH_RELATIVE:
+
/*
* Refresh the current rowset -- not currently implemented,
* but lie anyway
/*--------
* ConfigDSN
*
- * Description: ODBC Setup entry point
+ * Description: ODBC Setup entry point
* This entry point is called by the ODBC Installer
* (see file header for more details)
- * Input : hwnd ----------- Parent window handle
+ * Input : hwnd ----------- Parent window handle
* fRequest ------- Request type (i.e., add, config, or remove)
* lpszDriver ----- Driver name
* lpszAttributes - data source attribute string
- * Output : TRUE success, FALSE otherwise
+ * Output : TRUE success, FALSE otherwise
*--------
*/
BOOL CALLBACK
/*-------
* ConfigDlgProc
- * Description: Manage add data source name dialog
- * Input : hdlg --- Dialog window handle
+ * Description: Manage add data source name dialog
+ * Input : hdlg --- Dialog window handle
* wMsg --- Message
* wParam - Message parameter
* lParam - Message parameter
- * Output : TRUE if message processed, FALSE otherwise
+ * Output : TRUE if message processed, FALSE otherwise
*-------
*/
int CALLBACK
return TRUE; /* Focus was not set */
}
- /* Process buttons */
+ /* Process buttons */
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
+
/*
* Ensure the OK button is enabled only when a data
* source name
}
break;
- /* Accept results */
+ /* Accept results */
case IDOK:
{
LPSETUPDLG lpsetupdlg;
SetDSNAttributes(hdlg, lpsetupdlg);
}
- /* Return to caller */
+ /* Return to caller */
case IDCANCEL:
EndDialog(hdlg, wParam);
return TRUE;
/*-------
* ParseAttributes
*
- * Description: Parse attribute string moving values into the aAttr array
- * Input : lpszAttributes - Pointer to attribute string
- * Output : None (global aAttr normally updated)
+ * Description: Parse attribute string moving values into the aAttr array
+ * Input : lpszAttributes - Pointer to attribute string
+ * Output : None (global aAttr normally updated)
*-------
*/
void INTFUNC
for (lpsz = lpszAttributes; *lpsz; lpsz++)
{
- /* Extract key name (e.g., DSN), it must be terminated by an equals */
+
+ /*
+ * Extract key name (e.g., DSN), it must be terminated by an
+ * equals
+ */
lpszStart = lpsz;
for (;; lpsz++)
{
/*--------
* SetDSNAttributes
*
- * Description: Write data source attributes to ODBC.INI
- * Input : hwnd - Parent window handle (plus globals)
- * Output : TRUE if successful, FALSE otherwise
+ * Description: Write data source attributes to ODBC.INI
+ * Input : hwnd - Parent window handle (plus globals)
+ * Output : TRUE if successful, FALSE otherwise
*--------
*/
BOOL INTFUNC
{
switch (len)
{
- case 2:
- {
- unsigned short buf;
+ case 2:
+ {
+ unsigned short buf;
- SOCK_get_n_char(self, (char *) &buf, len);
- if (self->reverse)
- return buf;
- else
- return ntohs(buf);
- }
+ SOCK_get_n_char(self, (char *) &buf, len);
+ if (self->reverse)
+ return buf;
+ else
+ return ntohs(buf);
+ }
case 4:
- {
- unsigned int buf;
+ {
+ unsigned int buf;
- SOCK_get_n_char(self, (char *) &buf, len);
- if (self->reverse)
- return buf;
- else
- return ntohl(buf);
- }
+ SOCK_get_n_char(self, (char *) &buf, len);
+ if (self->reverse)
+ return buf;
+ else
+ return ntohl(buf);
+ }
default:
self->errornumber = SOCKET_GET_INT_WRONG_LENGTH;
{
if (self->buffer_read_in >= self->buffer_filled_in)
{
+
/*
- * there are no more bytes left in the buffer so
- * reload the buffer
+ * there are no more bytes left in the buffer so reload the buffer
*/
self->buffer_read_in = 0;
self->buffer_filled_in = recv(self->socket, (char *) self->buffer_in, globals.socket_buffersize, 0);
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
* itself in place (it can be executed again)
}
}
else if (fOption == SQL_RESET_PARAMS)
- {
SC_free_params(stmt, STMT_FREE_PARAMS_ALL);
- }
else
{
stmt->errormsg = "Invalid option passed to SQLFreeStmt.";
/*
* the memory pointed to by the bindings is not deallocated by the
- * driver but by the application that uses that driver, so we don't have to
- * care
+ * driver but by the application that uses that driver, so we don't
+ * have to care
*/
/* about that here. */
if (self->bindings)
/*
* Free any data at exec params before the statement is executed
- * again. If not, then there will be a memory leak when
- * the next SQLParamData/SQLPutData is called.
+ * again. If not, then there will be a memory leak when the next
+ * SQLParamData/SQLPutData is called.
*/
SC_free_params(self, STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY);
if (self->statement_type == STMT_TYPE_SELECT)
{
- char old_pre_executing = self->pre_executing;
+ char old_pre_executing = self->pre_executing;
+
self->pre_executing = TRUE;
self->inaccurate_result = FALSE;
{
char rv;
- /* Create a very informative errormsg if it hasn't been done yet. */
+ /* Create a very informative errormsg if it hasn't been done yet. */
if (!self->errormsg_created)
{
self->errormsg = SC_create_errormsg(self);
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
result = SQL_SUCCESS_WITH_INFO;
break;
- /* error msg already filled in */
+ /* error msg already filled in */
case COPY_GENERAL_ERROR:
SC_log_error(func, "", self);
result = SQL_ERROR;
break;
- /* This would not be meaningful in SQLFetch. */
+ /* This would not be meaningful in SQLFetch. */
case COPY_NO_DATA_FOUND:
break;
* substitution */
char pre_executing; /* This statement is prematurely executing */
- char inaccurate_result; /* Current status is PREMATURE
- * but result is inaccurate */
+ char inaccurate_result; /* Current status is PREMATURE but
+ * result is inaccurate */
};
#define SC_get_conn(a) (a->hdbc)
}
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