How to use as Functional Index to be used as Primary KEY - Mailing list pgsql-general

From Janning Vygen
Subject How to use as Functional Index to be used as Primary KEY
Date
Msg-id 200407311548.06813.vygen@gmx.de
Whole thread Raw
Responses Re: How to use as Functional Index to be used as Primary KEY  (Peter Eisentraut <peter_e@gmx.net>)
Re: How to use as Functional Index to be used as Primary KEY  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi,

i searched the docs and the archives and was really wondering that i have not
found anything searching for "functional index primary key".

i would like to have a table of members with nicknames which are
case-insensitive but i would like to save the user given name case-sensitive
to display 'JimKnopf' instead of 'jimknopf':

CREATE TABLE members (
  nickname      text      NOT NULL,
  CONSTRAINT pk_test PRIMARY KEY (lower(name))
);

psql:scratch.sql:7: ERROR:  syntax error at or near "(" at character 92

Of course i can use an index like this:

CREATE TABLE members (
  nickname      text      NOT NULL,
);
CREATE UNIQUE INDEX ix_name ON test (lower(name));

but the key isn't marked as primary then.

So here is my question: How can i define a functional index to be used with a
primary key (using postgreSQL 7.4.3)?

can anybody help me with this problem or give me a link to a archived mail
about this topic?

kind regards,
janning


pgsql-general by date:

Previous
From: Geoff Caplan
Date:
Subject: Correct escaping of untrusted data
Next
From: Peter Eisentraut
Date:
Subject: Re: How to use as Functional Index to be used as Primary KEY