Fix #126, update note about arrays

This commit is contained in:
steve-chavez
2018-05-28 13:26:18 -05:00
committed by Steve Chávez
parent 6e7a2ca26c
commit 7255f02610
+5 -1
View File
@@ -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 <https://www.postgresql.org/docs/current/static/sql-createfunction.html>`_ for more details.