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

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

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fix compiler warnings, and some unicode stuff
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.400r2=1.401diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.400 php-src/ext/pgsql/pgsql.c:1.401
--- php-src/ext/pgsql/pgsql.c:1.400 Thu Mar 12 22:53:37 2009
+++ php-src/ext/pgsql/pgsql.c   Tue May 19 16:03:23 2009
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.400 2009/03/12 22:53:37 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.401 2009/05/19 16:03:23 kalle Exp $ */
 
 #include stdlib.h
 
@@ -2636,7 +2636,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;
 
@@ -5095,6 +5095,7 @@
 PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, 
const zval *values, zval *result, ulong opt TSRMLS_DC) 
 {
HashPosition pos;
+   zstr zfield;
char *field = NULL;
uint field_len = -1;
ulong num_idx = -1;
@@ -5122,7 +5123,7 @@
skip_field = 0;
new_val = NULL;

-   if ((key_type = 
zend_hash_get_current_key_ex(Z_ARRVAL_P(values), field, field_len, num_idx, 
0, pos)) == HASH_KEY_NON_EXISTANT) {
+   if ((key_type = 
zend_hash_get_current_key_ex(Z_ARRVAL_P(values), zfield, field_len, num_idx, 
0, pos)) == HASH_KEY_NON_EXISTANT) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to 
get array key type);
err = 1;
}
@@ -5134,6 +5135,7 @@
php_error_docref(NULL TSRMLS_CC, E_WARNING, Accepts 
only string key for values);
err = 1;
}
+   field = zfield.s;
if (!err  zend_hash_find(Z_ARRVAL_P(meta), field, field_len, 
(void **)def) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, Invalid 
field name (%s) in values, field);
err = 1;
@@ -5784,8 +5786,8 @@
 PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval 
*var_array, ulong opt, char **sql TSRMLS_DC)
 {
zval **val, *converted = NULL;
+   zstr zfld;
char buf[256];
-   char *fld;
smart_str querystr = {0};
int key_type, ret = FAILURE;
uint fld_len;
@@ -5819,13 +5821,13 @@
smart_str_appends(querystr,  ();

zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(var_array), pos);
-   while ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(var_array), 
fld,
+   while ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(var_array), 
zfld,
fld_len, num_idx, 0, pos)) != 
HASH_KEY_NON_EXISTANT) {
if (key_type == HASH_KEY_IS_LONG) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, Expects 
associative array for values to be inserted);
goto cleanup;
}
-   smart_str_appendl(querystr, fld, fld_len - 1);
+   smart_str_appendl(querystr, zfld.s, fld_len - 1);
smart_str_appendc(querystr, ',');
zend_hash_move_forward_ex(Z_ARRVAL_P(var_array), pos);
}
@@ -5925,24 +5927,24 @@
 static inline int build_assignment_string(smart_str *querystr, HashTable *ht, 
const char *pad, int pad_len TSRMLS_DC)
 {
HashPosition pos;
+   zstr zfld;
uint fld_len;
int key_type;
ulong num_idx;
-   char *fld;
char buf[256];
zval **val;
 
for (zend_hash_internal_pointer_reset_ex(ht, pos);
 zend_hash_get_current_data_ex(ht, (void **)val, pos) == 
SUCCESS;
 zend_hash_move_forward_ex(ht, pos)) {
-key_type = zend_hash_get_current_key_ex(ht, fld, fld_len, 
num_idx, 0, pos);
+key_type = zend_hash_get_current_key_ex(ht, zfld, fld_len, 
num_idx, 0, pos);   
if (key_type == HASH_KEY_IS_LONG) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, Expects 
associative array for values to be inserted);
return -1;
}
-   smart_str_appendl(querystr, fld, fld_len - 1);
+   smart_str_appendl(querystr, zfld.s, fld_len - 1);
smart_str_appendc(querystr, '=');
-   
+
switch(Z_TYPE_PP(val)) {
case IS_STRING:
smart_str_appendl(querystr, Z_STRVAL_PP(val), 
Z_STRLEN_PP(val));



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



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

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

  Modified files:  
/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.399r2=1.400diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.399 php-src/ext/pgsql/pgsql.c:1.400
--- php-src/ext/pgsql/pgsql.c:1.399 Tue Mar 10 23:39:31 2009
+++ php-src/ext/pgsql/pgsql.c   Thu Mar 12 22:53:37 2009
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.399 2009/03/10 23:39:31 helly Exp $ */
+/* $Id: pgsql.c,v 1.400 2009/03/12 22:53:37 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -3889,7 +3889,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 /ext/pgsql pgsql.c

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

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  - Fixed bug #47048 (Segfault with new pg_meta_data)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.397r2=1.398diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.397 php-src/ext/pgsql/pgsql.c:1.398
--- php-src/ext/pgsql/pgsql.c:1.397 Tue Jan 13 19:08:37 2009
+++ php-src/ext/pgsql/pgsql.c   Sun Jan 18 23:49:11 2009
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.397 2009/01/13 19:08:37 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.398 2009/01/18 23:49:11 felipe Exp $ */
 
 #include stdlib.h
 
@@ -4830,7 +4830,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 /ext/pgsql pgsql.c

2009-01-13 Thread Ilia Alshanetsky
iliaa   Tue Jan 13 19:08:37 2009 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  
  MFB: Improved parameter handling
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.396r2=1.397diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.396 php-src/ext/pgsql/pgsql.c:1.397
--- php-src/ext/pgsql/pgsql.c:1.396 Wed Dec 31 11:12:34 2008
+++ php-src/ext/pgsql/pgsql.c   Tue Jan 13 19:08:37 2009
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.396 2008/12/31 11:12:34 sebastian Exp $ */
+/* $Id: pgsql.c,v 1.397 2009/01/13 19:08:37 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -2412,13 +2412,13 @@
zend_class_entry *ce = NULL;
 
if (into_object) {
-   char *class_name;
+   char *class_name = NULL;
int class_name_len;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|z!sz, 
result, zrow, class_name, class_name_len, ctor_params) == FAILURE) {
return;
-   }
-   if (ZEND_NUM_ARGS()  3) {
+   }
+   if (!class_name) {
ce = zend_standard_class_def;
} else {
ce = zend_fetch_class(class_name, class_name_len, 
ZEND_FETCH_CLASS_AUTO TSRMLS_CC);



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



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

2008-11-03 Thread Felipe Pena
felipe  Mon Nov  3 17:24:12 2008 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  - Fixed compiler warning
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.392r2=1.393diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.392 php-src/ext/pgsql/pgsql.c:1.393
--- php-src/ext/pgsql/pgsql.c:1.392 Sun Nov  2 21:10:10 2008
+++ php-src/ext/pgsql/pgsql.c   Mon Nov  3 17:24:12 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.392 2008/11/02 21:10:10 felipe Exp $ */
+/* $Id: pgsql.c,v 1.393 2008/11/03 17:24:12 felipe Exp $ */
 
 #include stdlib.h
 
@@ -3393,7 +3393,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) {
@@ -3427,6 +3427,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 /ext/pgsql pgsql.c

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

  Modified files:  
/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.388r2=1.389diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.388 php-src/ext/pgsql/pgsql.c:1.389
--- php-src/ext/pgsql/pgsql.c:1.388 Mon Oct 13 13:41:16 2008
+++ php-src/ext/pgsql/pgsql.c   Wed Oct 15 13:34:13 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.388 2008/10/13 13:41:16 felipe Exp $ */
+/* $Id: pgsql.c,v 1.389 2008/10/15 13:34:13 felipe Exp $ */
 
 #include stdlib.h
 
@@ -1713,7 +1713,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 /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:36:49 2008 UTC

  Added files: 
/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:
  - 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.389r2=1.390diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.389 php-src/ext/pgsql/pgsql.c:1.390
--- php-src/ext/pgsql/pgsql.c:1.389 Wed Oct 15 13:34:13 2008
+++ php-src/ext/pgsql/pgsql.c   Thu Oct 16 00:36:48 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.389 2008/10/15 13:34:13 felipe Exp $ */
+/* $Id: pgsql.c,v 1.390 2008/10/16 00:36:48 felipe Exp $ */
 
 #include stdlib.h
 
@@ -4897,27 +4897,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;
@@ -5832,7 +5852,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);
}
}
@@ -6183,7 +6203,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));
pg_insert($conn, 'foo', array('id' = 1, 'id2' = 2));
pg_insert($conn, 'foo', array('id' = 1, 'id2' = 2));
pg_insert($conn, 'foo', 

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

2008-10-13 Thread Felipe Pena
felipe  Mon Oct 13 13:41:16 2008 UTC

  Added files: 
/php-src/ext/pgsql/testsbug37100.phpt 

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  - 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.387r2=1.388diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.387 php-src/ext/pgsql/pgsql.c:1.388
--- php-src/ext/pgsql/pgsql.c:1.387 Wed Oct  8 23:04:58 2008
+++ php-src/ext/pgsql/pgsql.c   Mon Oct 13 13:41:16 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.387 2008/10/08 23:04:58 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.388 2008/10/13 13:41:16 felipe Exp $ */
 
 #include stdlib.h
 
@@ -2472,10 +2472,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 /ext/pgsql pgsql.c

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

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  
  MFB: use proper macro
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.386r2=1.387diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.386 php-src/ext/pgsql/pgsql.c:1.387
--- php-src/ext/pgsql/pgsql.c:1.386 Wed Oct  1 20:31:02 2008
+++ php-src/ext/pgsql/pgsql.c   Wed Oct  8 23:04:58 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.386 2008/10/01 20:31:02 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.387 2008/10/08 23:04:58 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -2877,7 +2877,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 /ext/pgsql pgsql.c

2008-10-01 Thread Ilia Alshanetsky
iliaa   Wed Oct  1 20:31:02 2008 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  
  MFB: Fixed bug #46206 (pg_query_params/pg_execute convert passed values to
  strings).
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.385r2=1.386diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.385 php-src/ext/pgsql/pgsql.c:1.386
--- php-src/ext/pgsql/pgsql.c:1.385 Mon Sep  8 01:30:55 2008
+++ php-src/ext/pgsql/pgsql.c   Wed Oct  1 20:31:02 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.385 2008/09/08 01:30:55 felipe Exp $ */
+/* $Id: pgsql.c,v 1.386 2008/10/01 20:31:02 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -1711,6 +1711,10 @@
 static void _php_pgsql_free_params(char **params, int num_params)
 {
if (num_params  0) {
+   int i;
+   for (i = 0; i  num_params; i++) {
+   efree(params[i]);
+   }
efree(params);
}
 }
@@ -1729,7 +1733,6 @@
int leftover = 0;
int num_params = 0;
char **params = NULL;
-   unsigned char otype;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
@@ -1778,19 +1781,20 @@
RETURN_FALSE;
}
 
-   otype = (*tmp)-type;
-   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);
-   RETURN_FALSE;
-   }
-
-   if (otype == IS_NULL) {
+   if (Z_TYPE_PP(tmp) == IS_NULL) {
params[i] = NULL;
-   }
-   else {
-   params[i] = Z_STRVAL_PP(tmp);
+   } else {
+   zval tmp_val = **tmp;
+   zval_copy_ctor(tmp_val);
+   convert_to_string(tmp_val);
+   if (Z_TYPE(tmp_val) != IS_STRING) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING,Error converting parameter);
+   zval_dtor(tmp_val);
+   _php_pgsql_free_params(params, 
num_params);
+   RETURN_FALSE;
+   }
+   params[i] = estrndup(Z_STRVAL(tmp_val), 
Z_STRLEN(tmp_val));
+   zval_dtor(tmp_val);
}
 
zend_hash_move_forward(Z_ARRVAL_P(pv_param_arr));
@@ -1936,7 +1940,6 @@
int leftover = 0;
int num_params = 0;
char **params = NULL;
-   unsigned char otype;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
@@ -1985,19 +1988,20 @@
RETURN_FALSE;
}
 
-   otype = (*tmp)-type;
-   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);
-   RETURN_FALSE;
-   }
-
-   if (otype == IS_NULL) {
+   if (Z_TYPE_PP(tmp) == IS_NULL) {
params[i] = NULL;
} else {
-   params[i] = Z_STRVAL_PP(tmp);
+   zval tmp_val = **tmp;
+   zval_copy_ctor(tmp_val);
+   convert_to_string(tmp_val);
+   if (Z_TYPE(tmp_val) != IS_STRING) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING,Error converting parameter);
+   zval_dtor(tmp_val);
+   _php_pgsql_free_params(params, 
num_params);
+   RETURN_FALSE;
+   }
+   params[i] = estrndup(Z_STRVAL(tmp_val), 
Z_STRLEN(tmp_val));
+   zval_dtor(tmp_val);
}
 
zend_hash_move_forward(Z_ARRVAL_P(pv_param_arr));
@@ -4548,7 +4552,6 @@
zval *pgsql_link, *pv_param_arr, **tmp;
int num_params = 0;
char **params = NULL;
-   unsigned char otype;
char *query;
int query_len, id 

[PHP-CVS] cvs: php-src /ext/pgsql pgsql.c /ext/standard file.c streamsfuncs.c

2008-09-07 Thread Felipe Pena
felipe  Mon Sep  8 01:30:56 2008 UTC

  Modified files:  
/php-src/ext/standard   streamsfuncs.c file.c 
/php-src/ext/pgsql  pgsql.c 
  Log:
  - Fixed some wrong format parameters
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/streamsfuncs.c?r1=1.121r2=1.122diff_format=u
Index: php-src/ext/standard/streamsfuncs.c
diff -u php-src/ext/standard/streamsfuncs.c:1.121 
php-src/ext/standard/streamsfuncs.c:1.122
--- php-src/ext/standard/streamsfuncs.c:1.121   Sat Aug 16 10:57:26 2008
+++ php-src/ext/standard/streamsfuncs.c Mon Sep  8 01:30:55 2008
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: streamsfuncs.c,v 1.121 2008/08/16 10:57:26 bjori Exp $ */
+/* $Id: streamsfuncs.c,v 1.122 2008/09/08 01:30:55 felipe Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -94,7 +94,7 @@
 
RETVAL_FALSE;

-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|zzd!lr, host, 
host_len, zerrno, zerrstr, timeout, flags, zcontext) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|zzdlr, host, 
host_len, zerrno, zerrstr, timeout, flags, zcontext) == FAILURE) {
RETURN_FALSE;
}

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/file.c?r1=1.525r2=1.526diff_format=u
Index: php-src/ext/standard/file.c
diff -u php-src/ext/standard/file.c:1.525 php-src/ext/standard/file.c:1.526
--- php-src/ext/standard/file.c:1.525   Tue Aug 12 19:38:04 2008
+++ php-src/ext/standard/file.c Mon Sep  8 01:30:55 2008
@@ -21,7 +21,7 @@
+--+
 */
 
-/* $Id: file.c,v 1.525 2008/08/12 19:38:04 felipe Exp $ */
+/* $Id: file.c,v 1.526 2008/09/08 01:30:55 felipe Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -2132,7 +2132,7 @@
zval *zstream;
zend_uchar delimiter_free = 0, enclosure_free = 0, escape_free = 0;
 
-   if (zend_parse_parameters(argc TSRMLS_CC, r|l!ttt, zstream, len,
+   if (zend_parse_parameters(argc TSRMLS_CC, r|lttt, zstream, len,
delimiter, delimiter_len, 
delimiter_type,
enclosure, enclosure_len, 
enclosure_type,
escape,escape_len,
escape_type) == FAILURE) {
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.384r2=1.385diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.384 php-src/ext/pgsql/pgsql.c:1.385
--- php-src/ext/pgsql/pgsql.c:1.384 Sun Aug  3 12:12:39 2008
+++ php-src/ext/pgsql/pgsql.c   Mon Sep  8 01:30:55 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.384 2008/08/03 12:12:39 jani Exp $ */
+/* $Id: pgsql.c,v 1.385 2008/09/08 01:30:55 felipe Exp $ */
 
 #include stdlib.h
 
@@ -2213,7 +2213,7 @@
char *table_name;
zend_rsrc_list_entry *field_table;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rl|b!, result, 
fnum, return_oid) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rl|b, result, 
fnum, return_oid) == FAILURE) {
return;
}
 
@@ -3950,7 +3950,7 @@
ExecStatusType status;
int argc = ZEND_NUM_ARGS();
 
-   if (zend_parse_parameters(argc TSRMLS_CC, rs/a|ss,
+   if (zend_parse_parameters(argc TSRMLS_CC, rsa|ss,
  pgsql_link, 
table_name, table_name_len, pg_rows,
  pg_delim, 
pg_delim_len, pg_null_as, pg_null_as_len) == FAILURE) {
return;



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



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

2008-07-01 Thread Felipe Pena
felipe  Wed Jul  2 00:13:26 2008 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  - MFB: Added arginfo
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.380r2=1.381diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.380 php-src/ext/pgsql/pgsql.c:1.381
--- php-src/ext/pgsql/pgsql.c:1.380 Mon Jun 30 01:59:35 2008
+++ php-src/ext/pgsql/pgsql.c   Wed Jul  2 00:13:26 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.380 2008/06/30 01:59:35 felipe Exp $ */
+/* $Id: pgsql.c,v 1.381 2008/07/02 00:13:26 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, field_number)
+ZEND_END_ARG_INFO()
+
+static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_pg_field_num, 0, 0, 2)
+   ZEND_ARG_INFO(0, 

[PHP-CVS] cvs: php-src /ext/pgsql pgsql.c /ext/pgsql/tests 08escape.phpt 98old_api.phpt

2008-06-29 Thread Felipe Pena
felipe  Mon Jun 30 01:59:35 2008 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
/php-src/ext/pgsql/tests08escape.phpt 98old_api.phpt 
  Log:
  - MFB: New parameter parsing API
  - Fixed tests
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.379r2=1.380diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.379 php-src/ext/pgsql/pgsql.c:1.380
--- php-src/ext/pgsql/pgsql.c:1.379 Mon May 19 15:18:49 2008
+++ php-src/ext/pgsql/pgsql.c   Mon Jun 30 01:59:35 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.379 2008/05/19 15:18:49 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.380 2008/06/30 01:59:35 felipe Exp $ */
 
 #include stdlib.h
 
@@ -848,37 +848,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;
}
@@ -900,30 +894,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:
@@ -1103,38 +1092,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:
-   WRONG_PARAM_COUNT;
-   break;

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

2008-05-19 Thread Ilia Alshanetsky
iliaa   Mon May 19 15:18:49 2008 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  
  MFB: 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.378r2=1.379diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.378 php-src/ext/pgsql/pgsql.c:1.379
--- php-src/ext/pgsql/pgsql.c:1.378 Mon Dec 31 07:12:13 2007
+++ php-src/ext/pgsql/pgsql.c   Mon May 19 15:18:49 2008
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.378 2007/12/31 07:12:13 sebastian Exp $ */
+/* $Id: pgsql.c,v 1.379 2008/05/19 15:18:49 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -4980,7 +4980,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 /ext/pgsql pgsql.c

2007-11-29 Thread Antony Dovgal
tony2001Thu Nov 29 21:23:59 2007 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  fix build
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.376r2=1.377diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.376 php-src/ext/pgsql/pgsql.c:1.377
--- php-src/ext/pgsql/pgsql.c:1.376 Thu Nov 22 00:20:40 2007
+++ php-src/ext/pgsql/pgsql.c   Thu Nov 29 21:23:59 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.376 2007/11/22 00:20:40 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.377 2007/11/29 21:23:59 tony2001 Exp $ */
 
 #include stdlib.h
 
@@ -5739,6 +5739,9 @@
} else {
char *element = PQgetvalue(pg_result, pg_row, 
i);
if (element) {
+   char *data;
+   size_t data_len;
+
data_len = strlen(element);
data = safe_estrndup(element, data_len);
 

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



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

2007-11-21 Thread Ilia Alshanetsky
iliaa   Thu Nov 22 00:20:40 2007 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  
  MFB: Fixed bug #43041 (micro-optimizations in pgsql data retrieval) 
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.375r2=1.376diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.375 php-src/ext/pgsql/pgsql.c:1.376
--- php-src/ext/pgsql/pgsql.c:1.375 Tue Nov 13 20:08:17 2007
+++ php-src/ext/pgsql/pgsql.c   Thu Nov 22 00:20:40 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.375 2007/11/13 20:08:17 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.376 2007/11/22 00:20:40 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -1986,8 +1986,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;
 
@@ -2058,12 +2057,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);
 
data = safe_estrndup(element, element_len);
data_len = element_len;
@@ -5720,8 +5719,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);
@@ -5738,11 +5737,10 @@
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) {
-   data = safe_estrndup(element, 
element_len);
-   data_len = element_len;
+   data_len = strlen(element);
+   data = safe_estrndup(element, data_len);
 
field_name = PQfname(pg_result, i);
add_assoc_stringl(row, field_name, 
data, data_len, 0);

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



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

2007-11-13 Thread Ilia Alshanetsky
iliaa   Tue Nov 13 20:08:17 2007 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  MFB: 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.374r2=1.375diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.374 php-src/ext/pgsql/pgsql.c:1.375
--- php-src/ext/pgsql/pgsql.c:1.374 Wed Oct  3 23:31:04 2007
+++ php-src/ext/pgsql/pgsql.c   Tue Nov 13 20:08:17 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.374 2007/10/03 23:31:04 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.375 2007/11/13 20:08:17 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -4061,6 +4061,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) {
@@ -4075,7 +4076,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



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

2007-10-03 Thread Ilia Alshanetsky
iliaa   Wed Oct  3 23:31:05 2007 UTC

  Modified files:  
/php-src/ext/pgsql/tests80_bug42783.phpt 
/php-src/ext/pgsql  pgsql.c 
  Log:
  
  MFB: Fixed bug #42783 (pg_insert() does not accept an empty list for
  insertion)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/tests/80_bug42783.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/pgsql/tests/80_bug42783.phpt
diff -u /dev/null php-src/ext/pgsql/tests/80_bug42783.phpt:1.2
--- /dev/null   Wed Oct  3 23:31:04 2007
+++ php-src/ext/pgsql/tests/80_bug42783.phptWed Oct  3 23:31:04 2007
@@ -0,0 +1,34 @@
+--TEST--
+Bug #42783 (pg_insert() does not support an empty value array)
+--SKIPIF--
+?php 
+require_once('skipif.inc');
+?
+--FILE--
+?php
+
+require_once('config.inc');
+   
+$dbh = @pg_connect($conn_str);
+if (!$dbh) {
+   die (Could not connect to the server);
+}
+
+pg_query(CREATE TABLE php_test (id SERIAL PRIMARY KEY, time TIMESTAMP NOT 
NULL DEFAULT now()));
+
+pg_insert($dbh, 'php_test', array());
+
+var_dump(pg_fetch_assoc(pg_query(SELECT * FROM php_test)));
+
+pg_query($dbh, DROP TABLE php_test);
+pg_close($dbh);
+?
+===DONE===
+--EXPECTF--
+array(2) {
+  [id]=
+  string(%d) %d
+  [time]=
+  string(%d) %s
+}
+===DONE===
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.373r2=1.374diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.373 php-src/ext/pgsql/pgsql.c:1.374
--- php-src/ext/pgsql/pgsql.c:1.373 Thu Sep 27 18:28:41 2007
+++ php-src/ext/pgsql/pgsql.c   Wed Oct  3 23:31:04 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.373 2007/09/27 18:28:41 dmitry Exp $ */
+/* $Id: pgsql.c,v 1.374 2007/10/03 23:31:04 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -5344,7 +5344,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 */
@@ -5402,6 +5406,9 @@
/* Remove the trailing , */
querystr.len--;
smart_str_appends(querystr, ););
+
+no_values:
+
smart_str_0(querystr);
 
if ((opt  (PGSQL_DML_EXEC|PGSQL_DML_ASYNC)) 
@@ -5413,7 +5420,7 @@
}

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

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



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

2007-09-05 Thread Ilia Alshanetsky
iliaa   Wed Sep  5 12:56:16 2007 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  
  MFB: Fixed bug #42506 (php_pgsql_convert() timezone parse bug)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.369r2=1.370diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.369 php-src/ext/pgsql/pgsql.c:1.370
--- php-src/ext/pgsql/pgsql.c:1.369 Tue Aug 21 23:51:34 2007
+++ php-src/ext/pgsql/pgsql.c   Wed Sep  5 12:56:16 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.369 2007/08/21 23:51:34 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.370 2007/09/05 12:56:16 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -4975,7 +4975,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,5})){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,2}(:[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 /ext/pgsql pgsql.c

2007-09-05 Thread Ilia Alshanetsky
iliaa   Wed Sep  5 12:58:48 2007 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  
  MFB: Fixed bug #41845 (pgsql extension does not compile with PostgreSQL
  7.4)
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.370r2=1.371diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.370 php-src/ext/pgsql/pgsql.c:1.371
--- php-src/ext/pgsql/pgsql.c:1.370 Wed Sep  5 12:56:16 2007
+++ php-src/ext/pgsql/pgsql.c   Wed Sep  5 12:58:48 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.370 2007/09/05 12:56:16 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.371 2007/09/05 12:58:48 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -82,6 +82,10 @@
 
 #define CHECK_DEFAULT_LINK(x) if ((x) == -1) { php_error_docref(NULL 
TSRMLS_CC, E_WARNING, No PostgreSQL link opened yet); }
 
+#ifndef HAVE_PQFREEMEM
+#define PGfreemem free
+#endif
+
 ZEND_DECLARE_MODULE_GLOBALS(pgsql)
 static PHP_GINIT_FUNCTION(pgsql);
 

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



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

2007-09-05 Thread Ilia Alshanetsky
iliaa   Wed Sep  5 13:03:33 2007 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed typo in function name
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.371r2=1.372diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.371 php-src/ext/pgsql/pgsql.c:1.372
--- php-src/ext/pgsql/pgsql.c:1.371 Wed Sep  5 12:58:48 2007
+++ php-src/ext/pgsql/pgsql.c   Wed Sep  5 13:03:33 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.371 2007/09/05 12:58:48 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.372 2007/09/05 13:03:33 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -83,7 +83,7 @@
 #define CHECK_DEFAULT_LINK(x) if ((x) == -1) { php_error_docref(NULL 
TSRMLS_CC, E_WARNING, No PostgreSQL link opened yet); }
 
 #ifndef HAVE_PQFREEMEM
-#define PGfreemem free
+#define PQfreemem free
 #endif
 
 ZEND_DECLARE_MODULE_GLOBALS(pgsql)

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



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

2007-08-21 Thread Ilia Alshanetsky
iliaa   Tue Aug 21 23:51:34 2007 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #42368 (Incorrect error message displayed by pg_escape_string)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.368r2=1.369diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.368 php-src/ext/pgsql/pgsql.c:1.369
--- php-src/ext/pgsql/pgsql.c:1.368 Sun Jul 15 19:50:06 2007
+++ php-src/ext/pgsql/pgsql.c   Tue Aug 21 23:51:34 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.368 2007/07/15 19:50:06 jani Exp $ */
+/* $Id: pgsql.c,v 1.369 2007/08/21 23:51:34 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -3545,11 +3545,20 @@
int from_len;
int id = -1;
 
-   if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() 
TSRMLS_CC, s, from, from_len) == SUCCESS) {
-   pgsql_link = NULL;
-   id = PGG(default_link);
-   } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rs, 
pgsql_link, from, from_len) == FAILURE) {
-   return;
+   switch (ZEND_NUM_ARGS()) {
+   case 1:
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
s, from, from_len) == FAILURE) {
+   return;
+   }
+   pgsql_link = NULL;
+   id = PGG(default_link);
+   break;
+
+   default:
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
rs, pgsql_link, from, from_len) == FAILURE) {
+   return;
+   }
+   break;
}
 
to = (char *) safe_emalloc(from_len, 2, 1);
@@ -3578,11 +3587,20 @@
 #endif
zval *pgsql_link;
 
-   if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() 
TSRMLS_CC, s, from, from_len) == SUCCESS) {
-   pgsql_link = NULL;
-   id = PGG(default_link);
-   } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rs, 
pgsql_link, from, from_len) == FAILURE) {
-   return;
+   switch (ZEND_NUM_ARGS()) {
+   case 1:
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
s, from, from_len) == FAILURE) {
+   return;
+   }
+   pgsql_link = NULL;
+   id = PGG(default_link);
+   break;
+
+   default:
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
rs, pgsql_link, from, from_len) == FAILURE) {
+   return;
+   }
+   break;
}
 
 #ifdef HAVE_PQESCAPE_BYTEA_CONN

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



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

2007-01-11 Thread Antony Dovgal
tony2001Thu Jan 11 16:45:28 2007 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  make sure the string is non-empty and use strlcpy()  strlcat()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.364r2=1.365diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.364 php-src/ext/pgsql/pgsql.c:1.365
--- php-src/ext/pgsql/pgsql.c:1.364 Mon Jan  1 09:29:28 2007
+++ php-src/ext/pgsql/pgsql.c   Thu Jan 11 16:45:27 2007
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.364 2007/01/01 09:29:28 sebastian Exp $ */
+/* $Id: pgsql.c,v 1.365 2007/01/11 16:45:27 tony2001 Exp $ */
 
 #include stdlib.h
 
@@ -3469,10 +3469,11 @@
 #if HAVE_PQPUTCOPYDATA
while 
(zend_hash_get_current_data_ex(Z_ARRVAL_P(pg_rows), (void **) tmp, pos) == 
SUCCESS) {
convert_to_string_ex(tmp);
-   query = (char 
*)emalloc(Z_STRLEN_PP(tmp) +2);
-   strcpy(query, Z_STRVAL_PP(tmp));
-   if(*(query+Z_STRLEN_PP(tmp)-1) != '\n')
-   strcat(query, \n);
+   query = (char 
*)emalloc(Z_STRLEN_PP(tmp) + 2);
+   strlcpy(query, Z_STRVAL_PP(tmp), 
Z_STRLEN_PP(tmp) + 2);
+   if(Z_STRLEN_PP(tmp)  0  *(query + 
Z_STRLEN_PP(tmp) - 1) != '\n') {
+   strlcat(query, \n, 
Z_STRLEN_PP(tmp) + 2);
+   }
if (PQputCopyData(pgsql, query, 
strlen(query)) != 1) {
efree(query);
PHP_PQ_ERROR(copy failed: %s, 
pgsql);
@@ -3488,10 +3489,11 @@
 #else
while 
(zend_hash_get_current_data_ex(Z_ARRVAL_P(pg_rows), (void **) tmp, pos) == 
SUCCESS) {
convert_to_string_ex(tmp);
-   query = (char 
*)emalloc(Z_STRLEN_PP(tmp) +2);
-   strcpy(query, Z_STRVAL_PP(tmp));
-   if(*(query+Z_STRLEN_PP(tmp)-1) != '\n')
-   strcat(query, \n);
+   query = (char 
*)emalloc(Z_STRLEN_PP(tmp) + 2);
+   strlcpy(query, Z_STRVAL_PP(tmp), 
Z_STRLEN_PP(tmp) + 2);
+   if(Z_STRLEN_PP(tmp)  0  *(query + 
Z_STRLEN_PP(tmp) - 1) != '\n') {
+   strlcat(query, \n, 
Z_STRLEN_PP(tmp) + 2);
+   }
if (PQputline(pgsql, query)==EOF) {
efree(query);
PHP_PQ_ERROR(copy failed: %s, 
pgsql);

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



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

2006-12-28 Thread Ilia Alshanetsky
iliaa   Thu Dec 28 15:21:32 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  
  MFB: Added buffer length checks
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.361r2=1.362diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.361 php-src/ext/pgsql/pgsql.c:1.362
--- php-src/ext/pgsql/pgsql.c:1.361 Tue Dec 26 17:40:20 2006
+++ php-src/ext/pgsql/pgsql.c   Thu Dec 28 15:21:32 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.361 2006/12/26 17:40:20 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.362 2006/12/28 15:21:32 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -5472,7 +5472,7 @@
smart_str_append_long(querystr, Z_LVAL_PP(val));
break;
case IS_DOUBLE:
-   smart_str_appendl(querystr, buf, sprintf(buf, 
%f, Z_DVAL_PP(val)));
+   smart_str_appendl(querystr, buf, 
MIN(snprintf(buf, sizeof(buf), %f, Z_DVAL_PP(val)), sizeof(buf)-1));
break;
default:
/* should not happen */

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



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

2006-12-28 Thread Ilia Alshanetsky
iliaa   Fri Dec 29 00:34:53 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  MFB: Fixed bug #39971 (pg_insert/pg_update do not allow now() to be used for  
 
  timestamp fields).
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.362r2=1.363diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.362 php-src/ext/pgsql/pgsql.c:1.363
--- php-src/ext/pgsql/pgsql.c:1.362 Thu Dec 28 15:21:32 2006
+++ php-src/ext/pgsql/pgsql.c   Fri Dec 29 00:34:53 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.362 2006/12/28 15:21:32 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.363 2006/12/29 00:34:53 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -4955,14 +4955,14 @@
switch(Z_TYPE_PP(val)) {
case IS_STRING:
if (Z_STRLEN_PP(val) == 0) {
-   ZVAL_STRING(new_val, 
NULL, 1);
-   }
-   else {
+   ZVAL_STRINGL(new_val, 
NULL, sizeof(NULL)-1, 1);
+   } else if 
(!strcasecmp(Z_STRVAL_PP(val), now())) {
+   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,5})){0,1})){0,1}$, 1 
TSRMLS_CC) == FAILURE) {
err = 1;
-   }
-   else {
+   } else {

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

php_pgsql_add_quotes(new_val, 1 TSRMLS_CC);
}
@@ -4970,7 +4970,7 @@
break;

case IS_NULL:
-   ZVAL_STRING(new_val, NULL, 1);
+   ZVAL_STRINGL(new_val, NULL, 
sizeof(NULL)-1, 1);
break;
 
default:

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



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

2006-11-13 Thread Ilia Alshanetsky
iliaa   Mon Nov 13 22:11:02 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  MFB: Fixed bug #36812 (pg_execute() modifies input array).
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.358r2=1.359diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.358 php-src/ext/pgsql/pgsql.c:1.359
--- php-src/ext/pgsql/pgsql.c:1.358 Fri Oct  6 21:45:35 2006
+++ php-src/ext/pgsql/pgsql.c   Mon Nov 13 22:11:02 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.358 2006/10/06 21:45:35 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.359 2006/11/13 22:11:02 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -1472,6 +1472,7 @@
php_error_docref(NULL TSRMLS_CC, E_NOTICE, Found results on 
this connection. Use pg_get_result() to get these results first);
}
 
+   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) {
@@ -1486,7 +1487,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);
@@ -1495,8 +1497,7 @@
 
if (otype == IS_NULL) {
params[i] = NULL;
-   }
-   else {
+   } else {
params[i] = Z_STRVAL_PP(tmp);
}
 

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



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

2006-10-03 Thread Hannes Magnusson
bjori   Tue Oct  3 15:22:54 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  MFB: pg_send_prepare(), pg_send_query_params()  pg_send_execute() do not 
throw Wrong parameter count
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.354r2=1.355diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.354 php-src/ext/pgsql/pgsql.c:1.355
--- php-src/ext/pgsql/pgsql.c:1.354 Fri Sep 15 19:48:55 2006
+++ php-src/ext/pgsql/pgsql.c   Tue Oct  3 15:22:54 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.354 2006/09/15 19:48:55 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.355 2006/10/03 15:22:54 bjori Exp $ */
 
 #include stdlib.h
 
@@ -3984,7 +3984,7 @@
int leftover = 0;
 
if (zend_get_parameters_ex(3, pgsql_link, query, pv_param_arr) == 
FAILURE) {
-   return;
+   WRONG_PARAM_COUNT;
}
 
if (pgsql_link == NULL  id == -1) {
@@ -4074,7 +4074,7 @@
int leftover = 0;
 
if (zend_get_parameters_ex(3, pgsql_link, stmtname, query) == 
FAILURE) {
-   return;
+   WRONG_PARAM_COUNT;
}
if (pgsql_link == NULL  id == -1) {
RETURN_FALSE;
@@ -4128,7 +4128,7 @@
int leftover = 0;
 
if (zend_get_parameters_ex(3, pgsql_link, stmtname, 
pv_param_arr)==FAILURE) {
-   return;
+   WRONG_PARAM_COUNT;
}
if (pgsql_link == NULL  id == -1) {
RETURN_FALSE;

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



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

2006-09-06 Thread Antony Dovgal
tony2001Wed Sep  6 12:40:47 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  fix leak in pg_copy_to() when invalid resource was passed
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.352r2=1.353diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.352 php-src/ext/pgsql/pgsql.c:1.353
--- php-src/ext/pgsql/pgsql.c:1.352 Tue Jun 13 13:12:19 2006
+++ php-src/ext/pgsql/pgsql.c   Wed Sep  6 12:40:47 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.352 2006/06/13 13:12:19 dmitry Exp $ */
+/* $Id: pgsql.c,v 1.353 2006/09/06 12:40:47 tony2001 Exp $ */
 
 #include stdlib.h
 
@@ -3296,12 +3296,13 @@
if (!pg_delim) {
pg_delim = \t;
}
+
+   ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL 
link, le_link, le_plink);
+
if (!pg_null_as) {
pg_null_as = safe_estrdup(N);
}
 
-   ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL 
link, le_link, le_plink);
-
query = (char *)emalloc(strlen(query_template) + strlen(table_name) + 
strlen(pg_null_as) + 1);
sprintf(query, COPY \%s\ TO STDOUT DELIMITERS '%c' WITH NULL AS 
'%s',
table_name, *pg_delim, pg_null_as);

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



Re: [PHP-CVS] cvs: php-src /ext/pgsql pgsql.c php_pgsql.h

2006-05-08 Thread Edin Kadribašić

http://livedocs.phpdoc.info/index.php?l=enq=function.pg-field-table

Christopher Kings-Lynne wrote:

Documentation?

Edin Kadribasic wrote:


edinkThu Mar 16 14:58:56 2006 UTC

  Modified files:  /php-src/ext/pgsqlpgsql.c 
php_pgsql.h   Log:

  Added pg_field_table() as per req: #36750
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/pgsql.c?r1=1.344r2=1.345diff_format=u 


Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.344 php-src/ext/pgsql/pgsql.c:1.345
--- php-src/ext/pgsql/pgsql.c:1.344Wed Mar  8 00:43:28 2006
+++ php-src/ext/pgsql/pgsql.cThu Mar 16 14:58:56 2006
@@ -20,7 +20,7 @@

+--+

  */
  -/* $Id: pgsql.c,v 1.344 2006/03/08 00:43:28 pajoye Exp $ */
+/* $Id: pgsql.c,v 1.345 2006/03/16 14:58:56 edink Exp $ */
 
 #include stdlib.h
 
@@ -151,6 +151,7 @@

 PHP_FE(pg_field_type_oid, NULL)
 PHP_FE(pg_field_prtlen,NULL)
 PHP_FE(pg_field_is_null,NULL)
+PHP_FE(pg_field_table,  NULL)
 /* async message function */
 PHP_FE(pg_get_notify,   NULL)
 PHP_FE(pg_get_pid,  NULL)
@@ -1694,6 +1695,95 @@
 }
 /* }}} */   
 
+/* {{{ proto mixed pg_field_table(resource result, int field_number[, 
bool oid_only])
+   Returns the name of the table field belongs to, or table's oid if 
oid_only is true */

+PHP_FUNCTION(pg_field_table)
+{
+zval *result;
+pgsql_result_handle *pg_result;
+long fnum = -1;
+zend_bool return_oid = 0;
+Oid oid;
+smart_str hash_key = {0};
+char *table_name;
+zend_rsrc_list_entry *field_table;
+
+if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rl|b!, 
result, fnum, return_oid) == FAILURE) {

+return;
+}
+
+ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, 
-1, PostgreSQL result, le_result);

+
+if (fnum  0 || fnum = PQnfields(pg_result-result)) {
+php_error_docref(NULL TSRMLS_CC, E_WARNING, Bad field offset 
specified);

+RETURN_FALSE;
+}
+
+oid = PQftable(pg_result-result, fnum);
+
+if (InvalidOid == oid) {
+RETURN_FALSE;
+}
+
+
+if (return_oid) {
+if (oid  LONG_MAX) {
+smart_str oidstr = {0};
+smart_str_append_unsigned(oidstr, oid);
+smart_str_0(oidstr);
+RETURN_STRINGL(oidstr.c, oidstr.len, 0);
+} else {
+RETURN_LONG((long)oid);
+}
+}
+
+/* try to lookup the table name in the resource list */
+smart_str_appends(hash_key, pgsql_table_oid_);
+smart_str_append_unsigned(hash_key, oid);
+smart_str_0(hash_key);
+
+if (zend_hash_find(EG(regular_list), hash_key.c, hash_key.len+1, 
(void **) field_table) == SUCCESS) {

+smart_str_free(hash_key);
+RETURN_STRING((char *)field_table-ptr, 1);
+} else { /* Not found, lookup by querying PostgreSQL system 
tables */

+PGresult *tmp_res;
+smart_str querystr = {0};
+zend_rsrc_list_entry new_field_table;
+
+smart_str_appends(querystr, select relname from pg_class 
where oid=);

+smart_str_append_unsigned(querystr, oid);
+smart_str_0(querystr);
+
+
+if ((tmp_res = PQexec(pg_result-conn, querystr.c)) == NULL 
|| PQresultStatus(tmp_res) != PGRES_TUPLES_OK) {

+if (tmp_res) {
+PQclear(tmp_res);
+}
+smart_str_free(querystr);
+smart_str_free(hash_key);
+RETURN_FALSE;
+}
+
+smart_str_free(querystr);
+
+if ((table_name = PQgetvalue(tmp_res, 0, 0)) == NULL) {
+PQclear(tmp_res);
+smart_str_free(hash_key);
+RETURN_FALSE;
+}
+
+Z_TYPE(new_field_table) = le_string;
+new_field_table.ptr = estrdup(table_name);
+zend_hash_update(EG(regular_list), hash_key.c, 
hash_key.len+1, (void *) new_field_table, 
sizeof(zend_rsrc_list_entry), NULL);

+
+smart_str_free(hash_key);
+PQclear(tmp_res);
+RETURN_STRING(table_name, 1);
+}
+
+}
+/* }}} */   
+

 #define PHP_PG_FIELD_NAME 1
 #define PHP_PG_FIELD_SIZE 2
 #define PHP_PG_FIELD_TYPE 3
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/php_pgsql.h?r1=1.74r2=1.75diff_format=u 


Index: php-src/ext/pgsql/php_pgsql.h
diff -u php-src/ext/pgsql/php_pgsql.h:1.74 
php-src/ext/pgsql/php_pgsql.h:1.75

--- php-src/ext/pgsql/php_pgsql.h:1.74Sun Jan  1 13:09:53 2006
+++ php-src/ext/pgsql/php_pgsql.hThu Mar 16 14:58:56 2006
@@ -17,7 +17,7 @@

+--+

  */
  -/* $Id: php_pgsql.h,v 1.74 2006/01/01 13:09:53 sniper Exp $ */
+/* $Id: php_pgsql.h,v 1.75 2006/03/16 14:58:56 edink Exp $ */
 
 #ifndef PHP_PGSQL_H

 #define PHP_PGSQL_H
@@ -125,6 +125,7 @@
 PHP_FUNCTION(pg_field_type_oid);
 PHP_FUNCTION(pg_field_prtlen);
 PHP_FUNCTION(pg_field_is_null);
+PHP_FUNCTION(pg_field_table);
 /* async message functions */
 

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

2006-04-10 Thread Marcus Boerger
helly   Mon Apr 10 19:48:27 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  - Fix possible SEGV
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/pgsql.c?r1=1.348r2=1.349diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.348 php-src/ext/pgsql/pgsql.c:1.349
--- php-src/ext/pgsql/pgsql.c:1.348 Wed Mar 29 01:10:27 2006
+++ php-src/ext/pgsql/pgsql.c   Mon Apr 10 19:48:27 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.348 2006/03/29 01:10:27 yohgaki Exp $ */
+/* $Id: pgsql.c,v 1.349 2006/04/10 19:48:27 helly Exp $ */
 
 #include stdlib.h
 
@@ -4586,7 +4586,7 @@
char *field = NULL;
uint field_len = -1;
ulong num_idx = -1;
-   zval *meta, **def, **type, **not_null, **has_default, **val, *new_val;
+   zval *meta, **def, **type, **not_null, **has_default, **val, *new_val = 
NULL;
int new_len, key_type, err = 0, skip_field;

assert(pg_link != NULL);
@@ -4646,7 +4646,7 @@
if (err) {
break; /* break out for() */
}
-   MAKE_STD_ZVAL(new_val);
+   ALLOC_INIT_ZVAL(new_val);
switch(php_pgsql_get_data_type(Z_STRVAL_PP(type), 
Z_STRLEN_PP(type)))
{
case PG_BOOL:
@@ -5178,7 +5178,7 @@
break;
} /* switch */

-   if (err) {
+   if (err  new_val) {
zval_dtor(new_val);
FREE_ZVAL(new_val);
break; /* break out for() */

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



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

2006-04-10 Thread Marcus Boerger
helly   Mon Apr 10 19:50:56 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  - Better order for SEGV prevention
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/pgsql.c?r1=1.349r2=1.350diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.349 php-src/ext/pgsql/pgsql.c:1.350
--- php-src/ext/pgsql/pgsql.c:1.349 Mon Apr 10 19:48:27 2006
+++ php-src/ext/pgsql/pgsql.c   Mon Apr 10 19:50:56 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.349 2006/04/10 19:48:27 helly Exp $ */
+/* $Id: pgsql.c,v 1.350 2006/04/10 19:50:56 helly Exp $ */
 
 #include stdlib.h
 
@@ -4586,7 +4586,7 @@
char *field = NULL;
uint field_len = -1;
ulong num_idx = -1;
-   zval *meta, **def, **type, **not_null, **has_default, **val, *new_val = 
NULL;
+   zval *meta, **def, **type, **not_null, **has_default, **val, *new_val;
int new_len, key_type, err = 0, skip_field;

assert(pg_link != NULL);
@@ -4608,6 +4608,7 @@
 zend_hash_get_current_data_ex(Z_ARRVAL_P(values), (void 
**)val, pos) == SUCCESS;
 zend_hash_move_forward_ex(Z_ARRVAL_P(values), pos)) {
skip_field = 0;
+   new_val = NULL;

if ((key_type = 
zend_hash_get_current_key_ex(Z_ARRVAL_P(values), field, field_len, num_idx, 
0, pos)) == HASH_KEY_NON_EXISTANT) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Failed to 
get array key type);

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



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

2006-03-28 Thread Yasuo Ohgaki
yohgaki Wed Mar 29 01:10:27 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  restore E_WARNING in correct place
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/pgsql.c?r1=1.347r2=1.348diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.347 php-src/ext/pgsql/pgsql.c:1.348
--- php-src/ext/pgsql/pgsql.c:1.347 Mon Mar 27 02:59:41 2006
+++ php-src/ext/pgsql/pgsql.c   Wed Mar 29 01:10:27 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.347 2006/03/27 02:59:41 yohgaki Exp $ */
+/* $Id: pgsql.c,v 1.348 2006/03/29 01:10:27 yohgaki Exp $ */
 
 #include stdlib.h
 
@@ -1522,6 +1522,7 @@
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
PQclear(pgsql_result);
+   PHP_PQ_ERROR(Query failed: %s, pgsql);
RETURN_FALSE;
break;
case PGRES_COMMAND_OK: /* successful command that did not 
return rows */

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



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

2006-03-26 Thread Yasuo Ohgaki
yohgaki Mon Mar 27 02:59:42 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  remove pg_execute() E_WARNING error when query plan is not defined
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/pgsql.c?r1=1.346r2=1.347diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.346 php-src/ext/pgsql/pgsql.c:1.347
--- php-src/ext/pgsql/pgsql.c:1.346 Wed Mar 22 17:32:21 2006
+++ php-src/ext/pgsql/pgsql.c   Mon Mar 27 02:59:41 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.346 2006/03/22 17:32:21 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.347 2006/03/27 02:59:41 yohgaki Exp $ */
 
 #include stdlib.h
 
@@ -1521,7 +1521,6 @@
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
-   PHP_PQ_ERROR(Query failed: %s, pgsql);
PQclear(pgsql_result);
RETURN_FALSE;
break;

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



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

2006-03-22 Thread Ilia Alshanetsky
iliaa   Wed Mar 22 17:32:21 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Simplify and optimize code.
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/pgsql.c?r1=1.345r2=1.346diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.345 php-src/ext/pgsql/pgsql.c:1.346
--- php-src/ext/pgsql/pgsql.c:1.345 Thu Mar 16 14:58:56 2006
+++ php-src/ext/pgsql/pgsql.c   Wed Mar 22 17:32:21 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.345 2006/03/16 14:58:56 edink Exp $ */
+/* $Id: pgsql.c,v 1.346 2006/03/22 17:32:21 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -2672,16 +2672,15 @@
   (Jouni)
*/
 
-   if (strchr(mode_string, 'r') == mode_string) {
+   if (mode_string[0] == 'r') {
pgsql_mode |= INV_READ;
-   if (strchr(mode_string, '+') == mode_string+1) {
+   if (mode_string[1] == '+') {
pgsql_mode |= INV_WRITE;
}
-   }
-   if (strchr(mode_string, 'w') == mode_string) {
+   } else if (mode_string[0] == 'w') {
pgsql_mode |= INV_WRITE;
create = 1;
-   if (strchr(mode_string, '+') == mode_string+1) {
+   if (mode_string[1] == '+') {
pgsql_mode |= INV_READ;
}
}

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



[PHP-CVS] cvs: php-src /ext/pgsql pgsql.c php_pgsql.h

2006-03-16 Thread Edin Kadribasic
edink   Thu Mar 16 14:58:56 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c php_pgsql.h 
  Log:
  Added pg_field_table() as per req: #36750
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/pgsql.c?r1=1.344r2=1.345diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.344 php-src/ext/pgsql/pgsql.c:1.345
--- php-src/ext/pgsql/pgsql.c:1.344 Wed Mar  8 00:43:28 2006
+++ php-src/ext/pgsql/pgsql.c   Thu Mar 16 14:58:56 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.344 2006/03/08 00:43:28 pajoye Exp $ */
+/* $Id: pgsql.c,v 1.345 2006/03/16 14:58:56 edink Exp $ */
 
 #include stdlib.h
 
@@ -151,6 +151,7 @@
PHP_FE(pg_field_type_oid, NULL)
PHP_FE(pg_field_prtlen, NULL)
PHP_FE(pg_field_is_null,NULL)
+   PHP_FE(pg_field_table,  NULL)
/* async message function */
PHP_FE(pg_get_notify,   NULL)
PHP_FE(pg_get_pid,  NULL)
@@ -1694,6 +1695,95 @@
 }
 /* }}} */  
 
+/* {{{ proto mixed pg_field_table(resource result, int field_number[, bool 
oid_only])
+   Returns the name of the table field belongs to, or table's oid if oid_only 
is true */
+PHP_FUNCTION(pg_field_table)
+{
+   zval *result;
+   pgsql_result_handle *pg_result;
+   long fnum = -1;
+   zend_bool return_oid = 0;
+   Oid oid;
+   smart_str hash_key = {0};
+   char *table_name;
+   zend_rsrc_list_entry *field_table;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rl|b!, result, 
fnum, return_oid) == FAILURE) {
+   return;
+   }
+
+   ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, 
PostgreSQL result, le_result);
+
+   if (fnum  0 || fnum = PQnfields(pg_result-result)) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Bad field offset 
specified);
+   RETURN_FALSE;
+   }
+
+   oid = PQftable(pg_result-result, fnum);
+
+   if (InvalidOid == oid) {
+   RETURN_FALSE;
+   }
+
+
+   if (return_oid) {
+   if (oid  LONG_MAX) {
+   smart_str oidstr = {0};
+   smart_str_append_unsigned(oidstr, oid);
+   smart_str_0(oidstr);
+   RETURN_STRINGL(oidstr.c, oidstr.len, 0);
+   } else {
+   RETURN_LONG((long)oid);
+   }
+   }
+
+   /* try to lookup the table name in the resource list */
+   smart_str_appends(hash_key, pgsql_table_oid_);
+   smart_str_append_unsigned(hash_key, oid);
+   smart_str_0(hash_key);
+
+   if (zend_hash_find(EG(regular_list), hash_key.c, hash_key.len+1, (void 
**) field_table) == SUCCESS) {
+   smart_str_free(hash_key);
+   RETURN_STRING((char *)field_table-ptr, 1);
+   } else { /* Not found, lookup by querying PostgreSQL system tables */
+   PGresult *tmp_res;
+   smart_str querystr = {0};
+   zend_rsrc_list_entry new_field_table;
+
+   smart_str_appends(querystr, select relname from pg_class 
where oid=);
+   smart_str_append_unsigned(querystr, oid);
+   smart_str_0(querystr);
+
+
+   if ((tmp_res = PQexec(pg_result-conn, querystr.c)) == NULL || 
PQresultStatus(tmp_res) != PGRES_TUPLES_OK) {
+   if (tmp_res) {
+   PQclear(tmp_res);
+   }
+   smart_str_free(querystr);
+   smart_str_free(hash_key);
+   RETURN_FALSE;
+   }
+
+   smart_str_free(querystr);
+
+   if ((table_name = PQgetvalue(tmp_res, 0, 0)) == NULL) {
+   PQclear(tmp_res);
+   smart_str_free(hash_key);
+   RETURN_FALSE;
+   }
+
+   Z_TYPE(new_field_table) = le_string;
+   new_field_table.ptr = estrdup(table_name);
+   zend_hash_update(EG(regular_list), hash_key.c, hash_key.len+1, 
(void *) new_field_table, sizeof(zend_rsrc_list_entry), NULL);
+
+   smart_str_free(hash_key);
+   PQclear(tmp_res);
+   RETURN_STRING(table_name, 1);
+   }
+
+}
+/* }}} */  
+
 #define PHP_PG_FIELD_NAME 1
 #define PHP_PG_FIELD_SIZE 2
 #define PHP_PG_FIELD_TYPE 3
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/php_pgsql.h?r1=1.74r2=1.75diff_format=u
Index: php-src/ext/pgsql/php_pgsql.h
diff -u php-src/ext/pgsql/php_pgsql.h:1.74 php-src/ext/pgsql/php_pgsql.h:1.75
--- php-src/ext/pgsql/php_pgsql.h:1.74  Sun Jan  1 13:09:53 2006
+++ php-src/ext/pgsql/php_pgsql.h   Thu Mar 16 14:58:56 2006
@@ -17,7 +17,7 @@
+--+
  */
  
-/* $Id: php_pgsql.h,v 1.74 2006/01/01 13:09:53 sniper Exp $ */
+/* 

Re: [PHP-CVS] cvs: php-src /ext/pgsql pgsql.c php_pgsql.h

2006-03-16 Thread Christopher Kings-Lynne

Documentation?

Edin Kadribasic wrote:

edink   Thu Mar 16 14:58:56 2006 UTC

  Modified files:  
/php-src/ext/pgsql	pgsql.c php_pgsql.h 
  Log:

  Added pg_field_table() as per req: #36750
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/pgsql.c?r1=1.344r2=1.345diff_format=u

Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.344 php-src/ext/pgsql/pgsql.c:1.345
--- php-src/ext/pgsql/pgsql.c:1.344 Wed Mar  8 00:43:28 2006
+++ php-src/ext/pgsql/pgsql.c   Thu Mar 16 14:58:56 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.344 2006/03/08 00:43:28 pajoye Exp $ */

+/* $Id: pgsql.c,v 1.345 2006/03/16 14:58:56 edink Exp $ */
 
 #include stdlib.h
 
@@ -151,6 +151,7 @@

PHP_FE(pg_field_type_oid, NULL)
PHP_FE(pg_field_prtlen, NULL)
PHP_FE(pg_field_is_null,NULL)
+   PHP_FE(pg_field_table,  NULL)
/* async message function */
PHP_FE(pg_get_notify,   NULL)
PHP_FE(pg_get_pid,  NULL)
@@ -1694,6 +1695,95 @@
 }
 /* }}} */  
 
+/* {{{ proto mixed pg_field_table(resource result, int field_number[, bool oid_only])

+   Returns the name of the table field belongs to, or table's oid if oid_only 
is true */
+PHP_FUNCTION(pg_field_table)
+{
+   zval *result;
+   pgsql_result_handle *pg_result;
+   long fnum = -1;
+   zend_bool return_oid = 0;
+   Oid oid;
+   smart_str hash_key = {0};
+   char *table_name;
+   zend_rsrc_list_entry *field_table;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rl|b!, result, 
fnum, return_oid) == FAILURE) {
+   return;
+   }
+
+   ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, 
PostgreSQL result, le_result);
+
+   if (fnum  0 || fnum = PQnfields(pg_result-result)) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Bad field offset 
specified);
+   RETURN_FALSE;
+   }
+
+   oid = PQftable(pg_result-result, fnum);
+
+   if (InvalidOid == oid) {
+   RETURN_FALSE;
+   }
+
+
+   if (return_oid) {
+   if (oid  LONG_MAX) {
+   smart_str oidstr = {0};
+   smart_str_append_unsigned(oidstr, oid);
+   smart_str_0(oidstr);
+   RETURN_STRINGL(oidstr.c, oidstr.len, 0);
+   } else {
+   RETURN_LONG((long)oid);
+   }
+   }
+
+   /* try to lookup the table name in the resource list */
+   smart_str_appends(hash_key, pgsql_table_oid_);
+   smart_str_append_unsigned(hash_key, oid);
+   smart_str_0(hash_key);
+
+   if (zend_hash_find(EG(regular_list), hash_key.c, hash_key.len+1, (void **) 
field_table) == SUCCESS) {
+   smart_str_free(hash_key);
+   RETURN_STRING((char *)field_table-ptr, 1);
+   } else { /* Not found, lookup by querying PostgreSQL system tables */
+   PGresult *tmp_res;
+   smart_str querystr = {0};
+   zend_rsrc_list_entry new_field_table;
+
+   smart_str_appends(querystr, select relname from pg_class where 
oid=);
+   smart_str_append_unsigned(querystr, oid);
+   smart_str_0(querystr);
+
+
+   if ((tmp_res = PQexec(pg_result-conn, querystr.c)) == NULL || 
PQresultStatus(tmp_res) != PGRES_TUPLES_OK) {
+   if (tmp_res) {
+   PQclear(tmp_res);
+   }
+   smart_str_free(querystr);
+   smart_str_free(hash_key);
+   RETURN_FALSE;
+   }
+
+   smart_str_free(querystr);
+
+   if ((table_name = PQgetvalue(tmp_res, 0, 0)) == NULL) {
+   PQclear(tmp_res);
+   smart_str_free(hash_key);
+   RETURN_FALSE;
+   }
+
+   Z_TYPE(new_field_table) = le_string;
+   new_field_table.ptr = estrdup(table_name);
+   zend_hash_update(EG(regular_list), hash_key.c, hash_key.len+1, 
(void *) new_field_table, sizeof(zend_rsrc_list_entry), NULL);
+
+   smart_str_free(hash_key);
+   PQclear(tmp_res);
+   RETURN_STRING(table_name, 1);
+   }
+
+}
+/* }}} */  
+
 #define PHP_PG_FIELD_NAME 1
 #define PHP_PG_FIELD_SIZE 2
 #define PHP_PG_FIELD_TYPE 3
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/php_pgsql.h?r1=1.74r2=1.75diff_format=u
Index: php-src/ext/pgsql/php_pgsql.h
diff -u php-src/ext/pgsql/php_pgsql.h:1.74 php-src/ext/pgsql/php_pgsql.h:1.75
--- php-src/ext/pgsql/php_pgsql.h:1.74  Sun Jan  1 13:09:53 2006
+++ php-src/ext/pgsql/php_pgsql.h   Thu Mar 16 14:58:56 2006
@@ -17,7 +17,7 @@
+--+
  */
  
-/* $Id: php_pgsql.h,v 

Re: [PHP-CVS] cvs: php-src /ext/pgsql pgsql.c php_pgsql.h

2006-03-16 Thread Ilia Alshanetsky

Christopher Kings-Lynne wrote:

Documentation?


What's that? ;-)

Ilia

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



[PHP-CVS] cvs: php-src /ext/pgsql pgsql.c /ext/pgsql/tests .cvsignore 80_bug36625.phpt

2006-03-06 Thread Marcus Boerger
helly   Mon Mar  6 20:16:34 2006 UTC

  Added files: 
/php-src/ext/pgsql/tests80_bug36625.phpt 

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
/php-src/ext/pgsql/tests.cvsignore 
  Log:
  - Fixed #36625 pg_trace() does not work
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/pgsql.c?r1=1.342r2=1.343diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.342 php-src/ext/pgsql/pgsql.c:1.343
--- php-src/ext/pgsql/pgsql.c:1.342 Sun Mar  5 13:33:28 2006
+++ php-src/ext/pgsql/pgsql.c   Mon Mar  6 20:16:34 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.342 2006/03/05 13:33:28 tony2001 Exp $ */
+/* $Id: pgsql.c,v 1.343 2006/03/06 20:16:34 helly Exp $ */
 
 #include stdlib.h
 
@@ -2360,7 +2360,7 @@
RETURN_FALSE;
}
 
-   if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void**)fp, 
REPORT_ERRORS)) {
+   if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, 
(void**)fp, REPORT_ERRORS)){
php_stream_close(stream);
RETURN_FALSE;
}
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/tests/.cvsignore?r1=1.6r2=1.7diff_format=u
Index: php-src/ext/pgsql/tests/.cvsignore
diff -u php-src/ext/pgsql/tests/.cvsignore:1.6 
php-src/ext/pgsql/tests/.cvsignore:1.7
--- php-src/ext/pgsql/tests/.cvsignore:1.6  Sun Oct 10 16:10:04 2004
+++ php-src/ext/pgsql/tests/.cvsignore  Mon Mar  6 20:16:34 2006
@@ -6,3 +6,4 @@
 *.php
 *.gcda
 *.gcno
+trace.tmp

http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/tests/80_bug36625.phpt?view=markuprev=1.1
Index: php-src/ext/pgsql/tests/80_bug36625.phpt
+++ php-src/ext/pgsql/tests/80_bug36625.phpt
--TEST--
Bug #36625 (pg_trace() does not work)
--SKIPIF--
?php
require_once('skipif.inc');
?
--FILE--
?php

require_once('config.inc');

$dbh = @pg_connect($conn_str);
if (!$dbh) {
die ('Could not connect to the server');
}

$tracefile = dirname(__FILE__) . '/trace.tmp';

@unlink($tracefile);
var_dump(file_exists($tracefile));

pg_trace($tracefile, 'w', $dbh);
$res = pg_query($dbh, 'select 1');
var_dump($res);
pg_close($dbh);

$found = 0;
function search_trace_file($line)
{
if (strpos($line, 'select 1') !== false || strpos($line, 'select 
1') !== false) {
$GLOBALS['found']++;
}
}

$trace = file($tracefile);
array_walk($trace, 'search_trace_file');
var_dump($found  0);
var_dump(file_exists($tracefile));

?
===DONE===
--CLEAN--
?php unlink($tracefile); ?
--EXPECTF--
bool(false)
resource(%d) of type (pgsql result)
bool(true)
bool(true)
===DONE===

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



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

2006-03-05 Thread Antony Dovgal
tony2001Sun Mar  5 13:33:28 2006 UTC

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  fix #36606 (pg_query_params() changes arguments type to string)
  
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/pgsql/pgsql.c?r1=1.341r2=1.342diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.341 php-src/ext/pgsql/pgsql.c:1.342
--- php-src/ext/pgsql/pgsql.c:1.341 Sun Feb 19 04:29:41 2006
+++ php-src/ext/pgsql/pgsql.c   Sun Mar  5 13:33:28 2006
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.341 2006/02/19 04:29:41 andi Exp $ */
+/* $Id: pgsql.c,v 1.342 2006/03/05 13:33:28 tony2001 Exp $ */
 
 #include stdlib.h
 
@@ -257,7 +257,7 @@
 
 static int le_link, le_plink, le_result, le_lofp, le_string;
 
-ZEND_DECLARE_MODULE_GLOBALS(pgsql);
+ZEND_DECLARE_MODULE_GLOBALS(pgsql)
 
 /* {{{ _php_pgsql_trim_message */
 static char * _php_pgsql_trim_message(const char *message, int *len)
@@ -1257,7 +1257,7 @@
}
 
otype = (*tmp)-type;
-   convert_to_string(*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



[PHP-CVS] cvs: php-src /ext/pgsql pgsql.c /ext/pgsql/tests 80_bug32223b.phpt

2005-11-07 Thread Marcus Boerger
helly   Mon Nov  7 07:56:23 2005 EDT

  Added files: 
/php-src/ext/pgsql/tests80_bug32223b.phpt 

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  - Fix Bug #32223 weird behaviour of pg_last_notice 
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.334r2=1.335ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.334 php-src/ext/pgsql/pgsql.c:1.335
--- php-src/ext/pgsql/pgsql.c:1.334 Sun Nov  6 07:01:42 2005
+++ php-src/ext/pgsql/pgsql.c   Mon Nov  7 07:56:19 2005
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.334 2005/11/06 12:01:42 helly Exp $ */
+/* $Id: pgsql.c,v 1.335 2005/11/07 12:56:19 helly Exp $ */
 
 #include stdlib.h
 
@@ -345,7 +345,7 @@
if (PGG(log_notices)) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, %s, 
notice-message);
}
-   zend_hash_index_update(PGG(notices), *(int *)resource_id, 
(void **)notice, sizeof(php_pgsql_notice *), NULL);
+   zend_hash_index_update(PGG(notices), (int)resource_id, (void 
**)notice, sizeof(php_pgsql_notice *), NULL);
}
 }
 /* }}} */
@@ -783,7 +783,7 @@
}
/* set notice processer */
if (! PGG(ignore_notices)  Z_TYPE_P(return_value) == IS_RESOURCE) {
-   PQsetNoticeProcessor(pgsql, _php_pgsql_notice_handler, (void 
*)Z_RESVAL_P(return_value));
+   PQsetNoticeProcessor(pgsql, _php_pgsql_notice_handler, 
(void*)Z_RESVAL_P(return_value));
}
php_pgsql_set_default_link(Z_LVAL_P(return_value) TSRMLS_CC);


http://cvs.php.net/co.php/php-src/ext/pgsql/tests/80_bug32223b.phpt?r=1.1p=1
Index: php-src/ext/pgsql/tests/80_bug32223b.phpt
+++ php-src/ext/pgsql/tests/80_bug32223b.phpt
--TEST--
Bug #32223 (weird behaviour of pg_last_notice using define)
--SKIPIF--
?php 
require_once('skipif.inc');

@pg_query($conn, CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler 
LANCOMPILER 'PL/pgSQL');
$res = @pg_query($conn, CREATE OR REPLACE FUNCTION test_notice() RETURNS 
boolean AS '
begin
RAISE NOTICE ''1'';
return ''f'';
end;
' LANGUAGE plpgsql;);
if (!$res) die('skip PLPGSQL not available');
?
--FILE--
?php

require('config.inc');

define ('dbh', pg_connect($conn_str));
//$dbh = @pg_connect($conn_str);
if (!dbh) {
die (Could not connect to the server);
}

//@pg_query(dbh, CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler 
LANCOMPILER 'PL/pgSQL');
$res = pg_query(dbh, CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean 
AS '
begin
RAISE NOTICE ''1'';
return ''f'';
end;
' LANGUAGE plpgsql;);

function tester() {
$res = pg_query(dbh, 'SELECT test_notice()');
$row = pg_fetch_row($res, 0);
var_dump($row);
pg_free_result($res);
if ($row[0] == 'f')
{
var_dump(pg_last_notice(dbh));
}
}
tester();

pg_close(dbh);

?
===DONE===
--EXPECTF--
array(1) {
  [0]=
  string(1) f
}
string(14) NOTICE:  1
===DONE===

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



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

2005-11-06 Thread Marcus Boerger
helly   Sun Nov  6 07:01:43 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  -MFB Fix parameter parsing 
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.333r2=1.334ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.333 php-src/ext/pgsql/pgsql.c:1.334
--- php-src/ext/pgsql/pgsql.c:1.333 Tue Oct 11 12:18:40 2005
+++ php-src/ext/pgsql/pgsql.c   Sun Nov  6 07:01:42 2005
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.333 2005/10/11 16:18:40 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.334 2005/11/06 12:01:42 helly Exp $ */
 
 #include stdlib.h
 
@@ -1872,7 +1872,7 @@
 /* {{{ void php_pgsql_fetch_hash */
 static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long 
result_type, int into_object)
 {
-   zval*result;
+   zval*result, *zrow = NULL;
PGresult*pgsql_result;
pgsql_result_handle *pg_result;
int i, num_fields, pgsql_row, use_row;
@@ -1886,7 +1886,7 @@
char *class_name;
int class_name_len;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|lsz, 
result, row, class_name, class_name_len, ctor_params) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|z!sz, 
result, zrow, class_name, class_name_len, ctor_params) == FAILURE) {
return;
}
if (ZEND_NUM_ARGS()  3) {
@@ -1900,10 +1900,16 @@
}
result_type = PGSQL_ASSOC;
} else {
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|ll, 
result, row, result_type) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|z!l, 
result, zrow, result_type) == FAILURE) {
return;
}
}
+   if (zrow == NULL) {
+   row = -1;
+   } else {
+   convert_to_long(zrow);
+   row = Z_LVAL_P(zrow);
+   }
use_row = ZEND_NUM_ARGS()  1  row != -1;
 
if (!(result_type  PGSQL_BOTH)) {

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



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

2005-10-11 Thread Ilia Alshanetsky
iliaa   Tue Oct 11 12:18:45 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #33167 (Possible crash inside pg_fetch_array()).
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.332r2=1.333ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.332 php-src/ext/pgsql/pgsql.c:1.333
--- php-src/ext/pgsql/pgsql.c:1.332 Fri Aug 12 10:08:23 2005
+++ php-src/ext/pgsql/pgsql.c   Tue Oct 11 12:18:40 2005
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.332 2005/08/12 14:08:23 sebastian Exp $ */
+/* $Id: pgsql.c,v 1.333 2005/10/11 16:18:40 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -1872,11 +1872,11 @@
 /* {{{ void php_pgsql_fetch_hash */
 static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, long 
result_type, int into_object)
 {
-   zval*result, *zrow;
+   zval*result;
PGresult*pgsql_result;
pgsql_result_handle *pg_result;
int i, num_fields, pgsql_row, use_row;
-   longrow;
+   longrow = -1;
char*element, *field_name;
uintelement_len;
zval*ctor_params = NULL;
@@ -1886,9 +1886,9 @@
char *class_name;
int class_name_len;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|zsz, 
result, zrow, class_name, class_name_len, ctor_params) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|lsz, 
result, row, class_name, class_name_len, ctor_params) == FAILURE) {
return;
-   }
+   }
if (ZEND_NUM_ARGS()  3) {
ce = zend_standard_class_def;
} else {
@@ -1900,15 +1900,11 @@
}
result_type = PGSQL_ASSOC;
} else {
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|zl, 
result, zrow, result_type) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r|ll, 
result, row, result_type) == FAILURE) {
return;
}
}
-   use_row = ZEND_NUM_ARGS()  1  Z_TYPE_P(zrow) != IS_NULL;
-   if (use_row) {
-   convert_to_long_ex(zrow);
-   row = Z_LVAL_P(zrow);
-   }
+   use_row = ZEND_NUM_ARGS()  1  row != -1;
 
if (!(result_type  PGSQL_BOTH)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid result 
type);

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



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

2005-07-05 Thread Edin Kadribasic
edink   Tue Jul  5 10:49:23 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Properly detect when the copy command fails
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.328r2=1.329ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.328 php-src/ext/pgsql/pgsql.c:1.329
--- php-src/ext/pgsql/pgsql.c:1.328 Tue Jul  5 08:45:39 2005
+++ php-src/ext/pgsql/pgsql.c   Tue Jul  5 10:49:22 2005
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.328 2005/07/05 12:45:39 derick Exp $ */
+/* $Id: pgsql.c,v 1.329 2005/07/05 14:49:22 edink Exp $ */
 
 #include stdlib.h
 
@@ -3327,6 +3327,7 @@
switch (status) {
case PGRES_COPY_IN:
if (pgsql_result) {
+   int command_failed = 0;
PQclear(pgsql_result);

zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(pg_rows), pos);
 #if HAVE_PQPUTCOPYDATA
@@ -3373,8 +3374,15 @@
}
 #endif
while ((pgsql_result = PQgetResult(pgsql))) {
+   if (PGRES_COMMAND_OK != 
PQresultStatus(pgsql_result)) {
+   PHP_PQ_ERROR(Copy command 
failed: %s, pgsql);
+   command_failed = 1;
+   }
PQclear(pgsql_result);
}
+   if (command_failed) {
+   RETURN_FALSE;
+   }
} else {
PQclear(pgsql_result);
RETURN_FALSE;

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



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

2005-05-10 Thread Antony Dovgal
tony2001Tue May 10 16:13:26 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  fix #32904 (pg_get_notify() ignores result_type parameter)
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.325r2=1.326ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.325 php-src/ext/pgsql/pgsql.c:1.326
--- php-src/ext/pgsql/pgsql.c:1.325 Tue May  3 18:50:00 2005
+++ php-src/ext/pgsql/pgsql.c   Tue May 10 16:13:24 2005
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.325 2005/05/03 22:50:00 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.326 2005/05/10 20:13:24 tony2001 Exp $ */
 
 #include stdlib.h
 
@@ -4144,11 +4144,11 @@
RETURN_FALSE;
}
array_init(return_value);
-   if (result_type  (PGSQL_NUM|PGSQL_BOTH)) {
+   if (result_type == PGSQL_NUM || result_type == PGSQL_BOTH) {
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 || result_type == PGSQL_BOTH) {
add_assoc_string(return_value, message, 
pgsql_notify-relname, 1);
add_assoc_long(return_value, pid, pgsql_notify-be_pid);
}

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



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

2005-05-10 Thread Andi Gutmans
So why not just do:
+   if (result_type  PGSQL_NUM) {
+   if (result_type PGSQL_ASSOC) {
Why do you need to reference PGSQL_BOTH? I might be missing something 
(didn't look at the .c file) but it seems strange.

Andi
At 08:13 PM 5/10/2005 +, Antony Dovgal wrote:
tony2001Tue May 10 16:13:26 2005 EDT
  Modified files:
/php-src/ext/pgsql  pgsql.c
  Log:
  fix #32904 (pg_get_notify() ignores result_type parameter)
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.325r2=1.326ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.325 php-src/ext/pgsql/pgsql.c:1.326
--- php-src/ext/pgsql/pgsql.c:1.325 Tue May  3 18:50:00 2005
+++ php-src/ext/pgsql/pgsql.c   Tue May 10 16:13:24 2005
@@ -20,7 +20,7 @@
+--+
  */
-/* $Id: pgsql.c,v 1.325 2005/05/03 22:50:00 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.326 2005/05/10 20:13:24 tony2001 Exp $ */
 #include stdlib.h
@@ -4144,11 +4144,11 @@
RETURN_FALSE;
}
array_init(return_value);
-   if (result_type  (PGSQL_NUM|PGSQL_BOTH)) {
+   if (result_type == PGSQL_NUM || result_type == PGSQL_BOTH) {
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 || result_type == PGSQL_BOTH) {
add_assoc_string(return_value, message, 
pgsql_notify-relname, 1);
add_assoc_long(return_value, pid, pgsql_notify-be_pid);
}

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


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

2005-05-10 Thread Antony Dovgal
On Tue, 10 May 2005 15:34:10 -0700
Andi Gutmans [EMAIL PROTECTED] wrote:

 So why not just do:
 +   if (result_type  PGSQL_NUM) {
 +   if (result_type PGSQL_ASSOC) {
 
 Why do you need to reference PGSQL_BOTH? I might be missing something 
 (didn't look at the .c file) but it seems strange.

Then I'll probably need to a check for result_type to be only PGSQL_NUM, 
PGSQL_ASSOC, PGSQL_BOTH.
No ?

-- 
Wbr, 
Antony Dovgal aka tony2001
[EMAIL PROTECTED]

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



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

2005-05-10 Thread Antony Dovgal
tony2001Tue May 10 19:12:33 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  use  and check for the right value of result_type
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.326r2=1.327ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.326 php-src/ext/pgsql/pgsql.c:1.327
--- php-src/ext/pgsql/pgsql.c:1.326 Tue May 10 16:13:24 2005
+++ php-src/ext/pgsql/pgsql.c   Tue May 10 19:12:31 2005
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.326 2005/05/10 20:13:24 tony2001 Exp $ */
+/* $Id: pgsql.c,v 1.327 2005/05/10 23:12:31 tony2001 Exp $ */
 
 #include stdlib.h
 
@@ -4137,6 +4137,11 @@
 
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);
if (!pgsql_notify) {
@@ -4144,11 +4149,11 @@
RETURN_FALSE;
}
array_init(return_value);
-   if (result_type == PGSQL_NUM || result_type == 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 || result_type == 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);
}

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



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

2005-05-05 Thread Jani Taskinen
 MFH? (to both PHP_4_3 and PHP_5_0)
 --Jani
On Tue, 3 May 2005, Ilia Alshanetsky wrote:
iliaa   Tue May  3 18:50:02 2005 EDT
 Modified files:
   /php-src/ext/pgsql   pgsql.c
 Log:
 Prevent double free.
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.324r2=1.325ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.324 php-src/ext/pgsql/pgsql.c:1.325
--- php-src/ext/pgsql/pgsql.c:1.324 Wed Apr 13 18:11:35 2005
+++ php-src/ext/pgsql/pgsql.c   Tue May  3 18:50:00 2005
@@ -20,7 +20,7 @@
   +--+
 */
-/* $Id: pgsql.c,v 1.324 2005/04/13 22:11:35 tony2001 Exp $ */
+/* $Id: pgsql.c,v 1.325 2005/05/03 22:50:00 iliaa Exp $ */
#include stdlib.h
@@ -356,8 +356,11 @@
static void _php_pgsql_notice_ptr_dtor(void **ptr)
{
php_pgsql_notice *notice = (php_pgsql_notice *)*ptr;
-   efree(notice-message);
-   efree(notice);
+   if (notice) {
+   efree(notice-message);
+   efree(notice);
+   notice = NULL;
+   }
}
/* }}} */

--
Donate @ http://pecl.php.net/wishlist.php/sniper
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-CVS] cvs: php-src /ext/pgsql pgsql.c php_pgsql.h

2005-04-13 Thread Derick Rethans
derick  Wed Apr 13 17:48:33 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c php_pgsql.h 
  Log:
  - MFH43: Fixed bug #32699 (pg_affected_rows() was defined when it was not
available).
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.322r2=1.323ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.322 php-src/ext/pgsql/pgsql.c:1.323
--- php-src/ext/pgsql/pgsql.c:1.322 Fri Mar 25 01:26:30 2005
+++ php-src/ext/pgsql/pgsql.c   Wed Apr 13 17:48:33 2005
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.322 2005/03/25 06:26:30 chriskl Exp $ */
+/* $Id: pgsql.c,v 1.323 2005/04/13 21:48:33 derick Exp $ */
 
 #include stdlib.h
 
@@ -127,7 +127,9 @@
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)
@@ -1586,6 +1588,7 @@
 }
 /* }}} */
 
+#if HAVE_PQCMDTUPLES
 /* {{{ proto int pg_affected_rows(resource result)
Returns the number of affected tuples */
 PHP_FUNCTION(pg_affected_rows)
@@ -1593,6 +1596,7 @@

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 */
http://cvs.php.net/diff.php/php-src/ext/pgsql/php_pgsql.h?r1=1.70r2=1.71ty=u
Index: php-src/ext/pgsql/php_pgsql.h
diff -u php-src/ext/pgsql/php_pgsql.h:1.70 php-src/ext/pgsql/php_pgsql.h:1.71
--- php-src/ext/pgsql/php_pgsql.h:1.70  Tue Mar 22 03:51:22 2005
+++ php-src/ext/pgsql/php_pgsql.h   Wed Apr 13 17:48:33 2005
@@ -17,7 +17,7 @@
+--+
  */
  
-/* $Id: php_pgsql.h,v 1.70 2005/03/22 08:51:22 chriskl Exp $ */
+/* $Id: php_pgsql.h,v 1.71 2005/04/13 21:48:33 derick Exp $ */
 
 #ifndef PHP_PGSQL_H
 #define PHP_PGSQL_H
@@ -107,7 +107,9 @@
 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);

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



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

2005-04-13 Thread Antony Dovgal
tony2001Wed Apr 13 18:11:39 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  disable pg_cmdtuples() too, if there is no pg_affected_rows()
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.323r2=1.324ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.323 php-src/ext/pgsql/pgsql.c:1.324
--- php-src/ext/pgsql/pgsql.c:1.323 Wed Apr 13 17:48:33 2005
+++ php-src/ext/pgsql/pgsql.c   Wed Apr 13 18:11:35 2005
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.323 2005/04/13 21:48:33 derick Exp $ */
+/* $Id: pgsql.c,v 1.324 2005/04/13 22:11:35 tony2001 Exp $ */
 
 #include stdlib.h
 
@@ -197,7 +197,9 @@
/* 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)

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



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

2005-03-24 Thread Ilia Alshanetsky
iliaa   Thu Mar 24 19:30:44 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Slightly safer code.
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.320r2=1.321ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.320 php-src/ext/pgsql/pgsql.c:1.321
--- php-src/ext/pgsql/pgsql.c:1.320 Tue Mar 22 03:51:21 2005
+++ php-src/ext/pgsql/pgsql.c   Thu Mar 24 19:30:43 2005
@@ -20,7 +20,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.320 2005/03/22 08:51:21 chriskl Exp $ */
+/* $Id: pgsql.c,v 1.321 2005/03/25 00:30:43 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -5164,7 +5164,7 @@
smart_str_append_long(querystr, 
Z_LVAL_PP(val));
break;
case IS_DOUBLE:
-   smart_str_appendl(querystr, buf, sprintf(buf, 
%f, Z_DVAL_PP(val)));
+   smart_str_appendl(querystr, buf, snprintf(buf, 
sizeof(buf), %f, Z_DVAL_PP(val)));
break;
default:
/* should not happen */

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



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

2005-03-19 Thread Christopher Kings-Lynne
chriskl Sat Mar 19 04:07:21 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Minor oversight in #if for an internal function
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.315r2=1.316ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.315 php-src/ext/pgsql/pgsql.c:1.316
--- php-src/ext/pgsql/pgsql.c:1.315 Sat Mar 19 03:46:55 2005
+++ php-src/ext/pgsql/pgsql.c   Sat Mar 19 04:07:20 2005
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.315 2005/03/19 08:46:55 chriskl Exp $ */
+/* $Id: pgsql.c,v 1.316 2005/03/19 09:07:20 chriskl Exp $ */
 
 #include stdlib.h
 
@@ -1144,7 +1144,7 @@
 }
 /* }}} */
 
-#if HAVE_PQEXECPARAMS || HAVE_PQEXECPREPARED
+#if HAVE_PQEXECPARAMS || HAVE_PQEXECPREPARED || HAVE_PQSENDQUERYPARAMS || 
HAVE_PQSENDQUERYPREPARED
 /* {{{ _php_pgsql_free_params */
 static void _php_pgsql_free_params(char **params, int num_params)
 {

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



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

2005-03-19 Thread Christopher Kings-Lynne
chriskl Sat Mar 19 04:21:51 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Another oversight - make sure constants related to pg_result_error_field are 
#if'd as well as the function itself
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.316r2=1.317ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.316 php-src/ext/pgsql/pgsql.c:1.317
--- php-src/ext/pgsql/pgsql.c:1.316 Sat Mar 19 04:07:20 2005
+++ php-src/ext/pgsql/pgsql.c   Sat Mar 19 04:21:51 2005
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.316 2005/03/19 09:07:20 chriskl Exp $ */
+/* $Id: pgsql.c,v 1.317 2005/03/19 09:21:51 chriskl Exp $ */
 
 #include stdlib.h
 
@@ -483,6 +483,7 @@
REGISTER_LONG_CONSTANT(PGSQL_BAD_RESPONSE, PGRES_BAD_RESPONSE, 
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(PGSQL_NONFATAL_ERROR, PGRES_NONFATAL_ERROR, 
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(PGSQL_FATAL_ERROR, PGRES_FATAL_ERROR, CONST_CS 
| CONST_PERSISTENT);
+#if HAVE_PQRESULTERRORFIELD
/* For pg_result_error_field() field codes */
REGISTER_LONG_CONSTANT(PGSQL_DIAG_SEVERITY, PG_DIAG_SEVERITY, 
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(PGSQL_DIAG_SQLSTATE, PG_DIAG_SQLSTATE, 
CONST_CS | CONST_PERSISTENT);
@@ -496,6 +497,7 @@
REGISTER_LONG_CONSTANT(PGSQL_DIAG_SOURCE_FILE, PG_DIAG_SOURCE_FILE, 
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(PGSQL_DIAG_SOURCE_LINE, PG_DIAG_SOURCE_LINE, 
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(PGSQL_DIAG_SOURCE_FUNCTION, 
PG_DIAG_SOURCE_FUNCTION, CONST_CS | CONST_PERSISTENT);
+#endif
/* pg_convert options */
REGISTER_LONG_CONSTANT(PGSQL_CONV_IGNORE_DEFAULT, 
PGSQL_CONV_IGNORE_DEFAULT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(PGSQL_CONV_FORCE_NULL, PGSQL_CONV_FORCE_NULL, 
CONST_CS | CONST_PERSISTENT);

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



[PHP-CVS] cvs: php-src /ext/pgsql pgsql.c /ext/pgsql/tests 03sync_query.phpt

2005-03-19 Thread Christopher Kings-Lynne
chriskl Sat Mar 19 21:46:03 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
/php-src/ext/pgsql/tests03sync_query.phpt 
  Log:
  Two of the diagnostic definitions were added in 8.0.  Add appropriate #ifdefs.
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.317r2=1.318ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.317 php-src/ext/pgsql/pgsql.c:1.318
--- php-src/ext/pgsql/pgsql.c:1.317 Sat Mar 19 04:21:51 2005
+++ php-src/ext/pgsql/pgsql.c   Sat Mar 19 21:46:01 2005
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.317 2005/03/19 09:21:51 chriskl Exp $ */
+/* $Id: pgsql.c,v 1.318 2005/03/20 02:46:01 chriskl Exp $ */
 
 #include stdlib.h
 
@@ -491,8 +491,12 @@
REGISTER_LONG_CONSTANT(PGSQL_DIAG_MESSAGE_DETAIL, 
PG_DIAG_MESSAGE_DETAIL, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(PGSQL_DIAG_MESSAGE_HINT, PG_DIAG_MESSAGE_HINT, 
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(PGSQL_DIAG_STATEMENT_POSITION, 
PG_DIAG_STATEMENT_POSITION, CONST_CS | CONST_PERSISTENT);
+#ifdef PG_DIAG_INTERNAL_POSITION
REGISTER_LONG_CONSTANT(PGSQL_DIAG_INTERNAL_POSITION, 
PG_DIAG_INTERNAL_POSITION, CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef PG_DIAG_INTERNAL_QUERY
REGISTER_LONG_CONSTANT(PGSQL_DIAG_INTERNAL_QUERY, 
PG_DIAG_INTERNAL_QUERY, CONST_CS | CONST_PERSISTENT);
+#endif
REGISTER_LONG_CONSTANT(PGSQL_DIAG_CONTEXT, PG_DIAG_CONTEXT, CONST_CS 
| CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(PGSQL_DIAG_SOURCE_FILE, PG_DIAG_SOURCE_FILE, 
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT(PGSQL_DIAG_SOURCE_LINE, PG_DIAG_SOURCE_LINE, 
CONST_CS | CONST_PERSISTENT);
@@ -3484,8 +3488,11 @@
RETURN_FALSE;
}
if (fieldcode  
(PG_DIAG_SEVERITY|PG_DIAG_SQLSTATE|PG_DIAG_MESSAGE_PRIMARY|PG_DIAG_MESSAGE_DETAIL
-   
|PG_DIAG_MESSAGE_HINT|PG_DIAG_STATEMENT_POSITION|PG_DIAG_INTERNAL_POSITION
-   
|PG_DIAG_INTERNAL_QUERY|PG_DIAG_CONTEXT|PG_DIAG_SOURCE_FILE|PG_DIAG_SOURCE_LINE
+   |PG_DIAG_MESSAGE_HINT|PG_DIAG_STATEMENT_POSITION
+#ifdef PG_DIAG_INTERNAL_POSITION  PG_DIAG_INTERNAL_QUERY
+   
|PG_DIAG_INTERNAL_POSITION|PG_DIAG_INTERNAL_QUERY
+#endif
+   
|PG_DIAG_CONTEXT|PG_DIAG_SOURCE_FILE|PG_DIAG_SOURCE_LINE
|PG_DIAG_SOURCE_FUNCTION)) {
field = (char *)PQresultErrorField(pgsql_result, fieldcode);
if (field == NULL) {
http://cvs.php.net/diff.php/php-src/ext/pgsql/tests/03sync_query.phpt?r1=1.4r2=1.5ty=u
Index: php-src/ext/pgsql/tests/03sync_query.phpt
diff -u php-src/ext/pgsql/tests/03sync_query.phpt:1.4 
php-src/ext/pgsql/tests/03sync_query.phpt:1.5
--- php-src/ext/pgsql/tests/03sync_query.phpt:1.4   Sat Mar 19 04:20:52 2005
+++ php-src/ext/pgsql/tests/03sync_query.phpt   Sat Mar 19 21:46:02 2005
@@ -38,8 +38,14 @@
 pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL);
 pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT);
 pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION);
-pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION);
-pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY);
+if (defined('PGSQL_DIAG_INTERNAL_POSITION'))
+{
+   pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION);
+}
+if (defined('PGSQL_DIAG_INTERNAL_QUERY'))
+{
+   pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY);
+}
 pg_result_error_field($result, PGSQL_DIAG_CONTEXT);
 pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE);
 pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE);

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



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

2005-03-19 Thread Jani Taskinen
sniper  Sat Mar 19 21:57:12 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  - Fixed a warning (might also be an error with some exotic compiler)
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.318r2=1.319ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.318 php-src/ext/pgsql/pgsql.c:1.319
--- php-src/ext/pgsql/pgsql.c:1.318 Sat Mar 19 21:46:01 2005
+++ php-src/ext/pgsql/pgsql.c   Sat Mar 19 21:57:10 2005
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.318 2005/03/20 02:46:01 chriskl Exp $ */
+/* $Id: pgsql.c,v 1.319 2005/03/20 02:57:10 sniper Exp $ */
 
 #include stdlib.h
 
@@ -3489,7 +3489,7 @@
}
if (fieldcode  
(PG_DIAG_SEVERITY|PG_DIAG_SQLSTATE|PG_DIAG_MESSAGE_PRIMARY|PG_DIAG_MESSAGE_DETAIL
|PG_DIAG_MESSAGE_HINT|PG_DIAG_STATEMENT_POSITION
-#ifdef PG_DIAG_INTERNAL_POSITION  PG_DIAG_INTERNAL_QUERY
+#if defined(PG_DIAG_INTERNAL_POSITION)  defined(PG_DIAG_INTERNAL_QUERY)

|PG_DIAG_INTERNAL_POSITION|PG_DIAG_INTERNAL_QUERY
 #endif

|PG_DIAG_CONTEXT|PG_DIAG_SOURCE_FILE|PG_DIAG_SOURCE_LINE

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



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

2005-02-14 Thread Edin Kadribasic
edink   Mon Feb 14 18:40:25 2005 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  ws fix
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.313r2=1.314ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.313 php-src/ext/pgsql/pgsql.c:1.314
--- php-src/ext/pgsql/pgsql.c:1.313 Mon Feb 14 18:36:16 2005
+++ php-src/ext/pgsql/pgsql.c   Mon Feb 14 18:40:24 2005
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.313 2005/02/14 23:36:16 edink Exp $ */
+/* $Id: pgsql.c,v 1.314 2005/02/14 23:40:24 edink Exp $ */
 
 #include stdlib.h
 
@@ -1346,7 +1346,7 @@
Returns the type oid for the given field */
 PHP_FUNCTION(pg_field_type_oid)
 {
-
php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_FIELD_TYPE_OID);
+   
php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_FIELD_TYPE_OID);
 }
 /* }}} */
 

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



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

2004-05-12 Thread Ilia Alshanetsky
iliaa   Wed May 12 12:49:47 2004 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #28374 (Possible unterminated loop inside 
  _php_pgsql_trim_message()).
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.310r2=1.311ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.310 php-src/ext/pgsql/pgsql.c:1.311
--- php-src/ext/pgsql/pgsql.c:1.310 Wed Apr 21 20:31:55 2004
+++ php-src/ext/pgsql/pgsql.c   Wed May 12 12:49:47 2004
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.310 2004/04/22 00:31:55 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.311 2004/05/12 16:49:47 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -227,7 +227,7 @@
if (i1  (message[i-1] == '\r' || message[i-1] == '\n')  message[i] == 
'.') {
--i;
}
-   while (i  (message[i] == '\r' || message[i] == '\n')) {
+   while (i0  (message[i] == '\r' || message[i] == '\n')) {
--i;
}
++i;

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



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

2004-04-21 Thread Ilia Alshanetsky
iliaa   Wed Apr 21 20:31:57 2004 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed possible crash inside pg_copy_(to|from) function if delimiter is more
  then 1 character long.
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.309r2=1.310ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.309 php-src/ext/pgsql/pgsql.c:1.310
--- php-src/ext/pgsql/pgsql.c:1.309 Wed Mar 17 20:34:58 2004
+++ php-src/ext/pgsql/pgsql.c   Wed Apr 21 20:31:55 2004
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.309 2004/03/18 01:34:58 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.310 2004/04/22 00:31:55 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -2658,8 +2658,8 @@
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL link, 
le_link, le_plink);
 
query = (char *)emalloc(strlen(query_template) + strlen(table_name) + 
strlen(pg_null_as) + 1);
-   sprintf(query, COPY \%s\ TO STDOUT DELIMITERS '%s' WITH NULL AS '%s',
-   table_name, pg_delim, pg_null_as);
+   sprintf(query, COPY \%s\ TO STDOUT DELIMITERS '%c' WITH NULL AS '%s',
+   table_name, *pg_delim, pg_null_as);
 
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
@@ -2768,8 +2768,8 @@
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL link, 
le_link, le_plink);
 
query = (char *)emalloc(strlen(query_template) + strlen(table_name) + 
strlen(pg_null_as) + 1);
-   sprintf(query, COPY \%s\ FROM STDIN DELIMITERS '%s' WITH NULL AS '%s',
-   table_name, pg_delim, pg_null_as);
+   sprintf(query, COPY \%s\ FROM STDIN DELIMITERS '%c' WITH NULL AS '%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 /ext/pgsql pgsql.c

2004-03-17 Thread Ilia Alshanetsky
iliaa   Wed Mar 17 20:34:59 2004 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #27300 (Improved regex for pg_convert()).
  
  # Patch by benjcarson at digitaljunkies dot ca
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.308r2=1.309ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.308 php-src/ext/pgsql/pgsql.c:1.309
--- php-src/ext/pgsql/pgsql.c:1.308 Mon Mar 15 15:16:52 2004
+++ php-src/ext/pgsql/pgsql.c   Wed Mar 17 20:34:58 2004
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.308 2004/03/15 20:16:52 helly Exp $ */
+/* $Id: pgsql.c,v 1.309 2004/03/18 01:34:58 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -3998,16 +3998,63 @@
ZVAL_STRING(new_val, NULL, 
1);
}
else {
-   /* FIXME: better regex must be 
used */
-   if 
(php_pgsql_convert_match(Z_STRVAL_PP(val), ^[+-]{0,1}[ 
\\t]+((second|seconds|minute|minute|hour|hour|day|days|week|weeks|month|monthes|year|years|decade|decades|century|centuries|millennium|millenniums){1,1}[
 \\t]+)+([ \\t]+ago){0,1}$, 1 TSRMLS_CC) == FAILURE 
-   
php_pgsql_convert_match(Z_STRVAL_PP(val), [EMAIL PROTECTED] \\t]+[+-]{0,1}[ 
\\t]+(second|seconds|minute|minute|hour|hour|day|days|week|weeks|month|monthes|year|years|decade|decades|century|centuries|millennium|millenniums){1,1}[
 \\t]+)+([ \\t]+ago$, 1 TSRMLS_CC) == FAILURE) {
+
+   /* From the Postgres docs:
+
+  interval values can be 
written with the following syntax:
+  [EMAIL PROTECTED] quantity 
unit [quantity unit...] [direction]
+  
+  Where: quantity is a number 
(possibly signed); unit is second, minute, hour,
+  day, week, month, year, 
decade, century, millennium, or abbreviations or
+  plurals of these units 
[note not *all* abbreviations] ; direction can be
+  ago or empty. The at sign 
(@) is optional noise.
+  
+  ...
+  
+  Quantities of days, hours, 
minutes, and seconds can be specified without explicit
+  unit markings. For example, 
'1 12:59:10' is read the same as '1 day 12 hours 59 min 10
+  sec'.
+   */ 
   
+   if 
(php_pgsql_convert_match(Z_STRVAL_PP(val),
+  
 ^(@?[ \\t]+)?(
+  
 
+  
 /* Textual time units and their abbreviations: */
+  
 (([-+]?[ \\t]+)?
+  
 [0-9]+(\\.[0-9]*)?[ \\t]*
+  
 (millenniums|millennia|millennium|mil|mils|
+  
 centuries|century|cent|c|
+  
 decades|decade|dec|decs|
+  
 years|year|y|
+  
 months|month|mon|
+  
 weeks|week|w| 
+  
   

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

2004-01-28 Thread Ilia Alshanetsky
iliaa   Wed Jan 28 21:54:30 2004 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #27007 (missing connection closure when connect fails in pgsql).
  
  
http://cvs.php.net/diff.php/php-src/ext/pgsql/pgsql.c?r1=1.303r2=1.304ty=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.303 php-src/ext/pgsql/pgsql.c:1.304
--- php-src/ext/pgsql/pgsql.c:1.303 Sun Jan 11 16:18:19 2004
+++ php-src/ext/pgsql/pgsql.c   Wed Jan 28 21:54:30 2004
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.303 2004/01/11 21:18:19 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.304 2004/01/29 02:54:30 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -694,6 +694,9 @@
}
if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
PHP_PQ_ERROR(Unable to connect to PostgreSQL server: %s, 
pgsql);
+   if (pgsql) {
+   PQfinish(pgsql);
+   }
goto err;
}
 

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



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

2004-01-11 Thread Ilia Alshanetsky
iliaa   Sun Jan 11 16:18:19 2004 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #26864 (pg_(update|delete) ignore PGSQL_DML_EXEC option).
  
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.302 php-src/ext/pgsql/pgsql.c:1.303
--- php-src/ext/pgsql/pgsql.c:1.302 Thu Jan  8 03:17:09 2004
+++ php-src/ext/pgsql/pgsql.c   Sun Jan 11 16:18:19 2004
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.302 2004/01/08 08:17:09 andi Exp $ */
+/* $Id: pgsql.c,v 1.303 2004/01/11 21:18:19 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -4424,8 +4424,11 @@
smart_str_appendc(querystr, ';');  
smart_str_0(querystr);
 
-   if (do_exec(querystr, PGRES_COMMAND_OK, pg_link, opt TSRMLS_CC) == 0)
+   if ((opt  PGSQL_DML_EXEC)  do_exec(querystr, PGRES_COMMAND_OK, pg_link, 
opt TSRMLS_CC) == 0) {
ret = SUCCESS;
+   } else if (opt  PGSQL_DML_STRING) {
+   ret = SUCCESS;
+   }
 
 cleanup:
if (var_converted) {
@@ -4517,8 +4520,11 @@
smart_str_appendc(querystr, ';');
smart_str_0(querystr);
 
-   if (do_exec(querystr, PGRES_COMMAND_OK, pg_link, opt TSRMLS_CC) == 0)
+   if ((opt  PGSQL_DML_EXEC)  do_exec(querystr, PGRES_COMMAND_OK, pg_link, 
opt TSRMLS_CC) == 0) {
ret = SUCCESS;
+   } else if (opt  PGSQL_DML_STRING) {
+   ret = SUCCESS;
+   }
 
 cleanup:
if (!(opt  PGSQL_DML_NO_CONV)) {

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



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

2003-12-22 Thread Ilia Alshanetsky
iliaa   Mon Dec 22 10:56:52 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Missing bit for bug #26625.
  
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.300 php-src/ext/pgsql/pgsql.c:1.301
--- php-src/ext/pgsql/pgsql.c:1.300 Mon Dec 15 20:00:34 2003
+++ php-src/ext/pgsql/pgsql.c   Mon Dec 22 10:56:51 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.300 2003/12/16 01:00:34 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.301 2003/12/22 15:56:51 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -3772,9 +3772,8 @@
if (Z_STRLEN_PP(val) == 0) {
if (opt  
PGSQL_CONV_FORCE_NULL) {
ZVAL_STRING(new_val, 
NULL, 1);
-   }
-   else {
-   ZVAL_STRING(new_val, 
empty_string, 1);
+   } else {
+   ZVAL_STRING(new_val, 
'', 1);
}
}
else {

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



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

2003-12-15 Thread Ilia Alshanetsky
iliaa   Mon Dec 15 20:00:36 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed Bug #26625 (pg_convert sets NULL incorrectly for character data 
  types).
  
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.299 php-src/ext/pgsql/pgsql.c:1.300
--- php-src/ext/pgsql/pgsql.c:1.299 Sun Dec  7 13:39:09 2003
+++ php-src/ext/pgsql/pgsql.c   Mon Dec 15 20:00:34 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.299 2003/12/07 18:39:09 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.300 2003/12/16 01:00:34 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -3789,8 +3789,8 @@
 #else  
Z_STRVAL_P(new_val) = 
php_addslashes(Z_STRVAL_PP(val), Z_STRLEN_PP(val), Z_STRLEN_P(new_val), 0 TSRMLS_CC);
 #endif
+   php_pgsql_add_quotes(new_val, 
1 TSRMLS_CC);
}
-   php_pgsql_add_quotes(new_val, 1 
TSRMLS_CC);
break;

case IS_LONG:

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



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

2003-12-07 Thread Ilia Alshanetsky
iliaa   Sun Dec  7 13:39:10 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Removed unused variable.
  
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.298 php-src/ext/pgsql/pgsql.c:1.299
--- php-src/ext/pgsql/pgsql.c:1.298 Sat Dec  6 16:36:21 2003
+++ php-src/ext/pgsql/pgsql.c   Sun Dec  7 13:39:09 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.298 2003/12/06 21:36:21 helly Exp $ */
+/* $Id: pgsql.c,v 1.299 2003/12/07 18:39:09 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -537,7 +537,6 @@
smart_str str = {0};
zval **args[5];
int i, connect_type = 0;
-   char *msgbuf;
PGresult *pg_result;
 
if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  5
@@ -1021,7 +1020,6 @@
PGresult *pgsql_result;
ExecStatusType status;
pgsql_result_handle *pg_result;
-   char *msgbuf;
 
switch(ZEND_NUM_ARGS()) {
case 1:
@@ -2545,7 +2543,6 @@
int id = -1;
PGconn *pgsql;
int result = 0;
-   char *msgbuf;
 
switch(ZEND_NUM_ARGS()) {
case 0:
@@ -2586,7 +2583,6 @@
int id = -1;
PGconn *pgsql;
int result = 0;
-   char *msgbuf;
 
switch(ZEND_NUM_ARGS()) {
case 1:
@@ -2640,7 +2636,6 @@
char *csv = (char *)NULL;
int ret;
int argc = ZEND_NUM_ARGS();
-   char *msgbuf;
 
if (zend_parse_parameters(argc TSRMLS_CC, rs|ss,
  pgsql_link, table_name, 
table_name_len,
@@ -2751,7 +2746,6 @@
PGresult *pgsql_result;
ExecStatusType status;
int argc = ZEND_NUM_ARGS();
-   char *msgbuf;
 
if (zend_parse_parameters(argc TSRMLS_CC, rs/a|ss,
  pgsql_link, table_name, 
table_name_len, pg_rows,

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



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

2003-12-06 Thread Marcus Boerger
helly   Sat Dec  6 16:36:22 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  MFB: PHP_PQ_ERROR() change
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.297 php-src/ext/pgsql/pgsql.c:1.298
--- php-src/ext/pgsql/pgsql.c:1.297 Thu Dec  4 20:03:34 2003
+++ php-src/ext/pgsql/pgsql.c   Sat Dec  6 16:36:21 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.297 2003/12/05 01:03:34 edink Exp $ */
+/* $Id: pgsql.c,v 1.298 2003/12/06 21:36:21 helly Exp $ */
 
 #include stdlib.h
 
@@ -219,6 +219,40 @@
 
 ZEND_DECLARE_MODULE_GLOBALS(pgsql);
 
+/* {{{ _php_pgsql_trim_message */
+static char * _php_pgsql_trim_message(const char *message, int *len)
+{
+   register int i = strlen(message)-1;
+
+   if (i1  (message[i-1] == '\r' || message[i-1] == '\n')  message[i] == 
'.') {
+   --i;
+   }
+   while (i  (message[i] == '\r' || message[i] == '\n')) {
+   --i;
+   }
+   ++i;
+   if (len) {
+   *len = i;
+   }
+   return estrndup(message, i);
+}
+/* }}} */
+
+/* {{{ _php_pgsql_trim_result */
+static inline char * _php_pgsql_trim_result(PGconn * pgsql, char **buf)
+{
+   return *buf = _php_pgsql_trim_message(PQerrorMessage(pgsql), NULL);
+}
+/* }}} */
+
+#define PQErrorMessageTrim(pgsql, buf) _php_pgsql_trim_result(pgsql, buf)
+
+#define PHP_PQ_ERROR(text, pgsql) { \
+   char *msgbuf = _php_pgsql_trim_message(PQerrorMessage(pgsql), NULL);\
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, text, msgbuf);  \
+   efree(msgbuf);  \
+} \
+
 /* {{{ php_pgsql_set_default_link
  */
 static void php_pgsql_set_default_link(int id TSRMLS_DC)
@@ -264,34 +298,6 @@
 }
 /* }}} */
 
-/* {{{ _php_pgsql_trim_message */
-static char * _php_pgsql_trim_message(const char *message, int *len)
-{
-   register int i = strlen(message)-1;
-
-   if (i1  (message[i-1] == '\r' || message[i-1] == '\n')  message[i] == 
'.') {
-   --i;
-   }
-   while (i  (message[i] == '\r' || message[i] == '\n')) {
-   --i;
-   }
-   ++i;
-   if (len) {
-   *len = i;
-   }
-   return estrndup(message, i);
-}
-/* }}} */
-
-/* {{{ _php_pgsql_trim_result */
-static inline char * _php_pgsql_trim_result(PGconn * pgsql, char **buf)
-{
-   return *buf = _php_pgsql_trim_message(PQerrorMessage(pgsql), NULL);
-}
-/* }}} */
-
-#define PQErrorMessageTrim(pgsql, buf) _php_pgsql_trim_result(pgsql, buf)
-
 /* {{{ _php_pgsql_notice_handler
  */
 static void _php_pgsql_notice_handler(void *resource_id, const char *message)
@@ -595,9 +601,7 @@
pgsql=PQsetdb(host,port,options,tty,dbname);
}
if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
-Unable to connect to 
PostgreSQL server: %s, PQErrorMessageTrim(pgsql, msgbuf));
-   efree(msgbuf);
+   PHP_PQ_ERROR(Unable to connect to PostgreSQL server: 
%s, pgsql)
if (pgsql) {
PQfinish(pgsql);
}
@@ -690,8 +694,7 @@
pgsql = PQsetdb(host,port,options,tty,dbname);
}
if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to connect 
to PostgreSQL server: %s, PQErrorMessageTrim(pgsql, msgbuf));
-   efree(msgbuf);
+   PHP_PQ_ERROR(Unable to connect to PostgreSQL server: %s, 
pgsql);
goto err;
}
 
@@ -1073,8 +1076,7 @@
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Query failed: 
%s, PQErrorMessageTrim(pgsql, msgbuf));
-   efree(msgbuf);
+   PHP_PQ_ERROR(Query failed: %s, pgsql);
PQclear(pgsql_result);
RETURN_FALSE;
break;
@@ -2568,8 +2570,7 @@
result = PQendcopy(pgsql);
 
if (result!=0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Query failed: %s, 
PQErrorMessageTrim(pgsql, msgbuf));
-   efree(msgbuf);
+   PHP_PQ_ERROR(Query failed: %s, pgsql);
RETURN_FALSE;
}
RETURN_TRUE;
@@ -2614,8 +2615,7 @@
result = PQputline(pgsql, Z_STRVAL_PP(query));
 
if (result==EOF) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Query failed: %s, 
PQErrorMessageTrim(pgsql, msgbuf));
-   efree(msgbuf);

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

2003-09-06 Thread Marcus Boerger
helly   Sat Sep  6 11:30:29 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Bugfix #25404
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.294 php-src/ext/pgsql/pgsql.c:1.295
--- php-src/ext/pgsql/pgsql.c:1.294 Thu Aug 28 19:04:27 2003
+++ php-src/ext/pgsql/pgsql.c   Sat Sep  6 11:30:28 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.294 2003/08/28 23:04:27 helly Exp $ */
+/* $Id: pgsql.c,v 1.295 2003/09/06 15:30:28 helly Exp $ */
 
 #include stdlib.h
 
@@ -351,7 +351,9 @@
 #if HAVE_PGTRANSACTIONSTATUS  HAVE_PQPROTOCOLVERSION
res = PQexec(link,ROLLBACK;);
 #else
-   res = PQexec(link,BEGIN;ROLLBACK;);
+   res = PQexec(link,BEGIN;);
+   PQclear(res);
+   res = PQexec(link,ROLLBACK;);
 #endif
PQclear(res);
PGG(ignore_notices) = orig;

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



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

2003-08-29 Thread Marcus Boerger
helly   Thu Aug 28 19:04:27 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  format string fix and number of arguments
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.293 php-src/ext/pgsql/pgsql.c:1.294
--- php-src/ext/pgsql/pgsql.c:1.293 Thu Aug 28 17:06:44 2003
+++ php-src/ext/pgsql/pgsql.c   Thu Aug 28 19:04:27 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.293 2003/08/28 21:06:44 andrey Exp $ */
+/* $Id: pgsql.c,v 1.294 2003/08/28 23:04:27 helly Exp $ */
 
 #include stdlib.h
 
@@ -576,12 +576,12 @@

if (PGG(max_links)!=-1  PGG(num_links)=PGG(max_links)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
-Cannot create new 
link. Too many open links (%d), PGG(num_links));
+Cannot create new 
link. Too many open links (%ld), PGG(num_links));
goto err;
}
if (PGG(max_persistent)!=-1  
PGG(num_persistent)=PGG(max_persistent)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
-Cannot create new 
link. Too many open persistent links (%d), PGG(num_persistent));
+Cannot create new 
link. Too many open persistent links (%ld), PGG(num_persistent));
goto err;
}
 
@@ -678,7 +678,7 @@
}
}
if (PGG(max_links)!=-1  PGG(num_links)=PGG(max_links)) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot create new 
link. Too many open links (%d), PGG(num_links));
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot create new 
link. Too many open links (%ld), PGG(num_links));
goto err;
}
if (connstring) {
@@ -2312,7 +2312,7 @@
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
  lsr, 
oid_long, file_out, name_len, pgsql_link) == SUCCESS) {
-   php_error_docref(NULL TSRMLS_CC, E_NOTICE,  %s(): Old API is used);
+   php_error_docref(NULL TSRMLS_CC, E_NOTICE, Old API is used);
if (oid_long = InvalidOid) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, Invalid OID 
specified);
RETURN_FALSE;

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



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

2003-08-14 Thread Ilia Alshanetsky
iliaa   Thu Aug 14 13:49:09 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Fixed bug #25093 (Various leaks due to non-freed queries)
  
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.288 php-src/ext/pgsql/pgsql.c:1.289
--- php-src/ext/pgsql/pgsql.c:1.288 Sun Jul 27 13:44:20 2003
+++ php-src/ext/pgsql/pgsql.c   Thu Aug 14 13:49:08 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.288 2003/07/27 17:44:20 helly Exp $ */
+/* $Id: pgsql.c,v 1.289 2003/08/14 17:49:08 iliaa Exp $ */
 
 #include stdlib.h
 
@@ -1072,6 +1072,7 @@
case PGRES_FATAL_ERROR:
php_error_docref(NULL TSRMLS_CC, E_WARNING, Query failed: 
%s, PQErrorMessageTrim(pgsql, msgbuf));
efree(msgbuf);
+   PQclear(pgsql_result);
RETURN_FALSE;
break;
case PGRES_COMMAND_OK: /* successful command that did not return rows 
*/
@@ -1083,6 +1084,7 @@
pg_result-row = 0;
ZEND_REGISTER_RESOURCE(return_value, pg_result, 
le_result);
} else {
+   PQclear(pgsql_result);
RETURN_FALSE;
}
break;
@@ -1229,6 +1231,7 @@
ret = estrdup(tmp_name);
}
}
+   PQclear(result);
}
 
smart_str_free(str);
@@ -3299,6 +3302,7 @@
name = PQgetvalue(pg_result,i,0);
add_assoc_zval(meta, name, elem);
}
+   PQclear(pg_result);

return SUCCESS;
 }
@@ -4129,6 +4133,7 @@
 
pg_result = PQexec(pg_link, querystr-c);
if (PQresultStatus(pg_result) == expect) {
+   PQclear(pg_result);
return 0;
} else {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, Failed to execute 
'%s', querystr-c);
@@ -4598,9 +4603,9 @@
ret = php_pgsql_result2array(pg_result, ret_array TSRMLS_CC);
} else {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, Failed to execute '%s', 
querystr.c);
-   PQclear(pg_result);
}
-   
+   PQclear(pg_result);
+
 cleanup:
if (!(opt  PGSQL_DML_NO_CONV)) {
zval_dtor(ids_converted);   



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



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

2003-07-27 Thread Marcus Boerger
helly   Sun Jul 27 12:45:10 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  New smart connect/shutdown for persistent connections.
  Behavior for old libs/servers is BEGIN;ROLLBACK; in request shutdown.
  For new libs a RESET ALL; is done in connect and ROLLBACK; is only done 
  where appropriate.
  
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.284 php-src/ext/pgsql/pgsql.c:1.285
--- php-src/ext/pgsql/pgsql.c:1.284 Tue Jul 22 19:05:17 2003
+++ php-src/ext/pgsql/pgsql.c   Sun Jul 27 12:45:10 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.284 2003/07/22 23:05:17 helly Exp $ */
+/* $Id: pgsql.c,v 1.285 2003/07/27 16:45:10 helly Exp $ */
 
 #include stdlib.h
 
@@ -339,11 +339,20 @@
while ((res = PQgetResult(link))) {
PQclear(res);
}
-   orig = PGG(ignore_notices);
-   PGG(ignore_notices) = 1;
-   res = PQexec(link,BEGIN;ROLLBACK;);
-   PQclear(res);
-   PGG(ignore_notices) = orig;
+#if HAVE_PGTRANSACTIONSTATUS  HAVE_PQPROTOCOLVERSION
+   if (PQprotocolVersion(link) = 3  PQtransactionStatus(link) != PQTRANS_IDLE)
+#endif
+   {
+   orig = PGG(ignore_notices);
+   PGG(ignore_notices) = 1;
+#if HAVE_PGTRANSACTIONSTATUS  HAVE_PQPROTOCOLVERSION
+   res = PQexec(link,ROLLBACK;);
+#else
+   res = PQexec(link,BEGIN;ROLLBACK;);
+#endif
+   PQclear(res);
+   PGG(ignore_notices) = orig;
+   }
 
return 0;
 }
@@ -517,6 +526,7 @@
zval **args[5];
int i, connect_type = 0;
char *msgbuf;
+   PGresult *pg_result;
 
if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  5
|| zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == 
FAILURE) {
@@ -625,12 +635,15 @@
goto err;
}
}
+   pgsql = (PGconn *) le-ptr;
+#if HAVE_PQPROTOCOLVERSION  HAVE_PQPARAMETERSTATUS
+   if (PQprotocolVersion(pgsql) = 3  
atof(PQparameterStatus(pgsql, server_version)) = 7.2) {
+#else
if (atof(PG_VERSION) = 7.2) {
-   PGresult *pg_result;
-   pg_result = PQexec(le-ptr, BEGIN;COMMIT;RESET ALL;);
+#endif
+   pg_result = PQexec(pgsql, RESET ALL;);
PQclear(pg_result);
}
-   pgsql = (PGconn *) le-ptr;
}
ZEND_REGISTER_RESOURCE(return_value, pgsql, le_plink);
} else { /* Non persistent connection */
@@ -840,7 +853,7 @@
add_assoc_long(return_value, protocol, 
PQprotocolVersion(pgsql));
 #if HAVE_PQPARAMETERSTATUS
if (PQprotocolVersion(pgsql) = 3) {
-   add_assoc_string(return_value, server, 
PQparameterStatus(pgsql, server_version), 1);
+   add_assoc_string(return_value, server, 
(char*)PQparameterStatus(pgsql, server_version), 1);
}
 #endif
 #endif
@@ -915,19 +928,24 @@
 }
 /* }}} */
 
-/* {{{ proto bool pg_ping(resource connection)
+/* {{{ proto bool pg_ping([resource connection])
Ping database. If connection is bad, try to reconnect. */
 PHP_FUNCTION(pg_ping)
 {
-   zval *pgsql_link = NULL;
-   int id = -1;
+   zval *pgsql_link;
+   int id;
PGconn *pgsql;
PGresult *res;
 
-   if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() 
TSRMLS_CC, r,
-pgsql_link) == 
FAILURE) {
-   RETURN_FALSE;
+   if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() 
TSRMLS_CC, r, pgsql_link) == SUCCESS) {
+   id = -1;
+   } else {
+   pgsql_link = NULL;
+   id = PGG(default_link);
}
+   if (pgsql_link == NULL  id == -1) {
+   RETURN_FALSE;
+   }   
 
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL link, 
le_link, le_plink);
 



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



[PHP-CVS] cvs: php-src /ext/pgsql pgsql.c php_pgsql.h

2003-07-27 Thread Marcus Boerger
helly   Sun Jul 27 12:47:36 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c php_pgsql.h 
  Log:
  Added new function pg_parameter_status()
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.285 php-src/ext/pgsql/pgsql.c:1.286
--- php-src/ext/pgsql/pgsql.c:1.285 Sun Jul 27 12:45:10 2003
+++ php-src/ext/pgsql/pgsql.c   Sun Jul 27 12:47:36 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.285 2003/07/27 16:45:10 helly Exp $ */
+/* $Id: pgsql.c,v 1.286 2003/07/27 16:47:36 helly Exp $ */
 
 #include stdlib.h
 
@@ -90,6 +90,9 @@
PHP_FE(pg_options,  NULL)
PHP_FE(pg_version,  NULL)
PHP_FE(pg_ping, NULL)
+#if HAVE_PQPARAMETERSTATUS
+   PHP_FE(pg_parameter_status, NULL)
+#endif
/* query functions */
PHP_FE(pg_query,NULL)
PHP_FE(pg_send_query,   NULL)
@@ -927,6 +930,41 @@
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_VERSION);
 }
 /* }}} */
+
+#if HAVE_PQPARAMETERSTATUS
+/* {{{ proto string|false pg_parameter_status([resource connection,] string 
param_name)
+   Returns the value of a server parameter */
+PHP_FUNCTION(pg_parameter_status)
+{
+   zval *pgsql_link;
+   int id;
+   PGconn *pgsql;
+   char *param;
+   int len;
+
+   if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() 
TSRMLS_CC, rs, pgsql_link, param, len) == SUCCESS) {
+   id = -1;
+   } else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, param, len) 
== SUCCESS) {
+   pgsql_link = NULL;
+   id = PGG(default_link);
+   } else {
+   RETURN_FALSE;
+   }
+   if (pgsql_link == NULL  id == -1) {
+   RETURN_FALSE;
+   }   
+
+   ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, PostgreSQL link, 
le_link, le_plink);
+
+   param = (char*)PQparameterStatus(pgsql, param);
+   if (param) {
+   RETURN_STRING(param, 1);
+   } else {
+   RETURN_FALSE;
+   }
+}
+/* }}} */
+#endif
 
 /* {{{ proto bool pg_ping([resource connection])
Ping database. If connection is bad, try to reconnect. */
Index: php-src/ext/pgsql/php_pgsql.h
diff -u php-src/ext/pgsql/php_pgsql.h:1.63 php-src/ext/pgsql/php_pgsql.h:1.64
--- php-src/ext/pgsql/php_pgsql.h:1.63  Tue Jul 22 19:05:17 2003
+++ php-src/ext/pgsql/php_pgsql.h   Sun Jul 27 12:47:36 2003
@@ -17,7 +17,7 @@
+--+
  */
  
-/* $Id: php_pgsql.h,v 1.63 2003/07/22 23:05:17 helly Exp $ */
+/* $Id: php_pgsql.h,v 1.64 2003/07/27 16:47:36 helly Exp $ */
 
 #ifndef PHP_PGSQL_H
 #define PHP_PGSQL_H
@@ -73,6 +73,9 @@
 PHP_FUNCTION(pg_options);
 PHP_FUNCTION(pg_version);
 PHP_FUNCTION(pg_ping);
+#if HAVE_PQPARAMETERSTATUS
+PHP_FUNCTION(pg_parameter_status);
+#endif
 /* query functions */
 PHP_FUNCTION(pg_query);
 PHP_FUNCTION(pg_send_query);



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



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

2003-07-27 Thread Marcus Boerger
helly   Sun Jul 27 13:05:56 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  In protocol version  3 we cannot test transaction status and do unconditional 
ROLLBACK;
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.286 php-src/ext/pgsql/pgsql.c:1.287
--- php-src/ext/pgsql/pgsql.c:1.286 Sun Jul 27 12:47:36 2003
+++ php-src/ext/pgsql/pgsql.c   Sun Jul 27 13:05:56 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.286 2003/07/27 16:47:36 helly Exp $ */
+/* $Id: pgsql.c,v 1.287 2003/07/27 17:05:56 helly Exp $ */
 
 #include stdlib.h
 
@@ -343,7 +343,7 @@
PQclear(res);
}
 #if HAVE_PGTRANSACTIONSTATUS  HAVE_PQPROTOCOLVERSION
-   if (PQprotocolVersion(link) = 3  PQtransactionStatus(link) != PQTRANS_IDLE)
+   if ((PQprotocolVersion(link) = 3  PQtransactionStatus(link) != 
PQTRANS_IDLE) || (PQprotocolVersion(link)  3)
 #endif
{
orig = PGG(ignore_notices);



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



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

2003-07-27 Thread Marcus Boerger
helly   Sun Jul 27 13:44:20 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  #damn
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.287 php-src/ext/pgsql/pgsql.c:1.288
--- php-src/ext/pgsql/pgsql.c:1.287 Sun Jul 27 13:05:56 2003
+++ php-src/ext/pgsql/pgsql.c   Sun Jul 27 13:44:20 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.287 2003/07/27 17:05:56 helly Exp $ */
+/* $Id: pgsql.c,v 1.288 2003/07/27 17:44:20 helly Exp $ */
 
 #include stdlib.h
 
@@ -343,7 +343,7 @@
PQclear(res);
}
 #if HAVE_PGTRANSACTIONSTATUS  HAVE_PQPROTOCOLVERSION
-   if ((PQprotocolVersion(link) = 3  PQtransactionStatus(link) != 
PQTRANS_IDLE) || (PQprotocolVersion(link)  3)
+   if ((PQprotocolVersion(link) = 3  PQtransactionStatus(link) != 
PQTRANS_IDLE) || PQprotocolVersion(link)  3)
 #endif
{
orig = PGG(ignore_notices);



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



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

2003-07-22 Thread Jani Taskinen

MFH?

--Jani


On Mon, 21 Jul 2003, Marcus Boerger wrote:

helly  Mon Jul 21 16:53:00 2003 EDT

  Modified files:  
/php-src/ext/pgsql pgsql.c 
  Log:
  Reset vars when reusing a persistent connection as requested from postgres 
 developers
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.280 php-src/ext/pgsql/pgsql.c:1.281
--- php-src/ext/pgsql/pgsql.c:1.280Mon Jul 21 16:49:47 2003
+++ php-src/ext/pgsql/pgsql.c  Mon Jul 21 16:53:00 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.280 2003/07/21 20:49:47 helly Exp $ */
+/* $Id: pgsql.c,v 1.281 2003/07/21 20:53:00 helly Exp $ */
 
 #include stdlib.h
 
@@ -623,6 +623,11 @@
   
 zend_hash_del(EG(persistent_list),str.c,str.len+1);
   goto err;
   }
+  }
+  if (atof(PG_VERSION) = 7.2) {
+  PGresult *pg_result;
+  pg_result = PQexec(le-ptr, RESET ALL);
+  PQclear(pg_result);
   }
   pgsql = (PGconn *) le-ptr;
   }






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



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

2003-07-22 Thread Marcus Brger
Hello Jani,

Tuesday, July 22, 2003, 10:47:37 AM, you wrote:


JT MFH?

No, it seems the request is very old but we need to discuss it a bit further
on the postgres list...

Best regards,
 Marcusmailto:[EMAIL PROTECTED]


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



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

2003-07-22 Thread Marcus Boerger
helly   Tue Jul 22 17:12:32 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Postgres decision on this
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.281 php-src/ext/pgsql/pgsql.c:1.282
--- php-src/ext/pgsql/pgsql.c:1.281 Mon Jul 21 16:53:00 2003
+++ php-src/ext/pgsql/pgsql.c   Tue Jul 22 17:12:32 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.281 2003/07/21 20:53:00 helly Exp $ */
+/* $Id: pgsql.c,v 1.282 2003/07/22 21:12:32 helly Exp $ */
 
 #include stdlib.h
 
@@ -626,7 +626,7 @@
}
if (atof(PG_VERSION) = 7.2) {
PGresult *pg_result;
-   pg_result = PQexec(le-ptr, RESET ALL);
+   pg_result = PQexec(le-ptr, BEGIN;COMMIT;RESET ALL;);
PQclear(pg_result);
}
pgsql = (PGconn *) le-ptr;



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



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

2003-07-22 Thread Marcus Boerger
helly   Tue Jul 22 18:05:46 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  The value might be a null pointer
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.282 php-src/ext/pgsql/pgsql.c:1.283
--- php-src/ext/pgsql/pgsql.c:1.282 Tue Jul 22 17:12:32 2003
+++ php-src/ext/pgsql/pgsql.c   Tue Jul 22 18:05:46 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.282 2003/07/22 21:12:32 helly Exp $ */
+/* $Id: pgsql.c,v 1.283 2003/07/22 22:05:46 helly Exp $ */
 
 #include stdlib.h
 
@@ -834,8 +834,13 @@
default:
RETURN_FALSE;
}
-   Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
-   Z_STRVAL_P(return_value) = (char *) estrdup(Z_STRVAL_P(return_value));
+   if (Z_STRVAL_P(return_value)) {
+   Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value));
+   Z_STRVAL_P(return_value) = (char *) estrdup(Z_STRVAL_P(return_value));
+   } else {
+   Z_STRLEN_P(return_value) = 0;
+   Z_STRVAL_P(return_value) = (char *) estrdup();
+   }
Z_TYPE_P(return_value) = IS_STRING;
 }
 /* }}} */



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



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

2003-07-21 Thread Marcus Boerger
helly   Mon Jul 21 16:49:47 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Go without #24499 hint sneaked in by accident
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.279 php-src/ext/pgsql/pgsql.c:1.280
--- php-src/ext/pgsql/pgsql.c:1.279 Sun Jul 20 12:00:40 2003
+++ php-src/ext/pgsql/pgsql.c   Mon Jul 21 16:49:47 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.279 2003/07/20 16:00:40 helly Exp $ */
+/* $Id: pgsql.c,v 1.280 2003/07/21 20:49:47 helly Exp $ */
 
 #include stdlib.h
 
@@ -1441,10 +1441,7 @@
   must be allowed for compatibility */
php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_ASSOC);
if (Z_TYPE_P(return_value)==IS_ARRAY) {
-   zval tmp = *return_value;
-   return_value-type = IS_NULL;
-   object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, 
Z_ARRVAL(tmp));
-   zval_dtor(tmp);
+   object_and_properties_init(return_value, ZEND_STANDARD_CLASS_DEF_PTR, 
Z_ARRVAL_P(return_value));
} else {
zval_dtor(return_value);
return_value-type = IS_NULL;



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



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

2003-07-21 Thread Marcus Boerger
helly   Mon Jul 21 16:53:00 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Reset vars when reusing a persistent connection as requested from postgres developers
  
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.280 php-src/ext/pgsql/pgsql.c:1.281
--- php-src/ext/pgsql/pgsql.c:1.280 Mon Jul 21 16:49:47 2003
+++ php-src/ext/pgsql/pgsql.c   Mon Jul 21 16:53:00 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.280 2003/07/21 20:49:47 helly Exp $ */
+/* $Id: pgsql.c,v 1.281 2003/07/21 20:53:00 helly Exp $ */
 
 #include stdlib.h
 
@@ -623,6 +623,11 @@

zend_hash_del(EG(persistent_list),str.c,str.len+1);
goto err;
}
+   }
+   if (atof(PG_VERSION) = 7.2) {
+   PGresult *pg_result;
+   pg_result = PQexec(le-ptr, RESET ALL);
+   PQclear(pg_result);
}
pgsql = (PGconn *) le-ptr;
}



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



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

2003-07-20 Thread Marcus Boerger
helly   Sun Jul 20 12:00:40 2003 EDT

  Modified files:  
/php-src/ext/pgsql  pgsql.c 
  Log:
  Use only one line per error message and don't terminate with a dot as everywhere 
else.
  Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.278 php-src/ext/pgsql/pgsql.c:1.279
--- php-src/ext/pgsql/pgsql.c:1.278 Sat Jul 19 15:23:32 2003
+++ php-src/ext/pgsql/pgsql.c   Sun Jul 20 12:00:40 2003
@@ -19,7 +19,7 @@
+--+
  */
  
-/* $Id: pgsql.c,v 1.278 2003/07/19 19:23:32 andrey Exp $ */
+/* $Id: pgsql.c,v 1.279 2003/07/20 16:00:40 helly Exp $ */
 
 #include stdlib.h
 
@@ -71,7 +71,7 @@
 #define PQ_SETNONBLOCKING(pg_link, flag) 0
 #endif
 
-#define CHECK_DEFAULT_LINK(x) if ((x) == -1) { php_error_docref(NULL TSRMLS_CC, 
E_WARNING, No PostgreSQL link opened yet.); }
+#define CHECK_DEFAULT_LINK(x) if ((x) == -1) { php_error_docref(NULL TSRMLS_CC, 
E_WARNING, No PostgreSQL link opened yet); }
 
 /* {{{ pgsql_functions[]
  */
@@ -259,23 +259,44 @@
 }
 /* }}} */
 
+/* {{{ _php_pgsql_trim_message */
+static char * _php_pgsql_trim_message(const char *message, int *len)
+{
+   register int i = strlen(message)-1;
+
+   if (i1  (message[i-1] == '\r' || message[i-1] == '\n')  message[i] == 
'.') {
+   --i;
+   }
+   while (i  (message[i] == '\r' || message[i] == '\n')) {
+   --i;
+   }
+   ++i;
+   if (len) {
+   *len = i;
+   }
+   return estrndup(message, i);
+}
+/* }}} */
+
+/* {{{ _php_pgsql_trim_result */
+static inline char * _php_pgsql_trim_result(PGconn * pgsql, char **buf)
+{
+   return *buf = _php_pgsql_trim_message(PQerrorMessage(pgsql), NULL);
+}
+/* }}} */
+
+#define PQErrorMessageTrim(pgsql, buf) _php_pgsql_trim_result(pgsql, buf)
+
 /* {{{ _php_pgsql_notice_handler
  */
 static void _php_pgsql_notice_handler(void *resource_id, const char *message)
 {
php_pgsql_notice *notice;
-   int i;

TSRMLS_FETCH();
if (! PGG(ignore_notices)) {
notice = (php_pgsql_notice *)emalloc(sizeof(php_pgsql_notice));
-   i = strlen(message)-1;
-   while (i  (message[i] == '\r' || message[i] == '\n')) {
-   i--;
-   }
-   i++;
-   notice-message = estrndup(message, i);
-   notice-len = i;
+   notice-message = _php_pgsql_trim_message(message, notice-len);
if (PGG(log_notices)) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, %s, 
notice-message);
}
@@ -310,7 +331,7 @@
link = (PGconn *) rsrc-ptr;
 
if (PQ_SETNONBLOCKING(link, 0)) {
-   php_error_docref(ref.pgsql TSRMLS_CC, E_NOTICE, Cannot set 
connection to blocking mode.);
+   php_error_docref(ref.pgsql TSRMLS_CC, E_NOTICE, Cannot set 
connection to blocking mode);
return -1;
}

@@ -494,6 +515,7 @@
smart_str str = {0};
zval **args[5];
int i, connect_type = 0;
+   char *msgbuf;
 
if (ZEND_NUM_ARGS()  1 || ZEND_NUM_ARGS()  5
|| zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args) == 
FAILURE) {
@@ -540,12 +562,12 @@

if (PGG(max_links)!=-1  PGG(num_links)=PGG(max_links)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
-Cannot create new 
link. Too many open links (%d)., PGG(num_links));
+Cannot create new 
link. Too many open links (%d), PGG(num_links));
goto err;
}
if (PGG(max_persistent)!=-1  
PGG(num_persistent)=PGG(max_persistent)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING,
-Cannot create new 
link. Too many open persistent links (%d)., PGG(num_persistent));
+Cannot create new 
link. Too many open persistent links (%d), PGG(num_persistent));
goto err;
}
 
@@ -556,8 +578,9 @@
pgsql=PQsetdb(host,port,options,tty,dbname);
}
if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING,
-Unable to connect to 
PostgreSQL server: %s., PQerrorMessage(pgsql));
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, 
+Unable to connect to 
PostgreSQL server: %s,