mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Use generic attribute management in PL/Python
Switch the implementation of the plan and result types to generic attribute management, as described at <http://docs.python.org/extending/newtypes.html>. This modernizes and simplifies the code a bit and prepares for Python 3.1, where the old way doesn't work anymore.
This commit is contained in:
@@ -87,3 +87,21 @@ SELECT join_sequences(sequences) FROM sequences
|
||||
WHERE join_sequences(sequences) ~* '^A';
|
||||
SELECT join_sequences(sequences) FROM sequences
|
||||
WHERE join_sequences(sequences) ~* '^B';
|
||||
|
||||
|
||||
--
|
||||
-- plan and result objects
|
||||
--
|
||||
|
||||
CREATE FUNCTION result_nrows_test() RETURNS int
|
||||
AS $$
|
||||
plan = plpy.prepare("SELECT 1 UNION SELECT 2")
|
||||
plpy.info(plan.status()) # not really documented or useful
|
||||
result = plpy.execute(plan)
|
||||
if result.status() > 0:
|
||||
return result.nrows()
|
||||
else:
|
||||
return None
|
||||
$$ LANGUAGE plpythonu;
|
||||
|
||||
SELECT result_nrows_test();
|
||||
|
||||
Reference in New Issue
Block a user