Re: [HACKERS] 6.4 Aggregate Bug - Mailing list pgsql-hackers
From | Bruce Momjian |
---|---|
Subject | Re: [HACKERS] 6.4 Aggregate Bug |
Date | |
Msg-id | 199808012012.QAA29464@candle.pha.pa.us Whole thread Raw |
In response to | 6.4 Aggregate Bug (David Hartwig <daybee@bellatlantic.net>) |
List | pgsql-hackers |
> While testing my 6.4 patch to allow functions/expressions to be > specified in the ORDER/GROUP BY clause (and not in the target list) I > came across a nasty little bug. A segmentation fault gets thrown > somewhere in replace_agg_clause() when using aggregates, in combination > with a function or expression. (I am still tracking down the > offending lines of code. Sorry, the Linux/GCC environment is still new > to me.) > > I backed out my patch, and discovered the bug was still present. The > bug does not exist in version 6.3.2. Here is an example: > > -- This crashes the backend > select upper(a) as x, count(k) from t group by x; > > -- This works fine > select upper(a) as x, count(a) from t group by x; > > Notice how in the first query, (the one that does not work) upper() has > a different argument than count(). And in the second query (the one > that works) upper() has the same argument as count(). When using > count(*) it will always fail. Here is my initial analysis of the crash. It appears the types do not match. Not sure why. --------------------------------------------------------------------------- POSTGRES backend interactive interface $Revision: 1.80 $ $Date: 1998/07/18 18:34:09 $ > select upper(a) as x, count(xmin) from t group by x; StartTransactionCommand() at Sat Aug 1 14:55:16 1998 Breakpoint 1, match_varid (test_var=0x305010, tlist=0x303750) at tlist.c:270 270 type_var = (Oid) test_var->vartype; (gdb) (gdb) cont Continuing. Breakpoint 1, match_varid (test_var=0x305110, tlist=0x303750) at tlist.c:270 270 type_var = (Oid) test_var->vartype; (gdb) cont Continuing. Breakpoint 1, match_varid (test_var=0x3048d0, tlist=0x303ad0) at tlist.c:270 270 type_var = (Oid) test_var->vartype; (gdb) l 265 match_varid(Var *test_var, List *tlist) 266 { 267 List *tl; 268 Oid type_var; 269 270 type_var = (Oid) test_var->vartype; 271 272 Assert(test_var->varlevelsup == 0); 273 foreach(tl, tlist) 274 { (gdb) call pprint(test_var) { VAR :varno 1 :varattno 3 :vartype 1043 :vartypmod -1 :varlevelsup 0 :varnoold 1 :varoattno 3 } (gdb) call pprint(tlist) ( { TARGETENTRY :resdom { RESDOM :resno 1 :restype 25 :restypmod -1 :resname "x" :reskey 1 :reskeyop 740 :resjunk 0 } :expr { VAR :varno 1 :varattno 1 :vartype 25 :vartypmod -1 :varlevelsup 0 :varnoold -1 :varoattno 1 } } { TARGETENTRY :resdom { RESDOM :resno 2 :restype 28 :restypmod -1 :resname "(null) " :reskey 0 :reskeyop 0 :resjunk 0 } :expr { VAR :varno 1 :varattno 2 :vartype 28 :vartypmod -1 :varlevelsup 0 :varnoold 1 :varoattno -3 } } ) -- Bruce Momjian | 830 Blythe Avenue maillist@candle.pha.pa.us | Drexel Hill, Pennsylvania 19026 + If your life is a hard drive, | (610) 353-9879(w) + Christ can be your backup. | (610) 853-3000(h)
pgsql-hackers by date: