Обсуждение: BUG #12792: I can do a SELECT with no fields

Поиск
Список
Период
Сортировка

BUG #12792: I can do a SELECT with no fields

От
lr@pcorp.us
Дата:
The following bug has been logged on the website:

Bug reference:      12792
Logged by:          Regina Obe
Email address:      lr@pcorp.us
PostgreSQL version: 9.4.1
Operating system:   Windows 2008 R2
Description:

I'm not sure if this is a bug or not, but it seems like a misfeature if it
isn't.

I made the typo of doing

SELECT FROM sometable;

you can also trigger the issue with just doing:

SELECT ;

outputs:
--
(1 row)

I thought there was something wrong with my viewer since it clearly showed
rows, but no fields.

In 9.3 -- this would just error out as I think most databases do.  So this
was a bit of a gotcha.

I'm not sure if this issue existed in 9.4.0 alreadyy since I've already
upgraded my database.

Re: BUG #12792: I can do a SELECT with no fields

От
Tom Lane
Дата:
lr@pcorp.us writes:
> I'm not sure if this is a bug or not, but it seems like a misfeature if it
> isn't.

It is an intentional change, see the 9.4 release notes.

            regards, tom lane

Re: BUG #12792: I can do a SELECT with no fields

От
Kevin Grittner
Дата:
"lr@pcorp.us" <lr@pcorp.us> wrote:

> I'm not sure if this is a bug or not,

It it's not.  See the release notes:

http://www.postgresql.org/docs/9.4/interactive/release-9-4.html

| Allow SELECT to have an empty target list (Tom Lane)
|
| This was added so that views that select from a table with zero
| columns can be dumped and restored correctly.

For a more detailed explanation of why this feature was added, see
the commit message:

http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=1b4f7f93b4693858cb983af3cd557f6097dab67b

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company