BUG #1903: result incorrect when function max() in table with inherit used

From: "Cesar Paipilla" <capix(dot)999(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1903: result incorrect when function max() in table with inherit used
Date: 2005-09-21 16:40:07
Message-ID: 20050921164007.2BF32F0FC1@svr2.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 1903
Logged by: Cesar Paipilla
Email address: capix(dot)999(at)gmail(dot)com
PostgreSQL version: 8.1 Beta2
Operating system: Mandrake 2006RC2
Description: result incorrect when function max() in table with
inherit used
Details:

result from :

select max(id_info)
from t_test;

is different from :

select id_info
from t_test
order by id_info desc
limit 1;

definition table t_test
Table "public.t_test"
Column | Type | Modifiers
---------------------+---------+--------------------------------------------
--------------------------------
id_info | integer | not null default
nextval('public.t_test_id_info_seq'::text)
descripcion | text |
Indexes:
"t_test_pkey" PRIMARY KEY, btree (id_info)

... Definition other tables with inherits to t_test

Table "public.t_test_inherits_1"
Column | Type | Modifiers
---------------------+---------+--------------------------------------------
--------------------------------
id_info | integer | not null default
nextval('public.t_test_inherits_1_id_info_seq'::text)
descripcion | text |
id_parent | integer |
Indexes:
"t_test_inherits_1_pkey" PRIMARY KEY, btree (id_info)
Foreign-key constraints:
"t_test_inherits_1_id_parent_fkey" FOREIGN KEY (id_parent) REFERENCES
t_test(id_info) ON UPDATE CASCADE ON DELETE CASCADE
Inherits: t_test

DATA :

public.t_test
id_info | descripcion
---------+--------------------------------
1 | Row 1 from table "t_test"
2 | Row A from table with inherits
3 | Row B from table with inherits
(3 rows)

public.t_test_inherit_1
id_info | descripcion | id_parent
---------+--------------------------------+------------
2 | Row A from table with inherits | 1
3 | Row B from table with inherits | 1
(2 rows)

--
SELECT max(id_info)
FROM t_test;

max
-----
1
(1 row)

--
SELECT id_info
FROM t_test
ORDER BY id_info DESC
LIMIT 1;

id_info
---------
2
(1 row)

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message SriKumar Kareti 2005-09-21 18:49:35 possible bug...
Previous Message Devrim GUNDUZ 2005-09-21 13:25:26 Re: problem start database