Commit b2fd8ebe authored by Tom Lane's avatar Tom Lane

Doc: update remaining tables of functions/operators for new layout.

This converts the contrib documentation to the new style, and mops up
a couple of function tables that were outside chapter 9 in the main
docs.

A few contrib modules choose not to present their functions in the
standard tabular format.  There might be room to rethink those decisions
now that the standard format is more friendly to verbose descriptions.
But I have not undertaken to do that here; I just converted existing
tables.
parent c265ed9b
...@@ -29,49 +29,69 @@ ...@@ -29,49 +29,69 @@
<table id="functions-adminpack-table"> <table id="functions-adminpack-table">
<title><filename>adminpack</filename> Functions</title> <title><filename>adminpack</filename> Functions</title>
<tgroup cols="3"> <tgroup cols="1">
<thead> <thead>
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
</thead> Function
</para>
<tbody> <para>
<row> Description
<entry><function>pg_catalog.pg_file_write(filename text, data text, append boolean)</function></entry> </para></entry>
<entry><type>bigint</type></entry> </row>
<entry> </thead>
Write, or append to, a text file
</entry> <tbody>
</row> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><function>pg_catalog.pg_file_sync(filename text)</function></entry> <function>pg_catalog.pg_file_write</function> ( <parameter>filename</parameter> <type>text</type>, <parameter>data</parameter> <type>text</type>, <parameter>append</parameter> <type>boolean</type> )
<entry><type>void</type></entry> <returnvalue>bigint</returnvalue>
<entry> </para>
Flush a file or directory to disk <para>
</entry> Writes, or appends to, a text file.
</row> </para></entry>
<row> </row>
<entry><function>pg_catalog.pg_file_rename(oldname text, newname text <optional>, archivename text</optional>)</function></entry>
<entry><type>boolean</type></entry> <row>
<entry> <entry role="func_table_entry"><para role="func_signature">
Rename a file <function>pg_catalog.pg_file_sync</function> ( <parameter>filename</parameter> <type>text</type> )
</entry> <returnvalue>void</returnvalue>
</row> </para>
<row> <para>
<entry><function>pg_catalog.pg_file_unlink(filename text)</function></entry> Flushes a file or directory to disk.
<entry><type>boolean</type></entry> </para></entry>
<entry> </row>
Remove a file
</entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<row> <function>pg_catalog.pg_file_rename</function> ( <parameter>oldname</parameter> <type>text</type>, <parameter>newname</parameter> <type>text</type> <optional>, <parameter>archivename</parameter> <type>text</type> </optional> )
<entry><function>pg_catalog.pg_logdir_ls()</function></entry> <returnvalue>boolean</returnvalue>
<entry><type>setof record</type></entry> </para>
<entry> <para>
List the log files in the <varname>log_directory</varname> directory Renames a file.
</entry> </para></entry>
</row> </row>
</tbody>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>pg_catalog.pg_file_unlink</function> ( <parameter>filename</parameter> <type>text</type> )
<returnvalue>boolean</returnvalue>
</para>
<para>
Removes a file.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>pg_catalog.pg_logdir_ls</function> ()
<returnvalue>setof record</returnvalue>
</para>
<para>
Lists the log files in the <varname>log_directory</varname> directory.
</para></entry>
</row>
</tbody>
</tgroup> </tgroup>
</table> </table>
......
...@@ -112,114 +112,113 @@ ...@@ -112,114 +112,113 @@
<title>Usage</title> <title>Usage</title>
<para> <para>
<xref linkend="cube-operators-table"/> shows the operators provided for <xref linkend="cube-operators-table"/> shows the specialized operators
type <type>cube</type>. provided for type <type>cube</type>.
</para> </para>
<table id="cube-operators-table"> <table id="cube-operators-table">
<title>Cube Operators</title> <title>Cube Operators</title>
<tgroup cols="3"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Operator</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Result</entry> Operator
<entry>Description</entry> </para>
</row> <para>
</thead> Description
</para></entry>
<tbody> </row>
<row> </thead>
<entry><literal>a = b</literal></entry>
<entry><type>boolean</type></entry> <tbody>
<entry>The cubes a and b are identical.</entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<type>cube</type> <literal>&amp;&amp;</literal> <type>cube</type>
<row> <returnvalue>boolean</returnvalue>
<entry><literal>a &amp;&amp; b</literal></entry> </para>
<entry><type>boolean</type></entry> <para>
<entry>The cubes a and b overlap.</entry> Do the cubes overlap?
</row> </para></entry>
</row>
<row>
<entry><literal>a @&gt; b</literal></entry> <row>
<entry><type>boolean</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>The cube a contains the cube b.</entry> <type>cube</type> <literal>@&gt;</literal> <type>cube</type>
</row> <returnvalue>boolean</returnvalue>
</para>
<row> <para>
<entry><literal>a &lt;@ b</literal></entry> Does the first cube contain the second?
<entry><type>boolean</type></entry> </para></entry>
<entry>The cube a is contained in the cube b.</entry> </row>
</row>
<row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>a &lt; b</literal></entry> <type>cube</type> <literal>&lt;@</literal> <type>cube</type>
<entry><type>boolean</type></entry> <returnvalue>boolean</returnvalue>
<entry>The cube a is less than the cube b.</entry> </para>
</row> <para>
Is the first cube contained in the second?
<row> </para></entry>
<entry><literal>a &lt;= b</literal></entry> </row>
<entry><type>boolean</type></entry>
<entry>The cube a is less than or equal to the cube b.</entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<type>cube</type> <literal>-&gt;</literal> <type>integer</type>
<row> <returnvalue>float8</returnvalue>
<entry><literal>a &gt; b</literal></entry> </para>
<entry><type>boolean</type></entry> <para>
<entry>The cube a is greater than the cube b.</entry> Extracts the <parameter>n</parameter>-th coordinate of the cube
</row> (counting from 1).
</para></entry>
<row> </row>
<entry><literal>a &gt;= b</literal></entry>
<entry><type>boolean</type></entry> <row>
<entry>The cube a is greater than or equal to the cube b.</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <type>cube</type> <literal>~&gt;</literal> <type>integer</type>
<returnvalue>float8</returnvalue>
<row> </para>
<entry><literal>a &lt;&gt; b</literal></entry> <para>
<entry><type>boolean</type></entry> Extracts the <parameter>n</parameter>-th coordinate of the cube,
<entry>The cube a is not equal to the cube b.</entry> counting in the following way: <parameter>n</parameter> = 2
</row> * <parameter>k</parameter> - 1 means lower bound
of <parameter>k</parameter>-th dimension, <parameter>n</parameter> = 2
<row> * <parameter>k</parameter> means upper bound of
<entry><literal>a -&gt; n</literal></entry> <parameter>k</parameter>-th dimension. Negative
<entry><type>float8</type></entry> <parameter>n</parameter> denotes the inverse value of the corresponding
<entry>Get <replaceable>n</replaceable>-th coordinate of cube (counting from 1).</entry>
</row>
<row>
<entry><literal>a ~&gt; n</literal></entry>
<entry><type>float8</type></entry>
<entry>
Get <replaceable>n</replaceable>-th coordinate of cube in following way:
n = 2 * k - 1 means lower bound of <replaceable>k</replaceable>-th
dimension, n = 2 * k means upper bound of
<replaceable>k</replaceable>-th dimension. Negative
<replaceable>n</replaceable> denotes the inverse value of the corresponding
positive coordinate. This operator is designed for KNN-GiST support. positive coordinate. This operator is designed for KNN-GiST support.
</entry> </para></entry>
</row> </row>
<row> <row>
<entry><literal>a &lt;-&gt; b</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>float8</type></entry> <type>cube</type> <literal>&lt;-&gt;</literal> <type>cube</type>
<entry>Euclidean distance between a and b.</entry> <returnvalue>float8</returnvalue>
</row> </para>
<para>
<row> Computes the Euclidean distance between the two cubes.
<entry><literal>a &lt;#&gt; b</literal></entry> </para></entry>
<entry><type>float8</type></entry> </row>
<entry>Taxicab (L-1 metric) distance between a and b.</entry>
</row> <row>
<entry role="func_table_entry"><para role="func_signature">
<row> <type>cube</type> <literal>&lt;#&gt;</literal> <type>cube</type>
<entry><literal>a &lt;=&gt; b</literal></entry> <returnvalue>float8</returnvalue>
<entry><type>float8</type></entry> </para>
<entry>Chebyshev (L-inf metric) distance between a and b.</entry> <para>
</row> Computes the taxicab (L-1 metric) distance between the two cubes.
</para></entry>
</tbody> </row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>cube</type> <literal>&lt;=&gt;</literal> <type>cube</type>
<returnvalue>float8</returnvalue>
</para>
<para>
Computes the Chebyshev (L-inf metric) distance between the two cubes.
</para></entry>
</row>
</tbody>
</tgroup> </tgroup>
</table> </table>
...@@ -232,12 +231,14 @@ ...@@ -232,12 +231,14 @@
</para> </para>
<para> <para>
The scalar ordering operators (<literal>&lt;</literal>, <literal>&gt;=</literal>, etc) In addition to the above operators, the usual comparison
do not make a lot of sense for any practical purpose but sorting. These operators shown in <xref linkend="functions-comparison-op-table"/> are
available for type <type>cube</type>. These
operators first compare the first coordinates, and if those are equal, operators first compare the first coordinates, and if those are equal,
compare the second coordinates, etc. They exist mainly to support the compare the second coordinates, etc. They exist mainly to support the
b-tree index operator class for <type>cube</type>, which can be useful for b-tree index operator class for <type>cube</type>, which can be useful for
example if you would like a UNIQUE constraint on a <type>cube</type> column. example if you would like a UNIQUE constraint on a <type>cube</type> column.
Otherwise, this ordering is not of much practical use.
</para> </para>
<para> <para>
...@@ -281,195 +282,262 @@ SELECT c FROM test ORDER BY c ~&gt; 3 DESC LIMIT 5; ...@@ -281,195 +282,262 @@ SELECT c FROM test ORDER BY c ~&gt; 3 DESC LIMIT 5;
<table id="cube-functions-table"> <table id="cube-functions-table">
<title>Cube Functions</title> <title>Cube Functions</title>
<tgroup cols="4"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Function</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Result</entry> Function
<entry>Description</entry> </para>
<entry>Example</entry> <para>
</row> Description
</thead> </para>
<para>
<tbody> Example(s)
<row> </para></entry>
<entry><literal>cube(float8)</literal></entry> </row>
<entry><type>cube</type></entry> </thead>
<entry>Makes a one dimensional cube with both coordinates the same.
</entry> <tbody>
<entry> <row>
<literal>cube(1) == '(1)'</literal> <entry role="func_table_entry"><para role="func_signature">
</entry> <function>cube</function> ( <type>float8</type> )
</row> <returnvalue>cube</returnvalue>
</para>
<row> <para>
<entry><literal>cube(float8, float8)</literal></entry> Makes a one dimensional cube with both coordinates the same.
<entry><type>cube</type></entry> </para>
<entry>Makes a one dimensional cube. <para>
</entry> <literal>cube(1)</literal>
<entry> <returnvalue>(1)</returnvalue>
<literal>cube(1,2) == '(1),(2)'</literal> </para></entry>
</entry> </row>
</row>
<row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>cube(float8[])</literal></entry> <function>cube</function> ( <type>float8</type>, <type>float8</type> )
<entry><type>cube</type></entry> <returnvalue>cube</returnvalue>
<entry>Makes a zero-volume cube using the coordinates </para>
defined by the array. <para>
</entry> Makes a one dimensional cube.
<entry> </para>
<literal>cube(ARRAY[1,2]) == '(1,2)'</literal> <para>
</entry> <literal>cube(1,2)</literal>
</row> <returnvalue>(1),(2)</returnvalue>
</para></entry>
<row> </row>
<entry><literal>cube(float8[], float8[])</literal></entry>
<entry><type>cube</type></entry> <row>
<entry>Makes a cube with upper right and lower left <entry role="func_table_entry"><para role="func_signature">
coordinates as defined by the two arrays, which must be of the <function>cube</function> ( <type>float8[]</type> )
same length. <returnvalue>cube</returnvalue>
</entry> </para>
<entry> <para>
<literal>cube(ARRAY[1,2], ARRAY[3,4]) == '(1,2),(3,4)' Makes a zero-volume cube using the coordinates defined by the array.
</literal> </para>
</entry> <para>
</row> <literal>cube(ARRAY[1,2,3])</literal>
<returnvalue>(1, 2, 3)</returnvalue>
<row> </para></entry>
<entry><literal>cube(cube, float8)</literal></entry> </row>
<entry><type>cube</type></entry>
<entry>Makes a new cube by adding a dimension on to an existing cube, <row>
with the same values for both endpoints of the new coordinate. This <entry role="func_table_entry"><para role="func_signature">
is useful for building cubes piece by piece from calculated values. <function>cube</function> ( <type>float8[]</type>, <type>float8[]</type> )
</entry> <returnvalue>cube</returnvalue>
<entry> </para>
<literal>cube('(1,2),(3,4)'::cube, 5) == '(1,2,5),(3,4,5)'</literal> <para>
</entry> Makes a cube with upper right and lower left coordinates as defined by
</row> the two arrays, which must be of the same length.
</para>
<row> <para>
<entry><literal>cube(cube, float8, float8)</literal></entry> <literal>cube(ARRAY[1,2], ARRAY[3,4])</literal>
<entry><type>cube</type></entry> <returnvalue>(1, 2),(3, 4)</returnvalue>
<entry>Makes a new cube by adding a dimension on to an existing </para></entry>
cube. This is useful for building cubes piece by piece from calculated </row>
values.
</entry> <row>
<entry> <entry role="func_table_entry"><para role="func_signature">
<literal>cube('(1,2),(3,4)'::cube, 5, 6) == '(1,2,5),(3,4,6)'</literal> <function>cube</function> ( <type>cube</type>, <type>float8</type> )
</entry> <returnvalue>cube</returnvalue>
</row> </para>
<para>
<row> Makes a new cube by adding a dimension on to an existing cube,
<entry><literal>cube_dim(cube)</literal></entry> with the same values for both endpoints of the new coordinate. This
<entry><type>integer</type></entry> is useful for building cubes piece by piece from calculated values.
<entry>Returns the number of dimensions of the cube. </para>
</entry> <para>
<entry> <literal>cube('(1,2),(3,4)'::cube, 5)</literal>
<literal>cube_dim('(1,2),(3,4)') == '2'</literal> <returnvalue>(1, 2, 5),(3, 4, 5)</returnvalue>
</entry> </para></entry>
</row> </row>
<row> <row>
<entry><literal>cube_ll_coord(cube, integer)</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>float8</type></entry> <function>cube</function> ( <type>cube</type>, <type>float8</type>, <type>float8</type> )
<entry>Returns the <replaceable>n</replaceable>-th coordinate value for the lower <returnvalue>cube</returnvalue>
left corner of the cube. </para>
</entry> <para>
<entry> Makes a new cube by adding a dimension on to an existing cube. This is
<literal>cube_ll_coord('(1,2),(3,4)', 2) == '2'</literal> useful for building cubes piece by piece from calculated values.
</entry> </para>
</row> <para>
<literal>cube('(1,2),(3,4)'::cube, 5, 6)</literal>
<row> <returnvalue>(1, 2, 5),(3, 4, 6)</returnvalue>
<entry><literal>cube_ur_coord(cube, integer)</literal></entry> </para></entry>
<entry><type>float8</type></entry> </row>
<entry>Returns the <replaceable>n</replaceable>-th coordinate value for the
upper right corner of the cube. <row>
</entry> <entry role="func_table_entry"><para role="func_signature">
<entry> <function>cube_dim</function> ( <type>cube</type> )
<literal>cube_ur_coord('(1,2),(3,4)', 2) == '4'</literal> <returnvalue>integer</returnvalue>
</entry> </para>
</row> <para>
Returns the number of dimensions of the cube.
<row> </para>
<entry><literal>cube_is_point(cube)</literal></entry> <para>
<entry><type>boolean</type></entry> <literal>cube_dim('(1,2),(3,4)')</literal>
<entry>Returns true if the cube is a point, that is, <returnvalue>2</returnvalue>
the two defining corners are the same.</entry> </para></entry>
<entry> </row>
</entry>
</row> <row>
<entry role="func_table_entry"><para role="func_signature">
<row> <function>cube_ll_coord</function> ( <type>cube</type>, <type>integer</type> )
<entry><literal>cube_distance(cube, cube)</literal></entry> <returnvalue>float8</returnvalue>
<entry><type>float8</type></entry> </para>
<entry>Returns the distance between two cubes. If both <para>
cubes are points, this is the normal distance function. Returns the <parameter>n</parameter>-th coordinate value for the lower
</entry> left corner of the cube.
<entry> </para>
</entry> <para>
</row> <literal>cube_ll_coord('(1,2),(3,4)', 2)</literal>
<returnvalue>2</returnvalue>
<row> </para></entry>
<entry><literal>cube_subset(cube, integer[])</literal></entry> </row>
<entry><type>cube</type></entry>
<entry>Makes a new cube from an existing cube, using a list of <row>
dimension indexes from an array. Can be used to extract the endpoints <entry role="func_table_entry"><para role="func_signature">
of a single dimension, or to drop dimensions, or to reorder them as <function>cube_ur_coord</function> ( <type>cube</type>, <type>integer</type> )
desired. <returnvalue>float8</returnvalue>
</entry> </para>
<entry> <para>
<literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[2]) == '(3),(7)'</literal> Returns the <parameter>n</parameter>-th coordinate value for the
<literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[3,2,1,1]) == upper right corner of the cube.
'(5,3,1,1),(8,7,6,6)'</literal> </para>
</entry> <para>
</row> <literal>cube_ur_coord('(1,2),(3,4)', 2)</literal>
<returnvalue>4</returnvalue>
<row> </para></entry>
<entry><literal>cube_union(cube, cube)</literal></entry> </row>
<entry><type>cube</type></entry>
<entry>Produces the union of two cubes. <row>
</entry> <entry role="func_table_entry"><para role="func_signature">
<entry> <function>cube_is_point</function> ( <type>cube</type> )
</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para>
<row> Returns true if the cube is a point, that is,
<entry><literal>cube_inter(cube, cube)</literal></entry> the two defining corners are the same.
<entry><type>cube</type></entry> </para>
<entry>Produces the intersection of two cubes. <para>
</entry> <literal>cube_is_point(cube(1,1))</literal>
<entry> <returnvalue>t</returnvalue>
</entry> </para></entry>
</row> </row>
<row> <row>
<entry><literal>cube_enlarge(c cube, r double, n integer)</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>cube</type></entry> <function>cube_distance</function> ( <type>cube</type>, <type>cube</type> )
<entry>Increases the size of the cube by the specified <returnvalue>float8</returnvalue>
radius <replaceable>r</replaceable> in at least <replaceable>n</replaceable> dimensions. </para>
If the radius is negative the cube is shrunk instead. <para>
All defined dimensions are changed by the radius <replaceable>r</replaceable>. Returns the distance between two cubes. If both
Lower-left coordinates are decreased by <replaceable>r</replaceable> and cubes are points, this is the normal distance function.
upper-right coordinates are increased by <replaceable>r</replaceable>. If a </para>
lower-left coordinate is increased to more than the corresponding <para>
upper-right coordinate (this can only happen when <replaceable>r</replaceable> <literal>cube_distance('(1,2)', '(3,4)')</literal>
&lt; 0) than both coordinates are set to their average. <returnvalue>2.8284271247461903</returnvalue>
If <replaceable>n</replaceable> is greater than the number of defined dimensions </para></entry>
and the cube is being enlarged (<replaceable>r</replaceable> &gt; 0), then extra </row>
dimensions are added to make <replaceable>n</replaceable> altogether;
0 is used as the initial value for the extra coordinates. <row>
This function is useful for creating bounding boxes around a point for <entry role="func_table_entry"><para role="func_signature">
searching for nearby points. <function>cube_subset</function> ( <type>cube</type>, <type>integer[]</type> )
</entry> <returnvalue>cube</returnvalue>
<entry> </para>
<literal>cube_enlarge('(1,2),(3,4)', 0.5, 3) == <para>
'(0.5,1.5,-0.5),(3.5,4.5,0.5)'</literal> Makes a new cube from an existing cube, using a list of
</entry> dimension indexes from an array. Can be used to extract the endpoints
</row> of a single dimension, or to drop dimensions, or to reorder them as
</tbody> desired.
</tgroup> </para>
<para>
<literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[2])</literal>
<returnvalue>(3),(7)</returnvalue>
</para>
<para>
<literal>cube_subset(cube('(1,3,5),(6,7,8)'), ARRAY[3,2,1,1])</literal>
<returnvalue>(5, 3, 1, 1),(8, 7, 6, 6)</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>cube_union</function> ( <type>cube</type>, <type>cube</type> )
<returnvalue>cube</returnvalue>
</para>
<para>
Produces the union of two cubes.
</para>
<para>
<literal>cube_union('(1,2)', '(3,4)')</literal>
<returnvalue>(1, 2),(3, 4)</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>cube_inter</function> ( <type>cube</type>, <type>cube</type> )
<returnvalue>cube</returnvalue>
</para>
<para>
Produces the intersection of two cubes.
</para>
<para>
<literal>cube_inter('(1,2)', '(3,4)')</literal>
<returnvalue>(3, 4),(1, 2)</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>cube_enlarge</function> ( <parameter>c</parameter> <type>cube</type>, <parameter>r</parameter> <type>double</type>, <parameter>n</parameter> <type>integer</type> )
<returnvalue>cube</returnvalue>
</para>
<para>
Increases the size of the cube by the specified
radius <parameter>r</parameter> in at least <parameter>n</parameter>
dimensions. If the radius is negative the cube is shrunk instead.
All defined dimensions are changed by the
radius <parameter>r</parameter>. Lower-left coordinates are decreased
by <parameter>r</parameter> and upper-right coordinates are increased
by <parameter>r</parameter>. If a lower-left coordinate is increased
to more than the corresponding upper-right coordinate (this can only
happen when <parameter>r</parameter> &lt; 0) than both coordinates are
set to their average. If <parameter>n</parameter> is greater than the
number of defined dimensions and the cube is being enlarged
(<parameter>r</parameter> &gt; 0), then extra dimensions are added to
make <parameter>n</parameter> altogether; 0 is used as the initial
value for the extra coordinates. This function is useful for creating
bounding boxes around a point for searching for nearby points.
</para>
<para>
<literal>cube_enlarge('(1,2),(3,4)', 0.5, 3)</literal>
<returnvalue>(0.5, 1.5, -0.5),(3.5, 4.5, 0.5)</returnvalue>
</para></entry>
</row>
</tbody>
</tgroup>
</table> </table>
</sect2> </sect2>
......
...@@ -67,76 +67,120 @@ ...@@ -67,76 +67,120 @@
<table id="earthdistance-cube-functions"> <table id="earthdistance-cube-functions">
<title>Cube-Based Earthdistance Functions</title> <title>Cube-Based Earthdistance Functions</title>
<tgroup cols="3"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Function</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Returns</entry> Function
<entry>Description</entry> </para>
</row> <para>
</thead> Description
<tbody> </para></entry>
<row> </row>
<entry><function>earth()</function><indexterm><primary>earth</primary></indexterm></entry> </thead>
<entry><type>float8</type></entry>
<entry>Returns the assumed radius of the Earth.</entry> <tbody>
</row> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><function>sec_to_gc(float8)</function><indexterm><primary>sec_to_gc</primary></indexterm></entry> <indexterm><primary>earth</primary></indexterm>
<entry><type>float8</type></entry> <function>earth</function> ()
<entry>Converts the normal straight line <returnvalue>float8</returnvalue>
(secant) distance between two points on the surface of the Earth </para>
to the great circle distance between them. <para>
</entry> Returns the assumed radius of the Earth.
</row> </para></entry>
<row> </row>
<entry><function>gc_to_sec(float8)</function><indexterm><primary>gc_to_sec</primary></indexterm></entry>
<entry><type>float8</type></entry> <row>
<entry>Converts the great circle distance between two points on the <entry role="func_table_entry"><para role="func_signature">
surface of the Earth to the normal straight line (secant) distance <indexterm><primary>sec_to_gc</primary></indexterm>
between them. <function>sec_to_gc</function> ( <type>float8</type> )
</entry> <returnvalue>float8</returnvalue>
</row> </para>
<row> <para>
<entry><function>ll_to_earth(float8, float8)</function><indexterm><primary>ll_to_earth</primary></indexterm></entry> Converts the normal straight line
<entry><type>earth</type></entry> (secant) distance between two points on the surface of the Earth
<entry>Returns the location of a point on the surface of the Earth given to the great circle distance between them.
its latitude (argument 1) and longitude (argument 2) in degrees. </para></entry>
</entry> </row>
</row>
<row> <row>
<entry><function>latitude(earth)</function><indexterm><primary>latitude</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>float8</type></entry> <indexterm><primary>gc_to_sec</primary></indexterm>
<entry>Returns the latitude in degrees of a point on the surface of the <function>gc_to_sec</function> ( <type>float8</type> )
Earth. <returnvalue>float8</returnvalue>
</entry> </para>
</row> <para>
<row> Converts the great circle distance between two points on the
<entry><function>longitude(earth)</function><indexterm><primary>longitude</primary></indexterm></entry> surface of the Earth to the normal straight line (secant) distance
<entry><type>float8</type></entry> between them.
<entry>Returns the longitude in degrees of a point on the surface of the </para></entry>
Earth. </row>
</entry>
</row> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><function>earth_distance(earth, earth)</function><indexterm><primary>earth_distance</primary></indexterm></entry> <indexterm><primary>ll_to_earth</primary></indexterm>
<entry><type>float8</type></entry> <function>ll_to_earth</function> ( <type>float8</type>, <type>float8</type> )
<entry>Returns the great circle distance between two points on the <returnvalue>earth</returnvalue>
surface of the Earth. </para>
</entry> <para>
</row> Returns the location of a point on the surface of the Earth given
<row> its latitude (argument 1) and longitude (argument 2) in degrees.
<entry><function>earth_box(earth, float8)</function><indexterm><primary>earth_box</primary></indexterm></entry> </para></entry>
<entry><type>cube</type></entry> </row>
<entry>Returns a box suitable for an indexed search using the cube
<literal>@&gt;</literal> <row>
operator for points within a given great circle distance of a location. <entry role="func_table_entry"><para role="func_signature">
Some points in this box are further than the specified great circle <indexterm><primary>latitude</primary></indexterm>
distance from the location, so a second check using <function>latitude</function> ( <type>earth</type> )
<function>earth_distance</function> should be included in the query. <returnvalue>float8</returnvalue>
</entry> </para>
</row> <para>
</tbody> Returns the latitude in degrees of a point on the surface of the
Earth.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>longitude</primary></indexterm>
<function>longitude</function> ( <type>earth</type> )
<returnvalue>float8</returnvalue>
</para>
<para>
Returns the longitude in degrees of a point on the surface of the
Earth.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>earth_distance</primary></indexterm>
<function>earth_distance</function> ( <type>earth</type>, <type>earth</type> )
<returnvalue>float8</returnvalue>
</para>
<para>
Returns the great circle distance between two points on the
surface of the Earth.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>earth_box</primary></indexterm>
<function>earth_box</function> ( <type>earth</type>, <type>float8</type> )
<returnvalue>cube</returnvalue>
</para>
<para>
Returns a box suitable for an indexed search using the <type>cube</type>
<literal>@&gt;</literal>
operator for points within a given great circle distance of a location.
Some points in this box are further than the specified great circle
distance from the location, so a second check using
<function>earth_distance</function> should be included in the query.
</para></entry>
</row>
</tbody>
</tgroup> </tgroup>
</table> </table>
...@@ -161,23 +205,29 @@ ...@@ -161,23 +205,29 @@
<table id="earthdistance-point-operators"> <table id="earthdistance-point-operators">
<title>Point-Based Earthdistance Operators</title> <title>Point-Based Earthdistance Operators</title>
<tgroup cols="3"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Operator</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Returns</entry> Operator
<entry>Description</entry> </para>
</row> <para>
</thead> Description
<tbody> </para></entry>
<row> </row>
<entry><type>point</type> <literal>&lt;@&gt;</literal> <type>point</type></entry> </thead>
<entry><type>float8</type></entry> <tbody>
<entry>Gives the distance in statute miles between <row>
two points on the Earth's surface. <entry role="func_table_entry"><para role="func_signature">
</entry> <type>point</type> <literal>&lt;@&gt;</literal> <type>point</type>
</row> <returnvalue>float8</returnvalue>
</tbody> </para>
<para>
Computes the distance in statute miles between
two points on the Earth's surface.
</para></entry>
</row>
</tbody>
</tgroup> </tgroup>
</table> </table>
......
...@@ -99,118 +99,223 @@ key =&gt; NULL ...@@ -99,118 +99,223 @@ key =&gt; NULL
<table id="hstore-op-table"> <table id="hstore-op-table">
<title><type>hstore</type> Operators</title> <title><type>hstore</type> Operators</title>
<tgroup cols="1">
<tgroup cols="4"> <thead>
<thead> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry>Operator</entry> Operator
<entry>Description</entry> </para>
<entry>Example</entry> <para>
<entry>Result</entry> Description
</row> </para>
</thead> <para>
Example(s)
<tbody> </para></entry>
<row> </row>
<entry><type>hstore</type> <literal>-&gt;</literal> <type>text</type></entry> </thead>
<entry>get value for key (<literal>NULL</literal> if not present)</entry>
<entry><literal>'a=&gt;x, b=&gt;y'::hstore -&gt; 'a'</literal></entry> <tbody>
<entry><literal>x</literal></entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<type>hstore</type> <literal>-&gt;</literal> <type>text</type>
<row> <returnvalue>text</returnvalue>
<entry><type>hstore</type> <literal>-&gt;</literal> <type>text[]</type></entry> </para>
<entry>get values for keys (<literal>NULL</literal> if not present)</entry> <para>
<entry><literal>'a=&gt;x, b=&gt;y, c=&gt;z'::hstore -&gt; ARRAY['c','a']</literal></entry> Returns value associated with given key, or <literal>NULL</literal> if
<entry><literal>{"z","x"}</literal></entry> not present.
</row> </para>
<para>
<row> <literal>'a=&gt;x, b=&gt;y'::hstore -&gt; 'a'</literal>
<entry><type>hstore</type> <literal>||</literal> <type>hstore</type></entry> <returnvalue>x</returnvalue>
<entry>concatenate <type>hstore</type>s</entry> </para></entry>
<entry><literal>'a=&gt;b, c=&gt;d'::hstore || 'c=&gt;x, d=&gt;q'::hstore</literal></entry> </row>
<entry><literal>"a"=&gt;"b", "c"=&gt;"x", "d"=&gt;"q"</literal></entry>
</row> <row>
<entry role="func_table_entry"><para role="func_signature">
<row> <type>hstore</type> <literal>-&gt;</literal> <type>text[]</type>
<entry><type>hstore</type> <literal>?</literal> <type>text</type></entry> <returnvalue>text[]</returnvalue>
<entry>does <type>hstore</type> contain key?</entry> </para>
<entry><literal>'a=&gt;1'::hstore ? 'a'</literal></entry> <para>
<entry><literal>t</literal></entry> Returns values associated with given keys, or <literal>NULL</literal>
</row> if not present.
</para>
<row> <para>
<entry><type>hstore</type> <literal>?&amp;</literal> <type>text[]</type></entry> <literal>'a=&gt;x, b=&gt;y, c=&gt;z'::hstore -&gt; ARRAY['c','a']</literal>
<entry>does <type>hstore</type> contain all specified keys?</entry> <returnvalue>{"z","x"}</returnvalue>
<entry><literal>'a=&gt;1,b=&gt;2'::hstore ?&amp; ARRAY['a','b']</literal></entry> </para></entry>
<entry><literal>t</literal></entry> </row>
</row>
<row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><type>hstore</type> <literal>?|</literal> <type>text[]</type></entry> <type>hstore</type> <literal>||</literal> <type>hstore</type>
<entry>does <type>hstore</type> contain any of the specified keys?</entry> <returnvalue>hstore</returnvalue>
<entry><literal>'a=&gt;1,b=&gt;2'::hstore ?| ARRAY['b','c']</literal></entry> </para>
<entry><literal>t</literal></entry> <para>
</row> Concatenates two <type>hstore</type>s.
</para>
<row> <para>
<entry><type>hstore</type> <literal>@&gt;</literal> <type>hstore</type></entry> <literal>'a=&gt;b, c=&gt;d'::hstore || 'c=&gt;x, d=&gt;q'::hstore</literal>
<entry>does left operand contain right?</entry> <returnvalue>"a"=&gt;"b", "c"=&gt;"x", "d"=&gt;"q"</returnvalue>
<entry><literal>'a=&gt;b, b=&gt;1, c=&gt;NULL'::hstore @&gt; 'b=&gt;1'</literal></entry> </para></entry>
<entry><literal>t</literal></entry> </row>
</row>
<row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><type>hstore</type> <literal>&lt;@</literal> <type>hstore</type></entry> <type>hstore</type> <literal>?</literal> <type>text</type>
<entry>is left operand contained in right?</entry> <returnvalue>boolean</returnvalue>
<entry><literal>'a=&gt;c'::hstore &lt;@ 'a=&gt;b, b=&gt;1, c=&gt;NULL'</literal></entry> </para>
<entry><literal>f</literal></entry> <para>
</row> Does <type>hstore</type> contain key?
</para>
<row> <para>
<entry><type>hstore</type> <literal>-</literal> <type>text</type></entry> <literal>'a=&gt;1'::hstore ? 'a'</literal>
<entry>delete key from left operand</entry> <returnvalue>t</returnvalue>
<entry><literal>'a=&gt;1, b=&gt;2, c=&gt;3'::hstore - 'b'::text</literal></entry> </para></entry>
<entry><literal>"a"=&gt;"1", "c"=&gt;"3"</literal></entry> </row>
</row>
<row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><type>hstore</type> <literal>-</literal> <type>text[]</type></entry> <type>hstore</type> <literal>?&amp;</literal> <type>text[]</type>
<entry>delete keys from left operand</entry> <returnvalue>boolean</returnvalue>
<entry><literal>'a=&gt;1, b=&gt;2, c=&gt;3'::hstore - ARRAY['a','b']</literal></entry> </para>
<entry><literal>"c"=&gt;"3"</literal></entry> <para>
</row> Does <type>hstore</type> contain all the specified keys?
</para>
<row> <para>
<entry><type>hstore</type> <literal>-</literal> <type>hstore</type></entry> <literal>'a=&gt;1,b=&gt;2'::hstore ?&amp; ARRAY['a','b']</literal>
<entry>delete matching pairs from left operand</entry> <returnvalue>t</returnvalue>
<entry><literal>'a=&gt;1, b=&gt;2, c=&gt;3'::hstore - 'a=&gt;4, b=&gt;2'::hstore</literal></entry> </para></entry>
<entry><literal>"a"=&gt;"1", "c"=&gt;"3"</literal></entry> </row>
</row>
<row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><type>record</type> <literal>#=</literal> <type>hstore</type></entry> <type>hstore</type> <literal>?|</literal> <type>text[]</type>
<entry>replace fields in <type>record</type> with matching values from <type>hstore</type></entry> <returnvalue>boolean</returnvalue>
<entry>see Examples section</entry> </para>
<entry></entry> <para>
</row> Does <type>hstore</type> contain any of the specified keys?
</para>
<row> <para>
<entry><literal>%%</literal> <type>hstore</type></entry> <literal>'a=&gt;1,b=&gt;2'::hstore ?| ARRAY['b','c']</literal>
<entry>convert <type>hstore</type> to array of alternating keys and values</entry> <returnvalue>t</returnvalue>
<entry><literal>%% 'a=&gt;foo, b=&gt;bar'::hstore</literal></entry> </para></entry>
<entry><literal>{a,foo,b,bar}</literal></entry> </row>
</row>
<row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>%#</literal> <type>hstore</type></entry> <type>hstore</type> <literal>@&gt;</literal> <type>hstore</type>
<entry>convert <type>hstore</type> to two-dimensional key/value array</entry> <returnvalue>boolean</returnvalue>
<entry><literal>%# 'a=&gt;foo, b=&gt;bar'::hstore</literal></entry> </para>
<entry><literal>{{a,foo},{b,bar}}</literal></entry> <para>
</row> Does left operand contain right?
</para>
</tbody> <para>
</tgroup> <literal>'a=&gt;b, b=&gt;1, c=&gt;NULL'::hstore @&gt; 'b=&gt;1'</literal>
<returnvalue>t</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>hstore</type> <literal>&lt;@</literal> <type>hstore</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Is left operand contained in right?
</para>
<para>
<literal>'a=&gt;c'::hstore &lt;@ 'a=&gt;b, b=&gt;1, c=&gt;NULL'</literal>
<returnvalue>f</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>hstore</type> <literal>-</literal> <type>text</type>
<returnvalue>hstore</returnvalue>
</para>
<para>
Deletes key from left operand.
</para>
<para>
<literal>'a=&gt;1, b=&gt;2, c=&gt;3'::hstore - 'b'::text</literal>
<returnvalue>"a"=&gt;"1", "c"=&gt;"3"</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>hstore</type> <literal>-</literal> <type>text[]</type>
<returnvalue>hstore</returnvalue>
</para>
<para>
Deletes keys from left operand.
</para>
<para>
<literal>'a=&gt;1, b=&gt;2, c=&gt;3'::hstore - ARRAY['a','b']</literal>
<returnvalue>"c"=&gt;"3"</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>hstore</type> <literal>-</literal> <type>hstore</type>
<returnvalue>hstore</returnvalue>
</para>
<para>
Deletes pairs from left operand that match pairs in the right operand.
</para>
<para>
<literal>'a=&gt;1, b=&gt;2, c=&gt;3'::hstore - 'a=&gt;4, b=&gt;2'::hstore</literal>
<returnvalue>"a"=&gt;"1", "c"=&gt;"3"</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>anyelement</type> <literal>#=</literal> <type>hstore</type>
<returnvalue>anyelement</returnvalue>
</para>
<para>
Replaces fields in the left operand (which must be a composite type)
with matching values from <type>hstore</type>.
</para>
<para>
<literal>ROW(1,3) #= 'f1=>11'::hstore</literal>
<returnvalue>(11,3)</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<literal>%%</literal> <type>hstore</type>
<returnvalue>text[]</returnvalue>
</para>
<para>
Converts <type>hstore</type> to an array of alternating keys and
values.
</para>
<para>
<literal>%% 'a=&gt;foo, b=&gt;bar'::hstore</literal>
<returnvalue>{a,foo,b,bar}</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<literal>%#</literal> <type>hstore</type>
<returnvalue>text[]</returnvalue>
</para>
<para>
Converts <type>hstore</type> to a two-dimensional key/value array.
</para>
<para>
<literal>%# 'a=&gt;foo, b=&gt;bar'::hstore</literal>
<returnvalue>{{a,foo},{b,bar}}</returnvalue>
</para></entry>
</row>
</tbody>
</tgroup>
</table> </table>
<note> <note>
...@@ -225,233 +330,389 @@ key =&gt; NULL ...@@ -225,233 +330,389 @@ key =&gt; NULL
<table id="hstore-func-table"> <table id="hstore-func-table">
<title><type>hstore</type> Functions</title> <title><type>hstore</type> Functions</title>
<tgroup cols="1">
<tgroup cols="5"> <thead>
<thead> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry>Function</entry> Function
<entry>Return Type</entry> </para>
<entry>Description</entry> <para>
<entry>Example</entry> Description
<entry>Result</entry> </para>
</row> <para>
</thead> Example(s)
</para></entry>
<tbody> </row>
<row> </thead>
<entry><function>hstore(record)</function><indexterm><primary>hstore</primary></indexterm></entry>
<entry><type>hstore</type></entry> <tbody>
<entry>construct an <type>hstore</type> from a record or row</entry> <row>
<entry><literal>hstore(ROW(1,2))</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>f1=&gt;1,f2=&gt;2</literal></entry> <indexterm><primary>hstore</primary></indexterm>
</row> <function>hstore</function> ( <type>record</type> )
<returnvalue>hstore</returnvalue>
<row> </para>
<entry><function>hstore(text[])</function></entry> <para>
<entry><type>hstore</type></entry> Constructs an <type>hstore</type> from a record or row.
<entry>construct an <type>hstore</type> from an array, which may be either </para>
a key/value array, or a two-dimensional array</entry> <para>
<entry><literal>hstore(ARRAY['a','1','b','2']) || hstore(ARRAY[['c','3'],['d','4']])</literal></entry> <literal>hstore(ROW(1,2))</literal>
<entry><literal>a=&gt;1, b=&gt;2, c=&gt;3, d=&gt;4</literal></entry> <returnvalue>"f1"=&gt;"1", "f2"=&gt;"2"</returnvalue>
</row> </para></entry>
</row>
<row>
<entry><function>hstore(text[], text[])</function></entry> <row>
<entry><type>hstore</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>construct an <type>hstore</type> from separate key and value arrays</entry> <function>hstore</function> ( <type>text[]</type> )
<entry><literal>hstore(ARRAY['a','b'], ARRAY['1','2'])</literal></entry> <returnvalue>hstore</returnvalue>
<entry><literal>"a"=&gt;"1","b"=&gt;"2"</literal></entry> </para>
</row> <para>
Constructs an <type>hstore</type> from an array, which may be either
<row> a key/value array, or a two-dimensional array.
<entry><function>hstore(text, text)</function></entry> </para>
<entry><type>hstore</type></entry> <para>
<entry>make single-item <type>hstore</type></entry> <literal>hstore(ARRAY['a','1','b','2'])</literal>
<entry><literal>hstore('a', 'b')</literal></entry> <returnvalue>"a"=&gt;"1", "b"=&gt;"2"</returnvalue>
<entry><literal>"a"=&gt;"b"</literal></entry> </para>
</row> <para>
<literal>hstore(ARRAY[['c','3'],['d','4']])</literal>
<row> <returnvalue>"c"=&gt;"3", "d"=&gt;"4"</returnvalue>
<entry><function>akeys(hstore)</function><indexterm><primary>akeys</primary></indexterm></entry> </para></entry>
<entry><type>text[]</type></entry> </row>
<entry>get <type>hstore</type>'s keys as an array</entry>
<entry><literal>akeys('a=&gt;1,b=&gt;2')</literal></entry> <row>
<entry><literal>{a,b}</literal></entry> <entry role="func_table_entry"><para role="func_signature">
</row> <function>hstore</function> ( <type>text[]</type>, <type>text[]</type> )
<returnvalue>hstore</returnvalue>
<row> </para>
<entry><function>skeys(hstore)</function><indexterm><primary>skeys</primary></indexterm></entry> <para>
<entry><type>setof text</type></entry> Constructs an <type>hstore</type> from separate key and value arrays.
<entry>get <type>hstore</type>'s keys as a set</entry> </para>
<entry><literal>skeys('a=&gt;1,b=&gt;2')</literal></entry> <para>
<entry> <literal>hstore(ARRAY['a','b'], ARRAY['1','2'])</literal>
<returnvalue>"a"=&gt;"1", "b"=&gt;"2"</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>hstore</function> ( <type>text</type>, <type>text</type> )
<returnvalue>hstore</returnvalue>
</para>
<para>
Makes a single-item <type>hstore</type>.
</para>
<para>
<literal>hstore('a', 'b')</literal>
<returnvalue>"a"=&gt;"b"</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>akeys</primary></indexterm>
<function>akeys</function> ( <type>hstore</type> )
<returnvalue>text[]</returnvalue>
</para>
<para>
Extracts an <type>hstore</type>'s keys as an array.
</para>
<para>
<literal>akeys('a=&gt;1,b=&gt;2')</literal>
<returnvalue>{a,b}</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>skeys</primary></indexterm>
<function>skeys</function> ( <type>hstore</type> )
<returnvalue>setof text</returnvalue>
</para>
<para>
Extracts an <type>hstore</type>'s keys as a set.
</para>
<para>
<literal>skeys('a=&gt;1,b=&gt;2')</literal>
<returnvalue></returnvalue>
<programlisting> <programlisting>
a a
b b
</programlisting></entry> </programlisting>
</row> </para></entry>
</row>
<row>
<entry><function>avals(hstore)</function><indexterm><primary>avals</primary></indexterm></entry> <row>
<entry><type>text[]</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>get <type>hstore</type>'s values as an array</entry> <indexterm><primary>avals</primary></indexterm>
<entry><literal>avals('a=&gt;1,b=&gt;2')</literal></entry> <function>avals</function> ( <type>hstore</type> )
<entry><literal>{1,2}</literal></entry> <returnvalue>text[]</returnvalue>
</row> </para>
<para>
<row> Extracts an <type>hstore</type>'s values as an array.
<entry><function>svals(hstore)</function><indexterm><primary>svals</primary></indexterm></entry> </para>
<entry><type>setof text</type></entry> <para>
<entry>get <type>hstore</type>'s values as a set</entry> <literal>avals('a=&gt;1,b=&gt;2')</literal>
<entry><literal>svals('a=&gt;1,b=&gt;2')</literal></entry> <returnvalue>{1,2}</returnvalue>
<entry> </para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>svals</primary></indexterm>
<function>svals</function> ( <type>hstore</type> )
<returnvalue>setof text</returnvalue>
</para>
<para>
Extracts an <type>hstore</type>'s values as a set.
</para>
<para>
<literal>svals('a=&gt;1,b=&gt;2')</literal>
<returnvalue></returnvalue>
<programlisting> <programlisting>
1 1
2 2
</programlisting></entry> </programlisting>
</row> </para></entry>
</row>
<row>
<entry><function>hstore_to_array(hstore)</function><indexterm><primary>hstore_to_array</primary></indexterm></entry> <row>
<entry><type>text[]</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>get <type>hstore</type>'s keys and values as an array of alternating <indexterm><primary>hstore_to_array</primary></indexterm>
keys and values</entry> <function>hstore_to_array</function> ( <type>hstore</type> )
<entry><literal>hstore_to_array('a=&gt;1,b=&gt;2')</literal></entry> <returnvalue>text[]</returnvalue>
<entry><literal>{a,1,b,2}</literal></entry> </para>
</row> <para>
Extracts an <type>hstore</type>'s keys and values as an array of
<row> alternating keys and values.
<entry><function>hstore_to_matrix(hstore)</function><indexterm><primary>hstore_to_matrix</primary></indexterm></entry> </para>
<entry><type>text[]</type></entry> <para>
<entry>get <type>hstore</type>'s keys and values as a two-dimensional array</entry> <literal>hstore_to_array('a=&gt;1,b=&gt;2')</literal>
<entry><literal>hstore_to_matrix('a=&gt;1,b=&gt;2')</literal></entry> <returnvalue>{a,1,b,2}</returnvalue>
<entry><literal>{{a,1},{b,2}}</literal></entry> </para></entry>
</row> </row>
<row> <row>
<entry><function>hstore_to_json(hstore)</function><indexterm><primary>hstore_to_json</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>json</type></entry> <indexterm><primary>hstore_to_matrix</primary></indexterm>
<entry>get <type>hstore</type> as a <type>json</type> value, converting <function>hstore_to_matrix</function> ( <type>hstore</type> )
all non-null values to JSON strings</entry> <returnvalue>text[]</returnvalue>
<entry><literal>hstore_to_json('"a key"=&gt;1, b=&gt;t, c=&gt;null, d=&gt;12345, e=&gt;012345, f=&gt;1.234, g=&gt;2.345e+4')</literal></entry> </para>
<entry><literal>{"a key": "1", "b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4"}</literal></entry> <para>
</row> Extracts an <type>hstore</type>'s keys and values as a two-dimensional
array.
<row> </para>
<entry><function>hstore_to_jsonb(hstore)</function><indexterm><primary>hstore_to_jsonb</primary></indexterm></entry> <para>
<entry><type>jsonb</type></entry> <literal>hstore_to_matrix('a=&gt;1,b=&gt;2')</literal>
<entry>get <type>hstore</type> as a <type>jsonb</type> value, converting <returnvalue>{{a,1},{b,2}}</returnvalue>
all non-null values to JSON strings</entry> </para></entry>
<entry><literal>hstore_to_jsonb('"a key"=&gt;1, b=&gt;t, c=&gt;null, d=&gt;12345, e=&gt;012345, f=&gt;1.234, g=&gt;2.345e+4')</literal></entry> </row>
<entry><literal>{"a key": "1", "b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4"}</literal></entry>
</row> <row>
<entry role="func_table_entry"><para role="func_signature">
<row> <indexterm><primary>hstore_to_json</primary></indexterm>
<entry><function>hstore_to_json_loose(hstore)</function><indexterm><primary>hstore_to_json_loose</primary></indexterm></entry> <function>hstore_to_json</function> ( <type>hstore</type> )
<entry><type>json</type></entry> <returnvalue>json</returnvalue>
<entry>get <type>hstore</type> as a <type>json</type> value, but attempt to distinguish numerical and Boolean values so they are unquoted in the JSON</entry> </para>
<entry><literal>hstore_to_json_loose('"a key"=&gt;1, b=&gt;t, c=&gt;null, d=&gt;12345, e=&gt;012345, f=&gt;1.234, g=&gt;2.345e+4')</literal></entry> <para>
<entry><literal>{"a key": 1, "b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4}</literal></entry> Converts an <type>hstore</type> to a <type>json</type> value,
</row> converting all non-null values to JSON strings.
</para>
<row> <para>
<entry><function>hstore_to_jsonb_loose(hstore)</function><indexterm><primary>hstore_to_jsonb_loose</primary></indexterm></entry> This function is used implicitly when an <type>hstore</type> value is
<entry><type>jsonb</type></entry> cast to <type>json</type>.
<entry>get <type>hstore</type> as a <type>jsonb</type> value, but attempt to distinguish numerical and Boolean values so they are unquoted in the JSON</entry> </para>
<entry><literal>hstore_to_jsonb_loose('"a key"=&gt;1, b=&gt;t, c=&gt;null, d=&gt;12345, e=&gt;012345, f=&gt;1.234, g=&gt;2.345e+4')</literal></entry> <para>
<entry><literal>{"a key": 1, "b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4}</literal></entry> <literal>hstore_to_json('"a key"=&gt;1, b=&gt;t, c=&gt;null, d=&gt;12345, e=&gt;012345, f=&gt;1.234, g=&gt;2.345e+4')</literal>
</row> <returnvalue>{"a key": "1", "b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4"}</returnvalue>
</para></entry>
<row> </row>
<entry><function>slice(hstore, text[])</function><indexterm><primary>slice</primary></indexterm></entry>
<entry><type>hstore</type></entry> <row>
<entry>extract a subset of an <type>hstore</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>slice('a=&gt;1,b=&gt;2,c=&gt;3'::hstore, ARRAY['b','c','x'])</literal></entry> <indexterm><primary>hstore_to_jsonb</primary></indexterm>
<entry><literal>"b"=&gt;"2", "c"=&gt;"3"</literal></entry> <function>hstore_to_jsonb</function> ( <type>hstore</type> )
</row> <returnvalue>jsonb</returnvalue>
</para>
<row> <para>
<entry><function>each(hstore)</function><indexterm><primary>each</primary></indexterm></entry> Converts an <type>hstore</type> to a <type>jsonb</type> value,
<entry><type>setof(key text, value text)</type></entry> converting all non-null values to JSON strings.
<entry>get <type>hstore</type>'s keys and values as a set</entry> </para>
<entry><literal>select * from each('a=&gt;1,b=&gt;2')</literal></entry> <para>
<entry> This function is used implicitly when an <type>hstore</type> value is
cast to <type>jsonb</type>.
</para>
<para>
<literal>hstore_to_jsonb('"a key"=&gt;1, b=&gt;t, c=&gt;null, d=&gt;12345, e=&gt;012345, f=&gt;1.234, g=&gt;2.345e+4')</literal>
<returnvalue>{"a key": "1", "b": "t", "c": null, "d": "12345", "e": "012345", "f": "1.234", "g": "2.345e+4"}</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>hstore_to_json_loose</primary></indexterm>
<function>hstore_to_json_loose</function> ( <type>hstore</type> )
<returnvalue>json</returnvalue>
</para>
<para>
Converts an <type>hstore</type> to a <type>json</type> value, but
attempts to distinguish numerical and Boolean values so they are
unquoted in the JSON.
</para>
<para>
<literal>hstore_to_json_loose('"a key"=&gt;1, b=&gt;t, c=&gt;null, d=&gt;12345, e=&gt;012345, f=&gt;1.234, g=&gt;2.345e+4')</literal>
<returnvalue>{"a key": 1, "b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4}</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>hstore_to_jsonb_loose</primary></indexterm>
<function>hstore_to_jsonb_loose</function> ( <type>hstore</type> )
<returnvalue>jsonb</returnvalue>
</para>
<para>
Converts an <type>hstore</type> to a <type>jsonb</type> value, but
attempts to distinguish numerical and Boolean values so they are
unquoted in the JSON.
</para>
<para>
<literal>hstore_to_jsonb_loose('"a key"=&gt;1, b=&gt;t, c=&gt;null, d=&gt;12345, e=&gt;012345, f=&gt;1.234, g=&gt;2.345e+4')</literal>
<returnvalue>{"a key": 1, "b": true, "c": null, "d": 12345, "e": "012345", "f": 1.234, "g": 2.345e+4}</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>slice</primary></indexterm>
<function>slice</function> ( <type>hstore</type>, <type>text[]</type> )
<returnvalue>hstore</returnvalue>
</para>
<para>
Extracts a subset of an <type>hstore</type> containing only the
specified keys.
</para>
<para>
<literal>slice('a=&gt;1,b=&gt;2,c=&gt;3'::hstore, ARRAY['b','c','x'])</literal>
<returnvalue>"b"=&gt;"2", "c"=&gt;"3"</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>each</primary></indexterm>
<function>each</function> ( <type>hstore</type> )
<returnvalue>setof record</returnvalue>
( <parameter>key</parameter> <type>text</type>,
<parameter>value</parameter> <type>text</type> )
</para>
<para>
Extracts an <type>hstore</type>'s keys and values as a set of records.
</para>
<para>
<literal>select * from each('a=&gt;1,b=&gt;2')</literal>
<returnvalue></returnvalue>
<programlisting> <programlisting>
key | value key | value
-----+------- -----+-------
a | 1 a | 1
b | 2 b | 2
</programlisting></entry> </programlisting>
</row> </para></entry>
</row>
<row>
<entry><function>exist(hstore,text)</function><indexterm><primary>exist</primary></indexterm></entry> <row>
<entry><type>boolean</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>does <type>hstore</type> contain key?</entry> <indexterm><primary>exist</primary></indexterm>
<entry><literal>exist('a=&gt;1','a')</literal></entry> <function>exist</function> ( <type>hstore</type>, <type>text</type> )
<entry><literal>t</literal></entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para>
<row> Does <type>hstore</type> contain key?
<entry><function>defined(hstore,text)</function><indexterm><primary>defined</primary></indexterm></entry> </para>
<entry><type>boolean</type></entry> <para>
<entry>does <type>hstore</type> contain non-<literal>NULL</literal> value for key?</entry> <literal>exist('a=&gt;1','a')</literal>
<entry><literal>defined('a=&gt;NULL','a')</literal></entry> <returnvalue>t</returnvalue>
<entry><literal>f</literal></entry> </para></entry>
</row> </row>
<row> <row>
<entry><function>delete(hstore,text)</function><indexterm><primary>delete</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>hstore</type></entry> <indexterm><primary>defined</primary></indexterm>
<entry>delete pair with matching key</entry> <function>defined</function> ( <type>hstore</type>, <type>text</type> )
<entry><literal>delete('a=&gt;1,b=&gt;2','b')</literal></entry> <returnvalue>boolean</returnvalue>
<entry><literal>"a"=&gt;"1"</literal></entry> </para>
</row> <para>
Does <type>hstore</type> contain a non-<literal>NULL</literal> value
<row> for key?
<entry><function>delete(hstore,text[])</function></entry> </para>
<entry><type>hstore</type></entry> <para>
<entry>delete pairs with matching keys</entry> <literal>defined('a=&gt;NULL','a')</literal>
<entry><literal>delete('a=&gt;1,b=&gt;2,c=&gt;3',ARRAY['a','b'])</literal></entry> <returnvalue>f</returnvalue>
<entry><literal>"c"=&gt;"3"</literal></entry> </para></entry>
</row> </row>
<row> <row>
<entry><function>delete(hstore,hstore)</function></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>hstore</type></entry> <indexterm><primary>delete</primary></indexterm>
<entry>delete pairs matching those in the second argument</entry> <function>delete</function> ( <type>hstore</type>, <type>text</type> )
<entry><literal>delete('a=&gt;1,b=&gt;2','a=&gt;4,b=&gt;2'::hstore)</literal></entry> <returnvalue>hstore</returnvalue>
<entry><literal>"a"=&gt;"1"</literal></entry> </para>
</row> <para>
Deletes pair with matching key.
<row> </para>
<entry><function>populate_record(record,hstore)</function><indexterm><primary>populate_record</primary></indexterm></entry> <para>
<entry><type>record</type></entry> <literal>delete('a=&gt;1,b=&gt;2','b')</literal>
<entry>replace fields in <type>record</type> with matching values from <type>hstore</type></entry> <returnvalue>"a"=&gt;"1"</returnvalue>
<entry>see Examples section</entry> </para></entry>
<entry></entry> </row>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>delete</function> ( <type>hstore</type>, <type>text[]</type> )
<returnvalue>hstore</returnvalue>
</para>
<para>
Deletes pairs with matching keys.
</para>
<para>
<literal>delete('a=&gt;1,b=&gt;2,c=&gt;3',ARRAY['a','b'])</literal>
<returnvalue>"c"=&gt;"3"</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>delete</function> ( <type>hstore</type>, <type>hstore</type> )
<returnvalue>hstore</returnvalue>
</para>
<para>
Deletes pairs matching those in the second argument.
</para>
<para>
<literal>delete('a=&gt;1,b=&gt;2','a=&gt;4,b=&gt;2'::hstore)</literal>
<returnvalue>"a"=&gt;"1"</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>populate_record</primary></indexterm>
<function>populate_record</function> ( <type>anyelement</type>, <type>hstore</type> )
<returnvalue>anyelement</returnvalue>
</para>
<para>
Replaces fields in the left operand (which must be a composite type)
with matching values from <type>hstore</type>.
</para>
<para>
<literal>populate_record(ROW(1,2), 'f1=>42'::hstore)</literal>
<returnvalue>(42,2)</returnvalue>
</para></entry>
</row>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>
<note>
<para>
The function <function>hstore_to_json</function> is used when
an <type>hstore</type> value is cast to <type>json</type>.
Likewise, <function>hstore_to_jsonb</function> is used when
an <type>hstore</type> value is cast to <type>jsonb</type>.
</para>
</note>
<note>
<para>
The function <function>populate_record</function> is actually declared
with <type>anyelement</type>, not <type>record</type>, as its first argument,
but it will reject non-record types with a run-time error.
</para>
</note>
</sect2> </sect2>
<sect2> <sect2>
......
...@@ -41,186 +41,325 @@ ...@@ -41,186 +41,325 @@
<table id="intarray-func-table"> <table id="intarray-func-table">
<title><filename>intarray</filename> Functions</title> <title><filename>intarray</filename> Functions</title>
<tgroup cols="1">
<tgroup cols="5"> <thead>
<thead> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry>Function</entry> Function
<entry>Return Type</entry> </para>
<entry>Description</entry> <para>
<entry>Example</entry> Description
<entry>Result</entry> </para>
</row> <para>
</thead> Example(s)
</para></entry>
<tbody> </row>
<row> </thead>
<entry><function>icount(int[])</function><indexterm><primary>icount</primary></indexterm></entry>
<entry><type>int</type></entry> <tbody>
<entry>number of elements in array</entry> <row>
<entry><literal>icount('{1,2,3}'::int[])</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>3</literal></entry> <indexterm><primary>icount</primary></indexterm>
</row> <function>icount</function> ( <type>integer[]</type> )
<returnvalue>integer</returnvalue>
<row> </para>
<entry><function>sort(int[], text dir)</function><indexterm><primary>sort</primary></indexterm></entry> <para>
<entry><type>int[]</type></entry> Returns the number of elements in the array.
<entry>sort array &mdash; <parameter>dir</parameter> must be <literal>asc</literal> or <literal>desc</literal></entry> </para>
<entry><literal>sort('{1,2,3}'::int[], 'desc')</literal></entry> <para>
<entry><literal>{3,2,1}</literal></entry> <literal>icount('{1,2,3}'::integer[])</literal>
</row> <returnvalue>3</returnvalue>
</para></entry>
<row> </row>
<entry><function>sort(int[])</function></entry>
<entry><type>int[]</type></entry> <row>
<entry>sort in ascending order</entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>sort(array[11,77,44])</literal></entry> <indexterm><primary>sort</primary></indexterm>
<entry><literal>{11,44,77}</literal></entry> <function>sort</function> ( <type>integer[]</type>, <parameter>dir</parameter> <type>text</type> )
</row> <returnvalue>integer[]</returnvalue>
</para>
<row> <para>
<entry><function>sort_asc(int[])</function><indexterm><primary>sort_asc</primary></indexterm></entry> Sorts the array in either ascending or descending order.
<entry><type>int[]</type></entry> <parameter>dir</parameter> must be <literal>asc</literal>
<entry>sort in ascending order</entry> or <literal>desc</literal>.
<entry><literal></literal></entry> </para>
<entry><literal></literal></entry> <para>
</row> <literal>sort('{1,3,2}'::integer[], 'desc')</literal>
<returnvalue>{3,2,1}</returnvalue>
<row> </para></entry>
<entry><function>sort_desc(int[])</function><indexterm><primary>sort_desc</primary></indexterm></entry> </row>
<entry><type>int[]</type></entry>
<entry>sort in descending order</entry> <row>
<entry><literal></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal></literal></entry> <function>sort</function> ( <type>integer[]</type> )
</row> <returnvalue>integer[]</returnvalue>
</para>
<row> <para role="func_signature">
<entry><function>uniq(int[])</function><indexterm><primary>uniq</primary></indexterm></entry> <indexterm><primary>sort_asc</primary></indexterm>
<entry><type>int[]</type></entry> <function>sort_asc</function> ( <type>integer[]</type> )
<entry>remove adjacent duplicates</entry> <returnvalue>integer[]</returnvalue>
<entry><literal>uniq(sort('{1,2,3,2,1}'::int[]))</literal></entry> </para>
<entry><literal>{1,2,3}</literal></entry> <para>
</row> Sorts in ascending order.
</para>
<row> <para>
<entry><function>idx(int[], int item)</function><indexterm><primary>idx</primary></indexterm></entry> <literal>sort(array[11,77,44])</literal>
<entry><type>int</type></entry> <returnvalue>{11,44,77}</returnvalue>
<entry>index of first element matching <parameter>item</parameter> (0 if none)</entry> </para></entry>
<entry><literal>idx(array[11,22,33,22,11], 22)</literal></entry> </row>
<entry><literal>2</literal></entry>
</row> <row>
<entry role="func_table_entry"><para role="func_signature">
<row> <indexterm><primary>sort_desc</primary></indexterm>
<entry><function>subarray(int[], int start, int len)</function><indexterm><primary>subarray</primary></indexterm></entry> <function>sort_desc</function> ( <type>integer[]</type> )
<entry><type>int[]</type></entry> <returnvalue>integer[]</returnvalue>
<entry>portion of array starting at position <parameter>start</parameter>, <parameter>len</parameter> elements</entry> </para>
<entry><literal>subarray('{1,2,3,2,1}'::int[], 2, 3)</literal></entry> <para>
<entry><literal>{2,3,2}</literal></entry> Sorts in descending order.
</row> </para>
<para>
<row> <literal>sort_desc(array[11,77,44])</literal>
<entry><function>subarray(int[], int start)</function></entry> <returnvalue>{77,44,11}</returnvalue>
<entry><type>int[]</type></entry> </para></entry>
<entry>portion of array starting at position <parameter>start</parameter></entry> </row>
<entry><literal>subarray('{1,2,3,2,1}'::int[], 2)</literal></entry>
<entry><literal>{2,3,2,1}</literal></entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>uniq</primary></indexterm>
<row> <function>uniq</function> ( <type>integer[]</type> )
<entry><function>intset(int)</function><indexterm><primary>intset</primary></indexterm></entry> <returnvalue>integer[]</returnvalue>
<entry><type>int[]</type></entry> </para>
<entry>make single-element array</entry> <para>
<entry><literal>intset(42)</literal></entry> Removes adjacent duplicates.
<entry><literal>{42}</literal></entry> </para>
</row> <para>
<literal>uniq(sort('{1,2,3,2,1}'::integer[]))</literal>
<returnvalue>{1,2,3}</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>idx</primary></indexterm>
<function>idx</function> ( <type>integer[]</type>, <parameter>item</parameter> <type>integer</type> )
<returnvalue>integer</returnvalue>
</para>
<para>
Returns index of the first array element
matching <parameter>item</parameter>, or 0 if no match.
</para>
<para>
<literal>idx(array[11,22,33,22,11], 22)</literal>
<returnvalue>2</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>subarray</primary></indexterm>
<function>subarray</function> ( <type>integer[]</type>, <parameter>start</parameter> <type>integer</type>, <parameter>len</parameter> <type>integer</type> )
<returnvalue>integer[]</returnvalue>
</para>
<para>
Extracts the portion of the array starting at
position <parameter>start</parameter>, with <parameter>len</parameter>
elements.
</para>
<para>
<literal>subarray('{1,2,3,2,1}'::integer[], 2, 3)</literal>
<returnvalue>{2,3,2}</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>subarray</function> ( <type>integer[]</type>, <parameter>start</parameter> <type>integer</type> )
<returnvalue>integer[]</returnvalue>
</para>
<para>
Extracts the portion of the array starting at
position <parameter>start</parameter>.
</para>
<para>
<literal>subarray('{1,2,3,2,1}'::integer[], 2)</literal>
<returnvalue>{2,3,2,1}</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>intset</primary></indexterm>
<function>intset</function> ( <type>integer</type> )
<returnvalue>integer[]</returnvalue>
</para>
<para>
Makes a single-element array.
</para>
<para>
<literal>intset(42)</literal>
<returnvalue>{42}</returnvalue>
</para></entry>
</row>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>
<table id="intarray-op-table"> <table id="intarray-op-table">
<title><filename>intarray</filename> Operators</title> <title><filename>intarray</filename> Operators</title>
<tgroup cols="1">
<tgroup cols="3"> <thead>
<thead> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry>Operator</entry> Operator
<entry>Returns</entry> </para>
<entry>Description</entry> <para>
</row> Description
</thead> </para></entry>
</row>
<tbody> </thead>
<row>
<entry><literal>int[] &amp;&amp; int[]</literal></entry> <tbody>
<entry><type>boolean</type></entry> <row>
<entry>overlap &mdash; <literal>true</literal> if arrays have at least one common element</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <type>integer[]</type> <literal>&amp;&amp;</literal> <type>integer[]</type>
<row> <returnvalue>boolean</returnvalue>
<entry><literal>int[] @&gt; int[]</literal></entry> </para>
<entry><type>boolean</type></entry> <para>
<entry>contains &mdash; <literal>true</literal> if left array contains right array</entry> Do arrays overlap (have at least one element in common)?
</row> </para></entry>
<row> </row>
<entry><literal>int[] &lt;@ int[]</literal></entry>
<entry><type>boolean</type></entry> <row>
<entry>contained &mdash; <literal>true</literal> if left array is contained in right array</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <type>integer[]</type> <literal>@&gt;</literal> <type>integer[]</type>
<row> <returnvalue>boolean</returnvalue>
<entry><literal># int[]</literal></entry> </para>
<entry><type>int</type></entry> <para>
<entry>number of elements in array</entry> Does left array contain right array?
</row> </para></entry>
<row> </row>
<entry><literal>int[] # int</literal></entry>
<entry><type>int</type></entry> <row>
<entry>index (same as <function>idx</function> function)</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <type>integer[]</type> <literal>&lt;@</literal> <type>integer[]</type>
<row> <returnvalue>boolean</returnvalue>
<entry><literal>int[] + int</literal></entry> </para>
<entry><type>int[]</type></entry> <para>
<entry>push element onto array (add it to end of array)</entry> Is left array contained in right array?
</row> </para></entry>
<row> </row>
<entry><literal>int[] + int[] </literal></entry>
<entry><type>int[]</type></entry> <row>
<entry>array concatenation (right array added to the end of left one)</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <type></type> <literal>#</literal> <type>integer[]</type>
<row> <returnvalue>integer</returnvalue>
<entry><literal>int[] - int</literal></entry> </para>
<entry><type>int[]</type></entry> <para>
<entry>remove entries matching right argument from array</entry> Returns the number of elements in the array.
</row> </para></entry>
<row> </row>
<entry><literal>int[] - int[]</literal></entry>
<entry><type>int[]</type></entry> <row>
<entry>remove elements of right array from left</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <type>integer[]</type> <literal>#</literal> <type>integer</type>
<row> <returnvalue>integer</returnvalue>
<entry><literal>int[] | int</literal></entry> </para>
<entry><type>int[]</type></entry> <para>
<entry>union of arguments</entry> Returns index of the first array element
</row> matching the right argument, or 0 if no match.
<row> (Same as <function>idx</function> function.)
<entry><literal>int[] | int[]</literal></entry> </para></entry>
<entry><type>int[]</type></entry> </row>
<entry>union of arrays</entry>
</row> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>int[] &amp; int[]</literal></entry> <type>integer[]</type> <literal>+</literal> <type>integer</type>
<entry><type>int[]</type></entry> <returnvalue>integer[]</returnvalue>
<entry>intersection of arrays</entry> </para>
</row> <para>
<row> Adds element to end of array.
<entry><literal>int[] @@ query_int</literal></entry> </para></entry>
<entry><type>boolean</type></entry> </row>
<entry><literal>true</literal> if array satisfies query (see below)</entry>
</row> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>query_int ~~ int[]</literal></entry> <type>integer[]</type> <literal>+</literal> <type>integer[]</type>
<entry><type>boolean</type></entry> <returnvalue>integer[]</returnvalue>
<entry><literal>true</literal> if array satisfies query (commutator of <literal>@@</literal>)</entry> </para>
</row> <para>
Concatenates the arrays.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>integer[]</type> <literal>-</literal> <type>integer</type>
<returnvalue>integer[]</returnvalue>
</para>
<para>
Removes entries matching the right argument from the array.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>integer[]</type> <literal>-</literal> <type>integer[]</type>
<returnvalue>integer[]</returnvalue>
</para>
<para>
Removes elements of the right array from the left array.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>integer[]</type> <literal>|</literal> <type>integer</type>
<returnvalue>integer[]</returnvalue>
</para>
<para>
Computes the union of the arguments.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>integer[]</type> <literal>|</literal> <type>integer[]</type>
<returnvalue>integer[]</returnvalue>
</para>
<para>
Computes the union of the arguments.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>integer[]</type> <literal>&amp;</literal> <type>integer[]</type>
<returnvalue>integer[]</returnvalue>
</para>
<para>
Computes the intersection of the arguments.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>integer[]</type> <literal>@@</literal> <type>query_int</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Does array satisfy query? (see below)
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>query_int</type> <literal>~~</literal> <type>integer[]</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Does array satisfy query? (commutator of <literal>@@</literal>)
</para></entry>
</row>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>
...@@ -274,7 +413,7 @@ ...@@ -274,7 +413,7 @@
The implementation uses an RD-tree data structure with The implementation uses an RD-tree data structure with
built-in lossy compression. built-in lossy compression.
</para> </para>
<para> <para>
<literal>gist__int_ops</literal> approximates an integer set as an array of <literal>gist__int_ops</literal> approximates an integer set as an array of
integer ranges. Its optional integer parameter <literal>numranges</literal> integer ranges. Its optional integer parameter <literal>numranges</literal>
...@@ -284,7 +423,7 @@ ...@@ -284,7 +423,7 @@
keys leads to a more precise search (scanning a smaller fraction of the index and keys leads to a more precise search (scanning a smaller fraction of the index and
fewer heap pages), at the cost of a larger index. fewer heap pages), at the cost of a larger index.
</para> </para>
<para> <para>
<literal>gist__intbig_ops</literal> approximates an integer set as a bitmap <literal>gist__intbig_ops</literal> approximates an integer set as a bitmap
signature. Its optional integer parameter <literal>siglen</literal> signature. Its optional integer parameter <literal>siglen</literal>
......
...@@ -38,6 +38,8 @@ ...@@ -38,6 +38,8 @@
<table id="isn-datatypes"> <table id="isn-datatypes">
<title><filename>isn</filename> Data Types</title> <title><filename>isn</filename> Data Types</title>
<tgroup cols="2"> <tgroup cols="2">
<colspec colname="col1" colwidth="1*"/>
<colspec colname="col2" colwidth="2*"/>
<thead> <thead>
<row> <row>
<entry>Data Type</entry> <entry>Data Type</entry>
...@@ -235,38 +237,63 @@ ...@@ -235,38 +237,63 @@
<table id="isn-functions"> <table id="isn-functions">
<title><filename>isn</filename> Functions</title> <title><filename>isn</filename> Functions</title>
<tgroup cols="3"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Function</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Returns</entry> Function
<entry>Description</entry> </para>
</row> <para>
</thead> Description
</para></entry>
<tbody> </row>
<row> </thead>
<entry><function>isn_weak(boolean)</function><indexterm><primary>isn_weak</primary></indexterm></entry>
<entry><type>boolean</type></entry> <tbody>
<entry>Sets the weak input mode (returns new setting)</entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<row> <indexterm><primary>isn_weak</primary></indexterm>
<entry><function>isn_weak()</function></entry> <function>isn_weak</function> ( <type>boolean</type> )
<entry><type>boolean</type></entry> <returnvalue>boolean</returnvalue>
<entry>Gets the current status of the weak mode</entry> </para>
</row> <para>
<row> Sets the weak input mode, and returns new setting.
<entry><function>make_valid(isn)</function><indexterm><primary>make_valid</primary></indexterm></entry> </para></entry>
<entry><type>isn</type></entry> </row>
<entry>Validates an invalid number (clears the invalid flag)</entry>
</row> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><function>is_valid(isn)</function><indexterm><primary>is_valid</primary></indexterm></entry> <function>isn_weak</function> ()
<entry><type>boolean</type></entry> <returnvalue>boolean</returnvalue>
<entry>Checks for the presence of the invalid flag</entry> </para>
</row> <para>
</tbody> Returns the current status of the weak mode.
</tgroup> </para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>make_valid</primary></indexterm>
<function>make_valid</function> ( <type>isn</type> )
<returnvalue>isn</returnvalue>
</para>
<para>
Validates an invalid number (clears the invalid flag).
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>is_valid</primary></indexterm>
<function>is_valid</function> ( <type>isn</type> )
<returnvalue>boolean</returnvalue>
</para>
<para>
Checks for the presence of the invalid flag.
</para></entry>
</row>
</tbody>
</tgroup>
</table> </table>
<para> <para>
......
...@@ -542,69 +542,82 @@ int lo_unlink(PGconn *conn, Oid lobjId); ...@@ -542,69 +542,82 @@ int lo_unlink(PGconn *conn, Oid lobjId);
listed in <xref linkend="lo-funcs-table"/>. listed in <xref linkend="lo-funcs-table"/>.
</para> </para>
<table id="lo-funcs-table"> <table id="lo-funcs-table">
<title>SQL-Oriented Large Object Functions</title> <title>SQL-Oriented Large Object Functions</title>
<tgroup cols="5"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Function</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Return Type</entry> Function
<entry>Description</entry> </para>
<entry>Example</entry> <para>
<entry>Result</entry> Description
</row> </para>
</thead> <para>
Example(s)
<tbody> </para></entry>
<row> </row>
<entry> </thead>
<indexterm>
<primary>lo_from_bytea</primary> <tbody>
</indexterm> <row>
<literal><function>lo_from_bytea(<parameter>loid</parameter> <type>oid</type>, <parameter>string</parameter> <type>bytea</type>)</function></literal> <entry role="func_table_entry"><para role="func_signature">
</entry> <indexterm>
<entry><type>oid</type></entry> <primary>lo_from_bytea</primary>
<entry> </indexterm>
Create a large object and store data there, returning its OID. <function>lo_from_bytea</function> ( <parameter>loid</parameter> <type>oid</type>, <parameter>data</parameter> <type>bytea</type> )
Pass <literal>0</literal> to have the system choose an OID. <returnvalue>oid</returnvalue>
</entry> </para>
<entry><literal>lo_from_bytea(0, '\xffffff00')</literal></entry> <para>
<entry><literal>24528</literal></entry> Creates a large object and stores <parameter>data</parameter> in it.
</row> If <parameter>loid</parameter> is zero then the system will choose a
free OID, otherwise that OID is used (with an error if some large
<row> object already has that OID). On success, the large object's OID is
<entry> returned.
<indexterm> </para>
<primary>lo_put</primary> <para>
</indexterm> <literal>lo_from_bytea(0, '\xffffff00')</literal>
<literal><function>lo_put(<parameter>loid</parameter> <type>oid</type>, <parameter>offset</parameter> <type>bigint</type>, <parameter>str</parameter> <type>bytea</type>)</function></literal> <returnvalue>24528</returnvalue>
</entry> </para></entry>
<entry><type>void</type></entry> </row>
<entry>
Write data at the given offset. <row>
</entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>lo_put(24528, 1, '\xaa')</literal></entry> <indexterm>
<entry></entry> <primary>lo_put</primary>
</row> </indexterm>
<function>lo_put</function> ( <parameter>loid</parameter> <type>oid</type>, <parameter>offset</parameter> <type>bigint</type>, <parameter>data</parameter> <type>bytea</type> )
<row> <returnvalue>void</returnvalue>
<entry> </para>
<indexterm> <para>
<primary>lo_get</primary> Writes <parameter>data</parameter> starting at the given offset within
</indexterm> the large object; the large object is enlarged if necessary.
<literal><function>lo_get(<parameter>loid</parameter> <type>oid</type> <optional>, <parameter>from</parameter> <type>bigint</type>, <parameter>for</parameter> <type>int</type></optional>)</function></literal> </para>
</entry> <para>
<entry><type>bytea</type></entry> <literal>lo_put(24528, 1, '\xaa')</literal>
<entry> <returnvalue></returnvalue>
Extract contents or a substring thereof. </para></entry>
</entry> </row>
<entry><literal>lo_get(24528, 0, 3)</literal></entry>
<entry><literal>\xffaaff</literal></entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<indexterm>
</tbody> <primary>lo_get</primary>
</tgroup> </indexterm>
</table> <function>lo_get</function> ( <parameter>loid</parameter> <type>oid</type> <optional>, <parameter>offset</parameter> <type>bigint</type>, <parameter>length</parameter> <type>integer</type> </optional> )
<returnvalue>bytea</returnvalue>
</para>
<para>
Extracts the large object's contents, or a substring thereof.
</para>
<para>
<literal>lo_get(24528, 0, 3)</literal>
<returnvalue>\xffaaff</returnvalue>
</para></entry>
</row>
</tbody>
</tgroup>
</table>
<para> <para>
There are additional server-side functions corresponding to each of the There are additional server-side functions corresponding to each of the
......
...@@ -201,169 +201,221 @@ Europe &amp; Russia*@ &amp; !Transportation ...@@ -201,169 +201,221 @@ Europe &amp; Russia*@ &amp; !Transportation
<table id="ltree-op-table"> <table id="ltree-op-table">
<title><type>ltree</type> Operators</title> <title><type>ltree</type> Operators</title>
<tgroup cols="1">
<tgroup cols="3"> <thead>
<thead> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry>Operator</entry> Operator
<entry>Returns</entry> </para>
<entry>Description</entry> <para>
</row> Description
</thead> </para></entry>
</row>
<tbody> </thead>
<row>
<entry><type>ltree</type> <literal>@&gt;</literal> <type>ltree</type></entry> <tbody>
<entry><type>boolean</type></entry> <row>
<entry>is left argument an ancestor of right (or equal)?</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <type>ltree</type> <literal>@&gt;</literal> <type>ltree</type>
<returnvalue>boolean</returnvalue>
<row> </para>
<entry><type>ltree</type> <literal>&lt;@</literal> <type>ltree</type></entry> <para>
<entry><type>boolean</type></entry> Is left argument an ancestor of right (or equal)?
<entry>is left argument a descendant of right (or equal)?</entry> </para></entry>
</row> </row>
<row> <row>
<entry><type>ltree</type> <literal>~</literal> <type>lquery</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>boolean</type></entry> <type>ltree</type> <literal>&lt;@</literal> <type>ltree</type>
<entry>does <type>ltree</type> match <type>lquery</type>?</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para>
<row> Is left argument a descendant of right (or equal)?
<entry><type>lquery</type> <literal>~</literal> <type>ltree</type></entry> </para></entry>
<entry><type>boolean</type></entry> </row>
<entry>does <type>ltree</type> match <type>lquery</type>?</entry>
</row> <row>
<entry role="func_table_entry"><para role="func_signature">
<row> <type>ltree</type> <literal>~</literal> <type>lquery</type>
<entry><type>ltree</type> <literal>?</literal> <type>lquery[]</type></entry> <returnvalue>boolean</returnvalue>
<entry><type>boolean</type></entry> </para>
<entry>does <type>ltree</type> match any <type>lquery</type> in array?</entry> <para role="func_signature">
</row> <type>lquery</type> <literal>~</literal> <type>ltree</type>
<returnvalue>boolean</returnvalue>
<row> </para>
<entry><type>lquery[]</type> <literal>?</literal> <type>ltree</type></entry> <para>
<entry><type>boolean</type></entry> Does <type>ltree</type> match <type>lquery</type>?
<entry>does <type>ltree</type> match any <type>lquery</type> in array?</entry> </para></entry>
</row> </row>
<row> <row>
<entry><type>ltree</type> <literal>@</literal> <type>ltxtquery</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>boolean</type></entry> <type>ltree</type> <literal>?</literal> <type>lquery[]</type>
<entry>does <type>ltree</type> match <type>ltxtquery</type>?</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para role="func_signature">
<row> <type>lquery[]</type> <literal>?</literal> <type>ltree</type>
<entry><type>ltxtquery</type> <literal>@</literal> <type>ltree</type></entry> <returnvalue>boolean</returnvalue>
<entry><type>boolean</type></entry> </para>
<entry>does <type>ltree</type> match <type>ltxtquery</type>?</entry> <para>
</row> Does <type>ltree</type> match any <type>lquery</type> in array?
</para></entry>
<row> </row>
<entry><type>ltree</type> <literal>||</literal> <type>ltree</type></entry>
<entry><type>ltree</type></entry> <row>
<entry>concatenate <type>ltree</type> paths</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <type>ltree</type> <literal>@</literal> <type>ltxtquery</type>
<returnvalue>boolean</returnvalue>
<row> </para>
<entry><type>ltree</type> <literal>||</literal> <type>text</type></entry> <para role="func_signature">
<entry><type>ltree</type></entry> <type>ltxtquery</type> <literal>@</literal> <type>ltree</type>
<entry>convert text to <type>ltree</type> and concatenate</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para>
<row> Does <type>ltree</type> match <type>ltxtquery</type>?
<entry><type>text</type> <literal>||</literal> <type>ltree</type></entry> </para></entry>
<entry><type>ltree</type></entry> </row>
<entry>convert text to <type>ltree</type> and concatenate</entry>
</row> <row>
<entry role="func_table_entry"><para role="func_signature">
<row> <type>ltree</type> <literal>||</literal> <type>ltree</type>
<entry><type>ltree[]</type> <literal>@&gt;</literal> <type>ltree</type></entry> <returnvalue>ltree</returnvalue>
<entry><type>boolean</type></entry> </para>
<entry>does array contain an ancestor of <type>ltree</type>?</entry> <para>
</row> Concatenates <type>ltree</type> paths.
</para></entry>
<row> </row>
<entry><type>ltree</type> <literal>&lt;@</literal> <type>ltree[]</type></entry>
<entry><type>boolean</type></entry> <row>
<entry>does array contain an ancestor of <type>ltree</type>?</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <type>ltree</type> <literal>||</literal> <type>text</type>
<returnvalue>ltree</returnvalue>
<row> </para>
<entry><type>ltree[]</type> <literal>&lt;@</literal> <type>ltree</type></entry> <para role="func_signature">
<entry><type>boolean</type></entry> <type>text</type> <literal>||</literal> <type>ltree</type>
<entry>does array contain a descendant of <type>ltree</type>?</entry> <returnvalue>ltree</returnvalue>
</row> </para>
<para>
<row> Converts text to <type>ltree</type> and concatenates.
<entry><type>ltree</type> <literal>@&gt;</literal> <type>ltree[]</type></entry> </para></entry>
<entry><type>boolean</type></entry> </row>
<entry>does array contain a descendant of <type>ltree</type>?</entry>
</row> <row>
<entry role="func_table_entry"><para role="func_signature">
<row> <type>ltree[]</type> <literal>@&gt;</literal> <type>ltree</type>
<entry><type>ltree[]</type> <literal>~</literal> <type>lquery</type></entry> <returnvalue>boolean</returnvalue>
<entry><type>boolean</type></entry> </para>
<entry>does array contain any path matching <type>lquery</type>?</entry> <para role="func_signature">
</row> <type>ltree</type> <literal>&lt;@</literal> <type>ltree[]</type>
<returnvalue>boolean</returnvalue>
<row> </para>
<entry><type>lquery</type> <literal>~</literal> <type>ltree[]</type></entry> <para>
<entry><type>boolean</type></entry> Does array contain an ancestor of <type>ltree</type>?
<entry>does array contain any path matching <type>lquery</type>?</entry> </para></entry>
</row> </row>
<row> <row>
<entry><type>ltree[]</type> <literal>?</literal> <type>lquery[]</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>boolean</type></entry> <type>ltree[]</type> <literal>&lt;@</literal> <type>ltree</type>
<entry>does <type>ltree</type> array contain any path matching any <type>lquery</type>?</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para role="func_signature">
<row> <type>ltree</type> <literal>@&gt;</literal> <type>ltree[]</type>
<entry><type>lquery[]</type> <literal>?</literal> <type>ltree[]</type></entry> <returnvalue>boolean</returnvalue>
<entry><type>boolean</type></entry> </para>
<entry>does <type>ltree</type> array contain any path matching any <type>lquery</type>?</entry> <para>
</row> Does array contain a descendant of <type>ltree</type>?
</para></entry>
<row> </row>
<entry><type>ltree[]</type> <literal>@</literal> <type>ltxtquery</type></entry>
<entry><type>boolean</type></entry> <row>
<entry>does array contain any path matching <type>ltxtquery</type>?</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <type>ltree[]</type> <literal>~</literal> <type>lquery</type>
<returnvalue>boolean</returnvalue>
<row> </para>
<entry><type>ltxtquery</type> <literal>@</literal> <type>ltree[]</type></entry> <para role="func_signature">
<entry><type>boolean</type></entry> <type>lquery</type> <literal>~</literal> <type>ltree[]</type>
<entry>does array contain any path matching <type>ltxtquery</type>?</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para>
<row> Does array contain any path matching <type>lquery</type>?
<entry><type>ltree[]</type> <literal>?@&gt;</literal> <type>ltree</type></entry> </para></entry>
<entry><type>ltree</type></entry> </row>
<entry>first array entry that is an ancestor of <type>ltree</type>; NULL if none</entry>
</row> <row>
<entry role="func_table_entry"><para role="func_signature">
<row> <type>ltree[]</type> <literal>?</literal> <type>lquery[]</type>
<entry><type>ltree[]</type> <literal>?&lt;@</literal> <type>ltree</type></entry> <returnvalue>boolean</returnvalue>
<entry><type>ltree</type></entry> </para>
<entry>first array entry that is a descendant of <type>ltree</type>; NULL if none</entry> <para role="func_signature">
</row> <type>lquery[]</type> <literal>?</literal> <type>ltree[]</type>
<returnvalue>boolean</returnvalue>
<row> </para>
<entry><type>ltree[]</type> <literal>?~</literal> <type>lquery</type></entry> <para>
<entry><type>ltree</type></entry> Does <type>ltree</type> array contain any path matching
<entry>first array entry that matches <type>lquery</type>; NULL if none</entry> any <type>lquery</type>?
</row> </para></entry>
</row>
<row>
<entry><type>ltree[]</type> <literal>?@</literal> <type>ltxtquery</type></entry> <row>
<entry><type>ltree</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>first array entry that matches <type>ltxtquery</type>; NULL if none</entry> <type>ltree[]</type> <literal>@</literal> <type>ltxtquery</type>
</row> <returnvalue>boolean</returnvalue>
</para>
</tbody> <para role="func_signature">
</tgroup> <type>ltxtquery</type> <literal>@</literal> <type>ltree[]</type>
<returnvalue>boolean</returnvalue>
</para>
<para>
Does array contain any path matching <type>ltxtquery</type>?
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>ltree[]</type> <literal>?@&gt;</literal> <type>ltree</type>
<returnvalue>ltree</returnvalue>
</para>
<para>
Returns first array entry that is an ancestor of <type>ltree</type>,
or <literal>NULL</literal> if none.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>ltree[]</type> <literal>?&lt;@</literal> <type>ltree</type>
<returnvalue>ltree</returnvalue>
</para>
<para>
Returns first array entry that is a descendant of <type>ltree</type>,
or <literal>NULL</literal> if none.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>ltree[]</type> <literal>?~</literal> <type>lquery</type>
<returnvalue>ltree</returnvalue>
</para>
<para>
Returns first array entry that matches <type>lquery</type>,
or <literal>NULL</literal> if none.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>ltree[]</type> <literal>?@</literal> <type>ltxtquery</type>
<returnvalue>ltree</returnvalue>
</para>
<para>
Returns first array entry that matches <type>ltxtquery</type>,
or <literal>NULL</literal> if none.
</para></entry>
</row>
</tbody>
</tgroup>
</table> </table>
<para> <para>
...@@ -380,114 +432,178 @@ Europe &amp; Russia*@ &amp; !Transportation ...@@ -380,114 +432,178 @@ Europe &amp; Russia*@ &amp; !Transportation
<table id="ltree-func-table"> <table id="ltree-func-table">
<title><type>ltree</type> Functions</title> <title><type>ltree</type> Functions</title>
<tgroup cols="1">
<tgroup cols="5"> <thead>
<thead> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry>Function</entry> Function
<entry>Return Type</entry> </para>
<entry>Description</entry> <para>
<entry>Example</entry> Description
<entry>Result</entry> </para>
</row> <para>
</thead> Example(s)
</para></entry>
<tbody> </row>
<row> </thead>
<entry><function>subltree(ltree, int start, int end)</function><indexterm><primary>subltree</primary></indexterm></entry>
<entry><type>ltree</type></entry> <tbody>
<entry>subpath of <type>ltree</type> from position <parameter>start</parameter> to <row>
position <parameter>end</parameter>-1 (counting from 0)</entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>subltree('Top.Child1.Child2',1,2)</literal></entry> <indexterm><primary>subltree</primary></indexterm>
<entry><literal>Child1</literal></entry> <function>subltree</function> ( <type>ltree</type>, <parameter>start</parameter> <type>integer</type>, <parameter>end</parameter> <type>integer</type> )
</row> <returnvalue>ltree</returnvalue>
</para>
<row> <para>
<entry><function>subpath(ltree, int offset, int len)</function><indexterm><primary>subpath</primary></indexterm></entry> Returns subpath of <type>ltree</type> from
<entry><type>ltree</type></entry> position <parameter>start</parameter> to
<entry>subpath of <type>ltree</type> starting at position position <parameter>end</parameter>-1 (counting from 0).
<parameter>offset</parameter>, length <parameter>len</parameter>. </para>
If <parameter>offset</parameter> is negative, subpath starts that far from the <para>
end of the path. If <parameter>len</parameter> is negative, leaves that many <literal>subltree('Top.Child1.Child2',1,2)</literal>
labels off the end of the path.</entry> <returnvalue>Child1</returnvalue>
<entry><literal>subpath('Top.Child1.Child2',0,2)</literal></entry> </para></entry>
<entry><literal>Top.Child1</literal></entry> </row>
</row>
<row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry><function>subpath(ltree, int offset)</function></entry> <indexterm><primary>subpath</primary></indexterm>
<entry><type>ltree</type></entry> <function>subpath</function> ( <type>ltree</type>, <parameter>offset</parameter> <type>integer</type>, <parameter>len</parameter> <type>integer</type> )
<entry>subpath of <type>ltree</type> starting at position <returnvalue>ltree</returnvalue>
<parameter>offset</parameter>, extending to end of path. </para>
If <parameter>offset</parameter> is negative, subpath starts that far from the <para>
end of the path.</entry> Returns subpath of <type>ltree</type> starting at
<entry><literal>subpath('Top.Child1.Child2',1)</literal></entry> position <parameter>offset</parameter>, with
<entry><literal>Child1.Child2</literal></entry> length <parameter>len</parameter>. If <parameter>offset</parameter>
</row> is negative, subpath starts that far from the end of the path.
If <parameter>len</parameter> is negative, leaves that many labels off
<row> the end of the path.
<entry><function>nlevel(ltree)</function><indexterm><primary>nlevel</primary></indexterm></entry> </para>
<entry><type>integer</type></entry> <para>
<entry>number of labels in path</entry> <literal>subpath('Top.Child1.Child2',0,2)</literal>
<entry><literal>nlevel('Top.Child1.Child2')</literal></entry> <returnvalue>Top.Child1</returnvalue>
<entry><literal>3</literal></entry> </para></entry>
</row> </row>
<row> <row>
<entry><function>index(ltree a, ltree b)</function><indexterm><primary>index</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>integer</type></entry> <function>subpath</function> ( <type>ltree</type>, <parameter>offset</parameter> <type>integer</type> )
<entry>position of first occurrence of <parameter>b</parameter> in <returnvalue>ltree</returnvalue>
<parameter>a</parameter>; -1 if not found</entry> </para>
<entry><literal>index('0.1.2.3.5.4.5.6.8.5.6.8','5.6')</literal></entry> <para>
<entry><literal>6</literal></entry> Returns subpath of <type>ltree</type> starting at
</row> position <parameter>offset</parameter>, extending to end of path.
If <parameter>offset</parameter> is negative, subpath starts that far
<row> from the end of the path.
<entry><function>index(ltree a, ltree b, int offset)</function></entry> </para>
<entry><type>integer</type></entry> <para>
<entry>position of first occurrence of <parameter>b</parameter> in <literal>subpath('Top.Child1.Child2',1)</literal>
<parameter>a</parameter>, searching starting at <parameter>offset</parameter>; <returnvalue>Child1.Child2</returnvalue>
negative <parameter>offset</parameter> means start <parameter>-offset</parameter> </para></entry>
labels from the end of the path</entry> </row>
<entry><literal>index('0.1.2.3.5.4.5.6.8.5.6.8','5.6',-4)</literal></entry>
<entry><literal>9</literal></entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>nlevel</primary></indexterm>
<row> <function>nlevel</function> ( <type>ltree</type> )
<entry><function>text2ltree(text)</function><indexterm><primary>text2ltree</primary></indexterm></entry> <returnvalue>integer</returnvalue>
<entry><type>ltree</type></entry> </para>
<entry>cast <type>text</type> to <type>ltree</type></entry> <para>
<entry><literal></literal></entry> Returns number of labels in path.
<entry><literal></literal></entry> </para>
</row> <para>
<literal>nlevel('Top.Child1.Child2')</literal>
<row> <returnvalue>3</returnvalue>
<entry><function>ltree2text(ltree)</function><indexterm><primary>ltree2text</primary></indexterm></entry> </para></entry>
<entry><type>text</type></entry> </row>
<entry>cast <type>ltree</type> to <type>text</type></entry>
<entry><literal></literal></entry> <row>
<entry><literal></literal></entry> <entry role="func_table_entry"><para role="func_signature">
</row> <indexterm><primary>index</primary></indexterm>
<function>index</function> ( <parameter>a</parameter> <type>ltree</type>, <parameter>b</parameter> <type>ltree</type> )
<row> <returnvalue>integer</returnvalue>
<entry><function>lca(ltree, ltree, ...)</function><indexterm><primary>lca</primary></indexterm></entry> </para>
<entry><type>ltree</type></entry> <para>
<entry>longest common ancestor of paths Returns position of first occurrence of <parameter>b</parameter> in
(up to 8 arguments supported)</entry> <parameter>a</parameter>, or -1 if not found.
<entry><literal>lca('1.2.3','1.2.3.4.5.6')</literal></entry> </para>
<entry><literal>1.2</literal></entry> <para>
</row> <literal>index('0.1.2.3.5.4.5.6.8.5.6.8','5.6')</literal>
<returnvalue>6</returnvalue>
<row> </para></entry>
<entry><function>lca(ltree[])</function></entry> </row>
<entry><type>ltree</type></entry>
<entry>longest common ancestor of paths in array</entry> <row>
<entry><literal>lca(array['1.2.3'::ltree,'1.2.3.4'])</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>1.2</literal></entry> <function>index</function> ( <parameter>a</parameter> <type>ltree</type>, <parameter>b</parameter> <type>ltree</type>, <parameter>offset</parameter> <type>integer</type> )
</row> <returnvalue>integer</returnvalue>
</para>
</tbody> <para>
</tgroup> Returns position of first occurrence of <parameter>b</parameter>
in <parameter>a</parameter>, or -1 if not found. The search starts at
position <parameter>offset</parameter>;
negative <parameter>offset</parameter> means
start <parameter>-offset</parameter> labels from the end of the path.
</para>
<para>
<literal>index('0.1.2.3.5.4.5.6.8.5.6.8','5.6',-4)</literal>
<returnvalue>9</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>text2ltree</primary></indexterm>
<function>text2ltree</function> ( <type>text</type> )
<returnvalue>ltree</returnvalue>
</para>
<para>
Casts <type>text</type> to <type>ltree</type>.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>ltree2text</primary></indexterm>
<function>ltree2text</function> ( <type>ltree</type> )
<returnvalue>text</returnvalue>
</para>
<para>
Casts <type>ltree</type> to <type>text</type>.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>lca</primary></indexterm>
<function>lca</function> ( <type>ltree</type> <optional>, <type>ltree</type> <optional>, ... </optional></optional> )
<returnvalue>ltree</returnvalue>
</para>
<para>
Computes longest common ancestor of paths
(up to 8 arguments are supported).
</para>
<para>
<literal>lca('1.2.3','1.2.3.4.5.6')</literal>
<returnvalue>1.2</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>lca</function> ( <type>ltree[]</type> )
<returnvalue>ltree</returnvalue>
</para>
<para>
Computes longest common ancestor of paths in array.
</para>
<para>
<literal>lca(array['1.2.3'::ltree,'1.2.3.4'])</literal>
<returnvalue>1.2</returnvalue>
</para></entry>
</row>
</tbody>
</tgroup>
</table> </table>
</sect2> </sect2>
......
...@@ -3375,122 +3375,179 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i ...@@ -3375,122 +3375,179 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
linkend="monitoring-stats-funcs-table"/>. linkend="monitoring-stats-funcs-table"/>.
</para> </para>
<table id="monitoring-stats-funcs-table"> <table id="monitoring-stats-funcs-table">
<title>Additional Statistics Functions</title> <title>Additional Statistics Functions</title>
<tgroup cols="1">
<tgroup cols="3"> <thead>
<thead> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry>Function</entry> Function
<entry>Return Type</entry> </para>
<entry>Description</entry> <para>
</row> Description
</thead> </para></entry>
</row>
<tbody> </thead>
<row> <tbody>
<row>
<!-- See also the entry for this in func.sgml --> <!-- See also the entry for this in func.sgml -->
<entry><literal><function>pg_backend_pid()</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>integer</type></entry> <function>pg_backend_pid</function> ()
<entry> <returnvalue>integer</returnvalue>
Process ID of the server process handling the current session </para>
</entry> <para>
</row> Returns the process ID of the server process attached to the current
session.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_activity</function>(<type>integer</type>)</literal><indexterm><primary>pg_stat_get_activity</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>setof record</type></entry> <indexterm>
<entry> <primary>pg_stat_get_activity</primary>
Returns a record of information about the backend with the specified PID, or </indexterm>
one record for each active backend in the system if <symbol>NULL</symbol> is <function>pg_stat_get_activity</function> ( <type>integer</type> )
specified. The fields returned are a subset of those in the <returnvalue>setof record</returnvalue>
<structname>pg_stat_activity</structname> view. </para>
</entry> <para>
</row> Returns a record of information about the backend with the specified
process ID, or one record for each active backend in the system
if <literal>NULL</literal> is specified. The fields returned are a
subset of those in the <structname>pg_stat_activity</structname> view.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_snapshot_timestamp()</function></literal><indexterm><primary>pg_stat_get_snapshot_timestamp</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>timestamp with time zone</type></entry> <indexterm>
<entry> <primary>pg_stat_get_snapshot_timestamp</primary>
Returns the timestamp of the current statistics snapshot </indexterm>
</entry> <function>pg_stat_get_snapshot_timestamp</function> ()
</row> <returnvalue>timestamp with time zone</returnvalue>
</para>
<para>
Returns the timestamp of the current statistics snapshot.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_clear_snapshot()</function></literal><indexterm><primary>pg_stat_clear_snapshot</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>void</type></entry> <indexterm>
<entry> <primary>pg_stat_clear_snapshot</primary>
Discard the current statistics snapshot </indexterm>
</entry> <function>pg_stat_clear_snapshot</function> ()
</row> <returnvalue>void</returnvalue>
</para>
<para>
Discards the current statistics snapshot.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_reset()</function></literal><indexterm><primary>pg_stat_reset</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>void</type></entry> <indexterm>
<entry> <primary>pg_stat_reset</primary>
Reset all statistics counters for the current database to zero </indexterm>
(requires superuser privileges by default, but EXECUTE for this <function>pg_stat_reset</function> ()
function can be granted to others.) <returnvalue>void</returnvalue>
</entry> </para>
</row> <para>
Resets all statistics counters for the current database to zero.
</para>
<para>
This function is restricted to superusers by default, but other users
can be granted EXECUTE to run the function.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_reset_shared</function>(text)</literal><indexterm><primary>pg_stat_reset_shared</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>void</type></entry> <indexterm>
<entry> <primary>pg_stat_reset_shared</primary>
Reset some cluster-wide statistics counters to zero, depending on the </indexterm>
argument (requires superuser privileges by default, but EXECUTE for <function>pg_stat_reset_shared</function> ( <type>text</type> )
this function can be granted to others). <returnvalue>void</returnvalue>
Calling <literal>pg_stat_reset_shared('bgwriter')</literal> will zero all the </para>
counters shown in the <structname>pg_stat_bgwriter</structname> view. <para>
Calling <literal>pg_stat_reset_shared('archiver')</literal> will zero all the Resets some cluster-wide statistics counters to zero, depending on the
counters shown in the <structname>pg_stat_archiver</structname> view. argument. The argument can be <literal>bgwriter</literal> to reset
</entry> all the counters shown in
</row> the <structname>pg_stat_bgwriter</structname>
view,or <literal>archiver</literal> to reset all the counters shown in
the <structname>pg_stat_archiver</structname> view.
</para>
<para>
This function is restricted to superusers by default, but other users
can be granted EXECUTE to run the function.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_reset_single_table_counters</function>(oid)</literal><indexterm><primary>pg_stat_reset_single_table_counters</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>void</type></entry> <indexterm>
<entry> <primary>pg_stat_reset_single_table_counters</primary>
Reset statistics for a single table or index in the current database to </indexterm>
zero (requires superuser privileges by default, but EXECUTE for this <function>pg_stat_reset_single_table_counters</function> ( <type>oid</type> )
function can be granted to others) <returnvalue>void</returnvalue>
</entry> </para>
</row> <para>
Resets statistics for a single table or index in the current database
to zero.
</para>
<para>
This function is restricted to superusers by default, but other users
can be granted EXECUTE to run the function.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_reset_single_function_counters</function>(oid)</literal><indexterm><primary>pg_stat_reset_single_function_counters</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>void</type></entry> <indexterm>
<entry> <primary>pg_stat_reset_single_function_counters</primary>
Reset statistics for a single function in the current database to </indexterm>
zero (requires superuser privileges by default, but EXECUTE for this <function>pg_stat_reset_single_function_counters</function> ( <type>oid</type> )
function can be granted to others) <returnvalue>void</returnvalue>
</entry> </para>
</row> <para>
Resets statistics for a single function in the current database to
zero.
</para>
<para>
This function is restricted to superusers by default, but other users
can be granted EXECUTE to run the function.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_reset_slru</function>(text)</literal><indexterm><primary>pg_stat_reset_slru</primary></indexterm></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>void</type></entry> <indexterm>
<entry> <primary>pg_stat_reset_slru</primary>
Reset statistics either for a single SLRU or all SLRUs in the cluster </indexterm>
to zero (requires superuser privileges by default, but EXECUTE for this <function>pg_stat_reset_slru</function> ( <type>text</type> )
function can be granted to others). <returnvalue>void</returnvalue>
Calling <literal>pg_stat_reset_slru(NULL)</literal> will zero all the </para>
counters shown in the <structname>pg_stat_slru</structname> view for <para>
all SLRU caches. Resets statistics to zero for a single SLRU cache, or for all SLRUs in
Calling <literal>pg_stat_reset_slru(name)</literal> with names from a the cluster. If the argument is NULL, all counters shown in
predefined list (<literal>async</literal>, <literal>clog</literal>, the <structname>pg_stat_slru</structname> view for all SLRU caches are
<literal>commit_timestamp</literal>, <literal>multixact_offset</literal>, reset. The argument can be one of <literal>async</literal>,
<literal>multixact_member</literal>, <literal>oldserxid</literal>, <literal>clog</literal>, <literal>commit_timestamp</literal>,
<literal>subtrans</literal> and <literal>other</literal>) resets counters <literal>multixact_offset</literal>,
for only that entry. Names not included in this list are treated as <literal>multixact_member</literal>, <literal>oldserxid</literal>, or
<literal>other</literal>. <literal>subtrans</literal> to reset the counters for only that entry.
</entry> If the argument is <literal>other</literal> (or indeed, any
</row> unrecognized name), then the counters for all other SLRU caches, such
</tbody> as extension-defined caches, are reset.
</tgroup> </para>
</table> <para>
This function is restricted to superusers by default, but other users
can be granted EXECUTE to run the function.
</para></entry>
</row>
</tbody>
</tgroup>
</table>
<para> <para>
<function>pg_stat_get_activity</function>, the underlying function of <function>pg_stat_get_activity</function>, the underlying function of
...@@ -3514,100 +3571,182 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, ...@@ -3514,100 +3571,182 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
</programlisting> </programlisting>
</para> </para>
<table id="monitoring-stats-backend-funcs-table"> <table id="monitoring-stats-backend-funcs-table">
<title>Per-Backend Statistics Functions</title> <title>Per-Backend Statistics Functions</title>
<tgroup cols="1">
<tgroup cols="3"> <thead>
<thead> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry>Function</entry> Function
<entry>Return Type</entry> </para>
<entry>Description</entry> <para>
</row> Description
</thead> </para></entry>
</row>
<tbody> </thead>
<row>
<entry><literal><function>pg_stat_get_backend_idset()</function></literal></entry>
<entry><type>setof integer</type></entry>
<entry>Set of currently active backend ID numbers (from 1 to the
number of active backends)</entry>
</row>
<row> <tbody>
<entry><literal><function>pg_stat_get_backend_activity(integer)</function></literal></entry> <row>
<entry><type>text</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Text of this backend's most recent query</entry> <indexterm>
</row> <primary>pg_stat_get_backend_idset</primary>
</indexterm>
<function>pg_stat_get_backend_idset</function> ()
<returnvalue>setof integer</returnvalue>
</para>
<para>
Returns the set of currently active backend ID numbers (from 1 to the
number of active backends).
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_backend_activity_start(integer)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>timestamp with time zone</type></entry> <indexterm>
<entry>Time when the most recent query was started</entry> <primary>pg_stat_get_backend_activity</primary>
</row> </indexterm>
<function>pg_stat_get_backend_activity</function> ( <type>integer</type> )
<returnvalue>text</returnvalue>
</para>
<para>
Returns the text of this backend's most recent query.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_backend_client_addr(integer)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>inet</type></entry> <indexterm>
<entry>IP address of the client connected to this backend</entry> <primary>pg_stat_get_backend_activity_start</primary>
</row> </indexterm>
<function>pg_stat_get_backend_activity_start</function> ( <type>integer</type> )
<returnvalue>timestamp with time zone</returnvalue>
</para>
<para>
Returns the time when the backend's most recent query was started.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_backend_client_port(integer)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>integer</type></entry> <indexterm>
<entry>TCP port number that the client is using for communication</entry> <primary>pg_stat_get_backend_client_addr</primary>
</row> </indexterm>
<function>pg_stat_get_backend_client_addr</function> ( <type>integer</type> )
<returnvalue>inet</returnvalue>
</para>
<para>
Returns the IP address of the client connected to this backend.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_backend_dbid(integer)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>oid</type></entry> <indexterm>
<entry>OID of the database this backend is connected to</entry> <primary>pg_stat_get_backend_client_port</primary>
</row> </indexterm>
<function>pg_stat_get_backend_client_port</function> ( <type>integer</type> )
<returnvalue>integer</returnvalue>
</para>
<para>
Returns the TCP port number that the client is using for communication.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_backend_pid(integer)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>integer</type></entry> <indexterm>
<entry>Process ID of this backend</entry> <primary>pg_stat_get_backend_dbid</primary>
</row> </indexterm>
<function>pg_stat_get_backend_dbid</function> ( <type>integer</type> )
<returnvalue>oid</returnvalue>
</para>
<para>
Returns the OID of the database this backend is connected to.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_backend_start(integer)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>timestamp with time zone</type></entry> <indexterm>
<entry>Time when this process was started</entry> <primary>pg_stat_get_backend_pid</primary>
</row> </indexterm>
<function>pg_stat_get_backend_pid</function> ( <type>integer</type> )
<returnvalue>integer</returnvalue>
</para>
<para>
Returns the process ID of this backend.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_backend_userid(integer)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>oid</type></entry> <indexterm>
<entry>OID of the user logged into this backend</entry> <primary>pg_stat_get_backend_start</primary>
</row> </indexterm>
<function>pg_stat_get_backend_start</function> ( <type>integer</type> )
<returnvalue>timestamp with time zone</returnvalue>
</para>
<para>
Returns the time when this process was started.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_backend_wait_event_type(integer)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>text</type></entry> <indexterm>
<entry>Wait event type name if backend is currently waiting, otherwise NULL. <primary>pg_stat_get_backend_userid</primary>
See <xref linkend="wait-event-table"/> for details. </indexterm>
</entry> <function>pg_stat_get_backend_userid</function> ( <type>integer</type> )
<returnvalue>oid</returnvalue>
</para>
<para>
Returns the OID of the user logged into this backend.
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>pg_stat_get_backend_wait_event(integer)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>text</type></entry> <indexterm>
<entry>Wait event name if backend is currently waiting, otherwise NULL. <primary>pg_stat_get_backend_wait_event_type</primary>
See <xref linkend="wait-event-table"/> for details. </indexterm>
</entry> <function>pg_stat_get_backend_wait_event_type</function> ( <type>integer</type> )
</row> <returnvalue>text</returnvalue>
</para>
<para>
Returns the wait event type name if this backend is currently waiting,
otherwise NULL. See <xref linkend="wait-event-table"/> for details.
</para></entry>
</row>
<row> <row>
<entry><literal><function>pg_stat_get_backend_xact_start(integer)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>timestamp with time zone</type></entry> <indexterm>
<entry>Time when the current transaction was started</entry> <primary>pg_stat_get_backend_wait_event</primary>
</row> </indexterm>
<function>pg_stat_get_backend_wait_event</function> ( <type>integer</type> )
<returnvalue>text</returnvalue>
</para>
<para>
Returns the wait event name if this backend is currently waiting,
otherwise NULL. See <xref linkend="wait-event-table"/> for details.
</para></entry>
</row>
</tbody> <row>
</tgroup> <entry role="func_table_entry"><para role="func_signature">
</table> <indexterm>
<primary>pg_stat_get_backend_xact_start</primary>
</indexterm>
<function>pg_stat_get_backend_xact_start</function> ( <type>integer</type> )
<returnvalue>timestamp with time zone</returnvalue>
</para>
<para>
Returns the time when the backend's current transaction was started.
</para></entry>
</row>
</tbody>
</tgroup>
</table>
</sect2> </sect2>
</sect1> </sect1>
...@@ -3834,7 +3973,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid, ...@@ -3834,7 +3973,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
<row> <row>
<entry><literal>finalizing analyze</literal></entry> <entry><literal>finalizing analyze</literal></entry>
<entry> <entry>
The command is updating pg_class. When this phase is completed, The command is updating pg_class. When this phase is completed,
<command>ANALYZE</command> will end. <command>ANALYZE</command> will end.
</entry> </entry>
</row> </row>
......
...@@ -70,83 +70,106 @@ ...@@ -70,83 +70,106 @@
<table id="pgtrgm-func-table"> <table id="pgtrgm-func-table">
<title><filename>pg_trgm</filename> Functions</title> <title><filename>pg_trgm</filename> Functions</title>
<tgroup cols="3"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Function</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Returns</entry> Function
<entry>Description</entry> </para>
</row> <para>
</thead> Description
</para></entry>
<tbody> </row>
<row> </thead>
<entry><function>similarity(text, text)</function><indexterm><primary>similarity</primary></indexterm></entry>
<entry><type>real</type></entry> <tbody>
<entry> <row>
Returns a number that indicates how similar the two arguments are. <entry role="func_table_entry"><para role="func_signature">
The range of the result is zero (indicating that the two strings are <indexterm><primary>similarity</primary></indexterm>
completely dissimilar) to one (indicating that the two strings are <function>similarity</function> ( <type>text</type>, <type>text</type> )
identical). <returnvalue>real</returnvalue>
</entry> </para>
</row> <para>
<row> Returns a number that indicates how similar the two arguments are.
<entry><function>show_trgm(text)</function><indexterm><primary>show_trgm</primary></indexterm></entry> The range of the result is zero (indicating that the two strings are
<entry><type>text[]</type></entry> completely dissimilar) to one (indicating that the two strings are
<entry> identical).
Returns an array of all the trigrams in the given string. </para></entry>
(In practice this is seldom useful except for debugging.) </row>
</entry>
</row> <row>
<row> <entry role="func_table_entry"><para role="func_signature">
<entry> <indexterm><primary>show_trgm</primary></indexterm>
<function>word_similarity(text, text)</function> <function>show_trgm</function> ( <type>text</type> )
<indexterm><primary>word_similarity</primary></indexterm> <returnvalue>text[]</returnvalue>
</entry> </para>
<entry><type>real</type></entry> <para>
<entry> Returns an array of all the trigrams in the given string.
Returns a number that indicates the greatest similarity between (In practice this is seldom useful except for debugging.)
the set of trigrams in the first string and any continuous extent </para></entry>
of an ordered set of trigrams in the second string. For details, see </row>
the explanation below.
</entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<row> <indexterm><primary>word_similarity</primary></indexterm>
<entry> <function>word_similarity</function> ( <type>text</type>, <type>text</type> )
<function>strict_word_similarity(text, text)</function> <returnvalue>real</returnvalue>
<indexterm><primary>strict_word_similarity</primary></indexterm> </para>
</entry> <para>
<entry><type>real</type></entry> Returns a number that indicates the greatest similarity between
<entry> the set of trigrams in the first string and any continuous extent
Same as <function>word_similarity(text, text)</function>, but forces of an ordered set of trigrams in the second string. For details, see
extent boundaries to match word boundaries. Since we don't have the explanation below.
cross-word trigrams, this function actually returns greatest similarity </para></entry>
between first string and any continuous extent of words of the second </row>
string.
</entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<row> <indexterm><primary>strict_word_similarity</primary></indexterm>
<entry><function>show_limit()</function><indexterm><primary>show_limit</primary></indexterm></entry> <function>strict_word_similarity</function> ( <type>text</type>, <type>text</type> )
<entry><type>real</type></entry> <returnvalue>real</returnvalue>
<entry> </para>
Returns the current similarity threshold used by the <literal>%</literal> <para>
operator. This sets the minimum similarity between Same as <function>word_similarity</function>, but forces
two words for them to be considered similar enough to extent boundaries to match word boundaries. Since we don't have
be misspellings of each other, for example cross-word trigrams, this function actually returns greatest similarity
(<emphasis>deprecated</emphasis>). between first string and any continuous extent of words of the second
</entry> string.
</row> </para></entry>
<row> </row>
<entry><function>set_limit(real)</function><indexterm><primary>set_limit</primary></indexterm></entry>
<entry><type>real</type></entry> <row>
<entry> <entry role="func_table_entry"><para role="func_signature">
Sets the current similarity threshold that is used by the <literal>%</literal> <indexterm><primary>show_limit</primary></indexterm>
operator. The threshold must be between 0 and 1 (default is 0.3). <function>show_limit</function> ()
Returns the same value passed in (<emphasis>deprecated</emphasis>). <returnvalue>real</returnvalue>
</entry> </para>
</row> <para>
</tbody> Returns the current similarity threshold used by the <literal>%</literal>
</tgroup> operator. This sets the minimum similarity between
two words for them to be considered similar enough to
be misspellings of each other, for example.
(<emphasis>Deprecated</emphasis>; instead use <command>SHOW</command>
<varname>pg_trgm.similarity_threshold</varname>.)
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>set_limit</primary></indexterm>
<function>set_limit</function> ( <type>real</type> )
<returnvalue>real</returnvalue>
</para>
<para>
Sets the current similarity threshold that is used by the <literal>%</literal>
operator. The threshold must be between 0 and 1 (default is 0.3).
Returns the same value passed in.
(<emphasis>Deprecated</emphasis>; instead use <command>SET</command>
<varname>pg_trgm.similarity_threshold</varname>.)
</para></entry>
</row>
</tbody>
</tgroup>
</table> </table>
<para> <para>
...@@ -178,9 +201,9 @@ ...@@ -178,9 +201,9 @@
</para> </para>
<para> <para>
At the same time, <function>strict_word_similarity(text, text)</function> At the same time, <function>strict_word_similarity</function>
selects an extent of words in the second string. In the example above, selects an extent of words in the second string. In the example above,
<function>strict_word_similarity(text, text)</function> would select the <function>strict_word_similarity</function> would select the
extent of a single word <literal>'words'</literal>, whose set of trigrams is extent of a single word <literal>'words'</literal>, whose set of trigrams is
<literal>{" w"," wo","wor","ord","rds","ds "}</literal>. <literal>{" w"," wo","wor","ord","rds","ds "}</literal>.
...@@ -194,117 +217,141 @@ ...@@ -194,117 +217,141 @@
</para> </para>
<para> <para>
Thus, the <function>strict_word_similarity(text, text)</function> function Thus, the <function>strict_word_similarity</function> function
is useful for finding the similarity to whole words, while is useful for finding the similarity to whole words, while
<function>word_similarity(text, text)</function> is more suitable for <function>word_similarity</function> is more suitable for
finding the similarity for parts of words. finding the similarity for parts of words.
</para> </para>
<table id="pgtrgm-op-table"> <table id="pgtrgm-op-table">
<title><filename>pg_trgm</filename> Operators</title> <title><filename>pg_trgm</filename> Operators</title>
<tgroup cols="3"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Operator</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Returns</entry> Operator
<entry>Description</entry> </para>
</row> <para>
</thead> Description
</para></entry>
<tbody> </row>
<row> </thead>
<entry><type>text</type> <literal>%</literal> <type>text</type></entry>
<entry><type>boolean</type></entry> <tbody>
<entry> <row>
Returns <literal>true</literal> if its arguments have a similarity that is <entry role="func_table_entry"><para role="func_signature">
greater than the current similarity threshold set by <type>text</type> <literal>%</literal> <type>text</type>
<varname>pg_trgm.similarity_threshold</varname>. <returnvalue>boolean</returnvalue>
</entry> </para>
</row> <para>
<row> Returns <literal>true</literal> if its arguments have a similarity
<entry><type>text</type> <literal>&lt;%</literal> <type>text</type></entry> that is greater than the current similarity threshold set by
<entry><type>boolean</type></entry> <varname>pg_trgm.similarity_threshold</varname>.
<entry> </para></entry>
Returns <literal>true</literal> if the similarity between the trigram </row>
set in the first argument and a continuous extent of an ordered trigram
set in the second argument is greater than the current word similarity <row>
threshold set by <varname>pg_trgm.word_similarity_threshold</varname> <entry role="func_table_entry"><para role="func_signature">
parameter. <type>text</type> <literal>&lt;%</literal> <type>text</type>
</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<row> <para>
<entry><type>text</type> <literal>%&gt;</literal> <type>text</type></entry> Returns <literal>true</literal> if the similarity between the trigram
<entry><type>boolean</type></entry> set in the first argument and a continuous extent of an ordered trigram
<entry> set in the second argument is greater than the current word similarity
Commutator of the <literal>&lt;%</literal> operator. threshold set by <varname>pg_trgm.word_similarity_threshold</varname>
</entry> parameter.
</row> </para></entry>
<row> </row>
<entry><type>text</type> <literal>&lt;&lt;%</literal> <type>text</type></entry>
<entry><type>boolean</type></entry> <row>
<entry> <entry role="func_table_entry"><para role="func_signature">
Returns <literal>true</literal> if its second argument has a continuous <type>text</type> <literal>%&gt;</literal> <type>text</type>
extent of an ordered trigram set that matches word boundaries, <returnvalue>boolean</returnvalue>
and its similarity to the trigram set of the first argument is greater </para>
than the current strict word similarity threshold set by the <para>
<varname>pg_trgm.strict_word_similarity_threshold</varname> parameter. Commutator of the <literal>&lt;%</literal> operator.
</entry> </para></entry>
</row> </row>
<row>
<entry><type>text</type> <literal>%&gt;&gt;</literal> <type>text</type></entry> <row>
<entry><type>boolean</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry> <type>text</type> <literal>&lt;&lt;%</literal> <type>text</type>
Commutator of the <literal>&lt;&lt;%</literal> operator. <returnvalue>boolean</returnvalue>
</entry> </para>
</row> <para>
<row> Returns <literal>true</literal> if its second argument has a continuous
<entry><type>text</type> <literal>&lt;-&gt;</literal> <type>text</type></entry> extent of an ordered trigram set that matches word boundaries,
<entry><type>real</type></entry> and its similarity to the trigram set of the first argument is greater
<entry> than the current strict word similarity threshold set by the
Returns the <quote>distance</quote> between the arguments, that is <varname>pg_trgm.strict_word_similarity_threshold</varname> parameter.
one minus the <function>similarity()</function> value. </para></entry>
</entry> </row>
</row>
<row> <row>
<entry> <entry role="func_table_entry"><para role="func_signature">
<type>text</type> <literal>&lt;&lt;-&gt;</literal> <type>text</type> <type>text</type> <literal>%&gt;&gt;</literal> <type>text</type>
</entry> <returnvalue>boolean</returnvalue>
<entry><type>real</type></entry> </para>
<entry> <para>
Returns the <quote>distance</quote> between the arguments, that is Commutator of the <literal>&lt;&lt;%</literal> operator.
one minus the <function>word_similarity()</function> value. </para></entry>
</entry> </row>
</row>
<row> <row>
<entry> <entry role="func_table_entry"><para role="func_signature">
<type>text</type> <literal>&lt;-&gt;&gt;</literal> <type>text</type> <type>text</type> <literal>&lt;-&gt;</literal> <type>text</type>
</entry> <returnvalue>real</returnvalue>
<entry><type>real</type></entry> </para>
<entry> <para>
Commutator of the <literal>&lt;&lt;-&gt;</literal> operator. Returns the <quote>distance</quote> between the arguments, that is
</entry> one minus the <function>similarity()</function> value.
</row> </para></entry>
<row> </row>
<entry>
<type>text</type> <literal>&lt;&lt;&lt;-&gt;</literal> <type>text</type> <row>
</entry> <entry role="func_table_entry"><para role="func_signature">
<entry><type>real</type></entry> <type>text</type> <literal>&lt;&lt;-&gt;</literal> <type>text</type>
<entry> <returnvalue>real</returnvalue>
Returns the <quote>distance</quote> between the arguments, that is </para>
one minus the <function>strict_word_similarity()</function> value. <para>
</entry> Returns the <quote>distance</quote> between the arguments, that is
</row> one minus the <function>word_similarity()</function> value.
<row> </para></entry>
<entry> </row>
<type>text</type> <literal>&lt;-&gt;&gt;&gt;</literal> <type>text</type>
</entry> <row>
<entry><type>real</type></entry> <entry role="func_table_entry"><para role="func_signature">
<entry> <type>text</type> <literal>&lt;-&gt;&gt;</literal> <type>text</type>
Commutator of the <literal>&lt;&lt;&lt;-&gt;</literal> operator. <returnvalue>real</returnvalue>
</entry> </para>
</row> <para>
</tbody> Commutator of the <literal>&lt;&lt;-&gt;</literal> operator.
</tgroup> </para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>text</type> <literal>&lt;&lt;&lt;-&gt;</literal> <type>text</type>
<returnvalue>real</returnvalue>
</para>
<para>
Returns the <quote>distance</quote> between the arguments, that is
one minus the <function>strict_word_similarity()</function> value.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<type>text</type> <literal>&lt;-&gt;&gt;&gt;</literal> <type>text</type>
<returnvalue>real</returnvalue>
</para>
<para>
Commutator of the <literal>&lt;&lt;&lt;-&gt;</literal> operator.
</para></entry>
</row>
</tbody>
</tgroup>
</table> </table>
</sect2> </sect2>
......
...@@ -198,8 +198,6 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d ...@@ -198,8 +198,6 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
<para> <para>
Generate data and load it into the standard tables, Generate data and load it into the standard tables,
replacing any data already present. replacing any data already present.
The default is to generate data client-side (<literal>g</literal>)
and transmit it over the connection.
</para> </para>
<para> <para>
With <literal>g</literal> (client-side data generation), With <literal>g</literal> (client-side data generation),
...@@ -207,18 +205,21 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d ...@@ -207,18 +205,21 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
sent to the server. This uses the client/server bandwidth sent to the server. This uses the client/server bandwidth
extensively through a <command>COPY</command>. extensively through a <command>COPY</command>.
Using <literal>g</literal> causes logging to print one message Using <literal>g</literal> causes logging to print one message
every 100,000 rows when generating data into every 100,000 rows while generating data for the
<structname>pgbench_accounts</structname> table. <structname>pgbench_accounts</structname> table.
</para> </para>
<para> <para>
With <literal>G</literal> (server-side data generation), With <literal>G</literal> (server-side data generation),
only limited queries are sent from <command>pgbench</command> only small queries are sent from the <command>pgbench</command>
client and then data is actually generated in the server. client and then data is actually generated in the server.
No significant bandwidth is required for this variant, but No significant bandwidth is required for this variant, but
the server will do more work. the server will do more work.
Using <literal>G</literal> causes logging not to print any progress Using <literal>G</literal> causes logging not to print any progress
message when generating data into message while generating data.
<structname>pgbench_accounts</structname> table. </para>
<para>
The default initialization behavior uses client-side data
generation (equivalent to <literal>g</literal>).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -897,14 +898,14 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d ...@@ -897,14 +898,14 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
<para> <para>
This utility, like most other <productname>PostgreSQL</productname> utilities, This utility, like most other <productname>PostgreSQL</productname> utilities,
uses the environment variables supported by <application>libpq</application> uses the environment variables supported by <application>libpq</application>
(see <xref linkend="libpq-envars"/>). (see <xref linkend="libpq-envars"/>).
</para> </para>
<para> <para>
The environment variable <envar>PG_COLOR</envar> specifies whether to use The environment variable <envar>PG_COLOR</envar> specifies whether to use
color in diagnostic messages. Possible values are color in diagnostic messages. Possible values are
...@@ -912,7 +913,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d ...@@ -912,7 +913,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
<literal>never</literal>. <literal>never</literal>.
</para> </para>
</refsect1> </refsect1>
<refsect1> <refsect1>
<title>Notes</title> <title>Notes</title>
...@@ -1011,8 +1012,10 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d ...@@ -1011,8 +1012,10 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
</para> </para>
<table id="pgbench-automatic-variables"> <table id="pgbench-automatic-variables">
<title>Automatic Variables</title> <title>pgbench Automatic Variables</title>
<tgroup cols="2"> <tgroup cols="2">
<colspec colname="col1" colwidth="1*"/>
<colspec colname="col2" colwidth="2*"/>
<thead> <thead>
<row> <row>
<entry>Variable</entry> <entry>Variable</entry>
...@@ -1253,167 +1256,368 @@ SELECT 4 AS four \; SELECT 5 AS five \aset ...@@ -1253,167 +1256,368 @@ SELECT 4 AS four \; SELECT 5 AS five \aset
<xref linkend="pgbench-operators"/> are built into <application>pgbench</application> <xref linkend="pgbench-operators"/> are built into <application>pgbench</application>
and may be used in expressions appearing in and may be used in expressions appearing in
<link linkend="pgbench-metacommand-set"><literal>\set</literal></link>. <link linkend="pgbench-metacommand-set"><literal>\set</literal></link>.
The operators are listed in increasing precedence order.
Except as noted, operators taking two numeric inputs will produce
a double value if either input is double, otherwise they produce
an integer result.
</para> </para>
<table id="pgbench-operators"> <table id="pgbench-operators">
<title>pgbench Operators by Increasing Precedence</title> <title>pgbench Operators</title>
<tgroup cols="4"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Operator</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Description</entry> Operator
<entry>Example</entry> </para>
<entry>Result</entry> <para>
</row> Description
</thead> </para>
<tbody> <para>
<row> Example(s)
<entry><literal>OR</literal></entry> </para></entry>
<entry>logical or</entry> </row>
<entry><literal>5 or 0</literal></entry> </thead>
<entry><literal>TRUE</literal></entry>
</row> <tbody>
<row> <row>
<entry><literal>AND</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>logical and</entry> <replaceable>boolean</replaceable> <literal>OR</literal> <replaceable>boolean</replaceable>
<entry><literal>3 and 0</literal></entry> <returnvalue><replaceable>boolean</replaceable></returnvalue>
<entry><literal>FALSE</literal></entry> </para>
</row> <para>
<row> Logical OR
<entry><literal>NOT</literal></entry> </para>
<entry>logical not</entry> <para>
<entry><literal>not false</literal></entry> <literal>5 or 0</literal>
<entry><literal>TRUE</literal></entry> <returnvalue>TRUE</returnvalue>
</row> </para></entry>
<row> </row>
<entry><literal>IS [NOT] (NULL|TRUE|FALSE)</literal></entry>
<entry>value tests</entry> <row>
<entry><literal>1 is null</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>FALSE</literal></entry> <replaceable>boolean</replaceable> <literal>AND</literal> <replaceable>boolean</replaceable>
</row> <returnvalue><replaceable>boolean</replaceable></returnvalue>
<row> </para>
<entry><literal>ISNULL|NOTNULL</literal></entry> <para>
<entry>null tests</entry> Logical AND
<entry><literal>1 notnull</literal></entry> </para>
<entry><literal>TRUE</literal></entry> <para>
</row> <literal>3 and 0</literal>
<row> <returnvalue>FALSE</returnvalue>
<entry><literal>=</literal></entry> </para></entry>
<entry>is equal</entry> </row>
<entry><literal>5 = 4</literal></entry>
<entry><literal>FALSE</literal></entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<row> <literal>NOT</literal> <replaceable>boolean</replaceable>
<entry><literal>&lt;&gt;</literal></entry> <returnvalue><replaceable>boolean</replaceable></returnvalue>
<entry>is not equal</entry> </para>
<entry><literal>5 &lt;&gt; 4</literal></entry> <para>
<entry><literal>TRUE</literal></entry> Logical NOT
</row> </para>
<row> <para>
<entry><literal>!=</literal></entry> <literal>not false</literal>
<entry>is not equal</entry> <returnvalue>TRUE</returnvalue>
<entry><literal>5 != 5</literal></entry> </para></entry>
<entry><literal>FALSE</literal></entry> </row>
</row>
<row> <row>
<entry><literal>&lt;</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>lower than</entry> <replaceable>boolean</replaceable> <literal>IS [NOT] (NULL|TRUE|FALSE)</literal>
<entry><literal>5 &lt; 4</literal></entry> <returnvalue><replaceable>boolean</replaceable></returnvalue>
<entry><literal>FALSE</literal></entry> </para>
</row> <para>
<row> Boolean value tests
<entry><literal>&lt;=</literal></entry> </para>
<entry>lower or equal</entry> <para>
<entry><literal>5 &lt;= 4</literal></entry> <literal>1 is null</literal>
<entry><literal>FALSE</literal></entry> <returnvalue>FALSE</returnvalue>
</row> </para></entry>
<row> </row>
<entry><literal>&gt;</literal></entry>
<entry>greater than</entry> <row>
<entry><literal>5 &gt; 4</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>TRUE</literal></entry> <replaceable>value</replaceable> <literal>ISNULL|NOTNULL</literal>
</row> <returnvalue><replaceable>boolean</replaceable></returnvalue>
<row> </para>
<entry><literal>&gt;=</literal></entry> <para>
<entry>greater or equal</entry> Nullness tests
<entry><literal>5 &gt;= 4</literal></entry> </para>
<entry><literal>TRUE</literal></entry> <para>
</row> <literal>1 notnull</literal>
<row> <returnvalue>TRUE</returnvalue>
<entry><literal>|</literal></entry> </para></entry>
<entry>integer bitwise OR</entry> </row>
<entry><literal>1 | 2</literal></entry>
<entry><literal>3</literal></entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<row> <replaceable>number</replaceable> <literal>=</literal> <replaceable>number</replaceable>
<entry><literal>#</literal></entry> <returnvalue><replaceable>boolean</replaceable></returnvalue>
<entry>integer bitwise XOR</entry> </para>
<entry><literal>1 # 3</literal></entry> <para>
<entry><literal>2</literal></entry> Equal
</row> </para>
<row> <para>
<entry><literal>&amp;</literal></entry> <literal>5 = 4</literal>
<entry>integer bitwise AND</entry> <returnvalue>FALSE</returnvalue>
<entry><literal>1 &amp; 3</literal></entry> </para></entry>
<entry><literal>1</literal></entry> </row>
</row>
<row> <row>
<entry><literal>~</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>integer bitwise NOT</entry> <replaceable>number</replaceable> <literal>&lt;&gt;</literal> <replaceable>number</replaceable>
<entry><literal>~ 1</literal></entry> <returnvalue><replaceable>boolean</replaceable></returnvalue>
<entry><literal>-2</literal></entry> </para>
</row> <para>
<row> Not equal
<entry><literal>&lt;&lt;</literal></entry> </para>
<entry>integer bitwise shift left</entry> <para>
<entry><literal>1 &lt;&lt; 2</literal></entry> <literal>5 &lt;&gt; 4</literal>
<entry><literal>4</literal></entry> <returnvalue>TRUE</returnvalue>
</row> </para></entry>
<row> </row>
<entry><literal>&gt;&gt;</literal></entry>
<entry>integer bitwise shift right</entry> <row>
<entry><literal>8 &gt;&gt; 2</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry><literal>2</literal></entry> <replaceable>number</replaceable> <literal>!=</literal> <replaceable>number</replaceable>
</row> <returnvalue><replaceable>boolean</replaceable></returnvalue>
<row> </para>
<entry><literal>+</literal></entry> <para>
<entry>addition</entry> Not equal
<entry><literal>5 + 4</literal></entry> </para>
<entry><literal>9</literal></entry> <para>
</row> <literal>5 != 5</literal>
<row> <returnvalue>FALSE</returnvalue>
<entry><literal>-</literal></entry> </para></entry>
<entry>subtraction</entry> </row>
<entry><literal>3 - 2.0</literal></entry>
<entry><literal>1.0</literal></entry> <row>
</row> <entry role="func_table_entry"><para role="func_signature">
<row> <replaceable>number</replaceable> <literal>&lt;</literal> <replaceable>number</replaceable>
<entry><literal>*</literal></entry> <returnvalue><replaceable>boolean</replaceable></returnvalue>
<entry>multiplication</entry> </para>
<entry><literal>5 * 4</literal></entry> <para>
<entry><literal>20</literal></entry> Less than
</row> </para>
<row> <para>
<entry><literal>/</literal></entry> <literal>5 &lt; 4</literal>
<entry>division (integer truncates the results)</entry> <returnvalue>FALSE</returnvalue>
<entry><literal>5 / 3</literal></entry> </para></entry>
<entry><literal>1</literal></entry> </row>
</row>
<row> <row>
<entry><literal>%</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>modulo</entry> <replaceable>number</replaceable> <literal>&lt;=</literal> <replaceable>number</replaceable>
<entry><literal>3 % 2</literal></entry> <returnvalue><replaceable>boolean</replaceable></returnvalue>
<entry><literal>1</literal></entry> </para>
</row> <para>
<row> Less than or equal to
<entry><literal>-</literal></entry> </para>
<entry>opposite</entry> <para>
<entry><literal>- 2.0</literal></entry> <literal>5 &lt;= 4</literal>
<entry><literal>-2.0</literal></entry> <returnvalue>FALSE</returnvalue>
</row> </para></entry>
</tbody> </row>
</tgroup>
</table> <row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>number</replaceable> <literal>&gt;</literal> <replaceable>number</replaceable>
<returnvalue><replaceable>boolean</replaceable></returnvalue>
</para>
<para>
Greater than
</para>
<para>
<literal>5 &gt; 4</literal>
<returnvalue>TRUE</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>number</replaceable> <literal>&gt;=</literal> <replaceable>number</replaceable>
<returnvalue><replaceable>boolean</replaceable></returnvalue>
</para>
<para>
Greater than or equal to
</para>
<para>
<literal>5 &gt;= 4</literal>
<returnvalue>TRUE</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>integer</replaceable> <literal>|</literal> <replaceable>integer</replaceable>
<returnvalue><replaceable>integer</replaceable></returnvalue>
</para>
<para>
Bitwise OR
</para>
<para>
<literal>1 | 2</literal>
<returnvalue>3</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>integer</replaceable> <literal>#</literal> <replaceable>integer</replaceable>
<returnvalue><replaceable>integer</replaceable></returnvalue>
</para>
<para>
Bitwise XOR
</para>
<para>
<literal>1 # 3</literal>
<returnvalue>2</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>integer</replaceable> <literal>&amp;</literal> <replaceable>integer</replaceable>
<returnvalue><replaceable>integer</replaceable></returnvalue>
</para>
<para>
Bitwise AND
</para>
<para>
<literal>1 &amp; 3</literal>
<returnvalue>1</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<literal>~</literal> <replaceable>integer</replaceable>
<returnvalue><replaceable>integer</replaceable></returnvalue>
</para>
<para>
Bitwise NOT
</para>
<para>
<literal>~ 1</literal>
<returnvalue>-2</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>integer</replaceable> <literal>&lt;&lt;</literal> <replaceable>integer</replaceable>
<returnvalue><replaceable>integer</replaceable></returnvalue>
</para>
<para>
Bitwise shift left
</para>
<para>
<literal>1 &lt;&lt; 2</literal>
<returnvalue>4</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>integer</replaceable> <literal>&gt;&gt;</literal> <replaceable>integer</replaceable>
<returnvalue><replaceable>integer</replaceable></returnvalue>
</para>
<para>
Bitwise shift right
</para>
<para>
<literal>8 &gt;&gt; 2</literal>
<returnvalue>2</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>number</replaceable> <literal>+</literal> <replaceable>number</replaceable>
<returnvalue><replaceable>number</replaceable></returnvalue>
</para>
<para>
Addition
</para>
<para>
<literal>5 + 4</literal>
<returnvalue>9</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>number</replaceable> <literal>-</literal> <replaceable>number</replaceable>
<returnvalue><replaceable>number</replaceable></returnvalue>
</para>
<para>
Subtraction
</para>
<para>
<literal>3 - 2.0</literal>
<returnvalue>1.0</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>number</replaceable> <literal>*</literal> <replaceable>number</replaceable>
<returnvalue><replaceable>number</replaceable></returnvalue>
</para>
<para>
Multiplication
</para>
<para>
<literal>5 * 4</literal>
<returnvalue>20</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>number</replaceable> <literal>/</literal> <replaceable>number</replaceable>
<returnvalue><replaceable>number</replaceable></returnvalue>
</para>
<para>
Division (truncates the result towards zero if both inputs are integers)
</para>
<para>
<literal>5 / 3</literal>
<returnvalue>1</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<replaceable>integer</replaceable> <literal>%</literal> <replaceable>integer</replaceable>
<returnvalue><replaceable>integer</replaceable></returnvalue>
</para>
<para>
Modulo (remainder)
</para>
<para>
<literal>3 % 2</literal>
<returnvalue>1</returnvalue>
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<literal>-</literal> <replaceable>number</replaceable>
<returnvalue><replaceable>number</replaceable></returnvalue>
</para>
<para>
Negation
</para>
<para>
<literal>- 2.0</literal>
<returnvalue>-2.0</returnvalue>
</para></entry>
</row>
</tbody>
</tgroup>
</table>
</refsect2> </refsect2>
<refsect2 id="pgbench-builtin-functions"> <refsect2 id="pgbench-builtin-functions">
...@@ -1428,156 +1632,298 @@ SELECT 4 AS four \; SELECT 5 AS five \aset ...@@ -1428,156 +1632,298 @@ SELECT 4 AS four \; SELECT 5 AS five \aset
<!-- list pgbench functions in alphabetical order --> <!-- list pgbench functions in alphabetical order -->
<table id="pgbench-functions"> <table id="pgbench-functions">
<title>pgbench Functions</title> <title>pgbench Functions</title>
<tgroup cols="5"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Function</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Return Type</entry> Function
<entry>Description</entry> </para>
<entry>Example</entry> <para>
<entry>Result</entry> Description
</para>
<para>
Example(s)
</para></entry>
</row> </row>
</thead> </thead>
<tbody> <tbody>
<row> <row>
<entry><literal><function>abs(<replaceable>a</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>same as <replaceable>a</replaceable></entry> <function>abs</function> ( <replaceable>number</replaceable> )
<entry>absolute value</entry> <returnvalue></returnvalue> same type as input
<entry><literal>abs(-17)</literal></entry> </para>
<entry><literal>17</literal></entry> <para>
Absolute value
</para>
<para>
<literal>abs(-17)</literal>
<returnvalue>17</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>debug(<replaceable>a</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>same as <replaceable>a</replaceable> </entry> <function>debug</function> ( <replaceable>number</replaceable> )
<entry>print <replaceable>a</replaceable> to <systemitem>stderr</systemitem>, <returnvalue></returnvalue> same type as input
and return <replaceable>a</replaceable></entry> </para>
<entry><literal>debug(5432.1)</literal></entry> <para>
<entry><literal>5432.1</literal></entry> Prints the argument to <systemitem>stderr</systemitem>,
and returns the argument.
</para>
<para>
<literal>debug(5432.1)</literal>
<returnvalue>5432.1</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>double(<replaceable>i</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>double</entry> <function>double</function> ( <replaceable>number</replaceable> )
<entry>cast to double</entry> <returnvalue>double</returnvalue>
<entry><literal>double(5432)</literal></entry> </para>
<entry><literal>5432.0</literal></entry> <para>
Casts to double.
</para>
<para>
<literal>double(5432)</literal>
<returnvalue>5432.0</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>exp(<replaceable>x</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>double</entry> <function>exp</function> ( <replaceable>number</replaceable> )
<entry>exponential</entry> <returnvalue>double</returnvalue>
<entry><literal>exp(1.0)</literal></entry> </para>
<entry><literal>2.718281828459045</literal></entry> <para>
Exponential (<literal>e</literal> raised to the given power)
</para>
<para>
<literal>exp(1.0)</literal>
<returnvalue>2.718281828459045</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>greatest(<replaceable>a</replaceable> [, <replaceable>...</replaceable> ] )</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>double if any <replaceable>a</replaceable> is double, else integer</entry> <function>greatest</function> ( <replaceable>number</replaceable> <optional>, <literal>...</literal> </optional> )
<entry>largest value among arguments</entry> <returnvalue></returnvalue> <type>double</type> if any argument is double, else <type>integer</type>
<entry><literal>greatest(5, 4, 3, 2)</literal></entry> </para>
<entry><literal>5</literal></entry> <para>
Selects the largest value among the arguments.
</para>
<para>
<literal>greatest(5, 4, 3, 2)</literal>
<returnvalue>5</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>hash(<replaceable>a</replaceable> [, <replaceable>seed</replaceable> ] )</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>integer</entry> <function>hash</function> ( <parameter>value</parameter> <optional>, <parameter>seed</parameter> </optional> )
<entry>alias for <literal>hash_murmur2()</literal></entry> <returnvalue>integer</returnvalue>
<entry><literal>hash(10, 5432)</literal></entry> </para>
<entry><literal>-5817877081768721676</literal></entry> <para>
This is an alias for <function>hash_murmur2</function>.
</para>
<para>
<literal>hash(10, 5432)</literal>
<returnvalue>-5817877081768721676</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>hash_fnv1a(<replaceable>a</replaceable> [, <replaceable>seed</replaceable> ] )</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>integer</entry> <function>hash_fnv1a</function> ( <parameter>value</parameter> <optional>, <parameter>seed</parameter> </optional> )
<entry><ulink url="https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function">FNV-1a hash</ulink></entry> <returnvalue>integer</returnvalue>
<entry><literal>hash_fnv1a(10, 5432)</literal></entry> </para>
<entry><literal>-7793829335365542153</literal></entry> <para>
Computes <ulink url="https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function">FNV-1a hash</ulink>.
</para>
<para>
<literal>hash_fnv1a(10, 5432)</literal>
<returnvalue>-7793829335365542153</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>hash_murmur2(<replaceable>a</replaceable> [, <replaceable>seed</replaceable> ] )</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>integer</entry> <function>hash_murmur2</function> ( <parameter>value</parameter> <optional>, <parameter>seed</parameter> </optional> )
<entry><ulink url="https://en.wikipedia.org/wiki/MurmurHash">MurmurHash2 hash</ulink></entry> <returnvalue>integer</returnvalue>
<entry><literal>hash_murmur2(10, 5432)</literal></entry> </para>
<entry><literal>-5817877081768721676</literal></entry> <para>
Computes <ulink url="https://en.wikipedia.org/wiki/MurmurHash">MurmurHash2 hash</ulink>.
</para>
<para>
<literal>hash_murmur2(10, 5432)</literal>
<returnvalue>-5817877081768721676</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>int(<replaceable>x</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>integer</entry> <function>int</function> ( <replaceable>number</replaceable> )
<entry>cast to int</entry> <returnvalue>integer</returnvalue>
<entry><literal>int(5.4 + 3.8)</literal></entry> </para>
<entry><literal>9</literal></entry> <para>
Casts to integer.
</para>
<para>
<literal>int(5.4 + 3.8)</literal>
<returnvalue>9</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>least(<replaceable>a</replaceable> [, <replaceable>...</replaceable> ] )</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>double if any <replaceable>a</replaceable> is double, else integer</entry> <function>least</function> ( <replaceable>number</replaceable> <optional>, <literal>...</literal> </optional> )
<entry>smallest value among arguments</entry> <returnvalue></returnvalue> <type>double</type> if any argument is double, else <type>integer</type>
<entry><literal>least(5, 4, 3, 2.1)</literal></entry> </para>
<entry><literal>2.1</literal></entry> <para>
Selects the smallest value among the arguments.
</para>
<para>
<literal>least(5, 4, 3, 2.1)</literal>
<returnvalue>2.1</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>ln(<replaceable>x</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>double</entry> <function>ln</function> ( <replaceable>number</replaceable> )
<entry>natural logarithm</entry> <returnvalue>double</returnvalue>
<entry><literal>ln(2.718281828459045)</literal></entry> </para>
<entry><literal>1.0</literal></entry> <para>
Natural logarithm
</para>
<para>
<literal>ln(2.718281828459045)</literal>
<returnvalue>1.0</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>mod(<replaceable>i</replaceable>, <replaceable>j</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>integer</entry> <function>mod</function> ( <replaceable>integer</replaceable>, <replaceable>integer</replaceable> )
<entry>modulo</entry> <returnvalue>integer</returnvalue>
<entry><literal>mod(54, 32)</literal></entry> </para>
<entry><literal>22</literal></entry> <para>
Modulo (remainder)
</para>
<para>
<literal>mod(54, 32)</literal>
<returnvalue>22</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>pi()</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>double</entry> <function>pi</function> ()
<entry>value of the constant <phrase role="symbol_font">&pi;</phrase></entry> <returnvalue>double</returnvalue>
<entry><literal>pi()</literal></entry> </para>
<entry><literal>3.14159265358979323846</literal></entry> <para>
Approximate value of <phrase role="symbol_font">&pi;</phrase>
</para>
<para>
<literal>pi()</literal>
<returnvalue>3.14159265358979323846</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>pow(<replaceable>x</replaceable>, <replaceable>y</replaceable>)</function>, <function>power(<replaceable>x</replaceable>, <replaceable>y</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>double</entry> <function>pow</function> ( <parameter>x</parameter>, <parameter>y</parameter> )
<entry>exponentiation</entry> <returnvalue>double</returnvalue>
<entry><literal>pow(2.0, 10)</literal>, <literal>power(2.0, 10)</literal></entry> </para>
<entry><literal>1024.0</literal></entry> <para role="func_signature">
<function>power</function> ( <parameter>x</parameter>, <parameter>y</parameter> )
<returnvalue>double</returnvalue>
</para>
<para>
<parameter>x</parameter> raised to the power of <parameter>y</parameter>
</para>
<para>
<literal>pow(2.0, 10)</literal>
<returnvalue>1024.0</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>random(<replaceable>lb</replaceable>, <replaceable>ub</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>integer</entry> <function>random</function> ( <parameter>lb</parameter>, <parameter>ub</parameter> )
<entry>uniformly-distributed random integer in <literal>[lb, ub]</literal></entry> <returnvalue>integer</returnvalue>
<entry><literal>random(1, 10)</literal></entry> </para>
<entry>an integer between <literal>1</literal> and <literal>10</literal></entry> <para>
Computes a uniformly-distributed random integer in <literal>[lb,
ub]</literal>.
</para>
<para>
<literal>random(1, 10)</literal>
<returnvalue>an integer between 1 and 10</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>random_exponential(<replaceable>lb</replaceable>, <replaceable>ub</replaceable>, <replaceable>parameter</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>integer</entry> <function>random_exponential</function> ( <parameter>lb</parameter>, <parameter>ub</parameter>, <parameter>parameter</parameter> )
<entry>exponentially-distributed random integer in <literal>[lb, ub]</literal>, <returnvalue>integer</returnvalue>
see below</entry> </para>
<entry><literal>random_exponential(1, 10, 3.0)</literal></entry> <para>
<entry>an integer between <literal>1</literal> and <literal>10</literal></entry> Computes an exponentially-distributed random integer in <literal>[lb,
ub]</literal>, see below.
</para>
<para>
<literal>random_exponential(1, 10, 3.0)</literal>
<returnvalue>an integer between 1 and 10</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>random_gaussian(<replaceable>lb</replaceable>, <replaceable>ub</replaceable>, <replaceable>parameter</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>integer</entry> <function>random_gaussian</function> ( <parameter>lb</parameter>, <parameter>ub</parameter>, <parameter>parameter</parameter> )
<entry>Gaussian-distributed random integer in <literal>[lb, ub]</literal>, <returnvalue>integer</returnvalue>
see below</entry> </para>
<entry><literal>random_gaussian(1, 10, 2.5)</literal></entry> <para>
<entry>an integer between <literal>1</literal> and <literal>10</literal></entry> Computes a gaussian-distributed random integer in <literal>[lb,
ub]</literal>, see below.
</para>
<para>
<literal>random_gaussian(1, 10, 2.5)</literal>
<returnvalue>an integer between 1 and 10</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>random_zipfian(<replaceable>lb</replaceable>, <replaceable>ub</replaceable>, <replaceable>parameter</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>integer</entry> <function>random_zipfian</function> ( <parameter>lb</parameter>, <parameter>ub</parameter>, <parameter>parameter</parameter> )
<entry>Zipfian-distributed random integer in <literal>[lb, ub]</literal>, <returnvalue>integer</returnvalue>
see below</entry> </para>
<entry><literal>random_zipfian(1, 10, 1.5)</literal></entry> <para>
<entry>an integer between <literal>1</literal> and <literal>10</literal></entry> Computes a Zipfian-distributed random integer in <literal>[lb,
ub]</literal>, see below.
</para>
<para>
<literal>random_zipfian(1, 10, 1.5)</literal>
<returnvalue>an integer between 1 and 10</returnvalue>
</para></entry>
</row> </row>
<row> <row>
<entry><literal><function>sqrt(<replaceable>x</replaceable>)</function></literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>double</entry> <function>sqrt</function> ( <replaceable>number</replaceable> )
<entry>square root</entry> <returnvalue>double</returnvalue>
<entry><literal>sqrt(2.0)</literal></entry> </para>
<entry><literal>1.414213562</literal></entry> <para>
Square root
</para>
<para>
<literal>sqrt(2.0)</literal>
<returnvalue>1.414213562</returnvalue>
</para></entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>
</table> </table>
<para> <para>
...@@ -1819,7 +2165,7 @@ END; ...@@ -1819,7 +2165,7 @@ END;
format is used for the log files: format is used for the log files:
<synopsis> <synopsis>
<replaceable>interval_start</replaceable> <replaceable>num_transactions</replaceable> <replaceable>sum_latency</replaceable> <replaceable>sum_latency_2</replaceable> <replaceable>min_latency</replaceable> <replaceable>max_latency</replaceable> <optional> <replaceable>sum_lag</replaceable> <replaceable>sum_lag_2</replaceable> <replaceable>min_lag</replaceable> <replaceable>max_lag</replaceable> <optional> <replaceable>skipped</replaceable> </optional> </optional> <replaceable>interval_start</replaceable> <replaceable>num_transactions</replaceable>&zwsp; <replaceable>sum_latency</replaceable> <replaceable>sum_latency_2</replaceable> <replaceable>min_latency</replaceable> <replaceable>max_latency</replaceable>&zwsp; <optional> <replaceable>sum_lag</replaceable> <replaceable>sum_lag_2</replaceable> <replaceable>min_lag</replaceable> <replaceable>max_lag</replaceable> <optional> <replaceable>skipped</replaceable> </optional> </optional>
</synopsis> </synopsis>
where where
......
...@@ -141,6 +141,8 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH"; ...@@ -141,6 +141,8 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH";
<table id="seg-input-examples"> <table id="seg-input-examples">
<title>Examples of Valid <type>seg</type> Input</title> <title>Examples of Valid <type>seg</type> Input</title>
<tgroup cols="2"> <tgroup cols="2">
<colspec colname="col1" colwidth="1*"/>
<colspec colname="col2" colwidth="2*"/>
<tbody> <tbody>
<row> <row>
<entry><literal>5.0</literal></entry> <entry><literal>5.0</literal></entry>
...@@ -248,65 +250,106 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH"; ...@@ -248,65 +250,106 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH";
<table id="seg-gist-operators"> <table id="seg-gist-operators">
<title>Seg GiST Operators</title> <title>Seg GiST Operators</title>
<tgroup cols="2"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Operator</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Description</entry> Operator
</row> </para>
</thead> <para>
Description
</para></entry>
</row>
</thead>
<tbody> <tbody>
<row> <row>
<entry><literal>[a, b] &lt;&lt; [c, d]</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>[a, b] is entirely to the left of [c, d]. That is, [a, <type>seg</type> <literal>&lt;&lt;</literal> <type>seg</type>
b] &lt;&lt; [c, d] is true if b &lt; c and false otherwise.</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para>
Is the first <type>seg</type> entirely to the left of the second?
[a, b] &lt;&lt; [c, d] is true if b &lt; c.
</para></entry>
</row>
<row> <row>
<entry><literal>[a, b] &gt;&gt; [c, d]</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>[a, b] is entirely to the right of [c, d]. That is, [a, <type>seg</type> <literal>&gt;&gt;</literal> <type>seg</type>
b] &gt;&gt; [c, d] is true if a &gt; d and false otherwise.</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para>
Is the first <type>seg</type> entirely to the right of the second?
[a, b] &gt;&gt; [c, d] is true if a &gt; d.
</para></entry>
</row>
<row> <row>
<entry><literal>[a, b] &amp;&lt; [c, d]</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Overlaps or is left of &mdash; This might be better read <type>seg</type> <literal>&amp;&lt;</literal> <type>seg</type>
as <quote>does not extend to right of</quote>. It is true when <returnvalue>boolean</returnvalue>
b &lt;= d.</entry> </para>
</row> <para>
Does the first <type>seg</type> not extend to the right of the
second?
[a, b] &amp;&lt; [c, d] is true if b &lt;= d.
</para></entry>
</row>
<row> <row>
<entry><literal>[a, b] &amp;&gt; [c, d]</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Overlaps or is right of &mdash; This might be better read <type>seg</type> <literal>&amp;&gt;</literal> <type>seg</type>
as <quote>does not extend to left of</quote>. It is true when <returnvalue>boolean</returnvalue>
a &gt;= c.</entry> </para>
</row> <para>
Does the first <type>seg</type> not extend to the left of the
second?
[a, b] &amp;&gt; [c, d] is true if a &gt;= c.
</para></entry>
</row>
<row> <row>
<entry><literal>[a, b] = [c, d]</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Same as &mdash; The segments [a, b] and [c, d] are <type>seg</type> <literal>=</literal> <type>seg</type>
identical, that is, a = c and b = d.</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para>
Are the two <type>seg</type>s equal?
</para></entry>
</row>
<row> <row>
<entry><literal>[a, b] &amp;&amp; [c, d]</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>The segments [a, b] and [c, d] overlap.</entry> <type>seg</type> <literal>&amp;&amp;</literal> <type>seg</type>
</row> <returnvalue>boolean</returnvalue>
</para>
<para>
Do the two <type>seg</type>s overlap?
</para></entry>
</row>
<row> <row>
<entry><literal>[a, b] @&gt; [c, d]</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>The segment [a, b] contains the segment [c, d], that is, <type>seg</type> <literal>@&gt;</literal> <type>seg</type>
a &lt;= c and b &gt;= d.</entry> <returnvalue>boolean</returnvalue>
</row> </para>
<para>
Does the first <type>seg</type> contain the second?
</para></entry>
</row>
<row> <row>
<entry><literal>[a, b] &lt;@ [c, d]</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>The segment [a, b] is contained in [c, d], that is, a <type>seg</type> <literal>&lt;@</literal> <type>seg</type>
&gt;= c and b &lt;= d.</entry> <returnvalue>boolean</returnvalue>
</row> </para>
</tbody> <para>
</tgroup> Is the first <type>seg</type> contained in the second?
</para></entry>
</row>
</tbody>
</tgroup>
</table> </table>
<para> <para>
...@@ -318,33 +361,10 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH"; ...@@ -318,33 +361,10 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH";
</para> </para>
<para> <para>
The standard B-tree operators are also provided, for example In addition to the above operators, the usual comparison
operators shown in <xref linkend="functions-comparison-op-table"/> are
<informaltable> available for type <type>seg</type>. These operators
<tgroup cols="2"> first compare (a) to (c),
<thead>
<row>
<entry>Operator</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>[a, b] &lt; [c, d]</literal></entry>
<entry>Less than</entry>
</row>
<row>
<entry><literal>[a, b] &gt; [c, d]</literal></entry>
<entry>Greater than</entry>
</row>
</tbody>
</tgroup>
</informaltable>
These operators do not make a lot of sense for any practical
purpose but sorting. These operators first compare (a) to (c),
and if these are equal, compare (b) to (d). That results in and if these are equal, compare (b) to (d). That results in
reasonably good sorting in most cases, which is useful if reasonably good sorting in most cases, which is useful if
you want to use ORDER BY with this type. you want to use ORDER BY with this type.
......
...@@ -605,7 +605,7 @@ regression=# select sepgsql_getcon(); ...@@ -605,7 +605,7 @@ regression=# select sepgsql_getcon();
(1 row) (1 row)
regression=# SELECT sepgsql_setcon('unconfined_u:unconfined_r:unconfined_t:s0-s0:c1.c4'); regression=# SELECT sepgsql_setcon('unconfined_u:unconfined_r:unconfined_t:s0-s0:c1.c4');
sepgsql_setcon sepgsql_setcon
---------------- ----------------
t t
(1 row) (1 row)
...@@ -659,45 +659,77 @@ ERROR: SELinux: security policy violation ...@@ -659,45 +659,77 @@ ERROR: SELinux: security policy violation
<table id="sepgsql-functions-table"> <table id="sepgsql-functions-table">
<title>Sepgsql Functions</title> <title>Sepgsql Functions</title>
<tgroup cols="2"> <tgroup cols="1">
<tbody> <thead>
<row> <row>
<entry><literal>sepgsql_getcon() returns text</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry> Function
Returns the client domain, the current security label of the client. </para>
</entry> <para>
</row> Description
<row> </para></entry>
<entry><literal>sepgsql_setcon(text) returns bool</literal></entry> </row>
<entry> </thead>
Switches the client domain of the current session to the new domain,
if allowed by the security policy. <tbody>
It also accepts <literal>NULL</literal> input as a request to transition <row>
to the client's original domain. <entry role="func_table_entry"><para role="func_signature">
</entry> <function>sepgsql_getcon</function> ()
</row> <returnvalue>text</returnvalue>
<row> </para>
<entry><literal>sepgsql_mcstrans_in(text) returns text</literal></entry> <para>
<entry>Translates the given qualified MLS/MCS range into raw format if Returns the client domain, the current security label of the client.
the mcstrans daemon is running. </para></entry>
</entry> </row>
</row>
<row> <row>
<entry><literal>sepgsql_mcstrans_out(text) returns text</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Translates the given raw MLS/MCS range into qualified format if <function>sepgsql_setcon</function> ( <type>text</type> )
the mcstrans daemon is running. <returnvalue>boolean</returnvalue>
</entry> </para>
</row> <para>
<row> Switches the client domain of the current session to the new domain,
<entry><literal>sepgsql_restorecon(text) returns bool</literal></entry> if allowed by the security policy.
<entry> It also accepts <literal>NULL</literal> input as a request to transition
Sets up initial security labels for all objects within the to the client's original domain.
current database. The argument may be NULL, or the name of a specfile </para></entry>
to be used as alternative of the system default. </row>
</entry>
</row> <row>
</tbody> <entry role="func_table_entry"><para role="func_signature">
</tgroup> <function>sepgsql_mcstrans_in</function> ( <type>text</type> )
<returnvalue>text</returnvalue>
</para>
<para>
Translates the given qualified MLS/MCS range into raw format if
the mcstrans daemon is running.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>sepgsql_mcstrans_out</function> ( <type>text</type> )
<returnvalue>text</returnvalue>
</para>
<para>
Translates the given raw MLS/MCS range into qualified format if
the mcstrans daemon is running.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>sepgsql_restorecon</function> ( <type>text</type> )
<returnvalue>boolean</returnvalue>
</para>
<para>
Sets up initial security labels for all objects within the
current database. The argument may be <literal>NULL</literal>, or the
name of a specfile to be used as alternative of the system default.
</para></entry>
</row>
</tbody>
</tgroup>
</table> </table>
</sect2> </sect2>
......
...@@ -24,83 +24,99 @@ ...@@ -24,83 +24,99 @@
<title>Functions Provided</title> <title>Functions Provided</title>
<para> <para>
<xref linkend="tablefunc-functions"/> shows the functions provided <xref linkend="tablefunc-functions"/> summarizes the functions provided
by the <filename>tablefunc</filename> module. by the <filename>tablefunc</filename> module.
</para> </para>
<table id="tablefunc-functions"> <table id="tablefunc-functions">
<title><filename>tablefunc</filename> Functions</title> <title><filename>tablefunc</filename> Functions</title>
<tgroup cols="3"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Function</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Returns</entry> Function
<entry>Description</entry> </para>
</row> <para>
</thead> Description
<tbody> </para></entry>
<row> </row>
<entry><function>normal_rand(int numvals, float8 mean, float8 stddev)</function></entry> </thead>
<entry><type>setof float8</type></entry>
<entry> <tbody>
Produces a set of normally distributed random values <row>
</entry> <entry role="func_table_entry"><para role="func_signature">
</row> <function>normal_rand</function> ( <parameter>numvals</parameter> <type>integer</type>, <parameter>mean</parameter> <type>float8</type>, <parameter>stddev</parameter> <type>float8</type> )
<row> <returnvalue>setof float8</returnvalue>
<entry><function>crosstab(text sql)</function></entry>
<entry><type>setof record</type></entry>
<entry>
Produces a <quote>pivot table</quote> containing
row names plus <replaceable>N</replaceable> value columns, where
<replaceable>N</replaceable> is determined by the row type specified in the calling
query
</entry>
</row>
<row>
<entry><function>crosstab<replaceable>N</replaceable>(text sql)</function></entry>
<entry><type>setof table_crosstab_<replaceable>N</replaceable></type></entry>
<entry>
Produces a <quote>pivot table</quote> containing
row names plus <replaceable>N</replaceable> value columns.
<function>crosstab2</function>, <function>crosstab3</function>, and
<function>crosstab4</function> are predefined, but you can create additional
<function>crosstab<replaceable>N</replaceable></function> functions as described below
</entry>
</row>
<row>
<entry><function>crosstab(text source_sql, text category_sql)</function></entry>
<entry><type>setof record</type></entry>
<entry>
Produces a <quote>pivot table</quote>
with the value columns specified by a second query
</entry>
</row>
<row>
<entry><function>crosstab(text sql, int N)</function></entry>
<entry><type>setof record</type></entry>
<entry>
<para>Obsolete version of <function>crosstab(text)</function>.
The parameter <replaceable>N</replaceable> is now ignored, since the number of
value columns is always determined by the calling query
</para> </para>
</entry> <para>
</row> Produces a set of normally distributed random values.
<row> </para></entry>
<entry> </row>
<function>
connectby(text relname, text keyid_fld, text parent_keyid_fld <row>
[, text orderby_fld ], text start_with, int max_depth <entry role="func_table_entry"><para role="func_signature">
[, text branch_delim ]) <function>crosstab</function> ( <parameter>sql</parameter> <type>text</type> )
</function> <returnvalue>setof record</returnvalue>
<indexterm><primary>connectby</primary></indexterm> </para>
</entry> <para>
<entry><type>setof record</type></entry> Produces a <quote>pivot table</quote> containing
<entry> row names plus <replaceable>N</replaceable> value columns, where
Produces a representation of a hierarchical tree structure <replaceable>N</replaceable> is determined by the row type specified
</entry> in the calling query.
</row> </para></entry>
</tbody> </row>
</tgroup>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>crosstab<replaceable>N</replaceable></function> ( <parameter>sql</parameter> <type>text</type> )
<returnvalue>setof table_crosstab_<replaceable>N</replaceable></returnvalue>
</para>
<para>
Produces a <quote>pivot table</quote> containing
row names plus <replaceable>N</replaceable> value columns.
<function>crosstab2</function>, <function>crosstab3</function>, and
<function>crosstab4</function> are predefined, but you can create additional
<function>crosstab<replaceable>N</replaceable></function> functions as described below.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>crosstab</function> ( <parameter>source_sql</parameter> <type>text</type>, <parameter>category_sql</parameter> <type>text</type> )
<returnvalue>setof record</returnvalue>
</para>
<para>
Produces a <quote>pivot table</quote>
with the value columns specified by a second query.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>crosstab</function> ( <parameter>sql</parameter> <type>text</type>, <parameter>N</parameter> <type>integer</type> )
<returnvalue>setof record</returnvalue>
</para>
<para>
Obsolete version of <function>crosstab(text)</function>.
The parameter <parameter>N</parameter> is now ignored, since the
number of value columns is always determined by the calling query.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>connectby</primary></indexterm>
<function>connectby</function> ( <parameter>relname</parameter> <type>text</type>, <parameter>keyid_fld</parameter> <type>text</type>, <parameter>parent_keyid_fld</parameter> <type>text</type>
<optional>, <parameter>orderby_fld</parameter> <type>text</type> </optional>, <parameter>start_with</parameter> <type>text</type>, <parameter>max_depth</parameter> <type>integer</type>
<optional>, <parameter>branch_delim</parameter> <type>text</type> </optional> )
<returnvalue>setof record</returnvalue>
</para>
<para>
Produces a representation of a hierarchical tree structure.
</para></entry>
</row>
</tbody>
</tgroup>
</table> </table>
<sect3> <sect3>
......
...@@ -37,46 +37,59 @@ ...@@ -37,46 +37,59 @@
<table id="uuid-ossp-functions"> <table id="uuid-ossp-functions">
<title>Functions for UUID Generation</title> <title>Functions for UUID Generation</title>
<tgroup cols="2"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Function</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Description</entry> Function
</row> </para>
</thead> <para>
<tbody> Description
<row> </para></entry>
<entry><function>uuid_generate_v1()</function><indexterm><primary>uuid_generate_v1</primary></indexterm></entry> </row>
<entry> </thead>
<tbody>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>uuid_generate_v1</primary></indexterm>
<function>uuid_generate_v1</function> ()
<returnvalue>uuid</returnvalue>
</para>
<para> <para>
This function generates a version 1 UUID. This involves the MAC Generates a version 1 UUID. This involves the MAC
address of the computer and a time stamp. Note that UUIDs of this address of the computer and a time stamp. Note that UUIDs of this
kind reveal the identity of the computer that created the identifier kind reveal the identity of the computer that created the identifier
and the time at which it did so, which might make it unsuitable for and the time at which it did so, which might make it unsuitable for
certain security-sensitive applications. certain security-sensitive applications.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>uuid_generate_v1mc</primary></indexterm>
<function>uuid_generate_v1mc</function> ()
<returnvalue>uuid</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry><function>uuid_generate_v1mc()</function><indexterm><primary>uuid_generate_v1mc</primary></indexterm></entry>
<entry>
<para> <para>
This function generates a version 1 UUID but uses a random multicast Generates a version 1 UUID, but uses a random multicast
MAC address instead of the real MAC address of the computer. MAC address instead of the real MAC address of the computer.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm><primary>uuid_generate_v3</primary></indexterm>
<function>uuid_generate_v3</function> ( <parameter>namespace</parameter> <type>uuid</type>, <parameter>name</parameter> <type>text</type> )
<returnvalue>uuid</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry><function>uuid_generate_v3(namespace uuid, name text)</function><indexterm><primary>uuid_generate_v3</primary></indexterm></entry>
<entry>
<para> <para>
This function generates a version 3 UUID in the given namespace using Generates a version 3 UUID in the given namespace using
the specified input name. The namespace should be one of the special the specified input name. The namespace should be one of the special
constants produced by the <function>uuid_ns_*()</function> functions shown constants produced by the <function>uuid_ns_*()</function> functions
in <xref linkend="uuid-ossp-constants"/>. (It could be any UUID in theory.) The name is an identifier shown in <xref linkend="uuid-ossp-constants"/>. (It could be any UUID
in the selected namespace. in theory.) The name is an identifier in the selected namespace.
</para> </para>
<para> <para>
For example: For example:
...@@ -88,82 +101,106 @@ SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org'); ...@@ -88,82 +101,106 @@ SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org');
derived from the generated UUID. derived from the generated UUID.
The generation of UUIDs by this method has no random or The generation of UUIDs by this method has no random or
environment-dependent element and is therefore reproducible. environment-dependent element and is therefore reproducible.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>uuid_generate_v4</function> ()
<returnvalue>uuid</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry><literal>uuid_generate_v4()</literal></entry>
<entry>
<para> <para>
This function generates a version 4 UUID, which is derived entirely Generates a version 4 UUID, which is derived entirely
from random numbers. from random numbers.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>uuid_generate_v5</function> ( <parameter>namespace</parameter> <type>uuid</type>, <parameter>name</parameter> <type>text</type> )
<returnvalue>uuid</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry><literal>uuid_generate_v5(namespace uuid, name text)</literal></entry>
<entry>
<para> <para>
This function generates a version 5 UUID, which works like a version 3 Generates a version 5 UUID, which works like a version 3
UUID except that SHA-1 is used as a hashing method. Version 5 should UUID except that SHA-1 is used as a hashing method. Version 5 should
be preferred over version 3 because SHA-1 is thought to be more secure be preferred over version 3 because SHA-1 is thought to be more secure
than MD5. than MD5.
</para> </para></entry>
</entry> </row>
</row> </tbody>
</tbody> </tgroup>
</tgroup>
</table> </table>
<table id="uuid-ossp-constants"> <table id="uuid-ossp-constants">
<title>Functions Returning UUID Constants</title> <title>Functions Returning UUID Constants</title>
<tgroup cols="2"> <tgroup cols="1">
<tbody> <thead>
<row> <row>
<entry><literal>uuid_nil()</literal></entry> <entry role="func_table_entry"><para role="func_signature">
<entry> Function
</para>
<para>
Description
</para></entry>
</row>
</thead>
<tbody>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>uuid_nil</function> ()
<returnvalue>uuid</returnvalue>
</para>
<para> <para>
A <quote>nil</quote> UUID constant, which does not occur as a real UUID. Returns a <quote>nil</quote> UUID constant, which does not occur as a
real UUID.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>uuid_ns_dns</function> ()
<returnvalue>uuid</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry><literal>uuid_ns_dns()</literal></entry>
<entry>
<para> <para>
Constant designating the DNS namespace for UUIDs. Returns a constant designating the DNS namespace for UUIDs.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>uuid_ns_url</function> ()
<returnvalue>uuid</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry><literal>uuid_ns_url()</literal></entry>
<entry>
<para> <para>
Constant designating the URL namespace for UUIDs. Returns a constant designating the URL namespace for UUIDs.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>uuid_ns_oid</function> ()
<returnvalue>uuid</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry><literal>uuid_ns_oid()</literal></entry>
<entry>
<para> <para>
Constant designating the ISO object identifier (OID) namespace for Returns a constant designating the ISO object identifier (OID) namespace for
UUIDs. (This pertains to ASN.1 OIDs, which are unrelated to the OIDs UUIDs. (This pertains to ASN.1 OIDs, which are unrelated to the OIDs
used in <productname>PostgreSQL</productname>.) used in <productname>PostgreSQL</productname>.)
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>uuid_ns_x500</function> ()
<returnvalue>uuid</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry><literal>uuid_ns_x500()</literal></entry>
<entry>
<para> <para>
Constant designating the X.500 distinguished name (DN) namespace for Returns a constant designating the X.500 distinguished name (DN)
UUIDs. namespace for UUIDs.
</para> </para></entry>
</entry> </row>
</row> </tbody>
</tbody> </tgroup>
</tgroup>
</table> </table>
</sect2> </sect2>
......
...@@ -36,161 +36,135 @@ ...@@ -36,161 +36,135 @@
<para> <para>
<xref linkend="xml2-functions-table"/> shows the functions provided by this module. <xref linkend="xml2-functions-table"/> shows the functions provided by this module.
These functions provide straightforward XML parsing and XPath queries. These functions provide straightforward XML parsing and XPath queries.
All arguments are of type <type>text</type>, so for brevity that is not shown.
</para> </para>
<table id="xml2-functions-table"> <table id="xml2-functions-table">
<title>Functions</title> <title><filename>xml2</filename> Functions</title>
<tgroup cols="3"> <tgroup cols="1">
<thead> <thead>
<row> <row>
<entry>Function</entry> <entry role="func_table_entry"><para role="func_signature">
<entry>Returns</entry> Function
<entry>Description</entry> </para>
</row> <para>
</thead> Description
<tbody> </para></entry>
<row> </row>
<entry> </thead>
<function>
xml_valid(document) <tbody>
</function> <row>
</entry> <entry role="func_table_entry"><para role="func_signature">
<entry> <function>xml_valid</function> ( <parameter>document</parameter> <type>text</type> )
<type>bool</type> <returnvalue>boolean</returnvalue>
</entry> </para>
<entry>
<para> <para>
This parses the document text in its parameter and returns true if the Parses the given document and returns true if the
document is well-formed XML. (Note: this is an alias for the standard document is well-formed XML. (Note: this is an alias for the standard
PostgreSQL function <function>xml_is_well_formed()</function>. The PostgreSQL function <function>xml_is_well_formed()</function>. The
name <function>xml_valid()</function> is technically incorrect since validity name <function>xml_valid()</function> is technically incorrect since validity
and well-formedness have different meanings in XML.) and well-formedness have different meanings in XML.)
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>xpath_string</function> ( <parameter>document</parameter> <type>text</type>, <parameter>query</parameter> <type>text</type> )
<returnvalue>text</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry>
<function>
xpath_string(document, query)
</function>
</entry>
<entry>
<type>text</type>
</entry>
<entry morerows="2">
<para> <para>
These functions evaluate the XPath query on the supplied document, and Evaluates the XPath query on the supplied document, and
cast the result to the specified type. casts the result to <type>text</type>.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>xpath_number</function> ( <parameter>document</parameter> <type>text</type>, <parameter>query</parameter> <type>text</type> )
<returnvalue>real</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry>
<function>
xpath_number(document, query)
</function>
</entry>
<entry>
<type>float4</type>
</entry>
</row>
<row>
<entry>
<function>
xpath_bool(document, query)
</function>
</entry>
<entry>
<type>bool</type>
</entry>
</row>
<row>
<entry>
<function>
xpath_nodeset(document, query, toptag, itemtag)
</function>
</entry>
<entry>
<type>text</type>
</entry>
<entry>
<para> <para>
This evaluates query on document and wraps the result in XML tags. If Evaluates the XPath query on the supplied document, and
the result is multivalued, the output will look like: casts the result to <type>real</type>.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>xpath_bool</function> ( <parameter>document</parameter> <type>text</type>, <parameter>query</parameter> <type>text</type> )
<returnvalue>boolean</returnvalue>
</para>
<para>
Evaluates the XPath query on the supplied document, and
casts the result to <type>boolean</type>.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>xpath_nodeset</function> ( <parameter>document</parameter> <type>text</type>, <parameter>query</parameter> <type>text</type>, <parameter>toptag</parameter> <type>text</type>, <parameter>itemtag</parameter> <type>text</type> )
<returnvalue>text</returnvalue>
</para>
<para>
Evaluates the query on the document and wraps the result in XML
tags. If the result is multivalued, the output will look like:
<synopsis> <synopsis>
&lt;toptag&gt; &lt;toptag&gt;
&lt;itemtag&gt;Value 1 which could be an XML fragment&lt;/itemtag&gt; &lt;itemtag&gt;Value 1 which could be an XML fragment&lt;/itemtag&gt;
&lt;itemtag&gt;Value 2....&lt;/itemtag&gt; &lt;itemtag&gt;Value 2....&lt;/itemtag&gt;
&lt;/toptag&gt; &lt;/toptag&gt;
</synopsis> </synopsis>
If either <literal>toptag</literal> or <literal>itemtag</literal> is an empty string, the relevant tag is omitted. If either <parameter>toptag</parameter>
or <parameter>itemtag</parameter> is an empty string, the relevant tag
is omitted.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>xpath_nodeset</function> ( <parameter>document</parameter> <type>text</type>, <parameter>query</parameter> <type>text</type>, <parameter>itemtag</parameter> <type>text</type> )
<returnvalue>text</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry>
<function>
xpath_nodeset(document, query)
</function>
</entry>
<entry>
<type>text</type>
</entry>
<entry>
<para> <para>
Like <function>xpath_nodeset(document, query, toptag, itemtag)</function> but result omits both tags. Like <function>xpath_nodeset(document, query, toptag, itemtag)</function> but result omits <parameter>toptag</parameter>.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>xpath_nodeset</function> ( <parameter>document</parameter> <type>text</type>, <parameter>query</parameter> <type>text</type> )
<returnvalue>text</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry>
<function>
xpath_nodeset(document, query, itemtag)
</function>
</entry>
<entry>
<type>text</type>
</entry>
<entry>
<para> <para>
Like <function>xpath_nodeset(document, query, toptag, itemtag)</function> but result omits <literal>toptag</literal>. Like <function>xpath_nodeset(document, query, toptag, itemtag)</function> but result omits both tags.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>xpath_list</function> ( <parameter>document</parameter> <type>text</type>, <parameter>query</parameter> <type>text</type>, <parameter>separator</parameter> <type>text</type> )
<returnvalue>text</returnvalue>
</para> </para>
</entry>
</row>
<row>
<entry>
<function>
xpath_list(document, query, separator)
</function>
</entry>
<entry>
<type>text</type>
</entry>
<entry>
<para> <para>
This function returns multiple values separated by the specified Evaluates the query on the document and returns multiple values
separator, for example <literal>Value 1,Value 2,Value 3</literal> if separated by the specified separator, for example <literal>Value
separator is <literal>,</literal>. 1,Value 2,Value 3</literal> if <parameter>separator</parameter>
is <literal>,</literal>.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<function>xpath_list</function> ( <parameter>document</parameter> <type>text</type>, <parameter>query</parameter> <type>text</type> )
<returnvalue>text</returnvalue>
</para> </para>
</entry> <para>
</row> This is a wrapper for the above function that uses <literal>,</literal>
<row> as the separator.
<entry> </para></entry>
<function> </row>
xpath_list(document, query) </tbody>
</function> </tgroup>
</entry>
<entry>
<type>text</type>
</entry>
<entry>
This is a wrapper for the above function that uses <literal>,</literal>
as the separator.
</entry>
</row>
</tbody>
</tgroup>
</table> </table>
</sect2> </sect2>
...@@ -217,6 +191,8 @@ xpath_table(text key, text document, text relation, text xpaths, text criteria) ...@@ -217,6 +191,8 @@ xpath_table(text key, text document, text relation, text xpaths, text criteria)
<table id="xml2-xpath-table-parameters"> <table id="xml2-xpath-table-parameters">
<title><function>xpath_table</function> Parameters</title> <title><function>xpath_table</function> Parameters</title>
<tgroup cols="2"> <tgroup cols="2">
<colspec colname="col1" colwidth="1*"/>
<colspec colname="col2" colwidth="2*"/>
<thead> <thead>
<row> <row>
<entry>Parameter</entry> <entry>Parameter</entry>
......
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