diff options
author | unknown <cmiller@zippy.(none)> | 2006-05-03 09:55:34 -0400 |
---|---|---|
committer | unknown <cmiller@zippy.(none)> | 2006-05-03 09:55:34 -0400 |
commit | 1db5a3606aad92e6478414253885ad9e82820d0b (patch) | |
tree | dec3c4bfe621d8751c3203a85c7056a9ef46136f /sql/event_timed.cc | |
parent | 9ccf74b808e45ee3731b74675a18214b2a4f94fb (diff) | |
download | mariadb-git-1db5a3606aad92e6478414253885ad9e82820d0b.tar.gz |
Added code to remove closing comment code from event text, as would be
supplied inside a /*!VERSION event-text */ segment. (Fixes Bug#18078
mysql-test/t/disabled.def:
Enabling 'mysqldump' test because events should load normally now.
mysql-test/t/mysqldump.test:
Add spaces and tabs to the end of statements, to prove trimming of
whitespace.
sql/event_timed.cc:
Remove */ close-comment characters at the end, just as sp_head does.
The parser should be smarter about not giving us text that jumps semantic
levels, but that's an issue for another day.
Diffstat (limited to 'sql/event_timed.cc')
-rw-r--r-- | sql/event_timed.cc | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/sql/event_timed.cc b/sql/event_timed.cc index adf28b8877c..ed012ecd399 100644 --- a/sql/event_timed.cc +++ b/sql/event_timed.cc @@ -106,6 +106,9 @@ Event_timed::init_name(THD *thd, sp_name *spn) NOTE The body is extracted by copying all data between the start of the body set by another method and the current pointer in Lex. + + Some questionable removal of characters is done in here, and that part + should be refactored when the parser is smarter. */ void @@ -116,9 +119,46 @@ Event_timed::init_body(THD *thd) body_begin, thd->lex->ptr)); body.length= thd->lex->ptr - body_begin; - /* Trim nuls at the end */ - while (body.length && body_begin[body.length-1] == '\0') - body.length--; + const uchar *body_end= body_begin + body.length - 1; + + /* Trim nuls or close-comments ('*'+'/') or spaces at the end */ + while (body_begin < body_end) + { + + if ((*body_end == '\0') || + (my_isspace(thd->variables.character_set_client, *body_end))) + { /* consume NULs and meaningless whitespace */ + --body.length; + --body_end; + continue; + } + + /* + consume closing comments + + This is arguably wrong, but it's the best we have until the parser is + changed to be smarter. FIXME PARSER + + See also the sp_head code, where something like this is done also. + + One idea is to keep in the lexer structure the count of the number of + open-comments we've entered, and scan left-to-right looking for a + closing comment IFF the count is greater than zero. + + Another idea is to remove the closing comment-characters wholly in the + parser, since that's where it "removes" the opening characters. + */ + if ((*(body_end - 1) == '*') && (*body_end == '/')) + { + DBUG_PRINT("info", ("consumend one '*" "/' comment in the query '%s'", + body_begin)); + body.length-= 2; + body_end-= 2; + continue; + } + + break; /* none were found, so we have excised all we can. */ + } /* the first is always whitespace which I cannot skip in the parser */ while (my_isspace(thd->variables.character_set_client, *body_begin)) |