Обсуждение: INDEX on a composite type
Hi all.
When trying to create an index on a composite type, I need to enclose
the columns in paranthesis. Is this normal?
I don't think so as there's no mention in the friendly manual.
An example:
create type atype as (
atext text,
anint int
);
create table atable (
info text,
compo atype
);
create index i_atable_compo on atable(
((compo).atext),((compo).anint)
);
With single parenthesis, as suggested by the friendly manual, I get a
syntax error close to the "."
test=# create index i_atable_compo on atable(
(compo).atext,(compo).anint
);
ERROR: syntax error at or near "."
LINE 2: (compo).atext,(compo).anint
^
--
Vincenzo Romano
Maybe Computers will never become as intelligent as Humans.
Surely they won't ever become so stupid. [VR-1989]
On Wed, Dec 19, 2007 at 10:07:32PM +0100, GMail wrote: > Hi all. > > When trying to create an index on a composite type, I need to enclose > the columns in paranthesis. Is this normal? > I don't think so as there's no mention in the friendly manual. I beleive it says somewhere that anything except straight column names need parenthesis. What you have is an expression and thus it needs them. Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Those who make peaceful revolution impossible will make violent revolution inevitable. > -- John F Kennedy
Вложения
GMail wrote: > When trying to create an index on a composite type, I need to enclose > the columns in paranthesis. Is this normal? > I don't think so as there's no mention in the friendly manual. I think your problem is similar to one that has been discussed here previously. http://www.mail-archive.com/pgsql-general@postgresql.org/msg75862.html Colin
Il Wednesday 19 December 2007 22:29:25 Colin Wetherbee ha scritto: > GMail wrote: > > When trying to create an index on a composite type, I need to enclose > > the columns in paranthesis. Is this normal? > > I don't think so as there's no mention in the friendly manual. > > I think your problem is similar to one that has been discussed here > previously. > > http://www.mail-archive.com/pgsql-general@postgresql.org/msg75862.html > > Colin By the way, why not allowing the declaration of an index over a composite type as a whole? (As opposed to a composite type as the list of single component types). -- Vincenzo Romano Maybe Computers will never become as intelligent as Humans. Surely they won't ever become so stupid. [VR-1989]
On Wed, Dec 19, 2007 at 10:41:36PM +0100, GMail wrote: > By the way, why not allowing the declaration of an index over a composite > type as a whole? (As opposed to a composite type as the list of single > component types). It would probably work if there was an operator class defined for your type, but there's no magic for that. Have a nice day, -- Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/ > Those who make peaceful revolution impossible will make violent revolution inevitable. > -- John F Kennedy