php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27300 [PATCH] pg_convert(): interval type regex does not compile
Submitted: 2004-02-17 21:58 UTC Modified: 2004-03-17 20:27 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: benjcarson at digitaljunkies dot ca Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 4CVS, 5CVS (2004-02-17) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
25 - 16 = ?
Subscribe to this entry?

 
 [2004-02-17 21:58 UTC] benjcarson at digitaljunkies dot ca
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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-13 03:55 UTC] mike at musicplace dot com
These probably all get fixed in the same place, but just in case:

Ditto for pg_insert(), haven't tried pg_delete() or pg_update()...
 [2004-03-17 20:27 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 15:01:29 2024 UTC