cvs: pear /PECL/session_pgsql session_pgsql.c
| From: | Yasuo Ohgaki | Date: | Mon, 13 Jan 2003 11:06:02 +0000 |
| Subject: | cvs: pear /PECL/session_pgsql session_pgsql.c | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8215@lists.php.net to get a copy of this message | ||
yohgaki Mon Jan 13 06:06:02 2003 EDT
Modified files:
/pear/PECL/session_pgsql session_pgsql.c
Log:
Switch to PQexec
Index: pear/PECL/session_pgsql/session_pgsql.c
diff -u pear/PECL/session_pgsql/session_pgsql.c:1.24 pear/PECL/session_pgsql/session_pgsql.c:1.25
--- pear/PECL/session_pgsql/session_pgsql.c:1.24 Mon Jan 13 05:50:16 2003
+++ pear/PECL/session_pgsql/session_pgsql.c Mon Jan 13 06:06:02 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: session_pgsql.c,v 1.24 2003/01/13 10:50:16 yohgaki Exp $ */
+/* $Id: session_pgsql.c,v 1.25 2003/01/13 11:06:02 yohgaki Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -314,14 +314,8 @@
sprintf(query, query_tmpl, time(NULL));
for (id = 0; id < PS_PGSQL(servers); id++) {
if (PS_PGSQL(pgsql_link)[id]) {
- PQsendQuery(PS_PGSQL(pgsql_link)[id], query);
- }
- }
- for (id = 0; id < PS_PGSQL(servers); id++) {
- if (PS_PGSQL(pgsql_link)[id]) {
- while ((pg_result = PQgetResult(PS_PGSQL(pgsql_link)[id]))) {
- PQclear(pg_result);
- }
+ pg_result = PQexec(PS_PGSQL(pgsql_link)[id], query);
+ PQclear(pg_result);
}
}
return SUCCESS;
@@ -727,6 +721,7 @@
*/
PS_WRITE_FUNC(pgsql)
{
+ PGresult *pg_result;
size_t query_len;
time_t now, exp;
char *data;
@@ -750,7 +745,8 @@
query_len = strlen(query_delete)+strlen(key);
query = emalloc(query_len+1);
snprintf(query, query_len, query_delete, key);
- PQsendQuery(PS_PGSQL(current_db), query);
+ pg_result = PQexec(PS_PGSQL(current_db), query);
+ PQclear(pg_result);
efree(query);
}
@@ -762,15 +758,16 @@
query_len = strlen(query_insert)+strlen(data)+strlen(key)+120;
query = emalloc(query_len+1);
snprintf(query, query_len, query_insert, key, now, now, exp, data);
- PQsendQuery(PS_PGSQL(current_db), query);
+ pg_result = PQexec(PS_PGSQL(current_db), query);
}
else {
/* UPDATE */
query_len = strlen(query_update)+strlen(key)+strlen(data)+120;
query = emalloc(query_len+1);
snprintf(query, query_len, query_update, data, now, exp, PS_PGSQL(sess_cnt),
PS_PGSQL(sess_error), PS_PGSQL(sess_warning), PS_PGSQL(sess_notice), key);
- PQsendQuery(PS_PGSQL(current_db), query);
+ pg_result = PQexec(PS_PGSQL(current_db), query);
}
+ PQclear(pg_result);
efree(query);
efree(data);
@@ -791,14 +788,14 @@
smart_str_appendl(&buf, escaped, len);
smart_str_appendl(&buf, "';", 2);
- PQsendQuery(PS_PGSQL(current_db), buf.c);
+ pg_result = PQexec(PS_PGSQL(current_db), buf.c);
+ PQclear(pg_result);
smart_str_free(&buf);
efree(PS_PGSQL(sess_error_message));
}
- PQsendQuery(PS_PGSQL(current_db), "END;");
-/* PQexec(PS_PGSQL(current_db), "END;"); */
+ PQexec(PS_PGSQL(current_db), "END;");
return SUCCESS;
}