Skip to content

Commit 646c0e5

Browse files
willfitchdsp
authored andcommitted
Bug #62593 Updated to always treat zval by value
1 parent f0835c0 commit 646c0e5

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

ext/pdo_pgsql/pgsql_statement.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
367367
if (param->is_param) {
368368
/* We need to manually convert to a pg native boolean value */
369369
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL) {
370-
SEPARATE_ZVAL_IF_NOT_REF(&param->parameter);
370+
SEPARATE_ZVAL(&param->parameter);
371371
param->param_type = PDO_PARAM_STR;
372372
ZVAL_STRINGL(param->parameter, Z_BVAL_P(param->parameter) ? "t" : "f", 1, 1);
373373
}

ext/pdo_pgsql/tests/bug62593.phpt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,22 @@ $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
1515
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
1616
$errors = array();
1717

18+
$value = true;
1819
$query = $db->prepare('SELECT :foo IS FALSE as val_is_false');
19-
$query->bindValue(':foo', true, PDO::PARAM_BOOL);
20+
$query->bindValue(':foo', $value, PDO::PARAM_BOOL);
2021
$query->execute();
2122
$errors[] = $query->errorInfo();
23+
var_dump($value);
2224

2325
$query->bindValue(':foo', 0, PDO::PARAM_BOOL);
2426
$query->execute();
2527
$errors[] = $query->errorInfo();
2628

27-
$query->bindValue(':foo', false, PDO::PARAM_BOOL);
29+
$value = false;
30+
$query->bindParam(':foo', $value, PDO::PARAM_BOOL);
2831
$query->execute();
2932
$errors[] = $query->errorInfo();
33+
var_dump($value);
3034

3135
$expect = 'No errors found';
3236

@@ -40,5 +44,6 @@ foreach ($errors as $error)
4044
echo $expect;
4145
?>
4246
--EXPECTF--
43-
47+
bool(true)
48+
bool(false)
4449
No errors found

0 commit comments

Comments
 (0)