1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-24 00:23:06 +03:00

Minor fixes to compile on unix for v6-40-0002

This commit is contained in:
Byron Nikolaidis
1998-12-29 14:59:30 +00:00
parent a75f2d21a8
commit 550de5db2c
8 changed files with 149 additions and 137 deletions

View File

@@ -740,139 +740,6 @@ mylog("SQLGetData: enter, stmt=%u\n", stmt);
}
}
RETCODE
SC_fetch(StatementClass *stmt)
{
static char *func = "SC_fetch";
QResultClass *res = stmt->result;
int retval, result;
Int2 num_cols, lf;
Oid type;
char *value;
ColumnInfoClass *ci;
// TupleField *tupleField;
stmt->last_fetch_count = 0;
ci = QR_get_fields(res); /* the column info */
mylog("manual_result = %d, use_declarefetch = %d\n", stmt->manual_result, globals.use_declarefetch);
if ( stmt->manual_result || ! globals.use_declarefetch) {
if (stmt->currTuple >= QR_get_num_tuples(res) -1 ||
(stmt->options.maxRows > 0 && stmt->currTuple == stmt->options.maxRows - 1)) {
/* if at the end of the tuples, return "no data found"
and set the cursor past the end of the result set
*/
stmt->currTuple = QR_get_num_tuples(res);
return SQL_NO_DATA_FOUND;
}
mylog("**** SQLFetch: manual_result\n");
(stmt->currTuple)++;
}
else {
// 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)
(stmt->currTuple)++; // all is well
else {
mylog("SQLFetch: error\n");
stmt->errornumber = STMT_EXEC_ERROR;
stmt->errormsg = "Error fetching next row";
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
}
num_cols = QR_NumResultCols(res);
result = SQL_SUCCESS;
stmt->last_fetch_count = 1;
for (lf=0; lf < num_cols; lf++) {
mylog("fetch: cols=%d, lf=%d, stmt = %u, stmt->bindings = %u, buffer[] = %u\n", num_cols, lf, stmt, stmt->bindings, stmt->bindings[lf].buffer);
/* reset for SQLGetData */
stmt->bindings[lf].data_left = -1;
if (stmt->bindings[lf].buffer != NULL) {
// this column has a binding
// type = QR_get_field_type(res, lf);
type = CI_get_oid(ci, lf); /* speed things up */
mylog("type = %d\n", type);
if (stmt->manual_result) {
value = QR_get_value_manual(res, stmt->currTuple, lf);
mylog("manual_result\n");
}
else if (globals.use_declarefetch)
value = QR_get_value_backend(res, lf);
else {
value = QR_get_value_backend_row(res, stmt->currTuple, lf);
}
mylog("value = '%s'\n", (value==NULL)?"<NULL>":value);
retval = copy_and_convert_field_bindinfo(stmt, type, value, lf);
mylog("copy_and_convert: retval = %d\n", retval);
switch(retval) {
case COPY_OK:
break; /* OK, do next bound column */
case COPY_UNSUPPORTED_TYPE:
stmt->errormsg = "Received an unsupported type from Postgres.";
stmt->errornumber = STMT_RESTRICTED_DATA_TYPE_ERROR;
SC_log_error(func, "", stmt);
result = SQL_ERROR;
break;
case COPY_UNSUPPORTED_CONVERSION:
stmt->errormsg = "Couldn't handle the necessary data type conversion.";
stmt->errornumber = STMT_RESTRICTED_DATA_TYPE_ERROR;
SC_log_error(func, "", stmt);
result = SQL_ERROR;
break;
case COPY_RESULT_TRUNCATED:
stmt->errornumber = STMT_TRUNCATED;
stmt->errormsg = "The buffer was too small for the result.";
result = SQL_SUCCESS_WITH_INFO;
break;
case COPY_GENERAL_ERROR: /* error msg already filled in */
SC_log_error(func, "", stmt);
result = SQL_ERROR;
break;
/* This would not be meaningful in SQLFetch. */
case COPY_NO_DATA_FOUND:
break;
default:
stmt->errormsg = "Unrecognized return value from copy_and_convert_field.";
stmt->errornumber = STMT_INTERNAL_ERROR;
SC_log_error(func, "", stmt);
result = SQL_ERROR;
break;
}
}
}
return result;
}
// Returns data for bound columns in the current row ("hstmt->iCursor"),