greenplum-db/plcontainer

ERROR not support trigger

BaiShaoqi opened this issue · 2 comments

Expected behavior

 fname  | lname | username | userid
--------+-------+----------+--------
 jane   | doe   | j_doe    |      1
 john   | doe   | johnd    |      2
 rick   | smith | slash    |      4
 willem | doe   | w_doe    |      3
(4 rows)


INSERT 0 1

INSERT 0 1

  fname  | lname  | username | userid
---------+--------+----------+--------
 willem  | doe    | w_doe    |      3
 jane    | doe    | j_doe    |      1
 john    | doe    | johnd    |      2
 rick    | smith  | slash    |      4
 willem  | smith  | w_smith  |      5
 charles | darwin | beagle   |      6
(6 rows)

Actual behavior

 fname  | lname | username | userid
--------+-------+----------+--------
 willem | doe   | w_doe    |      3
 jane   | doe   | j_doe    |      1
 john   | doe   | johnd    |      2
 rick   | smith | slash    |      4
(4 rows)

ERROR:  plcontainer: PL/Container does not support triggers (plcontainer.c:91)  (seg0 10.152.10.139:25432 pid=10025) (cdbdisp.c:254)

Step to reproduce the behavior

CREATE TABLE users (
	fname text not null,
	lname text not null,
	username text,
	userid serial,
	PRIMARY KEY(lname, fname)
	) ;
INSERT INTO users (fname, lname, username) VALUES ('jane', 'doe', 'j_doe');
INSERT INTO users (fname, lname, username) VALUES ('john', 'doe', 'johnd');
INSERT INTO users (fname, lname, username) VALUES ('willem', 'doe', 'w_doe');
INSERT INTO users (fname, lname, username) VALUES ('rick', 'smith', 'slash');

CREATE FUNCTION users_insert() returns trigger AS $$
# container: plc_python_shared
if TD["new"]["fname"] == None or TD["new"]["lname"] == None:
	return "SKIP"
if TD["new"]["username"] == None:
	TD["new"]["username"] = TD["new"]["fname"][:1] + "_" + TD["new"]["lname"]
	rv = "MODIFY"
else:
	rv = None
if TD["new"]["fname"] == "william":
	TD["new"]["fname"] = TD["args"][0]
	rv = "MODIFY"
return rv'
$$ LANGUAGE plcontainer;


CREATE TRIGGER users_insert_trig BEFORE INSERT ON users FOR EACH ROW
	EXECUTE PROCEDURE users_insert ('willem');

SELECT * FROM users;

INSERT INTO users (fname, lname) VALUES ('william', 'smith');
INSERT INTO users (fname, lname, username) VALUES ('charles', 'darwin', 'beagle');

SELECT * FROM users;

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

Trigger is not supported in PL/Container yet.