summaryrefslogtreecommitdiff
path: root/ext/pgsql
diff options
context:
space:
mode:
authorMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:37 -0400
committerMark A. Hershberger <mah@debian.(none)>2009-03-25 00:34:37 -0400
commit10f5b47dc7c1cf2b9a00991629f43652710322d3 (patch)
tree3b727a16f652b8042d573e90f003868ffb3b56c7 /ext/pgsql
parent0e920280a2e04b110827bb766b9f29e3d581c4ee (diff)
downloadphp-upstream/5.0.5.tar.gz
Imported Upstream version 5.0.5upstream/5.0.5
Diffstat (limited to 'ext/pgsql')
-rw-r--r--ext/pgsql/config.m44
-rw-r--r--ext/pgsql/pgsql.c23
-rw-r--r--ext/pgsql/php_pgsql.h4
3 files changed, 24 insertions, 7 deletions
diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4
index 1ed0e2722..ce0a8bd3d 100644
--- a/ext/pgsql/config.m4
+++ b/ext/pgsql/config.m4
@@ -1,5 +1,5 @@
dnl
-dnl $Id: config.m4,v 1.37.2.1 2004/12/30 07:04:11 sniper Exp $
+dnl $Id: config.m4,v 1.37.2.2 2005/04/03 13:06:33 tony2001 Exp $
dnl
AC_DEFUN([PHP_PGSQL_CHECK_FUNCTIONS],[
@@ -76,7 +76,7 @@ if test "$PHP_PGSQL" != "no"; then
AC_CHECK_LIB(pq, PQparameterStatus,AC_DEFINE(HAVE_PQPARAMETERSTATUS,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQprotocolVersion,AC_DEFINE(HAVE_PQPROTOCOLVERSION,1,[PostgreSQL 7.4 or later]))
AC_CHECK_LIB(pq, PQtransactionStatus,AC_DEFINE(HAVE_PGTRANSACTIONSTATUS,1,[PostgreSQL 7.4 or later]))
- AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibye]))
+ AC_CHECK_LIB(pq, pg_encoding_to_char,AC_DEFINE(HAVE_PGSQL_WITH_MULTIBYTE_SUPPORT,1,[Whether libpq is compiled with --enable-multibyte]))
LIBS=$old_LIBS
LDFLAGS=$old_LDFLAGS
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 3a1b75ca9..bf19dbd3a 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pgsql.c,v 1.311 2004/05/12 16:49:47 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.311.2.5 2005/07/05 12:47:06 derick Exp $ */
#include <stdlib.h>
@@ -105,7 +105,9 @@ function_entry pgsql_functions[] = {
PHP_FE(pg_fetch_array, NULL)
PHP_FE(pg_fetch_object, NULL)
PHP_FE(pg_fetch_all, NULL)
+#if HAVE_PQCMDTUPLES
PHP_FE(pg_affected_rows,NULL)
+#endif
PHP_FE(pg_get_result, NULL)
PHP_FE(pg_result_seek, NULL)
PHP_FE(pg_result_status,NULL)
@@ -166,7 +168,9 @@ function_entry pgsql_functions[] = {
/* aliases for downwards compatibility */
PHP_FALIAS(pg_exec, pg_query, NULL)
PHP_FALIAS(pg_getlastoid, pg_last_oid, NULL)
+#if HAVE_PQCMDTUPLES
PHP_FALIAS(pg_cmdtuples, pg_affected_rows, NULL)
+#endif
PHP_FALIAS(pg_errormessage, pg_last_error, NULL)
PHP_FALIAS(pg_numrows, pg_num_rows, NULL)
PHP_FALIAS(pg_numfields, pg_num_fields, NULL)
@@ -1156,6 +1160,7 @@ PHP_FUNCTION(pg_num_fields)
}
/* }}} */
+#if HAVE_PQCMDTUPLES
/* {{{ proto int pg_affected_rows(resource result)
Returns the number of affected tuples */
PHP_FUNCTION(pg_affected_rows)
@@ -1163,6 +1168,7 @@ PHP_FUNCTION(pg_affected_rows)
php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_CMD_TUPLES);
}
/* }}} */
+#endif
/* {{{ proto string pg_last_notice(resource connection)
Returns the last notice set by the backend */
@@ -2744,6 +2750,7 @@ PHP_FUNCTION(pg_copy_from)
zval **tmp;
char *table_name, *pg_delim = NULL, *pg_null_as = NULL;
int table_name_len, pg_delim_len, pg_null_as_len;
+ int pg_null_as_free = 0;
char *query;
char *query_template = "COPY \"\" FROM STDIN DELIMITERS ':' WITH NULL AS ''";
HashPosition pos;
@@ -2763,6 +2770,7 @@ PHP_FUNCTION(pg_copy_from)
}
if (!pg_null_as) {
pg_null_as = safe_estrdup("\\\\N");
+ pg_null_as_free = 1;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
@@ -2775,7 +2783,9 @@ PHP_FUNCTION(pg_copy_from)
}
pgsql_result = PQexec(pgsql, query);
- efree(pg_null_as);
+ if (pg_null_as_free) {
+ efree(pg_null_as);
+ }
efree(query);
if (pgsql_result) {
@@ -3268,6 +3278,11 @@ PHP_FUNCTION(pg_get_notify)
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
+
+ if (!(result_type & PGSQL_BOTH)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid result type");
+ RETURN_FALSE;
+ }
PQconsumeInput(pgsql);
pgsql_notify = PQnotifies(pgsql);
@@ -3276,11 +3291,11 @@ PHP_FUNCTION(pg_get_notify)
RETURN_FALSE;
}
array_init(return_value);
- if (result_type & (PGSQL_NUM|PGSQL_BOTH)) {
+ if (result_type & PGSQL_NUM) {
add_index_string(return_value, 0, pgsql_notify->relname, 1);
add_index_long(return_value, 1, pgsql_notify->be_pid);
}
- if (result_type & (PGSQL_ASSOC|PGSQL_BOTH)) {
+ if (result_type & PGSQL_ASSOC) {
add_assoc_string(return_value, "message", pgsql_notify->relname, 1);
add_assoc_long(return_value, "pid", pgsql_notify->be_pid);
}
diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h
index ac5e06213..1b56208d9 100644
--- a/ext/pgsql/php_pgsql.h
+++ b/ext/pgsql/php_pgsql.h
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pgsql.h,v 1.67 2004/01/08 17:32:40 sniper Exp $ */
+/* $Id: php_pgsql.h,v 1.67.2.1 2005/04/13 21:46:32 derick Exp $ */
#ifndef PHP_PGSQL_H
#define PHP_PGSQL_H
@@ -86,7 +86,9 @@ PHP_FUNCTION(pg_fetch_object);
PHP_FUNCTION(pg_fetch_result);
PHP_FUNCTION(pg_fetch_row);
PHP_FUNCTION(pg_fetch_all);
+#if HAVE_PQCMDTUPLES
PHP_FUNCTION(pg_affected_rows);
+#endif
PHP_FUNCTION(pg_get_result);
PHP_FUNCTION(pg_result_seek);
PHP_FUNCTION(pg_result_status);