Commit 34036c86 authored by Neil Conway's avatar Neil Conway

More minor SGML improvements for xfunc.sgml, including making some

titles more concise. (We usually don't need to repeat the name of a
section in the title of one of its subsections.)
parent ebf07164
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.119 2006/11/23 05:28:18 neilc Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.120 2006/11/23 05:43:32 neilc Exp $ -->
<sect1 id="xfunc"> <sect1 id="xfunc">
<title>User-Defined Functions</title> <title>User-Defined Functions</title>
...@@ -1587,7 +1587,7 @@ memcpy(destination-&gt;data, buffer, 40); ...@@ -1587,7 +1587,7 @@ memcpy(destination-&gt;data, buffer, 40);
</sect2> </sect2>
<sect2> <sect2>
<title>Calling Conventions Version 0 for C-Language Functions</title> <title>Version 0 Calling Conventions</title>
<para> <para>
We present the <quote>old style</quote> calling convention first &mdash; although We present the <quote>old style</quote> calling convention first &mdash; although
...@@ -1651,7 +1651,7 @@ copytext(text *t) ...@@ -1651,7 +1651,7 @@ copytext(text *t)
*/ */
memcpy((void *) VARDATA(new_t), /* destination */ memcpy((void *) VARDATA(new_t), /* destination */
(void *) VARDATA(t), /* source */ (void *) VARDATA(t), /* source */
VARSIZE(t)-VARHDRSZ); /* how many bytes */ VARSIZE(t) - VARHDRSZ); /* how many bytes */
return new_t; return new_t;
} }
...@@ -1662,9 +1662,9 @@ concat_text(text *arg1, text *arg2) ...@@ -1662,9 +1662,9 @@ concat_text(text *arg1, text *arg2)
text *new_text = (text *) palloc(new_text_size); text *new_text = (text *) palloc(new_text_size);
VARATT_SIZEP(new_text) = new_text_size; VARATT_SIZEP(new_text) = new_text_size;
memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ); memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1) - VARHDRSZ);
memcpy(VARDATA(new_text) + (VARSIZE(arg1)-VARHDRSZ), memcpy(VARDATA(new_text) + (VARSIZE(arg1) - VARHDRSZ),
VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ); VARDATA(arg2), VARSIZE(arg2) - VARHDRSZ);
return new_text; return new_text;
} }
</programlisting> </programlisting>
...@@ -1735,7 +1735,7 @@ CREATE FUNCTION concat_text(text, text) RETURNS text ...@@ -1735,7 +1735,7 @@ CREATE FUNCTION concat_text(text, text) RETURNS text
</sect2> </sect2>
<sect2> <sect2>
<title>Calling Conventions Version 1 for C-Language Functions</title> <title>Version 1 Calling Conventions</title>
<para> <para>
The version-1 calling convention relies on macros to suppress most The version-1 calling convention relies on macros to suppress most
...@@ -1837,7 +1837,7 @@ copytext(PG_FUNCTION_ARGS) ...@@ -1837,7 +1837,7 @@ copytext(PG_FUNCTION_ARGS)
*/ */
memcpy((void *) VARDATA(new_t), /* destination */ memcpy((void *) VARDATA(new_t), /* destination */
(void *) VARDATA(t), /* source */ (void *) VARDATA(t), /* source */
VARSIZE(t)-VARHDRSZ); /* how many bytes */ VARSIZE(t) - VARHDRSZ); /* how many bytes */
PG_RETURN_TEXT_P(new_t); PG_RETURN_TEXT_P(new_t);
} }
...@@ -1852,9 +1852,9 @@ concat_text(PG_FUNCTION_ARGS) ...@@ -1852,9 +1852,9 @@ concat_text(PG_FUNCTION_ARGS)
text *new_text = (text *) palloc(new_text_size); text *new_text = (text *) palloc(new_text_size);
VARATT_SIZEP(new_text) = new_text_size; VARATT_SIZEP(new_text) = new_text_size;
memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)-VARHDRSZ); memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1) - VARHDRSZ);
memcpy(VARDATA(new_text) + (VARSIZE(arg1)-VARHDRSZ), memcpy(VARDATA(new_text) + (VARSIZE(arg1) - VARHDRSZ),
VARDATA(arg2), VARSIZE(arg2)-VARHDRSZ); VARDATA(arg2), VARSIZE(arg2) - VARHDRSZ);
PG_RETURN_TEXT_P(new_text); PG_RETURN_TEXT_P(new_text);
} }
</programlisting> </programlisting>
...@@ -2261,7 +2261,7 @@ include $(PGXS) ...@@ -2261,7 +2261,7 @@ include $(PGXS)
<sect2> <sect2>
<title>Composite-Type Arguments in C-Language Functions</title> <title>Composite-Type Arguments</title>
<para> <para>
Composite types do not have a fixed layout like C structures. Composite types do not have a fixed layout like C structures.
...@@ -2366,7 +2366,7 @@ CREATE FUNCTION c_overpaid(emp, integer) RETURNS boolean ...@@ -2366,7 +2366,7 @@ CREATE FUNCTION c_overpaid(emp, integer) RETURNS boolean
</sect2> </sect2>
<sect2> <sect2>
<title>Returning Rows (Composite Types) from C-Language Functions</title> <title>Returning Rows (Composite Types)</title>
<para> <para>
To return a row or composite-type value from a C-language To return a row or composite-type value from a C-language
...@@ -2517,7 +2517,7 @@ HeapTupleGetDatum(HeapTuple tuple) ...@@ -2517,7 +2517,7 @@ HeapTupleGetDatum(HeapTuple tuple)
</sect2> </sect2>
<sect2 id="xfunc-c-return-set"> <sect2 id="xfunc-c-return-set">
<title>Returning Sets from C-Language Functions</title> <title>Returning Sets</title>
<para> <para>
There is also a special API that provides support for returning There is also a special API that provides support for returning
...@@ -2910,30 +2910,30 @@ CREATE FUNCTION make_array(anyelement) RETURNS anyarray ...@@ -2910,30 +2910,30 @@ CREATE FUNCTION make_array(anyelement) RETURNS anyarray
</para> </para>
</sect2> </sect2>
<sect2> <sect2>
<title>Shared Memory and LWLocks in C-Language Functions</title> <title>Shared Memory and LWLocks</title>
<para> <para>
Add-ins may reserve LWLocks and an allocation of shared memory on server Add-ins may reserve LWLocks and an allocation of shared memory on server
startup. The add-in's shared library must be preloaded, by specifying startup. The add-in's shared library must be preloaded by specifying
it in it in
<xref linkend="guc-shared-preload-libraries"><indexterm><primary>shared-preload-libraries</></>, <xref linkend="guc-shared-preload-libraries"><indexterm><primary>shared-preload-libraries</></>.
and the shared memory must be reserved by calling: Shared memory is reserved by calling:
<programlisting> <programlisting>
void RequestAddinShmemSpace(int size) void RequestAddinShmemSpace(int size)
</programlisting> </programlisting>
from your <function>_PG_init</> function. from your <function>_PG_init</> function.
</para> </para>
<para> <para>
LWLocks are reserved by calling: LWLocks are reserved by calling:
<programlisting> <programlisting>
void RequestAddinLWLocks(int n) void RequestAddinLWLocks(int n)
</programlisting> </programlisting>
from <function>_PG_init</>. from <function>_PG_init</>.
</para> </para>
<para> <para>
To avoid possible race-conditions, each backend should use the LWLock To avoid possible race-conditions, each backend should use the LWLock
<function>AddinShmemInitLock</> when connecting to and initializing <function>AddinShmemInitLock</> when connecting to and initializing
its allocation of shared memory, as shown here: its allocation of shared memory, as shown here:
<programlisting> <programlisting>
static mystruct *ptr = NULL; static mystruct *ptr = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment