Skip to content

Commit a96a1d6

Browse files
committed
Doc: improve xfunc-c-type-table.
List types numeric and timestamptz, which don't seem to have ever been included here. Restore bigint, which was no-doubt-accidentally deleted in v12. Fix some errors, or at least obsolete usages (nobody declares float arguments as "float8*" anymore, even though they might be that under the hood). Re-alphabetize. Remove the seeming claim that this is a complete list of built-in types. Per question from Oskar Stenberg. Discussion: https://postgr.es/m/HE1PR03MB2971DE2527ECE1E99D6C19A8F96E9@HE1PR03MB2971.eurprd03.prod.outlook.com
1 parent 9acea52 commit a96a1d6

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

doc/src/sgml/xfunc.sgml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,16 +2104,18 @@ memcpy(destination->data, buffer, 40);
21042104
</para>
21052105

21062106
<para>
2107-
<xref linkend="xfunc-c-type-table"/> specifies which C type
2108-
corresponds to which SQL type when writing a C-language function
2109-
that uses a built-in type of <productname>PostgreSQL</productname>.
2107+
<xref linkend="xfunc-c-type-table"/> shows the C types
2108+
corresponding to many of the built-in SQL data types
2109+
of <productname>PostgreSQL</productname>.
21102110
The <quote>Defined In</quote> column gives the header file that
21112111
needs to be included to get the type definition. (The actual
21122112
definition might be in a different file that is included by the
21132113
listed file. It is recommended that users stick to the defined
21142114
interface.) Note that you should always include
2115-
<filename>postgres.h</filename> first in any source file, because
2116-
it declares a number of things that you will need anyway.
2115+
<filename>postgres.h</filename> first in any source file of server
2116+
code, because it declares a number of things that you will need
2117+
anyway, and because including other headers first can cause
2118+
portability issues.
21172119
</para>
21182120

21192121
<table tocentry="1" id="xfunc-c-type-table">
@@ -2172,28 +2174,28 @@ memcpy(destination->data, buffer, 40);
21722174
<entry><filename>utils/date.h</filename></entry>
21732175
</row>
21742176
<row>
2175-
<entry><type>smallint</type> (<type>int2</type>)</entry>
2176-
<entry><type>int16</type></entry>
2177-
<entry><filename>postgres.h</filename></entry>
2177+
<entry><type>float4</type> (<type>real</type>)</entry>
2178+
<entry><type>float4</type></entry>
2179+
<entry><filename>postgres.h</filename></entry>
21782180
</row>
21792181
<row>
2180-
<entry><type>int2vector</type></entry>
2181-
<entry><type>int2vector*</type></entry>
2182+
<entry><type>float8</type> (<type>double precision</type>)</entry>
2183+
<entry><type>float8</type></entry>
21822184
<entry><filename>postgres.h</filename></entry>
21832185
</row>
21842186
<row>
2185-
<entry><type>integer</type> (<type>int4</type>)</entry>
2186-
<entry><type>int32</type></entry>
2187+
<entry><type>int2</type> (<type>smallint</type>)</entry>
2188+
<entry><type>int16</type></entry>
21872189
<entry><filename>postgres.h</filename></entry>
21882190
</row>
21892191
<row>
2190-
<entry><type>real</type> (<type>float4</type>)</entry>
2191-
<entry><type>float4*</type></entry>
2192-
<entry><filename>postgres.h</filename></entry>
2192+
<entry><type>int4</type> (<type>integer</type>)</entry>
2193+
<entry><type>int32</type></entry>
2194+
<entry><filename>postgres.h</filename></entry>
21932195
</row>
21942196
<row>
2195-
<entry><type>double precision</type> (<type>float8</type>)</entry>
2196-
<entry><type>float8*</type></entry>
2197+
<entry><type>int8</type> (<type>bigint</type>)</entry>
2198+
<entry><type>int64</type></entry>
21972199
<entry><filename>postgres.h</filename></entry>
21982200
</row>
21992201
<row>
@@ -2211,6 +2213,11 @@ memcpy(destination->data, buffer, 40);
22112213
<entry><type>Name</type></entry>
22122214
<entry><filename>postgres.h</filename></entry>
22132215
</row>
2216+
<row>
2217+
<entry><type>numeric</type></entry>
2218+
<entry><type>Numeric</type></entry>
2219+
<entry><filename>utils/numeric.h</filename></entry>
2220+
</row>
22142221
<row>
22152222
<entry><type>oid</type></entry>
22162223
<entry><type>Oid</type></entry>
@@ -2233,7 +2240,7 @@ memcpy(destination->data, buffer, 40);
22332240
</row>
22342241
<row>
22352242
<entry><type>regproc</type></entry>
2236-
<entry><type>regproc</type></entry>
2243+
<entry><type>RegProcedure</type></entry>
22372244
<entry><filename>postgres.h</filename></entry>
22382245
</row>
22392246
<row>
@@ -2261,6 +2268,11 @@ memcpy(destination->data, buffer, 40);
22612268
<entry><type>Timestamp</type></entry>
22622269
<entry><filename>datatype/timestamp.h</filename></entry>
22632270
</row>
2271+
<row>
2272+
<entry><type>timestamp with time zone</type></entry>
2273+
<entry><type>TimestampTz</type></entry>
2274+
<entry><filename>datatype/timestamp.h</filename></entry>
2275+
</row>
22642276
<row>
22652277
<entry><type>varchar</type></entry>
22662278
<entry><type>VarChar*</type></entry>

0 commit comments

Comments
 (0)