Re: Array of composite types returned from python

Поиск
Список
Период
Сортировка
От Behn, Edward (EBEHN)
Тема Re: Array of composite types returned from python
Дата
Msg-id 93F16B4BD93A7840AC75EB16E9494C7B1537EB39@EXANPMB2.arinc.com
обсуждение исходный текст
Ответ на Array of composite types returned from python  ("Behn, Edward (EBEHN)" <EBEHN@arinc.com>)
Список pgsql-hackers

Attached is the patch for the code change described below:

 

Project Name : Allow return array of composites from PL/Python

 

Currently, a SQL array of non-composite variables can be returned from PL/Python code by returning a iterable object. A SQL composite value may be returned by returning a iterable or a subscriptable object. However, returning a list of objects that each represent a composite variable is not converted to an SQL array of composite variables. This code change allows that conversion to take place. This allows for smooth, elegant interface between SQL and PL/Python.

 

This is a patch against MASTER

 

The patch compiles successfully. All the standard regression tests pass. Some modifications are needed for the .out files in order for the PL/Python regression tests to pass. This is due to the fact that the current .out files expect errors when a python array of composite is converted, where my modifications expect success. All tests have been performed with both Python2 and Python3.

 

                -Ed

 

 

From: pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Behn, Edward (EBEHN)
Sent: Thursday, March 20, 2014 5:54 PM
To: pgsql-hackers@postgresql.org
Subject: [HACKERS] Array of composite types returned from python

 

I’ve endeavored to enable the return of arrays of composite types from code written in PL/Python.  It seems that this can be accomplished though a very minor change to the code:

 

On line 401 in the file src/pl/plpython/plpy_typeio.c, remove the error report “PL/Python functions cannot return type…” and replace it with the command

arg->func = PLyObject_ToComposite;

 

From all that I can see, this does exactly what I want. A python list of tuples is converted to an array of composite types in SQL.

 

I ran the main and python regression suites for both python2 and python3 with assert enabled. The only discrepancies I got were ones that were due to the output expecting an error. When I altered the .out files to the expected behavior, it matched just fine.

 

Am I missing anything, (ie memory leak, undesirable behavior elsewhere)?

             -Ed

 

 

Ed Behn / Staff Engineer / Airline and Network Services
Information Management Services
2551 Riva Road, Annapolis, MD 21401 USA
Phone: 410.266.4426 / Cell: 240.696.7443
ebehn@arinc.com
www.rockwellcollins.com

 

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: About adding an attribute to a system catalog
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Still something fishy in the fastpath lock stuff