Created
August 16, 2011 16:43
-
-
Save jbq/1149512 to your computer and use it in GitHub Desktop.
Test case for PLyMapping_ToTuple issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE PROCEDURAL LANGUAGE plpythonu; | |
CREATE TABLE foo ( | |
id integer not null primary key, | |
value integer not null | |
); | |
CREATE FUNCTION get_foo() RETURNS SETOF foo | |
LANGUAGE plpythonu | |
AS $$ | |
r = plpy.execute("select * from foo limit 1 FOR UPDATE") | |
if len(r) == 0: | |
return | |
id = r[0]['id'] | |
r = plpy.execute("update foo SET value = value + 1 WHERE id = %s RETURNING *" % id) | |
yield r[0] | |
$$; | |
COPY foo (id, value) FROM stdin; | |
1 1 | |
\. | |
select * from get_foo(); | |
alter table foo drop column value; | |
alter table foo add column value int; | |
update foo set value=1; | |
select * from get_foo(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment