Table name used as aggregate argument

Started by Dennis Bjorklundabout 21 years ago2 messagesbugs
Jump to latest
#1Dennis Bjorklund
db@zigo.dhs.org

How come this work in pg (8.0 and older):

CREATE TABLE bug (x int);
SELECT count(bug) FROM bug;

Shouldn't it complain and say that "bug" is not a column?

--
/Dennis Bj�rklund

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dennis Bjorklund (#1)
Re: Table name used as aggregate argument

Dennis Bjorklund <db@zigo.dhs.org> writes:

How come this work in pg (8.0 and older):
CREATE TABLE bug (x int);
SELECT count(bug) FROM bug;

Shouldn't it complain and say that "bug" is not a column?

No. This is a perfectly good, if somewhat historical, spelling of

SELECT count(bug.*) FROM bug;

Since count() takes any data type at all, a record type is just as
good as anything else...

regards, tom lane