diff options
| author | Ondřej Surý <ondrej@sury.org> | 2012-01-11 15:43:42 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2012-01-11 15:43:42 +0100 |
| commit | 8f1428d29ef91d74b4d272af171675f2971eb15b (patch) | |
| tree | a1f4f4d7dc5bfe8096806dd5c5266634e19fa07a /ext/pgsql/tests | |
| parent | c6e4182351e0173fe58de141e143aac2eacf5efe (diff) | |
| download | php-upstream/5.3.9.tar.gz | |
Imported Upstream version 5.3.9upstream/5.3.9
Diffstat (limited to 'ext/pgsql/tests')
| -rw-r--r-- | ext/pgsql/tests/09notice.phpt | 13 | ||||
| -rwxr-xr-x | ext/pgsql/tests/22pg_fetch_object.phpt | 2 | ||||
| -rwxr-xr-x | ext/pgsql/tests/80_bug32223.phpt | 7 | ||||
| -rwxr-xr-x | ext/pgsql/tests/80_bug32223b.phpt | 7 | ||||
| -rw-r--r-- | ext/pgsql/tests/bug60244.phpt | 57 | ||||
| -rw-r--r-- | ext/pgsql/tests/lcmess.inc | 21 | ||||
| -rw-r--r-- | ext/pgsql/tests/skipif.inc | 1 |
7 files changed, 101 insertions, 7 deletions
diff --git a/ext/pgsql/tests/09notice.phpt b/ext/pgsql/tests/09notice.phpt index b7611b98c..316706916 100644 --- a/ext/pgsql/tests/09notice.phpt +++ b/ext/pgsql/tests/09notice.phpt @@ -1,16 +1,25 @@ --TEST-- PostgreSQL notice function --SKIPIF-- -<?php include("skipif.inc"); ?> +<?php + +include("skipif.inc"); + +_skip_lc_messages(); + +?> --INI-- pgsql.log_notice=1 pgsql.ignore_notices=0 --FILE-- <?php include 'config.inc'; +include 'lcmess.inc'; $db = pg_connect($conn_str); -pg_exec($db, "SET LC_MESSAGES='C';"); + +_set_lc_messages(); + pg_query($db, "BEGIN;"); pg_query($db, "BEGIN;"); diff --git a/ext/pgsql/tests/22pg_fetch_object.phpt b/ext/pgsql/tests/22pg_fetch_object.phpt index 4f2f5dc18..76a3fbeed 100755 --- a/ext/pgsql/tests/22pg_fetch_object.phpt +++ b/ext/pgsql/tests/22pg_fetch_object.phpt @@ -16,7 +16,7 @@ class test_class { $db = pg_connect($conn_str); -$sql = "SELECT * FROM $table_name"; +$sql = "SELECT * FROM $table_name WHERE num = 0"; $result = pg_query($db, $sql) or die('Cannot qeury db'); $rows = pg_num_rows($result); diff --git a/ext/pgsql/tests/80_bug32223.phpt b/ext/pgsql/tests/80_bug32223.phpt index b201d320c..573742c6e 100755 --- a/ext/pgsql/tests/80_bug32223.phpt +++ b/ext/pgsql/tests/80_bug32223.phpt @@ -3,6 +3,8 @@ Bug #32223 (weird behaviour of pg_last_notice) --SKIPIF-- <?php require_once('skipif.inc'); + +_skip_lc_messages(); @pg_query($conn, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'"); $res = @pg_query($conn, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS ' @@ -17,14 +19,15 @@ if (!$res) die('skip PLPGSQL not available'); <?php require_once('config.inc'); +require_once('lcmess.inc'); $dbh = @pg_connect($conn_str); if (!$dbh) { die ("Could not connect to the server"); } -pg_exec($dbh, "SET LC_MESSAGES='C';"); -//@pg_query($dbh, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'"); +_set_lc_messages(); + $res = pg_query($dbh, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS ' begin RAISE NOTICE ''11111''; diff --git a/ext/pgsql/tests/80_bug32223b.phpt b/ext/pgsql/tests/80_bug32223b.phpt index 98e472388..aada3f01b 100755 --- a/ext/pgsql/tests/80_bug32223b.phpt +++ b/ext/pgsql/tests/80_bug32223b.phpt @@ -3,6 +3,8 @@ Bug #32223 (weird behaviour of pg_last_notice using define) --SKIPIF-- <?php require_once('skipif.inc'); + +_skip_lc_messages(); @pg_query($conn, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'"); $res = @pg_query($conn, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS ' @@ -17,14 +19,15 @@ if (!$res) die('skip PLPGSQL not available'); <?php require_once('config.inc'); +require_once('lcmess.inc'); define('dbh', pg_connect($conn_str)); if (!dbh) { die ("Could not connect to the server"); } -pg_exec(dbh, "SET LC_MESSAGES='C';"); -//@pg_query(dbh, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'"); +_set_lc_messages(); + $res = pg_query(dbh, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS ' begin RAISE NOTICE ''11111''; diff --git a/ext/pgsql/tests/bug60244.phpt b/ext/pgsql/tests/bug60244.phpt new file mode 100644 index 000000000..94568b603 --- /dev/null +++ b/ext/pgsql/tests/bug60244.phpt @@ -0,0 +1,57 @@ +--TEST-- +Bug #60244 (pg_fetch_* functions do not validate that row param is >0) +--SKIPIF-- +<?php +include("skipif.inc"); +?> +--FILE-- +<?php + +include 'config.inc'; + +$db = pg_connect($conn_str); +$result = pg_query("select 'a' union select 'b'"); + +var_dump(pg_fetch_array($result, -1)); +var_dump(pg_fetch_assoc($result, -1)); +var_dump(pg_fetch_object($result, -1)); +var_dump(pg_fetch_row($result, -1)); + +var_dump(pg_fetch_array($result, 0)); +var_dump(pg_fetch_assoc($result, 0)); +var_dump(pg_fetch_object($result, 0)); +var_dump(pg_fetch_row($result, 0)); + +pg_close($db); + +?> +--EXPECTF-- +Warning: pg_fetch_array(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d +bool(false) + +Warning: pg_fetch_assoc(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d +bool(false) + +Warning: pg_fetch_object(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d +bool(false) + +Warning: pg_fetch_row(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d +bool(false) +array(2) { + [0]=> + string(1) "a" + ["?column?"]=> + string(1) "a" +} +array(1) { + ["?column?"]=> + string(1) "a" +} +object(stdClass)#1 (1) { + ["?column?"]=> + string(1) "a" +} +array(1) { + [0]=> + string(1) "a" +} diff --git a/ext/pgsql/tests/lcmess.inc b/ext/pgsql/tests/lcmess.inc new file mode 100644 index 000000000..6e0ac25b1 --- /dev/null +++ b/ext/pgsql/tests/lcmess.inc @@ -0,0 +1,21 @@ +<?php + +function _skip_lc_messages($lc_messages = 'C') +{ + if (!_set_lc_messages($lc_messages)) { + die("skip Cannot set LC_MESSAGES to '{$lc_messages}'\n"); + } +} + +function _set_lc_messages($lc_messages = 'C') +{ + if (pg_result(pg_query("SHOW LC_MESSAGES"), 0, 0) != $lc_messages) { + if (!@pg_exec("SET LC_MESSAGES='{$lc_messages}'")) { + return false; + } + } + + return true; +} + +?> diff --git a/ext/pgsql/tests/skipif.inc b/ext/pgsql/tests/skipif.inc index 74b27b3ad..7c5153e6f 100644 --- a/ext/pgsql/tests/skipif.inc +++ b/ext/pgsql/tests/skipif.inc @@ -7,6 +7,7 @@ // database include("config.inc"); +include("lcmess.inc"); if (!extension_loaded("pgsql")) { die("skip\n"); |
