#include <sqlext.h>
#endif
-// Bind parameters on a statement handle
+/* Bind parameters on a statement handle */
RETCODE SQL_API SQLBindParameter(
HSTMT hstmt,
stmt->parameters_allocated = ipar;
- // copy the old parameters over
+ /* copy the old parameters over */
for(i = 0; i < old_parameters_allocated; i++) {
- // a structure copy should work
+ /* a structure copy should work */
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)
free(old_parameters);
- // zero out the newly allocated parameters (in case they skipped some,
- // so we don't accidentally try to use them later)
+ /* zero out the newly allocated parameters (in case they skipped some, */
+ /* so we don't accidentally try to use them later) */
for(; i < stmt->parameters_allocated; i++) {
stmt->parameters[i].buflen = 0;
stmt->parameters[i].buffer = 0;
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].buffer = rgbValue;
stmt->parameters[ipar].used = pcbValue;
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(
HSTMT hstmt,
UWORD icol,
return SQL_SUCCESS;
}
- // allocate enough bindings if not already done
- // Most likely, execution of a statement would have setup the
- // necessary bindings. But some apps call BindCol before any
- // statement is executed.
+ /* allocate enough bindings if not already done */
+ /* Most likely, execution of a statement would have setup the */
+ /* necessary bindings. But some apps call BindCol before any */
+ /* statement is executed. */
if ( icol > stmt->bindings_allocated)
extend_bindings(stmt, icol);
- // check to see if the bindings were allocated
+ /* check to see if the bindings were allocated */
if ( ! stmt->bindings) {
stmt->errormsg = "Could not allocate memory for bindings.";
stmt->errornumber = STMT_NO_MEMORY_ERROR;
return SQL_SUCCESS;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
-// Returns the description of a parameter marker.
-// This function is listed as not being supported by SQLGetFunctions() because it is
-// 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,
-// it is best to say this function is not supported and let the application assume a
-// data type (most likely varchar).
+/* Returns the description of a parameter marker. */
+/* This function is listed as not being supported by SQLGetFunctions() because it is */
+/* 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, */
+/* it is best to say this function is not supported and let the application assume a */
+/* data type (most likely varchar). */
RETCODE SQL_API SQLDescribeParam(
HSTMT hstmt,
ipar--;
- // This implementation is not very good, since it is supposed to describe
- // parameter markers, not bound parameters.
+ /* This implementation is not very good, since it is supposed to describe */
+ /* parameter markers, not bound parameters. */
if(pfSqlType)
*pfSqlType = stmt->parameters[ipar].SQLType;
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(
HSTMT hstmt,
return SQL_ERROR;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
-// This function should really talk to the dbms to determine the number of
-// "parameter markers" (not bound parameters) in the statement. But, since
-// 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
-// like it does for SQLDescribeParam is that some applications don't care and try
-// to call it anyway.
-// If the statement does not have parameters, it should just return 0.
+/* This function should really talk to the dbms to determine the number of */
+/* "parameter markers" (not bound parameters) in the statement. But, since */
+/* 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 */
+/* like it does for SQLDescribeParam is that some applications don't care and try */
+/* to call it anyway. */
+/* If the statement does not have parameters, it should just return 0. */
RETCODE SQL_API SQLNumParams(
HSTMT hstmt,
SWORD FAR *pcpar)
if(!stmt->statement) {
- // no statement has been allocated
+ /* no statement has been allocated */
stmt->errormsg = "SQLNumParams called with no statement ready.";
stmt->errornumber = STMT_SEQUENCE_ERROR;
SC_log_error(func, "", stmt);
stmt->bindings_allocated = num_columns;
}
- // There is no reason to zero out extra bindings if there are
- // more than needed. If an app has allocated extra bindings,
- // let it worry about it by unbinding those columns.
+ /* There is no reason to zero out extra bindings if there are */
+ /* more than needed. If an app has allocated extra bindings, */
+ /* let it worry about it by unbinding those columns. */
- // SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings
- // SQLExecDirect(...) # returns 5 cols
- // SQLExecDirect(...) # returns 10 cols (now OK)
+ /* SQLBindCol(1..) ... SQLBindCol(10...) # got 10 bindings */
+ /* SQLExecDirect(...) # returns 5 cols */
+ /* SQLExecDirect(...) # returns 10 cols (now OK) */
mylog("exit extend_bindings\n");
}
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
{
- // check bounds
+ /* check bounds */
if((field_num < 0) || (field_num >= self->num_fields)) {
return;
}
- // store the info
+ /* store the info */
self->name[field_num] = strdup(new_name);
self->adtid[field_num] = new_adtid;
self->adtsize[field_num] = new_adtsize;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
RETCODE SQL_API SQLConnect(
HDBC hdbc,
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) {
- // Error messages are filled in
+ /* Error messages are filled in */
CC_log_error(func, "Error on CC_connect", conn);
return SQL_ERROR;
}
return SQL_SUCCESS;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
RETCODE SQL_API SQLBrowseConnect(
HDBC hdbc,
return SQL_SUCCESS;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
/* Drop any hstmts open on hdbc and disconnect from database */
RETCODE SQL_API SQLDisconnect(
}
-// - - - - - - - - -
+/* - - - - - - - - - */
RETCODE SQL_API SQLFreeConnect(
HDBC hdbc)
rv->errormsg_created = FALSE;
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));
self->errormsg_created = FALSE;
}
-// Used to cancel a transaction
-// We are almost always in the middle of a transaction.
+/* Used to cancel a transaction */
+/* We are almost always in the middle of a transaction. */
char
CC_abort(ConnectionClass *self)
{
mylog("in CC_Cleanup, self=%u\n", self);
- // Cancel an ongoing transaction
- // We are always in the middle of a transaction,
- // even if we are in auto commit.
+ /* Cancel an ongoing transaction */
+ /* We are always in the middle of a transaction, */
+ /* even if we are in auto commit. */
if (self->sock)
CC_abort(self);
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);
if ( PROTOCOL_63(ci))
mylog("gonna do authentication\n");
- // ***************************************************
- // Now get the authentication request from backend
- // ***************************************************
+ /* *************************************************** */
+ /* Now get the authentication request from backend */
+ /* *************************************************** */
if ( ! PROTOCOL_62(ci)) do {
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) {
self->errormsg = CC_create_errormsg(self);
self->errormsg_created = TRUE;
}
rv = (self->errornumber != 0);
- self->errornumber = 0; // clear the error
+ self->errornumber = 0; /* clear the error */
mylog("exit CC_get_error\n");
int id;
SocketClass *sock = self->sock;
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);
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) {
self->errornumber = CONNECTION_MSG_TOO_LONG;
self->errormsg = "Query string is too long";
mylog("~~~ NOTICE: '%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 */
/* There is a closing '\0' following the 'I', so we eat it */
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)) {
self->errornumber = CONNECTION_COULD_NOT_RECEIVE;
self->errormsg = QR_get_message(result_in);
mylog("send_function(G): 'N' - %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 */
return TRUE;
char
CC_send_settings(ConnectionClass *self)
{
-// char ini_query[MAX_MESSAGE_LEN];
+ /* char ini_query[MAX_MESSAGE_LEN]; */
ConnInfo *ci = &(self->connInfo);
-// QResultClass *res;
+/* QResultClass *res; */
HSTMT hstmt;
StatementClass *stmt;
RETCODE result;
* - thomas 2000-04-03
*/
char *mapFuncs[][2] = {
-// { "ASCII", "ascii" },
+/* { "ASCII", "ascii" }, */
{ "CHAR", "ichar" },
{ "CONCAT", "textcat" },
-// { "DIFFERENCE", "difference" },
-// { "INSERT", "insert" },
+/* { "DIFFERENCE", "difference" }, */
+/* { "INSERT", "insert" }, */
{ "LCASE", "lower" },
{ "LEFT", "ltrunc" },
{ "LOCATE", "strpos" },
{ "LENGTH", "char_length"},
-// { "LTRIM", "ltrim" },
+/* { "LTRIM", "ltrim" }, */
{ "RIGHT", "rtrunc" },
-// { "REPEAT", "repeat" },
-// { "REPLACE", "replace" },
-// { "RTRIM", "rtrim" },
-// { "SOUNDEX", "soundex" },
+/* { "REPEAT", "repeat" }, */
+/* { "REPLACE", "replace" }, */
+/* { "RTRIM", "rtrim" }, */
+/* { "SOUNDEX", "soundex" }, */
{ "SUBSTRING", "substr" },
{ "UCASE", "upper" },
-// { "ABS", "abs" },
-// { "ACOS", "acos" },
-// { "ASIN", "asin" },
-// { "ATAN", "atan" },
-// { "ATAN2", "atan2" },
+/* { "ABS", "abs" }, */
+/* { "ACOS", "acos" }, */
+/* { "ASIN", "asin" }, */
+/* { "ATAN", "atan" }, */
+/* { "ATAN2", "atan2" }, */
{ "CEILING", "ceil" },
-// { "COS", "cos" },
-// { "COT", "cot" },
-// { "DEGREES", "degrees" },
-// { "EXP", "exp" },
-// { "FLOOR", "floor" },
+/* { "COS", "cos" }, */
+/* { "COT", "cot" }, */
+/* { "DEGREES", "degrees" }, */
+/* { "EXP", "exp" }, */
+/* { "FLOOR", "floor" }, */
{ "LOG", "ln" },
{ "LOG10", "log" },
-// { "MOD", "mod" },
-// { "PI", "pi" },
+/* { "MOD", "mod" }, */
+/* { "PI", "pi" }, */
{ "POWER", "pow" },
-// { "RADIANS", "radians" },
+/* { "RADIANS", "radians" }, */
{ "RAND", "random" },
-// { "ROUND", "round" },
-// { "SIGN", "sign" },
-// { "SIN", "sin" },
-// { "SQRT", "sqrt" },
-// { "TAN", "tan" },
+/* { "ROUND", "round" }, */
+/* { "SIGN", "sign" }, */
+/* { "SIN", "sin" }, */
+/* { "SQRT", "sqrt" }, */
+/* { "TAN", "tan" }, */
{ "TRUNCATE", "trunc" },
-// { "CURDATE", "curdate" },
-// { "CURTIME", "curtime" },
-// { "DAYNAME", "dayname" },
-// { "DAYOFMONTH", "dayofmonth" },
-// { "DAYOFWEEK", "dayofweek" },
-// { "DAYOFYEAR", "dayofyear" },
-// { "HOUR", "hour" },
-// { "MINUTE", "minute" },
-// { "MONTH", "month" },
-// { "MONTHNAME", "monthname" },
-// { "NOW", "now" },
-// { "QUARTER", "quarter" },
-// { "SECOND", "second" },
-// { "WEEK", "week" },
-// { "YEAR", "year" },
-
-// { "DATABASE", "database" },
+/* { "CURDATE", "curdate" }, */
+/* { "CURTIME", "curtime" }, */
+/* { "DAYNAME", "dayname" }, */
+/* { "DAYOFMONTH", "dayofmonth" }, */
+/* { "DAYOFWEEK", "dayofweek" }, */
+/* { "DAYOFYEAR", "dayofyear" }, */
+/* { "HOUR", "hour" }, */
+/* { "MINUTE", "minute" }, */
+/* { "MONTH", "month" }, */
+/* { "MONTHNAME", "monthname" }, */
+/* { "NOW", "now" }, */
+/* { "QUARTER", "quarter" }, */
+/* { "SECOND", "second" }, */
+/* { "WEEK", "week" }, */
+/* { "YEAR", "year" }, */
+
+/* { "DATABASE", "database" }, */
{ "IFNULL", "coalesce" },
{ "USER", "odbc_user" },
{ 0, 0 }
case PG_TYPE_INT2VECTOR: {
int nval, i;
char *vp;
- // this is an array of eight integers
+ /* this is an array of eight integers */
short *short_array = (short *) ( (char *) rgbValue + rgbValueOffset);
len = 16;
and all that stuff since there is essentially no limit on the large
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);
/***** THIS IS NOT PROPERLY IMPLEMENTED *****/
} else {
*((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;
case SQL_C_STINYINT:
case SQL_C_BINARY:
- // truncate if necessary
- // convert octal escapes to bytes
+ /* truncate if necessary */
+ /* convert octal escapes to bytes */
len = convert_from_pgbinary(value, tempBuf, sizeof(tempBuf));
ptr = tempBuf;
}
}
- // 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) {
*(SDWORD *) ((char *)pcbValue + pcbValueOffset) = len;
}
if ( stmt->cursor_name[0] == '\0')
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) {
sprintf(new_statement, "declare %s cursor for ", stmt->cursor_name);
npos = strlen(new_statement);
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 &&
old_statement[opos+1] == '\n') {
continue;
}
- // Handle literals (date, time, timestamp) and ODBC scalar functions
+ /* Handle literals (date, time, timestamp) and ODBC scalar functions */
else if (old_statement[opos] == '{') {
char *esc;
char *begin = &old_statement[opos + 1];
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)
param_ctype = sqltype_to_default_ctype(param_sqltype);
}
default:
- // error
+ /* error */
stmt->errormsg = "Unrecognized C_parameter type in copy_statement_with_parameters";
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);
return SQL_ERROR;
}
break;
- // because of no conversion operator for bool and int4, SQL_BIT
- // must be quoted (0 or 1 is ok to use inside the quotes)
+ /* because of no conversion operator for bool and int4, SQL_BIT */
+ /* must be quoted (0 or 1 is ok to use inside the quotes) */
default: /* a numeric type or SQL_BIT */
if (param_sqltype == SQL_BIT)
} /* end, for */
- // make sure new_statement is always null-terminated
+ /* make sure new_statement is always null-terminated */
new_statement[npos] = '\0';
for (i = 0; i < strlen(s); i++) {
if (s[i] == '$' || s[i] == ',' || s[i] == ')')
- ; // skip these characters
+ ; /* skip these characters */
else if (s[i] == '(')
s[out++] = '-';
else
return y;
}
-// convert octal escapes to bytes
+/* convert octal escapes to bytes */
int
convert_from_pgbinary(unsigned char *value, unsigned char *rgbValue, int cbValueMax)
{
o++;
}
- rgbValue[o] = '\0'; // extra protection
+ rgbValue[o] = '\0'; /* extra protection */
return o;
}
return x;
}
-// convert non-ascii bytes to octal escape sequences
+/* convert non-ascii bytes to octal escape sequences */
int
convert_to_pgbinary(unsigned char *in, char *out, int len)
{
globals.fetch_max = GetDlgItemInt(hdlg, DRV_CACHE_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));
updateGlobals();
- // fall through
+ /* fall through */
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
switch (wMsg) {
case WM_INITDIALOG:
ci = (ConnInfo *) lParam;
- SetWindowLong(hdlg, DWL_USER, lParam); // save for OK
+ SetWindowLong(hdlg, DWL_USER, lParam); /* save for OK */
/* Change window caption */
if (ci->driver[0])
GetDlgItemText(hdlg, DS_CONNSETTINGS, ci->conn_settings, sizeof(ci->conn_settings));
- // fall through
+ /* fall through */
case IDCANCEL:
EndDialog(hdlg, GET_WM_COMMAND_ID(wParam, lParam) == IDOK);
else if (stricmp(attribute, INI_CONNSETTINGS) == 0) {
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);
char *DSN = ci->dsn;
char encoded_conn_settings[LARGE_REGISTRY_LEN];
- // 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 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[0] == '\0') {
if ( ci->driver[0] != '\0')
return;
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';
- // Proceed with getting info for the given DSN.
+ /* Proceed with getting info for the given DSN. */
if ( ci->desc[0] == '\0' || overwrite)
SQLGetPrivateProfileString(DSN, INI_KDESC, "", ci->desc, sizeof(ci->desc), ODBC_INI);
char temp[256];
- // Fetch Count is stored in driver section
+ /* Fetch Count is stored in driver section */
SQLGetPrivateProfileString(section, INI_FETCH, "",
temp, sizeof(temp), filename);
if ( temp[0] ) {
globals.fetch_max = FETCH_MAX;
- // Socket Buffersize is stored in driver section
+ /* Socket Buffersize is stored in driver section */
SQLGetPrivateProfileString(section, INI_SOCKET, "",
temp, sizeof(temp), filename);
if ( temp[0] )
globals.socket_buffersize = SOCK_BUFFER_SIZE;
- // Debug is stored in the driver section
+ /* Debug is stored in the driver section */
SQLGetPrivateProfileString(section, INI_DEBUG, "",
temp, sizeof(temp), filename);
if ( temp[0] )
globals.debug = DEFAULT_DEBUG;
- // CommLog is stored in the driver section
+ /* CommLog is stored in the driver section */
SQLGetPrivateProfileString(section, INI_COMMLOG, "",
temp, sizeof(temp), filename);
if ( temp[0] )
globals.commlog = DEFAULT_COMMLOG;
- // Optimizer is stored in the driver section only
+ /* Optimizer is stored in the driver section only */
SQLGetPrivateProfileString(section, INI_OPTIMIZER, "",
temp, sizeof(temp), filename);
if ( temp[0] )
else if ( ! override)
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, "",
temp, sizeof(temp), filename);
if ( temp[0] )
else if ( ! override)
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, "",
temp, sizeof(temp), filename);
if ( temp[0] )
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, "",
temp, sizeof(temp), filename);
if ( temp[0] )
globals.unknown_sizes = DEFAULT_UNKNOWNSIZES;
- // Lie about supported functions?
+ /* Lie about supported functions? */
SQLGetPrivateProfileString(section, INI_LIE, "",
temp, sizeof(temp), filename);
if ( temp[0] )
else if ( ! override)
globals.lie = DEFAULT_LIE;
- // Parse statements
+ /* Parse statements */
SQLGetPrivateProfileString(section, INI_PARSE, "",
temp, sizeof(temp), filename);
if ( temp[0] )
else if ( ! override)
globals.parse = DEFAULT_PARSE;
- // SQLCancel calls SQLFreeStmt in Driver Manager
+ /* SQLCancel calls SQLFreeStmt in Driver Manager */
SQLGetPrivateProfileString(section, INI_CANCELASFREESTMT, "",
temp, sizeof(temp), filename);
if ( temp[0] )
- // UseDeclareFetch is stored in the driver section only
+ /* UseDeclareFetch is stored in the driver section only */
SQLGetPrivateProfileString(section, INI_USEDECLAREFETCH, "",
temp, sizeof(temp), filename);
if ( temp[0] )
globals.use_declarefetch = DEFAULT_USEDECLAREFETCH;
- // Max Varchar Size
+ /* Max Varchar Size */
SQLGetPrivateProfileString(section, INI_MAXVARCHARSIZE, "",
temp, sizeof(temp), filename);
if ( temp[0] )
else if ( ! override)
globals.max_varchar_size = MAX_VARCHAR_SIZE;
- // Max TextField Size
+ /* Max TextField Size */
SQLGetPrivateProfileString(section, INI_MAXLONGVARCHARSIZE, "",
temp, sizeof(temp), filename);
if ( temp[0] )
else if ( ! override)
globals.max_longvarchar_size = TEXT_FIELD_SIZE;
- // Text As LongVarchar
+ /* Text As LongVarchar */
SQLGetPrivateProfileString(section, INI_TEXTASLONGVARCHAR, "",
temp, sizeof(temp), filename);
if ( temp[0] )
else if ( ! override)
globals.text_as_longvarchar = DEFAULT_TEXTASLONGVARCHAR;
- // Unknowns As LongVarchar
+ /* Unknowns As LongVarchar */
SQLGetPrivateProfileString(section, INI_UNKNOWNSASLONGVARCHAR, "",
temp, sizeof(temp), filename);
if ( temp[0] )
else if ( ! override)
globals.unknowns_as_longvarchar = DEFAULT_UNKNOWNSASLONGVARCHAR;
- // Bools As Char
+ /* Bools As Char */
SQLGetPrivateProfileString(section, INI_BOOLSASCHAR, "",
temp, sizeof(temp), filename);
if ( temp[0] )
else if ( ! override)
globals.bools_as_char = DEFAULT_BOOLSASCHAR;
- // Extra Systable prefixes
- // Use @@@ to distinguish between blank extra prefixes and no key entry
+ /* Extra Systable prefixes */
+ /* Use @@@ to distinguish between blank extra prefixes and no key entry */
SQLGetPrivateProfileString(section, INI_EXTRASYSTABLEPREFIXES, "@@@",
temp, sizeof(temp), filename);
if ( strcmp(temp, "@@@" ))
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) {
- // 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, "",
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, "",
temp, sizeof(temp), filename);
if ( temp[0] )
/* Connection Defaults */
#define DEFAULT_PORT "5432"
#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_TEXTASLONGVARCHAR 1
#define DEFAULT_UNKNOWNSASLONGVARCHAR 0
#define DEFAULT_BOOLSASCHAR 1
-#define DEFAULT_OPTIMIZER 1 // disable
-#define DEFAULT_KSQO 1 // on
-#define DEFAULT_UNIQUEINDEX 0 // dont recognize
-#define DEFAULT_COMMLOG 0 // dont log
+#define DEFAULT_OPTIMIZER 1 /* disable */
+#define DEFAULT_KSQO 1 /* on */
+#define DEFAULT_UNIQUEINDEX 0 /* dont recognize */
+#define DEFAULT_COMMLOG 0 /* dont log */
#define DEFAULT_DEBUG 0
#define DEFAULT_UNKNOWNSIZES UNKNOWNS_AS_MAX
#define DEFAULT_FAKEOIDINDEX 0
#define DEFAULT_SHOWOIDCOLUMN 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_PARSE 0
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);
- // If the ConnInfo in the hdbc is missing anything,
- // this function will fill them in from the registry (assuming
- // of course there is a DSN given -- if not, it does nothing!)
+ /* If the ConnInfo in the hdbc is missing anything, */
+ /* this function will fill them in from the registry (assuming */
+ /* of course there is a DSN given -- if not, it does nothing!) */
getDSNinfo(ci, CONN_DONT_OVERWRITE);
- // Fill in any default parameters if they are not there.
+ /* Fill in any default parameters if they are not there. */
getDSNdefaults(ci);
#ifdef WIN32
ci->server[0] == '\0' ||
ci->database[0] == '\0' ||
ci->port[0] == '\0') {
-// (password_required && ci->password[0] == '\0'))
+/* (password_required && ci->password[0] == '\0')) */
return SQL_NO_DATA_FOUND;
}
- // do the actual connect
+ /* do the actual connect */
retval = CC_connect(conn, password_required);
if (retval < 0) { /* need a password */
if (fDriverCompletion == SQL_DRIVER_NOPROMPT) {
}
}
else if (retval == 0) {
- // error msg filled in above
+ /* error msg filled in above */
CC_log_error(func, "Error from CC_Connect", conn);
return SQL_ERROR;
}
ShowWindow(GetDlgItem(hdlg, IDC_DESCTEXT), 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);
continue;
*equals = '\0';
- attribute = pair; // ex. DSN
- value = equals + 1; // ex. 'CEO co1'
+ attribute = pair; /* ex. DSN */
+ value = equals + 1; /* ex. 'CEO co1' */
mylog("attribute = '%s', value = '%s'\n", attribute, value);
if( !attribute || !value)
continue;
- // Copy the appropriate value to the conninfo
+ /* Copy the appropriate value to the conninfo */
copyAttributes(ci, attribute, value);
}
return SQL_ERROR;
}
-// Returns the next SQL error information.
+/* Returns the next SQL error information. */
RETCODE SQL_API SQLError(
HENV henv,
mylog("**** SQLError: henv=%u, hdbc=%u, hstmt=%u\n", henv, hdbc, hstmt);
if (SQL_NULL_HSTMT != hstmt) {
- // CC: return an error of a hstmt
+ /* CC: return an error of a hstmt */
StatementClass *stmt = (StatementClass *) hstmt;
if (SC_get_error(stmt, &status, &msg)) {
if (NULL != szSqlState)
switch (status) {
- // now determine the SQLSTATE to be returned
+ /* now determine the SQLSTATE to be returned */
case STMT_TRUNCATED:
strcpy(szSqlState, "01004");
- // data truncated
+ /* data truncated */
break;
case STMT_INFO_ONLY:
strcpy(szSqlState, "00000");
- // just information that is returned, no error
+ /* just information that is returned, no error */
break;
case STMT_BAD_ERROR:
strcpy(szSqlState, "08S01");
- // communication link failure
+ /* communication link failure */
break;
case STMT_CREATE_TABLE_ERROR:
strcpy(szSqlState, "S0001");
- // table already exists
+ /* table already exists */
break;
case STMT_STATUS_ERROR:
case STMT_SEQUENCE_ERROR:
strcpy(szSqlState, "S1010");
- // Function sequence error
+ /* Function sequence error */
break;
case STMT_NO_MEMORY_ERROR:
strcpy(szSqlState, "S1001");
- // memory allocation failure
+ /* memory allocation failure */
break;
case STMT_COLNUM_ERROR:
strcpy(szSqlState, "S1002");
- // invalid column number
+ /* invalid column number */
break;
case STMT_NO_STMTSTRING:
strcpy(szSqlState, "S1001");
- // having no stmtstring is also a malloc problem
+ /* having no stmtstring is also a malloc problem */
break;
case STMT_ERROR_TAKEN_FROM_BACKEND:
strcpy(szSqlState, "S1000");
- // general error
+ /* general error */
break;
case STMT_INTERNAL_ERROR:
strcpy(szSqlState, "S1000");
- // general error
+ /* general error */
break;
case STMT_ROW_OUT_OF_RANGE:
strcpy(szSqlState, "S1107");
break;
case STMT_NOT_IMPLEMENTED_ERROR:
- strcpy(szSqlState, "S1C00"); // == 'driver not capable'
+ strcpy(szSqlState, "S1C00"); /* == 'driver not capable' */
break;
case STMT_OPTION_OUT_OF_RANGE_ERROR:
strcpy(szSqlState, "S1092");
break;
case STMT_INVALID_ARGUMENT_NO:
strcpy(szSqlState, "S1009");
- // invalid argument value
+ /* invalid argument value */
break;
case STMT_INVALID_CURSOR_POSITION:
strcpy(szSqlState, "S1109");
case STMT_EXEC_ERROR:
default:
strcpy(szSqlState, "S1000");
- // also a general error
+ /* also a general error */
break;
}
case STMT_TRUNCATED:
case CONN_TRUNCATED:
strcpy(szSqlState, "01004");
- // data truncated
+ /* data truncated */
break;
case CONN_INIREAD_ERROR:
strcpy(szSqlState, "IM002");
- // data source not found
+ /* data source not found */
break;
case CONN_OPENDB_ERROR:
strcpy(szSqlState, "08001");
- // unable to connect to data source
+ /* unable to connect to data source */
break;
case CONN_INVALID_AUTHENTICATION:
case CONN_AUTH_TYPE_UNSUPPORTED:
break;
case CONN_STMT_ALLOC_ERROR:
strcpy(szSqlState, "S1001");
- // memory allocation failure
+ /* memory allocation failure */
break;
case CONN_IN_USE:
strcpy(szSqlState, "S1000");
- // general error
+ /* general error */
break;
case CONN_UNSUPPORTED_OPTION:
strcpy(szSqlState, "IM001");
- // driver does not support this function
+ /* driver does not support this function */
case CONN_INVALID_ARGUMENT_NO:
strcpy(szSqlState, "S1009");
- // invalid argument value
+ /* invalid argument value */
break;
case CONN_TRANSACT_IN_PROGRES:
strcpy(szSqlState, "S1010");
- // when the user tries to switch commit mode in a transaction
- // -> function sequence error
+ /* when the user tries to switch commit mode in a transaction */
+ /* -> function sequence error */
break;
case CONN_NO_MEMORY_ERROR:
strcpy(szSqlState, "S1001");
default:
strcpy(szSqlState, "S1000");
- // general error
+ /* general error */
break;
}
if(szSqlState) {
switch(status) {
case ENV_ALLOC_ERROR:
- // memory allocation failure
+ /* memory allocation failure */
strcpy(szSqlState, "S1001");
break;
default:
strcpy(szSqlState, "S1000");
- // general error
+ /* general error */
break;
}
}
mylog("in EN_Destructor, self=%u\n", self);
- // the error messages are static strings distributed throughout
- // the source--they should not be freed
+ /* the error messages are static strings distributed throughout */
+ /* the source--they should not be freed */
/* Free any connections belonging to this environment */
for (lf = 0; lf < MAX_CONNECTIONS; lf++) {
extern GLOBAL_VALUES globals;
-// Perform a Prepare on the SQL statement
+/* Perform a Prepare on the SQL statement */
RETCODE SQL_API SQLPrepare(HSTMT hstmt,
UCHAR FAR *szSqlStr,
SDWORD cbSqlStr)
self->prepare = TRUE;
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)) {
self->errornumber = STMT_EXEC_ERROR;
self->errormsg = "Connection is readonly, only select statements are allowed.";
}
-// - - - - - - - - -
+/* - - - - - - - - - */
-// Performs the equivalent of SQLPrepare, followed by SQLExecute.
+/* Performs the equivalent of SQLPrepare, followed by SQLExecute. */
RETCODE SQL_API SQLExecDirect(
HSTMT hstmt,
if (stmt->statement)
free(stmt->statement);
- // keep a copy of the un-parametrized statement, in case
- // they try to execute this statement again
+ /* keep a copy of the un-parametrized statement, in case */
+ /* they try to execute this statement again */
stmt->statement = make_string(szSqlStr, cbSqlStr, NULL);
if ( ! stmt->statement) {
stmt->errornumber = STMT_NO_MEMORY_ERROR;
stmt->prepare = FALSE;
- // If an SQLPrepare was performed prior to this, but was left in
- // the premature state because an error occurred prior to SQLExecute
- // then set the statement to finished so it can be recycled.
+ /* If an SQLPrepare was performed prior to this, but was left in */
+ /* the premature state because an error occurred prior to SQLExecute */
+ /* then set the statement to finished so it can be recycled. */
if ( stmt->status == STMT_PREMATURE )
stmt->status = STMT_FINISHED;
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)) {
stmt->errornumber = STMT_EXEC_ERROR;
stmt->errormsg = "Connection is readonly, only select statements are allowed.";
return result;
}
-// Execute a prepared SQL statement
+/* Execute a prepared SQL statement */
RETCODE SQL_API SQLExecute(
HSTMT hstmt)
{
stmt->data_at_exec++;
}
}
- // If there are some data at execution parameters, return need data
- // SQLParamData and SQLPutData will be used to send params and execute the statement.
+ /* If there are some data at execution parameters, return need data */
+ /* SQLParamData and SQLPutData will be used to send params and execute the statement. */
if (stmt->data_at_exec > 0)
return SQL_NEED_DATA;
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);
if( retval != SQL_SUCCESS)
/* error msg passed from above */
-// - - - - - - - - -
+/* - - - - - - - - - */
RETCODE SQL_API SQLTransact(
HENV henv,
HDBC hdbc,
CC_set_no_trans(conn);
if ( ! res) {
- // error msg will be in the connection
+ /* error msg will be in the connection */
CC_log_error(func, "", conn);
return SQL_ERROR;
}
return SQL_SUCCESS;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
RETCODE SQL_API SQLCancel(
- HSTMT hstmt) // Statement to cancel.
+ HSTMT hstmt) /* Statement to cancel. */
{
static char *func="SQLCancel";
StatementClass *stmt = (StatementClass *) hstmt;
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) {
SC_log_error(func, "", NULL);
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) {
return SQL_SUCCESS;
}
- // In the middle of SQLParamData/SQLPutData, so cancel that.
- // Note, any previous data-at-exec buffers will be freed in the recycle
- // if they call SQLExecDirect or SQLExecute again.
+ /* In the middle of SQLParamData/SQLPutData, so cancel that. */
+ /* Note, any previous data-at-exec buffers will be freed in the recycle */
+ /* if they call SQLExecDirect or SQLExecute again. */
stmt->data_at_exec = -1;
stmt->current_exec_param = -1;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
-// Returns the SQL string as modified by the driver.
-// Currently, just copy the input string without modification
-// observing buffer limits and truncation.
+/* Returns the SQL string as modified by the driver. */
+/* Currently, just copy the input string without modification */
+/* observing buffer limits and truncation. */
RETCODE SQL_API SQLNativeSql(
HDBC hdbc,
UCHAR FAR *szSqlStrIn,
return result;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
-// Supplies parameter data at execution time. Used in conjuction with
-// SQLPutData.
+/* Supplies parameter data at execution time. Used in conjuction with */
+/* SQLPutData. */
RETCODE SQL_API SQLParamData(
HSTMT hstmt,
return SQL_NEED_DATA;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
-// Supplies parameter data at execution time. Used in conjunction with
-// SQLParamData.
+/* Supplies parameter data at execution time. Used in conjunction with */
+/* SQLParamData. */
RETCODE SQL_API SQLPutData(
HSTMT hstmt,
-// GetPrivateProfileString() -- approximate implementation of
-// Windows NT System Services version of GetPrivateProfileString()
-// probably doesn't handle the NULL key for section name or value key
-// correctly also, doesn't provide Microsoft backwards compatability
-// wrt TAB characters in the value string -- Microsoft terminates value
-// 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
-// characters -- NO comments following value string separated by a TAB
-// are allowed (that is an anachronism anyway)
-// Added code to search for ODBC_INI file in users home directory on
-// Unix
+/* GetPrivateProfileString() -- approximate implementation of */
+/* Windows NT System Services version of GetPrivateProfileString() */
+/* probably doesn't handle the NULL key for section name or value key */
+/* correctly also, doesn't provide Microsoft backwards compatability */
+/* wrt TAB characters in the value string -- Microsoft terminates value */
+/* 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 */
+/* characters -- NO comments following value string separated by a TAB */
+/* are allowed (that is an anachronism anyway) */
+/* Added code to search for ODBC_INI file in users home directory on */
+/* Unix */
#ifndef WIN32
#if HAVE_CONFIG_H
-#include "config.h" // produced by configure
+#include "config.h" /* produced by configure */
#endif
#include <stdio.h>
DWORD
-GetPrivateProfileString(char *theSection, // section name
- char *theKey, // search key name
- char *theDefault, // default value if not found
- char *theReturnBuffer, // return value stored here
- size_t theReturnBufferLength, // byte length of return buffer
- char *theIniFileName) // pathname of ini file to search
+GetPrivateProfileString(char *theSection, /* section name */
+ char *theKey, /* search key name */
+ char *theDefault, /* default value if not found */
+ char *theReturnBuffer, /* return value stored here */
+ size_t theReturnBufferLength, /* byte length of return buffer */
+ char *theIniFileName) /* pathname of ini file to search */
{
char buf[MAXPGPATH];
char* ptr = 0;
int j = 0;
j = strlen(theIniFileName) + 1;
- ptr = (char*)getpwuid(getuid()); // get user info
+ ptr = (char*)getpwuid(getuid()); /* get user info */
if( ptr == NULL)
{
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' )
ptr = "/home";
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 ?
theReturnBufferLength : aLength;
strncpy(theReturnBuffer, theDefault, aLength);
while(fgets(aLine, sizeof(aLine), aFile) != NULL)
{
aLineLength = strlen(aLine);
- // strip final '\n'
+ /* strip final '\n' */
if(aLineLength > 0 && aLine[aLineLength - 1] == '\n')
{
aLine[aLineLength - 1] = '\0';
}
switch(*aLine)
{
- case ' ': // blank line
- case ';': // comment line
+ case ' ': /* blank line */
+ case ';': /* comment line */
continue;
break;
- case '[': // section marker
+ case '[': /* section marker */
if( (aString = strchr(aLine, ']')) )
{
while (isspace(*aString)) aString--;
*(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))
{
default:
- // try to match value keys if in proper section
+ /* try to match value keys if in proper section */
if(aSectionFound)
{
- // try to match requested key
+ /* try to match requested key */
if( (aString = aValue = strchr(aLine, '=')) )
{
*aValue = '\0';
++aValue;
- // strip leading blanks in value field
+ /* strip leading blanks in value field */
while(*aValue == ' ' && aValue < aLine + sizeof(aLine))
{
aStart = aLine;
while(isspace(*aStart)) aStart++;
- // strip trailing blanks from key
+ /* strip trailing blanks from key */
if(aString)
{
}
}
- // see if key is matched
+ /* see if key is matched */
if(theKey == NULL || !strcmp(theKey, aStart))
{
- // matched -- first, terminate value part
+ /* matched -- first, terminate value part */
aKeyFound = TRUE;
aLength = strlen(aValue);
- // remove trailing blanks from aValue if any
+ /* remove trailing blanks from aValue if any */
aString = aValue + aLength - 1;
--aLength;
}
- // unquote value if quoted
+ /* unquote value if quoted */
if(aLength >= 2 && aValue[0] == '"' &&
aValue[aLength - 1] == '"')
{
- // string quoted with double quotes
+ /* string quoted with double quotes */
aValue[aLength - 1] = '\0';
++aValue;
}
else
{
- // single quotes allowed also...
+ /* single quotes allowed also... */
if(aLength >= 2 && aValue[0] == '\'' &&
aValue[aLength - 1] == '\'')
}
}
- // compute maximum length copyable
+ /* compute maximum length copyable */
aLineLength = (aLength <
theReturnBufferLength - aReturnLength) ? aLength :
theReturnBufferLength - aReturnLength;
- // do the copy to return buffer
+ /* do the copy to return buffer */
if(aLineLength)
{
fclose(aFile);
}
- if(!aKeyFound) { // key wasn't found return default
- ++aLength; // room for NULL char
+ if(!aKeyFound) { /* key wasn't found return default */
+ ++aLength; /* room for NULL char */
aLength = theReturnBufferLength < aLength ?
theReturnBufferLength : aLength;
strncpy(theReturnBuffer, theDefault, aLength);
}
DWORD
-WritePrivateProfileString(char *theSection, // section name
- char *theKey, // write key name
- char *theBuffer, // input buffer
- char *theIniFileName) // pathname of ini file to write
+WritePrivateProfileString(char *theSection, /* section name */
+ char *theKey, /* write key name */
+ char *theBuffer, /* input buffer */
+ char *theIniFileName) /* pathname of ini file to write */
{
return 0;
}
+#if 0
/* 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
* I find out different.
+ */
DWORD
-WritePrivateProfileString(char *theSection, // section name
- char *theKey, // write key name
- char *theBuffer, // input buffer
- char *theIniFileName) // pathname of ini file to write
+WritePrivateProfileString(char *theSection, /* section name */
+ char *theKey, /* write key name */
+ char *theBuffer, /* input buffer */
+ char *theIniFileName) /* pathname of ini file to write */
{
char buf[MAXPGPATH];
char* ptr = 0;
BOOL keyFound = FALSE;
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 ||
theIniFileName == NULL) return 0;
if(aLength == 0) return 0;
j = strlen(theIniFileName) + 1;
- ptr = (char*)getpwuid(getuid()); // get user info
+ ptr = (char*)getpwuid(getuid()); /* get user info */
if( ptr == NULL)
{
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' )
ptr = "/home";
- // This doesn't make it so we find an ini file but allows normal
- // processing to continue further on down. The likelihood is that
- // the file won't be found and thus the default value will be
- // returned.
- //
+ /* This doesn't make it so we find an ini file but allows normal */
+ /* processing to continue further on down. The likelihood is that */
+ /* the file won't be found and thus the default value will be */
+ /* returned. */
+ /* */
if( MAXPGPATH-1 < strlen(ptr) + j )
{
if( MAXPGPATH-1 < strlen(ptr) )
sprintf( buf, "%s/%s",ptr,theIniFileName );
- // This code makes it so that a file in the users home dir
- // overrides a the "default" file as passed in
- //
+ /* This code makes it so that a file in the users home dir */
+ /* overrides a the "default" file as passed in */
+ /* */
aFile = (FILE*)(buf ? fopen(buf, "r+") : NULL);
if(!aFile) {
sprintf(buf,"%s",theIniFileName);
aLength = strlen(theBuffer);
- // We have to search for theKey, because if it already
- // exists we have to overwrite it. If it doesn't exist
- // we just write a new line to the file.
- //
+ /* We have to search for theKey, because if it already */
+ /* exists we have to overwrite it. If it doesn't exist */
+ /* we just write a new line to the file. */
+ /* */
while(fgets(aLine, sizeof(aLine), aFile) != NULL)
{
aLineLength = strlen(aLine);
- // strip final '\n'
+ /* strip final '\n' */
if(aLineLength > 0 && aLine[aLineLength - 1] == '\n')
{
aLine[aLineLength - 1] = '\0';
}
switch(*aLine)
{
- case ' ': // blank line
- case ';': // comment line
+ case ' ': /* blank line */
+ case ';': /* comment line */
continue;
break;
- case '[': // section marker
+ case '[': /* section marker */
if( (aString = strchr(aLine, ']')) )
{
*aString = '\0';
- // accept as matched if key exact match
+ /* accept as matched if key exact match */
if(!strcmp(aLine + 1, theSection))
{
default:
- // try to match value keys if in proper section
+ /* try to match value keys if in proper section */
if(aSectionFound)
{
- // try to match requested key
+ /* try to match requested key */
if( (aString = aValue = strchr(aLine, '=')) )
{
*aValue = '\0';
++aValue;
- // strip leading blanks in value field
+ /* strip leading blanks in value field */
while(*aValue == ' ' && aValue < aLine + sizeof(aLine))
{
aValue = "";
}
- // strip trailing blanks from key
+ /* strip trailing blanks from key */
if(aString)
{
}
}
- // see if key is matched
+ /* see if key is matched */
if(!strcmp(theKey, aLine))
{
keyFound = TRUE;
- // matched -- first, terminate value part
+ /* matched -- first, terminate value part */
- // overwrite current value
+ /* overwrite current value */
fseek(aFile,-aLineLength,SEEK_CUR);
- // overwrite key and value
+ /* overwrite key and value */
sprintf(aLine,"%s = %s\n",theKey,theBuffer);
fputs(aLine,aFile);
}
}
}
- if(!keyFound) { // theKey wasn't in file so
+ if(!keyFound) { /* theKey wasn't in file so */
if(aFile)
{
fclose(aFile);
return aReturnLength > 0 ? aReturnLength - 1 : 0;
}
-*/
+#endif
+
#endif
-// GetPrivateProfileString
-// for UNIX use
+/* GetPrivateProfileString */
+/* for UNIX use */
#ifndef GPPS_H
#define GPPS_H
#endif
DWORD
-GetPrivateProfileString(char *theSection, // section name
- char *theKey, // search key name
- char *theDefault, // default value if not found
- char *theReturnBuffer, // return valuse stored here
- size_t theBufferLength, // byte length of return buffer
- char *theIniFileName); // pathname of ini file to search
+GetPrivateProfileString(char *theSection, /* section name */
+ char *theKey, /* search key name */
+ char *theDefault, /* default value if not found */
+ char *theReturnBuffer, /* return valuse stored here */
+ size_t theBufferLength, /* byte length of return buffer */
+ char *theIniFileName); /* pathname of ini file to search */
DWORD
-WritePrivateProfileString(char *theSection, // section name
- char *theKey, // write key name
- char *theBuffer, // input buffer
- char *theIniFileName); // pathname of ini file to write
+WritePrivateProfileString(char *theSection, /* section name */
+ char *theKey, /* write key name */
+ char *theBuffer, /* input buffer */
+ char *theIniFileName); /* pathname of ini file to write */
#ifdef __cplusplus
}
extern GLOBAL_VALUES globals;
-// - - - - - - - - -
+/* - - - - - - - - - */
RETCODE SQL_API SQLGetInfo(
HDBC hdbc,
case SQL_DEFAULT_TXN_ISOLATION: /* ODBC 1.0 */
len = 4;
- value = SQL_TXN_READ_COMMITTED; //SQL_TXN_SERIALIZABLE;
+ value = SQL_TXN_READ_COMMITTED; /*SQL_TXN_SERIALIZABLE; */
break;
case SQL_DRIVER_NAME: /* ODBC 1.0 */
case SQL_TXN_ISOLATION_OPTION: /* ODBC 1.0 */
len = 4;
- value = SQL_TXN_READ_COMMITTED; // SQL_TXN_SERIALIZABLE;
+ value = SQL_TXN_READ_COMMITTED; /* SQL_TXN_SERIALIZABLE; */
break;
case SQL_UNION: /* ODBC 2.0 */
return result;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
RETCODE SQL_API SQLGetTypeInfo(
StatementClass *stmt = (StatementClass *) hstmt;
TupleNode *row;
int i;
-// Int4 type;
+/* Int4 type; */
Int4 pgType;
Int2 sqlType;
return SQL_SUCCESS;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
RETCODE SQL_API SQLGetFunctions(
HDBC hdbc,
else {
memset(pfExists, 0, sizeof(UWORD)*100);
- // ODBC core functions
+ /* ODBC core functions */
pfExists[SQL_API_SQLALLOCCONNECT] = TRUE;
pfExists[SQL_API_SQLALLOCENV] = TRUE;
pfExists[SQL_API_SQLALLOCSTMT] = TRUE;
pfExists[SQL_API_SQLCANCEL] = TRUE;
pfExists[SQL_API_SQLCOLATTRIBUTES] = 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_SQLERROR] = TRUE;
pfExists[SQL_API_SQLEXECDIRECT] = TRUE;
pfExists[SQL_API_SQLFREESTMT] = TRUE;
pfExists[SQL_API_SQLGETCURSORNAME] = 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_SQLSETCURSORNAME] = TRUE;
- pfExists[SQL_API_SQLSETPARAM] = FALSE; // odbc 1.0
+ pfExists[SQL_API_SQLSETPARAM] = FALSE; /* odbc 1.0 */
pfExists[SQL_API_SQLTRANSACT] = TRUE;
- // ODBC level 1 functions
+ /* ODBC level 1 functions */
pfExists[SQL_API_SQLBINDPARAMETER] = TRUE;
pfExists[SQL_API_SQLCOLUMNS] = 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_SQLGETFUNCTIONS] = 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_SQLPARAMDATA] = 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_SQLSPECIALCOLUMNS] = TRUE;
pfExists[SQL_API_SQLSTATISTICS] = TRUE;
pfExists[SQL_API_SQLTABLES] = TRUE;
- // ODBC level 2 functions
+ /* ODBC level 2 functions */
pfExists[SQL_API_SQLBROWSECONNECT] = FALSE;
pfExists[SQL_API_SQLCOLUMNPRIVILEGES] = FALSE;
- pfExists[SQL_API_SQLDATASOURCES] = FALSE; // only implemented by DM
- pfExists[SQL_API_SQLDESCRIBEPARAM] = FALSE; // not properly implemented
- pfExists[SQL_API_SQLDRIVERS] = 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_SQLDRIVERS] = FALSE; /* only implemented by DM */
pfExists[SQL_API_SQLEXTENDEDFETCH] = TRUE;
pfExists[SQL_API_SQLFOREIGNKEYS] = TRUE;
pfExists[SQL_API_SQLMORERESULTS] = TRUE;
pfExists[SQL_API_SQLPROCEDURECOLUMNS] = FALSE;
pfExists[SQL_API_SQLPROCEDURES] = FALSE;
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;
}
} else {
case SQL_API_SQLCANCEL: *pfExists = TRUE; break;
case SQL_API_SQLCOLATTRIBUTES: *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_SQLERROR: *pfExists = TRUE; break;
case SQL_API_SQLEXECDIRECT: *pfExists = TRUE; break;
case SQL_API_SQLPREPARE: *pfExists = TRUE; break;
case SQL_API_SQLROWCOUNT: *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;
- // ODBC level 1 functions
+ /* ODBC level 1 functions */
case SQL_API_SQLBINDPARAMETER: *pfExists = TRUE; break;
case SQL_API_SQLCOLUMNS: *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_SQLGETFUNCTIONS: *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_SQLPARAMDATA: *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_SQLSPECIALCOLUMNS: *pfExists = TRUE; break;
case SQL_API_SQLSTATISTICS: *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_SQLCOLUMNPRIVILEGES: *pfExists = FALSE; break;
- case SQL_API_SQLDATASOURCES: *pfExists = FALSE; break; // only implemented by DM
- case SQL_API_SQLDESCRIBEPARAM: *pfExists = FALSE; break; // not properly implemented
- case SQL_API_SQLDRIVERS: *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_SQLDRIVERS: *pfExists = FALSE; break; /* only implemented by DM */
case SQL_API_SQLEXTENDEDFETCH: *pfExists = TRUE; break;
case SQL_API_SQLFOREIGNKEYS: *pfExists = TRUE; break;
case SQL_API_SQLMORERESULTS: *pfExists = TRUE; break;
case SQL_API_SQLPROCEDURECOLUMNS: *pfExists = FALSE; break;
case SQL_API_SQLPROCEDURES: *pfExists = FALSE; 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;
}
}
}
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");
strcat(tables_query, " where relkind = 'r'");
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);
i = 0;
prefix[i] = strtok(prefixes, ";");
strcat(tables_query, " and int4out(usesysid) = int4out(relowner)");
strcat(tables_query, "order by relname");
- // **********************************************************************
+ /* ********************************************************************** */
result = SQLExecDirect(htbl_stmt, tables_query, strlen(tables_query));
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
return SQL_ERROR;
}
- // the binding structure for a statement is not set up until
- // a statement is actually executed, so we'll have to do this ourselves.
+ /* the binding structure for a statement is not set up until */
+ /* a statement is actually executed, so we'll have to do this ourselves. */
extend_bindings(stmt, 5);
- // set the field names
+ /* set the field names */
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, 1, "TABLE_OWNER", 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);
- // add the tuples
+ /* add the tuples */
result = SQLFetch(htbl_stmt);
while((result == SQL_SUCCESS) || (result == SQL_SUCCESS_WITH_INFO)) {
set_tuplefield_string(&row->tuple[0], "");
- // I have to hide the table owner from Access, otherwise it
- // insists on referring to the table as 'owner.table'.
- // (this is valid according to the ODBC SQL grammar, but
- // Postgres won't support it.)
- // set_tuplefield_string(&row->tuple[1], table_owner);
+ /* I have to hide the table owner from Access, otherwise it */
+ /* insists on referring to the table as 'owner.table'. */
+ /* (this is valid according to the ODBC SQL grammar, but */
+ /* Postgres won't support it.) */
+ /* set_tuplefield_string(&row->tuple[1], table_owner); */
mylog("SQLTables: table_name = '%s'\n", table_name);
return SQL_ERROR;
}
- // also, things need to think that this statement is finished so
- // the results can be retrieved.
+ /* also, things need to think that this statement is finished so */
+ /* the results can be retrieved. */
stmt->status = STMT_FINISHED;
- // set up the current tuple pointer for SQLFetch
+ /* set up the current tuple pointer for SQLFetch */
stmt->currTuple = -1;
stmt->rowset_start = -1;
stmt->current_col = -1;
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"
", t.typname, a.attnum, a.attlen, %s, a.attnotnull, c.relhasrules"
" from pg_user u, pg_class c, pg_attribute a, pg_type t"
my_strcat(columns_query, " and u.usename like '%.*s'", szTableOwner, cbTableOwner);
my_strcat(columns_query, " and a.attname like '%.*s'", szColumnName, cbColumnName);
- // give the output in the order the columns were defined
- // when the table was created
+ /* give the output in the order the columns were defined */
+ /* when the table was created */
strcat(columns_query, " order by attnum");
- // **********************************************************************
+ /* ********************************************************************** */
result = SQLAllocStmt( stmt->hdbc, &hcol_stmt);
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
return SQL_ERROR;
}
- // the binding structure for a statement is not set up until
- // a statement is actually executed, so we'll have to do this ourselves.
+ /* the binding structure for a statement is not set up until */
+ /* a statement is actually executed, so we'll have to do this ourselves. */
result_cols = 14;
extend_bindings(stmt, result_cols);
- // set the field names
+ /* set the field names */
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, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
QR_set_field_info(stmt->result, 10, "NULLABLE", PG_TYPE_INT2, 2);
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, 13, "FIELD_TYPE", PG_TYPE_INT4, 4);
(result_cols - 1) * sizeof(TupleField));
set_tuplefield_string(&row->tuple[0], "");
- // see note in SQLTables()
- // set_tuplefield_string(&row->tuple[1], table_owner);
+ /* see note in SQLTables() */
+ /* set_tuplefield_string(&row->tuple[1], table_owner); */
set_tuplefield_string(&row->tuple[1], "");
set_tuplefield_string(&row->tuple[2], table_name);
set_tuplefield_string(&row->tuple[3], "oid");
set_tuplefield_string(&row->tuple[0], "");
- // see note in SQLTables()
- // set_tuplefield_string(&row->tuple[1], table_owner);
+ /* see note in SQLTables() */
+ /* set_tuplefield_string(&row->tuple[1], table_owner); */
set_tuplefield_string(&row->tuple[1], "");
set_tuplefield_string(&row->tuple[2], table_name);
set_tuplefield_string(&row->tuple[3], field_name);
if (field_type == PG_TYPE_NUMERIC) {
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) {
useStaticPrecision = FALSE;
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[12], precision + 2); // sign+dec.point
+ set_tuplefield_int4(&row->tuple[12], precision + 2); /* sign+dec.point */
set_nullfield_int2(&row->tuple[8], scale);
}
}
useStaticPrecision = FALSE;
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)
mod_length = globals.max_varchar_size;
return SQL_ERROR;
}
- // Put the row version column at the end so it might not be
- // mistaken for a key field.
+ /* Put the row version column at the end so it might not be */
+ /* mistaken for a key field. */
if ( relhasrules[0] != '1' && ! stmt->internal && atoi(ci->row_versioning)) {
/* For Row Versioning fields */
the_type = PG_TYPE_INT4;
QR_add_tuple(stmt->result, row);
}
- // also, things need to think that this statement is finished so
- // the results can be retrieved.
+ /* also, things need to think that this statement is finished so */
+ /* the results can be retrieved. */
stmt->status = STMT_FINISHED;
- // set up the current tuple pointer for SQLFetch
+ /* set up the current tuple pointer for SQLFetch */
stmt->currTuple = -1;
stmt->rowset_start = -1;
stmt->current_col = -1;
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 "
"from pg_user u, pg_class c where "
"u.usesysid = c.relowner");
return SQL_ERROR;
}
- // the binding structure for a statement is not set up until
- // a statement is actually executed, so we'll have to do this ourselves.
+ /* the binding structure for a statement is not set up until */
+ /* a statement is actually executed, so we'll have to do this ourselves. */
extend_bindings(stmt, 13);
- // set the field names
+ /* set the field names */
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, 1, "TABLE_OWNER", 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
- // we never use qualifiers.
+ /* only use the table name... the owner should be redundant, and */
+ /* we never use qualifiers. */
table_name = make_string(szTableName, cbTableName, NULL);
if ( ! table_name) {
stmt->errormsg = "No table name passed to SQLStatistics.";
return SQL_ERROR;
}
- // we need to get a list of the field names first,
- // so we can return them later.
+ /* we need to get a list of the field names first, */
+ /* so we can return them later. */
result = SQLAllocStmt( stmt->hdbc, &hcol_stmt);
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
stmt->errormsg = "SQLAllocStmt failed in SQLStatistics for columns.";
col_stmt->internal = FALSE;
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
- stmt->errormsg = col_stmt->errormsg; // "SQLColumns failed in SQLStatistics.";
- stmt->errornumber = col_stmt->errornumber; // STMT_EXEC_ERROR;
+ stmt->errormsg = col_stmt->errormsg; /* "SQLColumns failed in SQLStatistics."; */
+ stmt->errornumber = col_stmt->errornumber; /* STMT_EXEC_ERROR; */
SQLFreeStmt(hcol_stmt, SQL_DROP);
goto SEEYA;
}
result = SQLFetch(hcol_stmt);
}
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;
SQLFreeStmt(hcol_stmt, SQL_DROP);
goto SEEYA;
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);
if((result != SQL_SUCCESS) && (result != SQL_SUCCESS_WITH_INFO)) {
stmt->errormsg = "SQLAllocStmt failed in SQLStatistics for indices.";
result = SQLExecDirect(hindx_stmt, index_query, strlen(index_query));
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;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
}
- // bind the index name column
+ /* bind the index name column */
result = SQLBindCol(hindx_stmt, 1, SQL_C_CHAR,
index_name, MAX_INFO_STRING, &index_name_len);
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;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
}
- // bind the vector column
+ /* bind the vector column */
result = SQLBindCol(hindx_stmt, 2, SQL_C_DEFAULT,
fields_vector, 16, &fields_vector_len);
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;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
}
- // bind the "is unique" column
+ /* bind the "is unique" column */
result = SQLBindCol(hindx_stmt, 3, SQL_C_CHAR,
isunique, sizeof(isunique), NULL);
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;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
}
- // bind the "is clustered" column
+ /* bind the "is clustered" column */
result = SQLBindCol(hindx_stmt, 4, SQL_C_CHAR,
isclustered, sizeof(isclustered), NULL);
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;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
row = (TupleNode *)malloc(sizeof(TupleNode) +
(13 - 1) * sizeof(TupleField));
- // no table qualifier
+ /* no table qualifier */
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[2], table_name);
- // non-unique index?
+ /* non-unique index? */
set_tuplefield_int2(&row->tuple[3], (Int2) (globals.unique_index ? FALSE : TRUE));
- // no index qualifier
+ /* no index qualifier */
set_tuplefield_string(&row->tuple[4], "");
sprintf(buf, "%s_idx_fake_oid", table_name);
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[7], (Int2) 1);
result = SQLFetch(hindx_stmt);
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 ||
(fUnique == SQL_INDEX_UNIQUE && atoi(isunique))) {
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) {
row = (TupleNode *)malloc(sizeof(TupleNode) +
(13 - 1) * sizeof(TupleField));
- // no table qualifier
+ /* no table qualifier */
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[2], table_name);
- // non-unique index?
+ /* non-unique index? */
if (globals.unique_index)
set_tuplefield_int2(&row->tuple[3], (Int2) (atoi(isunique) ? FALSE : TRUE));
else
set_tuplefield_int2(&row->tuple[3], TRUE);
- // no index qualifier
+ /* no index qualifier */
set_tuplefield_string(&row->tuple[4], "");
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[7], (Int2) (i+1));
result = SQLFetch(hindx_stmt);
}
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;
SQLFreeStmt(hindx_stmt, SQL_DROP);
goto SEEYA;
SQLFreeStmt(hindx_stmt, SQL_DROP);
- // also, things need to think that this statement is finished so
- // the results can be retrieved.
+ /* also, things need to think that this statement is finished so */
+ /* the results can be retrieved. */
stmt->status = STMT_FINISHED;
- // set up the current tuple pointer for SQLFetch
+ /* set up the current tuple pointer for SQLFetch */
stmt->currTuple = -1;
stmt->rowset_start = -1;
stmt->current_col = -1;
return SQL_ERROR;
}
- // the binding structure for a statement is not set up until
- // a statement is actually executed, so we'll have to do this ourselves.
+ /* the binding structure for a statement is not set up until */
+ /* a statement is actually executed, so we'll have to do this ourselves. */
result_cols = 6;
extend_bindings(stmt, result_cols);
- // set the field names
+ /* set the field names */
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, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
SQLFreeStmt(htbl_stmt, SQL_DROP);
- // also, things need to think that this statement is finished so
- // the results can be retrieved.
+ /* also, things need to think that this statement is finished so */
+ /* the results can be retrieved. */
stmt->status = STMT_FINISHED;
- // set up the current tuple pointer for SQLFetch
+ /* set up the current tuple pointer for SQLFetch */
stmt->currTuple = -1;
stmt->rowset_start = -1;
stmt->current_col = -1;
return SQL_ERROR;
}
- // the binding structure for a statement is not set up until
- // a statement is actually executed, so we'll have to do this ourselves.
+ /* the binding structure for a statement is not set up until */
+ /* a statement is actually executed, so we'll have to do this ourselves. */
result_cols = 14;
extend_bindings(stmt, result_cols);
- // set the field names
+ /* set the field names */
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, 1, "PKTABLE_OWNER", 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);
- // also, things need to think that this statement is finished so
- // the results can be retrieved.
+ /* also, things need to think that this statement is finished so */
+ /* the results can be retrieved. */
stmt->status = STMT_FINISHED;
- // set up the current tuple pointer for SQLFetch
+ /* set up the current tuple pointer for SQLFetch */
stmt->currTuple = -1;
stmt->rowset_start = -1;
stmt->current_col = -1;
set_tuplefield_string(&row->tuple[2], prel);
- // Get to the primary key
+ /* Get to the primary key */
ptr += strlen(ptr) + 1;
mylog("prel = '%s', ptr = '%s'\n", prel, ptr);
QR_add_tuple(stmt->result, row);
- // next foreign key
+ /* next foreign key */
fkptr += strlen(fkptr) + 1;
}
}
while (result == SQL_SUCCESS) {
- // Get the number of tables
+ /* Get the number of tables */
ptr = args;
ntabs = atoi(args);
ptr += strlen(ptr) + 1;
- // Handle action (i.e., 'cascade', 'restrict', 'setnull')
+ /* Handle action (i.e., 'cascade', 'restrict', 'setnull') */
switch(tolower(ptr[0])) {
case 'c':
action = SQL_CASCADE;
rule_type >>= TRIGGER_SHIFT;
ptr += strlen(ptr) + 1;
- // Calculate the number of key parts
+ /* Calculate the number of key parts */
pkeys = (nargs - ( 2 + ntabs)) / (ntabs + 1);
pkey_ptr = ptr;
ntabs = 0;
}
- // Get to the last primary keypart
+ /* Get to the last primary keypart */
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)) {
ntabs = 0;
break;
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++) {
seq = 0;
set_tuplefield_string(&row->tuple[5], "");
set_tuplefield_string(&row->tuple[6], frel);
- // Get to the foreign key
+ /* Get to the foreign key */
ptr += strlen(ptr) + 1;
set_tuplefield_string(&row->tuple[7], ptr);
QR_add_tuple(stmt->result, row);
- // next primary key
+ /* next primary key */
pkptr += strlen(pkptr) + 1;
}
argv[0].u.integer = mode;
if ( ! CC_send_function(conn, LO_CREAT, &retval, &result_len, 1, argv, 1))
- return 0; // invalid oid
+ return 0; /* invalid oid */
else
return retval;
return strlen(dst);
}
-// strncpy copies up to len characters, and doesn't terminate
-// the destination string if src has len characters or more.
-// instead, I want it to copy up to len-1 characters and always
-// terminate the destination string.
+/* strncpy copies up to len characters, and doesn't terminate */
+/* the destination string if src has len characters or more. */
+/* instead, I want it to copy up to len-1 characters and always */
+/* terminate the destination string. */
char *strncpy_null(char *dst, const char *src, int len)
{
int i;
return dst;
}
-// 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.
-// 2. If buf is not supplied, malloc space and return this string
+/* 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. */
+/* 2. If buf is not supplied, malloc space and return this string */
char *
make_string(char *s, int len, char *buf)
{
return NULL;
}
-// Concatenate a single formatted argument to a given buffer handling the SQL_NTS thing.
-// "fmt" must contain somewhere in it the single form '%.*s'
-// This is heavily used in creating queries for info routines (SQLTables, SQLColumns).
-// This routine could be modified to use vsprintf() to handle multiple arguments.
+/* Concatenate a single formatted argument to a given buffer handling the SQL_NTS thing. */
+/* "fmt" must contain somewhere in it the single form '%.*s' */
+/* This is heavily used in creating queries for info routines (SQLTables, SQLColumns). */
+/* This routine could be modified to use vsprintf() to handle multiple arguments. */
char *
my_strcat(char *buf, char *fmt, char *s, int len)
{
#ifndef WIN32
#define mylog(args...) /* GNU convention for variable arguments */
#else
- #define mylog // mylog
+ #define mylog /* mylog */
#endif
#endif
#ifndef WIN32
#define qlog(args...) /* GNU convention for variable arguments */
#else
- #define qlog // qlog
+ #define qlog /* qlog */
#endif
#endif
else {
if (vParam == SQL_CURSOR_FORWARD_ONLY || vParam == SQL_CURSOR_STATIC) {
- if (conn) conn->stmtOptions.cursor_type = vParam; // valid type
- if (stmt) stmt->options.cursor_type = vParam; // valid type
+ if (conn) conn->stmtOptions.cursor_type = vParam; /* valid type */
+ if (stmt) stmt->options.cursor_type = vParam; /* valid type */
}
else {
case SQL_QUERY_TIMEOUT: /* ignored */
mylog("SetStmtOption: SQL_QUERY_TIMEOUT, vParam = %d\n", vParam);
- // "0" returned in SQLGetStmtOption
+ /* "0" returned in SQLGetStmtOption */
break;
case SQL_RETRIEVE_DATA: /* ignored, but saved */
return SQL_SUCCESS;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
/* This function just can tell you whether you are in Autcommit mode or not */
RETCODE SQL_API SQLGetConnectOption(
return SQL_SUCCESS;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
RETCODE SQL_API SQLSetStmtOption(
HSTMT hstmt,
mylog("%s: entering...\n", func);
- // thought we could fake Access out by just returning SQL_SUCCESS
- // all the time, but it tries to set a huge value for SQL_MAX_LENGTH
- // and expects the driver to reduce it to the real value
+ /* thought we could fake Access out by just returning SQL_SUCCESS */
+ /* all the time, but it tries to set a huge value for SQL_MAX_LENGTH */
+ /* and expects the driver to reduce it to the real value */
if( ! stmt) {
SC_log_error(func, "", NULL);
}
-// - - - - - - - - -
+/* - - - - - - - - - */
RETCODE SQL_API SQLGetStmtOption(
HSTMT hstmt,
mylog("%s: entering...\n", func);
- // thought we could fake Access out by just returning SQL_SUCCESS
- // all the time, but it tries to set a huge value for SQL_MAX_LENGTH
- // and expects the driver to reduce it to the real value
+ /* thought we could fake Access out by just returning SQL_SUCCESS */
+ /* all the time, but it tries to set a huge value for SQL_MAX_LENGTH */
+ /* and expects the driver to reduce it to the real value */
if( ! stmt) {
SC_log_error(func, "", NULL);
res = stmt->result;
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) ||
(stmt->currTuple >= QR_get_num_tuples(res))) {
stmt->errormsg = "Not positioned on a valid row.";
return SQL_SUCCESS;
}
-// - - - - - - - - -
+/* - - - - - - - - - */
/* skip leading delimiters */
while (isspace(s[i]) || s[i] == ',') {
- // mylog("skipping '%c'\n", s[i]);
+ /* mylog("skipping '%c'\n", s[i]); */
i++;
}
i++;
}
- // mylog("done -- s[%d] = '%c'\n", i, s[i]);
+ /* mylog("done -- s[%d] = '%c'\n", i, s[i]); */
token[out] = '\0';
}
-/*
+#if 0
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, 1, "TABLE_OWNER", PG_TYPE_TEXT, MAX_INFO_STRING);
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, 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, 13, "FIELD_TYPE", PG_TYPE_INT4, 4);
-*/
+#endif
void
getColInfo(COL_INFO *col_info, FIELD_INFO *fi, int k)
total_cols--; /* makes up for the star */
/* Allocate some more field pointers if necessary */
- //-------------------------------------------------------------
+ /*------------------------------------------------------------- */
old_size = (stmt->nfld / FLD_INCR * FLD_INCR + FLD_INCR);
need = total_cols - (old_size - stmt->nfld);
}
}
- //-------------------------------------------------------------
- // 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--) {
mylog("copying field %d to %d\n", j, total_cols + j);
fi[total_cols + j] = fi[j];
}
mylog("done copying fields\n");
- //-------------------------------------------------------------
- // Set the new number of fields
+ /*------------------------------------------------------------- */
+ /* Set the new number of fields */
stmt->nfld += total_cols;
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);
for (n = 0; n < cols; 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) {
mylog("allocating field info at %d\n", n + i);
fi[n + i] = (FIELD_INFO *) malloc( sizeof(FIELD_INFO));
mylog("i now at %d\n", i);
}
- //-------------------------------------------------------------
+ /*------------------------------------------------------------- */
}
/* We either know which table the field was in because it was qualified
Int2 sqltype_to_default_ctype(Int2 sqltype)
{
- // from the table on page 623 of ODBC 2.0 Programmer's Reference
- // (Appendix D)
+ /* from the table on page 623 of ODBC 2.0 Programmer's Reference */
+ /* (Appendix D) */
switch(sqltype) {
case SQL_CHAR:
case SQL_VARCHAR:
/* 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_BYTEA 17
/* Info limits */
#define MAX_INFO_STRING 128
#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
if (self->manual_tuples)
TL_Destructor(self->manual_tuples);
- // If conn is defined, then we may have used "backend_tuples",
- // so in case we need to, free it up. Also, close the cursor.
+ /* If conn is defined, then we may have used "backend_tuples", */
+ /* so in case we need to, free it up. Also, close the cursor. */
if (self->conn && self->conn->sock && CC_is_in_trans(self->conn))
- QR_close(self); // close the cursor if there is one
+ 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)
free(self->cursor);
free(tuple[lf].value);
}
}
- tuple += num_fields; // next row
+ tuple += num_fields; /* next row */
}
free(self->backend_tuples);
mylog("QResult: free memory out\n");
}
-// This function is called by send_query()
+/* This function is called by send_query() */
char
QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor)
{
int tuple_size;
- // If called from send_query the first time (conn != NULL),
- // then set the inTuples state,
- // and read the tuples. If conn is NULL,
- // it implies that we are being called from next_tuple(),
- // like to get more rows so don't call next_tuple again!
+ /* If called from send_query the first time (conn != NULL), */
+ /* then set the inTuples state, */
+ /* and read the tuples. If conn is NULL, */
+ /* it implies that we are being called from next_tuple(), */
+ /* like to get more rows so don't call next_tuple again! */
if (conn != NULL) {
self->conn = conn;
self->cursor = strdup(cursor);
}
- // Read the field attributes.
- // $$$$ Should do some error control HERE! $$$$
+ /* Read the field attributes. */
+ /* $$$$ Should do some error control HERE! $$$$ */
if ( CI_read_fields(self->fields, self->conn)) {
self->status = PGRES_FIELDS_OK;
self->num_fields = CI_get_num_fields(self->fields);
}
else {
- // Always have to read the field attributes.
- // But we dont have to reallocate memory for them!
+ /* Always have to read the field attributes. */
+ /* But we dont have to reallocate memory for them! */
if ( ! CI_read_fields(NULL, self->conn)) {
self->status = PGRES_BAD_RESPONSE;
}
}
-// Close the cursor and end the transaction (if no cursors left)
-// We only close cursor/end the transaction if a cursor was used.
+/* Close the cursor and end the transaction (if no cursors left) */
+/* We only close cursor/end the transaction if a cursor was used. */
int
QR_close(QResultClass *self)
{
return TRUE;
}
-// This function is called by fetch_tuples() AND SQLFetch()
+/* This function is called by fetch_tuples() AND SQLFetch() */
int
QR_next_tuple(QResultClass *self)
{
char corrected = FALSE;
TupleField *the_tuples = self->backend_tuples;
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];
QueryInfo qi;
return TRUE;
}
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);
self->tupleField = NULL;
self->status = PGRES_END_TUPLES;
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.result_in = self;
qi.cursor = NULL;
}
self->fcount++;
- break; // continue reading
+ break; /* continue reading */
case 'C': /* End of tuple list */
self->tupleField = self->backend_tuples + (offset * self->num_fields);
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");
mylog("_next_tuple: 'C': DONE (fcount == 0)\n");
return -1; /* end of tuples */
Int2 bitcnt;
Int4 len;
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);
ColumnInfoClass *flds;
struct QResultClass_ {
- ColumnInfoClass *fields; // the Column information
- TupleListClass *manual_tuples; // manual result tuple list
- ConnectionClass *conn; // the connection this result is using (backend)
+ ColumnInfoClass *fields; /* the Column information */
+ TupleListClass *manual_tuples; /* manual result tuple list */
+ ConnectionClass *conn; /* the connection this result is using (backend) */
- // Stuff for declare/fetch tuples
- int fetch_count; // logical rows read so far
- int fcount; // actual rows read in the fetch
+ /* Stuff for declare/fetch tuples */
+ int fetch_count; /* logical rows read so far */
+ int fcount; /* actual rows read in the fetch */
int currTuple;
int base;
- int num_fields; // number of fields in the result
+ int num_fields; /* number of fields in the result */
int cache_size;
int rowset_size;
QueryResultCode status;
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 *notice;
- TupleField *backend_tuples; // data from the backend (the tuple cache)
- TupleField *tupleField; // current backend tuple being retrieved
+ TupleField *backend_tuples; /* data from the backend (the tuple cache) */
+ 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_notice(self) (self->notice)
#define QR_get_status(self) (self->status)
-// Core Functions
+/* Core Functions */
QResultClass *QR_Constructor(void);
void QR_Destructor(QResultClass *self);
char QR_read_tuple(QResultClass *self, char binary);
-//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by psqlodbc.rc
-//
+/*{{NO_DEPENDENCIES}} */
+/* Microsoft Developer Studio generated include file. */
+/* Used by psqlodbc.rc */
+/* */
#define IDS_BADDSN 1
#define IDS_MSGTITLE 2
#define DLG_OPTIONS_DRV 102
#define DS_PG64 1057
#define DS_PG63 1058
-// Next default values for new objects
-//
+/* Next default values for new objects */
+/* */
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
if (res && pcrow) {
msg = QR_get_command(res);
mylog("*** msg = '%s'\n", msg);
- trim(msg); // get rid of trailing spaces
+ trim(msg); /* get rid of trailing spaces */
ptr = strrchr(msg, ' ');
if (ptr) {
*pcrow = atoi(ptr+1);
}
-// This returns the number of columns associated with the database
-// attached to "hstmt".
+/* This returns the number of columns associated with the database */
+/* attached to "hstmt". */
RETCODE SQL_API SQLNumResultCols(
}
-// - - - - - - - - -
+/* - - - - - - - - - */
-// Return information about the database column the user wants
-// information about.
+/* Return information about the database column the user wants */
+/* information about. */
RETCODE SQL_API SQLDescribeCol(
HSTMT hstmt,
UWORD icol,
col_name = QR_get_fieldname(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);
if (pcbColDef) {
if ( precision < 0)
- precision = 0; // "I dont know"
+ precision = 0; /* "I dont know" */
*pcbColDef = precision;
return result;
}
-// Returns result column descriptor information for a result set.
+/* Returns result column descriptor information for a result set. */
RETCODE SQL_API SQLColAttributes(
HSTMT hstmt,
icol--;
- unknown_sizes = globals.unknown_sizes; // atoi(ci->unknown_sizes);
- if (unknown_sizes == UNKNOWNS_AS_DONTKNOW) // not appropriate for SQLColAttributes()
+ unknown_sizes = globals.unknown_sizes; /* atoi(ci->unknown_sizes); */
+ if (unknown_sizes == UNKNOWNS_AS_DONTKNOW) /* not appropriate for SQLColAttributes() */
unknown_sizes = UNKNOWNS_AS_MAX;
parse_ok = FALSE;
mylog("SQLColAttr: COLUMN_LABEL = '%s'\n", p);
break;
- } // otherwise same as column name -- FALL THROUGH!!!
+ } /* otherwise same as column name -- FALL THROUGH!!! */
case SQL_COLUMN_NAME:
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(
HSTMT hstmt,
else {
- // use zero-based column numbers
+ /* use zero-based column numbers */
icol--;
- // make sure the column number is valid
+ /* make sure the column number is valid */
num_cols = QR_NumResultCols(res);
if (icol >= num_cols) {
stmt->errormsg = "Invalid column number.";
}
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);
if((stmt->currTuple < 0) ||
(stmt->currTuple >= num_rows)) {
-// Returns data for bound columns in the current row ("hstmt->iCursor"),
-// advances the cursor.
+/* Returns data for bound columns in the current row ("hstmt->iCursor"), */
+/* advances the cursor. */
RETCODE SQL_API SQLFetch(
HSTMT hstmt)
}
if (stmt->bindings == NULL) {
- // just to avoid a crash if the user insists on calling this
- // function even if SQL_ExecDirect has reported an Error
+ /* just to avoid a crash if the user insists on calling this */
+ /* function even if SQL_ExecDirect has reported an Error */
stmt->errormsg = "Bindings were not allocated properly.";
stmt->errornumber = STMT_SEQUENCE_ERROR;
SC_log_error(func, "", stmt);
return SC_fetch(stmt);
}
-// This fetchs a block of data (rowset).
+/* This fetchs a block of data (rowset). */
RETCODE SQL_API SQLExtendedFetch(
HSTMT hstmt,
}
if (stmt->bindings == NULL) {
- // just to avoid a crash if the user insists on calling this
- // function even if SQL_ExecDirect has reported an Error
+ /* just to avoid a crash if the user insists on calling this */
+ /* function even if SQL_ExecDirect has reported an Error */
stmt->errormsg = "Bindings were not allocated properly.";
stmt->errornumber = STMT_SEQUENCE_ERROR;
SC_log_error(func, "", stmt);
truncated = error = FALSE;
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);
/* Determine Function status */
}
-// This determines whether there are more results sets available for
-// the "hstmt".
+/* This determines whether there are more results sets available for */
+/* the "hstmt". */
/* CC: return SQL_NO_DATA_FOUND since we do not support multiple result sets */
RETCODE SQL_API SQLMoreResults(
return SQL_NO_DATA_FOUND;
}
-// 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 positions the cursor within a rowset, that was positioned using SQLExtendedFetch. */
+/* This will be useful (so far) only when using SQLGetData after SQLExtendedFetch. */
RETCODE SQL_API SQLSetPos(
HSTMT hstmt,
UWORD irow,
}
-// Sets options that control the behavior of cursors.
+/* Sets options that control the behavior of cursors. */
RETCODE SQL_API SQLSetScrollOptions(
HSTMT hstmt,
}
-// Set the cursor name on a statement handle
+/* Set the cursor name on a statement handle */
RETCODE SQL_API SQLSetCursorName(
HSTMT hstmt,
return SQL_SUCCESS;
}
-// Return the cursor name for a statement handle
+/* Return the cursor name for a statement handle */
RETCODE SQL_API SQLGetCursorName(
HSTMT hstmt,
extern HINSTANCE NEAR s_hModule; /* Saved module handle. */
extern GLOBAL_VALUES globals;
-// Constants ---------------------------------------------------------------
+/* Constants --------------------------------------------------------------- */
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#ifdef WIN32
#define MAXPGPATH (255+1)
#endif
-#define MAXKEYLEN (15+1) // Max keyword length
-#define MAXDESC (255+1) // Max description length
-#define MAXDSNAME (32+1) // Max data source name length
+#define MAXKEYLEN (15+1) /* Max keyword length */
+#define MAXDESC (255+1) /* Max description length */
+#define MAXDSNAME (32+1) /* Max data source name length */
-// Globals -----------------------------------------------------------------
-// NOTE: All these are used by the dialog procedures
+/* Globals ----------------------------------------------------------------- */
+/* NOTE: All these are used by the dialog procedures */
typedef struct tagSETUPDLG {
- HWND hwndParent; // Parent window handle
- LPCSTR lpszDrvr; // Driver description
+ HWND hwndParent; /* Parent window handle */
+ LPCSTR lpszDrvr; /* Driver description */
ConnInfo ci;
- char szDSN[MAXDSNAME]; // Original data source name
- BOOL fNewDSN; // New data source flag
- BOOL fDefault; // Default data source flag
+ char szDSN[MAXDSNAME]; /* Original data source name */
+ BOOL fNewDSN; /* New data source flag */
+ BOOL fDefault; /* Default data source flag */
} SETUPDLG, FAR *LPSETUPDLG;
-// Prototypes --------------------------------------------------------------
+/* Prototypes -------------------------------------------------------------- */
void INTFUNC CenterDialog(HWND hdlg);
int CALLBACK ConfigDlgProc(HWND hdlg, WORD wMsg, WPARAM wParam, LPARAM lParam);
void INTFUNC ParseAttributes (LPCSTR lpszAttributes, LPSETUPDLG lpsetupdlg);
LPCSTR lpszDriver,
LPCSTR lpszAttributes)
{
-BOOL fSuccess; // Success/fail flag
+BOOL fSuccess; /* Success/fail flag */
GLOBALHANDLE hglbAttr;
LPSETUPDLG lpsetupdlg;
- // Allocate attribute array
+ /* Allocate attribute array */
hglbAttr = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof(SETUPDLG));
if (!hglbAttr)
return FALSE;
lpsetupdlg = (LPSETUPDLG)GlobalLock(hglbAttr);
- // Parse attribute string
+ /* Parse attribute string */
if (lpszAttributes)
ParseAttributes(lpszAttributes, lpsetupdlg);
- // Save original data source name
+ /* Save original data source name */
if (lpsetupdlg->ci.dsn[0])
lstrcpy(lpsetupdlg->szDSN, lpsetupdlg->ci.dsn);
else
lpsetupdlg->szDSN[0] = '\0';
- // Remove data source
+ /* Remove data source */
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])
fSuccess = FALSE;
- // Otherwise remove data source from ODBC.INI
+ /* Otherwise remove data source from ODBC.INI */
else
fSuccess = SQLRemoveDSNFromIni(lpsetupdlg->ci.dsn);
}
- // Add or Configure data source
+ /* Add or Configure data source */
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->lpszDrvr = lpszDriver;
lpsetupdlg->fNewDSN = (ODBC_ADD_DSN == fRequest);
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) {
- // Display dialog(s)
+ /* Display dialog(s) */
fSuccess = (IDOK == DialogBoxParam(s_hModule,
MAKEINTRESOURCE(DLG_CONFIG),
hwnd,
{
switch (wMsg) {
- // Initialize the dialog
+ /* Initialize the dialog */
case WM_INITDIALOG:
{
LPSETUPDLG lpsetupdlg = (LPSETUPDLG) lParam;
ShowWindow(GetDlgItem(hdlg, DRV_MSG_LABEL), SW_HIDE);
SetWindowLong(hdlg, DWL_USER, lParam);
- CenterDialog(hdlg); // Center dialog
+ CenterDialog(hdlg); /* Center dialog */
- // NOTE: Values supplied in the attribute string will always
- // override settings in ODBC.INI
+ /* NOTE: Values supplied in the attribute string will always */
+ /* override settings in ODBC.INI */
- // Get the rest of the common attributes
+ /* Get the rest of the common attributes */
getDSNinfo(ci, CONN_DONT_OVERWRITE);
- // Fill in any defaults
+ /* Fill in any defaults */
getDSNdefaults(ci);
- // Initialize dialog fields
+ /* Initialize dialog fields */
SetDlgStuff(hdlg, ci);
SendDlgItemMessage(hdlg, IDC_DESC,
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:
switch (GET_WM_COMMAND_ID(wParam, lParam)) {
- // Ensure the OK button is enabled only when a data source name
- // is entered
+ /* Ensure the OK button is enabled only when a data source name */
+ /* is entered */
case IDC_DSNAME:
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),
GetDlgItemText(hdlg, IDC_DSNAME,
szItem, sizeof(szItem)));
}
break;
- // Accept results
+ /* Accept results */
case IDOK:
{
LPSETUPDLG lpsetupdlg;
lpsetupdlg = (LPSETUPDLG)GetWindowLong(hdlg, DWL_USER);
- // Retrieve dialog values
+ /* Retrieve dialog values */
if (!lpsetupdlg->fDefault)
GetDlgItemText(hdlg, IDC_DSNAME,
lpsetupdlg->ci.dsn,
sizeof(lpsetupdlg->ci.dsn));
- // Get Dialog Values
+ /* Get Dialog Values */
GetDlgStuff(hdlg, &lpsetupdlg->ci);
- // Update ODBC.INI
+ /* Update ODBC.INI */
SetDSNAttributes(hdlg, lpsetupdlg);
}
- // Return to caller
+ /* Return to caller */
case IDCANCEL:
EndDialog(hdlg, wParam);
return TRUE;
break;
}
- // Message not processed
+ /* Message not processed */
return FALSE;
}
memset(&lpsetupdlg->ci, 0, sizeof(ConnInfo));
for (lpsz=lpszAttributes; *lpsz; lpsz++)
- { // Extract key name (e.g., DSN), it must be terminated by an equals
+ { /* Extract key name (e.g., DSN), it must be terminated by an equals */
lpszStart = lpsz;
for (;; lpsz++)
{
if (!*lpsz)
- return; // No key was found
+ return; /* No key was found */
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;
if (cbKey < sizeof(aszKey))
{
aszKey[cbKey] = '\0';
}
- // Locate end of key value
+ /* Locate end of key value */
lpszStart = ++lpsz;
for (; *lpsz; lpsz++);
- // lpsetupdlg->aAttr[iElement].fSupplied = TRUE;
+ /* lpsetupdlg->aAttr[iElement].fSupplied = TRUE; */
_fmemcpy(value, lpszStart, MIN(lpsz-lpszStart+1, MAXPGPATH));
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);
}
return;
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;
- // Validate arguments
+ /* Validate arguments */
if (lpsetupdlg->fNewDSN && !*lpsetupdlg->ci.dsn)
return FALSE;
- // Write the data source name
+ /* Write the data source name */
if (!SQLWriteDSNToIni(lpszDSN, lpsetupdlg->lpszDrvr))
{
if (hwndParent)
}
- // Update ODBC.INI
+ /* Update ODBC.INI */
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))
{
SQLRemoveDSNFromIni(lpsetupdlg->szDSN);
{
if (self->buffer_read_in >= self->buffer_filled_in) {
- // there are no more bytes left in the buffer ->
- // reload the buffer
+ /* there are no more bytes left in the buffer -> */
+ /* reload the buffer */
self->buffer_read_in = 0;
self->buffer_filled_in = recv(self->socket, (char *)self->buffer_in, globals.socket_buffersize, 0);
self->buffer_out[self->buffer_filled_out++] = next_byte;
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);
if (bytes_sent != globals.socket_buffersize) {
self->errornumber = SOCKET_WRITE_ERROR;
/* this should discard all the results, but leave the statement */
/* itself in place (it can be executed again) */
if (!SC_recycle_statement(stmt)) {
- // errormsg passed in above
+ /* errormsg passed in above */
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
void
InitializeStatementOptions(StatementOptions *opt)
{
- opt->maxRows = 0; // driver returns all rows
- opt->maxLength = 0; // driver returns all data for char/binary
+ opt->maxRows = 0; /* driver returns all rows */
+ opt->maxLength = 0; /* driver returns all data for char/binary */
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->cursor_type = SQL_CURSOR_FORWARD_ONLY;
opt->bind_size = 0; /* default is to bind by column */
/****************************************************************/
self->status = STMT_READY;
- self->manual_result = FALSE; // very important
+ self->manual_result = FALSE; /* very important */
self->currTuple = -1;
self->rowset_start = -1;
self->lobj_fd = -1;
- // Free any data at exec params before the statement is executed
- // again. If not, then there will be a memory leak when
- // the next SQLParamData/SQLPutData is called.
+ /* Free any data at exec params before the statement is executed */
+ /* again. If not, then there will be a memory leak when */
+ /* the next SQLParamData/SQLPutData is called. */
SC_free_params(self, STMT_FREE_PARAMS_DATA_AT_EXEC_ONLY);
return TRUE;
}
-// This function creates an error msg which is the concatenation
-// of the result, statement, connection, and socket messages.
+/* This function creates an error msg which is the concatenation */
+/* of the result, statement, connection, and socket messages. */
char *
SC_create_errormsg(StatementClass *self)
{
{
char rv;
- // Create a very informative errormsg if it hasn't been done yet.
+/* Create a very informative errormsg if it hasn't been done yet. */
if ( ! self->errormsg_created) {
self->errormsg = SC_create_errormsg(self);
self->errormsg_created = TRUE;
Oid type;
char *value;
ColumnInfoClass *ci;
-// TupleField *tupleField;
+/* TupleField *tupleField; */
self->last_fetch_count = 0;
ci = QR_get_fields(res); /* the column info */
}
else {
- // read from the cache or the physical next tuple
+ /* read from the cache or the physical next tuple */
retval = QR_next_tuple(res);
if (retval < 0) {
mylog("**** SQLFetch: end_tuples\n");
return SQL_NO_DATA_FOUND;
}
else if (retval > 0)
- (self->currTuple)++; // all is well
+ (self->currTuple)++; /* all is well */
else {
mylog("SQLFetch: error\n");
self->bindings[lf].data_left = -1;
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 */
mylog("type = %d\n", type);
self->status = STMT_EXECUTING;
- // If it's a SELECT statement, use a cursor.
- // Note that the declare cursor has already been prepended to the statement
- // in copy_statement...
+ /* If it's a SELECT statement, use a cursor. */
+ /* Note that the declare cursor has already been prepended to the statement */
+ /* in copy_statement... */
if (self->statement_type == STMT_TYPE_SELECT) {
char fetch[128];
}
- 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);
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)) {
res = CC_send_query(conn, "COMMIT", NULL);
QR_Destructor(res);
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);
}
else
void set_tuplefield_null(TupleField *tuple_field)
{
tuple_field->len = 0;
- tuple_field->value = NULL; // strdup("");
+ tuple_field->value = NULL; /* strdup(""); */
}
void set_tuplefield_string(TupleField *tuple_field, char *string)