Bug(s) or not?

Started by Teodor Sigaevover 22 years ago5 messages
#1Teodor Sigaev
teodor@sigaev.ru

Hi!

Simple test suite for current CVS:
%initdb ...
%createdb q
%psql q
q=# select * from pg_class limit 1;
SELECT
q=# select * from pg_class limit 2;
server sent data ("D" message) without prior row description ("T" message)
SELECT
q=# select * from pg_class limit 3;
server sent data ("D" message) without prior row description ("T" message)
server sent data ("D" message) without prior row description ("T" message)
SELECT

Why can I select from pg_class? Other system tables are working properly...

And one more:
q=# create table q(i int);
CREATE TABLE
q=# insert into q values (1);
INSERT 17450 1
q=# insert into q values (2);
INSERT 17451 1

q=# select count(*) from q;
count
-------
2
(1 row)

q=# select count(*) from q limit 1;
count
-------
2
(1 row)

q=# select count(*) from q limit 1 offset 1;
count
-------
(0 rows)

q=# select count(*) from q offset 1;
count
-------
(0 rows)

q=# select count(*) from q offset 0;
count
-------
2
(1 row)

I understand that it isn't correct query, but why pgsql do something strange
instead of say 'error'?

--
Teodor Sigaev E-mail: teodor@sigaev.ru

#2Bruno Wolff III
bruno@wolff.to
In reply to: Teodor Sigaev (#1)
Re: Bug(s) or not?

On Mon, May 26, 2003 at 14:17:52 +0400,
Teodor Sigaev <teodor@sigaev.ru> wrote:

q=# select count(*) from q;
count
-------
2
(1 row)

q=# select count(*) from q limit 1;
count
-------
2
(1 row)

q=# select count(*) from q limit 1 offset 1;
count
-------
(0 rows)

q=# select count(*) from q offset 1;
count
-------
(0 rows)

q=# select count(*) from q offset 0;
count
-------
2
(1 row)

I understand that it isn't correct query, but why pgsql do something
strange instead of say 'error'?

The above queries appear to be correct. The count returns a single row
with the number of rows in the table. If you skip over that row using
offset, you aren't going to get any rows.

#3Alvaro Herrera Munoz
alvherre@dcc.uchile.cl
In reply to: Teodor Sigaev (#1)
Re: Bug(s) or not?

On Mon, May 26, 2003 at 02:17:52PM +0400, Teodor Sigaev wrote:

q=# select * from pg_class limit 3;
server sent data ("D" message) without prior row description ("T" message)
server sent data ("D" message) without prior row description ("T" message)
SELECT

Why can I select from pg_class? Other system tables are working properly...

Doh... I've been seen the same behavior, but thought it was some bug in
my local copy. In fact I'm having a hard time finding a bug with
unreleased locks with code that seems functionally identical to CVS head
and I'm starting to think that it's not really a bug with my
modifications.

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
Major Fambrough: You wish to see the frontier?
John Dunbar: Yes sir, before it's gone.

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Teodor Sigaev (#1)
Re: Bug(s) or not?

Teodor Sigaev <teodor@sigaev.ru> writes:

Why can I select from pg_class? Other system tables are working properly...

That's darn bizarre. I see it too --- will look into it.

And one more:

That all looks like correct behavior to me. LIMIT/OFFSET are with
respect to the final query result, ie the single aggregate row.

regards, tom lane

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Tom Lane (#4)
Re: Bug(s) or not?

Teodor Sigaev <teodor@sigaev.ru> writes:

Why can I select from pg_class? Other system tables are working properly...

That's darn bizarre. I see it too --- will look into it.

Found it --- fix committed. Looks like libpq still needs some more work
for error recovery, too --- it was losing the original error message
about "unexpected field count in D message".

regards, tom lane