]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #39971 (pg_insert/pg_update do not allow now() to be used for
authorIlia Alshanetsky <iliaa@php.net>
Fri, 29 Dec 2006 00:35:25 +0000 (00:35 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Fri, 29 Dec 2006 00:35:25 +0000 (00:35 +0000)
timestamp fields).

NEWS
ext/pgsql/pgsql.c

diff --git a/NEWS b/NEWS
index c77a39c2f6aaec1b6162fc74cac6d86b0dbb5bf4..61d12d705818052c60bf08cb6e1143b3c313d4a1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP 4                                                                      NEWS
   indexing the page. (Ilia)
 - Updated PCRE to version 6.7. (Ilia)
 - Fixed missing open_basedir check inside chdir() function. (Ilia)
+- Fixed bug #39971 (pg_insert/pg_update do not allow now() to be used for   
+  timestamp fields). (Ilia)
 - Fixed bug #39890 (using autoconf 2.6x and --with-layout=GNU breaks PEAR 
   install path). (Tony)
 - Fixed bug #39653 (ext/dba doesn't check for db-4.5 and db-4.4 when db4 
index cd2f7df1897ae529f7762b98b3f4b989bd6a8584..996d1abbd4698ce3246dc89ab57b40b5ec6f3181 100644 (file)
@@ -3772,14 +3772,14 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                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);
                                                        }
@@ -3787,7 +3787,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                                break;
                                
                                        case IS_NULL:
-                                               ZVAL_STRING(new_val, "NULL", 1);
+                                               ZVAL_STRINGL(new_val, "NULL", sizeof("NULL")-1, 1);
                                                break;
 
                                        default: