From 7255f026108c242e5c8ebe0cbda3d8bbc6295462 Mon Sep 17 00:00:00 2001 From: steve-chavez Date: Fri, 25 May 2018 12:18:32 -0500 Subject: [PATCH] Fix #126, update note about arrays --- api.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/api.rst b/api.rst index 979874e56..270ccfd0f 100644 --- a/api.rst +++ b/api.rst @@ -533,7 +533,7 @@ The function parameter names match the JSON object keys in the POST case, for th .. note:: - We recommend using function arguments of type json to accept arrays from the client. To pass a PostgreSQL native array you'll need to quote it as a string: + For versions prior to PostgreSQL 10, to pass a PostgreSQL native array you'll need to quote it as a string: .. code:: http @@ -541,12 +541,16 @@ The function parameter names match the JSON object keys in the POST case, for th { "arg": "{1,2,3}" } + In these versions we recommend using function arguments of type json to accept arrays from the client: + .. code:: http POST /rpc/json_array_func HTTP/1.1 { "arg": [1,2,3] } + Starting from PostgreSQL 10, a json array from the client gets mapped normally to a PostgreSQL native array. + PostgreSQL has four procedural languages that are part of the core distribution: PL/pgSQL, PL/Tcl, PL/Perl, and PL/Python. There are many other procedural languages distributed as additional extensions. Also, plain SQL can be used to write functions (as shown in the example above). By default, a function is executed with the privileges of the user who calls it. This means that the user has to have all permissions to do the operations the procedure performs. Another option is to define the function with with the :code:`SECURITY DEFINER` option. Then only one permission check will take place, the permission to call the function, and the operations in the function will have the authority of the user who owns the function itself. See `PostgreSQL documentation `_ for more details.