From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Grzegorz Jaskiewicz <gj(at)pointblue(dot)com(dot)pl> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: question about count(b) where b is a custom type |
Date: | 2005-11-16 12:30:13 |
Message-ID: | 20051116123012.GF31063@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Nov 16, 2005 at 10:05:36AM +0100, Grzegorz Jaskiewicz wrote:
> Hi folks
>
> We're developing here gist index (which works finally, and I remember
> about writing some docs about it).
> I have few fprintf(stderr,""") in function that converts internal
> rep. into string. I was really supprised to see them on me screen when :
> select count(b) from blah where b ~ 'something';
> was issued. What the hell, isn't it wrong ? I don't need strings to
> count results, right ?
> IMO this is a serious bug.
> What do yah think ?
Firstly, if you just want a count, what's wrong with count(1) or
count(*).
Secondly, if you want an aggregate to work on your new type, you should
declare it as such. This is one of the reasons why implicit casts to
text are discouraged. If it had to be explicit, the parser would have
told you that what you asked for wasn't possible directly. (There's no
count(yourtype) function defined).
See CREATE AGGREGATE.
Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
From | Date | Subject | |
---|---|---|---|
Next Message | Hannu Krosing | 2005-11-16 12:42:39 | Re: question about count(b) where b is a custom type |
Previous Message | Alvaro Herrera | 2005-11-16 12:20:52 | Re: Reproducable deadlock situation (possibly with foreign keys) |