mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fixed several test failed
This commit is contained in:
parent
b1f88c9a13
commit
34bb45e92d
2 changed files with 33 additions and 19 deletions
|
@ -259,11 +259,11 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
|||
param->paramno = atoi(param->name->val + 1);
|
||||
} else {
|
||||
/* resolve parameter name to rewritten name */
|
||||
zval *namevar;
|
||||
char *namevar;
|
||||
|
||||
if (stmt->bound_param_map && (namevar = zend_hash_find(stmt->bound_param_map,
|
||||
if (stmt->bound_param_map && (namevar = zend_hash_find_ptr(stmt->bound_param_map,
|
||||
param->name)) != NULL) {
|
||||
param->paramno = atoi(((zend_string*)Z_PTR_P(namevar))->val + 1) - 1;
|
||||
param->paramno = atoi(namevar + 1) - 1;
|
||||
} else {
|
||||
pdo_raise_impl_error(stmt->dbh, stmt, "HY093", param->name->val TSRMLS_CC);
|
||||
return 0;
|
||||
|
@ -298,15 +298,23 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
|||
sizeof(Oid));
|
||||
}
|
||||
if (param->paramno >= 0) {
|
||||
zval *parameter;
|
||||
|
||||
if (param->paramno > zend_hash_num_elements(stmt->bound_param_map)) {
|
||||
pdo_pgsql_error_stmt(stmt, PGRES_FATAL_ERROR, "HY105");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (Z_ISREF(param->parameter)) {
|
||||
parameter = Z_REFVAL(param->parameter);
|
||||
} else {
|
||||
parameter = ¶m->parameter;
|
||||
}
|
||||
|
||||
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB &&
|
||||
Z_TYPE(param->parameter) == IS_RESOURCE) {
|
||||
Z_TYPE_P(parameter) == IS_RESOURCE) {
|
||||
php_stream *stm;
|
||||
php_stream_from_zval_no_verify(stm, ¶m->parameter);
|
||||
php_stream_from_zval_no_verify(stm, parameter);
|
||||
if (stm) {
|
||||
if (php_stream_is(stm, &pdo_pgsql_lob_stream_ops)) {
|
||||
struct pdo_pgsql_lob_self *self = (struct pdo_pgsql_lob_self*)stm->abstract;
|
||||
|
@ -325,10 +333,10 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
|||
} else {
|
||||
zend_string *str = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0);
|
||||
if (str != NULL) {
|
||||
SEPARATE_ZVAL_IF_NOT_REF(¶m->parameter);
|
||||
ZVAL_STR(¶m->parameter, str);
|
||||
//??SEPARATE_ZVAL_IF_NOT_REF(¶m->parameter);
|
||||
ZVAL_STR(parameter, str);
|
||||
} else {
|
||||
ZVAL_EMPTY_STRING(¶m->parameter);
|
||||
ZVAL_EMPTY_STRING(parameter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -339,16 +347,16 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
|||
}
|
||||
|
||||
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_NULL ||
|
||||
Z_TYPE(param->parameter) == IS_NULL) {
|
||||
Z_TYPE_P(parameter) == IS_NULL) {
|
||||
S->param_values[param->paramno] = NULL;
|
||||
S->param_lengths[param->paramno] = 0;
|
||||
} else if (Z_TYPE(param->parameter) == IS_FALSE || Z_TYPE(param->parameter) == IS_TRUE) {
|
||||
S->param_values[param->paramno] = Z_TYPE(param->parameter) == IS_TRUE ? "t" : "f";
|
||||
} else if (Z_TYPE_P(parameter) == IS_FALSE || Z_TYPE_P(parameter) == IS_TRUE) {
|
||||
S->param_values[param->paramno] = Z_TYPE_P(parameter) == IS_TRUE ? "t" : "f";
|
||||
S->param_lengths[param->paramno] = 1;
|
||||
S->param_formats[param->paramno] = 0;
|
||||
} else {
|
||||
SEPARATE_ZVAL_IF_NOT_REF(¶m->parameter);
|
||||
convert_to_string_ex(¶m->parameter);
|
||||
//???SEPARATE_ZVAL_IF_NOT_REF(¶m->parameter);
|
||||
convert_to_string_ex(parameter);
|
||||
S->param_values[param->paramno] = Z_STRVAL(param->parameter);
|
||||
S->param_lengths[param->paramno] = Z_STRLEN(param->parameter);
|
||||
S->param_formats[param->paramno] = 0;
|
||||
|
@ -367,9 +375,15 @@ static int pgsql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *
|
|||
/* We need to manually convert to a pg native boolean value */
|
||||
if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_BOOL &&
|
||||
((param->param_type & PDO_PARAM_INPUT_OUTPUT) != PDO_PARAM_INPUT_OUTPUT)) {
|
||||
SEPARATE_ZVAL(¶m->parameter);
|
||||
zval *parameter;
|
||||
if (Z_ISREF(param->parameter)) {
|
||||
parameter = Z_REFVAL(param->parameter);
|
||||
} else {
|
||||
parameter = ¶m->parameter;
|
||||
}
|
||||
//????SEPARATE_ZVAL(¶m->parameter);
|
||||
param->param_type = PDO_PARAM_STR;
|
||||
ZVAL_STRINGL(¶m->parameter, Z_TYPE(param->parameter) == IS_TRUE ? "t" : "f", 1);
|
||||
ZVAL_STRINGL(parameter, Z_TYPE_P(parameter) == IS_TRUE ? "t" : "f", 1);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
@ -439,7 +453,7 @@ static int pgsql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
|
|||
cols[colno].precision = PQfmod(S->result, colno);
|
||||
S->cols[colno].pgsql_type = PQftype(S->result, colno);
|
||||
|
||||
switch(S->cols[colno].pgsql_type) {
|
||||
switch (S->cols[colno].pgsql_type) {
|
||||
|
||||
case BOOLOID:
|
||||
cols[colno].param_type = PDO_PARAM_BOOL;
|
||||
|
@ -501,7 +515,7 @@ static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned
|
|||
*ptr = PQgetvalue(S->result, S->current_row - 1, colno);
|
||||
*len = PQgetlength(S->result, S->current_row - 1, colno);
|
||||
|
||||
switch(cols[colno].param_type) {
|
||||
switch (cols[colno].param_type) {
|
||||
|
||||
case PDO_PARAM_INT:
|
||||
S->cols[colno].intval = atol(*ptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue