Re: a few questions (and doubts) about xid

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Luca Ferrari <fluca1978(at)infinito(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: a few questions (and doubts) about xid
Date: 2007-07-27 09:11:03
Message-ID: 20070727091103.GI2550@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Luca Ferrari wrote:
> Thanks all for your comments. Just another little hint here (sorry for trivial
> questions):
>
> if (TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple)))
> {
> if (tuple->t_infomask & HEAP_IS_LOCKED)
> return true;
> if (HeapTupleHeaderGetCmax(tuple) >= GetCurrentCommandId())
> return true; /* deleted after scan started */
> else
> return false; /* deleted before scan started */
> }
>
> what does that "deleted after scan started" means? How is possible that the
> current transaction has deleted the tuple with a command higher than the one
> that is still executing?

It is possible.

> An example could clearify....

Consider an open cursor; you open it and leave it there. Then you
delete something from the table. Then you read from the cursor. The
deleted row must be in the cursor.

FK triggers have somewhat "interesting" behavior here as well. I'm not
sure if it's an issue in this particular case but they do tend to push
the limits of this stuff.

BTW "clarify" is one of these weird things about english during which
you make something "clear" instead of "clar". So you don't "clearify"
things. It just doesn't make any sense -- that's why it's english.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Weinand 2007-07-27 11:00:34 locale and performance?
Previous Message gazzag 2007-07-27 08:55:55 Re: Question about Postgres