Identify primary key in simple/updatable view - Mailing list pgsql-general

From Lionel Elie Mamane
Subject Identify primary key in simple/updatable view
Date
Msg-id 20130802151811.GD6816@capsaicin.mamane.lu
Whole thread Raw
Responses Re: Identify primary key in simple/updatable view  (Andrew Tipton <andrew@kiwidrew.com>)
Re: Identify primary key in simple/updatable view  (Richard Broersma <richard.broersma@gmail.com>)
List pgsql-general
Now that PostgreSQL has updatable views, users (of LibreOffice /
native PostgreSQL drivers) want to use them... LibreOffice needs a
primary key to "locate" updates (that is, construct the WHERE clause
of an UPDATE or DELETE).

How can the driver automatically identify the view columns that
correspond to the primary key of the underlying table (and more
generally the same for keys and indexes)? For "simple" views. Without
parsing the SQL that defines the view (unless libpq will serve me a
parse tree? Didn't think so.).

For tables, it does that by reading from pg_constraint, but to use
that for views, I'd need to parse the SQL, track renamed columns,
etc.

Thanks in advance for your precious help,

--
Lionel


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Add a NOT NULL column with default only during add
Next
From: Kevin Grittner
Date:
Subject: Re: Fastest Index/Algorithm to find similar sentences