Re: Replication Bundled with Main Source.

From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Unihost Web Hosting <tony(at)unihost(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: Replication Bundled with Main Source.
Date: 2003-10-10 23:15:37
Message-ID: 3F873D99.7020504@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Bruce Momjian wrote:
> Jan Wieck wrote:
>> Unfortunately I don't think it'll get there ever. There is a fundamental
>> design flaw in the system that is not fixable (there are multiple, but
>
> I was wondering about this. It seems to be part of our existing problem
> with handling unique contraints during the query, rather than at query
> end or transaction end:
>
> [...]
>
> Another idea would be to only queue up the unique constraint failures,
> and re-check on transaction commit --- that way, you only have a queue
> when you have a possible unique constraint violation, and you re-check
> at the end.
>

_That_ actually is _the_ idea I was missing!

During index insert I think we know everything that needs to be known.
We know the index in question, which definitely leads to the relation in
question. And we know the CTID of the new heap tuple containing the key
values in conflict. IIRC that is enough to schedule some sort of
[DEFERRED] AFTER INSERT trigger ... one more of these generic C monsters.

Some sort of, because it's call interface might be a bit different. We
won't have a pg_trigger row for it anywhere. But since it'd be a generic
function for all index dupkey checks, I wouldn't mind much to hardwire
it into the trigger queue.

The trigger actually only needs to do a

SELECT 1 FROM <rel> WHHERE <full qualification>

That over SPI_execp() with a tupcount of 2 and it'll be it. Maybe it
needs to do it FOR UPDATE to have the correct visibility and locking,
but that's a minor implementation detail.

Cool!

Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #

In response to

Browse pgsql-general by date

  From Date Subject
Next Message elein 2003-10-10 23:53:55 Re: int1? types?
Previous Message Sean Chittenden 2003-10-10 22:59:24 Re: go for a script! / ex: PostgreSQL vs. MySQL