Re: count syntax

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: count syntax
Дата
Msg-id
11375.1050071383@sss.pgh.pa.us
Ответ на
count syntax (Patrick Welche)
Список
Дерево обсуждения
count syntax Patrick Welche <prlw1@newn.cam.ac.uk>
Re: count syntax Tom Lane <tgl@sss.pgh.pa.us>
Re: count syntax Bruce Momjian <pgman@candle.pha.pa.us>
Re: count syntax Tom Lane <tgl@sss.pgh.pa.us>
Re: count syntax Bruce Momjian <pgman@candle.pha.pa.us>
Re: count syntax Tom Lane <tgl@sss.pgh.pa.us>
Re: count syntax Bruce Momjian <pgman@candle.pha.pa.us>
psql: FATAL: Missing or erroneous pg_hba.conf file bijoy@openlx.com
Re: psql: FATAL: Missing or erroneous pg_hba.conf file Bruce Momjian <pgman@candle.pha.pa.us>
Re: psql: FATAL: Missing or erroneous pg_hba.conf Ernest E Vogelsinger <ernest@vogelsinger.at>
Re: psql: FATAL: Missing or erroneous pg_hba.conf file Tom Lane <tgl@sss.pgh.pa.us>
Re: count syntax Bruno Wolff III <bruno@wolff.to>
Patrick Welche  writes:
> What is the difference between the following?

> transatlantic=# select count(*) from trans;

This is a SQL-spec-mandated special case meaning "count the number of rows".

> transatlantic=# select count(trans.flowindex) from trans;

This counts the number of non-null values of trans.flowindex.  Also
per spec.

> transatlantic=# select count(trans.*) from trans;
ERROR:  Memory exhausted in AllocSetAlloc(204)

This syntax is not legal per SQL spec.  Postgres interprets it as a
command to count the number of non-null values of "trans.*", which in
this context is taken as being a whole-row variable.  Unfortunately the
present implementation of whole-row variables leaks memory ...

I don't believe that a whole-row variable will ever be null, so the
end result is the same as count(*).  You may as well spell it in the
spec-approved fashion.

			regards, tom lane

В списке pgsql-general по дате отправления
От: Shridhar Daithankar
Дата:
Сообщение: Re: help Request
От: Bruno Wolff III
Дата:
Сообщение: Re: count syntax
FAQ