Patch to add table function support to PL/Tcl (Todo item)
От | Karl Lehenbauer |
---|---|
Тема | Patch to add table function support to PL/Tcl (Todo item) |
Дата | |
Msg-id | 6832CE40-94A9-42A0-A54D-36CF5C6BC6AC@gmail.com обсуждение исходный текст |
Ответы |
Re: Patch to add table function support to PL/Tcl (Todo item)
|
Список | pgsql-hackers |
Project name: Add table function support to PL/Tcl (Todo item) What the patch does: This patch adds table function support (returning record and SETOF record) to PL/Tcl. This patch also updates PL/Tcl to use the Tcl object-style interface instead of the older string-style one, increasing performance. Status of the patch: The code seems to work well, but this is its first submission. Branch the patch is against: HEAD Compiles and tests successfully on FreeBSD and Mac OS X. Have not tested it with other systems but there is nothing platform specific about it. Regression tests: Passes all existing tests but there aren't many for PL/Tcl. This change removes PL/Tcl backward compatibility to Tcl version 7. Since Tcl 8 has been in production release since 1997, I felt that 13 years was long enough and PL/Tcl users linking with Tcl 7 should go ahead and upgrade. This also allowed removal of the Tcl 7 compatibility shims. More importantly, this patch extends PL/Tcl to support returning rows and sets of rows. While I studied all of the other PL languages (PL/PgSql, PL/Perl, PL/Python and PL/C) while developing this patch, it hews most closely to to approach taken by PL/PgSQL. All existing semantics for functions and triggers have been retained, requiring no changes to existing PL/Tcl code. PL/Tcl coders who want to create functions returning a record will use "return" to return results, the same as for a scalar, except that the value returned should be a list of key-value pairs ("array get" format) where the keys are `the field names and the values are the corresponding values. To return sets of rows, one needs to use the new PL/Tcl function "return_next". Return_next also accepts a list of key-value pairs, as "return" does. Typically this will be invoked as something like return_next [array get row] To return multiple rows, the function should invoke return_next multiple times (once for each row returned). As mentioned, the C implementation works like PL/PgSQL, so PL/Tcl saves up the tuples in a tuple store and then uses the SFRM_Materialize return mode to send the results back. Fields are converted to Datum during the call to return_next, so if any field names are in the list that aren't in the row or there are data conversion errors, they will be returned as a Tcl error to the caller of return_next and can be caught using Tcl's "catch", etc.
Вложения
В списке pgsql-hackers по дате отправления: