Skip to content

Commit 687d7cf

Browse files
committed
Documentation for generate_series() functions committed a few days ago.
1 parent 8d09e25 commit 687d7cf

File tree

1 file changed

+91
-1
lines changed

1 file changed

+91
-1
lines changed

doc/src/sgml/func.sgml

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.185 2003/12/26 21:30:48 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.186 2004/02/05 22:54:36 joe Exp $
33
PostgreSQL documentation
44
-->
55

@@ -8199,6 +8199,96 @@ AND
81998199
</sect2>
82008200
</sect1>
82018201

8202+
<sect1 id="functions-srf">
8203+
<title>Set Returning Functions</title>
8204+
8205+
<indexterm zone="functions-srf">
8206+
<primary>set returning functions</primary>
8207+
<secondary>functions</secondary>
8208+
</indexterm>
8209+
8210+
<para>
8211+
This section describes functions that possibly return more than one row.
8212+
Currently the only functions in this class are series generating functions,
8213+
as detailed in <xref linkend="functions-srf-series">.
8214+
</para>
8215+
8216+
<table id="functions-srf-series">
8217+
<title>Series Generating Functions</title>
8218+
<tgroup cols="4">
8219+
<thead>
8220+
<row>
8221+
<entry>Function</entry>
8222+
<entry>Argument Type</entry>
8223+
<entry>Return Type</entry>
8224+
<entry>Description</entry>
8225+
</row>
8226+
</thead>
8227+
8228+
<tbody>
8229+
<row>
8230+
<entry><literal><function>generate_series</function>(<parameter>start</parameter>, <parameter>stop</parameter>)</literal></entry>
8231+
<entry><type>int</type> or <type>bigint</type></entry>
8232+
<entry><type>setof int</type> or <type>setof bigint</type> (same as argument type)</entry>
8233+
<entry>
8234+
Generate a series of values, from <parameter>start</parameter> to <parameter>stop</parameter>
8235+
with a step size of one.
8236+
</entry>
8237+
</row>
8238+
8239+
<row>
8240+
<entry><literal><function>generate_series</function>(<parameter>start</parameter>, <parameter>stop</parameter>, <parameter>step</parameter>)</literal></entry>
8241+
<entry><type>int</type> or <type>bigint</type></entry>
8242+
<entry><type>setof int</type> or <type>setof bigint</type> (same as argument type)</entry>
8243+
<entry>
8244+
Generate a series of values, from <parameter>start</parameter> to <parameter>stop</parameter>
8245+
with a step size of <parameter>step</parameter>.
8246+
</entry>
8247+
</row>
8248+
8249+
</tbody>
8250+
</tgroup>
8251+
</table>
8252+
8253+
<para>
8254+
When <parameter>step</parameter> is positive, zero rows are returned if
8255+
<parameter>start</parameter> is greater than <parameter>stop</parameter>.
8256+
Conversely, when <parameter>step</parameter> is negative, zero rows are
8257+
returned if <parameter>start</parameter> is less than <parameter>stop</parameter>.
8258+
Zero rows are also returned for <literal>NULL</literal> inputs. It is an error
8259+
for <parameter>step</parameter> to be zero. Some examples follow:
8260+
<programlisting>
8261+
select * from generate_series(2,4);
8262+
generate_series
8263+
-----------------
8264+
2
8265+
3
8266+
4
8267+
(3 rows)
8268+
8269+
select * from generate_series(5,1,-2);
8270+
generate_series
8271+
-----------------
8272+
5
8273+
3
8274+
1
8275+
(3 rows)
8276+
8277+
select * from generate_series(4,3);
8278+
generate_series
8279+
-----------------
8280+
(0 rows)
8281+
8282+
select current_date + s.a as dates from generate_series(0,14,7) as s(a);
8283+
dates
8284+
------------
8285+
2004-02-05
8286+
2004-02-12
8287+
2004-02-19
8288+
(3 rows)
8289+
</programlisting>
8290+
</para>
8291+
</sect1>
82028292
</chapter>
82038293

82048294
<!-- Keep this comment at the end of the file

0 commit comments

Comments
 (0)