#27300 [NEW]: pg_convert: interval type regex does not compile
| From: | benjcarson at digitaljunkies dot ca | Date: | Wed, 18 Feb 2004 02:58:15 +0000 |
| Subject: | #27300 [NEW]: pg_convert: interval type regex does not compile | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-55113@lists.php.net to get a copy of this message | ||
From: benjcarson at digitaljunkies dot ca
Operating system: Linux
PHP version: 5CVS-2004-02-17 (dev)
PHP Bug Type: PostgreSQL related
Bug description: pg_convert: interval type regex does not compile
Description:
------------
When trying to call pg_convert for a table with an interval column, php
throws a warning indicating that it can not compile the regex used to
match interval values.
The regex is on line 3999 of ext/pgsql/pgsql.c I think the regex is
missing a ')' as the second last character.
However, this regex also contains other semantic errors and rejects valid
values as well as accepts some bogus ones. I have written a replacement
regex and created a patch, available at
http://www.digitaljunkies.ca/~benj/pgsql.c.diff.txt.
Reproduce code:
---------------
<?php
error_reporting(E_ALL);
$con = pg_connect("dbname=database");
$arr = array("interval_col" => "1 day");
// Presumably tmp_table contains a column 'interval_col' with type
'interval'
$sql = pg_convert($con, "tmp_table", $arr);
print_r($sql);
echo "\n";
exit(0);
?>
Expected result:
----------------
Array
(
[interval_col] => '1 day'
)
Actual result:
--------------
Notice: pg_convert(): '1 day' does not match with '^[+-]{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}$' in pg_convert.php on line 8
Warning: pg_convert(): Cannot compile regex in pg_convert.php on line 8
Notice: pg_convert(): Expects NULL or string for PostgreSQL interval field
(interval_col) in pg_convert.php on line 8
--
Edit bug report at http://bugs.php.net/?id=27300&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27300&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27300&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27300&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27300&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27300&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27300&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27300&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27300&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27300&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27300&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27300&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27300&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27300&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27300&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27300&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27300&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27300&r=float