From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Andreas Kretschmer <akretschmer(at)spamfence(dot)net> |
Cc: | pgsql novice <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: plpgsql merge func question |
Date: | 2013-12-21 03:11:24 |
Message-ID: | CAHyXU0yv6BBQePEmEGJOO5e1php3n+=0uw5mq0F+Qa0KGJytdA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Friday, December 20, 2013, Merlin Moncure wrote:
> On Fri, Dec 20, 2013 at 6:42 AM, Andreas Kretschmer
> <akretschmer(at)spamfence(dot)net <javascript:;>> wrote:
> > Matthias Leopold <matthias(at)aic(dot)at <javascript:;>> wrote:
> >
> >> hi,
> >>
> >> i tried to write a merge function in plpgsql, which is derived from the
> >> example in the docs (Example 38-2 in
> >>
> http://www.postgresql.org/docs/8.4/static/plpgsql-control-structures.html
> ).
> >> Code is below. This works fine as long as entries in count_table have
> >> todays date in "datum". when i have older entries the function "locks
> >> up" (doesn't return, server has 100% cpu). i'm a plpgsql novice. can
> >> someone explain why this happens? related question: i didn't find a way
> >
> > Can't reproduce, works for me.
>
> Almost certainly a non-'unique_violation' exception is being thrown
> (perhaps from a dependent trigger). In a loop like that there should
> always be a handler of last resort. I bitterly griped about this
> example a few years back (search the archives). TBH, many times I've
> wished that caught-but-unhandled exceptions were re-thrown by default.
>
> Unless high concurrency is needed, for merge functionality it makes a
> lot more sense to just lock the table before the insert instead of
> rigging a loop.
>
>
Anctually, I had it messed up in my head...uncaught exceptions are not
supressed. What might be happening is an unguarded trigger...as with
http://www.spinics.net/lists/pgsql/msg112560.html. heh
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Matthias Leopold | 2013-12-23 13:23:20 | Re: plpgsql merge func question |
Previous Message | Merlin Moncure | 2013-12-20 20:03:59 | Re: plpgsql merge func question |