Commit 3b0453b2 authored by Neil Conway's avatar Neil Conway

Various documentation improvements. Add a lot of index entries for

the builtin functions (although some more entries are still needed),
and remove the duplicate index entries that have been causing
collateindex.pl warnings. Consistently use "int" and "bigint", rather
than a mix of "int", "integer", "int4", "bigint", and "int8". Make
parenthesis style in syntax examples more consistent. Various
copy-editing for newly-added documentation and SGML markup fixes.
parent 08dc2af9
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/dfunc.sgml,v 1.31 2005/04/09 03:52:43 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/dfunc.sgml,v 1.32 2005/09/14 21:14:26 neilc Exp $
--> -->
<sect2 id="dfunc"> <sect2 id="dfunc">
...@@ -28,11 +28,10 @@ $PostgreSQL: pgsql/doc/src/sgml/dfunc.sgml,v 1.31 2005/04/09 03:52:43 momjian Ex ...@@ -28,11 +28,10 @@ $PostgreSQL: pgsql/doc/src/sgml/dfunc.sgml,v 1.31 2005/04/09 03:52:43 momjian Ex
</para> </para>
<para> <para>
<indexterm><primary>PIC</></> Creating shared libraries is generally Creating shared libraries is generally analogous to linking
analogous to linking executables: first the source files are executables: first the source files are compiled into object files,
compiled into object files, then the object files are linked then the object files are linked together. The object files need to
together. The object files need to be created as be created as <firstterm>position-independent code</firstterm>
<firstterm>position-independent code</firstterm>
(<acronym>PIC</acronym>),<indexterm><primary>PIC</></> which (<acronym>PIC</acronym>),<indexterm><primary>PIC</></> which
conceptually means that they can be placed at an arbitrary location conceptually means that they can be placed at an arbitrary location
in memory when they are loaded by the executable. (Object files in memory when they are loaded by the executable. (Object files
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.284 2005/09/09 02:31:48 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.285 2005/09/14 21:14:26 neilc Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -263,7 +263,7 @@ PostgreSQL documentation ...@@ -263,7 +263,7 @@ PostgreSQL documentation
<primary>BETWEEN</primary> <primary>BETWEEN</primary>
</indexterm> </indexterm>
In addition to the comparison operators, the special In addition to the comparison operators, the special
<token>BETWEEN</token> construct is available.<indexterm><primary>BETWEEN</primary></indexterm> <token>BETWEEN</token> construct is available.
<synopsis> <synopsis>
<replaceable>a</replaceable> BETWEEN <replaceable>x</replaceable> AND <replaceable>y</replaceable> <replaceable>a</replaceable> BETWEEN <replaceable>x</replaceable> AND <replaceable>y</replaceable>
</synopsis> </synopsis>
...@@ -567,6 +567,64 @@ PostgreSQL documentation ...@@ -567,6 +567,64 @@ PostgreSQL documentation
boundary cases may therefore vary depending on the host system. boundary cases may therefore vary depending on the host system.
</para> </para>
<indexterm>
<primary>abs</primary>
</indexterm>
<indexterm>
<primary>cbrt</primary>
</indexterm>
<indexterm>
<primary>ceiling</primary>
</indexterm>
<indexterm>
<primary>degrees</primary>
</indexterm>
<indexterm>
<primary>exp</primary>
</indexterm>
<indexterm>
<primary>floor</primary>
</indexterm>
<indexterm>
<primary>ln</primary>
</indexterm>
<indexterm>
<primary>log</primary>
</indexterm>
<indexterm>
<primary>mod</primary>
</indexterm>
<indexterm>
<primary>&pi;</primary>
</indexterm>
<indexterm>
<primary>power</primary>
</indexterm>
<indexterm>
<primary>radians</primary>
</indexterm>
<indexterm>
<primary>random</primary>
</indexterm>
<indexterm>
<primary>round</primary>
</indexterm>
<indexterm>
<primary>setseed</primary>
</indexterm>
<indexterm>
<primary>sign</primary>
</indexterm>
<indexterm>
<primary>sqrt</primary>
</indexterm>
<indexterm>
<primary>trunc</primary>
</indexterm>
<indexterm>
<primary>width_bucket</primary>
</indexterm>
<table id="functions-math-func-table"> <table id="functions-math-func-table">
<title>Mathematical Functions</title> <title>Mathematical Functions</title>
<tgroup cols="5"> <tgroup cols="5">
...@@ -722,7 +780,7 @@ PostgreSQL documentation ...@@ -722,7 +780,7 @@ PostgreSQL documentation
</row> </row>
<row> <row>
<entry><literal><function>round</function>(<parameter>v</parameter> <type>numeric</type>, <parameter>s</parameter> <type>integer</type>)</literal></entry> <entry><literal><function>round</function>(<parameter>v</parameter> <type>numeric</type>, <parameter>s</parameter> <type>int</type>)</literal></entry>
<entry><type>numeric</type></entry> <entry><type>numeric</type></entry>
<entry>round to <parameter>s</parameter> decimal places</entry> <entry>round to <parameter>s</parameter> decimal places</entry>
<entry><literal>round(42.4382, 2)</literal></entry> <entry><literal>round(42.4382, 2)</literal></entry>
...@@ -731,7 +789,7 @@ PostgreSQL documentation ...@@ -731,7 +789,7 @@ PostgreSQL documentation
<row> <row>
<entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry> <entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>set seed for subsequent <literal>random()</literal> calls</entry> <entry>set seed for subsequent <literal>random()</literal> calls</entry>
<entry><literal>setseed(0.54823)</literal></entry> <entry><literal>setseed(0.54823)</literal></entry>
<entry><literal>1177314959</literal></entry> <entry><literal>1177314959</literal></entry>
...@@ -762,7 +820,7 @@ PostgreSQL documentation ...@@ -762,7 +820,7 @@ PostgreSQL documentation
</row> </row>
<row> <row>
<entry><literal><function>trunc</function>(<parameter>v</parameter> <type>numeric</type>, <parameter>s</parameter> <type>integer</type>)</literal></entry> <entry><literal><function>trunc</function>(<parameter>v</parameter> <type>numeric</type>, <parameter>s</parameter> <type>int</type>)</literal></entry>
<entry><type>numeric</type></entry> <entry><type>numeric</type></entry>
<entry>truncate to <parameter>s</parameter> decimal places</entry> <entry>truncate to <parameter>s</parameter> decimal places</entry>
<entry><literal>trunc(42.4382, 2)</literal></entry> <entry><literal>trunc(42.4382, 2)</literal></entry>
...@@ -770,8 +828,8 @@ PostgreSQL documentation ...@@ -770,8 +828,8 @@ PostgreSQL documentation
</row> </row>
<row> <row>
<entry><literal><function>width_bucket</function>(<parameter>op</parameter> <type>numeric</type>, <parameter>b1</parameter> <type>numeric</type>, <parameter>b2</parameter> <type>numeric</type>, <parameter>count</parameter> <type>integer</type>)</literal></entry> <entry><literal><function>width_bucket</function>(<parameter>op</parameter> <type>numeric</type>, <parameter>b1</parameter> <type>numeric</type>, <parameter>b2</parameter> <type>numeric</type>, <parameter>count</parameter> <type>int</type>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>return the bucket to which <parameter>operand</> would <entry>return the bucket to which <parameter>operand</> would
be assigned in an equidepth histogram with <parameter>count</> be assigned in an equidepth histogram with <parameter>count</>
buckets, an upper bound of <parameter>b1</>, and a lower bound buckets, an upper bound of <parameter>b1</>, and a lower bound
...@@ -790,6 +848,31 @@ PostgreSQL documentation ...@@ -790,6 +848,31 @@ PostgreSQL documentation
precision</type>. precision</type>.
</para> </para>
<indexterm>
<primary>acos</primary>
</indexterm>
<indexterm>
<primary>asin</primary>
</indexterm>
<indexterm>
<primary>atan</primary>
</indexterm>
<indexterm>
<primary>atan2</primary>
</indexterm>
<indexterm>
<primary>cos</primary>
</indexterm>
<indexterm>
<primary>cot</primary>
</indexterm>
<indexterm>
<primary>sin</primary>
</indexterm>
<indexterm>
<primary>tan</primary>
</indexterm>
<table id="functions-math-trig-table"> <table id="functions-math-trig-table">
<title>Trigonometric Functions</title> <title>Trigonometric Functions</title>
...@@ -874,6 +957,37 @@ PostgreSQL documentation ...@@ -874,6 +957,37 @@ PostgreSQL documentation
function invocation. (See <xref linkend="functions-string-other">.) function invocation. (See <xref linkend="functions-string-other">.)
</para> </para>
<indexterm>
<primary>bit_length</primary>
</indexterm>
<indexterm>
<primary>char_length</primary>
</indexterm>
<indexterm>
<primary>convert</primary>
</indexterm>
<indexterm>
<primary>lower</primary>
</indexterm>
<indexterm>
<primary>octet_length</primary>
</indexterm>
<indexterm>
<primary>overlay</primary>
</indexterm>
<indexterm>
<primary>position</primary>
</indexterm>
<indexterm>
<primary>substring</primary>
</indexterm>
<indexterm>
<primary>trim</primary>
</indexterm>
<indexterm>
<primary>upper</primary>
</indexterm>
<table id="functions-string-sql"> <table id="functions-string-sql">
<title><acronym>SQL</acronym> String Functions and Operators</title> <title><acronym>SQL</acronym> String Functions and Operators</title>
<tgroup cols="5"> <tgroup cols="5">
...@@ -905,7 +1019,7 @@ PostgreSQL documentation ...@@ -905,7 +1019,7 @@ PostgreSQL documentation
<row> <row>
<entry><literal><function>bit_length</function>(<parameter>string</parameter>)</literal></entry> <entry><literal><function>bit_length</function>(<parameter>string</parameter>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>Number of bits in string</entry> <entry>Number of bits in string</entry>
<entry><literal>bit_length('jose')</literal></entry> <entry><literal>bit_length('jose')</literal></entry>
<entry><literal>32</literal></entry> <entry><literal>32</literal></entry>
...@@ -913,7 +1027,7 @@ PostgreSQL documentation ...@@ -913,7 +1027,7 @@ PostgreSQL documentation
<row> <row>
<entry><literal><function>char_length</function>(<parameter>string</parameter>)</literal> or <literal><function>character_length</function>(<parameter>string</parameter>)</literal></entry> <entry><literal><function>char_length</function>(<parameter>string</parameter>)</literal> or <literal><function>character_length</function>(<parameter>string</parameter>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry> <entry>
Number of characters in string Number of characters in string
<indexterm> <indexterm>
...@@ -923,7 +1037,7 @@ PostgreSQL documentation ...@@ -923,7 +1037,7 @@ PostgreSQL documentation
<indexterm> <indexterm>
<primary>length</primary> <primary>length</primary>
<secondary sortas="character string">of a character string</secondary> <secondary sortas="character string">of a character string</secondary>
<see>character strings, length</see> <see>character string, length</see>
</indexterm> </indexterm>
</entry> </entry>
<entry><literal>char_length('jose')</literal></entry> <entry><literal>char_length('jose')</literal></entry>
...@@ -955,20 +1069,17 @@ PostgreSQL documentation ...@@ -955,20 +1069,17 @@ PostgreSQL documentation
<row> <row>
<entry><literal><function>octet_length</function>(<parameter>string</parameter>)</literal></entry> <entry><literal><function>octet_length</function>(<parameter>string</parameter>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>Number of bytes in string</entry> <entry>Number of bytes in string</entry>
<entry><literal>octet_length('jose')</literal></entry> <entry><literal>octet_length('jose')</literal></entry>
<entry><literal>4</literal></entry> <entry><literal>4</literal></entry>
</row> </row>
<row> <row>
<entry><literal><function>overlay</function>(<parameter>string</parameter> placing <parameter>string</parameter> from <type>integer</type> <optional>for <type>integer</type></optional>)</literal></entry> <entry><literal><function>overlay</function>(<parameter>string</parameter> placing <parameter>string</parameter> from <type>int</type> <optional>for <type>int</type></optional>)</literal></entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry> <entry>
Replace substring Replace substring
<indexterm>
<primary>overlay</primary>
</indexterm>
</entry> </entry>
<entry><literal>overlay('Txxxxas' placing 'hom' from 2 for 4)</literal></entry> <entry><literal>overlay('Txxxxas' placing 'hom' from 2 for 4)</literal></entry>
<entry><literal>Thomas</literal></entry> <entry><literal>Thomas</literal></entry>
...@@ -976,20 +1087,17 @@ PostgreSQL documentation ...@@ -976,20 +1087,17 @@ PostgreSQL documentation
<row> <row>
<entry><literal><function>position</function>(<parameter>substring</parameter> in <parameter>string</parameter>)</literal></entry> <entry><literal><function>position</function>(<parameter>substring</parameter> in <parameter>string</parameter>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>Location of specified substring</entry> <entry>Location of specified substring</entry>
<entry><literal>position('om' in 'Thomas')</literal></entry> <entry><literal>position('om' in 'Thomas')</literal></entry>
<entry><literal>3</literal></entry> <entry><literal>3</literal></entry>
</row> </row>
<row> <row>
<entry><literal><function>substring</function>(<parameter>string</parameter> <optional>from <type>integer</type></optional> <optional>for <type>integer</type></optional>)</literal></entry> <entry><literal><function>substring</function>(<parameter>string</parameter> <optional>from <type>int</type></optional> <optional>for <type>int</type></optional>)</literal></entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry> <entry>
Extract substring Extract substring
<indexterm>
<primary>substring</primary>
</indexterm>
</entry> </entry>
<entry><literal>substring('Thomas' from 2 for 3)</literal></entry> <entry><literal>substring('Thomas' from 2 for 3)</literal></entry>
<entry><literal>hom</literal></entry> <entry><literal>hom</literal></entry>
...@@ -1000,9 +1108,6 @@ PostgreSQL documentation ...@@ -1000,9 +1108,6 @@ PostgreSQL documentation
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry> <entry>
Extract substring matching POSIX regular expression Extract substring matching POSIX regular expression
<indexterm>
<primary>substring</primary>
</indexterm>
</entry> </entry>
<entry><literal>substring('Thomas' from '...$')</literal></entry> <entry><literal>substring('Thomas' from '...$')</literal></entry>
<entry><literal>mas</literal></entry> <entry><literal>mas</literal></entry>
...@@ -1014,9 +1119,6 @@ PostgreSQL documentation ...@@ -1014,9 +1119,6 @@ PostgreSQL documentation
<entry> <entry>
Extract substring matching <acronym>SQL</acronym> regular Extract substring matching <acronym>SQL</acronym> regular
expression expression
<indexterm>
<primary>substring</primary>
</indexterm>
</entry> </entry>
<entry><literal>substring('Thomas' from '%#"o_a#"_' for '#')</literal></entry> <entry><literal>substring('Thomas' from '%#"o_a#"_' for '#')</literal></entry>
<entry><literal>oma</literal></entry> <entry><literal>oma</literal></entry>
...@@ -1055,6 +1157,76 @@ PostgreSQL documentation ...@@ -1055,6 +1157,76 @@ PostgreSQL documentation
<acronym>SQL</acronym>-standard string functions listed in <xref linkend="functions-string-sql">. <acronym>SQL</acronym>-standard string functions listed in <xref linkend="functions-string-sql">.
</para> </para>
<indexterm>
<primary>ascii</primary>
</indexterm>
<indexterm>
<primary>btrim</primary>
</indexterm>
<indexterm>
<primary>chr</primary>
</indexterm>
<indexterm>
<primary>decode</primary>
</indexterm>
<indexterm>
<primary>encode</primary>
</indexterm>
<indexterm>
<primary>initcap</primary>
</indexterm>
<indexterm>
<primary>lpad</primary>
</indexterm>
<indexterm>
<primary>ltrim</primary>
</indexterm>
<indexterm>
<primary>md5</primary>
</indexterm>
<indexterm>
<primary>pg_client_encoding</primary>
</indexterm>
<indexterm>
<primary>quote_ident</primary>
</indexterm>
<indexterm>
<primary>quote_literal</primary>
</indexterm>
<indexterm>
<primary>regexp_replace</primary>
</indexterm>
<indexterm>
<primary>repeat</primary>
</indexterm>
<indexterm>
<primary>replace</primary>
</indexterm>
<indexterm>
<primary>rpad</primary>
</indexterm>
<indexterm>
<primary>rtrim</primary>
</indexterm>
<indexterm>
<primary>split_part</primary>
</indexterm>
<indexterm>
<primary>strpos</primary>
</indexterm>
<indexterm>
<primary>substr</primary>
</indexterm>
<indexterm>
<primary>to_ascii</primary>
</indexterm>
<indexterm>
<primary>to_hex</primary>
</indexterm>
<indexterm>
<primary>translate</primary>
</indexterm>
<table id="functions-string-other"> <table id="functions-string-other">
<title>Other String Functions</title> <title>Other String Functions</title>
<tgroup cols="5"> <tgroup cols="5">
...@@ -1071,7 +1243,7 @@ PostgreSQL documentation ...@@ -1071,7 +1243,7 @@ PostgreSQL documentation
<tbody> <tbody>
<row> <row>
<entry><literal><function>ascii</function>(<type>text</type>)</literal></entry> <entry><literal><function>ascii</function>(<type>text</type>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry><acronym>ASCII</acronym> code of the first character of the argument</entry> <entry><acronym>ASCII</acronym> code of the first character of the argument</entry>
<entry><literal>ascii('x')</literal></entry> <entry><literal>ascii('x')</literal></entry>
<entry><literal>120</literal></entry> <entry><literal>120</literal></entry>
...@@ -1091,7 +1263,7 @@ PostgreSQL documentation ...@@ -1091,7 +1263,7 @@ PostgreSQL documentation
</row> </row>
<row> <row>
<entry><literal><function>chr</function>(<type>integer</type>)</literal></entry> <entry><literal><function>chr</function>(<type>int</type>)</literal></entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry>Character with the given <acronym>ASCII</acronym> code</entry> <entry>Character with the given <acronym>ASCII</acronym> code</entry>
<entry><literal>chr(65)</literal></entry> <entry><literal>chr(65)</literal></entry>
...@@ -1159,18 +1331,9 @@ PostgreSQL documentation ...@@ -1159,18 +1331,9 @@ PostgreSQL documentation
<row> <row>
<entry><literal><function>length</function>(<parameter>string</parameter> <type>text</type>)</literal></entry> <entry><literal><function>length</function>(<parameter>string</parameter> <type>text</type>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry> <entry>
Number of characters in <parameter>string</parameter> Number of characters in <parameter>string</parameter>
<indexterm>
<primary>character string</primary>
<secondary>length</secondary>
</indexterm>
<indexterm>
<primary>length</primary>
<secondary sortas="character string">of a character string</secondary>
<see>character strings, length</see>
</indexterm>
</entry> </entry>
<entry><literal>length('jose')</literal></entry> <entry><literal>length('jose')</literal></entry>
<entry><literal>4</literal></entry> <entry><literal>4</literal></entry>
...@@ -1179,7 +1342,7 @@ PostgreSQL documentation ...@@ -1179,7 +1342,7 @@ PostgreSQL documentation
<row> <row>
<entry> <entry>
<literal><function>lpad</function>(<parameter>string</parameter> <type>text</type>, <literal><function>lpad</function>(<parameter>string</parameter> <type>text</type>,
<parameter>length</parameter> <type>integer</type> <parameter>length</parameter> <type>int</type>
<optional>, <parameter>fill</parameter> <type>text</type></optional>)</literal> <optional>, <parameter>fill</parameter> <type>text</type></optional>)</literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
...@@ -1231,7 +1394,7 @@ PostgreSQL documentation ...@@ -1231,7 +1394,7 @@ PostgreSQL documentation
</row> </row>
<row> <row>
<entry><literal><function>quote_ident</function>(<parameter>string</parameter> text)</literal><indexterm><primary>quote_ident</></></entry> <entry><literal><function>quote_ident</function>(<parameter>string</parameter> text)</literal></entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry> <entry>
Return the given string suitably quoted to be used as an identifier Return the given string suitably quoted to be used as an identifier
...@@ -1245,7 +1408,7 @@ PostgreSQL documentation ...@@ -1245,7 +1408,7 @@ PostgreSQL documentation
</row> </row>
<row> <row>
<entry><literal><function>quote_literal</function>(<parameter>string</parameter> text)</literal><indexterm><primary>quote_literal</></></entry> <entry><literal><function>quote_literal</function>(<parameter>string</parameter> text)</literal></entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry> <entry>
Return the given string suitably quoted to be used as a string literal Return the given string suitably quoted to be used as a string literal
...@@ -1277,7 +1440,7 @@ PostgreSQL documentation ...@@ -1277,7 +1440,7 @@ PostgreSQL documentation
</row> </row>
<row> <row>
<entry><literal><function>repeat</function>(<parameter>string</parameter> <type>text</type>, <parameter>number</parameter> <type>integer</type>)</literal></entry> <entry><literal><function>repeat</function>(<parameter>string</parameter> <type>text</type>, <parameter>number</parameter> <type>int</type>)</literal></entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry>Repeat <parameter>string</parameter> the specified <entry>Repeat <parameter>string</parameter> the specified
<parameter>number</parameter> of times</entry> <parameter>number</parameter> of times</entry>
...@@ -1300,7 +1463,7 @@ PostgreSQL documentation ...@@ -1300,7 +1463,7 @@ PostgreSQL documentation
<row> <row>
<entry> <entry>
<literal><function>rpad</function>(<parameter>string</parameter> <type>text</type>, <literal><function>rpad</function>(<parameter>string</parameter> <type>text</type>,
<parameter>length</parameter> <type>integer</type> <parameter>length</parameter> <type>int</type>
<optional>, <parameter>fill</parameter> <type>text</type></optional>)</literal> <optional>, <parameter>fill</parameter> <type>text</type></optional>)</literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
...@@ -1332,12 +1495,12 @@ PostgreSQL documentation ...@@ -1332,12 +1495,12 @@ PostgreSQL documentation
<row> <row>
<entry><literal><function>split_part</function>(<parameter>string</parameter> <type>text</type>, <entry><literal><function>split_part</function>(<parameter>string</parameter> <type>text</type>,
<parameter>delimiter</parameter> <type>text</type>, <parameter>delimiter</parameter> <type>text</type>,
<parameter>field</parameter> <type>integer</type>)</literal></entry> <parameter>field</parameter> <type>int</type>)</literal></entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry>Split <parameter>string</parameter> on <parameter>delimiter</parameter> <entry>Split <parameter>string</parameter> on <parameter>delimiter</parameter>
and return the given field (counting from one) and return the given field (counting from one)
</entry> </entry>
<entry><literal>split_part( 'abc~@~def~@~ghi', '~@~', 2)</literal></entry> <entry><literal>split_part('abc~@~def~@~ghi', '~@~', 2)</literal></entry>
<entry><literal>def</literal></entry> <entry><literal>def</literal></entry>
</row> </row>
...@@ -1386,7 +1549,7 @@ PostgreSQL documentation ...@@ -1386,7 +1549,7 @@ PostgreSQL documentation
</row> </row>
<row> <row>
<entry><literal><function>to_hex</function>(<parameter>number</parameter> <type>integer</type> <entry><literal><function>to_hex</function>(<parameter>number</parameter> <type>int</type>
or <type>bigint</type>)</literal></entry> or <type>bigint</type>)</literal></entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry>Convert <parameter>number</parameter> to its equivalent hexadecimal <entry>Convert <parameter>number</parameter> to its equivalent hexadecimal
...@@ -2200,7 +2363,7 @@ PostgreSQL documentation ...@@ -2200,7 +2363,7 @@ PostgreSQL documentation
<row> <row>
<entry><literal><function>octet_length</function>(<parameter>string</parameter>)</literal></entry> <entry><literal><function>octet_length</function>(<parameter>string</parameter>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>Number of bytes in binary string</entry> <entry>Number of bytes in binary string</entry>
<entry><literal>octet_length( 'jo\\000se'::bytea)</literal></entry> <entry><literal>octet_length( 'jo\\000se'::bytea)</literal></entry>
<entry><literal>5</literal></entry> <entry><literal>5</literal></entry>
...@@ -2208,14 +2371,14 @@ PostgreSQL documentation ...@@ -2208,14 +2371,14 @@ PostgreSQL documentation
<row> <row>
<entry><literal><function>position</function>(<parameter>substring</parameter> in <parameter>string</parameter>)</literal></entry> <entry><literal><function>position</function>(<parameter>substring</parameter> in <parameter>string</parameter>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>Location of specified substring</entry> <entry>Location of specified substring</entry>
<entry><literal>position('\\000om'::bytea in 'Th\\000omas'::bytea)</literal></entry> <entry><literal>position('\\000om'::bytea in 'Th\\000omas'::bytea)</literal></entry>
<entry><literal>3</literal></entry> <entry><literal>3</literal></entry>
</row> </row>
<row> <row>
<entry><literal><function>substring</function>(<parameter>string</parameter> <optional>from <type>integer</type></optional> <optional>for <type>integer</type></optional>)</literal></entry> <entry><literal><function>substring</function>(<parameter>string</parameter> <optional>from <type>int</type></optional> <optional>for <type>int</type></optional>)</literal></entry>
<entry><type>bytea</type></entry> <entry><type>bytea</type></entry>
<entry> <entry>
Extract substring Extract substring
...@@ -2245,7 +2408,7 @@ PostgreSQL documentation ...@@ -2245,7 +2408,7 @@ PostgreSQL documentation
<row> <row>
<entry><function>get_byte</function>(<parameter>string</parameter>, <parameter>offset</parameter>)</entry> <entry><function>get_byte</function>(<parameter>string</parameter>, <parameter>offset</parameter>)</entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry> <entry>
Extract byte from string Extract byte from string
<indexterm> <indexterm>
...@@ -2272,7 +2435,7 @@ PostgreSQL documentation ...@@ -2272,7 +2435,7 @@ PostgreSQL documentation
<row> <row>
<entry><function>get_bit</function>(<parameter>string</parameter>, <parameter>offset</parameter>)</entry> <entry><function>get_bit</function>(<parameter>string</parameter>, <parameter>offset</parameter>)</entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry> <entry>
Extract bit from string Extract bit from string
<indexterm> <indexterm>
...@@ -2337,7 +2500,7 @@ PostgreSQL documentation ...@@ -2337,7 +2500,7 @@ PostgreSQL documentation
<row> <row>
<entry><literal><function>length</function>(<parameter>string</parameter>)</literal></entry> <entry><literal><function>length</function>(<parameter>string</parameter>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry> <entry>
Length of binary string Length of binary string
<indexterm> <indexterm>
...@@ -2553,7 +2716,7 @@ cast(-44 as bit(12)) <lineannotation>111111010100</lineannotation> ...@@ -2553,7 +2716,7 @@ cast(-44 as bit(12)) <lineannotation>111111010100</lineannotation>
<sect2 id="functions-like"> <sect2 id="functions-like">
<title><function>LIKE</function></title> <title><function>LIKE</function></title>
<indexterm zone="functions-like"> <indexterm>
<primary>LIKE</primary> <primary>LIKE</primary>
</indexterm> </indexterm>
...@@ -2650,7 +2813,7 @@ cast(-44 as bit(12)) <lineannotation>111111010100</lineannotation> ...@@ -2650,7 +2813,7 @@ cast(-44 as bit(12)) <lineannotation>111111010100</lineannotation>
<sect2 id="functions-similarto-regexp"> <sect2 id="functions-similarto-regexp">
<title><function>SIMILAR TO</function> Regular Expressions</title> <title><function>SIMILAR TO</function> Regular Expressions</title>
<indexterm zone="functions-similarto-regexp"> <indexterm>
<primary>regular expression</primary> <primary>regular expression</primary>
<!-- <seealso>pattern matching</seealso> breaks index build --> <!-- <seealso>pattern matching</seealso> breaks index build -->
</indexterm> </indexterm>
...@@ -4090,13 +4253,22 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})'); ...@@ -4090,13 +4253,22 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
<sect1 id="functions-formatting"> <sect1 id="functions-formatting">
<title>Data Type Formatting Functions</title> <title>Data Type Formatting Functions</title>
<indexterm zone="functions-formatting"> <indexterm>
<primary>formatting</primary> <primary>formatting</primary>
</indexterm> </indexterm>
<indexterm zone="functions-formatting"> <indexterm>
<primary>to_char</primary> <primary>to_char</primary>
</indexterm> </indexterm>
<indexterm>
<primary>to_date</primary>
</indexterm>
<indexterm>
<primary>to_timestamp</primary>
</indexterm>
<indexterm>
<primary>to_number</primary>
</indexterm>
<para> <para>
The <productname>PostgreSQL</productname> formatting functions The <productname>PostgreSQL</productname> formatting functions
...@@ -5008,6 +5180,49 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})'); ...@@ -5008,6 +5180,49 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
</tgroup> </tgroup>
</table> </table>
<indexterm>
<primary>age</primary>
</indexterm>
<indexterm>
<primary>current_date</primary>
</indexterm>
<indexterm>
<primary>current_time</primary>
</indexterm>
<indexterm>
<primary>current_timestamp</primary>
</indexterm>
<indexterm>
<primary>date_part</primary>
</indexterm>
<indexterm>
<primary>date_trunc</primary>
</indexterm>
<indexterm>
<primary>extract</primary>
</indexterm>
<indexterm>
<primary>isfinite</primary>
</indexterm>
<indexterm>
<primary>justify_hours</primary>
</indexterm>
<indexterm>
<primary>justify_days</primary>
</indexterm>
<indexterm>
<primary>localtime</primary>
</indexterm>
<indexterm>
<primary>localtimestamp</primary>
</indexterm>
<indexterm>
<primary>now</primary>
</indexterm>
<indexterm>
<primary>timeofday</primary>
</indexterm>
<table id="functions-datetime-table"> <table id="functions-datetime-table">
<title>Date/Time Functions</title> <title>Date/Time Functions</title>
<tgroup cols="5"> <tgroup cols="5">
...@@ -5198,8 +5413,8 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})'); ...@@ -5198,8 +5413,8 @@ SELECT SUBSTRING('XY1234Z', 'Y*?([0-9]{1,3})');
In addition to these functions, the SQL <literal>OVERLAPS</> operator is In addition to these functions, the SQL <literal>OVERLAPS</> operator is
supported: supported:
<synopsis> <synopsis>
( <replaceable>start1</replaceable>, <replaceable>end1</replaceable> ) OVERLAPS ( <replaceable>start2</replaceable>, <replaceable>end2</replaceable> ) (<replaceable>start1</replaceable>, <replaceable>end1</replaceable>) OVERLAPS (<replaceable>start2</replaceable>, <replaceable>end2</replaceable>)
( <replaceable>start1</replaceable>, <replaceable>length1</replaceable> ) OVERLAPS ( <replaceable>start2</replaceable>, <replaceable>length2</replaceable> ) (<replaceable>start1</replaceable>, <replaceable>length1</replaceable>) OVERLAPS (<replaceable>start2</replaceable>, <replaceable>length2</replaceable>)
</synopsis> </synopsis>
This expression yields true when two time periods (defined by their This expression yields true when two time periods (defined by their
endpoints) overlap, false when they do not overlap. The endpoints endpoints) overlap, false when they do not overlap. The endpoints
...@@ -5237,8 +5452,15 @@ SELECT (DATE '2001-02-16', INTERVAL '100 days') OVERLAPS ...@@ -5237,8 +5452,15 @@ SELECT (DATE '2001-02-16', INTERVAL '100 days') OVERLAPS
<sect2 id="functions-datetime-extract"> <sect2 id="functions-datetime-extract">
<title><function>EXTRACT</function>, <function>date_part</function></title> <title><function>EXTRACT</function>, <function>date_part</function></title>
<indexterm>
<primary>date_part</primary>
</indexterm>
<indexterm>
<primary>extract</primary>
</indexterm>
<synopsis> <synopsis>
EXTRACT (<replaceable>field</replaceable> FROM <replaceable>source</replaceable>) EXTRACT(<replaceable>field</replaceable> FROM <replaceable>source</replaceable>)
</synopsis> </synopsis>
<para> <para>
...@@ -5586,7 +5808,6 @@ SELECT EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40'); ...@@ -5586,7 +5808,6 @@ SELECT EXTRACT(YEAR FROM TIMESTAMP '2001-02-16 20:38:40');
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</para> </para>
<para> <para>
...@@ -5621,6 +5842,10 @@ SELECT date_part('hour', INTERVAL '4 hours 3 minutes'); ...@@ -5621,6 +5842,10 @@ SELECT date_part('hour', INTERVAL '4 hours 3 minutes');
<sect2 id="functions-datetime-trunc"> <sect2 id="functions-datetime-trunc">
<title><function>date_trunc</function></title> <title><function>date_trunc</function></title>
<indexterm>
<primary>date_trunc</primary>
</indexterm>
<para> <para>
The function <function>date_trunc</function> is conceptually The function <function>date_trunc</function> is conceptually
similar to the <function>trunc</function> function for numbers. similar to the <function>trunc</function> function for numbers.
...@@ -5680,6 +5905,10 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40'); ...@@ -5680,6 +5905,10 @@ SELECT date_trunc('year', TIMESTAMP '2001-02-16 20:38:40');
<secondary>conversion</secondary> <secondary>conversion</secondary>
</indexterm> </indexterm>
<indexterm>
<primary>AT TIME ZONE</primary>
</indexterm>
<para> <para>
The <literal>AT TIME ZONE</literal> construct allows conversions The <literal>AT TIME ZONE</literal> construct allows conversions
of time stamps to different time zones. <xref of time stamps to different time zones. <xref
...@@ -5777,12 +6006,12 @@ SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST'; ...@@ -5777,12 +6006,12 @@ SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 20:38:40-05' AT TIME ZONE 'MST';
CURRENT_DATE CURRENT_DATE
CURRENT_TIME CURRENT_TIME
CURRENT_TIMESTAMP CURRENT_TIMESTAMP
CURRENT_TIME ( <replaceable>precision</replaceable> ) CURRENT_TIME (<replaceable>precision</replaceable>)
CURRENT_TIMESTAMP ( <replaceable>precision</replaceable> ) CURRENT_TIMESTAMP (<replaceable>precision</replaceable>)
LOCALTIME LOCALTIME
LOCALTIMESTAMP LOCALTIMESTAMP
LOCALTIME ( <replaceable>precision</replaceable> ) LOCALTIME (<replaceable>precision</replaceable>)
LOCALTIMESTAMP ( <replaceable>precision</replaceable> ) LOCALTIMESTAMP (<replaceable>precision</replaceable>)
</synopsis> </synopsis>
</para> </para>
...@@ -6090,6 +6319,42 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT ...@@ -6090,6 +6319,42 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT
</tgroup> </tgroup>
</table> </table>
<indexterm>
<primary>area</primary>
</indexterm>
<indexterm>
<primary>center</primary>
</indexterm>
<indexterm>
<primary>diameter</primary>
</indexterm>
<indexterm>
<primary>height</primary>
</indexterm>
<indexterm>
<primary>isclosed</primary>
</indexterm>
<indexterm>
<primary>isopen</primary>
</indexterm>
<indexterm>
<primary>length</primary>
</indexterm>
<indexterm>
<primary>npoints</primary>
</indexterm>
<indexterm>
<primary>pclose</primary>
</indexterm>
<indexterm>
<primary>popen</primary>
</indexterm>
<indexterm>
<primary>radius</primary>
</indexterm>
<indexterm>
<primary>width</primary>
</indexterm>
<table id="functions-geometry-func-table"> <table id="functions-geometry-func-table">
<title>Geometric Functions</title> <title>Geometric Functions</title>
...@@ -6147,13 +6412,13 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT ...@@ -6147,13 +6412,13 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT
</row> </row>
<row> <row>
<entry><literal><function>npoints</function>(<type>path</>)</literal></entry> <entry><literal><function>npoints</function>(<type>path</>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>number of points</entry> <entry>number of points</entry>
<entry><literal>npoints(path '[(0,0),(1,1),(2,0)]')</literal></entry> <entry><literal>npoints(path '[(0,0),(1,1),(2,0)]')</literal></entry>
</row> </row>
<row> <row>
<entry><literal><function>npoints</function>(<type>polygon</>)</literal></entry> <entry><literal><function>npoints</function>(<type>polygon</>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>number of points</entry> <entry>number of points</entry>
<entry><literal>npoints(polygon '((1,1),(0,0))')</literal></entry> <entry><literal>npoints(polygon '((1,1),(0,0))')</literal></entry>
</row> </row>
...@@ -6194,7 +6459,6 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT ...@@ -6194,7 +6459,6 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT
</tgroup> </tgroup>
</table> </table>
<table id="functions-geometry-conv-table"> <table id="functions-geometry-conv-table">
<title>Geometric Type Conversion Functions</title> <title>Geometric Type Conversion Functions</title>
<tgroup cols="4"> <tgroup cols="4">
...@@ -6468,13 +6732,13 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT ...@@ -6468,13 +6732,13 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT
</row> </row>
<row> <row>
<entry><literal><function>masklen</function>(<type>inet</type>)</literal></entry> <entry><literal><function>masklen</function>(<type>inet</type>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>extract netmask length</entry> <entry>extract netmask length</entry>
<entry><literal>masklen('192.168.1.5/24')</literal></entry> <entry><literal>masklen('192.168.1.5/24')</literal></entry>
<entry><literal>24</literal></entry> <entry><literal>24</literal></entry>
</row> </row>
<row> <row>
<entry><literal><function>set_masklen</function>(<type>inet</type>, <type>integer</type>)</literal></entry> <entry><literal><function>set_masklen</function>(<type>inet</type>, <type>int</type>)</literal></entry>
<entry><type>inet</type></entry> <entry><type>inet</type></entry>
<entry>set netmask length for <type>inet</type> value</entry> <entry>set netmask length for <type>inet</type> value</entry>
<entry><literal>set_masklen('192.168.1.5/24', 16)</literal></entry> <entry><literal>set_masklen('192.168.1.5/24', 16)</literal></entry>
...@@ -6517,7 +6781,7 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT ...@@ -6517,7 +6781,7 @@ SELECT TIMESTAMP 'now'; -- incorrect for use with DEFAULT
</row> </row>
<row> <row>
<entry><literal><function>family</function>(<type>inet</type>)</literal></entry> <entry><literal><function>family</function>(<type>inet</type>)</literal></entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>extract family of address; <literal>4</literal> for IPv4, <entry>extract family of address; <literal>4</literal> for IPv4,
<literal>6</literal> for IPv6</entry> <literal>6</literal> for IPv6</entry>
<entry><literal>family('::1')</literal></entry> <entry><literal>family('::1')</literal></entry>
...@@ -6982,7 +7246,6 @@ SELECT NULLIF(value, '(none)') ... ...@@ -6982,7 +7246,6 @@ SELECT NULLIF(value, '(none)') ...
the SQL standard, but are a common extension. the SQL standard, but are a common extension.
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -7155,10 +7418,10 @@ SELECT NULLIF(value, '(none)') ... ...@@ -7155,10 +7418,10 @@ SELECT NULLIF(value, '(none)') ...
<entry> <entry>
<literal> <literal>
<function>array_lower</function> <function>array_lower</function>
(<type>anyarray</type>, <type>integer</type>) (<type>anyarray</type>, <type>int</type>)
</literal> </literal>
</entry> </entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>returns lower bound of the requested array dimension</entry> <entry>returns lower bound of the requested array dimension</entry>
<entry><literal>array_lower(array_prepend(0, ARRAY[1,2,3]), 1)</literal></entry> <entry><literal>array_lower(array_prepend(0, ARRAY[1,2,3]), 1)</literal></entry>
<entry><literal>0</literal></entry> <entry><literal>0</literal></entry>
...@@ -7167,10 +7430,10 @@ SELECT NULLIF(value, '(none)') ... ...@@ -7167,10 +7430,10 @@ SELECT NULLIF(value, '(none)') ...
<entry> <entry>
<literal> <literal>
<function>array_upper</function> <function>array_upper</function>
(<type>anyarray</type>, <type>integer</type>) (<type>anyarray</type>, <type>int</type>)
</literal> </literal>
</entry> </entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>returns upper bound of the requested array dimension</entry> <entry>returns upper bound of the requested array dimension</entry>
<entry><literal>array_upper(ARRAY[1,2,3,4], 1)</literal></entry> <entry><literal>array_upper(ARRAY[1,2,3,4], 1)</literal></entry>
<entry><literal>4</literal></entry> <entry><literal>4</literal></entry>
...@@ -7244,7 +7507,7 @@ SELECT NULLIF(value, '(none)') ... ...@@ -7244,7 +7507,7 @@ SELECT NULLIF(value, '(none)') ...
<function>avg(<replaceable class="parameter">expression</replaceable>)</function> <function>avg(<replaceable class="parameter">expression</replaceable>)</function>
</entry> </entry>
<entry> <entry>
<type>smallint</type>, <type>integer</type>, <type>smallint</type>, <type>int</type>,
<type>bigint</type>, <type>real</type>, <type>double <type>bigint</type>, <type>real</type>, <type>double
precision</type>, <type>numeric</type>, or <type>interval</type> precision</type>, <type>numeric</type>, or <type>interval</type>
</entry> </entry>
...@@ -7264,7 +7527,7 @@ SELECT NULLIF(value, '(none)') ... ...@@ -7264,7 +7527,7 @@ SELECT NULLIF(value, '(none)') ...
<function>bit_and(<replaceable class="parameter">expression</replaceable>)</function> <function>bit_and(<replaceable class="parameter">expression</replaceable>)</function>
</entry> </entry>
<entry> <entry>
<type>smallint</type>, <type>integer</type>, <type>bigint</type>, or <type>smallint</type>, <type>int</type>, <type>bigint</type>, or
<type>bit</type> <type>bit</type>
</entry> </entry>
<entry> <entry>
...@@ -7281,7 +7544,7 @@ SELECT NULLIF(value, '(none)') ... ...@@ -7281,7 +7544,7 @@ SELECT NULLIF(value, '(none)') ...
<function>bit_or(<replaceable class="parameter">expression</replaceable>)</function> <function>bit_or(<replaceable class="parameter">expression</replaceable>)</function>
</entry> </entry>
<entry> <entry>
<type>smallint</type>, <type>integer</type>, <type>bigint</type>, or <type>smallint</type>, <type>int</type>, <type>bigint</type>, or
<type>bit</type> <type>bit</type>
</entry> </entry>
<entry> <entry>
...@@ -7385,7 +7648,7 @@ SELECT NULLIF(value, '(none)') ... ...@@ -7385,7 +7648,7 @@ SELECT NULLIF(value, '(none)') ...
<function>stddev(<replaceable class="parameter">expression</replaceable>)</function> <function>stddev(<replaceable class="parameter">expression</replaceable>)</function>
</entry> </entry>
<entry> <entry>
<type>smallint</type>, <type>integer</type>, <type>smallint</type>, <type>int</type>,
<type>bigint</type>, <type>real</type>, <type>double <type>bigint</type>, <type>real</type>, <type>double
precision</type>, or <type>numeric</type> precision</type>, or <type>numeric</type>
</entry> </entry>
...@@ -7399,14 +7662,14 @@ SELECT NULLIF(value, '(none)') ... ...@@ -7399,14 +7662,14 @@ SELECT NULLIF(value, '(none)') ...
<row> <row>
<entry><function>sum(<replaceable class="parameter">expression</replaceable>)</function></entry> <entry><function>sum(<replaceable class="parameter">expression</replaceable>)</function></entry>
<entry> <entry>
<type>smallint</type>, <type>integer</type>, <type>smallint</type>, <type>int</type>,
<type>bigint</type>, <type>real</type>, <type>double <type>bigint</type>, <type>real</type>, <type>double
precision</type>, <type>numeric</type>, or precision</type>, <type>numeric</type>, or
<type>interval</type> <type>interval</type>
</entry> </entry>
<entry> <entry>
<type>bigint</type> for <type>smallint</type> or <type>bigint</type> for <type>smallint</type> or
<type>integer</type> arguments, <type>numeric</type> for <type>int</type> arguments, <type>numeric</type> for
<type>bigint</type> arguments, <type>double precision</type> <type>bigint</type> arguments, <type>double precision</type>
for floating-point arguments, otherwise the same as the for floating-point arguments, otherwise the same as the
argument data type argument data type
...@@ -7422,7 +7685,7 @@ SELECT NULLIF(value, '(none)') ... ...@@ -7422,7 +7685,7 @@ SELECT NULLIF(value, '(none)') ...
<function>variance</function>(<replaceable class="parameter">expression</replaceable>) <function>variance</function>(<replaceable class="parameter">expression</replaceable>)
</entry> </entry>
<entry> <entry>
<type>smallint</type>, <type>integer</type>, <type>smallint</type>, <type>int</type>,
<type>bigint</type>, <type>real</type>, <type>double <type>bigint</type>, <type>real</type>, <type>double
precision</type>, or <type>numeric</type> precision</type>, or <type>numeric</type>
</entry> </entry>
...@@ -7526,7 +7789,7 @@ SELECT count(*) FROM sometable; ...@@ -7526,7 +7789,7 @@ SELECT count(*) FROM sometable;
<title><literal>EXISTS</literal></title> <title><literal>EXISTS</literal></title>
<synopsis> <synopsis>
EXISTS ( <replaceable>subquery</replaceable> ) EXISTS (<replaceable>subquery</replaceable>)
</synopsis> </synopsis>
<para> <para>
...@@ -8049,6 +8312,10 @@ AND ...@@ -8049,6 +8312,10 @@ AND
otherwise the result of the row comparison is unknown (null). otherwise the result of the row comparison is unknown (null).
</para> </para>
<indexterm>
<primary>IS DISTINCT FROM</primary>
</indexterm>
<synopsis> <synopsis>
<replaceable>row_constructor</replaceable> IS DISTINCT FROM <replaceable>row_constructor</replaceable> <replaceable>row_constructor</replaceable> IS DISTINCT FROM <replaceable>row_constructor</replaceable>
</synopsis> </synopsis>
...@@ -8082,6 +8349,10 @@ AND ...@@ -8082,6 +8349,10 @@ AND
<secondary>functions</secondary> <secondary>functions</secondary>
</indexterm> </indexterm>
<indexterm>
<primary>generate_series</primary>
</indexterm>
<para> <para>
This section describes functions that possibly return more than one row. This section describes functions that possibly return more than one row.
Currently the only functions in this class are series generating functions, Currently the only functions in this class are series generating functions,
...@@ -8213,7 +8484,7 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a); ...@@ -8213,7 +8484,7 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a);
<row> <row>
<entry><literal><function>inet_client_port</function>()</literal></entry> <entry><literal><function>inet_client_port</function>()</literal></entry>
<entry><type>int4</type></entry> <entry><type>int</type></entry>
<entry>port of the remote connection</entry> <entry>port of the remote connection</entry>
</row> </row>
...@@ -8225,7 +8496,7 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a); ...@@ -8225,7 +8496,7 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a);
<row> <row>
<entry><literal><function>inet_server_port</function>()</literal></entry> <entry><literal><function>inet_server_port</function>()</literal></entry>
<entry><type>int4</type></entry> <entry><type>int</type></entry>
<entry>port of the local connection</entry> <entry>port of the local connection</entry>
</row> </row>
...@@ -8345,8 +8616,9 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, .. ...@@ -8345,8 +8616,9 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
</indexterm> </indexterm>
<para> <para>
<function>pg_postmaster_start_time</function> returns the timestamp with time zone <function>pg_postmaster_start_time</function> returns the
when the <command>postmaster</> started. <type>timestamp with time zone</type> when the
<command>postmaster</> started.
</para> </para>
<indexterm zone="functions-info"> <indexterm zone="functions-info">
...@@ -8851,7 +9123,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype); ...@@ -8851,7 +9123,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
<row> <row>
<entry><literal><function>pg_tablespace_databases</function>(<parameter>tablespace_oid</parameter>)</literal></entry> <entry><literal><function>pg_tablespace_databases</function>(<parameter>tablespace_oid</parameter>)</literal></entry>
<entry><type>setof oid</type></entry> <entry><type>setof oid</type></entry>
<entry>get set of database OIDs that have objects in the tablespace</entry> <entry>get the set of database OIDs that have objects in the tablespace</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
...@@ -8886,20 +9158,22 @@ SELECT pg_type_is_visible('myschema.widget'::regtype); ...@@ -8886,20 +9158,22 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
</para> </para>
<para> <para>
<function>pg_get_userbyid</function> <function>pg_get_userbyid</function> extracts a role's name given
extracts a role's name given its OID. its OID.
<function>pg_get_serial_sequence</function>
fetches the name of the sequence associated with a serial or
bigserial column. The name is suitably formatted
for passing to the sequence functions (see <xref
linkend="functions-sequence">).
NULL is returned if the column does not have a sequence attached.
</para> </para>
<para> <para>
<function>pg_tablespace_databases</function> allows usage examination of a <function>pg_get_serial_sequence</function> fetches the name of the
tablespace. It will return a set of OIDs of databases that have objects sequence associated with a <type>serial</> or <type>bigserial</>
stored in the tablespace. If this function returns any row, the column. The name is suitably formatted for passing to the sequence
functions (see <xref linkend="functions-sequence">). NULL is
returned if the column does not have an associated sequence.
</para>
<para>
<function>pg_tablespace_databases</function> allows a tablespace to
be examined. It returns the set of OIDs of databases that have objects
stored in the tablespace. If this function returns any rows, the
tablespace is not empty and cannot be dropped. To tablespace is not empty and cannot be dropped. To
display the specific objects populating the tablespace, you will need display the specific objects populating the tablespace, you will need
to connect to the databases identified by to connect to the databases identified by
...@@ -9120,19 +9394,19 @@ SELECT set_config('log_statement_stats', 'off', false); ...@@ -9120,19 +9394,19 @@ SELECT set_config('log_statement_stats', 'off', false);
</para> </para>
<para> <para>
<function>pg_cancel_backend</> sends a Query Cancel (SIGINT) signal <function>pg_cancel_backend</> sends a query cancel
to a backend process identified by process ID (<literal>pid</literal>). (<systemitem>SIGINT</>) signal to a backend process identified by
The process ID of an active backend can be found from the process ID. The process ID of an active backend can be found from
<structfield>procpid</structfield> column in the the <structfield>procpid</structfield> column in the
<structname>pg_stat_activity</structname> view, or by listing the <structname>pg_stat_activity</structname> view, or by listing the
<command>postgres</command> processes on the server with <command>postgres</command> processes on the server with
<application>ps</>. <application>ps</>.
</para> </para>
<para> <para>
<function>pg_reload_conf</> sends a SIGHUP signal to the <function>pg_reload_conf</> sends a <systemitem>SIGHUP</> signal
postmaster, causing reload of the configuration files to the <application>postmaster</>, causing the configuration files
in all server processes. to be reloaded by all server processes.
</para> </para>
<para> <para>
...@@ -9245,7 +9519,7 @@ SELECT set_config('log_statement_stats', 'off', false); ...@@ -9245,7 +9519,7 @@ SELECT set_config('log_statement_stats', 'off', false);
<tbody> <tbody>
<row> <row>
<entry><function>pg_column_size</function>(<type>any</type>)</entry> <entry><function>pg_column_size</function>(<type>any</type>)</entry>
<entry><type>integer</type></entry> <entry><type>int</type></entry>
<entry>Number of bytes used to store a particular value (possibly compressed)</entry> <entry>Number of bytes used to store a particular value (possibly compressed)</entry>
</row> </row>
<row> <row>
...@@ -9375,7 +9649,7 @@ SELECT set_config('log_statement_stats', 'off', false); ...@@ -9375,7 +9649,7 @@ SELECT set_config('log_statement_stats', 'off', false);
</row> </row>
<row> <row>
<entry> <entry>
<literal><function>pg_read_file</function>(<parameter>filename</> <type>text</>, <parameter>offset</> <type>int8</>, <parameter>length</> <type>int8</>)</literal> <literal><function>pg_read_file</function>(<parameter>filename</> <type>text</>, <parameter>offset</> <type>bigint</>, <parameter>length</> <type>bigint</>)</literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry>Return the contents of a text file</entry> <entry>Return the contents of a text file</entry>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.75 2005/07/02 08:59:47 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.76 2005/09/14 21:14:26 neilc Exp $
--> -->
<chapter id="plpgsql"> <chapter id="plpgsql">
...@@ -1320,20 +1320,27 @@ EXECUTE 'UPDATE tbl SET ' ...@@ -1320,20 +1320,27 @@ EXECUTE 'UPDATE tbl SET '
</programlisting> </programlisting>
</para> </para>
<indexterm>
<primary>quote_ident</primary>
<secondary>use in PL/PgSQL</secondary>
</indexterm>
<indexterm>
<primary>quote_literal</primary>
<secondary>use in PL/PgSQL</secondary>
</indexterm>
<para> <para>
This example shows use of the functions This example demonstrates the use of the
<function>quote_ident(<type>text</type>)</function> and <function>quote_ident</function> and
<function>quote_literal(<type>text</type>)</function>.<indexterm><primary>quote_ident</><secondary>use <function>quote_literal</function> functions. For safety,
in expressions containing column and table identifiers should be
PL/pgSQL</></indexterm><indexterm><primary>quote_literal</><secondary>use passed to <function>quote_ident</function>. Expressions containing
in PL/pgSQL</></indexterm> For safety, variables containing column and values that should be literal strings in the constructed command
table identifiers should be passed to function should be passed to <function>quote_literal</function>. Both
<function>quote_ident</function>. Variables containing values take the appropriate steps to return the input text enclosed in
that should be literal strings in the constructed command should double or single quotes respectively, with any embedded special
be passed to <function>quote_literal</function>. Both take the characters properly escaped.
appropriate steps to return the input text enclosed in double or
single quotes respectively, with any embedded special characters
properly escaped.
</para> </para>
<para> <para>
...@@ -3599,11 +3606,11 @@ $$ LANGUAGE plpgsql; ...@@ -3599,11 +3606,11 @@ $$ LANGUAGE plpgsql;
The <application>PL/pgSQL</> version of The <application>PL/pgSQL</> version of
<command>EXECUTE</command> works similarly to the <command>EXECUTE</command> works similarly to the
<application>PL/SQL</> version, but you have to remember to use <application>PL/SQL</> version, but you have to remember to use
<function>quote_literal(text)</function> and <function>quote_literal</function> and
<function>quote_string(text)</function> as described in <xref <function>quote_ident</function> as described in <xref
linkend="plpgsql-statements-executing-dyn">. Constructs of the linkend="plpgsql-statements-executing-dyn">. Constructs of the
type <literal>EXECUTE 'SELECT * FROM $1';</literal> will not type <literal>EXECUTE 'SELECT * FROM $1';</literal> will not work
work unless you use these functions. unless you use these functions.
</para> </para>
</sect3> </sect3>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.103 2005/05/30 23:09:07 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.104 2005/09/14 21:14:26 neilc Exp $
--> -->
<sect1 id="xfunc"> <sect1 id="xfunc">
...@@ -99,9 +99,8 @@ $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.103 2005/05/30 23:09:07 tgl Exp $ ...@@ -99,9 +99,8 @@ $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.103 2005/05/30 23:09:07 tgl Exp $
<indexterm><primary>SETOF</><seealso>function</></> Alternatively, <indexterm><primary>SETOF</><seealso>function</></> Alternatively,
an SQL function may be declared to return a set, by specifying the an SQL function may be declared to return a set, by specifying the
function's return type as <literal>SETOF function's return type as <literal>SETOF
<replaceable>sometype</></literal>.<indexterm><primary>SETOF</></> <replaceable>sometype</></literal>. In this case all rows of the
In this case all rows of the last query's result are returned. last query's result are returned. Further details appear below.
Further details appear below.
</para> </para>
<para> <para>
......
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