pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #5989: Assertion failure on UPDATE of big value
18+ messages / 5 participants
[nested] [flat]

* BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 14:11  Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>
  0 siblings, 2 replies; 18+ messages in thread

From: Marko Tiikkaja @ 2011-04-20 14:11 UTC (permalink / raw)
  To: pgsql-bugs


The following bug has been logged online:

Bug reference:      5989
Logged by:          Marko Tiikkaja
Email address:      marko.tiikkaja@2ndquadrant.com
PostgreSQL version: git master
Operating system:   Linux
Description:        Assertion failure on UPDATE of big value
Details: 

Test case:

=# create table foo(a int[]);
CREATE TABLE

=# insert into foo select array(select i from generate_series(1,10000) i);
INSERT 0 1

=# update foo set a = a||1;

TRAP: FailedAssertion("!(((bool) (((void*)(&(newTuple->t_self)) != ((void
*)0)) && ((&(newTuple->t_self))->ip_posid != 0))))", File: "predicate.c",
Line: 2282)

The assertion only seems to trigger if the array is big enough to be
TOASTed, but I didn't debug further to see if that's really the case.



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 14:26  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>
  1 sibling, 1 reply; 18+ messages in thread

From: Tom Lane @ 2011-04-20 14:26 UTC (permalink / raw)
  To: Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>; +Cc: pgsql-bugs; Kevin Grittner <Kevin.Grittner@wicourts.gov>

"Marko Tiikkaja" <marko.tiikkaja@2ndquadrant.com> writes:
> =# create table foo(a int[]);
> CREATE TABLE

> =# insert into foo select array(select i from generate_series(1,10000) i);
> INSERT 0 1

> =# update foo set a = a||1;

> TRAP: FailedAssertion("!(((bool) (((void*)(&(newTuple->t_self)) != ((void
> *)0)) && ((&(newTuple->t_self))->ip_posid != 0))))", File: "predicate.c",
> Line: 2282)

Reproduced here.

Why is predicate.c getting called at all when transaction_isolation is
not SERIALIZABLE?  (Although the same crash happens when it is ...)

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 14:46  Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 18+ messages in thread

From: Heikki Linnakangas @ 2011-04-20 14:46 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>; pgsql-bugs; Kevin Grittner <Kevin.Grittner@wicourts.gov>

On 20.04.2011 17:26, Tom Lane wrote:
> "Marko Tiikkaja"<marko.tiikkaja@2ndquadrant.com>  writes:
>> =# create table foo(a int[]);
>> CREATE TABLE
>
>> =# insert into foo select array(select i from generate_series(1,10000) i);
>> INSERT 0 1
>
>> =# update foo set a = a||1;
>
>> TRAP: FailedAssertion("!(((bool) (((void*)(&(newTuple->t_self)) != ((void
>> *)0))&&  ((&(newTuple->t_self))->ip_posid != 0))))", File: "predicate.c",
>> Line: 2282)
>
> Reproduced here.

> Why is predicate.c getting called at all when transaction_isolation is
> not SERIALIZABLE?  (Although the same crash happens when it is ...)

Because another serializable transaction that reads/updates the tuple 
later needs to find the predicate lock acquired by the first 
transaction, even if the transaction in the middle isn't serializable.

It's unfortunate because it imposes a performance penalty to updates 
even if serializable transactions are not used. I don't think we ever 
measured the impact of this. :-(

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 14:51  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  1 sibling, 2 replies; 18+ messages in thread

From: Tom Lane @ 2011-04-20 14:51 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; +Cc: Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>; pgsql-bugs; Kevin Grittner <Kevin.Grittner@wicourts.gov>

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> On 20.04.2011 17:26, Tom Lane wrote:
>> Why is predicate.c getting called at all when transaction_isolation is
>> not SERIALIZABLE?  (Although the same crash happens when it is ...)

> Because another serializable transaction that reads/updates the tuple 
> later needs to find the predicate lock acquired by the first 
> transaction, even if the transaction in the middle isn't serializable.

Sorry, that argument doesn't pass the sniff test.  If the transaction in
the middle isn't serializable, then it is not the same as the "first
transaction", which means that the first transaction is completed and
can no longer be holding any locks.

> It's unfortunate because it imposes a performance penalty to updates 
> even if serializable transactions are not used. I don't think we ever 
> measured the impact of this. :-(

This feature was sold to us on the grounds that it wouldn't impose any
performance penalty when not in use.  Not having bothered to measure
the performance penalty isn't passing the sniff test either.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 14:59  Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 18+ messages in thread

From: Heikki Linnakangas @ 2011-04-20 14:59 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>; pgsql-bugs; Kevin Grittner <Kevin.Grittner@wicourts.gov>

On 20.04.2011 17:51, Tom Lane wrote:
> Heikki Linnakangas<heikki.linnakangas@enterprisedb.com>  writes:
>> On 20.04.2011 17:26, Tom Lane wrote:
>>> Why is predicate.c getting called at all when transaction_isolation is
>>> not SERIALIZABLE?  (Although the same crash happens when it is ...)
>
>> Because another serializable transaction that reads/updates the tuple
>> later needs to find the predicate lock acquired by the first
>> transaction, even if the transaction in the middle isn't serializable.
>
> Sorry, that argument doesn't pass the sniff test.  If the transaction in
> the middle isn't serializable, then it is not the same as the "first
> transaction", which means that the first transaction is completed and
> can no longer be holding any locks.

There's *three* transactions here. The first one is serializable, and 
reads the tuple. The second one is not serializable, and updates it. The 
third one is serializable and updates it again.

The second transaction needs to copy the predicate lock held by the 
first transaction to the new row version, so that the third transaction 
that updates it again sees the lock.

Or, we document that any non-serializable updates will break the 
serialization protection for any other transactions accessing the same rows.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 15:03  Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 18+ messages in thread

From: Heikki Linnakangas @ 2011-04-20 15:03 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>; pgsql-bugs; Kevin Grittner <Kevin.Grittner@wicourts.gov>

On 20.04.2011 17:51, Tom Lane wrote:
> ... which means that the first transaction is completed and
> can no longer be holding any locks.

Predicate locks are held after transaction commit. They can only be 
cleaned once the xid is older than the oldest xmin among all active 
serializable transactions.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 15:08  Kevin Grittner <Kevin.Grittner@wicourts.gov>
  parent: Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>
  1 sibling, 1 reply; 18+ messages in thread

From: Kevin Grittner @ 2011-04-20 15:08 UTC (permalink / raw)
  To: Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>; pgsql-bugs

"Marko Tiikkaja" <marko.tiikkaja@2ndquadrant.com> wrote:
 
> TRAP: FailedAssertion("!(((bool) (((void*)(&(newTuple->t_self)) !=
> ((void *)0)) && ((&(newTuple->t_self))->ip_posid != 0))))", File:
> "predicate.c", Line: 2282)
 
Am investigating, and have alerted Dan, in case he hasn't noticed
this thread.
 
-Kevin



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 15:12  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  0 siblings, 0 replies; 18+ messages in thread

From: Tom Lane @ 2011-04-20 15:12 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; +Cc: Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>; pgsql-bugs; Kevin Grittner <Kevin.Grittner@wicourts.gov>

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> There's *three* transactions here. The first one is serializable, and 
> reads the tuple. The second one is not serializable, and updates it. The 
> third one is serializable and updates it again.

> The second transaction needs to copy the predicate lock held by the 
> first transaction to the new row version, so that the third transaction 
> that updates it again sees the lock.

> Or, we document that any non-serializable updates will break the 
> serialization protection for any other transactions accessing the same rows.

Hmm.  I wonder whether we need to have some sort of system-wide enable
flag for this.  Unless you can show that the overhead is negligible
(and not having bothered to measure it is definitely not sufficient...)
I'm not excited about dragging down the performance of the entire
database on the off chance that somebody somewhere might be using SSI.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 15:12  Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
  0 siblings, 3 replies; 18+ messages in thread

From: Heikki Linnakangas @ 2011-04-20 15:12 UTC (permalink / raw)
  To: pgsql-bugs

On 20.04.2011 18:08, Kevin Grittner wrote:
> "Marko Tiikkaja"<marko.tiikkaja@2ndquadrant.com>  wrote:
>
>> TRAP: FailedAssertion("!(((bool) (((void*)(&(newTuple->t_self)) !=
>> ((void *)0))&&  ((&(newTuple->t_self))->ip_posid != 0))))", File:
>> "predicate.c", Line: 2282)
>
> Am investigating, and have alerted Dan, in case he hasn't noticed
> this thread.

The immediate fix is trivial:

inline patch 1: src/backend/access/heap/heapam.c (+0/-0 lines) download inline-1.patch--- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -2859,7 +2859,7 @@ l2: * Any existing SIREAD locks on the old tuple must be linked to
the new * tuple for conflict detection purposes. */ - PredicateLockTupleRowVersionLink(relation, &oldtup, newtup); + PredicateLockTupleRowVersionLink(relation, &oldtup, heaptup); if (newbuf != buffer) LockBuffer(newbuf, BUFFER_LOCK_UNLOCK); But the question Tom raised about doing this even for non-serializable transactions is more serious.. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com ^ permalink raw reply [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 15:26  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  2 siblings, 1 reply; 18+ messages in thread

From: Tom Lane @ 2011-04-20 15:26 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; +Cc: pgsql-bugs

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> The immediate fix is trivial:

> --- a/src/backend/access/heap/heapam.c
> +++ b/src/backend/access/heap/heapam.c
> @@ -2859,7 +2859,7 @@ l2:
>           * Any existing SIREAD locks on the old tuple must be linked to 
> the new
>           * tuple for conflict detection purposes.
>           */
> -       PredicateLockTupleRowVersionLink(relation, &oldtup, newtup);
> +       PredicateLockTupleRowVersionLink(relation, &oldtup, heaptup);

Egad.  If that's it, my confidence in the amount of testing SSI has
gotten has just dropped dramatically.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 15:26  Kevin Grittner <Kevin.Grittner@wicourts.gov>
  parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  1 sibling, 0 replies; 18+ messages in thread

From: Kevin Grittner @ 2011-04-20 15:26 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>; pgsql-bugs

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> wrote:
> On 20.04.2011 17:26, Tom Lane wrote:
 
>> Why is predicate.c getting called at all when
>> transaction_isolation is not SERIALIZABLE?  (Although the same
>> crash happens when it is ...)
> 
> Because another serializable transaction that reads/updates the
> tuple later needs to find the predicate lock acquired by the
> first transaction, even if the transaction in the middle isn't
> serializable.
 
For an example of the issue, see this post:
 
http://archives.postgresql.org/pgsql-hackers/2011-02/msg00325.php
 
While all transactions there are serializable, the issue exists even
if the transaction which updates the tuple with the predicate lock
isn't serializable.
 
-Kevin



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 16:35  Kevin Grittner <Kevin.Grittner@wicourts.gov>
  parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  2 siblings, 0 replies; 18+ messages in thread

From: Kevin Grittner @ 2011-04-20 16:35 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; pgsql-bugs

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> wrote:
 
> But the question Tom raised about doing this even for
> non-serializable transactions is more serious..
 
This particular call from heapam.c went in much later than most of
the code, since we had trouble proving that anything needed to be
done there in the first place.  As such, it wasn't there during the
many benchmarks which were done along the way.  None of those showed
any performance degradation for other isolation levels due to the
SSI code.
 
Dan and I are sorting out the best way to isolate this particular
call to assess the performance impact.  We also think there should
probably be an additional test or two in the regression tests to
exercise this area.  I think we should wait for the results of
performance tests and (if warranted by benchmark results) profiling
before we start talking about possible ways to address this.  The
evils of premature optimization and all.
 
Dan came to the same conclusion a fix before seeing Heikki's post on
the issue, so it would be good get that committed.
 
More to follow, once we have benchmark results on this and a
suggested patch for regression test coverage.
 
-Kevin



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 19:16  Kevin Grittner <Kevin.Grittner@wicourts.gov>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 18+ messages in thread

From: Kevin Grittner @ 2011-04-20 19:16 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

Tom Lane <tgl@sss.pgh.pa.us> wrote:
 
> Egad.  If that's it, my confidence in the amount of testing SSI
> has gotten has just dropped dramatically.
 
If I'm reading this correctly, it would appear that nobody has
updated anything to a TOASTed value in a build against HEAD in
testing *anything* in the last two and a half months.  And the
regression tests don't include a single UPDATE to a TOASTed value
anywhere.  That seems like a significant code coverage deficiency.
 
Attached is a patch to cure the latter of these.  I'm submitting
this separately since it seems a good idea regardless of what
happens with the related SSI issue.
 
It is, of course, no excuse for making a dumb mistake like that, but
it wouldn't have survived the day on my machine or Dan's, much less
been submitted as a patch or committed, with the attached general
test of update-to-TOAST functionality in the regression tests.
 
-Kevin

Attachments:

test-update-to-toast.patch (text/plain, 1.2K) download *** a/src/test/regress/expected/update.out --- b/src/test/regress/expected/update.out *************** *** 87,90 **** ERROR: invalid reference to FROM-clause entry for table "update_test" --- 87,99 ---- LINE 1: UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a... ^ HINT: Perhaps you meant to reference the table alias "t". + -- Make sure that we can update to a TOASTed value. + UPDATE update_test SET c = repeat('x', 10000) WHERE c = 'car'; + SELECT a, b, char_length(c) FROM update_test; + a | b | char_length + -----+----+------------- + 100 | 20 | + 11 | 41 | 10000 + (2 rows) + DROP TABLE update_test; *** a/src/test/regress/sql/update.sql --- b/src/test/regress/sql/update.sql *************** *** 54,57 **** UPDATE update_test SET (a,b) = (select a,b FROM update_test where c = 'foo') --- 54,61 ---- -- to the original table name UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a = 10; + -- Make sure that we can update to a TOASTed value. + UPDATE update_test SET c = repeat('x', 10000) WHERE c = 'car'; + SELECT a, b, char_length(c) FROM update_test; + DROP TABLE update_test;
^ permalink raw reply [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 19:37  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
  0 siblings, 2 replies; 18+ messages in thread

From: Tom Lane @ 2011-04-20 19:37 UTC (permalink / raw)
  To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; pgsql-bugs

"Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
> If I'm reading this correctly, it would appear that nobody has
> updated anything to a TOASTed value in a build against HEAD in
> testing *anything* in the last two and a half months.  And the
> regression tests don't include a single UPDATE to a TOASTed value
> anywhere.  That seems like a significant code coverage deficiency.
 
> Attached is a patch to cure the latter of these.  I'm submitting
> this separately since it seems a good idea regardless of what
> happens with the related SSI issue.

Hmm, is there much regression coverage for TOAST inserts or deletes
either?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 19:39  Kevin Grittner <Kevin.Grittner@wicourts.gov>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 18+ messages in thread

From: Kevin Grittner @ 2011-04-20 19:39 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; pgsql-bugs

Tom Lane <tgl@sss.pgh.pa.us> wrote:
 
> Hmm, is there much regression coverage for TOAST inserts or
> deletes either?
 
I'll check.
 
-Kevin



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 20:12  Kevin Grittner <Kevin.Grittner@wicourts.gov>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 18+ messages in thread

From: Kevin Grittner @ 2011-04-20 20:12 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; pgsql-bugs

Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Kevin Grittner" <Kevin.Grittner@wicourts.gov> writes:
>> If I'm reading this correctly, it would appear that nobody has
>> updated anything to a TOASTed value in a build against HEAD in
>> testing *anything* in the last two and a half months.  And the
>> regression tests don't include a single UPDATE to a TOASTed value
>> anywhere.  That seems like a significant code coverage
>> deficiency.
>  
>> Attached is a patch to cure the latter of these.  I'm submitting
>> this separately since it seems a good idea regardless of what
>> happens with the related SSI issue.
> 
> Hmm, is there much regression coverage for TOAST inserts or
> deletes either?
 
There didn't appear to be.  The attached provides minimal testing of
user-facing behavior of TOAST insert, update, and delete.  It's
pretty basic, but a lot better than having no tests for this at all.
 
I can't help feeling that there should be a toast.sql test file
which reaches deeper, but I'm not exactly sure how far that would
go.
 
-Kevin

Attachments:

test-toast-dml.patch (text/plain, 5.6K) download *** a/src/test/regress/expected/delete.out --- b/src/test/regress/expected/delete.out *************** *** 1,11 **** CREATE TABLE delete_test ( id SERIAL PRIMARY KEY, ! a INT ); NOTICE: CREATE TABLE will create implicit sequence "delete_test_id_seq" for serial column "delete_test.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "delete_test_pkey" for table "delete_test" INSERT INTO delete_test (a) VALUES (10); ! INSERT INTO delete_test (a) VALUES (50); INSERT INTO delete_test (a) VALUES (100); -- allow an alias to be specified for DELETE's target table DELETE FROM delete_test AS dt WHERE dt.a > 75; --- 1,12 ---- CREATE TABLE delete_test ( id SERIAL PRIMARY KEY, ! a INT, ! b text ); NOTICE: CREATE TABLE will create implicit sequence "delete_test_id_seq" for serial column "delete_test.id" NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "delete_test_pkey" for table "delete_test" INSERT INTO delete_test (a) VALUES (10); ! INSERT INTO delete_test (a, b) VALUES (50, repeat('x', 10000)); INSERT INTO delete_test (a) VALUES (100); -- allow an alias to be specified for DELETE's target table DELETE FROM delete_test AS dt WHERE dt.a > 75; *************** *** 16,26 **** ERROR: invalid reference to FROM-clause entry for table "delete_test" LINE 1: DELETE FROM delete_test dt WHERE delete_test.a > 25; ^ HINT: Perhaps you meant to reference the table alias "dt". ! SELECT * FROM delete_test; ! id | a ! ----+---- ! 1 | 10 ! 2 | 50 (2 rows) DROP TABLE delete_test; --- 17,35 ---- LINE 1: DELETE FROM delete_test dt WHERE delete_test.a > 25; ^ HINT: Perhaps you meant to reference the table alias "dt". ! SELECT id, a, char_length(b) FROM delete_test; ! id | a | char_length ! ----+----+------------- ! 1 | 10 | ! 2 | 50 | 10000 (2 rows) + -- delete a row with a TOASTed value + DELETE FROM delete_test WHERE a > 25; + SELECT id, a, char_length(b) FROM delete_test; + id | a | char_length + ----+----+------------- + 1 | 10 | + (1 row) + DROP TABLE delete_test; *** a/src/test/regress/expected/insert.out --- b/src/test/regress/expected/insert.out *************** *** 62,65 **** select * from inserttest; --- 62,82 ---- 2 | 3 | values are fun! (7 rows) + -- + -- TOASTed value test + -- + insert into inserttest values(30, 50, repeat('x', 10000)); + select col1, col2, char_length(col3) from inserttest; + col1 | col2 | char_length + ------+------+------------- + | 3 | 7 + | 5 | 7 + | 5 | 4 + | 7 | 7 + 10 | 20 | 2 + -1 | 2 | 7 + 2 | 3 | 15 + 30 | 50 | 10000 + (8 rows) + drop table inserttest; *** a/src/test/regress/expected/update.out --- b/src/test/regress/expected/update.out *************** *** 87,90 **** ERROR: invalid reference to FROM-clause entry for table "update_test" --- 87,99 ---- LINE 1: UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a... ^ HINT: Perhaps you meant to reference the table alias "t". + -- Make sure that we can update to a TOASTed value. + UPDATE update_test SET c = repeat('x', 10000) WHERE c = 'car'; + SELECT a, b, char_length(c) FROM update_test; + a | b | char_length + -----+----+------------- + 100 | 20 | + 11 | 41 | 10000 + (2 rows) + DROP TABLE update_test; *** a/src/test/regress/sql/delete.sql --- b/src/test/regress/sql/delete.sql *************** *** 1,10 **** CREATE TABLE delete_test ( id SERIAL PRIMARY KEY, ! a INT ); INSERT INTO delete_test (a) VALUES (10); ! INSERT INTO delete_test (a) VALUES (50); INSERT INTO delete_test (a) VALUES (100); -- allow an alias to be specified for DELETE's target table --- 1,11 ---- CREATE TABLE delete_test ( id SERIAL PRIMARY KEY, ! a INT, ! b text ); INSERT INTO delete_test (a) VALUES (10); ! INSERT INTO delete_test (a, b) VALUES (50, repeat('x', 10000)); INSERT INTO delete_test (a) VALUES (100); -- allow an alias to be specified for DELETE's target table *************** *** 14,19 **** DELETE FROM delete_test AS dt WHERE dt.a > 75; -- to be referenced DELETE FROM delete_test dt WHERE delete_test.a > 25; ! SELECT * FROM delete_test; DROP TABLE delete_test; --- 15,25 ---- -- to be referenced DELETE FROM delete_test dt WHERE delete_test.a > 25; ! SELECT id, a, char_length(b) FROM delete_test; ! ! -- delete a row with a TOASTed value ! DELETE FROM delete_test WHERE a > 25; ! ! SELECT id, a, char_length(b) FROM delete_test; DROP TABLE delete_test; *** a/src/test/regress/sql/insert.sql --- b/src/test/regress/sql/insert.sql *************** *** 28,31 **** insert into inserttest values(10, 20, '40'), (-1, 2, DEFAULT), --- 28,38 ---- select * from inserttest; + -- + -- TOASTed value test + -- + insert into inserttest values(30, 50, repeat('x', 10000)); + + select col1, col2, char_length(col3) from inserttest; + drop table inserttest; *** a/src/test/regress/sql/update.sql --- b/src/test/regress/sql/update.sql *************** *** 54,57 **** UPDATE update_test SET (a,b) = (select a,b FROM update_test where c = 'foo') --- 54,61 ---- -- to the original table name UPDATE update_test AS t SET b = update_test.b + 10 WHERE t.a = 10; + -- Make sure that we can update to a TOASTed value. + UPDATE update_test SET c = repeat('x', 10000) WHERE c = 'car'; + SELECT a, b, char_length(c) FROM update_test; + DROP TABLE update_test;
^ permalink raw reply [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-20 21:16  Kevin Grittner <Kevin.Grittner@wicourts.gov>
  parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
  2 siblings, 1 reply; 18+ messages in thread

From: Kevin Grittner @ 2011-04-20 21:16 UTC (permalink / raw)
  To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; pgsql-bugs

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> wrote:
 
> The immediate fix is trivial:
> 
> [patch changing one line of code]
 
I have confirmed that without this patch the new regression tests I
have proposed will fail, and with the patch they succeed.  I have
also confirmed that the isolation test suite continues to succeed
with this patch applied.
 
-Kevin



^ permalink  raw  reply  [nested|flat] 18+ messages in thread

* Re: BUG #5989: Assertion failure on UPDATE of big value
@ 2011-04-25 13:48  Robert Haas <robertmhaas@gmail.com>
  parent: Kevin Grittner <Kevin.Grittner@wicourts.gov>
  0 siblings, 0 replies; 18+ messages in thread

From: Robert Haas @ 2011-04-25 13:48 UTC (permalink / raw)
  To: Kevin Grittner <Kevin.Grittner@wicourts.gov>; +Cc: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; pgsql-bugs

On Wed, Apr 20, 2011 at 5:16 PM, Kevin Grittner
<Kevin.Grittner@wicourts.gov> wrote:
> Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> wrote:
>
>> The immediate fix is trivial:
>>
>> [patch changing one line of code]
>
> I have confirmed that without this patch the new regression tests I
> have proposed will fail, and with the patch they succeed.  I have
> also confirmed that the isolation test suite continues to succeed
> with this patch applied.

I committed the one-line fix, and the additional regression tests.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



^ permalink  raw  reply  [nested|flat] 18+ messages in thread


end of thread, other threads:[~2011-04-25 13:48 UTC | newest]

Thread overview: 18+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20 14:11 BUG #5989: Assertion failure on UPDATE of big value Marko Tiikkaja <marko.tiikkaja@2ndquadrant.com>
2011-04-20 14:26 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-04-20 14:46   ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
2011-04-20 14:51     ` Tom Lane <tgl@sss.pgh.pa.us>
2011-04-20 14:59       ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
2011-04-20 15:12         ` Tom Lane <tgl@sss.pgh.pa.us>
2011-04-20 15:03       ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
2011-04-20 15:26     ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-04-20 15:08 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-04-20 15:12   ` Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
2011-04-20 15:26     ` Tom Lane <tgl@sss.pgh.pa.us>
2011-04-20 19:16       ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-04-20 19:37         ` Tom Lane <tgl@sss.pgh.pa.us>
2011-04-20 19:39           ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-04-20 20:12           ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-04-20 16:35     ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-04-20 21:16     ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-04-25 13:48       ` Robert Haas <robertmhaas@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox