1--TEST-- 2PDO PgSQL PDOStatement::getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE) 3--EXTENSIONS-- 4pdo_pgsql 5--SKIPIF-- 6<?php 7require __DIR__ . '/config.inc'; 8require dirname(__DIR__, 2) . '/pdo/tests/pdo_test.inc'; 9PDOTest::skip(); 10if (!defined('PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE')) die('skip constant PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE does not exist'); 11--FILE-- 12<?php 13 14require_once __DIR__ . "/config.inc"; 15 16/** @var Pdo */ 17$db = Pdo::connect($config['ENV']['PDOTEST_DSN']); 18 19echo 'Result set with only 1 row: '; 20$statement = $db->query('select 1'); 21$result_1 = $statement->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE); 22var_dump($result_1); 23 24echo 'Result set with many rows: '; 25$result = $db->query('select generate_series(1, 10000)'); 26$result_2 = $result->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE); 27var_dump($result_2); 28 29echo 'Large result sets should require more memory than small ones: '; 30var_dump($result_2 > $result_1); 31 32echo 'Statements that are not executed should not consume memory: '; 33$statement = $db->prepare('select 1'); 34$result_3 = $statement->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE); 35var_dump($result_3); 36 37echo 'and should emit Error: '; 38printf("%s: %d: %s\n", ...$statement->errorInfo()); 39 40--EXPECTF-- 41Result set with only 1 row: int(%d) 42Result set with many rows: int(%d) 43Large result sets should require more memory than small ones: bool(true) 44Statements that are not executed should not consume memory: NULL 45and should emit Error: HY000: 0: statement '%s' has not been executed yet 46