From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: count syntax |
Date: | 2003-05-31 02:18:02 |
Message-ID: | 200305310218.h4V2I2G11092@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Is this a TODO bug?
---------------------------------------------------------------------------
Tom Lane wrote:
> Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk> 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2003-05-31 02:22:10 | Re: count syntax |
Previous Message | valerian | 2003-05-31 00:36:54 | Re: CURRENT_DATE and CURRENT_TIME return incorrect values |