|
From: <he...@us...> - 2013-05-11 07:40:07
|
Revision: 180
http://sourceforge.net/p/pdbsql/code/180
Author: herwinw
Date: 2013-05-11 07:40:03 +0000 (Sat, 11 May 2013)
Log Message:
-----------
Fixed the validation of the pq result
It actually broke in r162, and the fix in r178 wasn't as strict as the one we had before.
Revision Links:
--------------
http://sourceforge.net/p/pdbsql/code/162
http://sourceforge.net/p/pdbsql/code/178
Modified Paths:
--------------
branches/pdbsql_36/pdb_pgsql.c
Modified: branches/pdbsql_36/pdb_pgsql.c
===================================================================
--- branches/pdbsql_36/pdb_pgsql.c 2013-05-11 07:28:13 UTC (rev 179)
+++ branches/pdbsql_36/pdb_pgsql.c 2013-05-11 07:40:03 UTC (rev 180)
@@ -121,7 +121,7 @@
return handle;
}
-static PGresult *pdb_pgsql_query(struct pdb_pgsql_data *data, char *query)
+static PGresult *pdb_pgsql_query(struct pdb_pgsql_data *data, char *query, bool expect_resultset)
{
PGresult *result;
@@ -146,8 +146,7 @@
DEBUG(1, ("Error executing %s, %s (trying to recover with reconnect)\n", query, PQerrorMessage(data->handle)));
PQreset(data->handle);
} else {
- int status = PQresultStatus(result);
- if (status != PGRES_TUPLES_OK && status != PGRES_COMMAND_OK) {
+ if (PQresultStatus(result) != (expect_resultset ? PGRES_TUPLES_OK : PGRES_COMMAND_OK)) {
DEBUG(1, ("Error executing %s, %s\n", query, PQresultErrorMessage(result)));
PQclear(result);
result = NULL;
@@ -282,7 +281,7 @@
PQescapeString(esc, sname, strlen(sname));
query = sql_account_query_select(NULL, data->location, true, field, esc);
- result = pdb_pgsql_query(data, query);
+ result = pdb_pgsql_query(data, query, true);
/* Result? */
if (result == NULL)
@@ -379,7 +378,7 @@
PQescapeString(esc, sname, strlen(sname));
query = sql_account_query_delete(NULL, data->location, esc);
- result = pdb_pgsql_query(data, query);
+ result = pdb_pgsql_query(data, query, false);
if (result == NULL) {
retval = NT_STATUS_UNSUCCESSFUL;
@@ -421,7 +420,7 @@
}
/* Execute the query */
- result = pdb_pgsql_query(data, query);
+ result = pdb_pgsql_query(data, query, false);
if (result == NULL) {
retval = NT_STATUS_INVALID_PARAMETER;
@@ -548,7 +547,7 @@
/* The query to select all the users */
query = sql_account_query_select(NULL, data->location, false, SQL_SEARCH_NONE, NULL);
- search_state->pwent = pdb_pgsql_query(data, query);
+ search_state->pwent = pdb_pgsql_query(data, query, true);
search_state->currow = 0;
talloc_free(query);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|