Skip to content

Commit da6b54b

Browse files
impl: Notify statements that have not been executed using errorInfo().
1 parent b5769e6 commit da6b54b

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

ext/pdo_pgsql/pgsql_statement.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ static int pgsql_stmt_get_attr(pdo_stmt_t *stmt, zend_long attr, zval *val)
715715
if(stmt->executed) {
716716
ZVAL_LONG(val, PQresultMemorySize(S->result));
717717
} else {
718+
pdo_pgsql_error_stmt_msg(stmt, 0, "HY000", "statement has not been executed yet");
718719
ZVAL_NULL(val);
719720
}
720721
return 1;

ext/pdo_pgsql/tests/result_memory_size.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ $statement = $db->prepare('select 1');
3535
$result_3 = $statement->getAttribute(PDO::PGSQL_ATTR_RESULT_MEMORY_SIZE);
3636
var_dump($result_3);
3737

38+
echo 'and should emit Error: ';
39+
printf("%s: %d: %s\n", ...$statement->errorInfo());
40+
3841
--EXPECTF--
3942
Result set with only 1 row: int(%d)
4043
Result set with many rows: int(%d)
4144
Large result sets should require more memory than small ones: bool(true)
4245
Statements that are not executed should not consume memory: NULL
46+
and should emit Error: HY000: 0: statement has not been executed yet

0 commit comments

Comments
 (0)