[sqlite] How this /*A-overwrites-S*/ should work ?
Thanks for the answer ! > Wed Feb 24 2016 6:38:46 pm CET CET from "Richard Hipp" > > > The /*A-overwrites-S*/ comment is processed by Lemon, and Lemon has no > knowledge of #ifdefs. > > > I can understand that but it will confuse other people like it did to me ! Cheers !
[sqlite] How this /*A-overwrites-S*/ should work ?
I solved it setting a variable before " /*A-overwrites-S*/", but I's still confusing it's usage inside a wrapped "#ifdef" that supposed only will be executed conditionally. Cheers ! oneselect(A) ::= SELECT|XSELECT(S) distinct(D) selcollist(W) from(X) where_opt(Y) groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). { ? int isXSelect = @S == TK_XSELECT; #if SELECTTRACE_ENABLED ? Token s = S; /*A-overwrites-S*/ #endif ? A = sqlite3SelectNew(pParse,W,X,Y,P,Q,Z,D,L.pLimit,L.pOffset); ? if(isXSelect) A->selFlags |= SF_NOFlattening; #if SELECTTRACE_ENABLED ? /* Populate the Select.zSelName[] string that is used to help with ? ** query planner debugging, to differentiate between multiple Select ? ** objects in a complex query. ? ** ? ** If the SELECT keyword is immediately followed by a C-style comment ? ** then extract the first few alphanumeric characters from within that ? ** comment to be the zSelName value.? Otherwise, the label is #N where ? ** is an integer that is incremented with each SELECT statement seen. ? */ ? if( A!=0 ){ ??? const char *z = s.z+ (isXSelect ? 7 : 6); ??? int i; ??? sqlite3_snprintf(sizeof(A->zSelName), A->zSelName, "#%d", ++pParse->nSelect); ??? while( z[0]==' ' ) z++; ??? if( z[0]=='/' && z[1]=='*' ){ ? z += 2; ? while( z[0]==' ' ) z++; ? for(i=0; sqlite3Isalnum(z[i]); i++){} ? sqlite3_snprintf(sizeof(A->zSelName), A->zSelName, "%.*s", i, z); ??? } ? } #endif /* SELECTRACE_ENABLED */ }
[sqlite] How this /*A-overwrites-S*/ should work ?
Here is the full changes I did in parser.y: ? %endif SQLITE_OMIT_COMPOUND_SELECT oneselect(A) ::= SELECT|XSELECT(S) distinct(D) selcollist(W) from(X) where_opt(Y) groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). { #if SELECTTRACE_ENABLED ? Token s = S; /*A-overwrites-S*/ #endif ? A = sqlite3SelectNew(pParse,W,X,Y,P,Q,Z,D,L.pLimit,L.pOffset); ? if(@S == TK_XSELECT) A->selFlags |= SF_NOFlattening; #if SELECTTRACE_ENABLED ? /* Populate the Select.zSelName[] string that is used to help with ? ** query planner debugging, to differentiate between multiple Select ? ** objects in a complex query. ? ** ? ** If the SELECT keyword is immediately followed by a C-style comment ? ** then extract the first few alphanumeric characters from within that ? ** comment to be the zSelName value.? Otherwise, the label is #N where ? ** is an integer that is incremented with each SELECT statement seen. ? */ ? if( A!=0 ){ ??? const char *z = s.z+ (@S == TK_XSELECT ? 7 : 6); ??? int i; ??? sqlite3_snprintf(sizeof(A->zSelName), A->zSelName, "#%d", ++pParse->nSelect); ??? while( z[0]==' ' ) z++; ??? if( z[0]=='/' && z[1]=='*' ){ ? z += 2; ? while( z[0]==' ' ) z++; ? for(i=0; sqlite3Isalnum(z[i]); i++){} ? sqlite3_snprintf(sizeof(A->zSelName), A->zSelName, "%.*s", i, z); ??? } ? } #endif /* SELECTRACE_ENABLED */ } ?
[sqlite] How this /*A-overwrites-S*/ should work ?
Hello ! I have a modification on the parser.y for my own purposes and it was been parsed till the introduction of " /*A-overwrites-S*/" and it seems that something is wrong on parser.y see bellow, after the SELECT specification the " /*A-overwrites-S*/" is wrapped by "#if SELECTTRACE_ENABLED" that is not enabled in my build but the " /*A-overwrites-S*/" still seem to be active, even if I move the " /*A-overwrites-S*/" after the usage of " if(@S == TK_XSELECT)" I still get the same error. parse.y:495: Label S used after '/*A-overwrites-S*/'. How to get this to be parsed again ? Cheers ! multiselect_op(A) ::= EXCEPT|INTERSECT(OP).? {A = @OP; /*A-overwrites-OP*/} %endif SQLITE_OMIT_COMPOUND_SELECT oneselect(A) ::= SELECT|XSELECT(S) distinct(D) selcollist(W) from(X) where_opt(Y) groupby_opt(P) having_opt(Q) orderby_opt(Z) limit_opt(L). { #if SELECTTRACE_ENABLED? ///<<< this seems to intend to disable /*A-overwrites-S*/ but it doesn't ! ? Token s = S; /*A-overwrites-S*/ #endif ? A = sqlite3SelectNew(pParse,W,X,Y,P,Q,Z,D,L.pLimit,L.pOffset); ? if(@S == TK_XSELECT) A->selFlags |= SF_NOFlattening; #if SELECTTRACE_ENABLED
[sqlite] How this /*A-overwrites-S*/ should work ?
On 2/24/16, Domingo Alvarez Duarte wrote: > I solved it setting a variable before " /*A-overwrites-S*/", but I's still > confusing it's usage inside a wrapped "#ifdef" that supposed only will be > executed conditionally. The /*A-overwrites-S*/ comment is processed by Lemon, and Lemon has no knowledge of #ifdefs. -- D. Richard Hipp drh at sqlite.org
[sqlite] How this /*A-overwrites-S*/ should work ?
On 2/24/16, Domingo Alvarez Duarte wrote: > Hello ! > > I have a modification on the parser.y for my own purposes and it was been > parsed till the introduction of " /*A-overwrites-S*/" and it seems that > something is wrong on parser.y see bellow,\ The /*A-overwrites-S*/ comment is a hint to the parser generator that it can optimize by avoiding copy of a stack element in the PDA. You may safely remove the comment. -- D. Richard Hipp drh at sqlite.org