diff --git a/api.rst b/api.rst index 779e85bcf..f0f3af22a 100644 --- a/api.rst +++ b/api.rst @@ -359,10 +359,26 @@ The client can call it by posting an object like POST /rpc/add_them HTTP/1.1 - { "a": 1, "b": 2} + { "a": 1, "b": 2 } The keys of the object match the parameter names. Note that PostgreSQL converts parameter names to lowercase unless you quote them like :sql:`CREATE FUNCTION foo("mixedCase" text) ...`. +.. 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: + + .. code:: http + + POST /rpc/native_array_func HTTP/1.1 + + { "arg": "{1,2,3}" } + + .. code:: http + + POST /rpc/json_array_func HTTP/1.1 + + { "arg": [1,2,3] } + 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.