Skip to content

Commit

Permalink
Back out odbc changes until 7.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmomjian committed May 17, 2000
1 parent 61190ea commit 36c02de
Show file tree
Hide file tree
Showing 28 changed files with 662 additions and 667 deletions.
80 changes: 40 additions & 40 deletions bind.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <sqlext.h>
#endif

/* Bind parameters on a statement handle */
// Bind parameters on a statement handle

RETCODE SQL_API SQLBindParameter(
HSTMT hstmt,
Expand Down Expand Up @@ -75,18 +75,18 @@ static char *func="SQLBindParameter";

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;
Expand All @@ -105,7 +105,7 @@ static char *func="SQLBindParameter";

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;
Expand Down Expand Up @@ -140,9 +140,9 @@ static char *func="SQLBindParameter";
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,
Expand Down Expand Up @@ -195,14 +195,14 @@ mylog("**** SQLBindCol: stmt = %u, icol = %d\n", stmt, 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;
Expand Down Expand Up @@ -234,14 +234,14 @@ mylog("**** SQLBindCol: stmt = %u, icol = %d\n", stmt, icol);
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,
Expand Down Expand Up @@ -270,8 +270,8 @@ static char *func = "SQLDescribeParam";

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;

Expand All @@ -287,9 +287,9 @@ static char *func = "SQLDescribeParam";
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,
Expand All @@ -304,15 +304,15 @@ static char *func = "SQLParamOptions";
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)
Expand All @@ -338,7 +338,7 @@ static char *func = "SQLNumParams";


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);
Expand Down Expand Up @@ -419,13 +419,13 @@ mylog("%s: entering ... stmt=%u, bindings_allocated=%d, num_columns=%d\n", func,
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");
}
4 changes: 2 additions & 2 deletions columninfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ CI_set_field_info(ColumnInfoClass *self, int field_num, char *new_name,
Oid new_adtid, Int2 new_adtsize, Int4 new_atttypmod)
{

/* 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;
Expand Down
48 changes: 24 additions & 24 deletions connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static char *func="SQLAllocConnect";
}


/* - - - - - - - - - */
// - - - - - - - - -

RETCODE SQL_API SQLConnect(
HDBC hdbc,
Expand Down Expand Up @@ -111,7 +111,7 @@ static char *func = "SQLConnect";
qlog("conn = %u, %s(DSN='%s', UID='%s', PWD='%s')\n", conn, func, ci->dsn, ci->username, ci->password);

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;
}
Expand All @@ -121,7 +121,7 @@ static char *func = "SQLConnect";
return SQL_SUCCESS;
}

/* - - - - - - - - - */
// - - - - - - - - -

RETCODE SQL_API SQLBrowseConnect(
HDBC hdbc,
Expand All @@ -138,7 +138,7 @@ static char *func="SQLBrowseConnect";
return SQL_SUCCESS;
}

/* - - - - - - - - - */
// - - - - - - - - -

/* Drop any hstmts open on hdbc and disconnect from database */
RETCODE SQL_API SQLDisconnect(
Expand Down Expand Up @@ -176,7 +176,7 @@ static char *func = "SQLDisconnect";
}


/* - - - - - - - - - */
// - - - - - - - - -

RETCODE SQL_API SQLFreeConnect(
HDBC hdbc)
Expand Down Expand Up @@ -229,7 +229,7 @@ ConnectionClass *rv;
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));

Expand Down Expand Up @@ -334,8 +334,8 @@ CC_clear_error(ConnectionClass *self)
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)
{
Expand Down Expand Up @@ -371,9 +371,9 @@ StatementClass *stmt;

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);

Expand Down Expand Up @@ -549,7 +549,7 @@ static char *func="CC_connect";

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))
Expand Down Expand Up @@ -579,9 +579,9 @@ static char *func="CC_connect";
mylog("gonna do authentication\n");


/* *************************************************** */
/* Now get the authentication request from backend */
/* *************************************************** */
// ***************************************************
// Now get the authentication request from backend
// ***************************************************

if ( ! PROTOCOL_62(ci)) do {

Expand Down Expand Up @@ -790,7 +790,7 @@ int rv;

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;
Expand All @@ -802,7 +802,7 @@ int rv;
}
rv = (self->errornumber != 0);

self->errornumber = 0; /* clear the error */
self->errornumber = 0; // clear the error

mylog("exit CC_get_error\n");

Expand All @@ -826,13 +826,13 @@ char swallow;
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";
Expand Down Expand Up @@ -971,7 +971,7 @@ char cmdbuffer[MAX_MESSAGE_LEN+1]; /* QR_set_command() dups this string so dont
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 */
Expand Down Expand Up @@ -1034,7 +1034,7 @@ char cmdbuffer[MAX_MESSAGE_LEN+1]; /* QR_set_command() dups this string so dont
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);
Expand Down Expand Up @@ -1186,7 +1186,7 @@ int i;
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;
Expand All @@ -1206,9 +1206,9 @@ int i;
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;
Expand Down
Loading

0 comments on commit 36c02de

Please sign in to comment.