Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d859b17

Browse files
committed
Restructure CREATE FUNCTION "NOTES" section to be shorter; move items
into proper sections, per suggestion from Tom.
1 parent 77e0d7b commit d859b17

File tree

1 file changed

+58
-58
lines changed

1 file changed

+58
-58
lines changed

doc/src/sgml/ref/create_function.sgml

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/create_function.sgml,v 1.91 2010/02/25 22:24:00 momjian Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/create_function.sgml,v 1.92 2010/03/03 03:14:08 momjian Exp $
33
-->
44

55
<refentry id="SQL-CREATEFUNCTION">
@@ -46,6 +46,10 @@ CREATE [ OR REPLACE ] FUNCTION
4646
<command>CREATE FUNCTION</command> defines a new function.
4747
<command>CREATE OR REPLACE FUNCTION</command> will either create a
4848
new function, or replace an existing definition.
49+
To be able to define a function, the user must have the
50+
<literal>USAGE</literal> privilege on the language.
51+
</para>
52+
4953
</para>
5054

5155
<para>
@@ -69,6 +73,14 @@ CREATE [ OR REPLACE ] FUNCTION
6973
<literal>OUT</> parameters except by dropping the function.)
7074
</para>
7175

76+
<para>
77+
When <command>CREATE OR REPLACE FUNCTION</> is used to replace an
78+
existing function, the ownership and permissions of the function
79+
do not change. All other function properties are assigned the
80+
values specified or implied in the command. You must own the function
81+
to replace it (this includes being a member of the owning role).
82+
</para>
83+
7284
<para>
7385
If you drop and then recreate a function, the new function is not
7486
the same entity as the old; you will have to drop existing rules, views,
@@ -400,6 +412,18 @@ CREATE [ OR REPLACE ] FUNCTION
400412
the parameter as the value to be applied when the function is entered.
401413
</para>
402414

415+
<para>
416+
If a <literal>SET</> clause is attached to a function, then
417+
the effects of a <command>SET LOCAL</> command executed inside the
418+
function for the same variable are restricted to the function: the
419+
configuration parameter's prior value is still restored at function exit.
420+
However, an ordinary
421+
<command>SET</> command (without <literal>LOCAL</>) overrides the
422+
<literal>SET</> clause, much as it would do for a previous <command>SET
423+
LOCAL</> command: the effects of such a command will persist after
424+
function exit, unless the current transaction is rolled back.
425+
</para>
426+
403427
<para>
404428
See <xref linkend="sql-set" endterm="sql-set-title"> and
405429
<xref linkend="runtime-config">
@@ -417,6 +441,15 @@ CREATE [ OR REPLACE ] FUNCTION
417441
language. It can be an internal function name, the path to an
418442
object file, an SQL command, or text in a procedural language.
419443
</para>
444+
445+
<para>
446+
It is often helpful to use dollar quoting (see <xref
447+
linkend="sql-syntax-dollar-quoting">) to write the function definition
448+
string, rather than the normal single quote syntax. Without dollar
449+
quoting, any single quotes or backslashes in the function definition must
450+
be escaped by doubling them.
451+
</para>
452+
420453
</listitem>
421454
</varlistentry>
422455

@@ -436,6 +469,14 @@ CREATE [ OR REPLACE ] FUNCTION
436469
language source code. If the link symbol is omitted, it is assumed
437470
to be the same as the name of the SQL function being defined.
438471
</para>
472+
473+
<para>
474+
When repeated <command>CREATE FUNCTION</command> calls refer to
475+
the same object file, the file is only loaded once per session.
476+
To unload and
477+
reload the file (perhaps during development), start a new session.
478+
</para>
479+
439480
</listitem>
440481
</varlistentry>
441482

@@ -479,23 +520,13 @@ CREATE [ OR REPLACE ] FUNCTION
479520

480521
</refsect1>
481522

482-
<refsect1 id="sql-createfunction-notes">
483-
<title>Notes</title>
484-
485-
<para>
486-
Refer to <xref linkend="xfunc"> for further information on writing
487-
functions.
488-
</para>
523+
<para>
524+
Refer to <xref linkend="xfunc"> for further information on writing
525+
functions.
526+
</para>
489527

490-
<para>
491-
The full <acronym>SQL</acronym> type syntax is allowed for
492-
input arguments and return value. However, some details of the
493-
type specification (e.g., the precision field for
494-
type <type>numeric</type>) are the responsibility of the
495-
underlying function implementation and are silently swallowed
496-
(i.e., not recognized or
497-
enforced) by the <command>CREATE FUNCTION</command> command.
498-
</para>
528+
<refsect1 id="sql-createfunction-overloading">
529+
<title>Overloading</title>
499530

500531
<para>
501532
<productname>PostgreSQL</productname> allows function
@@ -529,50 +560,19 @@ CREATE FUNCTION foo(int, int default 42) ...
529560
function should be called.
530561
</para>
531562

532-
<para>
533-
When repeated <command>CREATE FUNCTION</command> calls refer to
534-
the same object file, the file is only loaded once per session.
535-
To unload and
536-
reload the file (perhaps during development), start a new session.
537-
</para>
538-
539-
<para>
540-
Use <xref linkend="sql-dropfunction"
541-
endterm="sql-dropfunction-title"> to remove user-defined
542-
functions.
543-
</para>
544-
545-
<para>
546-
It is often helpful to use dollar quoting (see <xref
547-
linkend="sql-syntax-dollar-quoting">) to write the function definition
548-
string, rather than the normal single quote syntax. Without dollar
549-
quoting, any single quotes or backslashes in the function definition must
550-
be escaped by doubling them.
551-
</para>
552-
553-
<para>
554-
If a <literal>SET</> clause is attached to a function, then
555-
the effects of a <command>SET LOCAL</> command executed inside the
556-
function for the same variable are restricted to the function: the
557-
configuration parameter's prior value is still restored at function exit.
558-
However, an ordinary
559-
<command>SET</> command (without <literal>LOCAL</>) overrides the
560-
<literal>SET</> clause, much as it would do for a previous <command>SET
561-
LOCAL</> command: the effects of such a command will persist after
562-
function exit, unless the current transaction is rolled back.
563-
</para>
563+
</refsect1>
564564

565-
<para>
566-
To be able to define a function, the user must have the
567-
<literal>USAGE</literal> privilege on the language.
568-
</para>
565+
<refsect1 id="sql-createfunction-notes">
566+
<title>Notes</title>
569567

570568
<para>
571-
When <command>CREATE OR REPLACE FUNCTION</> is used to replace an
572-
existing function, the ownership and permissions of the function
573-
do not change. All other function properties are assigned the
574-
values specified or implied in the command. You must own the function
575-
to replace it (this includes being a member of the owning role).
569+
The full <acronym>SQL</acronym> type syntax is allowed for
570+
input arguments and return value. However, some details of the
571+
type specification (e.g., the precision field for
572+
type <type>numeric</type>) are the responsibility of the
573+
underlying function implementation and are silently swallowed
574+
(i.e., not recognized or
575+
enforced) by the <command>CREATE FUNCTION</command> command.
576576
</para>
577577

578578
<para>

0 commit comments

Comments
 (0)