Thread: Another bug with parse statements on

Another bug with parse statements on

From
"Andrea Aime"
Date:
Hi everybody,
I've just come up with another bug... my last solution was to
apply my tiny bug fix on searchColInfo and keep "parse statements" = 1
Unfortunately this breaks another query, I think because the parser
has some problem with the "as" keyword... With "parse statements" = 1
the following query, issued from VB (using ADO 2.6), fails:

'SELECT min(classe) as minimo, max(classe) as massimo
FROM tav974'
(
 is a carriage return...)

I have found a quick fix, but it may work only in my environment.
1) Set "parse statements" = 0
2) Modify every occurence of:

if (globals.parse && stmt->statement_type == STMT_TYPE_SELECT)

into

if ((globals.parse || stmt->prepare) && stmt->statement_type ==
STMT_TYPE_SELECT)

in results.c.

This forces parsing on every prepared statement but avoids it on every
other
statement. Now my programs are working, but if something would issue a
prepared
statement like:

SELECT min(classe) as minimo, max(classe) as massimo
FROM tav974
where dummycol=?

the driver would fail. I have a mylog file with all the messages that
relates
to the mentioned bug, if you want I can send it to you (10kb if
compressed with
winzip). Sorry, but I have no time now to track down also this one...
maybe
it's stuff for someone more experienced than me.
Regards
Andrea Aime

Re: Another bug with parse statements on

From
Hiroshi Inoue
Date:
Hi Andrea,

Andrea Aime wrote:
>
> Hi everybody,
> I've just come up with another bug... my last solution was to
> apply my tiny bug fix on searchColInfo and keep "parse statements" = 1
> Unfortunately this breaks another query, I think because the parser
> has some problem with the "as" keyword... With "parse statements" = 1
> the following query, issued from VB (using ADO 2.6), fails:
>
> 'SELECT min(classe) as minimo, max(classe) as massimo
> FROM tav974'
> (
>  is a carriage return...)
>

What kind of errors do you see ?
I couldn't find any related ERRORs in your log.

regards,
Hiroshi Inoue

Re: Another bug with parse statements on

From
"Andrea Aime"
Date:
> >
> > 'SELECT min(classe) as minimo, max(classe) as massimo
> > FROM tav974'
> > (
> >  is a carriage return...)
> >
>
> What kind of errors do you see ?
> I couldn't find any related ERRORs in your log.
>

Snip from log file:

parse_statement: entering...
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='SELECT',
ptr='min(classe) as minimo, max(classe) as massimo
FROM tav974'
SELECT
got ispunct: s[3] = '('
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='min',
ptr='(classe) as minimo, max(classe) as massimo
FROM tav974'
reallocing at nfld=0
got field='min', dot=''
got ispunct: s[0] = '('
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='(',
ptr='classe) as minimo, max(classe) as massimo
FROM tav974'
**** got function = 'min'
got ispunct: s[6] = ')'
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='classe',
ptr=') as minimo, max(classe) as massimo
FROM tav974'
in_expr=0 or func=1
got ispunct: s[0] = ')'
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token=')', ptr='as
minimo, max(classe) as massimo
FROM tav974'
in_expr=0 or func=1
blevel-- = 0
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='as',
ptr='minimo, max(classe) as massimo
FROM tav974'
in_expr=0 or func=1
unquoted=1, quote=0, dquote=0, numeric=0, delim=',', token='minimo',
ptr=', max(classe) as massimo
FROM tav974'
in_expr=0 or func=1
got ispunct: s[5] = '('
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='max',
ptr='(classe) as massimo
FROM tav974'
in_expr=0 or func=1
got ispunct: s[0] = '('
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='(',
ptr='classe) as massimo
FROM tav974'
in_expr=0 or func=1
blevel++ = 1
got ispunct: s[6] = ')'
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='classe',
ptr=') as massimo
FROM tav974'
in_expr=0 or func=1
got ispunct: s[0] = ')'
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token=')', ptr='as
massimo
FROM tav974'
in_expr=0 or func=1
blevel-- = 0
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='as',
ptr='massimo
FROM tav974'
in_expr=0 or func=1
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='massimo',
ptr='FROM tav974'
in_expr=0 or func=1
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='FROM',
ptr='tav974'
FROM
unquoted=1, quote=0, dquote=0, numeric=0, delim=' ', token='tav974',
ptr=''
got table = 'tav974'
--------------------------------------------
nfld=1, ntab=1
Field 0:  expr=0, func=1, quote=0, dquote=0, numeric=0, name='min',
alias='', dot=''
Table 0: name='tav974', alias=''

nfld = 1? There are two fields in the result of my query. Moreover it
seems that he's
taking min as a the attribute name, not minimo... maybe it doesn't
recognize aggregate
function names?
Hope this helps
Andrea Aime

RE: Another bug with parse statements on

From
"Hiroshi Inoue"
Date:
> -----Original Message-----
> From: Andrea Aime [mailto:aaime@comune.modena.it]
>
> > >
> > > 'SELECT min(classe) as minimo, max(classe) as massimo
> > > FROM tav974'
> > > (
> > >  is a carriage return...)
> > >
> >
> > What kind of errors do you see ?
> > I couldn't find any related ERRORs in your log.
> >
> --------------------------------------------
> nfld=1, ntab=1
> Field 0:  expr=0, func=1, quote=0, dquote=0, numeric=0, name='min',
> alias='', dot=''
> Table 0: name='tav974', alias=''
>
> nfld = 1? There are two fields in the result of my query. Moreover it

OK please try the following patch.

regards,
Hiroshi Inoue

Index: parse.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/odbc/parse.c,v
retrieving revision 1.16
diff -c -c -r1.16 parse.c
*** parse.c    2001/03/27 04:00:54    1.16
--- parse.c    2001/04/23 08:59:18
***************
*** 393,398 ****
--- 393,401 ----
                  {
                      blevel--;
                      mylog("blevel-- = %d\n", blevel);
+                 }
+                 if (blevel == 0)
+                 {
                      if (delim == ',')
                      {
                          in_func = FALSE;


RE: Another bug with parse statements on

From
"Hiroshi Inoue"
Date:
> -----Original Message-----
> From: Andrea Aime [mailto:aaime@comune.modena.it]
>
> > >
> > > 'SELECT min(classe) as minimo, max(classe) as massimo
> > > FROM tav974'
> > > (
> > >  is a carriage return...)
> > >
> >
> > What kind of errors do you see ?
> > I couldn't find any related ERRORs in your log.
> >

[snip]
> --------------------------------------------
> nfld=1, ntab=1
> Field 0:  expr=0, func=1, quote=0, dquote=0, numeric=0, name='min',
> alias='', dot=''
> Table 0: name='tav974', alias=''
>
> nfld = 1? There are two fields in the result of my query. Moreover it

Oh I see your point.
I would examine parse_statement().

Thanks.
Hiroshi Inoue