diff options
Diffstat (limited to 'ext/pgsql/pgsql.c')
-rw-r--r-- | ext/pgsql/pgsql.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index c8cf494e3..273bee058 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2009 The PHP Group | + | Copyright (c) 1997-2010 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c 280789 2009-05-19 16:03:36Z kalle $ */ +/* $Id: pgsql.c 293036 2010-01-03 09:23:27Z sebastian $ */ #include <stdlib.h> @@ -819,7 +819,7 @@ static void _php_pgsql_notice_handler(void *resource_id, const char *message) 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 **)¬ice, sizeof(php_pgsql_notice *), NULL); + zend_hash_index_update(&PGG(notices), (ulong)resource_id, (void **)¬ice, sizeof(php_pgsql_notice *), NULL); } } /* }}} */ @@ -1217,13 +1217,14 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent) */ if (!(connect_type & PGSQL_CONNECT_FORCE_NEW) && zend_hash_find(&EG(regular_list),str.c,str.len+1,(void **) &index_ptr)==SUCCESS) { - int type,link; + int type; + ulong link; void *ptr; if (Z_TYPE_P(index_ptr) != le_index_ptr) { RETURN_FALSE; } - link = (int) index_ptr->ptr; + link = (ulong) index_ptr->ptr; ptr = zend_list_find(link,&type); /* check if the link is still there */ if (ptr && (type==le_link || type==le_plink)) { Z_LVAL_P(return_value) = link; @@ -2166,14 +2167,15 @@ PHP_FUNCTION(pg_field_table) if (return_oid) { +#if UINT_MAX > LONG_MAX /* Oid is unsigned int, we don't need this code, where LONG is wider */ 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 { + } else +#endif RETURN_LONG((long)oid); - } } /* try to lookup the table name in the resource list */ @@ -2271,7 +2273,7 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ case PHP_PG_FIELD_TYPE_OID: oid = PQftype(pgsql_result, field); - +#if UINT_MAX > LONG_MAX if (oid > LONG_MAX) { smart_str s = {0}; smart_str_append_unsigned(&s, oid); @@ -2279,7 +2281,9 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ Z_STRVAL_P(return_value) = s.c; Z_STRLEN_P(return_value) = s.len; Z_TYPE_P(return_value) = IS_STRING; - } else { + } else +#endif + { Z_LVAL_P(return_value) = (long)oid; Z_TYPE_P(return_value) = IS_LONG; } @@ -3760,7 +3764,11 @@ PHP_FUNCTION(pg_copy_to) pg_null_as = safe_estrdup("\\\\N"); } - spprintf(&query, 0, "COPY \"%s\" TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as); + if (memchr(table_name, '.', table_name_len)) { + spprintf(&query, 0, "COPY %s TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as); + } else { + spprintf(&query, 0, "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); |