summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-12-29 00:35:25 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-12-29 00:35:25 +0000
commit8351d9c7f3d69c1326b68fa7c6736a3ee1a516dc (patch)
tree7a9531a286d857c2963987365dc504cd860c88a5
parent7637f98be2f0f15f67afc707e9dc04a1dd0e2539 (diff)
downloadphp-git-8351d9c7f3d69c1326b68fa7c6736a3ee1a516dc.tar.gz
MFH: Fixed bug #39971 (pg_insert/pg_update do not allow now() to be used for
timestamp fields).
-rw-r--r--NEWS2
-rw-r--r--ext/pgsql/pgsql.c12
2 files changed, 8 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index c77a39c2f6..61d12d7058 100644
--- 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
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index cd2f7df189..996d1abbd4 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -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: