Re: question about count(b) where b is a custom type

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: question about count(b) where b is a custom type
Дата
Msg-id 20051116123012.GF31063@svana.org
обсуждение исходный текст
Ответ на question about count(b) where b is a custom type  (Grzegorz Jaskiewicz <gj@pointblue.com.pl>)
Список 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@svana.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.

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Reproducable deadlock situation (possibly with foreign keys)
Следующее
От: Hannu Krosing
Дата:
Сообщение: Re: question about count(b) where b is a custom type