1
- <!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.119 2006/11/23 05:28:18 neilc Exp $ -->
1
+ <!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.120 2006/11/23 05:43:32 neilc Exp $ -->
2
2
3
3
<sect1 id="xfunc">
4
4
<title>User-Defined Functions</title>
@@ -1587,7 +1587,7 @@ memcpy(destination->data, buffer, 40);
1587
1587
</sect2>
1588
1588
1589
1589
<sect2>
1590
- <title>Calling Conventions Version 0 for C-Language Functions </title>
1590
+ <title>Version 0 Calling Conventions </title>
1591
1591
1592
1592
<para>
1593
1593
We present the <quote>old style</quote> calling convention first — although
@@ -1651,7 +1651,7 @@ copytext(text *t)
1651
1651
*/
1652
1652
memcpy((void *) VARDATA(new_t), /* destination */
1653
1653
(void *) VARDATA(t), /* source */
1654
- VARSIZE(t)- VARHDRSZ); /* how many bytes */
1654
+ VARSIZE(t) - VARHDRSZ); /* how many bytes */
1655
1655
return new_t;
1656
1656
}
1657
1657
@@ -1662,9 +1662,9 @@ concat_text(text *arg1, text *arg2)
1662
1662
text *new_text = (text *) palloc(new_text_size);
1663
1663
1664
1664
VARATT_SIZEP(new_text) = new_text_size;
1665
- memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)- VARHDRSZ);
1666
- memcpy(VARDATA(new_text) + (VARSIZE(arg1)- VARHDRSZ),
1667
- VARDATA(arg2), VARSIZE(arg2)- VARHDRSZ);
1665
+ memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1) - VARHDRSZ);
1666
+ memcpy(VARDATA(new_text) + (VARSIZE(arg1) - VARHDRSZ),
1667
+ VARDATA(arg2), VARSIZE(arg2) - VARHDRSZ);
1668
1668
return new_text;
1669
1669
}
1670
1670
</programlisting>
@@ -1735,7 +1735,7 @@ CREATE FUNCTION concat_text(text, text) RETURNS text
1735
1735
</sect2>
1736
1736
1737
1737
<sect2>
1738
- <title>Calling Conventions Version 1 for C-Language Functions </title>
1738
+ <title>Version 1 Calling Conventions </title>
1739
1739
1740
1740
<para>
1741
1741
The version-1 calling convention relies on macros to suppress most
@@ -1837,7 +1837,7 @@ copytext(PG_FUNCTION_ARGS)
1837
1837
*/
1838
1838
memcpy((void *) VARDATA(new_t), /* destination */
1839
1839
(void *) VARDATA(t), /* source */
1840
- VARSIZE(t)- VARHDRSZ); /* how many bytes */
1840
+ VARSIZE(t) - VARHDRSZ); /* how many bytes */
1841
1841
PG_RETURN_TEXT_P(new_t);
1842
1842
}
1843
1843
@@ -1852,9 +1852,9 @@ concat_text(PG_FUNCTION_ARGS)
1852
1852
text *new_text = (text *) palloc(new_text_size);
1853
1853
1854
1854
VARATT_SIZEP(new_text) = new_text_size;
1855
- memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1)- VARHDRSZ);
1856
- memcpy(VARDATA(new_text) + (VARSIZE(arg1)- VARHDRSZ),
1857
- VARDATA(arg2), VARSIZE(arg2)- VARHDRSZ);
1855
+ memcpy(VARDATA(new_text), VARDATA(arg1), VARSIZE(arg1) - VARHDRSZ);
1856
+ memcpy(VARDATA(new_text) + (VARSIZE(arg1) - VARHDRSZ),
1857
+ VARDATA(arg2), VARSIZE(arg2) - VARHDRSZ);
1858
1858
PG_RETURN_TEXT_P(new_text);
1859
1859
}
1860
1860
</programlisting>
@@ -2261,7 +2261,7 @@ include $(PGXS)
2261
2261
2262
2262
2263
2263
<sect2>
2264
- <title>Composite-Type Arguments in C-Language Functions </title>
2264
+ <title>Composite-Type Arguments</title>
2265
2265
2266
2266
<para>
2267
2267
Composite types do not have a fixed layout like C structures.
@@ -2366,7 +2366,7 @@ CREATE FUNCTION c_overpaid(emp, integer) RETURNS boolean
2366
2366
</sect2>
2367
2367
2368
2368
<sect2>
2369
- <title>Returning Rows (Composite Types) from C-Language Functions </title>
2369
+ <title>Returning Rows (Composite Types)</title>
2370
2370
2371
2371
<para>
2372
2372
To return a row or composite-type value from a C-language
@@ -2517,7 +2517,7 @@ HeapTupleGetDatum(HeapTuple tuple)
2517
2517
</sect2>
2518
2518
2519
2519
<sect2 id="xfunc-c-return-set">
2520
- <title>Returning Sets from C-Language Functions </title>
2520
+ <title>Returning Sets</title>
2521
2521
2522
2522
<para>
2523
2523
There is also a special API that provides support for returning
@@ -2910,30 +2910,30 @@ CREATE FUNCTION make_array(anyelement) RETURNS anyarray
2910
2910
</para>
2911
2911
</sect2>
2912
2912
<sect2>
2913
- <title>Shared Memory and LWLocks in C-Language Functions </title>
2913
+ <title>Shared Memory and LWLocks</title>
2914
2914
2915
2915
<para>
2916
2916
Add-ins may reserve LWLocks and an allocation of shared memory on server
2917
- startup. The add-in's shared library must be preloaded, by specifying
2917
+ startup. The add-in's shared library must be preloaded by specifying
2918
2918
it in
2919
- <xref linkend="guc-shared-preload-libraries"><indexterm><primary>shared-preload-libraries</></>,
2920
- and the shared memory must be reserved by calling:
2919
+ <xref linkend="guc-shared-preload-libraries"><indexterm><primary>shared-preload-libraries</></>.
2920
+ Shared memory is reserved by calling:
2921
2921
<programlisting>
2922
2922
void RequestAddinShmemSpace(int size)
2923
2923
</programlisting>
2924
2924
from your <function>_PG_init</> function.
2925
2925
</para>
2926
2926
<para>
2927
- LWLocks are reserved by calling:
2927
+ LWLocks are reserved by calling:
2928
2928
<programlisting>
2929
2929
void RequestAddinLWLocks(int n)
2930
2930
</programlisting>
2931
- from <function>_PG_init</>.
2931
+ from <function>_PG_init</>.
2932
2932
</para>
2933
2933
<para>
2934
- To avoid possible race-conditions, each backend should use the LWLock
2935
- <function>AddinShmemInitLock</> when connecting to and initializing
2936
- its allocation of shared memory, as shown here:
2934
+ To avoid possible race-conditions, each backend should use the LWLock
2935
+ <function>AddinShmemInitLock</> when connecting to and initializing
2936
+ its allocation of shared memory, as shown here:
2937
2937
<programlisting>
2938
2938
static mystruct *ptr = NULL;
2939
2939
0 commit comments