Skip to content

Commit 0706792

Browse files
committed
add test, also makes sense to know which type of tuples we re going to get.
1 parent 72ec12b commit 0706792

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

ext/pgsql/pgsql.stub.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,11 @@
245245
* @cvalue PGRES_TUPLES_OK
246246
*/
247247
const PGSQL_TUPLES_OK = UNKNOWN;
248+
/**
249+
* @var int
250+
* @cvalue PGRES_TUPLES_CHUNK
251+
*/
252+
const PGSQL_TUPLES_CHUNK = UNKNOWN;
248253
/**
249254
* @var int
250255
* @cvalue PGRES_COPY_OUT

ext/pgsql/pgsql_arginfo.h

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
PostgreSQL pg_set_chunked_rows_mode
3+
--EXTENSIONS--
4+
pgsql
5+
--SKIPIF--
6+
<?php
7+
include("inc/skipif.inc");
8+
if (!function_exists("pg_set_chunked_rows_mode")) die("pg_set_chunked_rows_mode unsupported");
9+
?>
10+
--FILE--
11+
<?php
12+
13+
include('inc/config.inc');
14+
$table_name = "test_chunked_rows_mode";
15+
16+
$conn = pg_connect($conn_str);
17+
pg_query($conn, "CREATE TABLE {$table_name} (num int, str text)");
18+
19+
for ($i = 0; $i < 10; $i ++)
20+
pg_query($conn, "INSERT INTO {$table_name} DEFAULT VALUES");
21+
22+
try {
23+
pg_set_chunked_rows_mode($conn, -1);
24+
} catch (\ValueError $e) {
25+
echo $e->getMessage() . PHP_EOL;
26+
}
27+
28+
var_dump(pg_send_query($conn, "SELECT * FROM ".$table_name.";"));
29+
var_dump(pg_set_chunked_rows_mode($conn, 1));
30+
$result = pg_get_result($conn);
31+
var_dump(pg_result_status($result) === PGSQL_TUPLES_CHUNK);
32+
var_dump(pg_num_rows($result));
33+
var_dump(pg_set_chunked_rows_mode($conn, 10));
34+
?>
35+
--CLEAN--
36+
<?php
37+
include('inc/config.inc');
38+
$table_name = "test_chunked_rows_mode";
39+
40+
$conn = pg_connect($conn_str);
41+
pg_query($conn, "DROP TABLE IF EXISTS {$table_name}");
42+
?>
43+
--EXPECF--
44+
pg_set_chunked_rows_mode(): Argument #2 ($size) must be between 1 and %d
45+
bool(true)
46+
int(1)
47+
bool(true)
48+
int(1)
49+
int(0)

0 commit comments

Comments
 (0)