summaryrefslogtreecommitdiff
path: root/ext/pdo_pgsql
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-12-10 15:51:17 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-12-10 15:53:23 +0100
commit15b51a215ac08fa72aa6ea44755f7134710f9004 (patch)
tree3d0889e9df957283e4d4d785a68505243f73a3c9 /ext/pdo_pgsql
parentdde5572937e8165abac5fbaa2c4fbb85d7e391b2 (diff)
downloadphp-git-15b51a215ac08fa72aa6ea44755f7134710f9004.tar.gz
Fixed bug #79131
When a driver reports an error during EVT_ALLOC (and some over EVTs), make sure we handle it as usual, i.e. warn or throw. This requires some adjustments in PDO PgSQL to stop manually doing this through an impl error. Unfortunately the PDO PgSQL error messages regress because of this, as they now include a completely arbitrary error code. There doesn't seem to be an ability to skip it right now.
Diffstat (limited to 'ext/pdo_pgsql')
-rw-r--r--ext/pdo_pgsql/pgsql_statement.c6
-rw-r--r--ext/pdo_pgsql/php_pdo_pgsql_int.h3
-rw-r--r--ext/pdo_pgsql/tests/bug36727.phpt2
-rw-r--r--ext/pdo_pgsql/tests/bug69344.phpt2
-rw-r--r--ext/pdo_pgsql/tests/bug71573.phpt2
5 files changed, 9 insertions, 6 deletions
diff --git a/ext/pdo_pgsql/pgsql_statement.c b/ext/pdo_pgsql/pgsql_statement.c
index 88031622a4..149e1e6b51 100644
--- a/ext/pdo_pgsql/pgsql_statement.c
+++ b/ext/pdo_pgsql/pgsql_statement.c
@@ -282,7 +282,8 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
ZEND_ATOL(param->paramno, namevar + 1);
param->paramno--;
} else {
- pdo_raise_impl_error(stmt->dbh, stmt, "HY093", ZSTR_VAL(param->name));
+ pdo_pgsql_error_stmt_msg(
+ stmt, PGRES_FATAL_ERROR, "HY093", ZSTR_VAL(param->name));
return 0;
}
}
@@ -294,7 +295,8 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
return 1;
}
if (!zend_hash_index_exists(stmt->bound_param_map, param->paramno)) {
- pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined");
+ pdo_pgsql_error_stmt_msg(
+ stmt, PGRES_FATAL_ERROR, "HY093", "parameter was not defined");
return 0;
}
case PDO_PARAM_EVT_EXEC_POST:
diff --git a/ext/pdo_pgsql/php_pdo_pgsql_int.h b/ext/pdo_pgsql/php_pdo_pgsql_int.h
index 07dfa8ce27..bc31c9cdee 100644
--- a/ext/pdo_pgsql/php_pdo_pgsql_int.h
+++ b/ext/pdo_pgsql/php_pdo_pgsql_int.h
@@ -79,7 +79,8 @@ extern int _pdo_pgsql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, int errcode, const
#define pdo_pgsql_error(d,e,z) _pdo_pgsql_error(d, NULL, e, z, NULL, __FILE__, __LINE__)
#define pdo_pgsql_error_msg(d,e,m) _pdo_pgsql_error(d, NULL, e, NULL, m, __FILE__, __LINE__)
#define pdo_pgsql_error_stmt(s,e,z) _pdo_pgsql_error(s->dbh, s, e, z, NULL, __FILE__, __LINE__)
-#define pdo_pgsql_error_stmt_msg(s,e,m) _pdo_pgsql_error(s->dbh, s, e, NULL, m, __FILE__, __LINE__)
+#define pdo_pgsql_error_stmt_msg(stmt, e, sqlstate, msg) \
+ _pdo_pgsql_error(stmt->dbh, stmt, e, sqlstate, msg, __FILE__, __LINE__)
extern const struct pdo_stmt_methods pgsql_stmt_methods;
diff --git a/ext/pdo_pgsql/tests/bug36727.phpt b/ext/pdo_pgsql/tests/bug36727.phpt
index e6b5ab7f28..4c9716d141 100644
--- a/ext/pdo_pgsql/tests/bug36727.phpt
+++ b/ext/pdo_pgsql/tests/bug36727.phpt
@@ -19,6 +19,6 @@ var_dump($stmt->bindValue(':test', 1, PDO::PARAM_INT));
echo "Done\n";
?>
--EXPECTF--
-Warning: PDOStatement::bindValue(): SQLSTATE[HY093]: Invalid parameter number: :test in %sbug36727.php on line %d
+Warning: PDOStatement::bindValue(): SQLSTATE[HY093]: Invalid parameter number: 7 :test in %s on line %d
bool(false)
Done
diff --git a/ext/pdo_pgsql/tests/bug69344.phpt b/ext/pdo_pgsql/tests/bug69344.phpt
index f544518455..e2522653f5 100644
--- a/ext/pdo_pgsql/tests/bug69344.phpt
+++ b/ext/pdo_pgsql/tests/bug69344.phpt
@@ -39,5 +39,5 @@ $test();
?>
--EXPECT--
-SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
+SQLSTATE[HY093]: Invalid parameter number: 7 parameter was not defined
SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
diff --git a/ext/pdo_pgsql/tests/bug71573.phpt b/ext/pdo_pgsql/tests/bug71573.phpt
index 66562344ef..d9e4fe7514 100644
--- a/ext/pdo_pgsql/tests/bug71573.phpt
+++ b/ext/pdo_pgsql/tests/bug71573.phpt
@@ -18,4 +18,4 @@ $statement->execute([ 'test', 'test', 'test' ]);
?>
--EXPECTF--
-Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in %sbug71573.php on line %d
+Warning: PDOStatement::execute(): SQLSTATE[HY093]: Invalid parameter number: 7 parameter was not defined in %s on line %d