Re: [HACKERS] RE: Getting rid of setheapoverride (was Re: [COMMITTERS] heap.c)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>, pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] RE: Getting rid of setheapoverride (was Re: [COMMITTERS] heap.c)
Date: 2000-01-17 16:29:58
Message-ID: 21052.948126598@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
>> I figured out that the cases where setheapoverride (or, now,
>> CommandCounterIncrement) were needed were the cases where the
>> heap_update might be updating a tuple created earlier in the
>> same command. pg_operator.c has some cases like that, but many of
>> the other uses of setheapoverride seem to be unnecessary.

> I thought about that this morning and suspected this may be the case,
> though I thought tuples would be visible to the same transaction
> automatically. Hard to imagine why we would not want such visibility in
> all cases.

Normally you *don't* want tuples created/updated in the current command
to be visible. Consider an UPDATE proceeding by sequential scan. As it
finds tuples it needs to update, the updated versions of those tuples
will get added to the end of the relation. Eventually the UPDATE will
reach those tuples and be scanning its own output! Thanks to the
visibility rule, it will ignore those new tuples as not-yet-visible.
Without that, something as simple as "UPDATE t SET f = f + 1" would be
an infinite loop.

CommandCounterIncrement() is like a statement boundary inside a
transaction: after you call it, you can see the effects of your
prior operation (but no one else can; it's not a commit).

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2000-01-17 16:33:07 Re: [HACKERS] RE: Getting rid of setheapoverride (was Re: [COMMITTERS] heap.c)
Previous Message Tom Lane 2000-01-17 16:22:53 Re: [HACKERS] pg_dump not in very good shape