diff options
Diffstat (limited to 'ext/pdo/pdo_sql_parser.re')
| -rw-r--r-- | ext/pdo/pdo_sql_parser.re | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/ext/pdo/pdo_sql_parser.re b/ext/pdo/pdo_sql_parser.re index fa8ef187fa..e182bf65d1 100644 --- a/ext/pdo/pdo_sql_parser.re +++ b/ext/pdo/pdo_sql_parser.re @@ -165,7 +165,7 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, if (query_type != PDO_PLACEHOLDER_POSITIONAL && bindno > zend_hash_num_elements(params)) { int ok = 1; for (plc = placeholders; plc; plc = plc->next) { - if (zend_hash_find(params, plc->pos, plc->len, (void**) ¶m) == FAILURE) { + if ((params = zend_hash_str_find_ptr(params, plc->pos, plc->len)) == NULL) { ok = 0; break; } @@ -188,38 +188,37 @@ safe: /* let's quote all the values */ for (plc = placeholders; plc; plc = plc->next) { if (query_type == PDO_PLACEHOLDER_POSITIONAL) { - ret = zend_hash_index_find(params, plc->bindno, (void**) ¶m); + param = zend_hash_index_find_ptr(params, plc->bindno); } else { - ret = zend_hash_find(params, plc->pos, plc->len, (void**) ¶m); + param = zend_hash_str_find_ptr(params, plc->pos, plc->len); } - if (ret == FAILURE) { + if (param == NULL) { /* parameter was not defined */ ret = -1; pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined" TSRMLS_CC); goto clean_up; } if (stmt->dbh->methods->quoter) { - if (param->param_type == PDO_PARAM_LOB && Z_TYPE_P(param->parameter) == IS_RESOURCE) { + if (param->param_type == PDO_PARAM_LOB && Z_TYPE(param->parameter) == IS_RESOURCE) { php_stream *stm; php_stream_from_zval_no_verify(stm, ¶m->parameter); if (stm) { - size_t len; - char *buf = NULL; + zend_string *buf; - len = php_stream_copy_to_mem(stm, &buf, PHP_STREAM_COPY_ALL, 0); - if (!stmt->dbh->methods->quoter(stmt->dbh, buf, len, &plc->quoted, &plc->qlen, + buf = php_stream_copy_to_mem(stm, PHP_STREAM_COPY_ALL, 0); + if (!stmt->dbh->methods->quoter(stmt->dbh, buf->val, buf->len, &plc->quoted, &plc->qlen, param->param_type TSRMLS_CC)) { /* bork */ ret = -1; strncpy(stmt->error_code, stmt->dbh->error_code, 6); if (buf) { - efree(buf); + STR_RELEASE(buf); } goto clean_up; } if (buf) { - efree(buf); + STR_RELEASE(buf); } } else { pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource" TSRMLS_CC); @@ -228,8 +227,8 @@ safe: } plc->freeq = 1; } else { - zval tmp_param = *param->parameter; - zval_copy_ctor(&tmp_param); + zval tmp_param; + ZVAL_DUP(&tmp_param, ¶m->parameter); switch (Z_TYPE(tmp_param)) { case IS_NULL: plc->quoted = "NULL"; @@ -263,8 +262,8 @@ safe: zval_dtor(&tmp_param); } } else { - plc->quoted = Z_STRVAL_P(param->parameter); - plc->qlen = Z_STRLEN_P(param->parameter); + plc->quoted = Z_STRVAL(param->parameter); + plc->qlen = Z_STRLEN(param->parameter); } newbuffer_len += plc->qlen; } @@ -321,7 +320,7 @@ rewrite: name = estrndup(plc->pos, plc->len); /* check if bound parameter is already available */ - if (!strcmp(name, "?") || zend_hash_find(stmt->bound_param_map, name, plc->len + 1, (void**) &p) == FAILURE) { + if (!strcmp(name, "?") || (p = zend_hash_str_find_ptr(stmt->bound_param_map, name, plc->len)) == NULL) { spprintf(&idxbuf, 0, tmpl, bind_no++); } else { idxbuf = estrdup(p); @@ -335,11 +334,11 @@ rewrite: if (!skip_map && stmt->named_rewrite_template) { /* create a mapping */ - zend_hash_update(stmt->bound_param_map, name, plc->len + 1, idxbuf, plc->qlen + 1, NULL); + zend_hash_str_update_mem(stmt->bound_param_map, name, plc->len, idxbuf, plc->qlen + 1); } /* map number to name */ - zend_hash_index_update(stmt->bound_param_map, plc->bindno, idxbuf, plc->qlen + 1, NULL); + zend_hash_index_update_mem(stmt->bound_param_map, plc->bindno, idxbuf, plc->qlen + 1); efree(name); } @@ -360,7 +359,7 @@ rewrite: char *name; name = estrndup(plc->pos, plc->len); - zend_hash_index_update(stmt->bound_param_map, plc->bindno, name, plc->len + 1, NULL); + zend_hash_index_update_mem(stmt->bound_param_map, plc->bindno, name, plc->len + 1); efree(name); plc->quoted = "?"; plc->qlen = 1; |
