Skip to content

Commit

Permalink
Merge branch 'PHP-8.4'
Browse files Browse the repository at this point in the history
* PHP-8.4:
  ext/pdo_pgsql: Remove new PDO class constant specific to PGSQL driver
  • Loading branch information
Girgias committed Nov 16, 2024
2 parents cfc8361 + 5e360b6 commit 27a1d69
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 0 additions & 3 deletions ext/pdo_pgsql/pdo_pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ PHP_MINIT_FUNCTION(pdo_pgsql)
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INTRANS", (zend_long)PGSQL_TRANSACTION_INTRANS);
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_INERROR", (zend_long)PGSQL_TRANSACTION_INERROR);
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_TRANSACTION_UNKNOWN", (zend_long)PGSQL_TRANSACTION_UNKNOWN);
#ifdef HAVE_PG_RESULT_MEMORY_SIZE
REGISTER_PDO_CLASS_CONST_LONG("PGSQL_ATTR_RESULT_MEMORY_SIZE", (zend_long)PDO_PGSQL_ATTR_RESULT_MEMORY_SIZE);
#endif

PdoPgsql_ce = register_class_Pdo_Pgsql(pdo_dbh_ce);
PdoPgsql_ce->create_object = pdo_dbh_new;
Expand Down
10 changes: 5 additions & 5 deletions ext/pdo_pgsql/tests/result_memory_size.phpt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
--TEST--
PDO PgSQL PDOStatement::getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE)
PDO PgSQL PDOStatement::getAttribute(Pgsql::ATTR_RESULT_MEMORY_SIZE)
--EXTENSIONS--
pdo_pgsql
--SKIPIF--
<?php
require __DIR__ . '/config.inc';
require dirname(__DIR__, 2) . '/pdo/tests/pdo_test.inc';
PDOTest::skip();
if (!defined('PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE')) die('skip constant PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE does not exist');
if (!defined('Pgsql::ATTR_RESULT_MEMORY_SIZE')) die('skip constant Pgsql::ATTR_RESULT_MEMORY_SIZE does not exist');
--FILE--
<?php

Expand All @@ -18,20 +18,20 @@ $db = Pdo::connect($config['ENV']['PDOTEST_DSN']);

echo 'Result set with only 1 row: ';
$statement = $db->query('select 1');
$result_1 = $statement->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE);
$result_1 = $statement->getAttribute(Pgsql::ATTR_RESULT_MEMORY_SIZE);
var_dump($result_1);

echo 'Result set with many rows: ';
$result = $db->query('select generate_series(1, 10000)');
$result_2 = $result->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE);
$result_2 = $result->getAttribute(Pgsql::ATTR_RESULT_MEMORY_SIZE);
var_dump($result_2);

echo 'Large result sets should require more memory than small ones: ';
var_dump($result_2 > $result_1);

echo 'Statements that are not executed should not consume memory: ';
$statement = $db->prepare('select 1');
$result_3 = $statement->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE);
$result_3 = $statement->getAttribute(Pgsql::ATTR_RESULT_MEMORY_SIZE);
var_dump($result_3);

echo 'and should emit Error: ';
Expand Down

0 comments on commit 27a1d69

Please sign in to comment.