]> granicus.if.org Git - php/commitdiff
forgotten off the last commit
authorGeorge Schlossnagle <gschlossnagle@php.net>
Tue, 18 May 2004 19:30:43 +0000 (19:30 +0000)
committerGeorge Schlossnagle <gschlossnagle@php.net>
Tue, 18 May 2004 19:30:43 +0000 (19:30 +0000)
ext/pdo/pdo_sql_parser.c
ext/pdo/pdo_sql_parser.re
ext/pdo/php_pdo_driver.h

index c8bfd2e63ed4e0bfd5bd2fdfe6c26c534f8bba0f..3cdfa10d0a3211a7e3d4abcf332a9e8576ed9ae0 100644 (file)
@@ -1,5 +1,25 @@
-/* Generated by re2c 0.5 on Tue May 18 10:23:55 2004 */
+/* Generated by re2c 0.5 on Tue May 18 12:42:13 2004 */
 #line 1 "/home/george/src/pecl/pdo/pdo_sql_parser.re"
+/*
+  +----------------------------------------------------------------------+
+  | PHP Version 5                                                        |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 1997-2004 The PHP Group                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 3.0 of the PHP license,       |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available through the world-wide-web at the following url:           |
+  | http://www.php.net/license/3_0.txt.                                  |
+  | If you did not receive a copy of the PHP license and are unable to   |
+  | obtain it through the world-wide-web, please send a note to          |
+  | license@php.net so we can mail you a copy immediately.               |
+  +----------------------------------------------------------------------+
+  | Author: George Schlossnagle <george@omniti.com>                      |
+  +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
 #include "php.h"
 #include "php_pdo_driver.h"
 
@@ -24,7 +44,7 @@ static int scan(Scanner *s)
        char *cursor = s->cur;
        std:
                s->tok = cursor;
-       #line 31
+       #line 51
 
 
        {
@@ -76,7 +96,7 @@ yy2:  yyaccept = 0;
        yych = *(YYMARKER = ++YYCURSOR);
        if(yych >= '\001')      goto yy14;
 yy3:
-#line 36
+#line 56
        { RET(PDO_PARSER_TEXT); }
 yy4:   yych = *++YYCURSOR;
        if(yybm[0+yych] & 64)   goto yy10;
@@ -86,18 +106,18 @@ yy5:       ++YYCURSOR;
        yych = *YYCURSOR;
 yy6:   if(yybm[0+yych] & 32)   goto yy5;
 yy7:
-#line 37
+#line 57
        { RET(PDO_PARSER_TEXT); }
 yy8:   yych = *++YYCURSOR;
 yy9:
-#line 38
+#line 58
        { RET(PDO_PARSER_EOI); }
 yy10:  ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
        yych = *YYCURSOR;
 yy11:  if(yybm[0+yych] & 64)   goto yy10;
 yy12:
-#line 35
+#line 55
        { RET(PDO_PARSER_BIND); }
 yy13:  ++YYCURSOR;
        if(YYLIMIT == YYCURSOR) YYFILL(1);
@@ -117,10 +137,10 @@ yy16:     ++YYCURSOR;
        goto yy15;
 yy17:  yych = *++YYCURSOR;
 yy18:
-#line 34
+#line 54
        { RET(PDO_PARSER_TEXT); }
 }
-#line 39
+#line 59
        
 }
 
@@ -132,11 +152,19 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
        int t;
        int bindno = 0;
        int newbuffer_len;
+       int padding;
        HashTable *params = stmt->bound_params;
        struct pdo_bound_param_data *param;
 
        /* allocate buffer for query with expanded binds, ptr is our writing pointer */
        newbuffer_len = inquery_len;
+
+       /* calculate the possible padding factor due to quoting */
+       if(stmt->dbh->max_escaped_char_length) {
+               padding = stmt->dbh->max_escaped_char_length;
+       } else {
+               padding = 3;
+       }
        if(params) {
                zend_hash_internal_pointer_reset(params);
                while (SUCCESS == zend_hash_get_current_data(params, (void**)&param)) {
@@ -146,7 +174,7 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                    bind placeholders are at least 2 characters, so
                    the accomodate their own "'s
                 */
-                               newbuffer_len += 2 * Z_STRLEN_P(param->parameter);
+                               newbuffer_len += padding * Z_STRLEN_P(param->parameter);
                        }
                        zend_hash_move_forward(params);
                }
@@ -178,11 +206,6 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                                int quotedstrlen;
                                /* currently everything is a string here */
                                
-                               /* add leading quote */
-                               *ptr = '"';
-                               ptr++;
-                               (*outquery_len)++;
-
                                /* quote the bind value if necessary */
                                if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter), 
                                        Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen TSRMLS_CC))
@@ -196,10 +219,6 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                                        ptr += Z_STRLEN_P(param->parameter);
                                        *outquery_len += (Z_STRLEN_P(param->parameter));
                                }
-                               /* add trailing quote */
-                               *ptr = '"';
-                               ptr++;
-                               (*outquery_len)++;
                        }
                        else {
                                /* error and cleanup */
@@ -218,6 +237,6 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
  * tab-width: 4
  * c-basic-offset: 4
  * End:
- * vim600: noet sw=4 ts=4 fdm=marker
+ * vim600: noet sw=4 ts=4 fdm=marker ft=c
  * vim<600: noet sw=4 ts=4
  */
index 2bcde49f1c9c62e2a2e95f6f770b677a0fcbb38b..fbec7419fc7c97771a1ce95a1c8ef04bd79bd764 100644 (file)
@@ -67,11 +67,19 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
        int t;
        int bindno = 0;
        int newbuffer_len;
+       int padding;
        HashTable *params = stmt->bound_params;
        struct pdo_bound_param_data *param;
 
        /* allocate buffer for query with expanded binds, ptr is our writing pointer */
        newbuffer_len = inquery_len;
+
+       /* calculate the possible padding factor due to quoting */
+       if(stmt->dbh->max_escaped_char_length) {
+               padding = stmt->dbh->max_escaped_char_length;
+       } else {
+               padding = 3;
+       }
        if(params) {
                zend_hash_internal_pointer_reset(params);
                while (SUCCESS == zend_hash_get_current_data(params, (void**)&param)) {
@@ -81,7 +89,7 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                    bind placeholders are at least 2 characters, so
                    the accomodate their own "'s
                 */
-                               newbuffer_len += 2 * Z_STRLEN_P(param->parameter);
+                               newbuffer_len += padding * Z_STRLEN_P(param->parameter);
                        }
                        zend_hash_move_forward(params);
                }
@@ -113,11 +121,6 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                                int quotedstrlen;
                                /* currently everything is a string here */
                                
-                               /* add leading quote */
-                               *ptr = '"';
-                               ptr++;
-                               (*outquery_len)++;
-
                                /* quote the bind value if necessary */
                                if(stmt->dbh->methods->quoter(stmt->dbh, Z_STRVAL_P(param->parameter), 
                                        Z_STRLEN_P(param->parameter), &quotedstr, &quotedstrlen TSRMLS_CC))
@@ -131,10 +134,6 @@ int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **ou
                                        ptr += Z_STRLEN_P(param->parameter);
                                        *outquery_len += (Z_STRLEN_P(param->parameter));
                                }
-                               /* add trailing quote */
-                               *ptr = '"';
-                               ptr++;
-                               (*outquery_len)++;
                        }
                        else {
                                /* error and cleanup */
index ecaab983516401ee8c5e5c1ec0c0d513bc4647b3..bc795e9846f551fe4137f13bb1b061d4e0258d66 100755 (executable)
@@ -204,9 +204,12 @@ struct _pdo_dbh_t {
         * the driver */
        unsigned emulate_prepare:1;
 
+       /* max length a single character can become after correct quoting */
+       unsigned max_escaped_char_length:3;
+
        /* the sum of the number of bits here and the bit fields preceeding should
         * equal 32 */
-       unsigned _reserved_flags:24;
+       unsigned _reserved_flags:21;
 
        /* data source string used to open this handle */
        const char *data_source;