MXS-1536: Fix crash in CREATE TABLE

If a CREATE TABLE statement had a quoted keyword as the name of a field,
the calculated column count and actual column counts would differ.

In addition to this, oneline comments before the end of the statement
would truncate the SQL due to the fact that the whitespace was squashed
before the comment removal was done.
This commit is contained in:
Markus Mäkelä
2017-11-29 07:33:13 +02:00
parent 2217091019
commit 0ca04cb5d5
3 changed files with 39 additions and 24 deletions

View File

@ -553,7 +553,9 @@ strip_escape_chars(char* val)
#define BUFFER_GROWTH_RATE 2.0
static pcre2_code* remove_comments_re = NULL;
static const PCRE2_SPTR remove_comments_pattern = (PCRE2_SPTR)
"(?:`[^`]*`\\K)|(\\/[*](?!(M?!)).*?[*]\\/)|(?:#.*|--[[:space:]].*)";
"(?:`[^`]*`\\K)|"
"(\\/[*](?!(M?!)).*?[*]\\/)|"
"([[:space:]](?:#.*|--[[:space:]].*(\\n|\\r\\n)))";
/**
* Remove SQL comments from the end of a string