diff --git a/ext/pdo/pdo_sql_parser.c b/ext/pdo/pdo_sql_parser.c index af14951c931..10bf955177f 100644 --- a/ext/pdo/pdo_sql_parser.c +++ b/ext/pdo/pdo_sql_parser.c @@ -1,5 +1,5 @@ -/* Generated by re2c 0.9.3 on Sat Feb 12 15:31:40 2005 */ -#line 1 "/home/rei/php_dev/pecl/pdo/pdo_sql_parser.re" +/* Generated by re2c 0.9.3 on Sun Feb 13 00:25:51 2005 */ +#line 1 "pdo_sql_parser.re" /* +----------------------------------------------------------------------+ | PHP Version 5 | @@ -45,7 +45,7 @@ static int scan(Scanner *s) char *cursor = s->cur; std: s->tok = cursor; - #line 54 "/home/rei/php_dev/pecl/pdo/pdo_sql_parser.re" + #line 54 "pdo_sql_parser.re" @@ -103,7 +103,7 @@ yy2: yyaccept = 0; if(yych >= '\001') goto yy24; goto yy3; yy3: -#line 61 "/home/rei/php_dev/pecl/pdo/pdo_sql_parser.re" +#line 61 "pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } #line 63 "" yy4: yyaccept = 0; @@ -117,7 +117,7 @@ yy5: yych = *++YYCURSOR; yy6: ++YYCURSOR; goto yy7; yy7: -#line 60 "/home/rei/php_dev/pecl/pdo/pdo_sql_parser.re" +#line 60 "pdo_sql_parser.re" { RET(PDO_PARSER_BIND_POS); } #line 77 "" yy8: ++YYCURSOR; @@ -127,13 +127,13 @@ yy8: ++YYCURSOR; yy9: if(yybm[0+yych] & 8) goto yy8; goto yy10; yy10: -#line 62 "/home/rei/php_dev/pecl/pdo/pdo_sql_parser.re" +#line 62 "pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } #line 88 "" yy11: ++YYCURSOR; goto yy12; yy12: -#line 63 "/home/rei/php_dev/pecl/pdo/pdo_sql_parser.re" +#line 63 "pdo_sql_parser.re" { RET(PDO_PARSER_EOI); } #line 94 "" yy13: ++YYCURSOR; @@ -143,7 +143,7 @@ yy13: ++YYCURSOR; yy14: if(yybm[0+yych] & 16) goto yy13; goto yy15; yy15: -#line 59 "/home/rei/php_dev/pecl/pdo/pdo_sql_parser.re" +#line 59 "pdo_sql_parser.re" { RET(PDO_PARSER_BIND); } #line 105 "" yy16: ++YYCURSOR; @@ -169,7 +169,7 @@ yy20: if(yybm[0+yych] & 32) goto yy16; if(yych <= '\'') goto yy19; goto yy22; yy21: -#line 58 "/home/rei/php_dev/pecl/pdo/pdo_sql_parser.re" +#line 58 "pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } #line 132 "" yy22: ++YYCURSOR; @@ -193,11 +193,11 @@ yy25: ++YYCURSOR; yy26: ++YYCURSOR; goto yy27; yy27: -#line 57 "/home/rei/php_dev/pecl/pdo/pdo_sql_parser.re" +#line 57 "pdo_sql_parser.re" { RET(PDO_PARSER_TEXT); } #line 159 "" } -#line 64 "/home/rei/php_dev/pecl/pdo/pdo_sql_parser.re" +#line 64 "pdo_sql_parser.re" } @@ -275,7 +275,7 @@ PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, params = stmt->bound_params; /* Do we have placeholders but no bound params */ - if (bindno && !params) { + if (bindno && !params && stmt->supports_placeholders == PDO_PLACEHOLDER_NONE) { pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "no parameters were bound" TSRMLS_CC); ret = -1; goto clean_up; @@ -396,10 +396,25 @@ rewrite: } else { /* rewrite :name to ? */ + + newbuffer_len = inquery_len; + + if (stmt->bound_param_map == NULL) { + ALLOC_HASHTABLE(stmt->bound_param_map); + zend_hash_init(stmt->bound_param_map, 13, NULL, NULL, 0); + } + + for (plc = placeholders; plc; plc = plc->next) { + char *name; + + name = estrndup(plc->pos, plc->len); + zend_hash_index_update(stmt->bound_param_map, plc->bindno, name, plc->len + 1, NULL); + efree(name); + plc->quoted = "?"; + plc->qlen = 1; + } - /* HARD!. We need to remember the mapping and bind those positions. */ - pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "cannot map :name to ? in this version" TSRMLS_CC); - ret = -1; + goto rewrite; } clean_up: