Hi, Dominique,
Yes, your right, there is no additional need from the constructor of
qString and qLike to attempt to remove quotes. This significantly
simplies qString and qLike. Thanks.
John
On 3/26/12 11:07 AM, Dominique Prunier wrote:
> Hi John,
>
>
>
> I discovered a bug in the where clause parsing.
>
>
>
> It seems that the lexer already removed the first and last character
> of quoted strings:
>
>
>
> {QUOTED} { /* a quoted string literal */
>
> #if defined(DEBUG) && DEBUG + 0 > 1
>
> LOGGER(ibis::gVerbose >= 0)
>
> << __FILE__ << ':' << __LINE__ << " got a quoted string: " <<
> yytext;
>
> #endif
>
> yylval->stringVal = new std::string(yytext+1, yyleng-2);
>
> return token::STRLIT;
>
> }
>
>
>
> However, in *qString::qString* and *qLike::qLike* the string is
> unquoted once more.
>
>
>
> So typically, it make a predicate like str=’”test”’ test for the value
> test instead of ”test”.
>
>
>
> The fix would be to either change the lexer (but this is risky since
> it seems that the token STRLIT is used at other places) or, maybe more
> safely, remove the quote striping in *qString::qString* and
> *qLike::qLike* :
>
>
>
> diff --git a/src/qExpr.cpp b/src/qExpr.cpp
>
> index 4cb5aba..a726957 100644
>
> --- a/src/qExpr.cpp
>
> +++ b/src/qExpr.cpp
>
> @@ -1820,11 +1820,9 @@ ibis::qString::qString(const char* ls, const
> char* rs) :
>
> qExpr(ibis::qExpr::STRING), lstr(ibis::util::strnewdup(ls)) {
>
> // need to remove leading and trailing quote and the meta characters
>
> rstr = new char[1+strlen(rs)];
>
> - const char quote = ('"' == *rs || '\'' == *rs) ? *rs : 0;
>
> const char* cptr = rs;
>
> char* dptr = rstr;
>
> - cptr += (quote != 0);
>
> - while (*cptr != quote) {
>
> + while (*cptr != 0) {
>
> if (*cptr != '\\') {
>
> *dptr = *cptr;
>
> }
>
> @@ -1859,11 +1857,9 @@ ibis::qLike::qLike(const char* ls, const char*
> rs) :
>
> #endif
>
> // need to remove leading and trailing quote and the meta characters
>
> rpat = new char[1+strlen(rs)];
>
> - const char quote = ('"' == *rs || '\'' == *rs) ? *rs : 0;
>
> const char* cptr = rs;
>
> char* dptr = rpat;
>
> - cptr += (quote != 0);
>
> - while (*cptr != quote) {
>
> + while (*cptr != 0) {
>
> if (*cptr != '\\') {
>
> *dptr = *cptr;
>
> }
>
>
>
> The patch above seems to fix the issue.
>
>
>
> Thanks,
>
>
>
> */Dominique Prunier/**//*
>
> APG Lead Developper
>
> Logo-W4N-100dpi
>
> 4388, rue Saint-Denis
>
> Bureau 309
>
> Montreal (Quebec) H2J 2L1
>
> Tel. +1 514-842-6767 x310
>
> Fax +1 514-842-3989
>
> [email protected] <mailto:[email protected]>
>
> www.watch4net.com <http://www.watch4net.com/>
>
> / /
>
> /This message is for the designated recipient only and may contain
> privileged, proprietary, or otherwise private information. If you have
> received it in error, please notify the sender immediately and delete
> the original. Any other use of this electronic mail by you is prohibited.
>
> //Ce message est pour le récipiendaire désigné seulement et peut
> contenir des informations privilégiées, propriétaires ou autrement
> privées. Si vous l'avez reçu par erreur, S.V.P. avisez l'expéditeur
> immédiatement et effacez l'original. Toute autre utilisation de ce
> courrier électronique par vous est prohibée.///
>
>
>
>
>
> _______________________________________________
> FastBit-users mailing list
> [email protected]
> https://hpcrdm.lbl.gov/cgi-bin/mailman/listinfo/fastbit-users
_______________________________________________
FastBit-users mailing list
[email protected]
https://hpcrdm.lbl.gov/cgi-bin/mailman/listinfo/fastbit-users