Home PL/Python incompatibility between 9.4 and 9.6 when using a trigger
Reply: 0

PL/Python incompatibility between 9.4 and 9.6 when using a trigger

Stefan Badenhorst
1#
Stefan Badenhorst Published in 2018-01-12 14:15:16Z

I have created a trigger that calls a pl/python function in PostgreSQL 9.6. It works correctly.

I deployed it to a server running postgreSQL 9.4 and I'm getting an error when the trigger fires. How can I modify the code to work on both versions 9.4 and 9.6?

Detail:

[2018-01-12 14:36:07] ERROR: PL/Python functions cannot return type user_login_security_group[] 
[2018-01-12 14:36:07] Detail: PL/Python does not support conversion to arrays of row types.
[2018-01-12 14:36:07] Where: PL/Python function "publish_change"

The underlying table has a column of type user_login_security_group[]

CREATE TYPE USER_LOGIN_SECURITY_GROUP AS
(
  group_id  TEXT,
  from_date TIMESTAMP WITH TIME ZONE,
  thru_date TIMESTAMP WITH TIME ZONE
);

CREATE TABLE "user"
(
  user_login_id TEXT NOT NULL CONSTRAINT pk_user PRIMARY KEY,
  user_login_security_group   USER_LOGIN_SECURITY_GROUP []
  ...
)

CREATE FUNCTION publish_change() returns trigger
LANGUAGE plpython3u
AS $$
return None
$$;

CREATE TRIGGER trig_publish_change
after update or delete on "user"
for each row
execute procedure public.publish_change('id');
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301271 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO