From: | Jan Wieck <JanWieck(at)Yahoo(dot)com> |
---|---|
To: | "Mikheev, Vadim" <vmikheev(at)SECTORBASE(dot)COM> |
Cc: | "'vitus(at)ice(dot)ru'" <vitus(at)ice(dot)ru>, pgsql-bugs(at)postgresql(dot)org, "'pgsql-hackers(at)postgresql(dot)org'" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [HACKERS] RE: Update is not atomic |
Date: | 2001-06-20 21:27:20 |
Message-ID: | 200106202127.f5KLRK502539@jupiter.us.greatbridge.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
Mikheev, Vadim wrote:
> > Problem can be demonstrated by following example
> >
> > create table a (a numeric primary key);
> > insert into a values (1);
> > insert into a values (2);
> > insert into a values (3);
> > insert into a values (4);
> > update a set a=a+1 where a>2;
> > ERROR: Cannot insert a duplicate key into unique index a_pkey
>
> We use uniq index for UK/PK but shouldn't. Jan?
What else can you use than an index? A "deferred until
statement end" trigger checking for duplicates? Think it'd
have a real bad performance impact.
Whatever the execution order might be, the update of '3' to
'4' will see the other '4' as existent WRT the scan commandId
and given snapshot - right? If we at the time we now fire up
the ERROR add the key, the index and heap to a list of
"possible dupkeys", that we'll check at the end of the actual
command, the above would work. The check at statement end
would have to increment the commandcounter and for each entry
do an index scan with the key, counting the number of found,
valid heap tuples.
Well, with some million rows doing a "set a = a + 1" could
run out of memory. So this would be something that'd work in
the sandbox and for non-broken applications (tm). Maybe at
some level (when we escalate the lock to a full table lock?)
we simply forget about single keys, but have a new index
access function that checks the entire index for uniqueness.
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 #
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Rainer Mager | 2001-06-20 23:21:32 | RE: Memory leak in 7.0.3 JDBC driver |
Previous Message | Mikheev, Vadim | 2001-06-20 16:43:05 | RE: Update is not atomic |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2001-06-20 21:42:49 | Re: timestamp with/without time zone |
Previous Message | Nathan Myers | 2001-06-20 20:48:04 | Re: Re: [PATCHES] Australian timezone configure option |