Count column with name 'count' returns multiple rows. Why?

From: Rob Audenaerde <rob(dot)audenaerde(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Count column with name 'count' returns multiple rows. Why?
Date: 2017-08-18 11:01:45
Message-ID: CAPz8bx1sf0vzncvYUiEJq9MDf9xvELi2tJLY2jTN=t=L68nSGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I don't understand why this query:

select count(base.*) from mytable base;

does return multiple rows.

select count(1) from mytable base;

returns the proper count.

There is a column with the name 'count'.

Can anyone please explain this behaviour?

Steps to reproduce:

create table s91("count" int);
insert into s91 values (1),(2),(3);
select count(base.*) from s91 base;

count
-------
1
2
3
(3 rows)

I think this is either a bug or an undocumented feature?

ps. I posted this question on StackOverflow as well:
https://stackoverflow.com/q/45752412/461499

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Justin Pryzby 2017-08-18 11:37:15 Re: Count column with name 'count' returns multiple rows. Why?
Previous Message Dan 2017-08-18 09:57:32 Number of rows affected by ON CASCADE