[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2009-05-19 Thread Kalle Sommer Nielsen
kalle   Tue May 19 16:03:36 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  MFH: Fix compiler warnings
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.27r2=1.331.2.13.2.24.2.28diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.27 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.28
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.27  Thu Mar 12 22:53:16 2009
+++ php-src/ext/pgsql/pgsql.c   Tue May 19 16:03:36 2009
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.27 2009/03/12 22:53:16 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.28 2009/05/19 16:03:36 kalle Exp $ */
 
 #include stdlib.h
 
@@ -2650,7 +2650,7 @@
zval *result;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
-   long colno=0;
+   unsigned long colno=0;
int pg_numrows, pg_row;
size_t num_fields;
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2009-03-12 Thread Ilia Alshanetsky
iliaa   Thu Mar 12 22:53:16 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #47639 (pg_copy_from() WARNING: nonstandard use of \\ in a string
  literal)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.26r2=1.331.2.13.2.24.2.27diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.26 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.27
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.26  Sun Jan 18 23:49:31 2009
+++ php-src/ext/pgsql/pgsql.c   Thu Mar 12 22:53:16 2009
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.26 2009/01/18 23:49:31 felipe Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.27 2009/03/12 22:53:16 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -3890,7 +3890,7 @@
 
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL 
link, le_link, le_plink);
 
-   spprintf(query, 0, COPY \%s\ FROM STDIN DELIMITERS '%c' WITH NULL 
AS '%s', table_name, *pg_delim, pg_null_as);
+   spprintf(query, 0, COPY \%s\ FROM STDIN DELIMITERS E'%c' WITH NULL 
AS E'%s', table_name, *pg_delim, pg_null_as);
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2009-01-18 Thread Felipe Pena
felipe  Sun Jan 18 23:49:32 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  - MFH: Fixed bug #47048 (Segfault with new pg_meta_data)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.25r2=1.331.2.13.2.24.2.26diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.25 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.26
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.25  Tue Jan 13 19:08:08 2009
+++ php-src/ext/pgsql/pgsql.c   Sun Jan 18 23:49:31 2009
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.25 2009/01/13 19:08:08 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.26 2009/01/18 23:49:31 felipe Exp $ */
 
 #include stdlib.h
 
@@ -4831,7 +4831,7 @@
src = estrdup(table_name);
tmp_name = php_strtok_r(src, ., tmp_name2);

-   if (!*tmp_name2) {
+   if (!tmp_name2 || !*tmp_name2) {
/* Default schema */
tmp_name2 = tmp_name;
tmp_name = public;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2008-10-15 Thread Felipe Pena
felipe  Wed Oct 15 13:34:27 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  - Fixed possible efree(NULL)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.17r2=1.331.2.13.2.24.2.18diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.17 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.18
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.17  Mon Oct 13 13:44:32 2008
+++ php-src/ext/pgsql/pgsql.c   Wed Oct 15 13:34:26 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.17 2008/10/13 13:44:32 felipe Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.18 2008/10/15 13:34:26 felipe Exp $ */
 
 #include stdlib.h
 
@@ -1723,7 +1723,9 @@
if (num_params  0) {
int i;
for (i = 0; i  num_params; i++) {
-   efree(params[i]);
+   if (params[i]) {
+   efree(params[i]);
+   }
}
efree(params);
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c /ext/pgsql/tests pg_delete_001.phpt pg_insert_001.phpt pg_meta_data_001.phpt pg_select_001.phpt pg_update_001.phpt

2008-10-15 Thread Felipe Pena
felipe  Thu Oct 16 00:39:31 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/pgsql/testspg_delete_001.phpt pg_insert_001.phpt 
pg_meta_data_001.phpt pg_select_001.phpt 
pg_update_001.phpt 

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  MFH:
  - Fixed:
. Memory leak in pg_delete() when using PGSQL_DML_STRING.
. Bug #24679 (pg_insert problem!)
. Bug #35996 (pg_meta_data should take the schema into account)
. Bug #40808 (pg_insert problem)
. Bug #42078 (pg_meta_data mix tables metadata from different schemas)
  - Improved:
. Error messages
  - Added:
. Tests
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.18r2=1.331.2.13.2.24.2.19diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.18 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.19
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.18  Wed Oct 15 13:34:26 2008
+++ php-src/ext/pgsql/pgsql.c   Thu Oct 16 00:39:31 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.18 2008/10/15 13:34:26 felipe Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.19 2008/10/16 00:39:31 felipe Exp $ */
 
 #include stdlib.h
 
@@ -4899,27 +4899,47 @@
 PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, 
zval *meta TSRMLS_DC) 
 {
PGresult *pg_result;
-   char *tmp_name;
+   char *src, *tmp_name, *tmp_name2 = NULL;
smart_str querystr = {0};
int new_len;
int i, num_rows;
zval *elem;

+   if (!*table_name) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, The table name 
must be specified);
+   return FAILURE;
+   }
+
+   src = estrdup(table_name);
+   tmp_name = php_strtok_r(src, ., tmp_name2);
+   
+   if (!*tmp_name2) {
+   /* Default schema */
+   tmp_name2 = tmp_name;
+   tmp_name = public;
+   }
+
smart_str_appends(querystr, 
SELECT a.attname, a.attnum, t.typname, a.attlen, 
a.attnotNULL, a.atthasdef, a.attndims 
-   FROM pg_class as c, pg_attribute a, pg_type t 
+   FROM pg_class as c, pg_attribute a, pg_type t, 
pg_namespace n 
WHERE a.attnum  0 AND a.attrelid = c.oid AND 
c.relname = ');
+   tmp_name2 = php_addslashes(tmp_name2, strlen(tmp_name2), new_len, 0 
TSRMLS_CC);
+   smart_str_appendl(querystr, tmp_name2, new_len);

-   tmp_name = php_addslashes((char *)table_name, strlen(table_name), 
new_len, 0 TSRMLS_CC);
+   smart_str_appends(querystr, ' AND c.relnamespace = n.oid AND 
n.nspname = ');
+   tmp_name = php_addslashes(tmp_name, strlen(tmp_name), new_len, 0 
TSRMLS_CC);
smart_str_appendl(querystr, tmp_name, new_len);
-   efree(tmp_name);
 
smart_str_appends(querystr, ' AND a.atttypid = t.oid ORDER BY 
a.attnum;);
smart_str_0(querystr);

+   efree(tmp_name2);
+   efree(tmp_name);
+   efree(src); 
+   
pg_result = PQexec(pg_link, querystr.c);
if (PQresultStatus(pg_result) != PGRES_TUPLES_OK || (num_rows = 
PQntuples(pg_result)) == 0) {
-   php_error_docref(NULL TSRMLS_CC, E_NOTICE, Failed to query 
meta_data for '%s' table %s, table_name, querystr.c);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Table '%s' doesn't 
exists, table_name);
smart_str_free(querystr);
PQclear(pg_result);
return FAILURE;
@@ -5834,7 +5854,7 @@
PQclear(pg_result);
return 0;
} else {
-   php_error_docref(NULL TSRMLS_CC, E_NOTICE, Failed to 
execute '%s', querystr-c);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, %s, 
PQresultErrorMessage(pg_result));
PQclear(pg_result);
}
}
@@ -6185,7 +6205,7 @@
FREE_ZVAL(ids_converted);
}
if (ret == SUCCESS  (opt  PGSQL_DML_STRING)) {
-   *sql = estrdup(querystr.c);
+   *sql = querystr.c;
}
else {
smart_str_free(querystr);

http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/tests/pg_delete_001.phpt?view=markuprev=1.1
Index: php-src/ext/pgsql/tests/pg_delete_001.phpt
+++ php-src/ext/pgsql/tests/pg_delete_001.phpt
--TEST--
PostgreSQL pg_delete() - basic test using schema
--SKIPIF--
?php include(skipif.inc); ?
--FILE--
?php

include('config.inc');

$conn = pg_connect($conn_str);

pg_query('CREATE SCHEMA phptests');

pg_query('CREATE TABLE foo (id INT, id2 INT)');
pg_query('CREATE TABLE phptests.foo (id INT, id2 INT)');

pg_insert($conn, 'foo', array('id' = 1, 'id2' = 1));

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c /ext/pgsql/tests bug37100.phpt

2008-10-13 Thread Felipe Pena
felipe  Mon Oct 13 13:44:32 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/pgsql/testsbug37100.phpt 

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  MFH:
  - Fixed bug #37100 (data is returned truncated with BINARY CURSOR)
Patch by Tony
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.16r2=1.331.2.13.2.24.2.17diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.16 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.17
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.16  Wed Oct  8 23:04:38 2008
+++ php-src/ext/pgsql/pgsql.c   Mon Oct 13 13:44:32 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.16 2008/10/08 23:04:38 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.17 2008/10/13 13:44:32 felipe Exp $ */
 
 #include stdlib.h
 
@@ -2482,10 +2482,9 @@
if (PQgetisnull(pgsql_result, pgsql_row, field_offset)) {
Z_TYPE_P(return_value) = IS_NULL;
} else {
-   Z_STRVAL_P(return_value) = PQgetvalue(pgsql_result, pgsql_row, 
field_offset);
-   Z_STRLEN_P(return_value) = (Z_STRVAL_P(return_value) ? 
strlen(Z_STRVAL_P(return_value)) : 0);
-   Z_STRVAL_P(return_value) = 
safe_estrndup(Z_STRVAL_P(return_value),Z_STRLEN_P(return_value));
-   Z_TYPE_P(return_value) = IS_STRING;
+   char *value = PQgetvalue(pgsql_result, pgsql_row, field_offset);
+   int value_len = PQgetlength(pgsql_result, pgsql_row, 
field_offset);
+   ZVAL_STRINGL(return_value, value, value_len, 1);
}
 }
 /* }}} */

http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/tests/bug37100.phpt?view=markuprev=1.1
Index: php-src/ext/pgsql/tests/bug37100.phpt
+++ php-src/ext/pgsql/tests/bug37100.phpt
--TEST--
Bug #37100 (data is returned truncated with BINARY CURSOR)
--SKIPIF--
?php include(skipif.inc); ?
--FILE--
?php

include 'config.inc';

$db = pg_connect($conn_str);

@pg_query('DROP TABLE test_bug');

pg_query('CREATE TABLE test_bug (binfield byteA) ;');
pg_query(INSERT INTO test_bug VALUES (decode('0103AA000812','hex')));


$data = pg_query(SELECT binfield FROM test_bug);
$res = pg_fetch_result($data,0);
var_dump($res);
var_dump(bin2hex(pg_unescape_bytea($res)));

$sql = BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM 
test_bug; FETCH ALL IN mycursor;;

$data = pg_query($sql);
$res = pg_fetch_result($data,0);

var_dump(strlen($res));
var_dump(bin2hex($res));

pg_close($db);

$db = pg_connect($conn_str);
pg_query('DROP TABLE test_bug');
pg_close($db);


?
--EXPECT--
string(24) \001\003\252\000\010\022
string(12) 0103aa000812
int(6)
string(12) 0103aa000812



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2008-10-08 Thread Ilia Alshanetsky
iliaa   Wed Oct  8 23:04:40 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  use proper macro
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.15r2=1.331.2.13.2.24.2.16diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.15 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.16
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.15  Wed Oct  1 20:30:23 2008
+++ php-src/ext/pgsql/pgsql.c   Wed Oct  8 23:04:38 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.15 2008/10/01 20:30:23 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.16 2008/10/08 23:04:38 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -2891,7 +2891,7 @@
if (Z_LVAL_P(result) == 0) {
RETURN_FALSE;
}
-   zend_list_delete(Z_LVAL_P(result));
+   zend_list_delete(Z_RESVAL_P(result));
RETURN_TRUE;
 }
 /* }}} */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2008-09-09 Thread Ilia Alshanetsky
iliaa   Wed Sep 10 01:39:36 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed unused var warning
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.13r2=1.331.2.13.2.24.2.14diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.13 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.14
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.13  Mon Sep  8 01:33:07 2008
+++ php-src/ext/pgsql/pgsql.c   Wed Sep 10 01:39:35 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.13 2008/09/08 01:33:07 felipe Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.14 2008/09/10 01:39:35 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -3392,7 +3392,7 @@
int id = -1, name_len;
int argc = ZEND_NUM_ARGS();
PGconn *pgsql;
-   Oid wanted_oid, returned_oid;
+   Oid returned_oid;
 
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
 rs|z, 
pgsql_link, file_in, name_len, oid) == SUCCESS) {
@@ -3430,6 +3430,7 @@
 #ifndef HAVE_PG_LO_IMPORT_WITH_OID
php_error_docref(NULL TSRMLS_CC, E_NOTICE, OID value passing 
not supported);
 #else
+   Oid wanted_oid;
switch (Z_TYPE_P(oid)) {
case IS_STRING:
{   



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2008-07-01 Thread Felipe Pena
felipe  Wed Jul  2 00:10:55 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  - Added arginfo
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.8r2=1.331.2.13.2.24.2.9diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.8 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.9
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.8   Sun Jun 29 22:38:55 2008
+++ php-src/ext/pgsql/pgsql.c   Wed Jul  2 00:10:54 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.8 2008/06/29 22:38:55 felipe Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.9 2008/07/02 00:10:54 felipe Exp $ */
 
 #include stdlib.h
 
@@ -89,158 +89,693 @@
 ZEND_DECLARE_MODULE_GLOBALS(pgsql)
 static PHP_GINIT_FUNCTION(pgsql);
 
+/* {{{ arginfo */
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_connect, 0, 0, 1)
+   ZEND_ARG_INFO(0, connection_string)
+   ZEND_ARG_INFO(0, connect_type)
+   ZEND_ARG_INFO(0, host)
+   ZEND_ARG_INFO(0, port)
+   ZEND_ARG_INFO(0, options)
+   ZEND_ARG_INFO(0, tty)
+   ZEND_ARG_INFO(0, database)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_pconnect, 0, 0, 1)
+   ZEND_ARG_INFO(0, connection_string)
+   ZEND_ARG_INFO(0, host)
+   ZEND_ARG_INFO(0, port)
+   ZEND_ARG_INFO(0, options)
+   ZEND_ARG_INFO(0, tty)
+   ZEND_ARG_INFO(0, database)
+ZEND_END_ARG_INFO()
+
+#if HAVE_PQPARAMETERSTATUS
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_parameter_status, 0, 0, 1)
+   ZEND_ARG_INFO(0, connection)
+   ZEND_ARG_INFO(0, param_name)
+ZEND_END_ARG_INFO()
+#endif
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_close, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_dbname, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_last_error, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_options, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_port, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_tty, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_host, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_version, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_ping, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_query, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+   ZEND_ARG_INFO(0, query)
+ZEND_END_ARG_INFO()
+
+#if HAVE_PQEXECPARAMS
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_query_params, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+   ZEND_ARG_INFO(0, query)
+   ZEND_ARG_INFO(0, params)
+ZEND_END_ARG_INFO()
+#endif
+
+#if HAVE_PQPREPARE
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_prepare, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+   ZEND_ARG_INFO(0, stmtname)
+   ZEND_ARG_INFO(0, query)
+ZEND_END_ARG_INFO()
+#endif
+
+#if HAVE_PQEXECPREPARED
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_execute, 0, 0, 0)
+   ZEND_ARG_INFO(0, connection)
+   ZEND_ARG_INFO(0, stmtname)
+   ZEND_ARG_INFO(0, params)
+ZEND_END_ARG_INFO()
+#endif
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_num_rows, 0, 0, 1)
+   ZEND_ARG_INFO(0, result)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_num_fields, 0, 0, 1)
+   ZEND_ARG_INFO(0, result)
+ZEND_END_ARG_INFO()
+
+#if HAVE_PQCMDTUPLES
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_affected_rows, 0, 0, 1)
+   ZEND_ARG_INFO(0, result)
+ZEND_END_ARG_INFO()
+#endif
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_last_notice, 0, 0, 1)
+   ZEND_ARG_INFO(0, connection)
+ZEND_END_ARG_INFO()
+
+#ifdef HAVE_PQFTABLE
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_field_table, 0, 0, 2)
+   ZEND_ARG_INFO(0, result)
+   ZEND_ARG_INFO(0, field_number)
+   ZEND_ARG_INFO(0, oid_only)
+ZEND_END_ARG_INFO()
+#endif
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_field_name, 0, 0, 2)
+   ZEND_ARG_INFO(0, result)
+   ZEND_ARG_INFO(0, field_number)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_field_size, 0, 0, 2)
+   ZEND_ARG_INFO(0, result)
+   ZEND_ARG_INFO(0, field_number)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_field_type, 0, 0, 2)
+   ZEND_ARG_INFO(0, result)
+   ZEND_ARG_INFO(0, field_number)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_field_type_oid, 0, 0, 2)
+   ZEND_ARG_INFO(0, result)
+   ZEND_ARG_INFO(0, 

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2008-06-29 Thread Felipe Pena
felipe  Sun Jun 29 22:38:55 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  - New parameter parsing API
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.7r2=1.331.2.13.2.24.2.8diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.7 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.8
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.7   Mon May 19 15:16:47 2008
+++ php-src/ext/pgsql/pgsql.c   Sun Jun 29 22:38:55 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.7 2008/05/19 15:16:47 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.8 2008/06/29 22:38:55 felipe Exp $ */
 
 #include stdlib.h
 
@@ -858,37 +858,31 @@
Close a PostgreSQL connection */ 
 PHP_FUNCTION(pg_close)
 {
-   zval **pgsql_link = NULL;
-   int id;
+   zval *pgsql_link = NULL;
+   int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;

-   switch (ZEND_NUM_ARGS()) {
-   case 0:
-   id = PGG(default_link);
-   CHECK_DEFAULT_LINK(id);
-   break;
-   case 1:
-   if (zend_get_parameters_ex(1, pgsql_link)==FAILURE) {
-   RETURN_FALSE;
-   }
-   id = -1;
-   break;
-   default:
-   WRONG_PARAM_COUNT;
-   break;
+   if (zend_parse_parameters(argc TSRMLS_CC, |r, pgsql_link) == 
FAILURE) {
+   return;
}
+   
+   if (argc == 0) {
+   id = PGG(default_link);
+   CHECK_DEFAULT_LINK(id);
+   }
+
if (pgsql_link == NULL  id == -1) {
RETURN_FALSE;
}   
 
-   ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL 
link, le_link, le_plink);
+   ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL 
link, le_link, le_plink);
 
if (id==-1) { /* explicit resource number */
-   zend_list_delete(Z_RESVAL_PP(pgsql_link));
+   zend_list_delete(Z_RESVAL_P(pgsql_link));
}
 
if (id!=-1 
-   || (pgsql_link  Z_RESVAL_PP(pgsql_link)==PGG(default_link))) {
+   || (pgsql_link  Z_RESVAL_P(pgsql_link)==PGG(default_link))) {
zend_list_delete(PGG(default_link));
PGG(default_link) = -1;
}
@@ -910,30 +904,25 @@
  */
 static void php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAMETERS, int 
entry_type)
 {
-   zval **pgsql_link = NULL;
-   int id = -1;
+   zval *pgsql_link = NULL;
+   int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;
char *msgbuf;
 
-   switch(ZEND_NUM_ARGS()) {
-   case 0:
-   id = PGG(default_link);
-   CHECK_DEFAULT_LINK(id);
-   break;
-   case 1:
-   if (zend_get_parameters_ex(1, pgsql_link)==FAILURE) {
-   RETURN_FALSE;
-   }
-   break;
-   default:
-   WRONG_PARAM_COUNT;
-   break;
+   if (zend_parse_parameters(argc TSRMLS_CC, |r, pgsql_link) == 
FAILURE) {
+   return;
}
+   
+   if (argc == 0) {
+   id = PGG(default_link);
+   CHECK_DEFAULT_LINK(id);
+   }
+   
if (pgsql_link == NULL  id == -1) {
RETURN_FALSE;
}   
 
-   ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL 
link, le_link, le_plink);
+   ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL 
link, le_link, le_plink);
 
switch(entry_type) {
case PHP_PG_DBNAME:
@@ -1113,38 +1102,33 @@
Execute a query */
 PHP_FUNCTION(pg_query)
 {
-   zval **query, **pgsql_link = NULL;
-   int id = -1;
+   zval *pgsql_link = NULL;
+   char *query;
+   int id = -1, query_len, argc = ZEND_NUM_ARGS();
int leftover = 0;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
pgsql_result_handle *pg_result;
 
-   switch(ZEND_NUM_ARGS()) {
-   case 1:
-   if (zend_get_parameters_ex(1, query)==FAILURE) {
-   RETURN_FALSE;
-   }
-   id = PGG(default_link);
-   CHECK_DEFAULT_LINK(id);
-   break;
-   case 2:
-   if (zend_get_parameters_ex(2, pgsql_link, 
query)==FAILURE) {
-   RETURN_FALSE;
-   }
-   break;
-   default:
-   

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2008-05-19 Thread Ilia Alshanetsky
iliaa   Mon May 19 15:16:47 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #45004 (pg_insert() does not accept 4 digit timezone format)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.6r2=1.331.2.13.2.24.2.7diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.6 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.7
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.6   Mon Dec 31 07:17:12 2007
+++ php-src/ext/pgsql/pgsql.c   Mon May 19 15:16:47 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.6 2007/12/31 07:17:12 sebastian Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.7 2008/05/19 15:16:47 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -5003,7 +5003,7 @@
ZVAL_STRINGL(new_val, 
NOW(), sizeof(NOW())-1, 1);
} else {
/* FIXME: better regex 
must be used */
-   if 
(php_pgsql_convert_match(Z_STRVAL_PP(val), 
^([0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2})([ 
\\t]+(([0-9]{1,2}:[0-9]{1,2}){1}(:[0-9]{1,2}){0,1}(\\.[0-9]+){0,1}([ 
\\t]*([+-][0-9]{1,2}(:[0-9]{1,2}){0,1}|[-a-zA-Z_/+]{1,50})){0,1})){0,1}$, 1 
TSRMLS_CC) == FAILURE) {
+   if 
(php_pgsql_convert_match(Z_STRVAL_PP(val), 
^([0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2})([ 
\\t]+(([0-9]{1,2}:[0-9]{1,2}){1}(:[0-9]{1,2}){0,1}(\\.[0-9]+){0,1}([ 
\\t]*([+-][0-9]{1,4}(:[0-9]{1,2}){0,1}|[-a-zA-Z_/+]{1,50})){0,1})){0,1}$, 1 
TSRMLS_CC) == FAILURE) {
err = 1;
} else {

ZVAL_STRING(new_val, Z_STRVAL_PP(val), 1);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2007-11-21 Thread Ilia Alshanetsky
iliaa   Thu Nov 22 00:17:28 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #43041 (micro-optimizations in pgsql data retrieval) Initial patch
  by andy at petdance dot com
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.4r2=1.331.2.13.2.24.2.5diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.4 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.5
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.4   Tue Nov 13 20:05:47 2007
+++ php-src/ext/pgsql/pgsql.c   Thu Nov 22 00:17:28 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.4 2007/11/13 20:05:47 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.5 2007/11/22 00:17:28 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -1996,8 +1996,7 @@
pgsql_result_handle *pg_result;
int i, num_fields, pgsql_row, use_row;
longrow = -1;
-   char*element, *field_name;
-   uintelement_len;
+   char*field_name;
zval*ctor_params = NULL;
zend_class_entry *ce = NULL;
 
@@ -2068,12 +2067,12 @@
add_assoc_null(return_value, field_name);
}
} else {
-   element = PQgetvalue(pgsql_result, pgsql_row, i);
-   element_len = (element ? strlen(element) : 0);
+   char *element = PQgetvalue(pgsql_result, pgsql_row, i);
if (element) {
char *data;
int data_len;
int should_copy=0;
+   const uint element_len = strlen(element);
 
if (PG(magic_quotes_runtime)) {
data = php_addslashes(element, 
element_len, data_len, 0 TSRMLS_CC);
@@ -5743,8 +5742,8 @@
 PHP_PGSQL_API int php_pgsql_result2array(PGresult *pg_result, zval *ret_array 
TSRMLS_DC) 
 {
zval *row;
-   char *field_name, *element, *data;
-   size_t num_fields, element_len, data_len;
+   char *field_name;
+   size_t num_fields;
int pg_numrows, pg_row;
uint i;
assert(Z_TYPE_P(ret_array) == IS_ARRAY);
@@ -5761,9 +5760,12 @@
field_name = PQfname(pg_result, i);
add_assoc_null(row, field_name);
} else {
-   element = PQgetvalue(pg_result, pg_row, i);
-   element_len = (element ? strlen(element) : 0);
+   char *element = PQgetvalue(pg_result, pg_row, 
i);
if (element) {
+   char *data;
+   size_t data_len;
+   const size_t element_len = 
strlen(element);
+
if (PG(magic_quotes_runtime)) {
data = php_addslashes(element, 
element_len, data_len, 0 TSRMLS_CC);
} else {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2007-11-13 Thread Ilia Alshanetsky
iliaa   Tue Nov 13 20:05:47 2007 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #43279 (pg_send_query_params() converts all elements in 'params' 
  to strings)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.3r2=1.331.2.13.2.24.2.4diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.3 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.4
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.3   Fri Oct  5 15:00:08 2007
+++ php-src/ext/pgsql/pgsql.c   Tue Nov 13 20:05:47 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.3 2007/10/05 15:00:08 jani Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.4 2007/11/13 20:05:47 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -4084,6 +4084,7 @@
php_error_docref(NULL TSRMLS_CC, E_NOTICE, There are results 
on this connection. Call pg_get_result() until it returns FALSE);
}
 
+   SEPARATE_ZVAL(pv_param_arr);
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(pv_param_arr));
num_params = zend_hash_num_elements(Z_ARRVAL_PP(pv_param_arr));
if (num_params  0) {
@@ -4098,7 +4099,8 @@
}
 
otype = (*tmp)-type;
-   convert_to_string(*tmp);
+   SEPARATE_ZVAL(tmp);
+   convert_to_string_ex(tmp);
if (Z_TYPE_PP(tmp) != IS_STRING) {
php_error_docref(NULL TSRMLS_CC, 
E_WARNING,Error converting parameter);
_php_pgsql_free_params(params, num_params);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2007-11-13 Thread Antony Dovgal
What happens if Postgres returns OUT parameters?

On 13.11.2007 23:05, Ilia Alshanetsky wrote:
 @@ -4084,6 +4084,7 @@
   php_error_docref(NULL TSRMLS_CC, E_NOTICE, There are results 
 on this connection. Call pg_get_result() until it returns FALSE);
   }
  
 + SEPARATE_ZVAL(pv_param_arr);
   zend_hash_internal_pointer_reset(Z_ARRVAL_PP(pv_param_arr));
   num_params = zend_hash_num_elements(Z_ARRVAL_PP(pv_param_arr));
   if (num_params  0) {
 @@ -4098,7 +4099,8 @@
   }
  
   otype = (*tmp)-type;
 - convert_to_string(*tmp);
 + SEPARATE_ZVAL(tmp);
 + convert_to_string_ex(tmp);
   if (Z_TYPE_PP(tmp) != IS_STRING) {
   php_error_docref(NULL TSRMLS_CC, 
 E_WARNING,Error converting parameter);
   _php_pgsql_free_params(params, num_params);
 


-- 
Wbr, 
Antony Dovgal

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c

2007-11-13 Thread Ilia Alshanetsky
The function is designed for sending data allowing it to fetch bound  
params can lead to all kinds of undefined behaviors such as:


pg_send_query_params($dbconn, 'select count(*) from authors where city  
= $1', array('Perth'));


especially when the supplied value is a temp var.




On 13-Nov-07, at 3:48 PM, Antony Dovgal wrote:


What happens if Postgres returns OUT parameters?

On 13.11.2007 23:05, Ilia Alshanetsky wrote:

@@ -4084,6 +4084,7 @@
		php_error_docref(NULL TSRMLS_CC, E_NOTICE, There are results on  
this connection. Call pg_get_result() until it returns FALSE);

}

+   SEPARATE_ZVAL(pv_param_arr);
zend_hash_internal_pointer_reset(Z_ARRVAL_PP(pv_param_arr));
num_params = zend_hash_num_elements(Z_ARRVAL_PP(pv_param_arr));
if (num_params  0) {
@@ -4098,7 +4099,8 @@
}

otype = (*tmp)-type;
-   convert_to_string(*tmp);
+   SEPARATE_ZVAL(tmp);
+   convert_to_string_ex(tmp);
if (Z_TYPE_PP(tmp) != IS_STRING) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,Error converting  
parameter);

_php_pgsql_free_params(params, num_params);




--
Wbr,
Antony Dovgal

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Ilia Alshanetsky

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/pgsql pgsql.c /ext/pgsql/tests 80_bug42783.phpt

2007-10-03 Thread Ilia Alshanetsky
iliaa   Wed Oct  3 23:30:46 2007 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/pgsql/tests80_bug42783.phpt 

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  
  Fixed bug #42783 (pg_insert() does not accept an empty list for insertion)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.24.2.1r2=1.331.2.13.2.24.2.2diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.1 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.2
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.24.2.1   Thu Sep 27 18:00:42 2007
+++ php-src/ext/pgsql/pgsql.c   Wed Oct  3 23:30:46 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.24.2.1 2007/09/27 18:00:42 dmitry Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.24.2.2 2007/10/03 23:30:46 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -5366,7 +5366,11 @@
assert(Z_TYPE_P(var_array) == IS_ARRAY);
 
if (zend_hash_num_elements(Z_ARRVAL_P(var_array)) == 0) {
-   return FAILURE;
+   smart_str_appends(querystr, INSERT INTO );
+   smart_str_appends(querystr, table);
+   smart_str_appends(querystr,  DEFAULT VALUES);
+
+   goto no_values;
}
 
/* convert input array if needed */
@@ -5424,6 +5428,9 @@
/* Remove the trailing , */
querystr.len--;
smart_str_appends(querystr, ););
+
+no_values:
+
smart_str_0(querystr);
 
if ((opt  (PGSQL_DML_EXEC|PGSQL_DML_ASYNC)) 
@@ -5435,7 +5442,7 @@
}

 cleanup:
-   if (!(opt  PGSQL_DML_NO_CONV)) {
+   if (!(opt  PGSQL_DML_NO_CONV)  converted) {
zval_dtor(converted);   
FREE_ZVAL(converted);
}

http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/tests/80_bug42783.phpt?view=markuprev=1.1
Index: php-src/ext/pgsql/tests/80_bug42783.phpt
+++ php-src/ext/pgsql/tests/80_bug42783.phpt

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php