diff options
author | unknown <jimw@mysql.com> | 2005-05-06 05:48:46 -0700 |
---|---|---|
committer | unknown <jimw@mysql.com> | 2005-05-06 05:48:46 -0700 |
commit | 34ca109146f97a79fc17bfcac785c4beba426fe1 (patch) | |
tree | 5f0d8331cd9e45e21f18b60e13b5c9347b486517 /client | |
parent | 745d52bb3da3afb018061b4e3ec34420a8475389 (diff) | |
download | mariadb-git-34ca109146f97a79fc17bfcac785c4beba426fe1.tar.gz |
Support quoted identifiers containing single and double quotes in
mysqltest. (Bug #10251)
client/mysqltest.c:
Remove duplication in quote-handling quote, and add handling
of backquote (`).
mysql-test/t/mysqltest.test:
Add test of identifiers containing quotes.
mysql-test/r/mysqltest.result:
Update results
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqltest.c | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c index 4991e565594..a68b341a3e9 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2024,11 +2024,11 @@ my_bool end_of_query(int c) int read_line(char* buf, int size) { int c; + char quote; char* p= buf, *buf_end= buf + size - 1; int no_save= 0; - enum {R_NORMAL, R_Q1, R_ESC_Q_Q1, R_ESC_Q_Q2, - R_ESC_SLASH_Q1, R_ESC_SLASH_Q2, - R_Q2, R_COMMENT, R_LINE_START} state= R_LINE_START; + enum {R_NORMAL, R_Q, R_Q_IN_Q, R_SLASH_IN_Q, + R_COMMENT, R_LINE_START} state= R_LINE_START; DBUG_ENTER("read_line"); start_lineno= *lineno; @@ -2063,10 +2063,11 @@ int read_line(char* buf, int size) *p= 0; DBUG_RETURN(0); } - else if (c == '\'') - state = R_Q1; - else if (c == '"') - state = R_Q2; + else if (c == '\'' || c == '"' || c == '`') + { + quote= c; + state= R_Q; + } else if (c == '\n') { state = R_LINE_START; @@ -2101,55 +2102,36 @@ int read_line(char* buf, int size) *p= 0; DBUG_RETURN(0); } - else if (c == '\'') - state= R_Q1; - else if (c == '"') - state= R_Q2; - else - state= R_NORMAL; - break; - - case R_Q1: - if (c == '\'') - state= R_ESC_Q_Q1; - else if (c == '\\') - state= R_ESC_SLASH_Q1; - break; - case R_ESC_Q_Q1: - if (end_of_query(c)) + else if (c == '\'' || c == '"' || c == '`') { - *p= 0; - DBUG_RETURN(0); + quote= c; + state= R_Q; } - if (c != '\'') - state= R_NORMAL; else - state= R_Q1; - break; - case R_ESC_SLASH_Q1: - state= R_Q1; + state= R_NORMAL; break; - case R_Q2: - if (c == '"') - state= R_ESC_Q_Q2; + case R_Q: + if (c == quote) + state= R_Q_IN_Q; else if (c == '\\') - state= R_ESC_SLASH_Q2; + state= R_SLASH_IN_Q; break; - case R_ESC_Q_Q2: + case R_Q_IN_Q: if (end_of_query(c)) { *p= 0; DBUG_RETURN(0); } - if (c != '"') + if (c != quote) state= R_NORMAL; else - state= R_Q2; + state= R_Q; break; - case R_ESC_SLASH_Q2: - state= R_Q2; + case R_SLASH_IN_Q: + state= R_Q; break; + } if (!no_save) |