Skip site navigation (1) Skip section navigation (2)

Re: Scanning for insert

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: James William Pye <pgsql(at)jwp(dot)name>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Scanning for insert
Date: 2006-02-27 22:44:20
Message-ID: 22889.1141080260@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
James William Pye <pgsql(at)jwp(dot)name> writes:
> The attached patch extends pg_am by adding two methods, "scan for insert" and
> "insert from scan". These methods are meant to provide an index user with the
> ability to do conditional insertions based on the results of a conclusive
> locking scan--a scan that not only finds a match, but resolves its actual
> existence(what _bt_check_unique does), and makes any necessary locks to warrant
> later insertion by a call to insertfromscan.

Is this really a good idea?  The fundamental problem I see with it is
that it takes away the index AM's ability to make any guarantees about
its locking behavior, ie, how long locks will be held or what other
operations might intervene while holding them.  It'll also require the
AM to save potentially large amounts of state between the two calls
(eg, an entire search path might be needed for GiST).  Currently any
such state can live on the stack in local variables, but that won't
work if it has to be remembered until a later AM call.  Lastly, what
happens if the caller loses control (due to elog) and never makes the
followup AM call?

> These new index interfaces are meant to provide the necessary functionality
> for doing conditional index insertions that will likely aid in any
> implementation of error logging, and other features(merge?).

If that's what you want, maybe a better answer is to simply allow
aminsert to return a uniqueness-conflict indication, rather than
raising the ereport for itself.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Martijn van OosterhoutDate: 2006-02-27 22:51:23
Subject: Re: pg_config, pg_service.conf, postgresql.conf ....
Previous:From: James William PyeDate: 2006-02-27 22:25:16
Subject: Scanning for insert

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group