pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: christian_oederan@gmx.de
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6351: ERROR: btree index keys must be ordered by attribute
Date: Thu, 22 Dec 2011 11:27:15 -0500
Message-ID: <15472.1324571235@sss.pgh.pa.us> (raw)
In-Reply-To: <E1RdRfu-0004E9-8N@wrigleys.postgresql.org>
References: <E1RdRfu-0004E9-8N@wrigleys.postgresql.org>

christian_oederan@gmx.de writes:
> our OR-Mapper accidently created an index that contained the same column
> twice, with the result that some SELECTs could not be executed anymore and
> gave the error message "btree index keys must be ordered by attribute".

> The problem can be reproduced with a new table every time:

> CREATE TABLE tab (id SERIAL, a INTEGER, b INTEGER);
> CREATE INDEX tab123 ON tab (a, b, a);
> SELECT a, b FROM tab WHERE a = 0 AND b = 0;

> ERROR:  XX000: btree index keys must be ordered by attribute

Hmm.  This didn't use to be allowed at all before 9.0; previous releases
would reject the index definition:

regression=# CREATE INDEX tab123 ON tab (a, b, a);
ERROR:  duplicate key value violates unique constraint "pg_attribute_relid_attnam_index"

But now that we allow it it'd be nice if it actually worked :-(.
Looking into the archives I see that we were mainly thinking about
the possibility of exclusion constraints naming the same column
more than once, which may explain why nobody tried using such an
index for queries.  I'll see about fixing this in HEAD, although
my initial guess is that it will be too invasive to back-patch.

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <15472.1324571235@sss.pgh.pa.us>
Permalink:  ../15472.1324571235@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/15472.1324571235@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, christian_oederan@gmx.de
  Subject: Re: BUG #6351: ERROR: btree index keys must be ordered by attribute
  In-Reply-To: <15472.1324571235@sss.pgh.pa.us>
  References: <E1RdRfu-0004E9-8N@wrigleys.postgresql.org> <15472.1324571235@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox