xref: /PHP-8.1/ext/pgsql/tests/bug77047.phpt (revision e378968c)
1--TEST--
2Bug #77047 pg_insert has a broken regex for the 'TIME WITHOUT TIMEZONE' data type
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php
7include("skipif.inc");
8?>
9--FILE--
10<?php
11error_reporting(E_ALL);
12
13include 'config.inc';
14
15$db = pg_connect($conn_str);
16
17pg_query($db, "DROP TABLE IF EXISTS bug77047");
18pg_query($db, "CREATE TABLE bug77047 (
19        t TIME WITHOUT TIME ZONE
20    )");
21
22pg_insert($db, "bug77047", array("t" => "13:31"));
23pg_insert($db, "bug77047", array("t" => "13:31:13"));
24pg_insert($db, "bug77047", array("t" => "1:2:3"));
25pg_insert($db, "bug77047", array("t" => "xyz"));
26pg_insert($db, "bug77047", array("t" => NULL));
27pg_insert($db, "bug77047", array("t" => ""));
28
29$res = pg_query($db, "SELECT t FROM bug77047");
30while (false !== ($row = pg_fetch_row($res))) {
31    var_dump(array_pop($row));
32}
33
34?>
35--EXPECTF--
36Notice: pg_insert(): Expects NULL or string for PostgreSQL time field (t) in %s on line %d
37string(8) "13:31:00"
38string(8) "13:31:13"
39string(8) "01:02:03"
40NULL
41NULL
42
43