summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6a66234)
raw | patch | inline | side by side (parent: 6a66234)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 4 Mar 2009 15:00:53 +0000 (16:00 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 4 Mar 2009 17:17:09 +0000 (18:17 +0100) |
Also, while I was at it, improved some error messages.
src/postgresql.c | patch | blob | history |
diff --git a/src/postgresql.c b/src/postgresql.c
index adddc00a46f394ca7c561d6b1881eb32471b646a..d6dd0ba20e14399e30107aa1ef3f6674825c0ea3 100644 (file)
--- a/src/postgresql.c
+++ b/src/postgresql.c
int rows_num;
int status;
- int i;
+ int row, col;
/* The user data may hold parameter information, but may be NULL. */
data = udb_query_get_user_data (q);
BAIL_OUT (-1);
}
- for (i = 0; i < column_num; i++) {
+ for (col = 0; col < column_num; ++col) {
/* Pointers returned by `PQfname' are freed by `PQclear' via
* `BAIL_OUT'. */
- column_names[i] = PQfname (res, i);
- if (NULL == column_names[i]) {
- log_err ("PQfname (%i) failed.", i);
+ column_names[col] = PQfname (res, col);
+ if (NULL == column_names[col]) {
+ log_err ("Failed to resolv name of column %i.", col);
BAIL_OUT (-1);
}
}
BAIL_OUT (-1);
}
- for (i = 0; i < rows_num; ++i) {
- int j;
-
- for (j = 0; j < column_num; j++) {
+ for (row = 0; row < rows_num; ++row) {
+ for (col = 0; col < column_num; ++col) {
/* Pointers returned by `PQgetvalue' are freed by `PQclear' via
* `BAIL_OUT'. */
- column_values[j] = PQgetvalue (res, /* row = */ i, /* col = */ j);
- if (NULL == column_values[j]) {
- log_err ("PQgetvalue (%i, %i) failed.", i, j);
+ column_values[col] = PQgetvalue (res, row, col);
+ if (NULL == column_values[col]) {
+ log_err ("Failed to get value at (row = %i, col = %i).",
+ row, col);
break;
}
}
/* check for an error */
- if (j < column_num)
+ if (col < column_num)
continue;
status = udb_query_handle_result (q, column_values);
log_err ("udb_query_handle_result failed with status %i.",
status);
}
- } /* for (i = 0; i < rows_num; ++i) */
+ } /* for (row = 0; row < rows_num; ++row) */
BAIL_OUT (0);
#undef BAIL_OUT