From 53945b4c13d5342c3e72fcb5a04d6234b9812f44 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Wed, 2 May 2018 17:51:11 +0300 Subject: [PATCH] Remove remaining references to version-0 calling convention in docs. Support for version-0 calling convention was removed in PostgreSQL v10. Change the SPI example to use version 1 convention, so that it actually works. Author: John Naylor Discussion: https://www.postgresql.org/message-id/CAJVSVGVydmhLBdm80Rw3G8Oq5TnA7eCxUv065yoZfNfLbF1tzA@mail.gmail.com --- doc/src/sgml/plhandler.sgml | 5 ++--- doc/src/sgml/spi.sgml | 18 +++++++----------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/doc/src/sgml/plhandler.sgml b/doc/src/sgml/plhandler.sgml index 57a2a05ed2..91a8d9a5ba 100644 --- a/doc/src/sgml/plhandler.sgml +++ b/doc/src/sgml/plhandler.sgml @@ -11,9 +11,8 @@ All calls to functions that are written in a language other than the current version 1 interface for compiled - languages (this includes functions in user-defined procedural languages, - functions written in SQL, and functions using the version 0 compiled - language interface) go through a call handler + languages (this includes functions in user-defined procedural languages + and functions written in SQL) go through a call handler function for the specific language. It is the responsibility of the call handler to execute the function in a meaningful way, such as by interpreting the supplied source text. This chapter outlines diff --git a/doc/src/sgml/spi.sgml b/doc/src/sgml/spi.sgml index 9ce1270d37..0110d02e5a 100644 --- a/doc/src/sgml/spi.sgml +++ b/doc/src/sgml/spi.sgml @@ -4355,17 +4355,19 @@ INSERT INTO a SELECT * FROM a; PG_MODULE_MAGIC; #endif -int64 execq(text *sql, int cnt); +PG_FUNCTION_INFO_V1(execq); -int64 -execq(text *sql, int cnt) +Datum +execq(PG_FUNCTION_ARGS) { char *command; + int cnt; int ret; uint64 proc; /* Convert given text object to a C string */ - command = text_to_cstring(sql); + command = text_to_cstring(PG_GETARG_TEXT_PP(1)); + cnt = PG_GETARG_INT32(2); SPI_connect(); @@ -4398,16 +4400,10 @@ execq(text *sql, int cnt) SPI_finish(); pfree(command); - return (proc); + PG_RETURN_INT64(proc); } - - (This function uses call convention version 0, to make the example - easier to understand. In real applications you should use the new - version 1 interface.) - - This is how you declare the function after having compiled it into a shared library (details are in .): -- 2.40.0