MXS-1719 Treat # comments the same way as -- comments
sqlite does not treat # as the start of a to-end-of-line comment. It cannot trivially be treated as such because at startup sqlite parses statements containing the #-character. Thus, only after sqlite has been initialized can it be treated the same way as --.
This commit is contained in:
@ -2110,15 +2110,25 @@ public:
|
|||||||
update_names(zDatabase, table, NULL, NULL);
|
update_names(zDatabase, table, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void maxscaleComment()
|
int maxscaleComment()
|
||||||
{
|
{
|
||||||
ss_dassert(this_thread.initialized);
|
// We are regularily parsing if the thread has been initialized.
|
||||||
|
// In that case # should be interpreted as the start of a comment,
|
||||||
|
// otherwise it should not.
|
||||||
|
int regular_parsing = false;
|
||||||
|
|
||||||
if (m_status == QC_QUERY_INVALID)
|
if (this_thread.initialized)
|
||||||
{
|
{
|
||||||
m_status = QC_QUERY_PARSED;
|
regular_parsing = true;
|
||||||
m_type_mask = QUERY_TYPE_READ;
|
|
||||||
|
if (m_status == QC_QUERY_INVALID)
|
||||||
|
{
|
||||||
|
m_status = QC_QUERY_PARSED;
|
||||||
|
m_type_mask = QUERY_TYPE_READ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return regular_parsing;
|
||||||
}
|
}
|
||||||
|
|
||||||
void maxscaleDeclare(Parse* pParse)
|
void maxscaleDeclare(Parse* pParse)
|
||||||
|
|||||||
@ -198,6 +198,7 @@ int sqlite3IsIdChar(u8 c){ return IdChar(c); }
|
|||||||
** Store the token type in *tokenType before returning.
|
** Store the token type in *tokenType before returning.
|
||||||
*/
|
*/
|
||||||
#ifdef MAXSCALE
|
#ifdef MAXSCALE
|
||||||
|
extern int maxscaleComment();
|
||||||
int sqlite3GetToken(Parse* pParse, const unsigned char *z, int *tokenType){
|
int sqlite3GetToken(Parse* pParse, const unsigned char *z, int *tokenType){
|
||||||
#else
|
#else
|
||||||
int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
||||||
@ -219,8 +220,7 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
|||||||
case CC_MINUS: {
|
case CC_MINUS: {
|
||||||
if( z[1]=='-' ){
|
if( z[1]=='-' ){
|
||||||
#ifdef MAXSCALE
|
#ifdef MAXSCALE
|
||||||
extern void maxscaleComment();
|
maxscaleComment();
|
||||||
maxscaleComment();
|
|
||||||
#endif
|
#endif
|
||||||
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
|
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
|
||||||
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
|
*tokenType = TK_SPACE; /* IMP: R-22934-25134 */
|
||||||
@ -466,6 +466,13 @@ int sqlite3GetToken(const unsigned char *z, int *tokenType){
|
|||||||
testcase( z[0]=='$' ); testcase( z[0]=='@' );
|
testcase( z[0]=='$' ); testcase( z[0]=='@' );
|
||||||
testcase( z[0]==':' ); testcase( z[0]=='#' );
|
testcase( z[0]==':' ); testcase( z[0]=='#' );
|
||||||
#ifdef MAXSCALE
|
#ifdef MAXSCALE
|
||||||
|
if (z[0]=='#') {
|
||||||
|
if (maxscaleComment()) {
|
||||||
|
for(i=1; (c=z[i])!=0 && c!='\n'; i++){}
|
||||||
|
*tokenType = TK_SPACE;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (z[0]==':' && z[1]=='=') {
|
if (z[0]==':' && z[1]=='=') {
|
||||||
*tokenType = TK_EQ;
|
*tokenType = TK_EQ;
|
||||||
return 2;
|
return 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user