php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41144 Possibly incorrect regex for TIME field type in pg_convert (pg_insert)
Submitted: 2007-04-20 05:36 UTC Modified: 2008-11-05 01:00 UTC
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:0 of 1 (0.0%)
From: shade at nekto dot com Assigned:
Status: No Feedback Package: PostgreSQL related
PHP Version: 5.2.1 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: shade at nekto dot com
New email:
PHP Version: OS:

 

 [2007-04-20 05:36 UTC] shade at nekto dot com
Description:
------------
I am trying to insert 14:27 value in the datetime field. I think its correct, cause in PostgreSQL manual descripted following time inputs:

Table 8.11. Time Input
Example | Description 
04:05 | ISO 8601 
040506 | ISO 8601 
.... cutted here....
04:05:06 PST | time zone specified by name 
2003-04-12 04:05:06 America/New_York | time zone specified by full name 

Only 2003-04-12 04:05:06 matches by time regexp in pg_convert.
Here the reported regexp:
'^([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}$'

Its realizes logic 'date and maybe time', but it's not only possible input. Also i confised by [ \t]+ , united with XX:XX part of regexp.
I think that regexp must be like that:
'^(([0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2}){0,1}([ \t]+){0,1}(([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}$'

Expected result:
----------------
Inserted value in database table

Actual result:
--------------
Notice: pg_insert() [function.pg-insert]: '15:04' does not match with '^([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}$' in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\data\index.php on line 226


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-20 05:46 UTC] shade at nekto dot com
Err..
>I am trying to insert 14:27 value in the datetime field.
Really - in TIME field. Here is SQL: "time_from   time with time zone"
 [2008-10-28 22:28 UTC] jani@php.net
yohgaki seems to have left us so de-assigning.
 [2008-10-28 22:28 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2008-11-05 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 10:01:28 2024 UTC