Remove // comments from ODBC.
This commit is contained in:
parent
c328e75a6f
commit
ddae527c96
|
@ -34,7 +34,7 @@
|
||||||
#include <sqlext.h>
|
#include <sqlext.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Bind parameters on a statement handle
|
/* Bind parameters on a statement handle */
|
||||||
|
|
||||||
RETCODE SQL_API SQLBindParameter(
|
RETCODE SQL_API SQLBindParameter(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -75,18 +75,18 @@ static char *func="SQLBindParameter";
|
||||||
|
|
||||||
stmt->parameters_allocated = ipar;
|
stmt->parameters_allocated = ipar;
|
||||||
|
|
||||||
// copy the old parameters over
|
/* copy the old parameters over */
|
||||||
for(i = 0; i < old_parameters_allocated; i++) {
|
for(i = 0; i < old_parameters_allocated; i++) {
|
||||||
// a structure copy should work
|
/* a structure copy should work */
|
||||||
stmt->parameters[i] = old_parameters[i];
|
stmt->parameters[i] = old_parameters[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// get rid of the old parameters, if there were any
|
/* get rid of the old parameters, if there were any */
|
||||||
if(old_parameters)
|
if(old_parameters)
|
||||||
free(old_parameters);
|
free(old_parameters);
|
||||||
|
|
||||||
// zero out the newly allocated parameters (in case they skipped some,
|
/* zero out the newly allocated parameters (in case they skipped some, */
|
||||||
// so we don't accidentally try to use them later)
|
/* so we don't accidentally try to use them later) */
|
||||||
for(; i < stmt->parameters_allocated; i++) {
|
for(; i < stmt->parameters_allocated; i++) {
|
||||||
stmt->parameters[i].buflen = 0;
|
stmt->parameters[i].buflen = 0;
|
||||||
stmt->parameters[i].buffer = 0;
|
stmt->parameters[i].buffer = 0;
|
||||||
|
@ -105,7 +105,7 @@ static char *func="SQLBindParameter";
|
||||||
|
|
||||||
ipar--; /* use zero based column numbers for the below part */
|
ipar--; /* use zero based column numbers for the below part */
|
||||||
|
|
||||||
// store the given info
|
/* store the given info */
|
||||||
stmt->parameters[ipar].buflen = cbValueMax;
|
stmt->parameters[ipar].buflen = cbValueMax;
|
||||||
stmt->parameters[ipar].buffer = rgbValue;
|
stmt->parameters[ipar].buffer = rgbValue;
|
||||||
stmt->parameters[ipar].used = pcbValue;
|
stmt->parameters[ipar].used = pcbValue;
|
||||||
|
@ -140,9 +140,9 @@ static char *func="SQLBindParameter";
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
// Associate a user-supplied buffer with a database column.
|
/* Associate a user-supplied buffer with a database column. */
|
||||||
RETCODE SQL_API SQLBindCol(
|
RETCODE SQL_API SQLBindCol(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
UWORD icol,
|
UWORD icol,
|
||||||
|
@ -195,14 +195,14 @@ mylog("**** SQLBindCol: stmt = %u, icol = %d\n", stmt, icol);
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate enough bindings if not already done
|
/* allocate enough bindings if not already done */
|
||||||
// Most likely, execution of a statement would have setup the
|
/* Most likely, execution of a statement would have setup the */
|
||||||
// necessary bindings. But some apps call BindCol before any
|
/* necessary bindings. But some apps call BindCol before any */
|
||||||
// statement is executed.
|
/* statement is executed. */
|
||||||
if ( icol > stmt->bindings_allocated)
|
if ( icol > stmt->bindings_allocated)
|
||||||
extend_bindings(stmt, icol);
|
extend_bindings(stmt, icol);
|
||||||
|
|
||||||
// check to see if the bindings were allocated
|
/* check to see if the bindings were allocated */
|
||||||
if ( ! stmt->bindings) {
|
if ( ! stmt->bindings) {
|
||||||
stmt->errormsg = "Could not allocate memory for bindings.";
|
stmt->errormsg = "Could not allocate memory for bindings.";
|
||||||
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
||||||
|
@ -234,14 +234,14 @@ mylog("**** SQLBindCol: stmt = %u, icol = %d\n", stmt, icol);
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
// Returns the description of a parameter marker.
|
/* Returns the description of a parameter marker. */
|
||||||
// This function is listed as not being supported by SQLGetFunctions() because it is
|
/* This function is listed as not being supported by SQLGetFunctions() because it is */
|
||||||
// used to describe "parameter markers" (not bound parameters), in which case,
|
/* used to describe "parameter markers" (not bound parameters), in which case, */
|
||||||
// the dbms should return info on the markers. Since Postgres doesn't support that,
|
/* the dbms should return info on the markers. Since Postgres doesn't support that, */
|
||||||
// it is best to say this function is not supported and let the application assume a
|
/* it is best to say this function is not supported and let the application assume a */
|
||||||
// data type (most likely varchar).
|
/* data type (most likely varchar). */
|
||||||
|
|
||||||
RETCODE SQL_API SQLDescribeParam(
|
RETCODE SQL_API SQLDescribeParam(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -270,8 +270,8 @@ static char *func = "SQLDescribeParam";
|
||||||
|
|
||||||
ipar--;
|
ipar--;
|
||||||
|
|
||||||
// This implementation is not very good, since it is supposed to describe
|
/* This implementation is not very good, since it is supposed to describe */
|
||||||
// parameter markers, not bound parameters.
|
/* parameter markers, not bound parameters. */
|
||||||
if(pfSqlType)
|
if(pfSqlType)
|
||||||
*pfSqlType = stmt->parameters[ipar].SQLType;
|
*pfSqlType = stmt->parameters[ipar].SQLType;
|
||||||
|
|
||||||
|
@ -287,9 +287,9 @@ static char *func = "SQLDescribeParam";
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
// Sets multiple values (arrays) for the set of parameter markers.
|
/* Sets multiple values (arrays) for the set of parameter markers. */
|
||||||
|
|
||||||
RETCODE SQL_API SQLParamOptions(
|
RETCODE SQL_API SQLParamOptions(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -304,15 +304,15 @@ static char *func = "SQLParamOptions";
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
// This function should really talk to the dbms to determine the number of
|
/* This function should really talk to the dbms to determine the number of */
|
||||||
// "parameter markers" (not bound parameters) in the statement. But, since
|
/* "parameter markers" (not bound parameters) in the statement. But, since */
|
||||||
// Postgres doesn't support that, the driver should just count the number of markers
|
/* Postgres doesn't support that, the driver should just count the number of markers */
|
||||||
// and return that. The reason the driver just can't say this function is unsupported
|
/* and return that. The reason the driver just can't say this function is unsupported */
|
||||||
// like it does for SQLDescribeParam is that some applications don't care and try
|
/* like it does for SQLDescribeParam is that some applications don't care and try */
|
||||||
// to call it anyway.
|
/* to call it anyway. */
|
||||||
// If the statement does not have parameters, it should just return 0.
|
/* If the statement does not have parameters, it should just return 0. */
|
||||||
RETCODE SQL_API SQLNumParams(
|
RETCODE SQL_API SQLNumParams(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
SWORD FAR *pcpar)
|
SWORD FAR *pcpar)
|
||||||
|
@ -338,7 +338,7 @@ static char *func = "SQLNumParams";
|
||||||
|
|
||||||
|
|
||||||
if(!stmt->statement) {
|
if(!stmt->statement) {
|
||||||
// no statement has been allocated
|
/* no statement has been allocated */
|
||||||
stmt->errormsg = "SQLNumParams called with no statement ready.";
|
stmt->errormsg = "SQLNumParams called with no statement ready.";
|
||||||
stmt->errornumber = STMT_SEQUENCE_ERROR;
|
stmt->errornumber = STMT_SEQUENCE_ERROR;
|
||||||
SC_log_error(func, "", stmt);
|
SC_log_error(func, "", stmt);
|
||||||
|
@ -419,13 +419,13 @@ mylog("%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n", func,
|
||||||
stmt->bindings_allocated = num_columns;
|
stmt->bindings_allocated = num_columns;
|
||||||
|
|
||||||
}
|
}
|
||||||
// There is no reason to zero out extra bindings if there are
|
/* There is no reason to zero out extra bindings if there are */
|
||||||
// more than needed. If an app has allocated extra bindings,
|
/* more than needed. If an app has allocated extra bindings, */
|
||||||
// let it worry about it by unbinding those columns.
|
/* let it worry about it by unbinding those columns. */
|
||||||
|
|
||||||
// SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings
|
/* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */
|
||||||
// SQLExecDirect(...) # returns 5 cols
|
/* SQLExecDirect(...) # returns 5 cols */
|
||||||
// SQLExecDirect(...) # returns 10 cols (now OK)
|
/* SQLExecDirect(...) # returns 10 cols (now OK) */
|
||||||
|
|
||||||
mylog("exit extend_bindings\n");
|
mylog("exit extend_bindings\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,12 +144,12 @@ CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
|
||||||
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
|
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
|
||||||
{
|
{
|
||||||
|
|
||||||
// check bounds
|
/* check bounds */
|
||||||
if((field_num < 0) || (field_num >= self->num_fields)) {
|
if((field_num < 0) || (field_num >= self->num_fields)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the info
|
/* store the info */
|
||||||
self->name[field_num] = strdup(new_name);
|
self->name[field_num] = strdup(new_name);
|
||||||
self->adtid[field_num] = new_adtid;
|
self->adtid[field_num] = new_adtid;
|
||||||
self->adtsize[field_num] = new_adtsize;
|
self->adtsize[field_num] = new_adtsize;
|
||||||
|
|
|
@ -70,7 +70,7 @@ static char *func="SQLAllocConnect";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
RETCODE SQL_API SQLConnect(
|
RETCODE SQL_API SQLConnect(
|
||||||
HDBC hdbc,
|
HDBC hdbc,
|
||||||
|
@ -111,7 +111,7 @@ static char *func = "SQLConnect";
|
||||||
qlog("conn = %u, %s(DSN='%s', UID='%s', PWD='%s')\n", conn, func, ci->dsn, ci->username, ci->password);
|
qlog("conn = %u, %s(DSN='%s', UID='%s', PWD='%s')\n", conn, func, ci->dsn, ci->username, ci->password);
|
||||||
|
|
||||||
if ( CC_connect(conn, FALSE) <= 0) {
|
if ( CC_connect(conn, FALSE) <= 0) {
|
||||||
// Error messages are filled in
|
/* Error messages are filled in */
|
||||||
CC_log_error(func, "Error on CC_connect", conn);
|
CC_log_error(func, "Error on CC_connect", conn);
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ static char *func = "SQLConnect";
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
RETCODE SQL_API SQLBrowseConnect(
|
RETCODE SQL_API SQLBrowseConnect(
|
||||||
HDBC hdbc,
|
HDBC hdbc,
|
||||||
|
@ -138,7 +138,7 @@ static char *func="SQLBrowseConnect";
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
/* Drop any hstmts open on hdbc and disconnect from database */
|
/* Drop any hstmts open on hdbc and disconnect from database */
|
||||||
RETCODE SQL_API SQLDisconnect(
|
RETCODE SQL_API SQLDisconnect(
|
||||||
|
@ -176,7 +176,7 @@ static char *func = "SQLDisconnect";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
RETCODE SQL_API SQLFreeConnect(
|
RETCODE SQL_API SQLFreeConnect(
|
||||||
HDBC hdbc)
|
HDBC hdbc)
|
||||||
|
@ -229,7 +229,7 @@ ConnectionClass *rv;
|
||||||
rv->errormsg_created = FALSE;
|
rv->errormsg_created = FALSE;
|
||||||
|
|
||||||
rv->status = CONN_NOT_CONNECTED;
|
rv->status = CONN_NOT_CONNECTED;
|
||||||
rv->transact_status = CONN_IN_AUTOCOMMIT; // autocommit by default
|
rv->transact_status = CONN_IN_AUTOCOMMIT; /* autocommit by default */
|
||||||
|
|
||||||
memset(&rv->connInfo, 0, sizeof(ConnInfo));
|
memset(&rv->connInfo, 0, sizeof(ConnInfo));
|
||||||
|
|
||||||
|
@ -334,8 +334,8 @@ CC_clear_error(ConnectionClass *self)
|
||||||
self->errormsg_created = FALSE;
|
self->errormsg_created = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to cancel a transaction
|
/* Used to cancel a transaction */
|
||||||
// We are almost always in the middle of a transaction.
|
/* We are almost always in the middle of a transaction. */
|
||||||
char
|
char
|
||||||
CC_abort(ConnectionClass *self)
|
CC_abort(ConnectionClass *self)
|
||||||
{
|
{
|
||||||
|
@ -371,9 +371,9 @@ StatementClass *stmt;
|
||||||
|
|
||||||
mylog("in CC_Cleanup, self=%u\n", self);
|
mylog("in CC_Cleanup, self=%u\n", self);
|
||||||
|
|
||||||
// Cancel an ongoing transaction
|
/* Cancel an ongoing transaction */
|
||||||
// We are always in the middle of a transaction,
|
/* We are always in the middle of a transaction, */
|
||||||
// even if we are in auto commit.
|
/* even if we are in auto commit. */
|
||||||
if (self->sock)
|
if (self->sock)
|
||||||
CC_abort(self);
|
CC_abort(self);
|
||||||
|
|
||||||
|
@ -549,7 +549,7 @@ static char *func="CC_connect";
|
||||||
|
|
||||||
mylog("sizeof startup packet = %d\n", sizeof(StartupPacket));
|
mylog("sizeof startup packet = %d\n", sizeof(StartupPacket));
|
||||||
|
|
||||||
// Send length of Authentication Block
|
/* Send length of Authentication Block */
|
||||||
SOCK_put_int(sock, 4+sizeof(StartupPacket), 4);
|
SOCK_put_int(sock, 4+sizeof(StartupPacket), 4);
|
||||||
|
|
||||||
if ( PROTOCOL_63(ci))
|
if ( PROTOCOL_63(ci))
|
||||||
|
@ -579,9 +579,9 @@ static char *func="CC_connect";
|
||||||
mylog("gonna do authentication\n");
|
mylog("gonna do authentication\n");
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************
|
/* *************************************************** */
|
||||||
// Now get the authentication request from backend
|
/* Now get the authentication request from backend */
|
||||||
// ***************************************************
|
/* *************************************************** */
|
||||||
|
|
||||||
if ( ! PROTOCOL_62(ci)) do {
|
if ( ! PROTOCOL_62(ci)) do {
|
||||||
|
|
||||||
|
@ -790,7 +790,7 @@ int rv;
|
||||||
|
|
||||||
mylog("enter CC_get_error\n");
|
mylog("enter CC_get_error\n");
|
||||||
|
|
||||||
// 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) {
|
if ( ! self->errormsg_created) {
|
||||||
self->errormsg = CC_create_errormsg(self);
|
self->errormsg = CC_create_errormsg(self);
|
||||||
self->errormsg_created = TRUE;
|
self->errormsg_created = TRUE;
|
||||||
|
@ -802,7 +802,7 @@ int rv;
|
||||||
}
|
}
|
||||||
rv = (self->errornumber != 0);
|
rv = (self->errornumber != 0);
|
||||||
|
|
||||||
self->errornumber = 0; // clear the error
|
self->errornumber = 0; /* clear the error */
|
||||||
|
|
||||||
mylog("exit CC_get_error\n");
|
mylog("exit CC_get_error\n");
|
||||||
|
|
||||||
|
@ -826,13 +826,13 @@ char swallow;
|
||||||
int id;
|
int id;
|
||||||
SocketClass *sock = self->sock;
|
SocketClass *sock = self->sock;
|
||||||
static char msgbuffer[MAX_MESSAGE_LEN+1];
|
static char msgbuffer[MAX_MESSAGE_LEN+1];
|
||||||
char cmdbuffer[MAX_MESSAGE_LEN+1]; // QR_set_command() dups this string so dont need static
|
char cmdbuffer[MAX_MESSAGE_LEN+1]; /* QR_set_command() dups this string so dont need static */
|
||||||
|
|
||||||
|
|
||||||
mylog("send_query(): conn=%u, query='%s'\n", self, query);
|
mylog("send_query(): conn=%u, query='%s'\n", self, query);
|
||||||
qlog("conn=%u, query='%s'\n", self, query);
|
qlog("conn=%u, query='%s'\n", self, query);
|
||||||
|
|
||||||
// Indicate that we are sending a query to the backend
|
/* Indicate that we are sending a query to the backend */
|
||||||
if(strlen(query) > MAX_MESSAGE_LEN-2) {
|
if(strlen(query) > MAX_MESSAGE_LEN-2) {
|
||||||
self->errornumber = CONNECTION_MSG_TOO_LONG;
|
self->errornumber = CONNECTION_MSG_TOO_LONG;
|
||||||
self->errormsg = "Query string is too long";
|
self->errormsg = "Query string is too long";
|
||||||
|
@ -971,7 +971,7 @@ char cmdbuffer[MAX_MESSAGE_LEN+1]; // QR_set_command() dups this string so dont
|
||||||
mylog("~~~ NOTICE: '%s'\n", cmdbuffer);
|
mylog("~~~ NOTICE: '%s'\n", cmdbuffer);
|
||||||
qlog("NOTICE from backend during send_query: '%s'\n", cmdbuffer);
|
qlog("NOTICE from backend during send_query: '%s'\n", cmdbuffer);
|
||||||
|
|
||||||
continue; // dont return a result -- continue reading
|
continue; /* dont return a result -- continue reading */
|
||||||
|
|
||||||
case 'I' : /* The server sends an empty query */
|
case 'I' : /* The server sends an empty query */
|
||||||
/* There is a closing '\0' following the 'I', so we eat it */
|
/* There is a closing '\0' following the 'I', so we eat it */
|
||||||
|
@ -1034,7 +1034,7 @@ char cmdbuffer[MAX_MESSAGE_LEN+1]; // QR_set_command() dups this string so dont
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // next fetch, so reuse an existing result
|
else { /* next fetch, so reuse an existing result */
|
||||||
if ( ! QR_fetch_tuples(result_in, NULL, NULL)) {
|
if ( ! QR_fetch_tuples(result_in, NULL, NULL)) {
|
||||||
self->errornumber = CONNECTION_COULD_NOT_RECEIVE;
|
self->errornumber = CONNECTION_COULD_NOT_RECEIVE;
|
||||||
self->errormsg = QR_get_message(result_in);
|
self->errormsg = QR_get_message(result_in);
|
||||||
|
@ -1186,7 +1186,7 @@ int i;
|
||||||
mylog("send_function(G): 'N' - %s\n", msgbuffer);
|
mylog("send_function(G): 'N' - %s\n", msgbuffer);
|
||||||
qlog("NOTICE from backend during send_function: '%s'\n", msgbuffer);
|
qlog("NOTICE from backend during send_function: '%s'\n", msgbuffer);
|
||||||
|
|
||||||
continue; // dont return a result -- continue reading
|
continue; /* dont return a result -- continue reading */
|
||||||
|
|
||||||
case '0': /* empty result */
|
case '0': /* empty result */
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1206,9 +1206,9 @@ int i;
|
||||||
char
|
char
|
||||||
CC_send_settings(ConnectionClass *self)
|
CC_send_settings(ConnectionClass *self)
|
||||||
{
|
{
|
||||||
// char ini_query[MAX_MESSAGE_LEN];
|
/* char ini_query[MAX_MESSAGE_LEN]; */
|
||||||
ConnInfo *ci = &(self->connInfo);
|
ConnInfo *ci = &(self->connInfo);
|
||||||
// QResultClass *res;
|
/* QResultClass *res; */
|
||||||
HSTMT hstmt;
|
HSTMT hstmt;
|
||||||
StatementClass *stmt;
|
StatementClass *stmt;
|
||||||
RETCODE result;
|
RETCODE result;
|
||||||
|
|
|
@ -65,66 +65,66 @@ extern GLOBAL_VALUES globals;
|
||||||
* - thomas 2000-04-03
|
* - thomas 2000-04-03
|
||||||
*/
|
*/
|
||||||
char *mapFuncs[][2] = {
|
char *mapFuncs[][2] = {
|
||||||
// { "ASCII", "ascii" },
|
/* { "ASCII", "ascii" }, */
|
||||||
{ "CHAR", "ichar" },
|
{ "CHAR", "ichar" },
|
||||||
{ "CONCAT", "textcat" },
|
{ "CONCAT", "textcat" },
|
||||||
// { "DIFFERENCE", "difference" },
|
/* { "DIFFERENCE", "difference" }, */
|
||||||
// { "INSERT", "insert" },
|
/* { "INSERT", "insert" }, */
|
||||||
{ "LCASE", "lower" },
|
{ "LCASE", "lower" },
|
||||||
{ "LEFT", "ltrunc" },
|
{ "LEFT", "ltrunc" },
|
||||||
{ "LOCATE", "strpos" },
|
{ "LOCATE", "strpos" },
|
||||||
{ "LENGTH", "char_length"},
|
{ "LENGTH", "char_length"},
|
||||||
// { "LTRIM", "ltrim" },
|
/* { "LTRIM", "ltrim" }, */
|
||||||
{ "RIGHT", "rtrunc" },
|
{ "RIGHT", "rtrunc" },
|
||||||
// { "REPEAT", "repeat" },
|
/* { "REPEAT", "repeat" }, */
|
||||||
// { "REPLACE", "replace" },
|
/* { "REPLACE", "replace" }, */
|
||||||
// { "RTRIM", "rtrim" },
|
/* { "RTRIM", "rtrim" }, */
|
||||||
// { "SOUNDEX", "soundex" },
|
/* { "SOUNDEX", "soundex" }, */
|
||||||
{ "SUBSTRING", "substr" },
|
{ "SUBSTRING", "substr" },
|
||||||
{ "UCASE", "upper" },
|
{ "UCASE", "upper" },
|
||||||
|
|
||||||
// { "ABS", "abs" },
|
/* { "ABS", "abs" }, */
|
||||||
// { "ACOS", "acos" },
|
/* { "ACOS", "acos" }, */
|
||||||
// { "ASIN", "asin" },
|
/* { "ASIN", "asin" }, */
|
||||||
// { "ATAN", "atan" },
|
/* { "ATAN", "atan" }, */
|
||||||
// { "ATAN2", "atan2" },
|
/* { "ATAN2", "atan2" }, */
|
||||||
{ "CEILING", "ceil" },
|
{ "CEILING", "ceil" },
|
||||||
// { "COS", "cos" },
|
/* { "COS", "cos" }, */
|
||||||
// { "COT", "cot" },
|
/* { "COT", "cot" }, */
|
||||||
// { "DEGREES", "degrees" },
|
/* { "DEGREES", "degrees" }, */
|
||||||
// { "EXP", "exp" },
|
/* { "EXP", "exp" }, */
|
||||||
// { "FLOOR", "floor" },
|
/* { "FLOOR", "floor" }, */
|
||||||
{ "LOG", "ln" },
|
{ "LOG", "ln" },
|
||||||
{ "LOG10", "log" },
|
{ "LOG10", "log" },
|
||||||
// { "MOD", "mod" },
|
/* { "MOD", "mod" }, */
|
||||||
// { "PI", "pi" },
|
/* { "PI", "pi" }, */
|
||||||
{ "POWER", "pow" },
|
{ "POWER", "pow" },
|
||||||
// { "RADIANS", "radians" },
|
/* { "RADIANS", "radians" }, */
|
||||||
{ "RAND", "random" },
|
{ "RAND", "random" },
|
||||||
// { "ROUND", "round" },
|
/* { "ROUND", "round" }, */
|
||||||
// { "SIGN", "sign" },
|
/* { "SIGN", "sign" }, */
|
||||||
// { "SIN", "sin" },
|
/* { "SIN", "sin" }, */
|
||||||
// { "SQRT", "sqrt" },
|
/* { "SQRT", "sqrt" }, */
|
||||||
// { "TAN", "tan" },
|
/* { "TAN", "tan" }, */
|
||||||
{ "TRUNCATE", "trunc" },
|
{ "TRUNCATE", "trunc" },
|
||||||
|
|
||||||
// { "CURDATE", "curdate" },
|
/* { "CURDATE", "curdate" }, */
|
||||||
// { "CURTIME", "curtime" },
|
/* { "CURTIME", "curtime" }, */
|
||||||
// { "DAYNAME", "dayname" },
|
/* { "DAYNAME", "dayname" }, */
|
||||||
// { "DAYOFMONTH", "dayofmonth" },
|
/* { "DAYOFMONTH", "dayofmonth" }, */
|
||||||
// { "DAYOFWEEK", "dayofweek" },
|
/* { "DAYOFWEEK", "dayofweek" }, */
|
||||||
// { "DAYOFYEAR", "dayofyear" },
|
/* { "DAYOFYEAR", "dayofyear" }, */
|
||||||
// { "HOUR", "hour" },
|
/* { "HOUR", "hour" }, */
|
||||||
// { "MINUTE", "minute" },
|
/* { "MINUTE", "minute" }, */
|
||||||
// { "MONTH", "month" },
|
/* { "MONTH", "month" }, */
|
||||||
// { "MONTHNAME", "monthname" },
|
/* { "MONTHNAME", "monthname" }, */
|
||||||
// { "NOW", "now" },
|
/* { "NOW", "now" }, */
|
||||||
// { "QUARTER", "quarter" },
|
/* { "QUARTER", "quarter" }, */
|
||||||
// { "SECOND", "second" },
|
/* { "SECOND", "second" }, */
|
||||||
// { "WEEK", "week" },
|
/* { "WEEK", "week" }, */
|
||||||
// { "YEAR", "year" },
|
/* { "YEAR", "year" }, */
|
||||||
|
|
||||||
// { "DATABASE", "database" },
|
/* { "DATABASE", "database" }, */
|
||||||
{ "IFNULL", "coalesce" },
|
{ "IFNULL", "coalesce" },
|
||||||
{ "USER", "odbc_user" },
|
{ "USER", "odbc_user" },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
|
@ -270,7 +270,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||||
case PG_TYPE_INT2VECTOR: {
|
case PG_TYPE_INT2VECTOR: {
|
||||||
int nval, i;
|
int nval, i;
|
||||||
char *vp;
|
char *vp;
|
||||||
// this is an array of eight integers
|
/* this is an array of eight integers */
|
||||||
short *short_array = (short *) ( (char *) rgbValue + rgbValueOffset);
|
short *short_array = (short *) ( (char *) rgbValue + rgbValueOffset);
|
||||||
|
|
||||||
len = 16;
|
len = 16;
|
||||||
|
@ -381,7 +381,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||||
and all that stuff since there is essentially no limit on the large
|
and all that stuff since there is essentially no limit on the large
|
||||||
object used to store those.
|
object used to store those.
|
||||||
*/
|
*/
|
||||||
case PG_TYPE_BYTEA: // convert binary data to hex strings (i.e, 255 = "FF")
|
case PG_TYPE_BYTEA: /* convert binary data to hex strings (i.e, 255 = "FF") */
|
||||||
len = convert_pgbinary_to_char(value, rgbValueBindRow, cbValueMax);
|
len = convert_pgbinary_to_char(value, rgbValueBindRow, cbValueMax);
|
||||||
|
|
||||||
/***** THIS IS NOT PROPERLY IMPLEMENTED *****/
|
/***** THIS IS NOT PROPERLY IMPLEMENTED *****/
|
||||||
|
@ -495,7 +495,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||||
} else {
|
} else {
|
||||||
*((UCHAR *)rgbValue + bind_row) = atoi(value);
|
*((UCHAR *)rgbValue + bind_row) = atoi(value);
|
||||||
}
|
}
|
||||||
// mylog("SQL_C_BIT: val = %d, cb = %d, rgb=%d\n", atoi(value), cbValueMax, *((UCHAR *)rgbValue));
|
/* mylog("SQL_C_BIT: val = %d, cb = %d, rgb=%d\n", atoi(value), cbValueMax, *((UCHAR *)rgbValue)); */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SQL_C_STINYINT:
|
case SQL_C_STINYINT:
|
||||||
|
@ -575,8 +575,8 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||||
|
|
||||||
case SQL_C_BINARY:
|
case SQL_C_BINARY:
|
||||||
|
|
||||||
// truncate if necessary
|
/* truncate if necessary */
|
||||||
// convert octal escapes to bytes
|
/* convert octal escapes to bytes */
|
||||||
|
|
||||||
len = convert_from_pgbinary(value, tempBuf, sizeof(tempBuf));
|
len = convert_from_pgbinary(value, tempBuf, sizeof(tempBuf));
|
||||||
ptr = tempBuf;
|
ptr = tempBuf;
|
||||||
|
@ -623,7 +623,7 @@ copy_and_convert_field(StatementClass *stmt, Int4 field_type, void *value, Int2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the length of what was copied, if there's a place for it
|
/* store the length of what was copied, if there's a place for it */
|
||||||
if(pcbValue) {
|
if(pcbValue) {
|
||||||
*(SDWORD *) ((char *)pcbValue + pcbValueOffset) = len;
|
*(SDWORD *) ((char *)pcbValue + pcbValueOffset) = len;
|
||||||
}
|
}
|
||||||
|
@ -674,7 +674,7 @@ int lobj_fd, retval;
|
||||||
if ( stmt->cursor_name[0] == '\0')
|
if ( stmt->cursor_name[0] == '\0')
|
||||||
sprintf(stmt->cursor_name, "SQL_CUR%p", stmt);
|
sprintf(stmt->cursor_name, "SQL_CUR%p", stmt);
|
||||||
|
|
||||||
// For selects, prepend a declare cursor to the statement
|
/* For selects, prepend a declare cursor to the statement */
|
||||||
if (stmt->statement_type == STMT_TYPE_SELECT && globals.use_declarefetch) {
|
if (stmt->statement_type == STMT_TYPE_SELECT && globals.use_declarefetch) {
|
||||||
sprintf(new_statement, "declare %s cursor for ", stmt->cursor_name);
|
sprintf(new_statement, "declare %s cursor for ", stmt->cursor_name);
|
||||||
npos = strlen(new_statement);
|
npos = strlen(new_statement);
|
||||||
|
@ -690,13 +690,13 @@ int lobj_fd, retval;
|
||||||
|
|
||||||
for (opos = 0; opos < oldstmtlen; opos++) {
|
for (opos = 0; opos < oldstmtlen; opos++) {
|
||||||
|
|
||||||
// Squeeze carriage-return/linefeed pairs to linefeed only
|
/* Squeeze carriage-return/linefeed pairs to linefeed only */
|
||||||
if (old_statement[opos] == '\r' && opos+1 < oldstmtlen &&
|
if (old_statement[opos] == '\r' && opos+1 < oldstmtlen &&
|
||||||
old_statement[opos+1] == '\n') {
|
old_statement[opos+1] == '\n') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle literals (date, time, timestamp) and ODBC scalar functions
|
/* Handle literals (date, time, timestamp) and ODBC scalar functions */
|
||||||
else if (old_statement[opos] == '{') {
|
else if (old_statement[opos] == '{') {
|
||||||
char *esc;
|
char *esc;
|
||||||
char *begin = &old_statement[opos + 1];
|
char *begin = &old_statement[opos + 1];
|
||||||
|
@ -779,7 +779,7 @@ int lobj_fd, retval;
|
||||||
|
|
||||||
mylog("copy_statement_with_params: from(fcType)=%d, to(fSqlType)=%d\n", param_ctype, param_sqltype);
|
mylog("copy_statement_with_params: from(fcType)=%d, to(fSqlType)=%d\n", param_ctype, param_sqltype);
|
||||||
|
|
||||||
// replace DEFAULT with something we can use
|
/* replace DEFAULT with something we can use */
|
||||||
if(param_ctype == SQL_C_DEFAULT)
|
if(param_ctype == SQL_C_DEFAULT)
|
||||||
param_ctype = sqltype_to_default_ctype(param_sqltype);
|
param_ctype = sqltype_to_default_ctype(param_sqltype);
|
||||||
|
|
||||||
|
@ -878,10 +878,10 @@ int lobj_fd, retval;
|
||||||
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
// error
|
/* error */
|
||||||
stmt->errormsg = "Unrecognized C_parameter type in copy_statement_with_parameters";
|
stmt->errormsg = "Unrecognized C_parameter type in copy_statement_with_parameters";
|
||||||
stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
|
stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
|
||||||
new_statement[npos] = '\0'; // just in case
|
new_statement[npos] = '\0'; /* just in case */
|
||||||
SC_log_error(func, "", stmt);
|
SC_log_error(func, "", stmt);
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -1062,8 +1062,8 @@ int lobj_fd, retval;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// because of no conversion operator for bool and int4, SQL_BIT
|
/* because of no conversion operator for bool and int4, SQL_BIT */
|
||||||
// must be quoted (0 or 1 is ok to use inside the quotes)
|
/* must be quoted (0 or 1 is ok to use inside the quotes) */
|
||||||
|
|
||||||
default: /* a numeric type or SQL_BIT */
|
default: /* a numeric type or SQL_BIT */
|
||||||
if (param_sqltype == SQL_BIT)
|
if (param_sqltype == SQL_BIT)
|
||||||
|
@ -1087,7 +1087,7 @@ int lobj_fd, retval;
|
||||||
|
|
||||||
} /* end, for */
|
} /* end, for */
|
||||||
|
|
||||||
// make sure new_statement is always null-terminated
|
/* make sure new_statement is always null-terminated */
|
||||||
new_statement[npos] = '\0';
|
new_statement[npos] = '\0';
|
||||||
|
|
||||||
|
|
||||||
|
@ -1194,7 +1194,7 @@ size_t i = 0, out = 0;
|
||||||
|
|
||||||
for (i = 0; i < strlen(s); i++) {
|
for (i = 0; i < strlen(s); i++) {
|
||||||
if (s[i] == '$' || s[i] == ',' || s[i] == ')')
|
if (s[i] == '$' || s[i] == ',' || s[i] == ')')
|
||||||
; // skip these characters
|
; /* skip these characters */
|
||||||
else if (s[i] == '(')
|
else if (s[i] == '(')
|
||||||
s[out++] = '-';
|
s[out++] = '-';
|
||||||
else
|
else
|
||||||
|
@ -1358,7 +1358,7 @@ int i, y=0, val;
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert octal escapes to bytes
|
/* convert octal escapes to bytes */
|
||||||
int
|
int
|
||||||
convert_from_pgbinary(unsigned char *value, unsigned char *rgbValue, int cbValueMax)
|
convert_from_pgbinary(unsigned char *value, unsigned char *rgbValue, int cbValueMax)
|
||||||
{
|
{
|
||||||
|
@ -1378,7 +1378,7 @@ int o=0;
|
||||||
o++;
|
o++;
|
||||||
}
|
}
|
||||||
|
|
||||||
rgbValue[o] = '\0'; // extra protection
|
rgbValue[o] = '\0'; /* extra protection */
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
@ -1402,7 +1402,7 @@ static char x[6];
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert non-ascii bytes to octal escape sequences
|
/* convert non-ascii bytes to octal escape sequences */
|
||||||
int
|
int
|
||||||
convert_to_pgbinary(unsigned char *in, char *out, int len)
|
convert_to_pgbinary(unsigned char *in, char *out, int len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -156,7 +156,7 @@ int CALLBACK driver_optionsProc(HWND hdlg,
|
||||||
|
|
||||||
globals.fetch_max = GetDlgItemInt(hdlg, DRV_CACHE_SIZE, NULL, FALSE);
|
globals.fetch_max = GetDlgItemInt(hdlg, DRV_CACHE_SIZE, NULL, FALSE);
|
||||||
globals.max_varchar_size = GetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, NULL, FALSE);
|
globals.max_varchar_size = GetDlgItemInt(hdlg, DRV_VARCHAR_SIZE, NULL, FALSE);
|
||||||
globals.max_longvarchar_size= GetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, NULL, TRUE); // allows for SQL_NO_TOTAL
|
globals.max_longvarchar_size= GetDlgItemInt(hdlg, DRV_LONGVARCHAR_SIZE, NULL, TRUE); /* allows for SQL_NO_TOTAL */
|
||||||
|
|
||||||
GetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, globals.extra_systable_prefixes, sizeof(globals.extra_systable_prefixes));
|
GetDlgItemText(hdlg, DRV_EXTRASYSTABLEPREFIXES, globals.extra_systable_prefixes, sizeof(globals.extra_systable_prefixes));
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ int CALLBACK driver_optionsProc(HWND hdlg,
|
||||||
|
|
||||||
updateGlobals();
|
updateGlobals();
|
||||||
|
|
||||||
// fall through
|
/* fall through */
|
||||||
|
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
|
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
|
||||||
|
@ -230,7 +230,7 @@ char buf[128];
|
||||||
switch (wMsg) {
|
switch (wMsg) {
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
ci = (ConnInfo *) lParam;
|
ci = (ConnInfo *) lParam;
|
||||||
SetWindowLong(hdlg, DWL_USER, lParam); // save for OK
|
SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK */
|
||||||
|
|
||||||
/* Change window caption */
|
/* Change window caption */
|
||||||
if (ci->driver[0])
|
if (ci->driver[0])
|
||||||
|
@ -301,7 +301,7 @@ char buf[128];
|
||||||
GetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings, sizeof(ci->conn_settings));
|
GetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings, sizeof(ci->conn_settings));
|
||||||
|
|
||||||
|
|
||||||
// fall through
|
/* fall through */
|
||||||
|
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
|
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
|
||||||
|
@ -389,7 +389,7 @@ copyAttributes(ConnInfo *ci, char *attribute, char *value)
|
||||||
|
|
||||||
else if (stricmp(attribute, INI_CONNSETTINGS) == 0) {
|
else if (stricmp(attribute, INI_CONNSETTINGS) == 0) {
|
||||||
decode(value, ci->conn_settings);
|
decode(value, ci->conn_settings);
|
||||||
// strcpy(ci->conn_settings, value);
|
/* strcpy(ci->conn_settings, value); */
|
||||||
}
|
}
|
||||||
|
|
||||||
mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s', conn_settings='%s')\n", ci->dsn, ci->server,ci->database,ci->username,ci->password,ci->port,ci->onlyread,ci->protocol,ci->conn_settings);
|
mylog("copyAttributes: DSN='%s',server='%s',dbase='%s',user='%s',passwd='%s',port='%s',onlyread='%s',protocol='%s', conn_settings='%s')\n", ci->dsn, ci->server,ci->database,ci->username,ci->password,ci->port,ci->onlyread,ci->protocol,ci->conn_settings);
|
||||||
|
@ -428,8 +428,8 @@ getDSNinfo(ConnInfo *ci, char overwrite)
|
||||||
char *DSN = ci->dsn;
|
char *DSN = ci->dsn;
|
||||||
char encoded_conn_settings[LARGE_REGISTRY_LEN];
|
char encoded_conn_settings[LARGE_REGISTRY_LEN];
|
||||||
|
|
||||||
// If a driver keyword was present, then dont use a DSN and return.
|
/* If a driver keyword was present, then dont use a DSN and return. */
|
||||||
// If DSN is null and no driver, then use the default datasource.
|
/* If DSN is null and no driver, then use the default datasource. */
|
||||||
if ( DSN[0] == '\0') {
|
if ( DSN[0] == '\0') {
|
||||||
if ( ci->driver[0] != '\0')
|
if ( ci->driver[0] != '\0')
|
||||||
return;
|
return;
|
||||||
|
@ -437,10 +437,10 @@ char encoded_conn_settings[LARGE_REGISTRY_LEN];
|
||||||
strcpy(DSN, INI_DSN);
|
strcpy(DSN, INI_DSN);
|
||||||
}
|
}
|
||||||
|
|
||||||
// brute-force chop off trailing blanks...
|
/* brute-force chop off trailing blanks... */
|
||||||
while (*(DSN+strlen(DSN)-1) == ' ') *(DSN+strlen(DSN)-1) = '\0';
|
while (*(DSN+strlen(DSN)-1) == ' ') *(DSN+strlen(DSN)-1) = '\0';
|
||||||
|
|
||||||
// Proceed with getting info for the given DSN.
|
/* Proceed with getting info for the given DSN. */
|
||||||
|
|
||||||
if ( ci->desc[0] == '\0' || overwrite)
|
if ( ci->desc[0] == '\0' || overwrite)
|
||||||
SQLGetPrivateProfileString(DSN, INI_KDESC, "", ci->desc, sizeof(ci->desc), ODBC_INI);
|
SQLGetPrivateProfileString(DSN, INI_KDESC, "", ci->desc, sizeof(ci->desc), ODBC_INI);
|
||||||
|
@ -600,7 +600,7 @@ void getGlobalDefaults(char *section, char *filename, char override)
|
||||||
char temp[256];
|
char temp[256];
|
||||||
|
|
||||||
|
|
||||||
// Fetch Count is stored in driver section
|
/* Fetch Count is stored in driver section */
|
||||||
SQLGetPrivateProfileString(section, INI_FETCH, "",
|
SQLGetPrivateProfileString(section, INI_FETCH, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] ) {
|
if ( temp[0] ) {
|
||||||
|
@ -613,7 +613,7 @@ char temp[256];
|
||||||
globals.fetch_max = FETCH_MAX;
|
globals.fetch_max = FETCH_MAX;
|
||||||
|
|
||||||
|
|
||||||
// Socket Buffersize is stored in driver section
|
/* Socket Buffersize is stored in driver section */
|
||||||
SQLGetPrivateProfileString(section, INI_SOCKET, "",
|
SQLGetPrivateProfileString(section, INI_SOCKET, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -622,7 +622,7 @@ char temp[256];
|
||||||
globals.socket_buffersize = SOCK_BUFFER_SIZE;
|
globals.socket_buffersize = SOCK_BUFFER_SIZE;
|
||||||
|
|
||||||
|
|
||||||
// Debug is stored in the driver section
|
/* Debug is stored in the driver section */
|
||||||
SQLGetPrivateProfileString(section, INI_DEBUG, "",
|
SQLGetPrivateProfileString(section, INI_DEBUG, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -631,7 +631,7 @@ char temp[256];
|
||||||
globals.debug = DEFAULT_DEBUG;
|
globals.debug = DEFAULT_DEBUG;
|
||||||
|
|
||||||
|
|
||||||
// CommLog is stored in the driver section
|
/* CommLog is stored in the driver section */
|
||||||
SQLGetPrivateProfileString(section, INI_COMMLOG, "",
|
SQLGetPrivateProfileString(section, INI_COMMLOG, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -640,7 +640,7 @@ char temp[256];
|
||||||
globals.commlog = DEFAULT_COMMLOG;
|
globals.commlog = DEFAULT_COMMLOG;
|
||||||
|
|
||||||
|
|
||||||
// Optimizer is stored in the driver section only
|
/* Optimizer is stored in the driver section only */
|
||||||
SQLGetPrivateProfileString(section, INI_OPTIMIZER, "",
|
SQLGetPrivateProfileString(section, INI_OPTIMIZER, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -648,7 +648,7 @@ char temp[256];
|
||||||
else if ( ! override)
|
else if ( ! override)
|
||||||
globals.disable_optimizer = DEFAULT_OPTIMIZER;
|
globals.disable_optimizer = DEFAULT_OPTIMIZER;
|
||||||
|
|
||||||
// KSQO is stored in the driver section only
|
/* KSQO is stored in the driver section only */
|
||||||
SQLGetPrivateProfileString(section, INI_KSQO, "",
|
SQLGetPrivateProfileString(section, INI_KSQO, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -656,7 +656,7 @@ char temp[256];
|
||||||
else if ( ! override)
|
else if ( ! override)
|
||||||
globals.ksqo = DEFAULT_KSQO;
|
globals.ksqo = DEFAULT_KSQO;
|
||||||
|
|
||||||
// Recognize Unique Index is stored in the driver section only
|
/* Recognize Unique Index is stored in the driver section only */
|
||||||
SQLGetPrivateProfileString(section, INI_UNIQUEINDEX, "",
|
SQLGetPrivateProfileString(section, INI_UNIQUEINDEX, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -665,7 +665,7 @@ char temp[256];
|
||||||
globals.unique_index = DEFAULT_UNIQUEINDEX;
|
globals.unique_index = DEFAULT_UNIQUEINDEX;
|
||||||
|
|
||||||
|
|
||||||
// Unknown Sizes is stored in the driver section only
|
/* Unknown Sizes is stored in the driver section only */
|
||||||
SQLGetPrivateProfileString(section, INI_UNKNOWNSIZES, "",
|
SQLGetPrivateProfileString(section, INI_UNKNOWNSIZES, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -674,7 +674,7 @@ char temp[256];
|
||||||
globals.unknown_sizes = DEFAULT_UNKNOWNSIZES;
|
globals.unknown_sizes = DEFAULT_UNKNOWNSIZES;
|
||||||
|
|
||||||
|
|
||||||
// Lie about supported functions?
|
/* Lie about supported functions? */
|
||||||
SQLGetPrivateProfileString(section, INI_LIE, "",
|
SQLGetPrivateProfileString(section, INI_LIE, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -682,7 +682,7 @@ char temp[256];
|
||||||
else if ( ! override)
|
else if ( ! override)
|
||||||
globals.lie = DEFAULT_LIE;
|
globals.lie = DEFAULT_LIE;
|
||||||
|
|
||||||
// Parse statements
|
/* Parse statements */
|
||||||
SQLGetPrivateProfileString(section, INI_PARSE, "",
|
SQLGetPrivateProfileString(section, INI_PARSE, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -690,7 +690,7 @@ char temp[256];
|
||||||
else if ( ! override)
|
else if ( ! override)
|
||||||
globals.parse = DEFAULT_PARSE;
|
globals.parse = DEFAULT_PARSE;
|
||||||
|
|
||||||
// SQLCancel calls SQLFreeStmt in Driver Manager
|
/* SQLCancel calls SQLFreeStmt in Driver Manager */
|
||||||
SQLGetPrivateProfileString(section, INI_CANCELASFREESTMT, "",
|
SQLGetPrivateProfileString(section, INI_CANCELASFREESTMT, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -700,7 +700,7 @@ char temp[256];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// UseDeclareFetch is stored in the driver section only
|
/* UseDeclareFetch is stored in the driver section only */
|
||||||
SQLGetPrivateProfileString(section, INI_USEDECLAREFETCH, "",
|
SQLGetPrivateProfileString(section, INI_USEDECLAREFETCH, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -709,7 +709,7 @@ char temp[256];
|
||||||
globals.use_declarefetch = DEFAULT_USEDECLAREFETCH;
|
globals.use_declarefetch = DEFAULT_USEDECLAREFETCH;
|
||||||
|
|
||||||
|
|
||||||
// Max Varchar Size
|
/* Max Varchar Size */
|
||||||
SQLGetPrivateProfileString(section, INI_MAXVARCHARSIZE, "",
|
SQLGetPrivateProfileString(section, INI_MAXVARCHARSIZE, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -717,7 +717,7 @@ char temp[256];
|
||||||
else if ( ! override)
|
else if ( ! override)
|
||||||
globals.max_varchar_size = MAX_VARCHAR_SIZE;
|
globals.max_varchar_size = MAX_VARCHAR_SIZE;
|
||||||
|
|
||||||
// Max TextField Size
|
/* Max TextField Size */
|
||||||
SQLGetPrivateProfileString(section, INI_MAXLONGVARCHARSIZE, "",
|
SQLGetPrivateProfileString(section, INI_MAXLONGVARCHARSIZE, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -725,7 +725,7 @@ char temp[256];
|
||||||
else if ( ! override)
|
else if ( ! override)
|
||||||
globals.max_longvarchar_size = TEXT_FIELD_SIZE;
|
globals.max_longvarchar_size = TEXT_FIELD_SIZE;
|
||||||
|
|
||||||
// Text As LongVarchar
|
/* Text As LongVarchar */
|
||||||
SQLGetPrivateProfileString(section, INI_TEXTASLONGVARCHAR, "",
|
SQLGetPrivateProfileString(section, INI_TEXTASLONGVARCHAR, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -733,7 +733,7 @@ char temp[256];
|
||||||
else if ( ! override)
|
else if ( ! override)
|
||||||
globals.text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR;
|
globals.text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR;
|
||||||
|
|
||||||
// Unknowns As LongVarchar
|
/* Unknowns As LongVarchar */
|
||||||
SQLGetPrivateProfileString(section, INI_UNKNOWNSASLONGVARCHAR, "",
|
SQLGetPrivateProfileString(section, INI_UNKNOWNSASLONGVARCHAR, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -741,7 +741,7 @@ char temp[256];
|
||||||
else if ( ! override)
|
else if ( ! override)
|
||||||
globals.unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR;
|
globals.unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR;
|
||||||
|
|
||||||
// Bools As Char
|
/* Bools As Char */
|
||||||
SQLGetPrivateProfileString(section, INI_BOOLSASCHAR, "",
|
SQLGetPrivateProfileString(section, INI_BOOLSASCHAR, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
@ -749,8 +749,8 @@ char temp[256];
|
||||||
else if ( ! override)
|
else if ( ! override)
|
||||||
globals.bools_as_char = DEFAULT_BOOLSASCHAR;
|
globals.bools_as_char = DEFAULT_BOOLSASCHAR;
|
||||||
|
|
||||||
// Extra Systable prefixes
|
/* Extra Systable prefixes */
|
||||||
// Use @@@ to distinguish between blank extra prefixes and no key entry
|
/* Use @@@ to distinguish between blank extra prefixes and no key entry */
|
||||||
SQLGetPrivateProfileString(section, INI_EXTRASYSTABLEPREFIXES, "@@@",
|
SQLGetPrivateProfileString(section, INI_EXTRASYSTABLEPREFIXES, "@@@",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( strcmp(temp, "@@@" ))
|
if ( strcmp(temp, "@@@" ))
|
||||||
|
@ -761,14 +761,14 @@ char temp[256];
|
||||||
mylog("globals.extra_systable_prefixes = '%s'\n", globals.extra_systable_prefixes);
|
mylog("globals.extra_systable_prefixes = '%s'\n", globals.extra_systable_prefixes);
|
||||||
|
|
||||||
|
|
||||||
// Dont allow override of an override!
|
/* Dont allow override of an override! */
|
||||||
if ( ! override) {
|
if ( ! override) {
|
||||||
|
|
||||||
// ConnSettings is stored in the driver section and per datasource for override
|
/* ConnSettings is stored in the driver section and per datasource for override */
|
||||||
SQLGetPrivateProfileString(section, INI_CONNSETTINGS, "",
|
SQLGetPrivateProfileString(section, INI_CONNSETTINGS, "",
|
||||||
globals.conn_settings, sizeof(globals.conn_settings), filename);
|
globals.conn_settings, sizeof(globals.conn_settings), filename);
|
||||||
|
|
||||||
// Default state for future DSN's Readonly attribute
|
/* Default state for future DSN's Readonly attribute */
|
||||||
SQLGetPrivateProfileString(section, INI_READONLY, "",
|
SQLGetPrivateProfileString(section, INI_READONLY, "",
|
||||||
temp, sizeof(temp), filename);
|
temp, sizeof(temp), filename);
|
||||||
if ( temp[0] )
|
if ( temp[0] )
|
||||||
|
|
|
@ -91,15 +91,15 @@
|
||||||
/* Connection Defaults */
|
/* Connection Defaults */
|
||||||
#define DEFAULT_PORT "5432"
|
#define DEFAULT_PORT "5432"
|
||||||
#define DEFAULT_READONLY 1
|
#define DEFAULT_READONLY 1
|
||||||
#define DEFAULT_PROTOCOL "6.4" // the latest protocol is the default
|
#define DEFAULT_PROTOCOL "6.4" /* the latest protocol is the default */
|
||||||
#define DEFAULT_USEDECLAREFETCH 0
|
#define DEFAULT_USEDECLAREFETCH 0
|
||||||
#define DEFAULT_TEXTASLONGVARCHAR 1
|
#define DEFAULT_TEXTASLONGVARCHAR 1
|
||||||
#define DEFAULT_UNKNOWNSASLONGVARCHAR 0
|
#define DEFAULT_UNKNOWNSASLONGVARCHAR 0
|
||||||
#define DEFAULT_BOOLSASCHAR 1
|
#define DEFAULT_BOOLSASCHAR 1
|
||||||
#define DEFAULT_OPTIMIZER 1 // disable
|
#define DEFAULT_OPTIMIZER 1 /* disable */
|
||||||
#define DEFAULT_KSQO 1 // on
|
#define DEFAULT_KSQO 1 /* on */
|
||||||
#define DEFAULT_UNIQUEINDEX 0 // dont recognize
|
#define DEFAULT_UNIQUEINDEX 0 /* dont recognize */
|
||||||
#define DEFAULT_COMMLOG 0 // dont log
|
#define DEFAULT_COMMLOG 0 /* dont log */
|
||||||
#define DEFAULT_DEBUG 0
|
#define DEFAULT_DEBUG 0
|
||||||
#define DEFAULT_UNKNOWNSIZES UNKNOWNS_AS_MAX
|
#define DEFAULT_UNKNOWNSIZES UNKNOWNS_AS_MAX
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
#define DEFAULT_FAKEOIDINDEX 0
|
#define DEFAULT_FAKEOIDINDEX 0
|
||||||
#define DEFAULT_SHOWOIDCOLUMN 0
|
#define DEFAULT_SHOWOIDCOLUMN 0
|
||||||
#define DEFAULT_ROWVERSIONING 0
|
#define DEFAULT_ROWVERSIONING 0
|
||||||
#define DEFAULT_SHOWSYSTEMTABLES 0 // dont show system tables
|
#define DEFAULT_SHOWSYSTEMTABLES 0 /* dont show system tables */
|
||||||
#define DEFAULT_LIE 0
|
#define DEFAULT_LIE 0
|
||||||
#define DEFAULT_PARSE 0
|
#define DEFAULT_PARSE 0
|
||||||
|
|
||||||
|
|
|
@ -103,15 +103,15 @@ int len = 0;
|
||||||
|
|
||||||
ci = &(conn->connInfo);
|
ci = &(conn->connInfo);
|
||||||
|
|
||||||
// Parse the connect string and fill in conninfo for this hdbc.
|
/* Parse the connect string and fill in conninfo for this hdbc. */
|
||||||
dconn_get_connect_attributes(connStrIn, ci);
|
dconn_get_connect_attributes(connStrIn, ci);
|
||||||
|
|
||||||
// If the ConnInfo in the hdbc is missing anything,
|
/* If the ConnInfo in the hdbc is missing anything, */
|
||||||
// this function will fill them in from the registry (assuming
|
/* this function will fill them in from the registry (assuming */
|
||||||
// of course there is a DSN given -- if not, it does nothing!)
|
/* of course there is a DSN given -- if not, it does nothing!) */
|
||||||
getDSNinfo(ci, CONN_DONT_OVERWRITE);
|
getDSNinfo(ci, CONN_DONT_OVERWRITE);
|
||||||
|
|
||||||
// Fill in any default parameters if they are not there.
|
/* Fill in any default parameters if they are not there. */
|
||||||
getDSNdefaults(ci);
|
getDSNdefaults(ci);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
@ -164,13 +164,13 @@ dialog:
|
||||||
ci->server[0] == '\0' ||
|
ci->server[0] == '\0' ||
|
||||||
ci->database[0] == '\0' ||
|
ci->database[0] == '\0' ||
|
||||||
ci->port[0] == '\0') {
|
ci->port[0] == '\0') {
|
||||||
// (password_required && ci->password[0] == '\0'))
|
/* (password_required && ci->password[0] == '\0')) */
|
||||||
|
|
||||||
return SQL_NO_DATA_FOUND;
|
return SQL_NO_DATA_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// do the actual connect
|
/* do the actual connect */
|
||||||
retval = CC_connect(conn, password_required);
|
retval = CC_connect(conn, password_required);
|
||||||
if (retval < 0) { /* need a password */
|
if (retval < 0) { /* need a password */
|
||||||
if (fDriverCompletion == SQL_DRIVER_NOPROMPT) {
|
if (fDriverCompletion == SQL_DRIVER_NOPROMPT) {
|
||||||
|
@ -187,7 +187,7 @@ dialog:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (retval == 0) {
|
else if (retval == 0) {
|
||||||
// error msg filled in above
|
/* error msg filled in above */
|
||||||
CC_log_error(func, "Error from CC_Connect", conn);
|
CC_log_error(func, "Error from CC_Connect", conn);
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ ConnInfo *ci;
|
||||||
ShowWindow(GetDlgItem(hdlg, IDC_DESCTEXT), SW_HIDE);
|
ShowWindow(GetDlgItem(hdlg, IDC_DESCTEXT), SW_HIDE);
|
||||||
ShowWindow(GetDlgItem(hdlg, IDC_DESC), SW_HIDE);
|
ShowWindow(GetDlgItem(hdlg, IDC_DESC), SW_HIDE);
|
||||||
|
|
||||||
SetWindowLong(hdlg, DWL_USER, lParam);// Save the ConnInfo for the "OK"
|
SetWindowLong(hdlg, DWL_USER, lParam);/* Save the ConnInfo for the "OK" */
|
||||||
|
|
||||||
SetDlgStuff(hdlg, ci);
|
SetDlgStuff(hdlg, ci);
|
||||||
|
|
||||||
|
@ -354,15 +354,15 @@ char *strtok_arg;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
*equals = '\0';
|
*equals = '\0';
|
||||||
attribute = pair; // ex. DSN
|
attribute = pair; /* ex. DSN */
|
||||||
value = equals + 1; // ex. 'CEO co1'
|
value = equals + 1; /* ex. 'CEO co1' */
|
||||||
|
|
||||||
mylog("attribute = '%s', value = '%s'\n", attribute, value);
|
mylog("attribute = '%s', value = '%s'\n", attribute, value);
|
||||||
|
|
||||||
if( !attribute || !value)
|
if( !attribute || !value)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Copy the appropriate value to the conninfo
|
/* Copy the appropriate value to the conninfo */
|
||||||
copyAttributes(ci, attribute, value);
|
copyAttributes(ci, attribute, value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ mylog("**** in SQLFreeEnv: env = %u ** \n", env);
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the next SQL error information.
|
/* Returns the next SQL error information. */
|
||||||
|
|
||||||
RETCODE SQL_API SQLError(
|
RETCODE SQL_API SQLError(
|
||||||
HENV henv,
|
HENV henv,
|
||||||
|
@ -75,7 +75,7 @@ int status;
|
||||||
mylog("**** SQLError: henv=%u, hdbc=%u, hstmt=%u\n", henv, hdbc, hstmt);
|
mylog("**** SQLError: henv=%u, hdbc=%u, hstmt=%u\n", henv, hdbc, hstmt);
|
||||||
|
|
||||||
if (SQL_NULL_HSTMT != hstmt) {
|
if (SQL_NULL_HSTMT != hstmt) {
|
||||||
// CC: return an error of a hstmt
|
/* CC: return an error of a hstmt */
|
||||||
StatementClass *stmt = (StatementClass *) hstmt;
|
StatementClass *stmt = (StatementClass *) hstmt;
|
||||||
|
|
||||||
if (SC_get_error(stmt, &status, &msg)) {
|
if (SC_get_error(stmt, &status, &msg)) {
|
||||||
|
@ -102,47 +102,47 @@ int status;
|
||||||
if (NULL != szSqlState)
|
if (NULL != szSqlState)
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
// now determine the SQLSTATE to be returned
|
/* now determine the SQLSTATE to be returned */
|
||||||
case STMT_TRUNCATED:
|
case STMT_TRUNCATED:
|
||||||
strcpy(szSqlState, "01004");
|
strcpy(szSqlState, "01004");
|
||||||
// data truncated
|
/* data truncated */
|
||||||
break;
|
break;
|
||||||
case STMT_INFO_ONLY:
|
case STMT_INFO_ONLY:
|
||||||
strcpy(szSqlState, "00000");
|
strcpy(szSqlState, "00000");
|
||||||
// just information that is returned, no error
|
/* just information that is returned, no error */
|
||||||
break;
|
break;
|
||||||
case STMT_BAD_ERROR:
|
case STMT_BAD_ERROR:
|
||||||
strcpy(szSqlState, "08S01");
|
strcpy(szSqlState, "08S01");
|
||||||
// communication link failure
|
/* communication link failure */
|
||||||
break;
|
break;
|
||||||
case STMT_CREATE_TABLE_ERROR:
|
case STMT_CREATE_TABLE_ERROR:
|
||||||
strcpy(szSqlState, "S0001");
|
strcpy(szSqlState, "S0001");
|
||||||
// table already exists
|
/* table already exists */
|
||||||
break;
|
break;
|
||||||
case STMT_STATUS_ERROR:
|
case STMT_STATUS_ERROR:
|
||||||
case STMT_SEQUENCE_ERROR:
|
case STMT_SEQUENCE_ERROR:
|
||||||
strcpy(szSqlState, "S1010");
|
strcpy(szSqlState, "S1010");
|
||||||
// Function sequence error
|
/* Function sequence error */
|
||||||
break;
|
break;
|
||||||
case STMT_NO_MEMORY_ERROR:
|
case STMT_NO_MEMORY_ERROR:
|
||||||
strcpy(szSqlState, "S1001");
|
strcpy(szSqlState, "S1001");
|
||||||
// memory allocation failure
|
/* memory allocation failure */
|
||||||
break;
|
break;
|
||||||
case STMT_COLNUM_ERROR:
|
case STMT_COLNUM_ERROR:
|
||||||
strcpy(szSqlState, "S1002");
|
strcpy(szSqlState, "S1002");
|
||||||
// invalid column number
|
/* invalid column number */
|
||||||
break;
|
break;
|
||||||
case STMT_NO_STMTSTRING:
|
case STMT_NO_STMTSTRING:
|
||||||
strcpy(szSqlState, "S1001");
|
strcpy(szSqlState, "S1001");
|
||||||
// having no stmtstring is also a malloc problem
|
/* having no stmtstring is also a malloc problem */
|
||||||
break;
|
break;
|
||||||
case STMT_ERROR_TAKEN_FROM_BACKEND:
|
case STMT_ERROR_TAKEN_FROM_BACKEND:
|
||||||
strcpy(szSqlState, "S1000");
|
strcpy(szSqlState, "S1000");
|
||||||
// general error
|
/* general error */
|
||||||
break;
|
break;
|
||||||
case STMT_INTERNAL_ERROR:
|
case STMT_INTERNAL_ERROR:
|
||||||
strcpy(szSqlState, "S1000");
|
strcpy(szSqlState, "S1000");
|
||||||
// general error
|
/* general error */
|
||||||
break;
|
break;
|
||||||
case STMT_ROW_OUT_OF_RANGE:
|
case STMT_ROW_OUT_OF_RANGE:
|
||||||
strcpy(szSqlState, "S1107");
|
strcpy(szSqlState, "S1107");
|
||||||
|
@ -153,7 +153,7 @@ int status;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STMT_NOT_IMPLEMENTED_ERROR:
|
case STMT_NOT_IMPLEMENTED_ERROR:
|
||||||
strcpy(szSqlState, "S1C00"); // == 'driver not capable'
|
strcpy(szSqlState, "S1C00"); /* == 'driver not capable' */
|
||||||
break;
|
break;
|
||||||
case STMT_OPTION_OUT_OF_RANGE_ERROR:
|
case STMT_OPTION_OUT_OF_RANGE_ERROR:
|
||||||
strcpy(szSqlState, "S1092");
|
strcpy(szSqlState, "S1092");
|
||||||
|
@ -181,7 +181,7 @@ int status;
|
||||||
break;
|
break;
|
||||||
case STMT_INVALID_ARGUMENT_NO:
|
case STMT_INVALID_ARGUMENT_NO:
|
||||||
strcpy(szSqlState, "S1009");
|
strcpy(szSqlState, "S1009");
|
||||||
// invalid argument value
|
/* invalid argument value */
|
||||||
break;
|
break;
|
||||||
case STMT_INVALID_CURSOR_POSITION:
|
case STMT_INVALID_CURSOR_POSITION:
|
||||||
strcpy(szSqlState, "S1109");
|
strcpy(szSqlState, "S1109");
|
||||||
|
@ -198,7 +198,7 @@ int status;
|
||||||
case STMT_EXEC_ERROR:
|
case STMT_EXEC_ERROR:
|
||||||
default:
|
default:
|
||||||
strcpy(szSqlState, "S1000");
|
strcpy(szSqlState, "S1000");
|
||||||
// also a general error
|
/* also a general error */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,15 +250,15 @@ int status;
|
||||||
case STMT_TRUNCATED:
|
case STMT_TRUNCATED:
|
||||||
case CONN_TRUNCATED:
|
case CONN_TRUNCATED:
|
||||||
strcpy(szSqlState, "01004");
|
strcpy(szSqlState, "01004");
|
||||||
// data truncated
|
/* data truncated */
|
||||||
break;
|
break;
|
||||||
case CONN_INIREAD_ERROR:
|
case CONN_INIREAD_ERROR:
|
||||||
strcpy(szSqlState, "IM002");
|
strcpy(szSqlState, "IM002");
|
||||||
// data source not found
|
/* data source not found */
|
||||||
break;
|
break;
|
||||||
case CONN_OPENDB_ERROR:
|
case CONN_OPENDB_ERROR:
|
||||||
strcpy(szSqlState, "08001");
|
strcpy(szSqlState, "08001");
|
||||||
// unable to connect to data source
|
/* unable to connect to data source */
|
||||||
break;
|
break;
|
||||||
case CONN_INVALID_AUTHENTICATION:
|
case CONN_INVALID_AUTHENTICATION:
|
||||||
case CONN_AUTH_TYPE_UNSUPPORTED:
|
case CONN_AUTH_TYPE_UNSUPPORTED:
|
||||||
|
@ -266,23 +266,23 @@ int status;
|
||||||
break;
|
break;
|
||||||
case CONN_STMT_ALLOC_ERROR:
|
case CONN_STMT_ALLOC_ERROR:
|
||||||
strcpy(szSqlState, "S1001");
|
strcpy(szSqlState, "S1001");
|
||||||
// memory allocation failure
|
/* memory allocation failure */
|
||||||
break;
|
break;
|
||||||
case CONN_IN_USE:
|
case CONN_IN_USE:
|
||||||
strcpy(szSqlState, "S1000");
|
strcpy(szSqlState, "S1000");
|
||||||
// general error
|
/* general error */
|
||||||
break;
|
break;
|
||||||
case CONN_UNSUPPORTED_OPTION:
|
case CONN_UNSUPPORTED_OPTION:
|
||||||
strcpy(szSqlState, "IM001");
|
strcpy(szSqlState, "IM001");
|
||||||
// driver does not support this function
|
/* driver does not support this function */
|
||||||
case CONN_INVALID_ARGUMENT_NO:
|
case CONN_INVALID_ARGUMENT_NO:
|
||||||
strcpy(szSqlState, "S1009");
|
strcpy(szSqlState, "S1009");
|
||||||
// invalid argument value
|
/* invalid argument value */
|
||||||
break;
|
break;
|
||||||
case CONN_TRANSACT_IN_PROGRES:
|
case CONN_TRANSACT_IN_PROGRES:
|
||||||
strcpy(szSqlState, "S1010");
|
strcpy(szSqlState, "S1010");
|
||||||
// when the user tries to switch commit mode in a transaction
|
/* when the user tries to switch commit mode in a transaction */
|
||||||
// -> function sequence error
|
/* -> function sequence error */
|
||||||
break;
|
break;
|
||||||
case CONN_NO_MEMORY_ERROR:
|
case CONN_NO_MEMORY_ERROR:
|
||||||
strcpy(szSqlState, "S1001");
|
strcpy(szSqlState, "S1001");
|
||||||
|
@ -299,7 +299,7 @@ int status;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
strcpy(szSqlState, "S1000");
|
strcpy(szSqlState, "S1000");
|
||||||
// general error
|
/* general error */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,12 +341,12 @@ int status;
|
||||||
if(szSqlState) {
|
if(szSqlState) {
|
||||||
switch(status) {
|
switch(status) {
|
||||||
case ENV_ALLOC_ERROR:
|
case ENV_ALLOC_ERROR:
|
||||||
// memory allocation failure
|
/* memory allocation failure */
|
||||||
strcpy(szSqlState, "S1001");
|
strcpy(szSqlState, "S1001");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strcpy(szSqlState, "S1000");
|
strcpy(szSqlState, "S1000");
|
||||||
// general error
|
/* general error */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,8 +405,8 @@ char rv = 1;
|
||||||
|
|
||||||
mylog("in EN_Destructor, self=%u\n", self);
|
mylog("in EN_Destructor, self=%u\n", self);
|
||||||
|
|
||||||
// the error messages are static strings distributed throughout
|
/* the error messages are static strings distributed throughout */
|
||||||
// the source--they should not be freed
|
/* the source--they should not be freed */
|
||||||
|
|
||||||
/* Free any connections belonging to this environment */
|
/* Free any connections belonging to this environment */
|
||||||
for (lf = 0; lf < MAX_CONNECTIONS; lf++) {
|
for (lf = 0; lf < MAX_CONNECTIONS; lf++) {
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
extern GLOBAL_VALUES globals;
|
extern GLOBAL_VALUES globals;
|
||||||
|
|
||||||
|
|
||||||
// Perform a Prepare on the SQL statement
|
/* Perform a Prepare on the SQL statement */
|
||||||
RETCODE SQL_API SQLPrepare(HSTMT hstmt,
|
RETCODE SQL_API SQLPrepare(HSTMT hstmt,
|
||||||
UCHAR FAR *szSqlStr,
|
UCHAR FAR *szSqlStr,
|
||||||
SDWORD cbSqlStr)
|
SDWORD cbSqlStr)
|
||||||
|
@ -108,7 +108,7 @@ StatementClass *self = (StatementClass *) hstmt;
|
||||||
self->prepare = TRUE;
|
self->prepare = TRUE;
|
||||||
self->statement_type = statement_type(self->statement);
|
self->statement_type = statement_type(self->statement);
|
||||||
|
|
||||||
// Check if connection is onlyread (only selects are allowed)
|
/* Check if connection is onlyread (only selects are allowed) */
|
||||||
if ( CC_is_onlyread(self->hdbc) && STMT_UPDATE(self)) {
|
if ( CC_is_onlyread(self->hdbc) && STMT_UPDATE(self)) {
|
||||||
self->errornumber = STMT_EXEC_ERROR;
|
self->errornumber = STMT_EXEC_ERROR;
|
||||||
self->errormsg = "Connection is readonly, only select statements are allowed.";
|
self->errormsg = "Connection is readonly, only select statements are allowed.";
|
||||||
|
@ -121,9 +121,9 @@ StatementClass *self = (StatementClass *) hstmt;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
// Performs the equivalent of SQLPrepare, followed by SQLExecute.
|
/* Performs the equivalent of SQLPrepare, followed by SQLExecute. */
|
||||||
|
|
||||||
RETCODE SQL_API SQLExecDirect(
|
RETCODE SQL_API SQLExecDirect(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -144,8 +144,8 @@ static char *func = "SQLExecDirect";
|
||||||
if (stmt->statement)
|
if (stmt->statement)
|
||||||
free(stmt->statement);
|
free(stmt->statement);
|
||||||
|
|
||||||
// keep a copy of the un-parametrized statement, in case
|
/* keep a copy of the un-parametrized statement, in case */
|
||||||
// they try to execute this statement again
|
/* they try to execute this statement again */
|
||||||
stmt->statement = make_string(szSqlStr, cbSqlStr, NULL);
|
stmt->statement = make_string(szSqlStr, cbSqlStr, NULL);
|
||||||
if ( ! stmt->statement) {
|
if ( ! stmt->statement) {
|
||||||
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
stmt->errornumber = STMT_NO_MEMORY_ERROR;
|
||||||
|
@ -158,15 +158,15 @@ static char *func = "SQLExecDirect";
|
||||||
|
|
||||||
stmt->prepare = FALSE;
|
stmt->prepare = FALSE;
|
||||||
|
|
||||||
// If an SQLPrepare was performed prior to this, but was left in
|
/* If an SQLPrepare was performed prior to this, but was left in */
|
||||||
// the premature state because an error occurred prior to SQLExecute
|
/* the premature state because an error occurred prior to SQLExecute */
|
||||||
// then set the statement to finished so it can be recycled.
|
/* then set the statement to finished so it can be recycled. */
|
||||||
if ( stmt->status == STMT_PREMATURE )
|
if ( stmt->status == STMT_PREMATURE )
|
||||||
stmt->status = STMT_FINISHED;
|
stmt->status = STMT_FINISHED;
|
||||||
|
|
||||||
stmt->statement_type = statement_type(stmt->statement);
|
stmt->statement_type = statement_type(stmt->statement);
|
||||||
|
|
||||||
// Check if connection is onlyread (only selects are allowed)
|
/* Check if connection is onlyread (only selects are allowed) */
|
||||||
if ( CC_is_onlyread(stmt->hdbc) && STMT_UPDATE(stmt)) {
|
if ( CC_is_onlyread(stmt->hdbc) && STMT_UPDATE(stmt)) {
|
||||||
stmt->errornumber = STMT_EXEC_ERROR;
|
stmt->errornumber = STMT_EXEC_ERROR;
|
||||||
stmt->errormsg = "Connection is readonly, only select statements are allowed.";
|
stmt->errormsg = "Connection is readonly, only select statements are allowed.";
|
||||||
|
@ -182,7 +182,7 @@ static char *func = "SQLExecDirect";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute a prepared SQL statement
|
/* Execute a prepared SQL statement */
|
||||||
RETCODE SQL_API SQLExecute(
|
RETCODE SQL_API SQLExecute(
|
||||||
HSTMT hstmt)
|
HSTMT hstmt)
|
||||||
{
|
{
|
||||||
|
@ -272,15 +272,15 @@ int i, retval;
|
||||||
stmt->data_at_exec++;
|
stmt->data_at_exec++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If there are some data at execution parameters, return need data
|
/* If there are some data at execution parameters, return need data */
|
||||||
// SQLParamData and SQLPutData will be used to send params and execute the statement.
|
/* SQLParamData and SQLPutData will be used to send params and execute the statement. */
|
||||||
if (stmt->data_at_exec > 0)
|
if (stmt->data_at_exec > 0)
|
||||||
return SQL_NEED_DATA;
|
return SQL_NEED_DATA;
|
||||||
|
|
||||||
|
|
||||||
mylog("%s: copying statement params: trans_status=%d, len=%d, stmt='%s'\n", func, conn->transact_status, strlen(stmt->statement), stmt->statement);
|
mylog("%s: copying statement params: trans_status=%d, len=%d, stmt='%s'\n", func, conn->transact_status, strlen(stmt->statement), stmt->statement);
|
||||||
|
|
||||||
// Create the statement with parameters substituted.
|
/* Create the statement with parameters substituted. */
|
||||||
retval = copy_statement_with_parameters(stmt);
|
retval = copy_statement_with_parameters(stmt);
|
||||||
if( retval != SQL_SUCCESS)
|
if( retval != SQL_SUCCESS)
|
||||||
/* error msg passed from above */
|
/* error msg passed from above */
|
||||||
|
@ -296,7 +296,7 @@ int i, retval;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
RETCODE SQL_API SQLTransact(
|
RETCODE SQL_API SQLTransact(
|
||||||
HENV henv,
|
HENV henv,
|
||||||
HDBC hdbc,
|
HDBC hdbc,
|
||||||
|
@ -355,7 +355,7 @@ int lf;
|
||||||
CC_set_no_trans(conn);
|
CC_set_no_trans(conn);
|
||||||
|
|
||||||
if ( ! res) {
|
if ( ! res) {
|
||||||
// error msg will be in the connection
|
/* error msg will be in the connection */
|
||||||
CC_log_error(func, "", conn);
|
CC_log_error(func, "", conn);
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -371,10 +371,10 @@ int lf;
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
RETCODE SQL_API SQLCancel(
|
RETCODE SQL_API SQLCancel(
|
||||||
HSTMT hstmt) // Statement to cancel.
|
HSTMT hstmt) /* Statement to cancel. */
|
||||||
{
|
{
|
||||||
static char *func="SQLCancel";
|
static char *func="SQLCancel";
|
||||||
StatementClass *stmt = (StatementClass *) hstmt;
|
StatementClass *stmt = (StatementClass *) hstmt;
|
||||||
|
@ -386,13 +386,13 @@ FARPROC addr;
|
||||||
|
|
||||||
mylog( "%s: entering...\n", func);
|
mylog( "%s: entering...\n", func);
|
||||||
|
|
||||||
// Check if this can handle canceling in the middle of a SQLPutData?
|
/* Check if this can handle canceling in the middle of a SQLPutData? */
|
||||||
if ( ! stmt) {
|
if ( ! stmt) {
|
||||||
SC_log_error(func, "", NULL);
|
SC_log_error(func, "", NULL);
|
||||||
return SQL_INVALID_HANDLE;
|
return SQL_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not in the middle of SQLParamData/SQLPutData so cancel like a close.
|
/* Not in the middle of SQLParamData/SQLPutData so cancel like a close. */
|
||||||
if (stmt->data_at_exec < 0) {
|
if (stmt->data_at_exec < 0) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -423,9 +423,9 @@ FARPROC addr;
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In the middle of SQLParamData/SQLPutData, so cancel that.
|
/* In the middle of SQLParamData/SQLPutData, so cancel that. */
|
||||||
// Note, any previous data-at-exec buffers will be freed in the recycle
|
/* Note, any previous data-at-exec buffers will be freed in the recycle */
|
||||||
// if they call SQLExecDirect or SQLExecute again.
|
/* if they call SQLExecDirect or SQLExecute again. */
|
||||||
|
|
||||||
stmt->data_at_exec = -1;
|
stmt->data_at_exec = -1;
|
||||||
stmt->current_exec_param = -1;
|
stmt->current_exec_param = -1;
|
||||||
|
@ -435,11 +435,11 @@ FARPROC addr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
// Returns the SQL string as modified by the driver.
|
/* Returns the SQL string as modified by the driver. */
|
||||||
// Currently, just copy the input string without modification
|
/* Currently, just copy the input string without modification */
|
||||||
// observing buffer limits and truncation.
|
/* observing buffer limits and truncation. */
|
||||||
RETCODE SQL_API SQLNativeSql(
|
RETCODE SQL_API SQLNativeSql(
|
||||||
HDBC hdbc,
|
HDBC hdbc,
|
||||||
UCHAR FAR *szSqlStrIn,
|
UCHAR FAR *szSqlStrIn,
|
||||||
|
@ -485,10 +485,10 @@ RETCODE result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
// Supplies parameter data at execution time. Used in conjuction with
|
/* Supplies parameter data at execution time. Used in conjuction with */
|
||||||
// SQLPutData.
|
/* SQLPutData. */
|
||||||
|
|
||||||
RETCODE SQL_API SQLParamData(
|
RETCODE SQL_API SQLParamData(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -583,10 +583,10 @@ int i, retval;
|
||||||
return SQL_NEED_DATA;
|
return SQL_NEED_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
// Supplies parameter data at execution time. Used in conjunction with
|
/* Supplies parameter data at execution time. Used in conjunction with */
|
||||||
// SQLParamData.
|
/* SQLParamData. */
|
||||||
|
|
||||||
RETCODE SQL_API SQLPutData(
|
RETCODE SQL_API SQLPutData(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
// GetPrivateProfileString() -- approximate implementation of
|
/* GetPrivateProfileString() -- approximate implementation of */
|
||||||
// Windows NT System Services version of GetPrivateProfileString()
|
/* Windows NT System Services version of GetPrivateProfileString() */
|
||||||
// probably doesn't handle the NULL key for section name or value key
|
/* probably doesn't handle the NULL key for section name or value key */
|
||||||
// correctly also, doesn't provide Microsoft backwards compatability
|
/* correctly also, doesn't provide Microsoft backwards compatability */
|
||||||
// wrt TAB characters in the value string -- Microsoft terminates value
|
/* wrt TAB characters in the value string -- Microsoft terminates value */
|
||||||
// at the first TAB, but I couldn't discover what the behavior should
|
/* at the first TAB, but I couldn't discover what the behavior should */
|
||||||
// be regarding TABS in quoted strings so, I treat tabs like any other
|
/* be regarding TABS in quoted strings so, I treat tabs like any other */
|
||||||
// characters -- NO comments following value string separated by a TAB
|
/* characters -- NO comments following value string separated by a TAB */
|
||||||
// are allowed (that is an anachronism anyway)
|
/* are allowed (that is an anachronism anyway) */
|
||||||
// Added code to search for ODBC_INI file in users home directory on
|
/* Added code to search for ODBC_INI file in users home directory on */
|
||||||
// Unix
|
/* Unix */
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
#include "config.h" // produced by configure
|
#include "config.h" /* produced by configure */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -38,12 +38,12 @@
|
||||||
|
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
GetPrivateProfileString(char *theSection, // section name
|
GetPrivateProfileString(char *theSection, /* section name */
|
||||||
char *theKey, // search key name
|
char *theKey, /* search key name */
|
||||||
char *theDefault, // default value if not found
|
char *theDefault, /* default value if not found */
|
||||||
char *theReturnBuffer, // return value stored here
|
char *theReturnBuffer, /* return value stored here */
|
||||||
size_t theReturnBufferLength, // byte length of return buffer
|
size_t theReturnBufferLength, /* byte length of return buffer */
|
||||||
char *theIniFileName) // pathname of ini file to search
|
char *theIniFileName) /* pathname of ini file to search */
|
||||||
{
|
{
|
||||||
char buf[MAXPGPATH];
|
char buf[MAXPGPATH];
|
||||||
char* ptr = 0;
|
char* ptr = 0;
|
||||||
|
@ -61,7 +61,7 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
j = strlen(theIniFileName) + 1;
|
j = strlen(theIniFileName) + 1;
|
||||||
ptr = (char*)getpwuid(getuid()); // get user info
|
ptr = (char*)getpwuid(getuid()); /* get user info */
|
||||||
|
|
||||||
if( ptr == NULL)
|
if( ptr == NULL)
|
||||||
{
|
{
|
||||||
|
@ -70,7 +70,7 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
|
|
||||||
sprintf(buf,"%s",theIniFileName);
|
sprintf(buf,"%s",theIniFileName);
|
||||||
}
|
}
|
||||||
ptr = ((struct passwd*)ptr)->pw_dir; // get user home dir
|
ptr = ((struct passwd*)ptr)->pw_dir; /* get user home dir */
|
||||||
if( ptr == NULL || *ptr == '\0' )
|
if( ptr == NULL || *ptr == '\0' )
|
||||||
ptr = "/home";
|
ptr = "/home";
|
||||||
|
|
||||||
|
@ -120,9 +120,9 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
|
|
||||||
if(aFile == NULL)
|
if(aFile == NULL)
|
||||||
{
|
{
|
||||||
// no ini file specified, return the default
|
/* no ini file specified, return the default */
|
||||||
|
|
||||||
++aLength; // room for NULL char
|
++aLength; /* room for NULL char */
|
||||||
aLength = theReturnBufferLength < aLength ?
|
aLength = theReturnBufferLength < aLength ?
|
||||||
theReturnBufferLength : aLength;
|
theReturnBufferLength : aLength;
|
||||||
strncpy(theReturnBuffer, theDefault, aLength);
|
strncpy(theReturnBuffer, theDefault, aLength);
|
||||||
|
@ -134,19 +134,19 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
while(fgets(aLine, sizeof(aLine), aFile) != NULL)
|
while(fgets(aLine, sizeof(aLine), aFile) != NULL)
|
||||||
{
|
{
|
||||||
aLineLength = strlen(aLine);
|
aLineLength = strlen(aLine);
|
||||||
// strip final '\n'
|
/* strip final '\n' */
|
||||||
if(aLineLength > 0 && aLine[aLineLength - 1] == '\n')
|
if(aLineLength > 0 && aLine[aLineLength - 1] == '\n')
|
||||||
{
|
{
|
||||||
aLine[aLineLength - 1] = '\0';
|
aLine[aLineLength - 1] = '\0';
|
||||||
}
|
}
|
||||||
switch(*aLine)
|
switch(*aLine)
|
||||||
{
|
{
|
||||||
case ' ': // blank line
|
case ' ': /* blank line */
|
||||||
case ';': // comment line
|
case ';': /* comment line */
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '[': // section marker
|
case '[': /* section marker */
|
||||||
|
|
||||||
if( (aString = strchr(aLine, ']')) )
|
if( (aString = strchr(aLine, ']')) )
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,7 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
while (isspace(*aString)) aString--;
|
while (isspace(*aString)) aString--;
|
||||||
*(aString+1) = '\0';
|
*(aString+1) = '\0';
|
||||||
|
|
||||||
// accept as matched if NULL key or exact match
|
/* accept as matched if NULL key or exact match */
|
||||||
|
|
||||||
if(!theSection || !strcmp(aStart, theSection))
|
if(!theSection || !strcmp(aStart, theSection))
|
||||||
{
|
{
|
||||||
|
@ -168,18 +168,18 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
// try to match value keys if in proper section
|
/* try to match value keys if in proper section */
|
||||||
|
|
||||||
if(aSectionFound)
|
if(aSectionFound)
|
||||||
{
|
{
|
||||||
// try to match requested key
|
/* try to match requested key */
|
||||||
|
|
||||||
if( (aString = aValue = strchr(aLine, '=')) )
|
if( (aString = aValue = strchr(aLine, '=')) )
|
||||||
{
|
{
|
||||||
*aValue = '\0';
|
*aValue = '\0';
|
||||||
++aValue;
|
++aValue;
|
||||||
|
|
||||||
// strip leading blanks in value field
|
/* strip leading blanks in value field */
|
||||||
|
|
||||||
while(*aValue == ' ' && aValue < aLine + sizeof(aLine))
|
while(*aValue == ' ' && aValue < aLine + sizeof(aLine))
|
||||||
{
|
{
|
||||||
|
@ -198,7 +198,7 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
aStart = aLine;
|
aStart = aLine;
|
||||||
while(isspace(*aStart)) aStart++;
|
while(isspace(*aStart)) aStart++;
|
||||||
|
|
||||||
// strip trailing blanks from key
|
/* strip trailing blanks from key */
|
||||||
|
|
||||||
if(aString)
|
if(aString)
|
||||||
{
|
{
|
||||||
|
@ -208,16 +208,16 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if key is matched
|
/* see if key is matched */
|
||||||
|
|
||||||
if(theKey == NULL || !strcmp(theKey, aStart))
|
if(theKey == NULL || !strcmp(theKey, aStart))
|
||||||
{
|
{
|
||||||
// matched -- first, terminate value part
|
/* matched -- first, terminate value part */
|
||||||
|
|
||||||
aKeyFound = TRUE;
|
aKeyFound = TRUE;
|
||||||
aLength = strlen(aValue);
|
aLength = strlen(aValue);
|
||||||
|
|
||||||
// remove trailing blanks from aValue if any
|
/* remove trailing blanks from aValue if any */
|
||||||
|
|
||||||
aString = aValue + aLength - 1;
|
aString = aValue + aLength - 1;
|
||||||
|
|
||||||
|
@ -227,12 +227,12 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
--aLength;
|
--aLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unquote value if quoted
|
/* unquote value if quoted */
|
||||||
|
|
||||||
if(aLength >= 2 && aValue[0] == '"' &&
|
if(aLength >= 2 && aValue[0] == '"' &&
|
||||||
aValue[aLength - 1] == '"')
|
aValue[aLength - 1] == '"')
|
||||||
{
|
{
|
||||||
// string quoted with double quotes
|
/* string quoted with double quotes */
|
||||||
|
|
||||||
aValue[aLength - 1] = '\0';
|
aValue[aLength - 1] = '\0';
|
||||||
++aValue;
|
++aValue;
|
||||||
|
@ -240,7 +240,7 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// single quotes allowed also...
|
/* single quotes allowed also... */
|
||||||
|
|
||||||
if(aLength >= 2 && aValue[0] == '\'' &&
|
if(aLength >= 2 && aValue[0] == '\'' &&
|
||||||
aValue[aLength - 1] == '\'')
|
aValue[aLength - 1] == '\'')
|
||||||
|
@ -251,13 +251,13 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute maximum length copyable
|
/* compute maximum length copyable */
|
||||||
|
|
||||||
aLineLength = (aLength <
|
aLineLength = (aLength <
|
||||||
theReturnBufferLength - aReturnLength) ? aLength :
|
theReturnBufferLength - aReturnLength) ? aLength :
|
||||||
theReturnBufferLength - aReturnLength;
|
theReturnBufferLength - aReturnLength;
|
||||||
|
|
||||||
// do the copy to return buffer
|
/* do the copy to return buffer */
|
||||||
|
|
||||||
if(aLineLength)
|
if(aLineLength)
|
||||||
{
|
{
|
||||||
|
@ -289,8 +289,8 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
fclose(aFile);
|
fclose(aFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!aKeyFound) { // key wasn't found return default
|
if(!aKeyFound) { /* key wasn't found return default */
|
||||||
++aLength; // room for NULL char
|
++aLength; /* room for NULL char */
|
||||||
aLength = theReturnBufferLength < aLength ?
|
aLength = theReturnBufferLength < aLength ?
|
||||||
theReturnBufferLength : aLength;
|
theReturnBufferLength : aLength;
|
||||||
strncpy(theReturnBuffer, theDefault, aLength);
|
strncpy(theReturnBuffer, theDefault, aLength);
|
||||||
|
@ -301,22 +301,24 @@ GetPrivateProfileString(char *theSection, // section name
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
WritePrivateProfileString(char *theSection, // section name
|
WritePrivateProfileString(char *theSection, /* section name */
|
||||||
char *theKey, // write key name
|
char *theKey, /* write key name */
|
||||||
char *theBuffer, // input buffer
|
char *theBuffer, /* input buffer */
|
||||||
char *theIniFileName) // pathname of ini file to write
|
char *theIniFileName) /* pathname of ini file to write */
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* Ok. What the hell's the default behaviour for a null input buffer, and null
|
/* Ok. What the hell's the default behaviour for a null input buffer, and null
|
||||||
* section name. For now if either are null I ignore the request, until
|
* section name. For now if either are null I ignore the request, until
|
||||||
* I find out different.
|
* I find out different.
|
||||||
|
*/
|
||||||
DWORD
|
DWORD
|
||||||
WritePrivateProfileString(char *theSection, // section name
|
WritePrivateProfileString(char *theSection, /* section name */
|
||||||
char *theKey, // write key name
|
char *theKey, /* write key name */
|
||||||
char *theBuffer, // input buffer
|
char *theBuffer, /* input buffer */
|
||||||
char *theIniFileName) // pathname of ini file to write
|
char *theIniFileName) /* pathname of ini file to write */
|
||||||
{
|
{
|
||||||
char buf[MAXPGPATH];
|
char buf[MAXPGPATH];
|
||||||
char* ptr = 0;
|
char* ptr = 0;
|
||||||
|
@ -332,7 +334,7 @@ WritePrivateProfileString(char *theSection, // section name
|
||||||
BOOL keyFound = FALSE;
|
BOOL keyFound = FALSE;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
// If this isn't correct processing we'll change it later
|
/* If this isn't correct processing we'll change it later */
|
||||||
if(theSection == NULL || theKey == NULL || theBuffer == NULL ||
|
if(theSection == NULL || theKey == NULL || theBuffer == NULL ||
|
||||||
theIniFileName == NULL) return 0;
|
theIniFileName == NULL) return 0;
|
||||||
|
|
||||||
|
@ -340,7 +342,7 @@ WritePrivateProfileString(char *theSection, // section name
|
||||||
if(aLength == 0) return 0;
|
if(aLength == 0) return 0;
|
||||||
|
|
||||||
j = strlen(theIniFileName) + 1;
|
j = strlen(theIniFileName) + 1;
|
||||||
ptr = (char*)getpwuid(getuid()); // get user info
|
ptr = (char*)getpwuid(getuid()); /* get user info */
|
||||||
|
|
||||||
if( ptr == NULL)
|
if( ptr == NULL)
|
||||||
{
|
{
|
||||||
|
@ -349,15 +351,15 @@ WritePrivateProfileString(char *theSection, // section name
|
||||||
|
|
||||||
sprintf(buf,"%s",theIniFileName);
|
sprintf(buf,"%s",theIniFileName);
|
||||||
}
|
}
|
||||||
ptr = ((struct passwd*)ptr)->pw_dir; // get user home dir
|
ptr = ((struct passwd*)ptr)->pw_dir; /* get user home dir */
|
||||||
if( ptr == NULL || *ptr == '\0' )
|
if( ptr == NULL || *ptr == '\0' )
|
||||||
ptr = "/home";
|
ptr = "/home";
|
||||||
|
|
||||||
// This doesn't make it so we find an ini file but allows normal
|
/* This doesn't make it so we find an ini file but allows normal */
|
||||||
// processing to continue further on down. The likelihood is that
|
/* processing to continue further on down. The likelihood is that */
|
||||||
// the file won't be found and thus the default value will be
|
/* the file won't be found and thus the default value will be */
|
||||||
// returned.
|
/* returned. */
|
||||||
//
|
/* */
|
||||||
if( MAXPGPATH-1 < strlen(ptr) + j )
|
if( MAXPGPATH-1 < strlen(ptr) + j )
|
||||||
{
|
{
|
||||||
if( MAXPGPATH-1 < strlen(ptr) )
|
if( MAXPGPATH-1 < strlen(ptr) )
|
||||||
|
@ -368,9 +370,9 @@ WritePrivateProfileString(char *theSection, // section name
|
||||||
|
|
||||||
sprintf( buf, "%s/%s",ptr,theIniFileName );
|
sprintf( buf, "%s/%s",ptr,theIniFileName );
|
||||||
|
|
||||||
// This code makes it so that a file in the users home dir
|
/* This code makes it so that a file in the users home dir */
|
||||||
// overrides a the "default" file as passed in
|
/* overrides a the "default" file as passed in */
|
||||||
//
|
/* */
|
||||||
aFile = (FILE*)(buf ? fopen(buf, "r+") : NULL);
|
aFile = (FILE*)(buf ? fopen(buf, "r+") : NULL);
|
||||||
if(!aFile) {
|
if(!aFile) {
|
||||||
sprintf(buf,"%s",theIniFileName);
|
sprintf(buf,"%s",theIniFileName);
|
||||||
|
@ -381,32 +383,32 @@ WritePrivateProfileString(char *theSection, // section name
|
||||||
|
|
||||||
aLength = strlen(theBuffer);
|
aLength = strlen(theBuffer);
|
||||||
|
|
||||||
// We have to search for theKey, because if it already
|
/* We have to search for theKey, because if it already */
|
||||||
// exists we have to overwrite it. If it doesn't exist
|
/* exists we have to overwrite it. If it doesn't exist */
|
||||||
// we just write a new line to the file.
|
/* we just write a new line to the file. */
|
||||||
//
|
/* */
|
||||||
while(fgets(aLine, sizeof(aLine), aFile) != NULL)
|
while(fgets(aLine, sizeof(aLine), aFile) != NULL)
|
||||||
{
|
{
|
||||||
aLineLength = strlen(aLine);
|
aLineLength = strlen(aLine);
|
||||||
// strip final '\n'
|
/* strip final '\n' */
|
||||||
if(aLineLength > 0 && aLine[aLineLength - 1] == '\n')
|
if(aLineLength > 0 && aLine[aLineLength - 1] == '\n')
|
||||||
{
|
{
|
||||||
aLine[aLineLength - 1] = '\0';
|
aLine[aLineLength - 1] = '\0';
|
||||||
}
|
}
|
||||||
switch(*aLine)
|
switch(*aLine)
|
||||||
{
|
{
|
||||||
case ' ': // blank line
|
case ' ': /* blank line */
|
||||||
case ';': // comment line
|
case ';': /* comment line */
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '[': // section marker
|
case '[': /* section marker */
|
||||||
|
|
||||||
if( (aString = strchr(aLine, ']')) )
|
if( (aString = strchr(aLine, ']')) )
|
||||||
{
|
{
|
||||||
*aString = '\0';
|
*aString = '\0';
|
||||||
|
|
||||||
// accept as matched if key exact match
|
/* accept as matched if key exact match */
|
||||||
|
|
||||||
if(!strcmp(aLine + 1, theSection))
|
if(!strcmp(aLine + 1, theSection))
|
||||||
{
|
{
|
||||||
|
@ -418,18 +420,18 @@ WritePrivateProfileString(char *theSection, // section name
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
// try to match value keys if in proper section
|
/* try to match value keys if in proper section */
|
||||||
|
|
||||||
if(aSectionFound)
|
if(aSectionFound)
|
||||||
{
|
{
|
||||||
// try to match requested key
|
/* try to match requested key */
|
||||||
|
|
||||||
if( (aString = aValue = strchr(aLine, '=')) )
|
if( (aString = aValue = strchr(aLine, '=')) )
|
||||||
{
|
{
|
||||||
*aValue = '\0';
|
*aValue = '\0';
|
||||||
++aValue;
|
++aValue;
|
||||||
|
|
||||||
// strip leading blanks in value field
|
/* strip leading blanks in value field */
|
||||||
|
|
||||||
while(*aValue == ' ' && aValue < aLine + sizeof(aLine))
|
while(*aValue == ' ' && aValue < aLine + sizeof(aLine))
|
||||||
{
|
{
|
||||||
|
@ -445,7 +447,7 @@ WritePrivateProfileString(char *theSection, // section name
|
||||||
aValue = "";
|
aValue = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// strip trailing blanks from key
|
/* strip trailing blanks from key */
|
||||||
|
|
||||||
if(aString)
|
if(aString)
|
||||||
{
|
{
|
||||||
|
@ -455,16 +457,16 @@ WritePrivateProfileString(char *theSection, // section name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// see if key is matched
|
/* see if key is matched */
|
||||||
|
|
||||||
if(!strcmp(theKey, aLine))
|
if(!strcmp(theKey, aLine))
|
||||||
{
|
{
|
||||||
keyFound = TRUE;
|
keyFound = TRUE;
|
||||||
// matched -- first, terminate value part
|
/* matched -- first, terminate value part */
|
||||||
|
|
||||||
// overwrite current value
|
/* overwrite current value */
|
||||||
fseek(aFile,-aLineLength,SEEK_CUR);
|
fseek(aFile,-aLineLength,SEEK_CUR);
|
||||||
// overwrite key and value
|
/* overwrite key and value */
|
||||||
sprintf(aLine,"%s = %s\n",theKey,theBuffer);
|
sprintf(aLine,"%s = %s\n",theKey,theBuffer);
|
||||||
fputs(aLine,aFile);
|
fputs(aLine,aFile);
|
||||||
}
|
}
|
||||||
|
@ -475,7 +477,7 @@ WritePrivateProfileString(char *theSection, // section name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!keyFound) { // theKey wasn't in file so
|
if(!keyFound) { /* theKey wasn't in file so */
|
||||||
if(aFile)
|
if(aFile)
|
||||||
{
|
{
|
||||||
fclose(aFile);
|
fclose(aFile);
|
||||||
|
@ -483,6 +485,7 @@ WritePrivateProfileString(char *theSection, // section name
|
||||||
|
|
||||||
return aReturnLength > 0 ? aReturnLength - 1 : 0;
|
return aReturnLength > 0 ? aReturnLength - 1 : 0;
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// GetPrivateProfileString
|
/* GetPrivateProfileString */
|
||||||
// for UNIX use
|
/* for UNIX use */
|
||||||
#ifndef GPPS_H
|
#ifndef GPPS_H
|
||||||
#define GPPS_H
|
#define GPPS_H
|
||||||
|
|
||||||
|
@ -17,18 +17,18 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
GetPrivateProfileString(char *theSection, // section name
|
GetPrivateProfileString(char *theSection, /* section name */
|
||||||
char *theKey, // search key name
|
char *theKey, /* search key name */
|
||||||
char *theDefault, // default value if not found
|
char *theDefault, /* default value if not found */
|
||||||
char *theReturnBuffer, // return valuse stored here
|
char *theReturnBuffer, /* return valuse stored here */
|
||||||
size_t theBufferLength, // byte length of return buffer
|
size_t theBufferLength, /* byte length of return buffer */
|
||||||
char *theIniFileName); // pathname of ini file to search
|
char *theIniFileName); /* pathname of ini file to search */
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
WritePrivateProfileString(char *theSection, // section name
|
WritePrivateProfileString(char *theSection, /* section name */
|
||||||
char *theKey, // write key name
|
char *theKey, /* write key name */
|
||||||
char *theBuffer, // input buffer
|
char *theBuffer, /* input buffer */
|
||||||
char *theIniFileName); // pathname of ini file to write
|
char *theIniFileName); /* pathname of ini file to write */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
extern GLOBAL_VALUES globals;
|
extern GLOBAL_VALUES globals;
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
RETCODE SQL_API SQLGetInfo(
|
RETCODE SQL_API SQLGetInfo(
|
||||||
HDBC hdbc,
|
HDBC hdbc,
|
||||||
|
@ -196,7 +196,7 @@ RETCODE result;
|
||||||
|
|
||||||
case SQL_DEFAULT_TXN_ISOLATION: /* ODBC 1.0 */
|
case SQL_DEFAULT_TXN_ISOLATION: /* ODBC 1.0 */
|
||||||
len = 4;
|
len = 4;
|
||||||
value = SQL_TXN_READ_COMMITTED; //SQL_TXN_SERIALIZABLE;
|
value = SQL_TXN_READ_COMMITTED; /*SQL_TXN_SERIALIZABLE; */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SQL_DRIVER_NAME: /* ODBC 1.0 */
|
case SQL_DRIVER_NAME: /* ODBC 1.0 */
|
||||||
|
@ -572,7 +572,7 @@ RETCODE result;
|
||||||
|
|
||||||
case SQL_TXN_ISOLATION_OPTION: /* ODBC 1.0 */
|
case SQL_TXN_ISOLATION_OPTION: /* ODBC 1.0 */
|
||||||
len = 4;
|
len = 4;
|
||||||
value = SQL_TXN_READ_COMMITTED; // SQL_TXN_SERIALIZABLE;
|
value = SQL_TXN_READ_COMMITTED; /* SQL_TXN_SERIALIZABLE; */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SQL_UNION: /* ODBC 2.0 */
|
case SQL_UNION: /* ODBC 2.0 */
|
||||||
|
@ -632,7 +632,7 @@ RETCODE result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
|
|
||||||
RETCODE SQL_API SQLGetTypeInfo(
|
RETCODE SQL_API SQLGetTypeInfo(
|
||||||
|
@ -643,7 +643,7 @@ static char *func = "SQLGetTypeInfo";
|
||||||
StatementClass *stmt = (StatementClass *) hstmt;
|
StatementClass *stmt = (StatementClass *) hstmt;
|
||||||
TupleNode *row;
|
TupleNode *row;
|
||||||
int i;
|
int i;
|
||||||
// Int4 type;
|
/* Int4 type; */
|
||||||
Int4 pgType;
|
Int4 pgType;
|
||||||
Int2 sqlType;
|
Int2 sqlType;
|
||||||
|
|
||||||
|
@ -721,7 +721,7 @@ Int2 sqlType;
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
RETCODE SQL_API SQLGetFunctions(
|
RETCODE SQL_API SQLGetFunctions(
|
||||||
HDBC hdbc,
|
HDBC hdbc,
|
||||||
|
@ -748,7 +748,7 @@ static char *func="SQLGetFunctions";
|
||||||
else {
|
else {
|
||||||
memset(pfExists, 0, sizeof(UWORD)*100);
|
memset(pfExists, 0, sizeof(UWORD)*100);
|
||||||
|
|
||||||
// ODBC core functions
|
/* ODBC core functions */
|
||||||
pfExists[SQL_API_SQLALLOCCONNECT] = TRUE;
|
pfExists[SQL_API_SQLALLOCCONNECT] = TRUE;
|
||||||
pfExists[SQL_API_SQLALLOCENV] = TRUE;
|
pfExists[SQL_API_SQLALLOCENV] = TRUE;
|
||||||
pfExists[SQL_API_SQLALLOCSTMT] = TRUE;
|
pfExists[SQL_API_SQLALLOCSTMT] = TRUE;
|
||||||
|
@ -756,7 +756,7 @@ static char *func="SQLGetFunctions";
|
||||||
pfExists[SQL_API_SQLCANCEL] = TRUE;
|
pfExists[SQL_API_SQLCANCEL] = TRUE;
|
||||||
pfExists[SQL_API_SQLCOLATTRIBUTES] = TRUE;
|
pfExists[SQL_API_SQLCOLATTRIBUTES] = TRUE;
|
||||||
pfExists[SQL_API_SQLCONNECT] = TRUE;
|
pfExists[SQL_API_SQLCONNECT] = TRUE;
|
||||||
pfExists[SQL_API_SQLDESCRIBECOL] = TRUE; // partial
|
pfExists[SQL_API_SQLDESCRIBECOL] = TRUE; /* partial */
|
||||||
pfExists[SQL_API_SQLDISCONNECT] = TRUE;
|
pfExists[SQL_API_SQLDISCONNECT] = TRUE;
|
||||||
pfExists[SQL_API_SQLERROR] = TRUE;
|
pfExists[SQL_API_SQLERROR] = TRUE;
|
||||||
pfExists[SQL_API_SQLEXECDIRECT] = TRUE;
|
pfExists[SQL_API_SQLEXECDIRECT] = TRUE;
|
||||||
|
@ -767,36 +767,36 @@ static char *func="SQLGetFunctions";
|
||||||
pfExists[SQL_API_SQLFREESTMT] = TRUE;
|
pfExists[SQL_API_SQLFREESTMT] = TRUE;
|
||||||
pfExists[SQL_API_SQLGETCURSORNAME] = TRUE;
|
pfExists[SQL_API_SQLGETCURSORNAME] = TRUE;
|
||||||
pfExists[SQL_API_SQLNUMRESULTCOLS] = TRUE;
|
pfExists[SQL_API_SQLNUMRESULTCOLS] = TRUE;
|
||||||
pfExists[SQL_API_SQLPREPARE] = TRUE; // complete?
|
pfExists[SQL_API_SQLPREPARE] = TRUE; /* complete? */
|
||||||
pfExists[SQL_API_SQLROWCOUNT] = TRUE;
|
pfExists[SQL_API_SQLROWCOUNT] = TRUE;
|
||||||
pfExists[SQL_API_SQLSETCURSORNAME] = TRUE;
|
pfExists[SQL_API_SQLSETCURSORNAME] = TRUE;
|
||||||
pfExists[SQL_API_SQLSETPARAM] = FALSE; // odbc 1.0
|
pfExists[SQL_API_SQLSETPARAM] = FALSE; /* odbc 1.0 */
|
||||||
pfExists[SQL_API_SQLTRANSACT] = TRUE;
|
pfExists[SQL_API_SQLTRANSACT] = TRUE;
|
||||||
|
|
||||||
// ODBC level 1 functions
|
/* ODBC level 1 functions */
|
||||||
pfExists[SQL_API_SQLBINDPARAMETER] = TRUE;
|
pfExists[SQL_API_SQLBINDPARAMETER] = TRUE;
|
||||||
pfExists[SQL_API_SQLCOLUMNS] = TRUE;
|
pfExists[SQL_API_SQLCOLUMNS] = TRUE;
|
||||||
pfExists[SQL_API_SQLDRIVERCONNECT] = TRUE;
|
pfExists[SQL_API_SQLDRIVERCONNECT] = TRUE;
|
||||||
pfExists[SQL_API_SQLGETCONNECTOPTION] = TRUE; // partial
|
pfExists[SQL_API_SQLGETCONNECTOPTION] = TRUE; /* partial */
|
||||||
pfExists[SQL_API_SQLGETDATA] = TRUE;
|
pfExists[SQL_API_SQLGETDATA] = TRUE;
|
||||||
pfExists[SQL_API_SQLGETFUNCTIONS] = TRUE;
|
pfExists[SQL_API_SQLGETFUNCTIONS] = TRUE;
|
||||||
pfExists[SQL_API_SQLGETINFO] = TRUE;
|
pfExists[SQL_API_SQLGETINFO] = TRUE;
|
||||||
pfExists[SQL_API_SQLGETSTMTOPTION] = TRUE; // partial
|
pfExists[SQL_API_SQLGETSTMTOPTION] = TRUE; /* partial */
|
||||||
pfExists[SQL_API_SQLGETTYPEINFO] = TRUE;
|
pfExists[SQL_API_SQLGETTYPEINFO] = TRUE;
|
||||||
pfExists[SQL_API_SQLPARAMDATA] = TRUE;
|
pfExists[SQL_API_SQLPARAMDATA] = TRUE;
|
||||||
pfExists[SQL_API_SQLPUTDATA] = TRUE;
|
pfExists[SQL_API_SQLPUTDATA] = TRUE;
|
||||||
pfExists[SQL_API_SQLSETCONNECTOPTION] = TRUE; // partial
|
pfExists[SQL_API_SQLSETCONNECTOPTION] = TRUE; /* partial */
|
||||||
pfExists[SQL_API_SQLSETSTMTOPTION] = TRUE;
|
pfExists[SQL_API_SQLSETSTMTOPTION] = TRUE;
|
||||||
pfExists[SQL_API_SQLSPECIALCOLUMNS] = TRUE;
|
pfExists[SQL_API_SQLSPECIALCOLUMNS] = TRUE;
|
||||||
pfExists[SQL_API_SQLSTATISTICS] = TRUE;
|
pfExists[SQL_API_SQLSTATISTICS] = TRUE;
|
||||||
pfExists[SQL_API_SQLTABLES] = TRUE;
|
pfExists[SQL_API_SQLTABLES] = TRUE;
|
||||||
|
|
||||||
// ODBC level 2 functions
|
/* ODBC level 2 functions */
|
||||||
pfExists[SQL_API_SQLBROWSECONNECT] = FALSE;
|
pfExists[SQL_API_SQLBROWSECONNECT] = FALSE;
|
||||||
pfExists[SQL_API_SQLCOLUMNPRIVILEGES] = FALSE;
|
pfExists[SQL_API_SQLCOLUMNPRIVILEGES] = FALSE;
|
||||||
pfExists[SQL_API_SQLDATASOURCES] = FALSE; // only implemented by DM
|
pfExists[SQL_API_SQLDATASOURCES] = FALSE; /* only implemented by DM */
|
||||||
pfExists[SQL_API_SQLDESCRIBEPARAM] = FALSE; // not properly implemented
|
pfExists[SQL_API_SQLDESCRIBEPARAM] = FALSE; /* not properly implemented */
|
||||||
pfExists[SQL_API_SQLDRIVERS] = FALSE; // only implemented by DM
|
pfExists[SQL_API_SQLDRIVERS] = FALSE; /* only implemented by DM */
|
||||||
pfExists[SQL_API_SQLEXTENDEDFETCH] = TRUE;
|
pfExists[SQL_API_SQLEXTENDEDFETCH] = TRUE;
|
||||||
pfExists[SQL_API_SQLFOREIGNKEYS] = TRUE;
|
pfExists[SQL_API_SQLFOREIGNKEYS] = TRUE;
|
||||||
pfExists[SQL_API_SQLMORERESULTS] = TRUE;
|
pfExists[SQL_API_SQLMORERESULTS] = TRUE;
|
||||||
|
@ -807,7 +807,7 @@ static char *func="SQLGetFunctions";
|
||||||
pfExists[SQL_API_SQLPROCEDURECOLUMNS] = FALSE;
|
pfExists[SQL_API_SQLPROCEDURECOLUMNS] = FALSE;
|
||||||
pfExists[SQL_API_SQLPROCEDURES] = FALSE;
|
pfExists[SQL_API_SQLPROCEDURES] = FALSE;
|
||||||
pfExists[SQL_API_SQLSETPOS] = TRUE;
|
pfExists[SQL_API_SQLSETPOS] = TRUE;
|
||||||
pfExists[SQL_API_SQLSETSCROLLOPTIONS] = TRUE; // odbc 1.0
|
pfExists[SQL_API_SQLSETSCROLLOPTIONS] = TRUE; /* odbc 1.0 */
|
||||||
pfExists[SQL_API_SQLTABLEPRIVILEGES] = FALSE;
|
pfExists[SQL_API_SQLTABLEPRIVILEGES] = FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -825,7 +825,7 @@ static char *func="SQLGetFunctions";
|
||||||
case SQL_API_SQLCANCEL: *pfExists = TRUE; break;
|
case SQL_API_SQLCANCEL: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLCOLATTRIBUTES: *pfExists = TRUE; break;
|
case SQL_API_SQLCOLATTRIBUTES: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLCONNECT: *pfExists = TRUE; break;
|
case SQL_API_SQLCONNECT: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLDESCRIBECOL: *pfExists = TRUE; break; // partial
|
case SQL_API_SQLDESCRIBECOL: *pfExists = TRUE; break; /* partial */
|
||||||
case SQL_API_SQLDISCONNECT: *pfExists = TRUE; break;
|
case SQL_API_SQLDISCONNECT: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLERROR: *pfExists = TRUE; break;
|
case SQL_API_SQLERROR: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLEXECDIRECT: *pfExists = TRUE; break;
|
case SQL_API_SQLEXECDIRECT: *pfExists = TRUE; break;
|
||||||
|
@ -839,33 +839,33 @@ static char *func="SQLGetFunctions";
|
||||||
case SQL_API_SQLPREPARE: *pfExists = TRUE; break;
|
case SQL_API_SQLPREPARE: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLROWCOUNT: *pfExists = TRUE; break;
|
case SQL_API_SQLROWCOUNT: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLSETCURSORNAME: *pfExists = TRUE; break;
|
case SQL_API_SQLSETCURSORNAME: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLSETPARAM: *pfExists = FALSE; break; // odbc 1.0
|
case SQL_API_SQLSETPARAM: *pfExists = FALSE; break; /* odbc 1.0 */
|
||||||
case SQL_API_SQLTRANSACT: *pfExists = TRUE; break;
|
case SQL_API_SQLTRANSACT: *pfExists = TRUE; break;
|
||||||
|
|
||||||
// ODBC level 1 functions
|
/* ODBC level 1 functions */
|
||||||
case SQL_API_SQLBINDPARAMETER: *pfExists = TRUE; break;
|
case SQL_API_SQLBINDPARAMETER: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLCOLUMNS: *pfExists = TRUE; break;
|
case SQL_API_SQLCOLUMNS: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLDRIVERCONNECT: *pfExists = TRUE; break;
|
case SQL_API_SQLDRIVERCONNECT: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLGETCONNECTOPTION: *pfExists = TRUE; break; // partial
|
case SQL_API_SQLGETCONNECTOPTION: *pfExists = TRUE; break; /* partial */
|
||||||
case SQL_API_SQLGETDATA: *pfExists = TRUE; break;
|
case SQL_API_SQLGETDATA: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLGETFUNCTIONS: *pfExists = TRUE; break;
|
case SQL_API_SQLGETFUNCTIONS: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLGETINFO: *pfExists = TRUE; break;
|
case SQL_API_SQLGETINFO: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLGETSTMTOPTION: *pfExists = TRUE; break; // partial
|
case SQL_API_SQLGETSTMTOPTION: *pfExists = TRUE; break; /* partial */
|
||||||
case SQL_API_SQLGETTYPEINFO: *pfExists = TRUE; break;
|
case SQL_API_SQLGETTYPEINFO: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLPARAMDATA: *pfExists = TRUE; break;
|
case SQL_API_SQLPARAMDATA: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLPUTDATA: *pfExists = TRUE; break;
|
case SQL_API_SQLPUTDATA: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLSETCONNECTOPTION: *pfExists = TRUE; break; // partial
|
case SQL_API_SQLSETCONNECTOPTION: *pfExists = TRUE; break; /* partial */
|
||||||
case SQL_API_SQLSETSTMTOPTION: *pfExists = TRUE; break;
|
case SQL_API_SQLSETSTMTOPTION: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLSPECIALCOLUMNS: *pfExists = TRUE; break;
|
case SQL_API_SQLSPECIALCOLUMNS: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLSTATISTICS: *pfExists = TRUE; break;
|
case SQL_API_SQLSTATISTICS: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLTABLES: *pfExists = TRUE; break;
|
case SQL_API_SQLTABLES: *pfExists = TRUE; break;
|
||||||
|
|
||||||
// ODBC level 2 functions
|
/* ODBC level 2 functions */
|
||||||
case SQL_API_SQLBROWSECONNECT: *pfExists = FALSE; break;
|
case SQL_API_SQLBROWSECONNECT: *pfExists = FALSE; break;
|
||||||
case SQL_API_SQLCOLUMNPRIVILEGES: *pfExists = FALSE; break;
|
case SQL_API_SQLCOLUMNPRIVILEGES: *pfExists = FALSE; break;
|
||||||
case SQL_API_SQLDATASOURCES: *pfExists = FALSE; break; // only implemented by DM
|
case SQL_API_SQLDATASOURCES: *pfExists = FALSE; break; /* only implemented by DM */
|
||||||
case SQL_API_SQLDESCRIBEPARAM: *pfExists = FALSE; break; // not properly implemented
|
case SQL_API_SQLDESCRIBEPARAM: *pfExists = FALSE; break; /* not properly implemented */
|
||||||
case SQL_API_SQLDRIVERS: *pfExists = FALSE; break; // only implemented by DM
|
case SQL_API_SQLDRIVERS: *pfExists = FALSE; break; /* only implemented by DM */
|
||||||
case SQL_API_SQLEXTENDEDFETCH: *pfExists = TRUE; break;
|
case SQL_API_SQLEXTENDEDFETCH: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLFOREIGNKEYS: *pfExists = TRUE; break;
|
case SQL_API_SQLFOREIGNKEYS: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLMORERESULTS: *pfExists = TRUE; break;
|
case SQL_API_SQLMORERESULTS: *pfExists = TRUE; break;
|
||||||
|
@ -876,7 +876,7 @@ static char *func="SQLGetFunctions";
|
||||||
case SQL_API_SQLPROCEDURECOLUMNS: *pfExists = FALSE; break;
|
case SQL_API_SQLPROCEDURECOLUMNS: *pfExists = FALSE; break;
|
||||||
case SQL_API_SQLPROCEDURES: *pfExists = FALSE; break;
|
case SQL_API_SQLPROCEDURES: *pfExists = FALSE; break;
|
||||||
case SQL_API_SQLSETPOS: *pfExists = TRUE; break;
|
case SQL_API_SQLSETPOS: *pfExists = TRUE; break;
|
||||||
case SQL_API_SQLSETSCROLLOPTIONS: *pfExists = TRUE; break; // odbc 1.0
|
case SQL_API_SQLSETSCROLLOPTIONS: *pfExists = TRUE; break; /* odbc 1.0 */
|
||||||
case SQL_API_SQLTABLEPRIVILEGES: *pfExists = FALSE; break;
|
case SQL_API_SQLTABLEPRIVILEGES: *pfExists = FALSE; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -935,9 +935,9 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
}
|
}
|
||||||
tbl_stmt = (StatementClass *) htbl_stmt;
|
tbl_stmt = (StatementClass *) htbl_stmt;
|
||||||
|
|
||||||
// **********************************************************************
|
/* ********************************************************************** */
|
||||||
// Create the query to find out the tables
|
/* Create the query to find out the tables */
|
||||||
// **********************************************************************
|
/* ********************************************************************** */
|
||||||
|
|
||||||
strcpy(tables_query, "select relname, usename, relhasrules from pg_class, pg_user");
|
strcpy(tables_query, "select relname, usename, relhasrules from pg_class, pg_user");
|
||||||
strcat(tables_query, " where relkind = 'r'");
|
strcat(tables_query, " where relkind = 'r'");
|
||||||
|
@ -946,7 +946,7 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
my_strcat(tables_query, " and relname like '%.*s'", szTableName, cbTableName);
|
my_strcat(tables_query, " and relname like '%.*s'", szTableName, cbTableName);
|
||||||
|
|
||||||
|
|
||||||
// Parse the extra systable prefix
|
/* Parse the extra systable prefix */
|
||||||
strcpy(prefixes, globals.extra_systable_prefixes);
|
strcpy(prefixes, globals.extra_systable_prefixes);
|
||||||
i = 0;
|
i = 0;
|
||||||
prefix[i] = strtok(prefixes, ";");
|
prefix[i] = strtok(prefixes, ";");
|
||||||
|
@ -1012,7 +1012,7 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
strcat(tables_query, " and int4out(usesysid) = int4out(relowner)");
|
strcat(tables_query, " and int4out(usesysid) = int4out(relowner)");
|
||||||
strcat(tables_query, "order by relname");
|
strcat(tables_query, "order by relname");
|
||||||
|
|
||||||
// **********************************************************************
|
/* ********************************************************************** */
|
||||||
|
|
||||||
result = SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query));
|
result = SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query));
|
||||||
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||||
|
@ -1061,11 +1061,11 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the binding structure for a statement is not set up until
|
/* the binding structure for a statement is not set up until */
|
||||||
// a statement is actually executed, so we'll have to do this ourselves.
|
/* a statement is actually executed, so we'll have to do this ourselves. */
|
||||||
extend_bindings(stmt, 5);
|
extend_bindings(stmt, 5);
|
||||||
|
|
||||||
// set the field names
|
/* set the field names */
|
||||||
QR_set_num_fields(stmt->result, 5);
|
QR_set_num_fields(stmt->result, 5);
|
||||||
QR_set_field_info(stmt->result, 0, "TABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 0, "TABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
QR_set_field_info(stmt->result, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
|
@ -1073,7 +1073,7 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
QR_set_field_info(stmt->result, 3, "TABLE_TYPE", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 3, "TABLE_TYPE", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
QR_set_field_info(stmt->result, 4, "REMARKS", PG_TYPE_TEXT, 254);
|
QR_set_field_info(stmt->result, 4, "REMARKS", PG_TYPE_TEXT, 254);
|
||||||
|
|
||||||
// add the tuples
|
/* add the tuples */
|
||||||
result = SQLFetch(htbl_stmt);
|
result = SQLFetch(htbl_stmt);
|
||||||
while((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) {
|
while((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) {
|
||||||
|
|
||||||
|
@ -1118,11 +1118,11 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
|
|
||||||
set_tuplefield_string(&row->tuple[0], "");
|
set_tuplefield_string(&row->tuple[0], "");
|
||||||
|
|
||||||
// I have to hide the table owner from Access, otherwise it
|
/* I have to hide the table owner from Access, otherwise it */
|
||||||
// insists on referring to the table as 'owner.table'.
|
/* insists on referring to the table as 'owner.table'. */
|
||||||
// (this is valid according to the ODBC SQL grammar, but
|
/* (this is valid according to the ODBC SQL grammar, but */
|
||||||
// Postgres won't support it.)
|
/* Postgres won't support it.) */
|
||||||
// set_tuplefield_string(&row->tuple[1], table_owner);
|
/* set_tuplefield_string(&row->tuple[1], table_owner); */
|
||||||
|
|
||||||
mylog("SQLTables: table_name = '%s'\n", table_name);
|
mylog("SQLTables: table_name = '%s'\n", table_name);
|
||||||
|
|
||||||
|
@ -1143,11 +1143,11 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// also, things need to think that this statement is finished so
|
/* also, things need to think that this statement is finished so */
|
||||||
// the results can be retrieved.
|
/* the results can be retrieved. */
|
||||||
stmt->status = STMT_FINISHED;
|
stmt->status = STMT_FINISHED;
|
||||||
|
|
||||||
// set up the current tuple pointer for SQLFetch
|
/* set up the current tuple pointer for SQLFetch */
|
||||||
stmt->currTuple = -1;
|
stmt->currTuple = -1;
|
||||||
stmt->rowset_start = -1;
|
stmt->rowset_start = -1;
|
||||||
stmt->current_col = -1;
|
stmt->current_col = -1;
|
||||||
|
@ -1198,9 +1198,9 @@ ConnInfo *ci;
|
||||||
|
|
||||||
ci = &stmt->hdbc->connInfo;
|
ci = &stmt->hdbc->connInfo;
|
||||||
|
|
||||||
// **********************************************************************
|
/* ********************************************************************** */
|
||||||
// Create the query to find out the columns (Note: pre 6.3 did not have the atttypmod field)
|
/* Create the query to find out the columns (Note: pre 6.3 did not have the atttypmod field) */
|
||||||
// **********************************************************************
|
/* ********************************************************************** */
|
||||||
sprintf(columns_query, "select u.usename, c.relname, a.attname, a.atttypid"
|
sprintf(columns_query, "select u.usename, c.relname, a.attname, a.atttypid"
|
||||||
", t.typname, a.attnum, a.attlen, %s, a.attnotnull, c.relhasrules"
|
", t.typname, a.attnum, a.attlen, %s, a.attnotnull, c.relhasrules"
|
||||||
" from pg_user u, pg_class c, pg_attribute a, pg_type t"
|
" from pg_user u, pg_class c, pg_attribute a, pg_type t"
|
||||||
|
@ -1212,10 +1212,10 @@ ConnInfo *ci;
|
||||||
my_strcat(columns_query, " and u.usename like '%.*s'", szTableOwner, cbTableOwner);
|
my_strcat(columns_query, " and u.usename like '%.*s'", szTableOwner, cbTableOwner);
|
||||||
my_strcat(columns_query, " and a.attname like '%.*s'", szColumnName, cbColumnName);
|
my_strcat(columns_query, " and a.attname like '%.*s'", szColumnName, cbColumnName);
|
||||||
|
|
||||||
// give the output in the order the columns were defined
|
/* give the output in the order the columns were defined */
|
||||||
// when the table was created
|
/* when the table was created */
|
||||||
strcat(columns_query, " order by attnum");
|
strcat(columns_query, " order by attnum");
|
||||||
// **********************************************************************
|
/* ********************************************************************** */
|
||||||
|
|
||||||
result = SQLAllocStmt( stmt->hdbc, &hcol_stmt);
|
result = SQLAllocStmt( stmt->hdbc, &hcol_stmt);
|
||||||
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||||
|
@ -1347,12 +1347,12 @@ ConnInfo *ci;
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the binding structure for a statement is not set up until
|
/* the binding structure for a statement is not set up until */
|
||||||
// a statement is actually executed, so we'll have to do this ourselves.
|
/* a statement is actually executed, so we'll have to do this ourselves. */
|
||||||
result_cols = 14;
|
result_cols = 14;
|
||||||
extend_bindings(stmt, result_cols);
|
extend_bindings(stmt, result_cols);
|
||||||
|
|
||||||
// set the field names
|
/* set the field names */
|
||||||
QR_set_num_fields(stmt->result, result_cols);
|
QR_set_num_fields(stmt->result, result_cols);
|
||||||
QR_set_field_info(stmt->result, 0, "TABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 0, "TABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
QR_set_field_info(stmt->result, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
|
@ -1367,7 +1367,7 @@ ConnInfo *ci;
|
||||||
QR_set_field_info(stmt->result, 10, "NULLABLE", PG_TYPE_INT2, 2);
|
QR_set_field_info(stmt->result, 10, "NULLABLE", PG_TYPE_INT2, 2);
|
||||||
QR_set_field_info(stmt->result, 11, "REMARKS", PG_TYPE_TEXT, 254);
|
QR_set_field_info(stmt->result, 11, "REMARKS", PG_TYPE_TEXT, 254);
|
||||||
|
|
||||||
// User defined fields
|
/* User defined fields */
|
||||||
QR_set_field_info(stmt->result, 12, "DISPLAY_SIZE", PG_TYPE_INT4, 4);
|
QR_set_field_info(stmt->result, 12, "DISPLAY_SIZE", PG_TYPE_INT4, 4);
|
||||||
QR_set_field_info(stmt->result, 13, "FIELD_TYPE", PG_TYPE_INT4, 4);
|
QR_set_field_info(stmt->result, 13, "FIELD_TYPE", PG_TYPE_INT4, 4);
|
||||||
|
|
||||||
|
@ -1392,8 +1392,8 @@ ConnInfo *ci;
|
||||||
(result_cols - 1) * sizeof(TupleField));
|
(result_cols - 1) * sizeof(TupleField));
|
||||||
|
|
||||||
set_tuplefield_string(&row->tuple[0], "");
|
set_tuplefield_string(&row->tuple[0], "");
|
||||||
// see note in SQLTables()
|
/* see note in SQLTables() */
|
||||||
// set_tuplefield_string(&row->tuple[1], table_owner);
|
/* set_tuplefield_string(&row->tuple[1], table_owner); */
|
||||||
set_tuplefield_string(&row->tuple[1], "");
|
set_tuplefield_string(&row->tuple[1], "");
|
||||||
set_tuplefield_string(&row->tuple[2], table_name);
|
set_tuplefield_string(&row->tuple[2], table_name);
|
||||||
set_tuplefield_string(&row->tuple[3], "oid");
|
set_tuplefield_string(&row->tuple[3], "oid");
|
||||||
|
@ -1422,8 +1422,8 @@ ConnInfo *ci;
|
||||||
|
|
||||||
|
|
||||||
set_tuplefield_string(&row->tuple[0], "");
|
set_tuplefield_string(&row->tuple[0], "");
|
||||||
// see note in SQLTables()
|
/* see note in SQLTables() */
|
||||||
// set_tuplefield_string(&row->tuple[1], table_owner);
|
/* set_tuplefield_string(&row->tuple[1], table_owner); */
|
||||||
set_tuplefield_string(&row->tuple[1], "");
|
set_tuplefield_string(&row->tuple[1], "");
|
||||||
set_tuplefield_string(&row->tuple[2], table_name);
|
set_tuplefield_string(&row->tuple[2], table_name);
|
||||||
set_tuplefield_string(&row->tuple[3], field_name);
|
set_tuplefield_string(&row->tuple[3], field_name);
|
||||||
|
@ -1449,7 +1449,7 @@ ConnInfo *ci;
|
||||||
|
|
||||||
if (field_type == PG_TYPE_NUMERIC) {
|
if (field_type == PG_TYPE_NUMERIC) {
|
||||||
if (mod_length >= 4)
|
if (mod_length >= 4)
|
||||||
mod_length -= 4; // the length is in atttypmod - 4
|
mod_length -= 4; /* the length is in atttypmod - 4 */
|
||||||
|
|
||||||
if (mod_length >= 0) {
|
if (mod_length >= 0) {
|
||||||
useStaticPrecision = FALSE;
|
useStaticPrecision = FALSE;
|
||||||
|
@ -1459,9 +1459,9 @@ ConnInfo *ci;
|
||||||
|
|
||||||
mylog("SQLColumns: field type is NUMERIC: field_type = %d, mod_length=%d, precision=%d, scale=%d\n", field_type, mod_length, precision, scale );
|
mylog("SQLColumns: field type is NUMERIC: field_type = %d, mod_length=%d, precision=%d, scale=%d\n", field_type, mod_length, precision, scale );
|
||||||
|
|
||||||
set_tuplefield_int4(&row->tuple[7], precision + 2); // sign+dec.point
|
set_tuplefield_int4(&row->tuple[7], precision + 2); /* sign+dec.point */
|
||||||
set_tuplefield_int4(&row->tuple[6], precision);
|
set_tuplefield_int4(&row->tuple[6], precision);
|
||||||
set_tuplefield_int4(&row->tuple[12], precision + 2); // sign+dec.point
|
set_tuplefield_int4(&row->tuple[12], precision + 2); /* sign+dec.point */
|
||||||
set_nullfield_int2(&row->tuple[8], scale);
|
set_nullfield_int2(&row->tuple[8], scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1473,7 +1473,7 @@ ConnInfo *ci;
|
||||||
useStaticPrecision = FALSE;
|
useStaticPrecision = FALSE;
|
||||||
|
|
||||||
if (mod_length >= 4)
|
if (mod_length >= 4)
|
||||||
mod_length -= 4; // the length is in atttypmod - 4
|
mod_length -= 4; /* the length is in atttypmod - 4 */
|
||||||
|
|
||||||
if (mod_length > globals.max_varchar_size || mod_length <= 0)
|
if (mod_length > globals.max_varchar_size || mod_length <= 0)
|
||||||
mod_length = globals.max_varchar_size;
|
mod_length = globals.max_varchar_size;
|
||||||
|
@ -1514,8 +1514,8 @@ ConnInfo *ci;
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put the row version column at the end so it might not be
|
/* Put the row version column at the end so it might not be */
|
||||||
// mistaken for a key field.
|
/* mistaken for a key field. */
|
||||||
if ( relhasrules[0] != '1' && ! stmt->internal && atoi(ci->row_versioning)) {
|
if ( relhasrules[0] != '1' && ! stmt->internal && atoi(ci->row_versioning)) {
|
||||||
/* For Row Versioning fields */
|
/* For Row Versioning fields */
|
||||||
the_type = PG_TYPE_INT4;
|
the_type = PG_TYPE_INT4;
|
||||||
|
@ -1541,11 +1541,11 @@ ConnInfo *ci;
|
||||||
QR_add_tuple(stmt->result, row);
|
QR_add_tuple(stmt->result, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
// also, things need to think that this statement is finished so
|
/* also, things need to think that this statement is finished so */
|
||||||
// the results can be retrieved.
|
/* the results can be retrieved. */
|
||||||
stmt->status = STMT_FINISHED;
|
stmt->status = STMT_FINISHED;
|
||||||
|
|
||||||
// set up the current tuple pointer for SQLFetch
|
/* set up the current tuple pointer for SQLFetch */
|
||||||
stmt->currTuple = -1;
|
stmt->currTuple = -1;
|
||||||
stmt->rowset_start = -1;
|
stmt->rowset_start = -1;
|
||||||
stmt->current_col = -1;
|
stmt->current_col = -1;
|
||||||
|
@ -1590,9 +1590,9 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
stmt->manual_result = TRUE;
|
stmt->manual_result = TRUE;
|
||||||
|
|
||||||
|
|
||||||
// **********************************************************************
|
/* ********************************************************************** */
|
||||||
// Create the query to find out if this is a view or not...
|
/* Create the query to find out if this is a view or not... */
|
||||||
// **********************************************************************
|
/* ********************************************************************** */
|
||||||
sprintf(columns_query, "select c.relhasrules "
|
sprintf(columns_query, "select c.relhasrules "
|
||||||
"from pg_user u, pg_class c where "
|
"from pg_user u, pg_class c where "
|
||||||
"u.usesysid = c.relowner");
|
"u.usesysid = c.relowner");
|
||||||
|
@ -1749,11 +1749,11 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the binding structure for a statement is not set up until
|
/* the binding structure for a statement is not set up until */
|
||||||
// a statement is actually executed, so we'll have to do this ourselves.
|
/* a statement is actually executed, so we'll have to do this ourselves. */
|
||||||
extend_bindings(stmt, 13);
|
extend_bindings(stmt, 13);
|
||||||
|
|
||||||
// set the field names
|
/* set the field names */
|
||||||
QR_set_num_fields(stmt->result, 13);
|
QR_set_num_fields(stmt->result, 13);
|
||||||
QR_set_field_info(stmt->result, 0, "TABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 0, "TABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
QR_set_field_info(stmt->result, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
|
@ -1770,8 +1770,8 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
QR_set_field_info(stmt->result, 12, "FILTER_CONDITION", PG_TYPE_TEXT, MAX_INFO_STRING);
|
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
|
/* only use the table name... the owner should be redundant, and */
|
||||||
// we never use qualifiers.
|
/* we never use qualifiers. */
|
||||||
table_name = make_string(szTableName, cbTableName, NULL);
|
table_name = make_string(szTableName, cbTableName, NULL);
|
||||||
if ( ! table_name) {
|
if ( ! table_name) {
|
||||||
stmt->errormsg = "No table name passed to SQLStatistics.";
|
stmt->errormsg = "No table name passed to SQLStatistics.";
|
||||||
|
@ -1780,8 +1780,8 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to get a list of the field names first,
|
/* we need to get a list of the field names first, */
|
||||||
// so we can return them later.
|
/* so we can return them later. */
|
||||||
result = SQLAllocStmt( stmt->hdbc, &hcol_stmt);
|
result = SQLAllocStmt( stmt->hdbc, &hcol_stmt);
|
||||||
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||||
stmt->errormsg = "SQLAllocStmt failed in SQLStatistics for columns.";
|
stmt->errormsg = "SQLAllocStmt failed in SQLStatistics for columns.";
|
||||||
|
@ -1800,8 +1800,8 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
col_stmt->internal = FALSE;
|
col_stmt->internal = FALSE;
|
||||||
|
|
||||||
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||||
stmt->errormsg = col_stmt->errormsg; // "SQLColumns failed in SQLStatistics.";
|
stmt->errormsg = col_stmt->errormsg; /* "SQLColumns failed in SQLStatistics."; */
|
||||||
stmt->errornumber = col_stmt->errornumber; // STMT_EXEC_ERROR;
|
stmt->errornumber = col_stmt->errornumber; /* STMT_EXEC_ERROR; */
|
||||||
SQLFreeStmt(hcol_stmt, SQL_DROP);
|
SQLFreeStmt(hcol_stmt, SQL_DROP);
|
||||||
goto SEEYA;
|
goto SEEYA;
|
||||||
}
|
}
|
||||||
|
@ -1831,7 +1831,7 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
result = SQLFetch(hcol_stmt);
|
result = SQLFetch(hcol_stmt);
|
||||||
}
|
}
|
||||||
if(result != SQL_NO_DATA_FOUND || total_columns == 0) {
|
if(result != SQL_NO_DATA_FOUND || total_columns == 0) {
|
||||||
stmt->errormsg = SC_create_errormsg(hcol_stmt); // "Couldn't get column names in SQLStatistics.";
|
stmt->errormsg = SC_create_errormsg(hcol_stmt); /* "Couldn't get column names in SQLStatistics."; */
|
||||||
stmt->errornumber = col_stmt->errornumber;
|
stmt->errornumber = col_stmt->errornumber;
|
||||||
SQLFreeStmt(hcol_stmt, SQL_DROP);
|
SQLFreeStmt(hcol_stmt, SQL_DROP);
|
||||||
goto SEEYA;
|
goto SEEYA;
|
||||||
|
@ -1840,7 +1840,7 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
|
|
||||||
SQLFreeStmt(hcol_stmt, SQL_DROP);
|
SQLFreeStmt(hcol_stmt, SQL_DROP);
|
||||||
|
|
||||||
// get a list of indexes on this table
|
/* get a list of indexes on this table */
|
||||||
result = SQLAllocStmt( stmt->hdbc, &hindx_stmt);
|
result = SQLAllocStmt( stmt->hdbc, &hindx_stmt);
|
||||||
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||||
stmt->errormsg = "SQLAllocStmt failed in SQLStatistics for indices.";
|
stmt->errormsg = "SQLAllocStmt failed in SQLStatistics for indices.";
|
||||||
|
@ -1858,48 +1858,48 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
|
|
||||||
result = SQLExecDirect(hindx_stmt, index_query, strlen(index_query));
|
result = SQLExecDirect(hindx_stmt, index_query, strlen(index_query));
|
||||||
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||||
stmt->errormsg = SC_create_errormsg(hindx_stmt); // "Couldn't execute index query (w/SQLExecDirect) in SQLStatistics.";
|
stmt->errormsg = SC_create_errormsg(hindx_stmt); /* "Couldn't execute index query (w/SQLExecDirect) in SQLStatistics."; */
|
||||||
stmt->errornumber = indx_stmt->errornumber;
|
stmt->errornumber = indx_stmt->errornumber;
|
||||||
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
||||||
goto SEEYA;
|
goto SEEYA;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// bind the index name column
|
/* bind the index name column */
|
||||||
result = SQLBindCol(hindx_stmt, 1, SQL_C_CHAR,
|
result = SQLBindCol(hindx_stmt, 1, SQL_C_CHAR,
|
||||||
index_name, MAX_INFO_STRING, &index_name_len);
|
index_name, MAX_INFO_STRING, &index_name_len);
|
||||||
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||||
stmt->errormsg = indx_stmt->errormsg; // "Couldn't bind column in SQLStatistics.";
|
stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column in SQLStatistics."; */
|
||||||
stmt->errornumber = indx_stmt->errornumber;
|
stmt->errornumber = indx_stmt->errornumber;
|
||||||
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
||||||
goto SEEYA;
|
goto SEEYA;
|
||||||
|
|
||||||
}
|
}
|
||||||
// bind the vector column
|
/* bind the vector column */
|
||||||
result = SQLBindCol(hindx_stmt, 2, SQL_C_DEFAULT,
|
result = SQLBindCol(hindx_stmt, 2, SQL_C_DEFAULT,
|
||||||
fields_vector, 16, &fields_vector_len);
|
fields_vector, 16, &fields_vector_len);
|
||||||
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||||
stmt->errormsg = indx_stmt->errormsg; // "Couldn't bind column in SQLStatistics.";
|
stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column in SQLStatistics."; */
|
||||||
stmt->errornumber = indx_stmt->errornumber;
|
stmt->errornumber = indx_stmt->errornumber;
|
||||||
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
||||||
goto SEEYA;
|
goto SEEYA;
|
||||||
|
|
||||||
}
|
}
|
||||||
// bind the "is unique" column
|
/* bind the "is unique" column */
|
||||||
result = SQLBindCol(hindx_stmt, 3, SQL_C_CHAR,
|
result = SQLBindCol(hindx_stmt, 3, SQL_C_CHAR,
|
||||||
isunique, sizeof(isunique), NULL);
|
isunique, sizeof(isunique), NULL);
|
||||||
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||||
stmt->errormsg = indx_stmt->errormsg; // "Couldn't bind column in SQLStatistics.";
|
stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column in SQLStatistics."; */
|
||||||
stmt->errornumber = indx_stmt->errornumber;
|
stmt->errornumber = indx_stmt->errornumber;
|
||||||
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
||||||
goto SEEYA;
|
goto SEEYA;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bind the "is clustered" column
|
/* bind the "is clustered" column */
|
||||||
result = SQLBindCol(hindx_stmt, 4, SQL_C_CHAR,
|
result = SQLBindCol(hindx_stmt, 4, SQL_C_CHAR,
|
||||||
isclustered, sizeof(isclustered), NULL);
|
isclustered, sizeof(isclustered), NULL);
|
||||||
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
|
||||||
stmt->errormsg = indx_stmt->errormsg; // "Couldn't bind column in SQLStatistics.";
|
stmt->errormsg = indx_stmt->errormsg; /* "Couldn't bind column in SQLStatistics."; */
|
||||||
stmt->errornumber = indx_stmt->errornumber;
|
stmt->errornumber = indx_stmt->errornumber;
|
||||||
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
||||||
goto SEEYA;
|
goto SEEYA;
|
||||||
|
@ -1920,22 +1920,22 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
row = (TupleNode *)malloc(sizeof(TupleNode) +
|
row = (TupleNode *)malloc(sizeof(TupleNode) +
|
||||||
(13 - 1) * sizeof(TupleField));
|
(13 - 1) * sizeof(TupleField));
|
||||||
|
|
||||||
// no table qualifier
|
/* no table qualifier */
|
||||||
set_tuplefield_string(&row->tuple[0], "");
|
set_tuplefield_string(&row->tuple[0], "");
|
||||||
// don't set the table owner, else Access tries to use it
|
/* don't set the table owner, else Access tries to use it */
|
||||||
set_tuplefield_string(&row->tuple[1], "");
|
set_tuplefield_string(&row->tuple[1], "");
|
||||||
set_tuplefield_string(&row->tuple[2], table_name);
|
set_tuplefield_string(&row->tuple[2], table_name);
|
||||||
|
|
||||||
// non-unique index?
|
/* non-unique index? */
|
||||||
set_tuplefield_int2(&row->tuple[3], (Int2) (globals.unique_index ? FALSE : TRUE));
|
set_tuplefield_int2(&row->tuple[3], (Int2) (globals.unique_index ? FALSE : TRUE));
|
||||||
|
|
||||||
// no index qualifier
|
/* no index qualifier */
|
||||||
set_tuplefield_string(&row->tuple[4], "");
|
set_tuplefield_string(&row->tuple[4], "");
|
||||||
|
|
||||||
sprintf(buf, "%s_idx_fake_oid", table_name);
|
sprintf(buf, "%s_idx_fake_oid", table_name);
|
||||||
set_tuplefield_string(&row->tuple[5], buf);
|
set_tuplefield_string(&row->tuple[5], buf);
|
||||||
|
|
||||||
// Clustered index? I think non-clustered should be type OTHER not HASHED
|
/* Clustered index? I think non-clustered should be type OTHER not HASHED */
|
||||||
set_tuplefield_int2(&row->tuple[6], (Int2) SQL_INDEX_OTHER);
|
set_tuplefield_int2(&row->tuple[6], (Int2) SQL_INDEX_OTHER);
|
||||||
set_tuplefield_int2(&row->tuple[7], (Int2) 1);
|
set_tuplefield_int2(&row->tuple[7], (Int2) 1);
|
||||||
|
|
||||||
|
@ -1951,33 +1951,33 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
result = SQLFetch(hindx_stmt);
|
result = SQLFetch(hindx_stmt);
|
||||||
while((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) {
|
while((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) {
|
||||||
|
|
||||||
// If only requesting unique indexs, then just return those.
|
/* If only requesting unique indexs, then just return those. */
|
||||||
if (fUnique == SQL_INDEX_ALL ||
|
if (fUnique == SQL_INDEX_ALL ||
|
||||||
(fUnique == SQL_INDEX_UNIQUE && atoi(isunique))) {
|
(fUnique == SQL_INDEX_UNIQUE && atoi(isunique))) {
|
||||||
i = 0;
|
i = 0;
|
||||||
// add a row in this table for each field in the index
|
/* add a row in this table for each field in the index */
|
||||||
while(i < 8 && fields_vector[i] != 0) {
|
while(i < 8 && fields_vector[i] != 0) {
|
||||||
|
|
||||||
row = (TupleNode *)malloc(sizeof(TupleNode) +
|
row = (TupleNode *)malloc(sizeof(TupleNode) +
|
||||||
(13 - 1) * sizeof(TupleField));
|
(13 - 1) * sizeof(TupleField));
|
||||||
|
|
||||||
// no table qualifier
|
/* no table qualifier */
|
||||||
set_tuplefield_string(&row->tuple[0], "");
|
set_tuplefield_string(&row->tuple[0], "");
|
||||||
// don't set the table owner, else Access tries to use it
|
/* don't set the table owner, else Access tries to use it */
|
||||||
set_tuplefield_string(&row->tuple[1], "");
|
set_tuplefield_string(&row->tuple[1], "");
|
||||||
set_tuplefield_string(&row->tuple[2], table_name);
|
set_tuplefield_string(&row->tuple[2], table_name);
|
||||||
|
|
||||||
// non-unique index?
|
/* non-unique index? */
|
||||||
if (globals.unique_index)
|
if (globals.unique_index)
|
||||||
set_tuplefield_int2(&row->tuple[3], (Int2) (atoi(isunique) ? FALSE : TRUE));
|
set_tuplefield_int2(&row->tuple[3], (Int2) (atoi(isunique) ? FALSE : TRUE));
|
||||||
else
|
else
|
||||||
set_tuplefield_int2(&row->tuple[3], TRUE);
|
set_tuplefield_int2(&row->tuple[3], TRUE);
|
||||||
|
|
||||||
// no index qualifier
|
/* no index qualifier */
|
||||||
set_tuplefield_string(&row->tuple[4], "");
|
set_tuplefield_string(&row->tuple[4], "");
|
||||||
set_tuplefield_string(&row->tuple[5], index_name);
|
set_tuplefield_string(&row->tuple[5], index_name);
|
||||||
|
|
||||||
// Clustered index? I think non-clustered should be type OTHER not HASHED
|
/* Clustered index? I think non-clustered should be type OTHER not HASHED */
|
||||||
set_tuplefield_int2(&row->tuple[6], (Int2) (atoi(isclustered) ? SQL_INDEX_CLUSTERED : SQL_INDEX_OTHER));
|
set_tuplefield_int2(&row->tuple[6], (Int2) (atoi(isclustered) ? SQL_INDEX_CLUSTERED : SQL_INDEX_OTHER));
|
||||||
set_tuplefield_int2(&row->tuple[7], (Int2) (i+1));
|
set_tuplefield_int2(&row->tuple[7], (Int2) (i+1));
|
||||||
|
|
||||||
|
@ -2007,7 +2007,7 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
result = SQLFetch(hindx_stmt);
|
result = SQLFetch(hindx_stmt);
|
||||||
}
|
}
|
||||||
if(result != SQL_NO_DATA_FOUND) {
|
if(result != SQL_NO_DATA_FOUND) {
|
||||||
stmt->errormsg = SC_create_errormsg(hindx_stmt); // "SQLFetch failed in SQLStatistics.";
|
stmt->errormsg = SC_create_errormsg(hindx_stmt); /* "SQLFetch failed in SQLStatistics."; */
|
||||||
stmt->errornumber = indx_stmt->errornumber;
|
stmt->errornumber = indx_stmt->errornumber;
|
||||||
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
||||||
goto SEEYA;
|
goto SEEYA;
|
||||||
|
@ -2015,11 +2015,11 @@ mylog("%s: entering...stmt=%u\n", func, stmt);
|
||||||
|
|
||||||
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
SQLFreeStmt(hindx_stmt, SQL_DROP);
|
||||||
|
|
||||||
// also, things need to think that this statement is finished so
|
/* also, things need to think that this statement is finished so */
|
||||||
// the results can be retrieved.
|
/* the results can be retrieved. */
|
||||||
stmt->status = STMT_FINISHED;
|
stmt->status = STMT_FINISHED;
|
||||||
|
|
||||||
// set up the current tuple pointer for SQLFetch
|
/* set up the current tuple pointer for SQLFetch */
|
||||||
stmt->currTuple = -1;
|
stmt->currTuple = -1;
|
||||||
stmt->rowset_start = -1;
|
stmt->rowset_start = -1;
|
||||||
stmt->current_col = -1;
|
stmt->current_col = -1;
|
||||||
|
@ -2108,12 +2108,12 @@ Int2 result_cols;
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the binding structure for a statement is not set up until
|
/* the binding structure for a statement is not set up until */
|
||||||
// a statement is actually executed, so we'll have to do this ourselves.
|
/* a statement is actually executed, so we'll have to do this ourselves. */
|
||||||
result_cols = 6;
|
result_cols = 6;
|
||||||
extend_bindings(stmt, result_cols);
|
extend_bindings(stmt, result_cols);
|
||||||
|
|
||||||
// set the field names
|
/* set the field names */
|
||||||
QR_set_num_fields(stmt->result, result_cols);
|
QR_set_num_fields(stmt->result, result_cols);
|
||||||
QR_set_field_info(stmt->result, 0, "TABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 0, "TABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
QR_set_field_info(stmt->result, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
|
@ -2218,11 +2218,11 @@ Int2 result_cols;
|
||||||
SQLFreeStmt(htbl_stmt, SQL_DROP);
|
SQLFreeStmt(htbl_stmt, SQL_DROP);
|
||||||
|
|
||||||
|
|
||||||
// also, things need to think that this statement is finished so
|
/* also, things need to think that this statement is finished so */
|
||||||
// the results can be retrieved.
|
/* the results can be retrieved. */
|
||||||
stmt->status = STMT_FINISHED;
|
stmt->status = STMT_FINISHED;
|
||||||
|
|
||||||
// set up the current tuple pointer for SQLFetch
|
/* set up the current tuple pointer for SQLFetch */
|
||||||
stmt->currTuple = -1;
|
stmt->currTuple = -1;
|
||||||
stmt->rowset_start = -1;
|
stmt->rowset_start = -1;
|
||||||
stmt->current_col = -1;
|
stmt->current_col = -1;
|
||||||
|
@ -2281,12 +2281,12 @@ Int2 result_cols;
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the binding structure for a statement is not set up until
|
/* the binding structure for a statement is not set up until */
|
||||||
// a statement is actually executed, so we'll have to do this ourselves.
|
/* a statement is actually executed, so we'll have to do this ourselves. */
|
||||||
result_cols = 14;
|
result_cols = 14;
|
||||||
extend_bindings(stmt, result_cols);
|
extend_bindings(stmt, result_cols);
|
||||||
|
|
||||||
// set the field names
|
/* set the field names */
|
||||||
QR_set_num_fields(stmt->result, result_cols);
|
QR_set_num_fields(stmt->result, result_cols);
|
||||||
QR_set_field_info(stmt->result, 0, "PKTABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 0, "PKTABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
QR_set_field_info(stmt->result, 1, "PKTABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 1, "PKTABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
|
@ -2303,11 +2303,11 @@ Int2 result_cols;
|
||||||
QR_set_field_info(stmt->result, 12, "PK_NAME", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 12, "PK_NAME", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
QR_set_field_info(stmt->result, 13, "TRIGGER_NAME", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 13, "TRIGGER_NAME", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
|
|
||||||
// also, things need to think that this statement is finished so
|
/* also, things need to think that this statement is finished so */
|
||||||
// the results can be retrieved.
|
/* the results can be retrieved. */
|
||||||
stmt->status = STMT_FINISHED;
|
stmt->status = STMT_FINISHED;
|
||||||
|
|
||||||
// set up the current tuple pointer for SQLFetch
|
/* set up the current tuple pointer for SQLFetch */
|
||||||
stmt->currTuple = -1;
|
stmt->currTuple = -1;
|
||||||
stmt->rowset_start = -1;
|
stmt->rowset_start = -1;
|
||||||
stmt->current_col = -1;
|
stmt->current_col = -1;
|
||||||
|
@ -2475,7 +2475,7 @@ Int2 result_cols;
|
||||||
|
|
||||||
set_tuplefield_string(&row->tuple[2], prel);
|
set_tuplefield_string(&row->tuple[2], prel);
|
||||||
|
|
||||||
// Get to the primary key
|
/* Get to the primary key */
|
||||||
ptr += strlen(ptr) + 1;
|
ptr += strlen(ptr) + 1;
|
||||||
|
|
||||||
mylog("prel = '%s', ptr = '%s'\n", prel, ptr);
|
mylog("prel = '%s', ptr = '%s'\n", prel, ptr);
|
||||||
|
@ -2499,7 +2499,7 @@ Int2 result_cols;
|
||||||
|
|
||||||
QR_add_tuple(stmt->result, row);
|
QR_add_tuple(stmt->result, row);
|
||||||
|
|
||||||
// next foreign key
|
/* next foreign key */
|
||||||
fkptr += strlen(fkptr) + 1;
|
fkptr += strlen(fkptr) + 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2609,13 +2609,13 @@ Int2 result_cols;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (result == SQL_SUCCESS) {
|
while (result == SQL_SUCCESS) {
|
||||||
// Get the number of tables
|
/* Get the number of tables */
|
||||||
ptr = args;
|
ptr = args;
|
||||||
ntabs = atoi(args);
|
ntabs = atoi(args);
|
||||||
ptr += strlen(ptr) + 1;
|
ptr += strlen(ptr) + 1;
|
||||||
|
|
||||||
|
|
||||||
// Handle action (i.e., 'cascade', 'restrict', 'setnull')
|
/* Handle action (i.e., 'cascade', 'restrict', 'setnull') */
|
||||||
switch(tolower(ptr[0])) {
|
switch(tolower(ptr[0])) {
|
||||||
case 'c':
|
case 'c':
|
||||||
action = SQL_CASCADE;
|
action = SQL_CASCADE;
|
||||||
|
@ -2634,7 +2634,7 @@ Int2 result_cols;
|
||||||
rule_type >>= TRIGGER_SHIFT;
|
rule_type >>= TRIGGER_SHIFT;
|
||||||
ptr += strlen(ptr) + 1;
|
ptr += strlen(ptr) + 1;
|
||||||
|
|
||||||
// Calculate the number of key parts
|
/* Calculate the number of key parts */
|
||||||
pkeys = (nargs - ( 2 + ntabs)) / (ntabs + 1);
|
pkeys = (nargs - ( 2 + ntabs)) / (ntabs + 1);
|
||||||
pkey_ptr = ptr;
|
pkey_ptr = ptr;
|
||||||
|
|
||||||
|
@ -2644,10 +2644,10 @@ Int2 result_cols;
|
||||||
ntabs = 0;
|
ntabs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get to the last primary keypart
|
/* Get to the last primary keypart */
|
||||||
for (i = 1; i < pkeys; i++) {
|
for (i = 1; i < pkeys; i++) {
|
||||||
|
|
||||||
// If keypart doesnt match, skip this entry
|
/* If keypart doesnt match, skip this entry */
|
||||||
if ( keyresult != SQL_SUCCESS || strcmp(pkey, ptr)) {
|
if ( keyresult != SQL_SUCCESS || strcmp(pkey, ptr)) {
|
||||||
ntabs = 0;
|
ntabs = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -2660,7 +2660,7 @@ Int2 result_cols;
|
||||||
mylog("Foreign Key Case#1: nargs = %d, ntabs = %d, pkeys = %d\n", nargs, ntabs, pkeys);
|
mylog("Foreign Key Case#1: nargs = %d, ntabs = %d, pkeys = %d\n", nargs, ntabs, pkeys);
|
||||||
|
|
||||||
|
|
||||||
// Get Foreign Key Tables
|
/* Get Foreign Key Tables */
|
||||||
for (i = 0; i < ntabs; i++) {
|
for (i = 0; i < ntabs; i++) {
|
||||||
|
|
||||||
seq = 0;
|
seq = 0;
|
||||||
|
@ -2685,7 +2685,7 @@ Int2 result_cols;
|
||||||
set_tuplefield_string(&row->tuple[5], "");
|
set_tuplefield_string(&row->tuple[5], "");
|
||||||
set_tuplefield_string(&row->tuple[6], frel);
|
set_tuplefield_string(&row->tuple[6], frel);
|
||||||
|
|
||||||
// Get to the foreign key
|
/* Get to the foreign key */
|
||||||
ptr += strlen(ptr) + 1;
|
ptr += strlen(ptr) + 1;
|
||||||
|
|
||||||
set_tuplefield_string(&row->tuple[7], ptr);
|
set_tuplefield_string(&row->tuple[7], ptr);
|
||||||
|
@ -2705,7 +2705,7 @@ Int2 result_cols;
|
||||||
|
|
||||||
QR_add_tuple(stmt->result, row);
|
QR_add_tuple(stmt->result, row);
|
||||||
|
|
||||||
// next primary key
|
/* next primary key */
|
||||||
pkptr += strlen(pkptr) + 1;
|
pkptr += strlen(pkptr) + 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ int retval, result_len;
|
||||||
argv[0].u.integer = mode;
|
argv[0].u.integer = mode;
|
||||||
|
|
||||||
if ( ! CC_send_function(conn, LO_CREAT, &retval, &result_len, 1, argv, 1))
|
if ( ! CC_send_function(conn, LO_CREAT, &retval, &result_len, 1, argv, 1))
|
||||||
return 0; // invalid oid
|
return 0; /* invalid oid */
|
||||||
else
|
else
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
|
|
|
@ -169,10 +169,10 @@ my_strcpy(char *dst, int dst_len, char *src, int src_len)
|
||||||
return strlen(dst);
|
return strlen(dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
// strncpy copies up to len characters, and doesn't terminate
|
/* strncpy copies up to len characters, and doesn't terminate */
|
||||||
// the destination string if src has len characters or more.
|
/* the destination string if src has len characters or more. */
|
||||||
// instead, I want it to copy up to len-1 characters and always
|
/* instead, I want it to copy up to len-1 characters and always */
|
||||||
// terminate the destination string.
|
/* terminate the destination string. */
|
||||||
char *strncpy_null(char *dst, const char *src, int len)
|
char *strncpy_null(char *dst, const char *src, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -199,9 +199,9 @@ int i;
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a null terminated string (handling the SQL_NTS thing):
|
/* Create a null terminated string (handling the SQL_NTS thing): */
|
||||||
// 1. If buf is supplied, place the string in there (assumes enough space) and return buf.
|
/* 1. If buf is supplied, place the string in there (assumes enough space) and return buf. */
|
||||||
// 2. If buf is not supplied, malloc space and return this string
|
/* 2. If buf is not supplied, malloc space and return this string */
|
||||||
char *
|
char *
|
||||||
make_string(char *s, int len, char *buf)
|
make_string(char *s, int len, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -227,10 +227,10 @@ char *str;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Concatenate a single formatted argument to a given buffer handling the SQL_NTS thing.
|
/* Concatenate a single formatted argument to a given buffer handling the SQL_NTS thing. */
|
||||||
// "fmt" must contain somewhere in it the single form '%.*s'
|
/* "fmt" must contain somewhere in it the single form '%.*s' */
|
||||||
// This is heavily used in creating queries for info routines (SQLTables, SQLColumns).
|
/* This is heavily used in creating queries for info routines (SQLTables, SQLColumns). */
|
||||||
// This routine could be modified to use vsprintf() to handle multiple arguments.
|
/* This routine could be modified to use vsprintf() to handle multiple arguments. */
|
||||||
char *
|
char *
|
||||||
my_strcat(char *buf, char *fmt, char *s, int len)
|
my_strcat(char *buf, char *fmt, char *s, int len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#define mylog(args...) /* GNU convention for variable arguments */
|
#define mylog(args...) /* GNU convention for variable arguments */
|
||||||
#else
|
#else
|
||||||
#define mylog // mylog
|
#define mylog /* mylog */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#define qlog(args...) /* GNU convention for variable arguments */
|
#define qlog(args...) /* GNU convention for variable arguments */
|
||||||
#else
|
#else
|
||||||
#define qlog // qlog
|
#define qlog /* qlog */
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,8 @@ char changed = FALSE;
|
||||||
else {
|
else {
|
||||||
if (vParam == SQL_CURSOR_FORWARD_ONLY || vParam == SQL_CURSOR_STATIC) {
|
if (vParam == SQL_CURSOR_FORWARD_ONLY || vParam == SQL_CURSOR_STATIC) {
|
||||||
|
|
||||||
if (conn) conn->stmtOptions.cursor_type = vParam; // valid type
|
if (conn) conn->stmtOptions.cursor_type = vParam; /* valid type */
|
||||||
if (stmt) stmt->options.cursor_type = vParam; // valid type
|
if (stmt) stmt->options.cursor_type = vParam; /* valid type */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ char changed = FALSE;
|
||||||
|
|
||||||
case SQL_QUERY_TIMEOUT: /* ignored */
|
case SQL_QUERY_TIMEOUT: /* ignored */
|
||||||
mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", vParam);
|
mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", vParam);
|
||||||
// "0" returned in SQLGetStmtOption
|
/* "0" returned in SQLGetStmtOption */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SQL_RETRIEVE_DATA: /* ignored, but saved */
|
case SQL_RETRIEVE_DATA: /* ignored, but saved */
|
||||||
|
@ -390,7 +390,7 @@ int i;
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
/* This function just can tell you whether you are in Autcommit mode or not */
|
/* This function just can tell you whether you are in Autcommit mode or not */
|
||||||
RETCODE SQL_API SQLGetConnectOption(
|
RETCODE SQL_API SQLGetConnectOption(
|
||||||
|
@ -465,7 +465,7 @@ ConnectionClass *conn = (ConnectionClass *) hdbc;
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
RETCODE SQL_API SQLSetStmtOption(
|
RETCODE SQL_API SQLSetStmtOption(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -477,9 +477,9 @@ StatementClass *stmt = (StatementClass *) hstmt;
|
||||||
|
|
||||||
mylog("%s: entering...\n", func);
|
mylog("%s: entering...\n", func);
|
||||||
|
|
||||||
// thought we could fake Access out by just returning SQL_SUCCESS
|
/* 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
|
/* 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
|
/* and expects the driver to reduce it to the real value */
|
||||||
|
|
||||||
if( ! stmt) {
|
if( ! stmt) {
|
||||||
SC_log_error(func, "", NULL);
|
SC_log_error(func, "", NULL);
|
||||||
|
@ -490,7 +490,7 @@ StatementClass *stmt = (StatementClass *) hstmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
RETCODE SQL_API SQLGetStmtOption(
|
RETCODE SQL_API SQLGetStmtOption(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -503,9 +503,9 @@ QResultClass *res;
|
||||||
|
|
||||||
mylog("%s: entering...\n", func);
|
mylog("%s: entering...\n", func);
|
||||||
|
|
||||||
// thought we could fake Access out by just returning SQL_SUCCESS
|
/* 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
|
/* 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
|
/* and expects the driver to reduce it to the real value */
|
||||||
|
|
||||||
if( ! stmt) {
|
if( ! stmt) {
|
||||||
SC_log_error(func, "", NULL);
|
SC_log_error(func, "", NULL);
|
||||||
|
@ -519,7 +519,7 @@ QResultClass *res;
|
||||||
res = stmt->result;
|
res = stmt->result;
|
||||||
|
|
||||||
if ( stmt->manual_result || ! globals.use_declarefetch) {
|
if ( stmt->manual_result || ! globals.use_declarefetch) {
|
||||||
// make sure we're positioned on a valid row
|
/* make sure we're positioned on a valid row */
|
||||||
if((stmt->currTuple < 0) ||
|
if((stmt->currTuple < 0) ||
|
||||||
(stmt->currTuple >= QR_get_num_tuples(res))) {
|
(stmt->currTuple >= QR_get_num_tuples(res))) {
|
||||||
stmt->errormsg = "Not positioned on a valid row.";
|
stmt->errormsg = "Not positioned on a valid row.";
|
||||||
|
@ -618,4 +618,4 @@ QResultClass *res;
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
|
@ -56,7 +56,7 @@ char qc, in_escape = FALSE;
|
||||||
|
|
||||||
/* skip leading delimiters */
|
/* skip leading delimiters */
|
||||||
while (isspace(s[i]) || s[i] == ',') {
|
while (isspace(s[i]) || s[i] == ',') {
|
||||||
// mylog("skipping '%c'\n", s[i]);
|
/* mylog("skipping '%c'\n", s[i]); */
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ char qc, in_escape = FALSE;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// mylog("done -- s[%d] = '%c'\n", i, s[i]);
|
/* mylog("done -- s[%d] = '%c'\n", i, s[i]); */
|
||||||
|
|
||||||
token[out] = '\0';
|
token[out] = '\0';
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ char qc, in_escape = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
#if 0
|
||||||
QR_set_num_fields(stmt->result, 14);
|
QR_set_num_fields(stmt->result, 14);
|
||||||
QR_set_field_info(stmt->result, 0, "TABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 0, "TABLE_QUALIFIER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
QR_set_field_info(stmt->result, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
QR_set_field_info(stmt->result, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
|
||||||
|
@ -170,10 +170,10 @@ QR_set_field_info(stmt->result, 8, "SCALE", PG_TYPE_INT2, 2);
|
||||||
QR_set_field_info(stmt->result, 9, "RADIX", PG_TYPE_INT2, 2);
|
QR_set_field_info(stmt->result, 9, "RADIX", PG_TYPE_INT2, 2);
|
||||||
QR_set_field_info(stmt->result, 10, "NULLABLE", PG_TYPE_INT2, 2);
|
QR_set_field_info(stmt->result, 10, "NULLABLE", PG_TYPE_INT2, 2);
|
||||||
QR_set_field_info(stmt->result, 11, "REMARKS", PG_TYPE_TEXT, 254);
|
QR_set_field_info(stmt->result, 11, "REMARKS", PG_TYPE_TEXT, 254);
|
||||||
// User defined fields
|
/* User defined fields */
|
||||||
QR_set_field_info(stmt->result, 12, "DISPLAY_SIZE", PG_TYPE_INT4, 4);
|
QR_set_field_info(stmt->result, 12, "DISPLAY_SIZE", PG_TYPE_INT4, 4);
|
||||||
QR_set_field_info(stmt->result, 13, "FIELD_TYPE", PG_TYPE_INT4, 4);
|
QR_set_field_info(stmt->result, 13, "FIELD_TYPE", PG_TYPE_INT4, 4);
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k)
|
getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k)
|
||||||
|
@ -676,7 +676,7 @@ RETCODE result;
|
||||||
total_cols--; /* makes up for the star */
|
total_cols--; /* makes up for the star */
|
||||||
|
|
||||||
/* Allocate some more field pointers if necessary */
|
/* Allocate some more field pointers if necessary */
|
||||||
//-------------------------------------------------------------
|
/*------------------------------------------------------------- */
|
||||||
old_size = (stmt->nfld / FLD_INCR * FLD_INCR + FLD_INCR);
|
old_size = (stmt->nfld / FLD_INCR * FLD_INCR + FLD_INCR);
|
||||||
need = total_cols - (old_size - stmt->nfld);
|
need = total_cols - (old_size - stmt->nfld);
|
||||||
|
|
||||||
|
@ -692,22 +692,22 @@ RETCODE result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
/*------------------------------------------------------------- */
|
||||||
// copy any other fields (if there are any) up past the expansion
|
/* copy any other fields (if there are any) up past the expansion */
|
||||||
for (j = stmt->nfld - 1; j > i; j--) {
|
for (j = stmt->nfld - 1; j > i; j--) {
|
||||||
mylog("copying field %d to %d\n", j, total_cols + j);
|
mylog("copying field %d to %d\n", j, total_cols + j);
|
||||||
fi[total_cols + j] = fi[j];
|
fi[total_cols + j] = fi[j];
|
||||||
}
|
}
|
||||||
mylog("done copying fields\n");
|
mylog("done copying fields\n");
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
/*------------------------------------------------------------- */
|
||||||
// Set the new number of fields
|
/* Set the new number of fields */
|
||||||
stmt->nfld += total_cols;
|
stmt->nfld += total_cols;
|
||||||
mylog("stmt->nfld now at %d\n", stmt->nfld);
|
mylog("stmt->nfld now at %d\n", stmt->nfld);
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
/*------------------------------------------------------------- */
|
||||||
// copy the new field info
|
/* copy the new field info */
|
||||||
|
|
||||||
|
|
||||||
do_all_tables = (fi[i]->ti ? FALSE : TRUE);
|
do_all_tables = (fi[i]->ti ? FALSE : TRUE);
|
||||||
|
@ -720,7 +720,7 @@ RETCODE result;
|
||||||
|
|
||||||
for (n = 0; n < cols; n++) {
|
for (n = 0; n < cols; n++) {
|
||||||
mylog("creating field info: n=%d\n", n);
|
mylog("creating field info: n=%d\n", n);
|
||||||
// skip malloc (already did it for the Star)
|
/* skip malloc (already did it for the Star) */
|
||||||
if (k > 0 || n > 0) {
|
if (k > 0 || n > 0) {
|
||||||
mylog("allocating field info at %d\n", n + i);
|
mylog("allocating field info at %d\n", n + i);
|
||||||
fi[n + i] = (FIELD_INFO *) malloc( sizeof(FIELD_INFO));
|
fi[n + i] = (FIELD_INFO *) malloc( sizeof(FIELD_INFO));
|
||||||
|
@ -744,7 +744,7 @@ RETCODE result;
|
||||||
mylog("i now at %d\n", i);
|
mylog("i now at %d\n", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------
|
/*------------------------------------------------------------- */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We either know which table the field was in because it was qualified
|
/* We either know which table the field was in because it was qualified
|
||||||
|
|
|
@ -737,8 +737,8 @@ char *pgtype_create_params(StatementClass *stmt, Int4 type)
|
||||||
|
|
||||||
Int2 sqltype_to_default_ctype(Int2 sqltype)
|
Int2 sqltype_to_default_ctype(Int2 sqltype)
|
||||||
{
|
{
|
||||||
// from the table on page 623 of ODBC 2.0 Programmer's Reference
|
/* from the table on page 623 of ODBC 2.0 Programmer's Reference */
|
||||||
// (Appendix D)
|
/* (Appendix D) */
|
||||||
switch(sqltype) {
|
switch(sqltype) {
|
||||||
case SQL_CHAR:
|
case SQL_CHAR:
|
||||||
case SQL_VARCHAR:
|
case SQL_VARCHAR:
|
||||||
|
|
|
@ -16,7 +16,9 @@
|
||||||
/* in table pg_type */
|
/* in table pg_type */
|
||||||
|
|
||||||
|
|
||||||
// #define PG_TYPE_LO ???? /* waiting for permanent type */
|
#if 0
|
||||||
|
#define PG_TYPE_LO ???? /* waiting for permanent type */
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PG_TYPE_BOOL 16
|
#define PG_TYPE_BOOL 16
|
||||||
#define PG_TYPE_BYTEA 17
|
#define PG_TYPE_BYTEA 17
|
||||||
|
|
|
@ -83,7 +83,7 @@ typedef UInt4 Oid;
|
||||||
/* Info limits */
|
/* Info limits */
|
||||||
#define MAX_INFO_STRING 128
|
#define MAX_INFO_STRING 128
|
||||||
#define MAX_KEYPARTS 20
|
#define MAX_KEYPARTS 20
|
||||||
#define MAX_KEYLEN 512 // max key of the form "date+outlet+invoice"
|
#define MAX_KEYLEN 512 /* max key of the form "date+outlet+invoice" */
|
||||||
#define MAX_STATEMENT_LEN MAX_MESSAGE_LEN
|
#define MAX_STATEMENT_LEN MAX_MESSAGE_LEN
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -125,14 +125,14 @@ QR_Destructor(QResultClass *self)
|
||||||
if (self->manual_tuples)
|
if (self->manual_tuples)
|
||||||
TL_Destructor(self->manual_tuples);
|
TL_Destructor(self->manual_tuples);
|
||||||
|
|
||||||
// If conn is defined, then we may have used "backend_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.
|
/* 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))
|
if (self->conn && self->conn->sock && CC_is_in_trans(self->conn))
|
||||||
QR_close(self); // close the cursor if there is one
|
QR_close(self); /* close the cursor if there is one */
|
||||||
|
|
||||||
QR_free_memory(self); // safe to call anyway
|
QR_free_memory(self); /* safe to call anyway */
|
||||||
|
|
||||||
// Should have been freed in the close() but just in case...
|
/* Should have been freed in the close() but just in case... */
|
||||||
if (self->cursor)
|
if (self->cursor)
|
||||||
free(self->cursor);
|
free(self->cursor);
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ int num_fields = self->num_fields;
|
||||||
free(tuple[lf].value);
|
free(tuple[lf].value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tuple += num_fields; // next row
|
tuple += num_fields; /* next row */
|
||||||
}
|
}
|
||||||
|
|
||||||
free(self->backend_tuples);
|
free(self->backend_tuples);
|
||||||
|
@ -204,17 +204,17 @@ int num_fields = self->num_fields;
|
||||||
mylog("QResult: free memory out\n");
|
mylog("QResult: free memory out\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is called by send_query()
|
/* This function is called by send_query() */
|
||||||
char
|
char
|
||||||
QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor)
|
QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor)
|
||||||
{
|
{
|
||||||
int tuple_size;
|
int tuple_size;
|
||||||
|
|
||||||
// If called from send_query the first time (conn != NULL),
|
/* If called from send_query the first time (conn != NULL), */
|
||||||
// then set the inTuples state,
|
/* then set the inTuples state, */
|
||||||
// and read the tuples. If conn is NULL,
|
/* and read the tuples. If conn is NULL, */
|
||||||
// it implies that we are being called from next_tuple(),
|
/* it implies that we are being called from next_tuple(), */
|
||||||
// like to get more rows so don't call next_tuple again!
|
/* like to get more rows so don't call next_tuple again! */
|
||||||
if (conn != NULL) {
|
if (conn != NULL) {
|
||||||
self->conn = conn;
|
self->conn = conn;
|
||||||
|
|
||||||
|
@ -232,8 +232,8 @@ int tuple_size;
|
||||||
self->cursor = strdup(cursor);
|
self->cursor = strdup(cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the field attributes.
|
/* Read the field attributes. */
|
||||||
// $$$$ Should do some error control HERE! $$$$
|
/* $$$$ Should do some error control HERE! $$$$ */
|
||||||
if ( CI_read_fields(self->fields, self->conn)) {
|
if ( CI_read_fields(self->fields, self->conn)) {
|
||||||
self->status = PGRES_FIELDS_OK;
|
self->status = PGRES_FIELDS_OK;
|
||||||
self->num_fields = CI_get_num_fields(self->fields);
|
self->num_fields = CI_get_num_fields(self->fields);
|
||||||
|
@ -272,8 +272,8 @@ int tuple_size;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// Always have to read the field attributes.
|
/* Always have to read the field attributes. */
|
||||||
// But we dont have to reallocate memory for them!
|
/* But we dont have to reallocate memory for them! */
|
||||||
|
|
||||||
if ( ! CI_read_fields(NULL, self->conn)) {
|
if ( ! CI_read_fields(NULL, self->conn)) {
|
||||||
self->status = PGRES_BAD_RESPONSE;
|
self->status = PGRES_BAD_RESPONSE;
|
||||||
|
@ -284,8 +284,8 @@ int tuple_size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the cursor and end the transaction (if no cursors left)
|
/* Close the cursor and end the transaction (if no cursors left) */
|
||||||
// We only close cursor/end the transaction if a cursor was used.
|
/* We only close cursor/end the transaction if a cursor was used. */
|
||||||
int
|
int
|
||||||
QR_close(QResultClass *self)
|
QR_close(QResultClass *self)
|
||||||
{
|
{
|
||||||
|
@ -331,7 +331,7 @@ QResultClass *res;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function is called by fetch_tuples() AND SQLFetch()
|
/* This function is called by fetch_tuples() AND SQLFetch() */
|
||||||
int
|
int
|
||||||
QR_next_tuple(QResultClass *self)
|
QR_next_tuple(QResultClass *self)
|
||||||
{
|
{
|
||||||
|
@ -346,7 +346,7 @@ int end_tuple = self->rowset_size + self->base;
|
||||||
char corrected = FALSE;
|
char corrected = FALSE;
|
||||||
TupleField *the_tuples = self->backend_tuples;
|
TupleField *the_tuples = self->backend_tuples;
|
||||||
static char msgbuffer[MAX_MESSAGE_LEN+1];
|
static char msgbuffer[MAX_MESSAGE_LEN+1];
|
||||||
char cmdbuffer[MAX_MESSAGE_LEN+1]; // QR_set_command() dups this string so dont need static
|
char cmdbuffer[MAX_MESSAGE_LEN+1]; /* QR_set_command() dups this string so dont need static */
|
||||||
char fetch[128];
|
char fetch[128];
|
||||||
QueryInfo qi;
|
QueryInfo qi;
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ QueryInfo qi;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if (self->fcount < self->cache_size) { /* last row from cache */
|
else if (self->fcount < self->cache_size) { /* last row from cache */
|
||||||
// We are done because we didn't even get CACHE_SIZE tuples
|
/* We are done because we didn't even get CACHE_SIZE tuples */
|
||||||
mylog("next_tuple: fcount < CACHE_SIZE: fcount = %d, fetch_count = %d\n", fcount, fetch_count);
|
mylog("next_tuple: fcount < CACHE_SIZE: fcount = %d, fetch_count = %d\n", fcount, fetch_count);
|
||||||
self->tupleField = NULL;
|
self->tupleField = NULL;
|
||||||
self->status = PGRES_END_TUPLES;
|
self->status = PGRES_END_TUPLES;
|
||||||
|
@ -417,7 +417,7 @@ QueryInfo qi;
|
||||||
|
|
||||||
mylog("next_tuple: sending actual fetch (%d) query '%s'\n", fetch_size, fetch);
|
mylog("next_tuple: sending actual fetch (%d) query '%s'\n", fetch_size, fetch);
|
||||||
|
|
||||||
// don't read ahead for the next tuple (self) !
|
/* don't read ahead for the next tuple (self) ! */
|
||||||
qi.row_size = self->cache_size;
|
qi.row_size = self->cache_size;
|
||||||
qi.result_in = self;
|
qi.result_in = self;
|
||||||
qi.cursor = NULL;
|
qi.cursor = NULL;
|
||||||
|
@ -479,7 +479,7 @@ QueryInfo qi;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->fcount++;
|
self->fcount++;
|
||||||
break; // continue reading
|
break; /* continue reading */
|
||||||
|
|
||||||
|
|
||||||
case 'C': /* End of tuple list */
|
case 'C': /* End of tuple list */
|
||||||
|
@ -498,7 +498,7 @@ QueryInfo qi;
|
||||||
self->tupleField = self->backend_tuples + (offset * self->num_fields);
|
self->tupleField = self->backend_tuples + (offset * self->num_fields);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else { // We are surely done here (we read 0 tuples)
|
else { /* We are surely done here (we read 0 tuples) */
|
||||||
qlog(" [ fetched 0 rows ]\n");
|
qlog(" [ fetched 0 rows ]\n");
|
||||||
mylog("_next_tuple: 'C': DONE (fcount == 0)\n");
|
mylog("_next_tuple: 'C': DONE (fcount == 0)\n");
|
||||||
return -1; /* end of tuples */
|
return -1; /* end of tuples */
|
||||||
|
@ -546,7 +546,7 @@ Int2 bitmap_pos;
|
||||||
Int2 bitcnt;
|
Int2 bitcnt;
|
||||||
Int4 len;
|
Int4 len;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int num_fields = self->num_fields; // speed up access
|
int num_fields = self->num_fields; /* speed up access */
|
||||||
SocketClass *sock = CC_get_socket(self->conn);
|
SocketClass *sock = CC_get_socket(self->conn);
|
||||||
ColumnInfoClass *flds;
|
ColumnInfoClass *flds;
|
||||||
|
|
||||||
|
|
|
@ -37,31 +37,31 @@ typedef enum QueryResultCode_ QueryResultCode;
|
||||||
|
|
||||||
|
|
||||||
struct QResultClass_ {
|
struct QResultClass_ {
|
||||||
ColumnInfoClass *fields; // the Column information
|
ColumnInfoClass *fields; /* the Column information */
|
||||||
TupleListClass *manual_tuples; // manual result tuple list
|
TupleListClass *manual_tuples; /* manual result tuple list */
|
||||||
ConnectionClass *conn; // the connection this result is using (backend)
|
ConnectionClass *conn; /* the connection this result is using (backend) */
|
||||||
|
|
||||||
// Stuff for declare/fetch tuples
|
/* Stuff for declare/fetch tuples */
|
||||||
int fetch_count; // logical rows read so far
|
int fetch_count; /* logical rows read so far */
|
||||||
int fcount; // actual rows read in the fetch
|
int fcount; /* actual rows read in the fetch */
|
||||||
int currTuple;
|
int currTuple;
|
||||||
int base;
|
int base;
|
||||||
|
|
||||||
int num_fields; // number of fields in the result
|
int num_fields; /* number of fields in the result */
|
||||||
int cache_size;
|
int cache_size;
|
||||||
int rowset_size;
|
int rowset_size;
|
||||||
|
|
||||||
QueryResultCode status;
|
QueryResultCode status;
|
||||||
|
|
||||||
char *message;
|
char *message;
|
||||||
char *cursor; // The name of the cursor for select statements
|
char *cursor; /* The name of the cursor for select statements */
|
||||||
char *command;
|
char *command;
|
||||||
char *notice;
|
char *notice;
|
||||||
|
|
||||||
TupleField *backend_tuples; // data from the backend (the tuple cache)
|
TupleField *backend_tuples; /* data from the backend (the tuple cache) */
|
||||||
TupleField *tupleField; // current backend tuple being retrieved
|
TupleField *tupleField; /* current backend tuple being retrieved */
|
||||||
|
|
||||||
char inTuples; // is a fetch of rows from the backend in progress?
|
char inTuples; /* is a fetch of rows from the backend in progress? */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define QR_get_fields(self) (self->fields)
|
#define QR_get_fields(self) (self->fields)
|
||||||
|
@ -97,7 +97,7 @@ struct QResultClass_ {
|
||||||
#define QR_get_notice(self) (self->notice)
|
#define QR_get_notice(self) (self->notice)
|
||||||
#define QR_get_status(self) (self->status)
|
#define QR_get_status(self) (self->status)
|
||||||
|
|
||||||
// Core Functions
|
/* Core Functions */
|
||||||
QResultClass *QR_Constructor(void);
|
QResultClass *QR_Constructor(void);
|
||||||
void QR_Destructor(QResultClass *self);
|
void QR_Destructor(QResultClass *self);
|
||||||
char QR_read_tuple(QResultClass *self, char binary);
|
char QR_read_tuple(QResultClass *self, char binary);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//{{NO_DEPENDENCIES}}
|
/*{{NO_DEPENDENCIES}} */
|
||||||
// Microsoft Developer Studio generated include file.
|
/* Microsoft Developer Studio generated include file. */
|
||||||
// Used by psqlodbc.rc
|
/* Used by psqlodbc.rc */
|
||||||
//
|
/* */
|
||||||
#define IDS_BADDSN 1
|
#define IDS_BADDSN 1
|
||||||
#define IDS_MSGTITLE 2
|
#define IDS_MSGTITLE 2
|
||||||
#define DLG_OPTIONS_DRV 102
|
#define DLG_OPTIONS_DRV 102
|
||||||
|
@ -50,8 +50,8 @@
|
||||||
#define DS_PG64 1057
|
#define DS_PG64 1057
|
||||||
#define DS_PG63 1058
|
#define DS_PG63 1058
|
||||||
|
|
||||||
// Next default values for new objects
|
/* Next default values for new objects */
|
||||||
//
|
/* */
|
||||||
#ifdef APSTUDIO_INVOKED
|
#ifdef APSTUDIO_INVOKED
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 104
|
#define _APS_NEXT_RESOURCE_VALUE 104
|
||||||
|
|
|
@ -78,7 +78,7 @@ char *msg, *ptr;
|
||||||
if (res && pcrow) {
|
if (res && pcrow) {
|
||||||
msg = QR_get_command(res);
|
msg = QR_get_command(res);
|
||||||
mylog("*** msg = '%s'\n", msg);
|
mylog("*** msg = '%s'\n", msg);
|
||||||
trim(msg); // get rid of trailing spaces
|
trim(msg); /* get rid of trailing spaces */
|
||||||
ptr = strrchr(msg, ' ');
|
ptr = strrchr(msg, ' ');
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
*pcrow = atoi(ptr+1);
|
*pcrow = atoi(ptr+1);
|
||||||
|
@ -99,8 +99,8 @@ char *msg, *ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This returns the number of columns associated with the database
|
/* This returns the number of columns associated with the database */
|
||||||
// attached to "hstmt".
|
/* attached to "hstmt". */
|
||||||
|
|
||||||
|
|
||||||
RETCODE SQL_API SQLNumResultCols(
|
RETCODE SQL_API SQLNumResultCols(
|
||||||
|
@ -155,12 +155,12 @@ char parse_ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// - - - - - - - - -
|
/* - - - - - - - - - */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Return information about the database column the user wants
|
/* Return information about the database column the user wants */
|
||||||
// information about.
|
/* information about. */
|
||||||
RETCODE SQL_API SQLDescribeCol(
|
RETCODE SQL_API SQLDescribeCol(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
UWORD icol,
|
UWORD icol,
|
||||||
|
@ -264,7 +264,7 @@ RETCODE result;
|
||||||
col_name = QR_get_fieldname(res, icol);
|
col_name = QR_get_fieldname(res, icol);
|
||||||
fieldtype = QR_get_field_type(res, icol);
|
fieldtype = QR_get_field_type(res, icol);
|
||||||
|
|
||||||
precision = pgtype_precision(stmt, fieldtype, icol, globals.unknown_sizes); // atoi(ci->unknown_sizes)
|
precision = pgtype_precision(stmt, fieldtype, icol, globals.unknown_sizes); /* atoi(ci->unknown_sizes) */
|
||||||
}
|
}
|
||||||
|
|
||||||
mylog("describeCol: col %d fieldname = '%s'\n", icol, col_name);
|
mylog("describeCol: col %d fieldname = '%s'\n", icol, col_name);
|
||||||
|
@ -308,7 +308,7 @@ RETCODE result;
|
||||||
if (pcbColDef) {
|
if (pcbColDef) {
|
||||||
|
|
||||||
if ( precision < 0)
|
if ( precision < 0)
|
||||||
precision = 0; // "I dont know"
|
precision = 0; /* "I dont know" */
|
||||||
|
|
||||||
*pcbColDef = precision;
|
*pcbColDef = precision;
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ RETCODE result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns result column descriptor information for a result set.
|
/* Returns result column descriptor information for a result set. */
|
||||||
|
|
||||||
RETCODE SQL_API SQLColAttributes(
|
RETCODE SQL_API SQLColAttributes(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -377,8 +377,8 @@ int len = 0, value = 0;
|
||||||
|
|
||||||
icol--;
|
icol--;
|
||||||
|
|
||||||
unknown_sizes = globals.unknown_sizes; // atoi(ci->unknown_sizes);
|
unknown_sizes = globals.unknown_sizes; /* atoi(ci->unknown_sizes); */
|
||||||
if (unknown_sizes == UNKNOWNS_AS_DONTKNOW) // not appropriate for SQLColAttributes()
|
if (unknown_sizes == UNKNOWNS_AS_DONTKNOW) /* not appropriate for SQLColAttributes() */
|
||||||
unknown_sizes = UNKNOWNS_AS_MAX;
|
unknown_sizes = UNKNOWNS_AS_MAX;
|
||||||
|
|
||||||
parse_ok = FALSE;
|
parse_ok = FALSE;
|
||||||
|
@ -483,7 +483,7 @@ int len = 0, value = 0;
|
||||||
mylog("SQLColAttr: COLUMN_LABEL = '%s'\n", p);
|
mylog("SQLColAttr: COLUMN_LABEL = '%s'\n", p);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} // otherwise same as column name -- FALL THROUGH!!!
|
} /* otherwise same as column name -- FALL THROUGH!!! */
|
||||||
|
|
||||||
case SQL_COLUMN_NAME:
|
case SQL_COLUMN_NAME:
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ int len = 0, value = 0;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns result data for a single column in the current row.
|
/* Returns result data for a single column in the current row. */
|
||||||
|
|
||||||
RETCODE SQL_API SQLGetData(
|
RETCODE SQL_API SQLGetData(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -657,10 +657,10 @@ mylog("SQLGetData: enter, stmt=%u\n", stmt);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// use zero-based column numbers
|
/* use zero-based column numbers */
|
||||||
icol--;
|
icol--;
|
||||||
|
|
||||||
// make sure the column number is valid
|
/* make sure the column number is valid */
|
||||||
num_cols = QR_NumResultCols(res);
|
num_cols = QR_NumResultCols(res);
|
||||||
if (icol >= num_cols) {
|
if (icol >= num_cols) {
|
||||||
stmt->errormsg = "Invalid column number.";
|
stmt->errormsg = "Invalid column number.";
|
||||||
|
@ -671,7 +671,7 @@ mylog("SQLGetData: enter, stmt=%u\n", stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( stmt->manual_result || ! globals.use_declarefetch) {
|
if ( stmt->manual_result || ! globals.use_declarefetch) {
|
||||||
// make sure we're positioned on a valid row
|
/* make sure we're positioned on a valid row */
|
||||||
num_rows = QR_get_num_tuples(res);
|
num_rows = QR_get_num_tuples(res);
|
||||||
if((stmt->currTuple < 0) ||
|
if((stmt->currTuple < 0) ||
|
||||||
(stmt->currTuple >= num_rows)) {
|
(stmt->currTuple >= num_rows)) {
|
||||||
|
@ -765,8 +765,8 @@ mylog("SQLGetData: enter, stmt=%u\n", stmt);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Returns data for bound columns in the current row ("hstmt->iCursor"),
|
/* Returns data for bound columns in the current row ("hstmt->iCursor"), */
|
||||||
// advances the cursor.
|
/* advances the cursor. */
|
||||||
|
|
||||||
RETCODE SQL_API SQLFetch(
|
RETCODE SQL_API SQLFetch(
|
||||||
HSTMT hstmt)
|
HSTMT hstmt)
|
||||||
|
@ -815,8 +815,8 @@ mylog("SQLFetch: stmt = %u, stmt->result= %u\n", stmt, stmt->result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmt->bindings == NULL) {
|
if (stmt->bindings == NULL) {
|
||||||
// just to avoid a crash if the user insists on calling this
|
/* just to avoid a crash if the user insists on calling this */
|
||||||
// function even if SQL_ExecDirect has reported an Error
|
/* function even if SQL_ExecDirect has reported an Error */
|
||||||
stmt->errormsg = "Bindings were not allocated properly.";
|
stmt->errormsg = "Bindings were not allocated properly.";
|
||||||
stmt->errornumber = STMT_SEQUENCE_ERROR;
|
stmt->errornumber = STMT_SEQUENCE_ERROR;
|
||||||
SC_log_error(func, "", stmt);
|
SC_log_error(func, "", stmt);
|
||||||
|
@ -829,7 +829,7 @@ mylog("SQLFetch: stmt = %u, stmt->result= %u\n", stmt, stmt->result);
|
||||||
return SC_fetch(stmt);
|
return SC_fetch(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This fetchs a block of data (rowset).
|
/* This fetchs a block of data (rowset). */
|
||||||
|
|
||||||
RETCODE SQL_API SQLExtendedFetch(
|
RETCODE SQL_API SQLExtendedFetch(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -892,8 +892,8 @@ mylog("SQLExtendedFetch: stmt=%u\n", stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmt->bindings == NULL) {
|
if (stmt->bindings == NULL) {
|
||||||
// just to avoid a crash if the user insists on calling this
|
/* just to avoid a crash if the user insists on calling this */
|
||||||
// function even if SQL_ExecDirect has reported an Error
|
/* function even if SQL_ExecDirect has reported an Error */
|
||||||
stmt->errormsg = "Bindings were not allocated properly.";
|
stmt->errormsg = "Bindings were not allocated properly.";
|
||||||
stmt->errornumber = STMT_SEQUENCE_ERROR;
|
stmt->errornumber = STMT_SEQUENCE_ERROR;
|
||||||
SC_log_error(func, "", stmt);
|
SC_log_error(func, "", stmt);
|
||||||
|
@ -1050,7 +1050,7 @@ mylog("SQLExtendedFetch: stmt=%u\n", stmt);
|
||||||
truncated = error = FALSE;
|
truncated = error = FALSE;
|
||||||
for (i = 0; i < stmt->options.rowset_size; i++) {
|
for (i = 0; i < stmt->options.rowset_size; i++) {
|
||||||
|
|
||||||
stmt->bind_row = i; // set the binding location
|
stmt->bind_row = i; /* set the binding location */
|
||||||
result = SC_fetch(stmt);
|
result = SC_fetch(stmt);
|
||||||
|
|
||||||
/* Determine Function status */
|
/* Determine Function status */
|
||||||
|
@ -1100,8 +1100,8 @@ mylog("SQLExtendedFetch: stmt=%u\n", stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This determines whether there are more results sets available for
|
/* This determines whether there are more results sets available for */
|
||||||
// the "hstmt".
|
/* the "hstmt". */
|
||||||
|
|
||||||
/* CC: return SQL_NO_DATA_FOUND since we do not support multiple result sets */
|
/* CC: return SQL_NO_DATA_FOUND since we do not support multiple result sets */
|
||||||
RETCODE SQL_API SQLMoreResults(
|
RETCODE SQL_API SQLMoreResults(
|
||||||
|
@ -1110,8 +1110,8 @@ RETCODE SQL_API SQLMoreResults(
|
||||||
return SQL_NO_DATA_FOUND;
|
return SQL_NO_DATA_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This positions the cursor within a rowset, that was positioned using SQLExtendedFetch.
|
/* This positions the cursor within a rowset, that was positioned using SQLExtendedFetch. */
|
||||||
// This will be useful (so far) only when using SQLGetData after SQLExtendedFetch.
|
/* This will be useful (so far) only when using SQLGetData after SQLExtendedFetch. */
|
||||||
RETCODE SQL_API SQLSetPos(
|
RETCODE SQL_API SQLSetPos(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
UWORD irow,
|
UWORD irow,
|
||||||
|
@ -1172,7 +1172,7 @@ BindInfoClass *bindings = stmt->bindings;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets options that control the behavior of cursors.
|
/* Sets options that control the behavior of cursors. */
|
||||||
|
|
||||||
RETCODE SQL_API SQLSetScrollOptions(
|
RETCODE SQL_API SQLSetScrollOptions(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -1187,7 +1187,7 @@ static char *func = "SQLSetScrollOptions";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set the cursor name on a statement handle
|
/* Set the cursor name on a statement handle */
|
||||||
|
|
||||||
RETCODE SQL_API SQLSetCursorName(
|
RETCODE SQL_API SQLSetCursorName(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
@ -1218,7 +1218,7 @@ mylog("SQLSetCursorName: hstmt=%u, szCursor=%u, cbCursorMax=%d\n", hstmt, szCurs
|
||||||
return SQL_SUCCESS;
|
return SQL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the cursor name for a statement handle
|
/* Return the cursor name for a statement handle */
|
||||||
|
|
||||||
RETCODE SQL_API SQLGetCursorName(
|
RETCODE SQL_API SQLGetCursorName(
|
||||||
HSTMT hstmt,
|
HSTMT hstmt,
|
||||||
|
|
|
@ -29,33 +29,33 @@
|
||||||
extern HINSTANCE NEAR s_hModule; /* Saved module handle. */
|
extern HINSTANCE NEAR s_hModule; /* Saved module handle. */
|
||||||
extern GLOBAL_VALUES globals;
|
extern GLOBAL_VALUES globals;
|
||||||
|
|
||||||
// Constants ---------------------------------------------------------------
|
/* Constants --------------------------------------------------------------- */
|
||||||
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define MAXPGPATH (255+1)
|
#define MAXPGPATH (255+1)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAXKEYLEN (15+1) // Max keyword length
|
#define MAXKEYLEN (15+1) /* Max keyword length */
|
||||||
#define MAXDESC (255+1) // Max description length
|
#define MAXDESC (255+1) /* Max description length */
|
||||||
#define MAXDSNAME (32+1) // Max data source name length
|
#define MAXDSNAME (32+1) /* Max data source name length */
|
||||||
|
|
||||||
|
|
||||||
// Globals -----------------------------------------------------------------
|
/* Globals ----------------------------------------------------------------- */
|
||||||
// NOTE: All these are used by the dialog procedures
|
/* NOTE: All these are used by the dialog procedures */
|
||||||
typedef struct tagSETUPDLG {
|
typedef struct tagSETUPDLG {
|
||||||
HWND hwndParent; // Parent window handle
|
HWND hwndParent; /* Parent window handle */
|
||||||
LPCSTR lpszDrvr; // Driver description
|
LPCSTR lpszDrvr; /* Driver description */
|
||||||
ConnInfo ci;
|
ConnInfo ci;
|
||||||
char szDSN[MAXDSNAME]; // Original data source name
|
char szDSN[MAXDSNAME]; /* Original data source name */
|
||||||
BOOL fNewDSN; // New data source flag
|
BOOL fNewDSN; /* New data source flag */
|
||||||
BOOL fDefault; // Default data source flag
|
BOOL fDefault; /* Default data source flag */
|
||||||
|
|
||||||
} SETUPDLG, FAR *LPSETUPDLG;
|
} SETUPDLG, FAR *LPSETUPDLG;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Prototypes --------------------------------------------------------------
|
/* Prototypes -------------------------------------------------------------- */
|
||||||
void INTFUNC CenterDialog(HWND hdlg);
|
void INTFUNC CenterDialog(HWND hdlg);
|
||||||
int CALLBACK ConfigDlgProc(HWND hdlg, WORD wMsg, WPARAM wParam, LPARAM lParam);
|
int CALLBACK ConfigDlgProc(HWND hdlg, WORD wMsg, WPARAM wParam, LPARAM lParam);
|
||||||
void INTFUNC ParseAttributes (LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg);
|
void INTFUNC ParseAttributes (LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg);
|
||||||
|
@ -78,49 +78,49 @@ BOOL CALLBACK ConfigDSN (HWND hwnd,
|
||||||
LPCSTR lpszDriver,
|
LPCSTR lpszDriver,
|
||||||
LPCSTR lpszAttributes)
|
LPCSTR lpszAttributes)
|
||||||
{
|
{
|
||||||
BOOL fSuccess; // Success/fail flag
|
BOOL fSuccess; /* Success/fail flag */
|
||||||
GLOBALHANDLE hglbAttr;
|
GLOBALHANDLE hglbAttr;
|
||||||
LPSETUPDLG lpsetupdlg;
|
LPSETUPDLG lpsetupdlg;
|
||||||
|
|
||||||
|
|
||||||
// Allocate attribute array
|
/* Allocate attribute array */
|
||||||
hglbAttr = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(SETUPDLG));
|
hglbAttr = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(SETUPDLG));
|
||||||
if (!hglbAttr)
|
if (!hglbAttr)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
lpsetupdlg = (LPSETUPDLG)GlobalLock(hglbAttr);
|
lpsetupdlg = (LPSETUPDLG)GlobalLock(hglbAttr);
|
||||||
|
|
||||||
// Parse attribute string
|
/* Parse attribute string */
|
||||||
if (lpszAttributes)
|
if (lpszAttributes)
|
||||||
ParseAttributes(lpszAttributes, lpsetupdlg);
|
ParseAttributes(lpszAttributes, lpsetupdlg);
|
||||||
|
|
||||||
// Save original data source name
|
/* Save original data source name */
|
||||||
if (lpsetupdlg->ci.dsn[0])
|
if (lpsetupdlg->ci.dsn[0])
|
||||||
lstrcpy(lpsetupdlg->szDSN, lpsetupdlg->ci.dsn);
|
lstrcpy(lpsetupdlg->szDSN, lpsetupdlg->ci.dsn);
|
||||||
else
|
else
|
||||||
lpsetupdlg->szDSN[0] = '\0';
|
lpsetupdlg->szDSN[0] = '\0';
|
||||||
|
|
||||||
// Remove data source
|
/* Remove data source */
|
||||||
if (ODBC_REMOVE_DSN == fRequest) {
|
if (ODBC_REMOVE_DSN == fRequest) {
|
||||||
// Fail if no data source name was supplied
|
/* Fail if no data source name was supplied */
|
||||||
if (!lpsetupdlg->ci.dsn[0])
|
if (!lpsetupdlg->ci.dsn[0])
|
||||||
fSuccess = FALSE;
|
fSuccess = FALSE;
|
||||||
|
|
||||||
// Otherwise remove data source from ODBC.INI
|
/* Otherwise remove data source from ODBC.INI */
|
||||||
else
|
else
|
||||||
fSuccess = SQLRemoveDSNFromIni(lpsetupdlg->ci.dsn);
|
fSuccess = SQLRemoveDSNFromIni(lpsetupdlg->ci.dsn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add or Configure data source
|
/* Add or Configure data source */
|
||||||
else {
|
else {
|
||||||
// Save passed variables for global access (e.g., dialog access)
|
/* Save passed variables for global access (e.g., dialog access) */
|
||||||
lpsetupdlg->hwndParent = hwnd;
|
lpsetupdlg->hwndParent = hwnd;
|
||||||
lpsetupdlg->lpszDrvr = lpszDriver;
|
lpsetupdlg->lpszDrvr = lpszDriver;
|
||||||
lpsetupdlg->fNewDSN = (ODBC_ADD_DSN == fRequest);
|
lpsetupdlg->fNewDSN = (ODBC_ADD_DSN == fRequest);
|
||||||
lpsetupdlg->fDefault = !lstrcmpi(lpsetupdlg->ci.dsn, INI_DSN);
|
lpsetupdlg->fDefault = !lstrcmpi(lpsetupdlg->ci.dsn, INI_DSN);
|
||||||
|
|
||||||
// Display the appropriate dialog (if parent window handle supplied)
|
/* Display the appropriate dialog (if parent window handle supplied) */
|
||||||
if (hwnd) {
|
if (hwnd) {
|
||||||
// Display dialog(s)
|
/* Display dialog(s) */
|
||||||
fSuccess = (IDOK == DialogBoxParam(s_hModule,
|
fSuccess = (IDOK == DialogBoxParam(s_hModule,
|
||||||
MAKEINTRESOURCE(DLG_CONFIG),
|
MAKEINTRESOURCE(DLG_CONFIG),
|
||||||
hwnd,
|
hwnd,
|
||||||
|
@ -202,7 +202,7 @@ int CALLBACK ConfigDlgProc(HWND hdlg,
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (wMsg) {
|
switch (wMsg) {
|
||||||
// Initialize the dialog
|
/* Initialize the dialog */
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
{
|
{
|
||||||
LPSETUPDLG lpsetupdlg = (LPSETUPDLG) lParam;
|
LPSETUPDLG lpsetupdlg = (LPSETUPDLG) lParam;
|
||||||
|
@ -212,19 +212,19 @@ int CALLBACK ConfigDlgProc(HWND hdlg,
|
||||||
ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE);
|
ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE);
|
||||||
|
|
||||||
SetWindowLong(hdlg, DWL_USER, lParam);
|
SetWindowLong(hdlg, DWL_USER, lParam);
|
||||||
CenterDialog(hdlg); // Center dialog
|
CenterDialog(hdlg); /* Center dialog */
|
||||||
|
|
||||||
// NOTE: Values supplied in the attribute string will always
|
/* NOTE: Values supplied in the attribute string will always */
|
||||||
// override settings in ODBC.INI
|
/* override settings in ODBC.INI */
|
||||||
|
|
||||||
// Get the rest of the common attributes
|
/* Get the rest of the common attributes */
|
||||||
getDSNinfo(ci, CONN_DONT_OVERWRITE);
|
getDSNinfo(ci, CONN_DONT_OVERWRITE);
|
||||||
|
|
||||||
// Fill in any defaults
|
/* Fill in any defaults */
|
||||||
getDSNdefaults(ci);
|
getDSNdefaults(ci);
|
||||||
|
|
||||||
|
|
||||||
// Initialize dialog fields
|
/* Initialize dialog fields */
|
||||||
SetDlgStuff(hdlg, ci);
|
SetDlgStuff(hdlg, ci);
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,22 +238,22 @@ int CALLBACK ConfigDlgProc(HWND hdlg,
|
||||||
|
|
||||||
SendDlgItemMessage(hdlg, IDC_DESC,
|
SendDlgItemMessage(hdlg, IDC_DESC,
|
||||||
EM_LIMITTEXT, (WPARAM)(MAXDESC-1), 0L);
|
EM_LIMITTEXT, (WPARAM)(MAXDESC-1), 0L);
|
||||||
return TRUE; // Focus was not set
|
return TRUE; /* Focus was not set */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Process buttons
|
/* Process buttons */
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
|
|
||||||
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
|
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
|
||||||
// Ensure the OK button is enabled only when a data source name
|
/* Ensure the OK button is enabled only when a data source name */
|
||||||
// is entered
|
/* is entered */
|
||||||
case IDC_DSNAME:
|
case IDC_DSNAME:
|
||||||
if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE)
|
if (GET_WM_COMMAND_CMD(wParam, lParam) == EN_CHANGE)
|
||||||
{
|
{
|
||||||
char szItem[MAXDSNAME]; // Edit control text
|
char szItem[MAXDSNAME]; /* Edit control text */
|
||||||
|
|
||||||
// Enable/disable the OK button
|
/* Enable/disable the OK button */
|
||||||
EnableWindow(GetDlgItem(hdlg, IDOK),
|
EnableWindow(GetDlgItem(hdlg, IDOK),
|
||||||
GetDlgItemText(hdlg, IDC_DSNAME,
|
GetDlgItemText(hdlg, IDC_DSNAME,
|
||||||
szItem, sizeof(szItem)));
|
szItem, sizeof(szItem)));
|
||||||
|
@ -262,27 +262,27 @@ int CALLBACK ConfigDlgProc(HWND hdlg,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Accept results
|
/* Accept results */
|
||||||
case IDOK:
|
case IDOK:
|
||||||
{
|
{
|
||||||
LPSETUPDLG lpsetupdlg;
|
LPSETUPDLG lpsetupdlg;
|
||||||
|
|
||||||
lpsetupdlg = (LPSETUPDLG)GetWindowLong(hdlg, DWL_USER);
|
lpsetupdlg = (LPSETUPDLG)GetWindowLong(hdlg, DWL_USER);
|
||||||
// Retrieve dialog values
|
/* Retrieve dialog values */
|
||||||
if (!lpsetupdlg->fDefault)
|
if (!lpsetupdlg->fDefault)
|
||||||
GetDlgItemText(hdlg, IDC_DSNAME,
|
GetDlgItemText(hdlg, IDC_DSNAME,
|
||||||
lpsetupdlg->ci.dsn,
|
lpsetupdlg->ci.dsn,
|
||||||
sizeof(lpsetupdlg->ci.dsn));
|
sizeof(lpsetupdlg->ci.dsn));
|
||||||
|
|
||||||
|
|
||||||
// Get Dialog Values
|
/* Get Dialog Values */
|
||||||
GetDlgStuff(hdlg, &lpsetupdlg->ci);
|
GetDlgStuff(hdlg, &lpsetupdlg->ci);
|
||||||
|
|
||||||
// Update ODBC.INI
|
/* Update ODBC.INI */
|
||||||
SetDSNAttributes(hdlg, lpsetupdlg);
|
SetDSNAttributes(hdlg, lpsetupdlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return to caller
|
/* Return to caller */
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
EndDialog(hdlg, wParam);
|
EndDialog(hdlg, wParam);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -310,7 +310,7 @@ int CALLBACK ConfigDlgProc(HWND hdlg,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Message not processed
|
/* Message not processed */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,16 +331,16 @@ char value[MAXPGPATH];
|
||||||
memset(&lpsetupdlg->ci, 0, sizeof(ConnInfo));
|
memset(&lpsetupdlg->ci, 0, sizeof(ConnInfo));
|
||||||
|
|
||||||
for (lpsz=lpszAttributes; *lpsz; lpsz++)
|
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;
|
lpszStart = lpsz;
|
||||||
for (;; lpsz++)
|
for (;; lpsz++)
|
||||||
{
|
{
|
||||||
if (!*lpsz)
|
if (!*lpsz)
|
||||||
return; // No key was found
|
return; /* No key was found */
|
||||||
else if (*lpsz == '=')
|
else if (*lpsz == '=')
|
||||||
break; // Valid key found
|
break; /* Valid key found */
|
||||||
}
|
}
|
||||||
// Determine the key's index in the key table (-1 if not found)
|
/* Determine the key's index in the key table (-1 if not found) */
|
||||||
cbKey = lpsz - lpszStart;
|
cbKey = lpsz - lpszStart;
|
||||||
if (cbKey < sizeof(aszKey))
|
if (cbKey < sizeof(aszKey))
|
||||||
{
|
{
|
||||||
|
@ -349,17 +349,17 @@ char value[MAXPGPATH];
|
||||||
aszKey[cbKey] = '\0';
|
aszKey[cbKey] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locate end of key value
|
/* Locate end of key value */
|
||||||
lpszStart = ++lpsz;
|
lpszStart = ++lpsz;
|
||||||
for (; *lpsz; lpsz++);
|
for (; *lpsz; lpsz++);
|
||||||
|
|
||||||
|
|
||||||
// lpsetupdlg->aAttr[iElement].fSupplied = TRUE;
|
/* lpsetupdlg->aAttr[iElement].fSupplied = TRUE; */
|
||||||
_fmemcpy(value, lpszStart, MIN(lpsz-lpszStart+1, MAXPGPATH));
|
_fmemcpy(value, lpszStart, MIN(lpsz-lpszStart+1, MAXPGPATH));
|
||||||
|
|
||||||
mylog("aszKey='%s', value='%s'\n", aszKey, value);
|
mylog("aszKey='%s', value='%s'\n", aszKey, value);
|
||||||
|
|
||||||
// Copy the appropriate value to the conninfo
|
/* Copy the appropriate value to the conninfo */
|
||||||
copyAttributes(&lpsetupdlg->ci, aszKey, value);
|
copyAttributes(&lpsetupdlg->ci, aszKey, value);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -374,15 +374,15 @@ char value[MAXPGPATH];
|
||||||
|
|
||||||
BOOL INTFUNC SetDSNAttributes(HWND hwndParent, LPSETUPDLG lpsetupdlg)
|
BOOL INTFUNC SetDSNAttributes(HWND hwndParent, LPSETUPDLG lpsetupdlg)
|
||||||
{
|
{
|
||||||
LPCSTR lpszDSN; // Pointer to data source name
|
LPCSTR lpszDSN; /* Pointer to data source name */
|
||||||
|
|
||||||
lpszDSN = lpsetupdlg->ci.dsn;
|
lpszDSN = lpsetupdlg->ci.dsn;
|
||||||
|
|
||||||
// Validate arguments
|
/* Validate arguments */
|
||||||
if (lpsetupdlg->fNewDSN && !*lpsetupdlg->ci.dsn)
|
if (lpsetupdlg->fNewDSN && !*lpsetupdlg->ci.dsn)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// Write the data source name
|
/* Write the data source name */
|
||||||
if (!SQLWriteDSNToIni(lpszDSN, lpsetupdlg->lpszDrvr))
|
if (!SQLWriteDSNToIni(lpszDSN, lpsetupdlg->lpszDrvr))
|
||||||
{
|
{
|
||||||
if (hwndParent)
|
if (hwndParent)
|
||||||
|
@ -399,11 +399,11 @@ LPCSTR lpszDSN; // Pointer to da
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update ODBC.INI
|
/* Update ODBC.INI */
|
||||||
writeDSNinfo(&lpsetupdlg->ci);
|
writeDSNinfo(&lpsetupdlg->ci);
|
||||||
|
|
||||||
|
|
||||||
// If the data source name has changed, remove the old name
|
/* If the data source name has changed, remove the old name */
|
||||||
if (lstrcmpi(lpsetupdlg->szDSN, lpsetupdlg->ci.dsn))
|
if (lstrcmpi(lpsetupdlg->szDSN, lpsetupdlg->ci.dsn))
|
||||||
{
|
{
|
||||||
SQLRemoveDSNFromIni(lpsetupdlg->szDSN);
|
SQLRemoveDSNFromIni(lpsetupdlg->szDSN);
|
||||||
|
|
|
@ -277,8 +277,8 @@ SOCK_get_next_byte(SocketClass *self)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (self->buffer_read_in >= self->buffer_filled_in) {
|
if (self->buffer_read_in >= self->buffer_filled_in) {
|
||||||
// there are no more bytes left in the buffer ->
|
/* there are no more bytes left in the buffer -> */
|
||||||
// reload the buffer
|
/* reload the buffer */
|
||||||
|
|
||||||
self->buffer_read_in = 0;
|
self->buffer_read_in = 0;
|
||||||
self->buffer_filled_in = recv(self->socket, (char *)self->buffer_in, globals.socket_buffersize, 0);
|
self->buffer_filled_in = recv(self->socket, (char *)self->buffer_in, globals.socket_buffersize, 0);
|
||||||
|
@ -308,7 +308,7 @@ int bytes_sent;
|
||||||
self->buffer_out[self->buffer_filled_out++] = next_byte;
|
self->buffer_out[self->buffer_filled_out++] = next_byte;
|
||||||
|
|
||||||
if (self->buffer_filled_out == globals.socket_buffersize) {
|
if (self->buffer_filled_out == globals.socket_buffersize) {
|
||||||
// buffer is full, so write it out
|
/* buffer is full, so write it out */
|
||||||
bytes_sent = send(self->socket, (char *)self->buffer_out, globals.socket_buffersize, 0);
|
bytes_sent = send(self->socket, (char *)self->buffer_out, globals.socket_buffersize, 0);
|
||||||
if (bytes_sent != globals.socket_buffersize) {
|
if (bytes_sent != globals.socket_buffersize) {
|
||||||
self->errornumber = SOCKET_WRITE_ERROR;
|
self->errornumber = SOCKET_WRITE_ERROR;
|
||||||
|
|
|
@ -152,7 +152,7 @@ StatementClass *stmt = (StatementClass *) hstmt;
|
||||||
/* this should discard all the results, but leave the statement */
|
/* this should discard all the results, but leave the statement */
|
||||||
/* itself in place (it can be executed again) */
|
/* itself in place (it can be executed again) */
|
||||||
if (!SC_recycle_statement(stmt)) {
|
if (!SC_recycle_statement(stmt)) {
|
||||||
// errormsg passed in above
|
/* errormsg passed in above */
|
||||||
SC_log_error(func, "", stmt);
|
SC_log_error(func, "", stmt);
|
||||||
return SQL_ERROR;
|
return SQL_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -178,10 +178,10 @@ StatementClass *stmt = (StatementClass *) hstmt;
|
||||||
void
|
void
|
||||||
InitializeStatementOptions(StatementOptions *opt)
|
InitializeStatementOptions(StatementOptions *opt)
|
||||||
{
|
{
|
||||||
opt->maxRows = 0; // driver returns all rows
|
opt->maxRows = 0; /* driver returns all rows */
|
||||||
opt->maxLength = 0; // driver returns all data for char/binary
|
opt->maxLength = 0; /* driver returns all data for char/binary */
|
||||||
opt->rowset_size = 1;
|
opt->rowset_size = 1;
|
||||||
opt->keyset_size = 0; // fully keyset driven is the default
|
opt->keyset_size = 0; /* fully keyset driven is the default */
|
||||||
opt->scroll_concurrency = SQL_CONCUR_READ_ONLY;
|
opt->scroll_concurrency = SQL_CONCUR_READ_ONLY;
|
||||||
opt->cursor_type = SQL_CURSOR_FORWARD_ONLY;
|
opt->cursor_type = SQL_CURSOR_FORWARD_ONLY;
|
||||||
opt->bind_size = 0; /* default is to bind by column */
|
opt->bind_size = 0; /* default is to bind by column */
|
||||||
|
@ -447,7 +447,7 @@ mylog("recycle statement: self= %u\n", self);
|
||||||
/****************************************************************/
|
/****************************************************************/
|
||||||
|
|
||||||
self->status = STMT_READY;
|
self->status = STMT_READY;
|
||||||
self->manual_result = FALSE; // very important
|
self->manual_result = FALSE; /* very important */
|
||||||
|
|
||||||
self->currTuple = -1;
|
self->currTuple = -1;
|
||||||
self->rowset_start = -1;
|
self->rowset_start = -1;
|
||||||
|
@ -461,9 +461,9 @@ mylog("recycle statement: self= %u\n", self);
|
||||||
|
|
||||||
self->lobj_fd = -1;
|
self->lobj_fd = -1;
|
||||||
|
|
||||||
// Free any data at exec params before the statement is executed
|
/* Free any data at exec params before the statement is executed */
|
||||||
// again. If not, then there will be a memory leak when
|
/* again. If not, then there will be a memory leak when */
|
||||||
// the next SQLParamData/SQLPutData is called.
|
/* the next SQLParamData/SQLPutData is called. */
|
||||||
SC_free_params(self, STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY);
|
SC_free_params(self, STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -517,8 +517,8 @@ SC_clear_error(StatementClass *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This function creates an error msg which is the concatenation
|
/* This function creates an error msg which is the concatenation */
|
||||||
// of the result, statement, connection, and socket messages.
|
/* of the result, statement, connection, and socket messages. */
|
||||||
char *
|
char *
|
||||||
SC_create_errormsg(StatementClass *self)
|
SC_create_errormsg(StatementClass *self)
|
||||||
{
|
{
|
||||||
|
@ -557,7 +557,7 @@ SC_get_error(StatementClass *self, int *number, char **message)
|
||||||
{
|
{
|
||||||
char rv;
|
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) {
|
if ( ! self->errormsg_created) {
|
||||||
self->errormsg = SC_create_errormsg(self);
|
self->errormsg = SC_create_errormsg(self);
|
||||||
self->errormsg_created = TRUE;
|
self->errormsg_created = TRUE;
|
||||||
|
@ -595,7 +595,7 @@ Int2 num_cols, lf;
|
||||||
Oid type;
|
Oid type;
|
||||||
char *value;
|
char *value;
|
||||||
ColumnInfoClass *ci;
|
ColumnInfoClass *ci;
|
||||||
// TupleField *tupleField;
|
/* TupleField *tupleField; */
|
||||||
|
|
||||||
self->last_fetch_count = 0;
|
self->last_fetch_count = 0;
|
||||||
ci = QR_get_fields(res); /* the column info */
|
ci = QR_get_fields(res); /* the column info */
|
||||||
|
@ -619,14 +619,14 @@ ColumnInfoClass *ci;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
// read from the cache or the physical next tuple
|
/* read from the cache or the physical next tuple */
|
||||||
retval = QR_next_tuple(res);
|
retval = QR_next_tuple(res);
|
||||||
if (retval < 0) {
|
if (retval < 0) {
|
||||||
mylog("**** SQLFetch: end_tuples\n");
|
mylog("**** SQLFetch: end_tuples\n");
|
||||||
return SQL_NO_DATA_FOUND;
|
return SQL_NO_DATA_FOUND;
|
||||||
}
|
}
|
||||||
else if (retval > 0)
|
else if (retval > 0)
|
||||||
(self->currTuple)++; // all is well
|
(self->currTuple)++; /* all is well */
|
||||||
|
|
||||||
else {
|
else {
|
||||||
mylog("SQLFetch: error\n");
|
mylog("SQLFetch: error\n");
|
||||||
|
@ -663,9 +663,9 @@ ColumnInfoClass *ci;
|
||||||
self->bindings[lf].data_left = -1;
|
self->bindings[lf].data_left = -1;
|
||||||
|
|
||||||
if (self->bindings[lf].buffer != NULL) {
|
if (self->bindings[lf].buffer != NULL) {
|
||||||
// this column has a binding
|
/* this column has a binding */
|
||||||
|
|
||||||
// type = QR_get_field_type(res, lf);
|
/* type = QR_get_field_type(res, lf); */
|
||||||
type = CI_get_oid(ci, lf); /* speed things up */
|
type = CI_get_oid(ci, lf); /* speed things up */
|
||||||
|
|
||||||
mylog("type = %d\n", type);
|
mylog("type = %d\n", type);
|
||||||
|
@ -783,9 +783,9 @@ QueryInfo qi;
|
||||||
self->status = STMT_EXECUTING;
|
self->status = STMT_EXECUTING;
|
||||||
|
|
||||||
|
|
||||||
// If it's a SELECT statement, use a cursor.
|
/* If it's a SELECT statement, use a cursor. */
|
||||||
// Note that the declare cursor has already been prepended to the statement
|
/* Note that the declare cursor has already been prepended to the statement */
|
||||||
// in copy_statement...
|
/* in copy_statement... */
|
||||||
if (self->statement_type == STMT_TYPE_SELECT) {
|
if (self->statement_type == STMT_TYPE_SELECT) {
|
||||||
|
|
||||||
char fetch[128];
|
char fetch[128];
|
||||||
|
@ -821,11 +821,11 @@ QueryInfo qi;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else { // not a SELECT statement so don't use a cursor
|
else { /* not a SELECT statement so don't use a cursor */
|
||||||
mylog(" it's NOT a select statement: stmt=%u\n", self);
|
mylog(" it's NOT a select statement: stmt=%u\n", self);
|
||||||
self->result = CC_send_query(conn, self->stmt_with_params, NULL);
|
self->result = CC_send_query(conn, self->stmt_with_params, NULL);
|
||||||
|
|
||||||
// If we are in autocommit, we must send the commit.
|
/* If we are in autocommit, we must send the commit. */
|
||||||
if ( ! self->internal && CC_is_in_autocommit(conn) && STMT_UPDATE(self)) {
|
if ( ! self->internal && CC_is_in_autocommit(conn) && STMT_UPDATE(self)) {
|
||||||
res = CC_send_query(conn, "COMMIT", NULL);
|
res = CC_send_query(conn, "COMMIT", NULL);
|
||||||
QR_Destructor(res);
|
QR_Destructor(res);
|
||||||
|
@ -929,7 +929,7 @@ SC_log_error(char *func, char *desc, StatementClass *self)
|
||||||
qlog(" status=%d, inTuples=%d\n", res->status, res->inTuples);
|
qlog(" status=%d, inTuples=%d\n", res->status, res->inTuples);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log the connection error if there is one
|
/* Log the connection error if there is one */
|
||||||
CC_log_error(func, desc, self->hdbc);
|
CC_log_error(func, desc, self->hdbc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
void set_tuplefield_null(TupleField *tuple_field)
|
void set_tuplefield_null(TupleField *tuple_field)
|
||||||
{
|
{
|
||||||
tuple_field->len = 0;
|
tuple_field->len = 0;
|
||||||
tuple_field->value = NULL; // strdup("");
|
tuple_field->value = NULL; /* strdup(""); */
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_tuplefield_string(TupleField *tuple_field, char *string)
|
void set_tuplefield_string(TupleField *tuple_field, char *string)
|
||||||
|
|
Loading…
Reference in New Issue