mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Run pgindent on ODBC code only, to reformat new comments.
This commit is contained in:
parent
296e7ba2ba
commit
1c551683cb
@ -145,7 +145,7 @@ SQLBindParameter(
|
||||
|
||||
/* 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;
|
||||
@ -160,7 +160,7 @@ SQLBindParameter(
|
||||
}
|
||||
|
||||
|
||||
/* Associate a user-supplied buffer with a database column. */
|
||||
/* Associate a user-supplied buffer with a database column. */
|
||||
RETCODE SQL_API
|
||||
SQLBindCol(
|
||||
HSTMT hstmt,
|
||||
@ -220,10 +220,9 @@ SQLBindCol(
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
@ -467,10 +466,11 @@ extend_bindings(StatementClass *stmt, int num_columns)
|
||||
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 */
|
||||
|
@ -61,7 +61,8 @@ CI_read_fields(ColumnInfoClass *self, ConnectionClass *conn)
|
||||
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;
|
||||
@ -152,7 +153,7 @@ CI_set_num_fields(ColumnInfoClass *self, int new_num_fields)
|
||||
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);
|
||||
|
@ -762,7 +762,7 @@ CC_connect(ConnectionClass *self, char do_password)
|
||||
CC_set_translation(self);
|
||||
|
||||
/*
|
||||
* Send any initial settings
|
||||
* Send any initial settings
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -915,8 +915,10 @@ CC_send_query(ConnectionClass *self, char *query, QueryInfo *qi)
|
||||
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];
|
||||
|
||||
@ -1210,6 +1212,7 @@ CC_send_function(ConnectionClass *self, int fnid, void *result_buf, int *actual_
|
||||
c,
|
||||
done;
|
||||
SocketClass *sock = self->sock;
|
||||
|
||||
/* ERROR_MSG_LENGTH is sufficient */
|
||||
static char msgbuffer[ERROR_MSG_LENGTH + 1];
|
||||
int i;
|
||||
@ -1590,8 +1593,8 @@ CC_lookup_pg_version(ConnectionClass *self)
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
|
@ -69,7 +69,7 @@ extern GLOBAL_VALUES globals;
|
||||
* 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" }, */
|
||||
@ -199,9 +199,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||
*/
|
||||
|
||||
if (bind_size > 0)
|
||||
{
|
||||
pcbValueOffset = rgbValueOffset = (bind_size * bind_row);
|
||||
}
|
||||
else
|
||||
{
|
||||
pcbValueOffset = bind_row * sizeof(SDWORD);
|
||||
@ -221,9 +219,10 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||
|
||||
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;
|
||||
@ -242,18 +241,18 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
@ -269,9 +268,10 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||
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);
|
||||
@ -295,7 +295,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||
}
|
||||
break;
|
||||
|
||||
/* This is for internal use by SQLStatistics() */
|
||||
/* This is for internal use by SQLStatistics() */
|
||||
case PG_TYPE_INT2VECTOR:
|
||||
{
|
||||
int nval,
|
||||
@ -379,6 +379,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||
if (fCType == SQL_C_CHAR)
|
||||
{
|
||||
/* Special character formatting as required */
|
||||
|
||||
/*
|
||||
* These really should return error if cbValueMax is not big
|
||||
* enough.
|
||||
@ -483,6 +484,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||
}
|
||||
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
|
||||
@ -780,8 +782,10 @@ copy_statement_with_parameters(StatementClass *stmt)
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
char *end = multibyte_strchr(begin, '}');
|
||||
|
||||
#else
|
||||
char *end = strchr(begin, '}');
|
||||
|
||||
#endif
|
||||
|
||||
if (!end)
|
||||
@ -806,6 +810,7 @@ copy_statement_with_parameters(StatementClass *stmt)
|
||||
*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
|
||||
@ -1101,9 +1106,7 @@ copy_statement_with_parameters(StatementClass *stmt)
|
||||
case SQL_LONGVARBINARY:
|
||||
|
||||
if (stmt->parameters[param_number].data_at_exec)
|
||||
{
|
||||
lobj_oid = stmt->parameters[param_number].lobj_oid;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* begin transaction if needed */
|
||||
@ -1308,7 +1311,8 @@ convert_escape(char *value)
|
||||
|
||||
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 */
|
||||
@ -1316,6 +1320,7 @@ convert_escape(char *value)
|
||||
}
|
||||
else if (strcmp(key, "fn") == 0)
|
||||
{
|
||||
|
||||
/*
|
||||
* Function invocation Separate off the func name, skipping
|
||||
* trailing whitespace.
|
||||
@ -1722,7 +1727,7 @@ convert_lo(StatementClass *stmt, void *value, Int2 fCType, PTR rgbValue,
|
||||
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];
|
||||
|
@ -56,6 +56,7 @@ extern GLOBAL_VALUES globals;
|
||||
void
|
||||
SetDlgStuff(HWND hdlg, ConnInfo *ci)
|
||||
{
|
||||
|
||||
/*
|
||||
* If driver attribute NOT present, then set the datasource name and
|
||||
* description
|
||||
@ -269,7 +270,7 @@ ds_optionsProc(HWND hdlg,
|
||||
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));
|
||||
@ -791,6 +792,7 @@ getGlobalDefaults(char *section, char *filename, char override)
|
||||
/* Dont allow override of an override! */
|
||||
if (!override)
|
||||
{
|
||||
|
||||
/*
|
||||
* ConnSettings is stored in the driver section and per datasource
|
||||
* for override
|
||||
|
@ -112,9 +112,9 @@ SQLDriverConnect(
|
||||
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);
|
||||
|
||||
@ -175,7 +175,7 @@ dialog:
|
||||
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;
|
||||
}
|
||||
@ -217,6 +217,7 @@ dialog:
|
||||
|
||||
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,
|
||||
|
@ -308,6 +308,7 @@ SQLError(
|
||||
break;
|
||||
case CONN_TRANSACT_IN_PROGRES:
|
||||
strcpy(szSqlState, "S1010");
|
||||
|
||||
/*
|
||||
* when the user tries to switch commit mode in a
|
||||
* transaction
|
||||
@ -441,8 +442,8 @@ EN_Destructor(EnvironmentClass *self)
|
||||
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 */
|
||||
|
@ -153,8 +153,8 @@ SQLExecDirect(
|
||||
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)
|
||||
@ -170,9 +170,9 @@ SQLExecDirect(
|
||||
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;
|
||||
@ -288,18 +288,23 @@ SQLExecute(
|
||||
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
|
||||
@ -313,11 +318,15 @@ SQLExecute(
|
||||
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;
|
||||
@ -449,6 +458,7 @@ SQLCancel(
|
||||
*/
|
||||
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
|
||||
@ -753,8 +763,8 @@ SQLPutData(
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@ -787,7 +797,8 @@ SQLPutData(
|
||||
}
|
||||
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)
|
||||
@ -805,7 +816,8 @@ SQLPutData(
|
||||
}
|
||||
else
|
||||
{
|
||||
Int4 used = ctype_length(ctype);
|
||||
Int4 used = ctype_length(ctype);
|
||||
|
||||
current_param->EXEC_buffer = malloc(used);
|
||||
if (!current_param->EXEC_buffer)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@
|
||||
|
||||
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
|
||||
@ -281,7 +281,7 @@ GetPrivateProfileString(char *theSection, /* section name */
|
||||
|
||||
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 */
|
||||
@ -298,7 +298,7 @@ WritePrivateProfileString(char *theSection, /* section name */
|
||||
*/
|
||||
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 */
|
||||
@ -342,9 +342,8 @@ WritePrivateProfileString(char *theSection, /* section name */
|
||||
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
@ -357,8 +356,8 @@ WritePrivateProfileString(char *theSection, /* section name */
|
||||
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)
|
||||
@ -372,9 +371,9 @@ WritePrivateProfileString(char *theSection, /* section name */
|
||||
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)
|
||||
{
|
||||
|
@ -153,6 +153,7 @@ SQLGetInfo(
|
||||
break;
|
||||
|
||||
case SQL_CORRELATION_NAME: /* ODBC 1.0 */
|
||||
|
||||
/*
|
||||
* Saying no correlation name makes Query not work right.
|
||||
* value = SQL_CN_NONE;
|
||||
@ -180,6 +181,7 @@ SQLGetInfo(
|
||||
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
|
||||
@ -195,6 +197,7 @@ SQLGetInfo(
|
||||
break;
|
||||
|
||||
case SQL_DBMS_VER: /* ODBC 1.0 */
|
||||
|
||||
/*
|
||||
* The ODBC spec wants ##.##.#### ...whatever... so prepend
|
||||
* the driver
|
||||
@ -252,6 +255,7 @@ SQLGetInfo(
|
||||
break;
|
||||
|
||||
case SQL_IDENTIFIER_CASE: /* ODBC 1.0 */
|
||||
|
||||
/*
|
||||
* are identifiers case-sensitive (yes, but only when quoted.
|
||||
* If not quoted, they default to lowercase)
|
||||
@ -270,6 +274,7 @@ SQLGetInfo(
|
||||
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
|
||||
@ -362,6 +367,7 @@ SQLGetInfo(
|
||||
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,
|
||||
@ -377,7 +383,7 @@ SQLGetInfo(
|
||||
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 */
|
||||
@ -410,6 +416,7 @@ SQLGetInfo(
|
||||
break;
|
||||
|
||||
case SQL_NEED_LONG_DATA_LEN: /* ODBC 2.0 */
|
||||
|
||||
/*
|
||||
* Don't need the length, SQLPutData can handle any size and
|
||||
* multiple calls
|
||||
@ -537,6 +544,7 @@ SQLGetInfo(
|
||||
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
|
||||
@ -624,6 +632,7 @@ SQLGetInfo(
|
||||
break;
|
||||
|
||||
case SQL_TXN_CAPABLE: /* ODBC 1.0 */
|
||||
|
||||
/*
|
||||
* Postgres can deal with create or drop table statements in a
|
||||
* transaction
|
||||
@ -1297,6 +1306,7 @@ SQLTables(
|
||||
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.
|
||||
@ -1351,9 +1361,9 @@ SQLTables(
|
||||
|
||||
/*
|
||||
* 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);
|
||||
*/
|
||||
@ -1379,8 +1389,8 @@ SQLTables(
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@ -1463,8 +1473,8 @@ SQLColumns(
|
||||
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");
|
||||
|
||||
@ -1787,8 +1797,8 @@ SQLColumns(
|
||||
}
|
||||
|
||||
/*
|
||||
* 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))
|
||||
{
|
||||
@ -1817,8 +1827,8 @@ SQLColumns(
|
||||
}
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@ -2064,8 +2074,8 @@ SQLStatistics(
|
||||
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)
|
||||
@ -2077,8 +2087,8 @@ SQLStatistics(
|
||||
}
|
||||
|
||||
/*
|
||||
* 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))
|
||||
@ -2168,12 +2178,13 @@ SQLStatistics(
|
||||
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;
|
||||
@ -2343,7 +2354,7 @@ SQLStatistics(
|
||||
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;
|
||||
@ -2352,8 +2363,8 @@ SQLStatistics(
|
||||
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;
|
||||
|
||||
@ -2399,7 +2410,7 @@ SQLColumnPrivileges(
|
||||
|
||||
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;
|
||||
@ -2575,8 +2586,8 @@ SQLPrimaryKeys(
|
||||
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
@ -2636,11 +2647,12 @@ SQLForeignKeys(
|
||||
|
||||
#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)
|
||||
{
|
||||
@ -2690,8 +2702,8 @@ SQLForeignKeys(
|
||||
#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;
|
||||
|
||||
|
@ -41,7 +41,7 @@ lo_open(ConnectionClass *conn, int lobjId, int mode)
|
||||
int fd;
|
||||
int result_len;
|
||||
LO_ARG argv[2];
|
||||
|
||||
|
||||
argv[0].isint = 1;
|
||||
argv[0].len = 4;
|
||||
argv[0].u.integer = lobjId;
|
||||
|
@ -85,6 +85,7 @@ mylog(char *fmt,...)
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -114,6 +115,7 @@ qlog(char *fmt,...)
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Undefine these because windows.h will redefine and cause a warning */
|
||||
|
@ -110,18 +110,18 @@ multibyte_char_check(unsigned char s)
|
||||
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);
|
||||
|
@ -67,6 +67,7 @@ set_statement_option(ConnectionClass *conn,
|
||||
break;
|
||||
|
||||
case SQL_CONCURRENCY:
|
||||
|
||||
/*
|
||||
* positioned update isn't supported so cursor concurrency is
|
||||
* read-only
|
||||
@ -81,18 +82,18 @@ set_statement_option(ConnectionClass *conn,
|
||||
* 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;
|
||||
@ -101,6 +102,7 @@ set_statement_option(ConnectionClass *conn,
|
||||
*/
|
||||
|
||||
case SQL_CURSOR_TYPE:
|
||||
|
||||
/*
|
||||
* if declare/fetch, then type can only be forward. otherwise,
|
||||
* it can only be forward or static.
|
||||
@ -171,7 +173,7 @@ set_statement_option(ConnectionClass *conn,
|
||||
*-------
|
||||
*/
|
||||
|
||||
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;
|
||||
@ -179,7 +181,7 @@ set_statement_option(ConnectionClass *conn,
|
||||
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;
|
||||
@ -187,16 +189,16 @@ set_statement_option(ConnectionClass *conn,
|
||||
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;
|
||||
@ -315,10 +317,11 @@ SQLSetConnectOption(
|
||||
|
||||
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:
|
||||
@ -353,9 +356,9 @@ SQLSetConnectOption(
|
||||
|
||||
break;
|
||||
|
||||
/*
|
||||
* Connection Options
|
||||
*/
|
||||
/*
|
||||
* Connection Options
|
||||
*/
|
||||
|
||||
case SQL_ACCESS_MODE: /* ignored */
|
||||
break;
|
||||
@ -392,7 +395,7 @@ SQLSetConnectOption(
|
||||
case SQL_CURRENT_QUALIFIER: /* ignored */
|
||||
break;
|
||||
|
||||
case SQL_LOGIN_TIMEOUT: /* ignored */
|
||||
case SQL_LOGIN_TIMEOUT:/* ignored */
|
||||
break;
|
||||
|
||||
case SQL_PACKET_SIZE: /* ignored */
|
||||
@ -401,10 +404,10 @@ SQLSetConnectOption(
|
||||
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:
|
||||
@ -456,7 +459,7 @@ SQLGetConnectOption(
|
||||
|
||||
switch (fOption)
|
||||
{
|
||||
case SQL_ACCESS_MODE: /* NOT SUPPORTED */
|
||||
case SQL_ACCESS_MODE: /* NOT SUPPORTED */
|
||||
*((UDWORD *) pvParam) = SQL_MODE_READ_WRITE;
|
||||
break;
|
||||
|
||||
@ -471,23 +474,23 @@ SQLGetConnectOption(
|
||||
|
||||
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:
|
||||
@ -525,9 +528,9 @@ SQLSetStmtOption(
|
||||
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)
|
||||
{
|
||||
@ -552,9 +555,9 @@ SQLGetStmtOption(
|
||||
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)
|
||||
{
|
||||
|
@ -233,8 +233,9 @@ getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k)
|
||||
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++)
|
||||
{
|
||||
@ -575,7 +576,8 @@ parse_statement(StatementClass *stmt)
|
||||
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);
|
||||
|
@ -51,7 +51,7 @@ Int4 getCharPrecision(StatementClass *stmt, Int4 type, int col, int handle_unkn
|
||||
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -237,7 +237,7 @@ pgtype_to_sqltype(StatementClass *stmt, Int4 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;
|
||||
|
||||
@ -262,13 +262,14 @@ pgtype_to_sqltype(StatementClass *stmt, Int4 type)
|
||||
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;
|
||||
@ -328,7 +329,7 @@ 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:
|
||||
@ -378,8 +379,8 @@ pgtype_to_name(StatementClass *stmt, Int4 type)
|
||||
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;
|
||||
|
||||
/*
|
||||
@ -640,7 +641,7 @@ pgtype_display_size(StatementClass *stmt, Int4 type, int col, int handle_unknown
|
||||
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);
|
||||
}
|
||||
@ -686,7 +687,7 @@ pgtype_length(StatementClass *stmt, Int4 type, int col, int handle_unknown_size_
|
||||
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);
|
||||
}
|
||||
@ -708,10 +709,10 @@ pgtype_scale(StatementClass *stmt, Int4 type, int col)
|
||||
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:
|
||||
@ -911,8 +912,8 @@ pgtype_create_params(StatementClass *stmt, Int4 type)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@ -922,9 +923,10 @@ pgtype_create_params(StatementClass *stmt, Int4 type)
|
||||
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)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
* 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
|
||||
@ -138,8 +138,8 @@ QR_Destructor(QResultClass *self)
|
||||
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 */
|
||||
@ -232,11 +232,10 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor)
|
||||
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)
|
||||
{
|
||||
@ -303,9 +302,10 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor)
|
||||
}
|
||||
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))
|
||||
@ -390,8 +390,10 @@ QR_next_tuple(QResultClass *self)
|
||||
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];
|
||||
@ -413,10 +415,11 @@ QR_next_tuple(QResultClass *self)
|
||||
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,
|
||||
@ -513,7 +516,7 @@ QR_next_tuple(QResultClass *self)
|
||||
|
||||
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");
|
||||
@ -646,6 +649,7 @@ QR_read_tuple(QResultClass *self, char binary)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* NO, the field is not null. so get at first the length of
|
||||
* the field (four bytes)
|
||||
|
@ -212,8 +212,8 @@ SQLDescribeCol(
|
||||
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 */
|
||||
@ -251,9 +251,9 @@ SQLDescribeCol(
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
@ -285,7 +285,7 @@ SQLDescribeCol(
|
||||
|
||||
/* 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);
|
||||
@ -407,10 +407,10 @@ SQLColAttributes(
|
||||
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;
|
||||
@ -505,11 +505,11 @@ SQLColAttributes(
|
||||
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);
|
||||
|
||||
@ -592,6 +592,7 @@ SQLColAttributes(
|
||||
break;
|
||||
|
||||
case SQL_COLUMN_UPDATABLE:
|
||||
|
||||
/*
|
||||
* Neither Access or Borland care about this.
|
||||
*
|
||||
@ -992,6 +993,7 @@ SQLExtendedFetch(
|
||||
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
|
||||
@ -1009,6 +1011,7 @@ SQLExtendedFetch(
|
||||
|
||||
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
|
||||
@ -1054,6 +1057,7 @@ SQLExtendedFetch(
|
||||
break;
|
||||
|
||||
case SQL_FETCH_RELATIVE:
|
||||
|
||||
/*
|
||||
* Refresh the current rowset -- not currently implemented,
|
||||
* but lie anyway
|
||||
|
@ -66,14 +66,14 @@ BOOL INTFUNC SetDSNAttributes(HWND hwnd, LPSETUPDLG lpsetupdlg);
|
||||
/*--------
|
||||
* 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
|
||||
@ -204,12 +204,12 @@ CenterDialog(HWND hdlg)
|
||||
|
||||
/*-------
|
||||
* 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
|
||||
@ -261,10 +261,11 @@ ConfigDlgProc(HWND hdlg,
|
||||
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
|
||||
@ -283,7 +284,7 @@ ConfigDlgProc(HWND hdlg,
|
||||
}
|
||||
break;
|
||||
|
||||
/* Accept results */
|
||||
/* Accept results */
|
||||
case IDOK:
|
||||
{
|
||||
LPSETUPDLG lpsetupdlg;
|
||||
@ -301,7 +302,7 @@ ConfigDlgProc(HWND hdlg,
|
||||
SetDSNAttributes(hdlg, lpsetupdlg);
|
||||
}
|
||||
|
||||
/* Return to caller */
|
||||
/* Return to caller */
|
||||
case IDCANCEL:
|
||||
EndDialog(hdlg, wParam);
|
||||
return TRUE;
|
||||
@ -335,9 +336,9 @@ ConfigDlgProc(HWND hdlg,
|
||||
/*-------
|
||||
* 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
|
||||
@ -353,7 +354,11 @@ ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg)
|
||||
|
||||
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++)
|
||||
{
|
||||
@ -390,9 +395,9 @@ ParseAttributes(LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg)
|
||||
/*--------
|
||||
* 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
|
||||
|
@ -227,27 +227,27 @@ SOCK_get_int(SocketClass *self, short len)
|
||||
{
|
||||
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;
|
||||
@ -302,9 +302,9 @@ SOCK_get_next_byte(SocketClass *self)
|
||||
{
|
||||
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);
|
||||
|
@ -181,11 +181,10 @@ SQLFreeStmt(HSTMT hstmt,
|
||||
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)
|
||||
@ -198,9 +197,7 @@ SQLFreeStmt(HSTMT hstmt,
|
||||
}
|
||||
}
|
||||
else if (fOption == SQL_RESET_PARAMS)
|
||||
{
|
||||
SC_free_params(stmt, STMT_FREE_PARAMS_ALL);
|
||||
}
|
||||
else
|
||||
{
|
||||
stmt->errormsg = "Invalid option passed to SQLFreeStmt.";
|
||||
@ -321,8 +318,8 @@ SC_Destructor(StatementClass *self)
|
||||
|
||||
/*
|
||||
* 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)
|
||||
@ -534,8 +531,8 @@ SC_recycle_statement(StatementClass *self)
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
@ -555,7 +552,8 @@ SC_pre_execute(StatementClass *self)
|
||||
|
||||
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;
|
||||
|
||||
@ -657,7 +655,7 @@ SC_get_error(StatementClass *self, int *number, char **message)
|
||||
{
|
||||
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);
|
||||
@ -715,6 +713,7 @@ SC_fetch(StatementClass *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
|
||||
@ -824,13 +823,13 @@ SC_fetch(StatementClass *self)
|
||||
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;
|
||||
|
||||
|
@ -215,8 +215,8 @@ struct StatementClass_
|
||||
* 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)
|
||||
|
@ -137,6 +137,7 @@ TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno)
|
||||
}
|
||||
else if (start_is_closer)
|
||||
{
|
||||
|
||||
/*
|
||||
* the shortest way is to start the search from the head of the
|
||||
* list
|
||||
@ -182,6 +183,7 @@ TL_get_fieldval(TupleListClass *self, Int4 tupleno, Int2 fieldno)
|
||||
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
|
||||
@ -200,6 +202,7 @@ TL_add_tuple(TupleListClass *self, TupleNode *new_field)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* there is already an element in the list, so add the new one at
|
||||
* the end of the list
|
||||
|
Loading…
x
Reference in New Issue
Block a user