pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #14439: Trigger function fails with internal error after upgrade to 9.6
3+ messages / 2 participants
[nested] [flat]

* BUG #14439: Trigger function fails with internal error after upgrade to 9.6
@ 2016-11-29 14:16  max.valjanski@gmail.com
  0 siblings, 2 replies; 3+ messages in thread

From: max.valjanski@gmail.com @ 2016-11-29 14:16 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      14439
Logged by:          Maxim Valyanskiy
Email address:      max.valjanski@gmail.com
PostgreSQL version: 9.6.1
Operating system:   CentOS 6.8
Description:        

Trigger function stopped working after upgrade from 9.5 to 9.6. Upgrade was
performed via pg_upgrade.

This is that error output:

# update ab_group set name='Domain Controllerz' where id=466;
ERROR:  table row type and query-specified row type do not match
ПОДРОБНОСТИ:  Query provides a value for a dropped column at ordinal
position 6.
КОНТЕКСТ:  SQL statement "UPDATE ab_group SET name_gin =
to_tsvector('simple', NEW.name) WHERE id = NEW.id AND NEW.name <>
OLD.name"
PL/pgSQL function update_group_name_gin() line 4 at SQL statement

I tried to recreate function, made VACUUM FULL and CLUSTER for that table
and it did not fix the problem.

Here is source code for that function:

CREATE OR REPLACE FUNCTION public.update_group_name_gin()
 RETURNS trigger
 LANGUAGE plpgsql
AS $function$
            BEGIN
                IF (TG_OP = 'UPDATE') THEN
                    UPDATE ab_group SET name_gin = to_tsvector('simple',
NEW.name) WHERE id = NEW.id AND NEW.name <> OLD.name;
                    RETURN NEW;
                ELSIF (TG_OP = 'INSERT') THEN
                    UPDATE ab_group SET name_gin = to_tsvector('simple',
NEW.name) WHERE id = NEW.id;
                END IF;
                RETURN NULL;
            END;
        $function$
 


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


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

* Re: BUG #14439: Trigger function fails with internal error after upgrade to 9.6
@ 2016-11-29 14:53  Tom Lane <tgl@sss.pgh.pa.us>
  parent: max.valjanski@gmail.com
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2016-11-29 14:53 UTC (permalink / raw)
  To: max.valjanski@gmail.com; +Cc: pgsql-bugs

max.valjanski@gmail.com writes:
> # update ab_group set name='Domain Controllerz' where id=466;
> ERROR:  table row type and query-specified row type do not match
> ПОДРОБНОСТИ:  Query provides a value for a dropped column at ordinal
> position 6.
> КОНТЕКСТ:  SQL statement "UPDATE ab_group SET name_gin =
> to_tsvector('simple', NEW.name) WHERE id = NEW.id AND NEW.name <>
> OLD.name"
> PL/pgSQL function update_group_name_gin() line 4 at SQL statement

Wait a minute ... the trigger is issuing another UPDATE on its
own table?  Aren't you risking an infinite recursion?

Could we see the result of

select attname,atttypid,attnum,attisdropped from pg_attribute
where attrelid = 'ab_group'::regclass order by attnum;

Also the exact definitions of all triggers and rules for that table.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



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

* Re: BUG #14439: Trigger function fails with internal error after upgrade to 9.6
@ 2016-11-29 15:26  Tom Lane <tgl@sss.pgh.pa.us>
  parent: max.valjanski@gmail.com
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2016-11-29 15:26 UTC (permalink / raw)
  To: max.valjanski@gmail.com; +Cc: pgsql-bugs

max.valjanski@gmail.com writes:
> Trigger function stopped working after upgrade from 9.5 to 9.6. Upgrade was
> performed via pg_upgrade.

After further thought I suspect this is the same issue discovered earlier
this month:

https://www.postgresql.org/message-id/flat/83shraampf.fsf%40is-it.eu

There's a patch here:

https://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=f4d865f22

If you're not prepared to rebuild with the patch, I think the only
short-term workaround is to recreate the table without a dropped
column.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



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


end of thread, other threads:[~2016-11-29 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29 14:16 BUG #14439: Trigger function fails with internal error after upgrade to 9.6 max.valjanski@gmail.com
2016-11-29 14:53 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-11-29 15:26 ` Tom Lane <tgl@sss.pgh.pa.us>

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