diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index 16a0074010508d793cd38ca8eb111dc7fbb97cf3..8425bb4fa6ef519794521c32d42cdad0348be846 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -1,5 +1,5 @@ <chapter id="datatype"> - <title>Data Types</title> + <title id="datatype-title">Data Types</title> <abstract> <para> diff --git a/doc/src/sgml/docguide.sgml b/doc/src/sgml/docguide.sgml index d16e3c1d1af8aabe33a5791895c7cb2fdf9e0880..af4e7b04641ab03652097b3c395942db051063e4 100644 --- a/doc/src/sgml/docguide.sgml +++ b/doc/src/sgml/docguide.sgml @@ -1,9 +1,12 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/docguide.sgml,v 1.15 1999/05/27 15:49:07 thomas Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/docguide.sgml,v 1.16 1999/06/14 07:36:11 thomas Exp $ Documentation Guide Thomas Lockhart $Log: docguide.sgml,v $ +Revision 1.16 1999/06/14 07:36:11 thomas +Minor updates for release. + Revision 1.15 1999/05/27 15:49:07 thomas Markup fixes. Update for v6.5 release. @@ -175,7 +178,7 @@ Include working list of all documentation sources, with current status James Clark's <ulink url="http://www.jclark.com/jade/"> <productname>jade</productname></ulink> and Norm Walsh's - <ulink url="http://www.berkshire.net/~norm/docbook/dsssl">Modular DocBook Stylesheets</ulink>. + <ulink url="http://www.nwalsh.com/docbook/dsssl/">Modular DocBook Stylesheets</ulink>. </para> <para> diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 0c27254c2208fc40ea0ada115484c1b22ff572cf..492859f56b6243af532fb328aa9b85403f53cbfa 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,17 +1,18 @@ - <Chapter Id="functions"> - <Title id="functions-title">Functions</Title> + <chapter id="functions"> + <title id="functions-title">Functions</title> - <Abstract> - <Para> - Describes the built-in functions available in <ProductName>Postgres</ProductName>. - </Para> - </Abstract> + <abstract> + <para> + Describes the built-in functions available + in <productname>Postgres</productname>. + </para> + </abstract> - <Para> + <para> Many data types have functions available for conversion to other related types. In addition, there are some type-specific functions. Some functions are also available through operators and may be documented as operators only. - </Para> + </para> <sect1> <title id="sql-funcs">SQL Functions</title> @@ -24,37 +25,37 @@ </para> <para> - <TABLE TOCENTRY="1"> - <TITLE>SQL Functions</TITLE> - <TGROUP COLS="4"> - <THEAD> - <ROW> - <ENTRY>Function</ENTRY> - <ENTRY>Returns</ENTRY> - <ENTRY>Description</ENTRY> - <ENTRY>Example</ENTRY> - </ROW> - </THEAD> - <TBODY> - <ROW> - <ENTRY> COALESCE(<replaceable class="parameter">list</replaceable>) </ENTRY> - <ENTRY> non-NULL </ENTRY> - <ENTRY> return first non-NULL value in list </ENTRY> - <ENTRY> COALESCE(<replaceable class="parameter">c1</replaceable>, <replaceable class="parameter">c2</replaceable> + 5, 0) </ENTRY> - </ROW> - <ROW> - <ENTRY> IFNULL(<replaceable - class="parameter">input</replaceable>,<replaceable> class="parameter">non-NULL substitute</replaceable>) </ENTRY> - <ENTRY> non-NULL </ENTRY> - <ENTRY> return second argument if first is NULL </ENTRY> - <ENTRY> IFNULL(<replaceable class="parameter">c1</replaceable>, 'N/A')</ENTRY> - </ROW> - <ROW> - <ENTRY> CASE(WHEN <replaceable class="parameter">expr</replaceable> THEN <replaceable class="parameter">expr</replaceable> [...] ELSE <replaceable class="parameter">expr</replaceable> ) </ENTRY> - <ENTRY> <replaceable class="parameter">expr</replaceable> </ENTRY> - <ENTRY> return expression for first true clause </ENTRY> - <ENTRY> CASE(WHEN <replaceable class="parameter">c1</replaceable> = 1 THEN 'match' ELSE 'no match') </ENTRY> - </ROW> + <table tocentry="1"> + <title>SQL Functions</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Function</entry> + <entry>Returns</entry> + <entry>Description</entry> + <entry>Example</entry> + </row> + </thead> + <tbody> + <row> + <entry> COALESCE(<replaceable class="parameter">list</replaceable>) </entry> + <entry> non-NULL </entry> + <entry> return first non-NULL value in list </entry> + <entry> COALESCE(<replaceable class="parameter">r"</replaceable>le>, <replaceable + class="parameter">c2</replaceable> + 5, 0) </entry> + </row> + <row> + <entry> IFNULL(<replaceable class="parameter">input</replaceable>,<replaceable class="parameter">non-NULL substitute</replaceable>) </entry> + <entry> non-NULL </entry> + <entry> return second argument if first is NULL </entry> + <entry> IFNULL(<replaceable class="parameter">c1</replaceable>, 'N/A')</entry> + </row> + <row> + <entry> CASE WHEN <replaceable class="parameter">expr</replaceable> THEN <replaceable class="parameter">expr</replaceable> [...] ELSE <replaceable class="parameter">expr</replaceable> END </entry> + <entry> <replaceable class="parameter">expr</replaceable> </entry> + <entry> return expression for first true clause </entry> + <entry> CASE WHEN <replaceable class="parameter">c1</replaceable> = 1 THEN 'match' ELSE 'no match' END </entry> + </row> </tbody> </tgroup> </table> @@ -64,237 +65,237 @@ <sect1> <title id="math-funcs">Mathematical Functions</title> - <Para> - <TABLE TOCENTRY="1"> - <TITLE>Mathematical Functions</TITLE> - <TGROUP COLS="4"> - <THEAD> - <ROW> - <ENTRY>Function</ENTRY> - <ENTRY>Returns</ENTRY> - <ENTRY>Description</ENTRY> - <ENTRY>Example</ENTRY> - </ROW> - </THEAD> - <TBODY> - <ROW> - <ENTRY> dexp(float8) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> raise e to the specified exponent </ENTRY> - <ENTRY> dexp(2.0) </ENTRY> - </ROW> - <ROW> - <ENTRY> dpow(float8,float8) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> raise a number to the specified exponent </ENTRY> - <ENTRY> dpow(2.0, 16.0) </ENTRY> - </ROW> - <ROW> - <ENTRY> float(int) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> convert integer to floating point </ENTRY> - <ENTRY> float(2) </ENTRY> - </ROW> - <ROW> - <ENTRY> float4(int) </ENTRY> - <ENTRY> float4 </ENTRY> - <ENTRY> convert integer to floating point </ENTRY> - <ENTRY> float4(2) </ENTRY> - </ROW> - <ROW> - <ENTRY> integer(float) </ENTRY> - <ENTRY> int </ENTRY> - <ENTRY> convert floating point to integer </ENTRY> - <ENTRY> integer(2.0) </ENTRY> - </ROW> - </TBODY> - </TGROUP> - </TABLE> - </Para> + <para> + <table tocentry="1"> + <title>Mathematical Functions</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Function</entry> + <entry>Returns</entry> + <entry>Description</entry> + <entry>Example</entry> + </row> + </thead> + <tbody> + <row> + <entry> dexp(float8) </entry> + <entry> float8 </entry> + <entry> raise e to the specified exponent </entry> + <entry> dexp(2.0) </entry> + </row> + <row> + <entry> dpow(float8,float8) </entry> + <entry> float8 </entry> + <entry> raise a number to the specified exponent </entry> + <entry> dpow(2.0, 16.0) </entry> + </row> + <row> + <entry> float(int) </entry> + <entry> float8 </entry> + <entry> convert integer to floating point </entry> + <entry> float(2) </entry> + </row> + <row> + <entry> float4(int) </entry> + <entry> float4 </entry> + <entry> convert integer to floating point </entry> + <entry> float4(2) </entry> + </row> + <row> + <entry> integer(float) </entry> + <entry> int </entry> + <entry> convert floating point to integer </entry> + <entry> integer(2.0) </entry> + </row> + </tbody> + </tgroup> + </table> + </para> </sect1> <sect1> <title>String Functions</title> - <Para> + <para> SQL92 defines string functions with specific syntax. Some of these - are implemented using other <ProductName>Postgres</ProductName> functions. + are implemented using other <productname>Postgres</productname> functions. The supported string types for <acronym>SQL92</acronym> are <type>char</type>, <type>varchar</type>, and <type>text</type>. - </Para> + </para> - <Para> - <TABLE TOCENTRY="1"> - <TITLE><Acronym>SQL92</Acronym> String Functions</TITLE> - <TGROUP COLS="4"> - <THEAD> - <ROW> - <ENTRY>Function</ENTRY> - <ENTRY>Returns</ENTRY> - <ENTRY>Description</ENTRY> - <ENTRY>Example</ENTRY> - </ROW> - </THEAD> - <TBODY> - <ROW> - <ENTRY> char_length(string) </ENTRY> - <ENTRY> int4 </ENTRY> - <ENTRY> length of string </ENTRY> - <ENTRY> char_length('jose') </ENTRY> - </ROW> - <ROW> - <ENTRY> character_length(string) </ENTRY> - <ENTRY> int4 </ENTRY> - <ENTRY> length of string </ENTRY> - <ENTRY> char_length('jose') </ENTRY> - </ROW> - <ROW> - <ENTRY> lower(string) </ENTRY> - <ENTRY> string </ENTRY> - <ENTRY> convert string to lower case </ENTRY> - <ENTRY> lower('TOM') </ENTRY> - </ROW> - <ROW> - <ENTRY> octet_length(string) </ENTRY> - <ENTRY> int4 </ENTRY> - <ENTRY> storage length of string </ENTRY> - <ENTRY> octet_length('jose') </ENTRY> - </ROW> - <ROW> - <ENTRY> position(string in string) </ENTRY> - <ENTRY> int4 </ENTRY> - <ENTRY> location of specified substring </ENTRY> - <ENTRY> position('o' in 'Tom') </ENTRY> - </ROW> - <ROW> - <ENTRY> substring(string [from int] [for int]) </ENTRY> - <ENTRY> string </ENTRY> - <ENTRY> extract specified substring </ENTRY> - <ENTRY> substring('Tom' from 2 for 2) </ENTRY> - </ROW> - <ROW> - <ENTRY> trim([leading|trailing|both] [string] from string) </ENTRY> - <ENTRY> string </ENTRY> - <ENTRY> trim characters from string </ENTRY> - <ENTRY> trim(both 'x' from 'xTomx') </ENTRY> - </ROW> - <ROW> - <ENTRY> upper(text) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> convert text to upper case </ENTRY> - <ENTRY> upper('tom') </ENTRY> - </ROW> - </TBODY> - </TGROUP> - </TABLE> - </Para> + <para> + <table tocentry="1"> + <title><acronym>SQL92</acronym> String Functions</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Function</entry> + <entry>Returns</entry> + <entry>Description</entry> + <entry>Example</entry> + </row> + </thead> + <tbody> + <row> + <entry> char_length(string) </entry> + <entry> int4 </entry> + <entry> length of string </entry> + <entry> char_length('jose') </entry> + </row> + <row> + <entry> character_length(string) </entry> + <entry> int4 </entry> + <entry> length of string </entry> + <entry> char_length('jose') </entry> + </row> + <row> + <entry> lower(string) </entry> + <entry> string </entry> + <entry> convert string to lower case </entry> + <entry> lower('TOM') </entry> + </row> + <row> + <entry> octet_length(string) </entry> + <entry> int4 </entry> + <entry> storage length of string </entry> + <entry> octet_length('jose') </entry> + </row> + <row> + <entry> position(string in string) </entry> + <entry> int4 </entry> + <entry> location of specified substring </entry> + <entry> position('o' in 'Tom') </entry> + </row> + <row> + <entry> substring(string [from int] [for int]) </entry> + <entry> string </entry> + <entry> extract specified substring </entry> + <entry> substring('Tom' from 2 for 2) </entry> + </row> + <row> + <entry> trim([leading|trailing|both] [string] from string) </entry> + <entry> string </entry> + <entry> trim characters from string </entry> + <entry> trim(both 'x' from 'xTomx') </entry> + </row> + <row> + <entry> upper(text) </entry> + <entry> text </entry> + <entry> convert text to upper case </entry> + <entry> upper('tom') </entry> + </row> + </tbody> + </tgroup> + </table> + </para> - <Para> + <para> Many additional string functions are available for text, varchar(), and char() types. Some are used internally to implement the SQL92 string functions listed above. - </Para> + </para> - <Para> - <TABLE TOCENTRY="1"> - <TITLE>String Functions</TITLE> - <TGROUP COLS="4"> - <THEAD> - <ROW> - <ENTRY>Function</ENTRY> - <ENTRY>Returns</ENTRY> - <ENTRY>Description</ENTRY> - <ENTRY>Example</ENTRY> - </ROW> - </THEAD> - <TBODY> - <ROW> - <ENTRY> char(text) </ENTRY> - <ENTRY> char </ENTRY> - <ENTRY> convert text to char type </ENTRY> - <ENTRY> char('text string') </ENTRY> - </ROW> - <ROW> - <ENTRY> char(varchar) </ENTRY> - <ENTRY> char </ENTRY> - <ENTRY> convert varchar to char type </ENTRY> - <ENTRY> char(varchar 'varchar string') </ENTRY> - </ROW> - <ROW> - <ENTRY> initcap(text) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> first letter of each word to upper case </ENTRY> - <ENTRY> initcap('thomas') </ENTRY> - </ROW> - <ROW> - <ENTRY> lpad(text,int,text) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> left pad string to specified length </ENTRY> - <ENTRY> lpad('hi',4,'??') </ENTRY> - </ROW> - <ROW> - <ENTRY> ltrim(text,text) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> left trim characters from text </ENTRY> - <ENTRY> ltrim('xxxxtrim','x') </ENTRY> - </ROW> - <ROW> - <ENTRY> textpos(text,text) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> locate specified substring </ENTRY> - <ENTRY> position('high','ig') </ENTRY> - </ROW> - <ROW> - <ENTRY> rpad(text,int,text) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> right pad string to specified length </ENTRY> - <ENTRY> rpad('hi',4,'x') </ENTRY> - </ROW> - <ROW> - <ENTRY> rtrim(text,text) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> right trim characters from text </ENTRY> - <ENTRY> rtrim('trimxxxx','x') </ENTRY> - </ROW> - <ROW> - <ENTRY> substr(text,int[,int]) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> extract specified substring </ENTRY> - <ENTRY> substr('hi there',3,5) </ENTRY> - </ROW> - <ROW> - <ENTRY> text(char) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> convert char to text type </ENTRY> - <ENTRY> text('char string') </ENTRY> - </ROW> - <ROW> - <ENTRY> text(varchar) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> convert varchar to text type </ENTRY> - <ENTRY> text(varchar 'varchar string') </ENTRY> - </ROW> - <ROW> - <ENTRY> translate(text,from,to) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> convert character in string </ENTRY> - <ENTRY> translate('12345', '1', 'a') </ENTRY> - </ROW> - <ROW> - <ENTRY> varchar(char) </ENTRY> - <ENTRY> varchar </ENTRY> - <ENTRY> convert char to varchar type </ENTRY> - <ENTRY> varchar('char string') </ENTRY> - </ROW> - <ROW> - <ENTRY> varchar(text) </ENTRY> - <ENTRY> varchar </ENTRY> - <ENTRY> convert text to varchar type </ENTRY> - <ENTRY> varchar('text string') </ENTRY> - </ROW> - </TBODY> - </TGROUP> - </TABLE> - </Para> + <para> + <table tocentry="1"> + <title>String Functions</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Function</entry> + <entry>Returns</entry> + <entry>Description</entry> + <entry>Example</entry> + </row> + </thead> + <tbody> + <row> + <entry> char(text) </entry> + <entry> char </entry> + <entry> convert text to char type </entry> + <entry> char('text string') </entry> + </row> + <row> + <entry> char(varchar) </entry> + <entry> char </entry> + <entry> convert varchar to char type </entry> + <entry> char(varchar 'varchar string') </entry> + </row> + <row> + <entry> initcap(text) </entry> + <entry> text </entry> + <entry> first letter of each word to upper case </entry> + <entry> initcap('thomas') </entry> + </row> + <row> + <entry> lpad(text,int,text) </entry> + <entry> text </entry> + <entry> left pad string to specified length </entry> + <entry> lpad('hi',4,'??') </entry> + </row> + <row> + <entry> ltrim(text,text) </entry> + <entry> text </entry> + <entry> left trim characters from text </entry> + <entry> ltrim('xxxxtrim','x') </entry> + </row> + <row> + <entry> textpos(text,text) </entry> + <entry> text </entry> + <entry> locate specified substring </entry> + <entry> position('high','ig') </entry> + </row> + <row> + <entry> rpad(text,int,text) </entry> + <entry> text </entry> + <entry> right pad string to specified length </entry> + <entry> rpad('hi',4,'x') </entry> + </row> + <row> + <entry> rtrim(text,text) </entry> + <entry> text </entry> + <entry> right trim characters from text </entry> + <entry> rtrim('trimxxxx','x') </entry> + </row> + <row> + <entry> substr(text,int[,int]) </entry> + <entry> text </entry> + <entry> extract specified substring </entry> + <entry> substr('hi there',3,5) </entry> + </row> + <row> + <entry> text(char) </entry> + <entry> text </entry> + <entry> convert char to text type </entry> + <entry> text('char string') </entry> + </row> + <row> + <entry> text(varchar) </entry> + <entry> text </entry> + <entry> convert varchar to text type </entry> + <entry> text(varchar 'varchar string') </entry> + </row> + <row> + <entry> translate(text,from,to) </entry> + <entry> text </entry> + <entry> convert character in string </entry> + <entry> translate('12345', '1', 'a') </entry> + </row> + <row> + <entry> varchar(char) </entry> + <entry> varchar </entry> + <entry> convert char to varchar type </entry> + <entry> varchar('char string') </entry> + </row> + <row> + <entry> varchar(text) </entry> + <entry> varchar </entry> + <entry> convert text to varchar type </entry> + <entry> varchar('text string') </entry> + </row> + </tbody> + </tgroup> + </table> + </para> <para> Most functions explicitly defined for text will work for char() and varchar() arguments. @@ -309,113 +310,114 @@ for manipulating various date/time types. </para> - <Para> - <TABLE TOCENTRY="1"> - <TITLE>Date/Time Functions</TITLE> - <TGROUP COLS="4"> - <THEAD> - <ROW> - <ENTRY>Function</ENTRY> - <ENTRY>Returns</ENTRY> - <ENTRY>Description</ENTRY> - <ENTRY>Example</ENTRY> - </ROW> - </THEAD> - <TBODY> - <ROW> - <ENTRY> abstime(datetime) </ENTRY> - <ENTRY> abstime </ENTRY> - <ENTRY> convert to abstime </ENTRY> - <ENTRY> abstime('now'::datetime) </ENTRY> - </ROW> - <ROW> - <ENTRY> age(datetime,datetime) </ENTRY> - <ENTRY> timespan </ENTRY> - <ENTRY> span preserving months and years </ENTRY> - <ENTRY> age('now','1957-06-13'::datetime) </ENTRY> - </ROW> - <ROW> - <ENTRY> datetime(abstime) </ENTRY> - <ENTRY> datetime </ENTRY> - <ENTRY> convert to datetime </ENTRY> - <ENTRY> datetime('now'::abstime) </ENTRY> - </ROW> - <ROW> - <ENTRY> datetime(date) </ENTRY> - <ENTRY> datetime </ENTRY> - <ENTRY> convert to datetime </ENTRY> - <ENTRY> datetime('today'::date) </ENTRY> - </ROW> - <ROW> - <ENTRY> datetime(date,time) </ENTRY> - <ENTRY> datetime </ENTRY> - <ENTRY> convert to datetime </ENTRY> - <ENTRY> datetime('1998-02-24'::datetime, '23:07'::time); </ENTRY> - </ROW> - <ROW> - <ENTRY> date_part(text,datetime) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> specified portion of date field </ENTRY> - <ENTRY> date_part('dow','now'::datetime) </ENTRY> - </ROW> - <ROW> - <ENTRY> date_part(text,timespan) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> specified portion of time field </ENTRY> - <ENTRY> date_part('hour','4 hrs 3 mins'::timespan) </ENTRY> - </ROW> - <ROW> - <ENTRY> date_trunc(text,datetime) </ENTRY> - <ENTRY> datetime </ENTRY> - <ENTRY> truncate date at specified units </ENTRY> - <ENTRY> date_trunc('month','now'::abstime) </ENTRY> - </ROW> - <ROW> - <ENTRY> isfinite(abstime) </ENTRY> - <ENTRY> bool </ENTRY> - <ENTRY> TRUE if this is a finite time </ENTRY> - <ENTRY> isfinite('now'::abstime) </ENTRY> - </ROW> - <ROW> - <ENTRY> isfinite(datetime) </ENTRY> - <ENTRY> bool </ENTRY> - <ENTRY> TRUE if this is a finite time </ENTRY> - <ENTRY> isfinite('now'::datetime) </ENTRY> - </ROW> - <ROW> - <ENTRY> isfinite(timespan) </ENTRY> - <ENTRY> bool </ENTRY> - <ENTRY> TRUE if this is a finite time </ENTRY> - <ENTRY> isfinite('4 hrs'::timespan) </ENTRY> - </ROW> - <ROW> - <ENTRY> reltime(timespan) </ENTRY> - <ENTRY> reltime </ENTRY> - <ENTRY> convert to reltime </ENTRY> - <ENTRY> reltime('4 hrs'::timespan) </ENTRY> - </ROW> - <ROW> - <ENTRY> timespan(reltime) </ENTRY> - <ENTRY> timespan </ENTRY> - <ENTRY> convert to timespan </ENTRY> - <ENTRY> timespan('4 hours'::reltime) </ENTRY> - </ROW> - </TBODY> - </TGROUP> - </TABLE> - </Para> + <para> + <table tocentry="1"> + <title>Date/Time Functions</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Function</entry> + <entry>Returns</entry> + <entry>Description</entry> + <entry>Example</entry> + </row> + </thead> + <tbody> + <row> + <entry> abstime(datetime) </entry> + <entry> abstime </entry> + <entry> convert to abstime </entry> + <entry> abstime('now'::datetime) </entry> + </row> + <row> + <entry> age(datetime,datetime) </entry> + <entry> timespan </entry> + <entry> preserve months and years </entry> + <entry> age('now','1957-06-13'::datetime) </entry> + </row> + <row> + <entry> datetime(abstime) </entry> + <entry> datetime </entry> + <entry> convert to datetime </entry> + <entry> datetime('now'::abstime) </entry> + </row> + <row> + <entry> datetime(date) </entry> + <entry> datetime </entry> + <entry> convert to datetime </entry> + <entry> datetime('today'::date) </entry> + </row> + <row> + <entry> datetime(date,time) </entry> + <entry> datetime </entry> + <entry> convert to datetime </entry> + <entry> datetime('1998-02-24'::datetime, '23:07'::time); </entry> + </row> + <row> + <entry> date_part(text,datetime) </entry> + <entry> float8 </entry> + <entry> portion of date </entry> + <entry> date_part('dow','now'::datetime) </entry> + </row> + <row> + <entry> date_part(text,timespan) </entry> + <entry> float8 </entry> + <entry> portion of time </entry> + <entry> date_part('hour','4 hrs 3 mins'::timespan) </entry> + </row> + <row> + <entry> date_trunc(text,datetime) </entry> + <entry> datetime </entry> + <entry> truncate date </entry> + <entry> date_trunc('month','now'::abstime) </entry> + </row> + <row> + <entry> isfinite(abstime) </entry> + <entry> bool </entry> + <entry> a finite time? </entry> + <entry> isfinite('now'::abstime) </entry> + </row> + <row> + <entry> isfinite(datetime) </entry> + <entry> bool </entry> + <entry> a finite time? </entry> + <entry> isfinite('now'::datetime) </entry> + </row> + <row> + <entry> isfinite(timespan) </entry> + <entry> bool </entry> + <entry> a finite time? </entry> + <entry> isfinite('4 hrs'::timespan) </entry> + </row> + <row> + <entry> reltime(timespan) </entry> + <entry> reltime </entry> + <entry> convert to reltime </entry> + <entry> reltime('4 hrs'::timespan) </entry> + </row> + <row> + <entry> timespan(reltime) </entry> + <entry> timespan </entry> + <entry> convert to timespan </entry> + <entry> timespan('4 hours'::reltime) </entry> + </row> + </tbody> + </tgroup> + </table> + </para> - <Para> + <para> For the - <Function>date_part</Function> and <Function>date_trunc</Function> + <function>date_part</function> and <function>date_trunc</function> functions, arguments can be `year', `month', `day', `hour', `minute', and `second', as well as the more specialized quantities `decade', `century', `millenium', `millisecond', and `microsecond'. - <Function>date_part</Function> allows `dow' - to return day of week and `epoch' to return seconds since 1970 (for <Type>datetime</Type>) - or 'epoch' to return total elapsed seconds (for <Type>timespan</Type>). - </Para> + <function>date_part</function> allows `dow' + to return day of week and `epoch' to return seconds since 1970 + (for <type>datetime</type>) + or 'epoch' to return total elapsed seconds (for <type>timespan</type>). + </para> </sect1> <sect1> @@ -426,335 +428,335 @@ circle have a large set of native support functions. </para> - <Para> - <TABLE TOCENTRY="1"> - <TITLE>Geometric Functions</TITLE> - <TGROUP COLS="4"> - <THEAD> - <ROW> - <ENTRY>Function</ENTRY> - <ENTRY>Returns</ENTRY> - <ENTRY>Description</ENTRY> - <ENTRY>Example</ENTRY> - </ROW> - </THEAD> - <TBODY> - <ROW> - <ENTRY> area(box) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> area of box </ENTRY> - <ENTRY> area('((0,0),(1,1))'::box) </ENTRY> - </ROW> - <ROW> - <ENTRY> area(circle) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> area of circle </ENTRY> - <ENTRY> area('((0,0),2.0)'::circle) </ENTRY> - </ROW> - <ROW> - <ENTRY> box(box,box) </ENTRY> - <ENTRY> box </ENTRY> - <ENTRY> boxes to intersection box </ENTRY> - <ENTRY> box('((0,0),(1,1))','((0.5,0.5),(2,2))') </ENTRY> - </ROW> - <ROW> - <ENTRY> center(box) </ENTRY> - <ENTRY> point </ENTRY> - <ENTRY> center of object </ENTRY> - <ENTRY> center('((0,0),(1,2))'::box) </ENTRY> - </ROW> - <ROW> - <ENTRY> center(circle) </ENTRY> - <ENTRY> point </ENTRY> - <ENTRY> center of object </ENTRY> - <ENTRY> center('((0,0),2.0)'::circle) </ENTRY> - </ROW> - <ROW> - <ENTRY> diameter(circle) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> diameter of circle </ENTRY> - <ENTRY> diameter('((0,0),2.0)'::circle) </ENTRY> - </ROW> - <ROW> - <ENTRY> height(box) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> vertical size of box </ENTRY> - <ENTRY> height('((0,0),(1,1))'::box) </ENTRY> - </ROW> - <ROW> - <ENTRY> isclosed(path) </ENTRY> - <ENTRY> bool </ENTRY> - <ENTRY> TRUE if this is a closed path </ENTRY> - <ENTRY> isclosed('((0,0),(1,1),(2,0))'::path) </ENTRY> - </ROW> - <ROW> - <ENTRY> isopen(path) </ENTRY> - <ENTRY> bool </ENTRY> - <ENTRY> TRUE if this is an open path </ENTRY> - <ENTRY> isopen('[(0,0),(1,1),(2,0)]'::path) </ENTRY> - </ROW> - <ROW> - <ENTRY> length(lseg) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> length of line segment </ENTRY> - <ENTRY> length('((-1,0),(1,0))'::lseg) </ENTRY> - </ROW> - <ROW> - <ENTRY> length(path) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> length of path </ENTRY> - <ENTRY> length('((0,0),(1,1),(2,0))'::path) </ENTRY> - </ROW> - <ROW> - <ENTRY> pclose(path) </ENTRY> - <ENTRY> path </ENTRY> - <ENTRY> convert path to closed variant </ENTRY> - <ENTRY> popen('[(0,0),(1,1),(2,0)]'::path) </ENTRY> - </ROW> - <ROW> - <ENTRY> point(lseg,lseg) </ENTRY> - <ENTRY> point </ENTRY> - <ENTRY> convert to point (intersection) </ENTRY> - <ENTRY> point('((-1,0),(1,0))'::lseg,'((-2,-2),(2,2))'::lseg) </ENTRY> - </ROW> - <ROW> - <ENTRY> points(path) </ENTRY> - <ENTRY> int4 </ENTRY> - <ENTRY> number of points in path </ENTRY> - <ENTRY> points('[(0,0),(1,1),(2,0)]'::path) </ENTRY> - </ROW> - <ROW> - <ENTRY> popen(path) </ENTRY> - <ENTRY> path </ENTRY> - <ENTRY> convert path to open variant </ENTRY> - <ENTRY> popen('((0,0),(1,1),(2,0))'::path) </ENTRY> - </ROW> - <ROW> - <ENTRY> radius(circle) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> radius of circle </ENTRY> - <ENTRY> radius('((0,0),2.0)'::circle) </ENTRY> - </ROW> - <ROW> - <ENTRY> width(box) </ENTRY> - <ENTRY> float8 </ENTRY> - <ENTRY> horizontal size of box </ENTRY> - <ENTRY> width('((0,0),(1,1))'::box) </ENTRY> - </ROW> - </TBODY> - </TGROUP> - </TABLE> - </Para> + <para> + <table tocentry="1"> + <title>Geometric Functions</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Function</entry> + <entry>Returns</entry> + <entry>Description</entry> + <entry>Example</entry> + </row> + </thead> + <tbody> + <row> + <entry> area(box) </entry> + <entry> float8 </entry> + <entry> area of box </entry> + <entry> area('((0,0),(1,1))'::box) </entry> + </row> + <row> + <entry> area(circle) </entry> + <entry> float8 </entry> + <entry> area of circle </entry> + <entry> area('((0,0),2.0)'::circle) </entry> + </row> + <row> + <entry> box(box,box) </entry> + <entry> box </entry> + <entry> boxes to intersection box </entry> + <entry> box('((0,0),(1,1))','((0.5,0.5),(2,2))') </entry> + </row> + <row> + <entry> center(box) </entry> + <entry> point </entry> + <entry> center of object </entry> + <entry> center('((0,0),(1,2))'::box) </entry> + </row> + <row> + <entry> center(circle) </entry> + <entry> point </entry> + <entry> center of object </entry> + <entry> center('((0,0),2.0)'::circle) </entry> + </row> + <row> + <entry> diameter(circle) </entry> + <entry> float8 </entry> + <entry> diameter of circle </entry> + <entry> diameter('((0,0),2.0)'::circle) </entry> + </row> + <row> + <entry> height(box) </entry> + <entry> float8 </entry> + <entry> vertical size of box </entry> + <entry> height('((0,0),(1,1))'::box) </entry> + </row> + <row> + <entry> isclosed(path) </entry> + <entry> bool </entry> + <entry> a closed path? </entry> + <entry> isclosed('((0,0),(1,1),(2,0))'::path) </entry> + </row> + <row> + <entry> isopen(path) </entry> + <entry> bool </entry> + <entry> an open path? </entry> + <entry> isopen('[(0,0),(1,1),(2,0)]'::path) </entry> + </row> + <row> + <entry> length(lseg) </entry> + <entry> float8 </entry> + <entry> length of line segment </entry> + <entry> length('((-1,0),(1,0))'::lseg) </entry> + </row> + <row> + <entry> length(path) </entry> + <entry> float8 </entry> + <entry> length of path </entry> + <entry> length('((0,0),(1,1),(2,0))'::path) </entry> + </row> + <row> + <entry> pclose(path) </entry> + <entry> path </entry> + <entry> convert path to closed </entry> + <entry> popen('[(0,0),(1,1),(2,0)]'::path) </entry> + </row> + <row> + <entry> point(lseg,lseg) </entry> + <entry> point </entry> + <entry> intersection </entry> + <entry> point('((-1,0),(1,0))'::lseg,'((-2,-2),(2,2))'::lseg) </entry> + </row> + <row> + <entry> points(path) </entry> + <entry> int4 </entry> + <entry> number of points </entry> + <entry> points('[(0,0),(1,1),(2,0)]'::path) </entry> + </row> + <row> + <entry> popen(path) </entry> + <entry> path </entry> + <entry> convert path to open </entry> + <entry> popen('((0,0),(1,1),(2,0))'::path) </entry> + </row> + <row> + <entry> radius(circle) </entry> + <entry> float8 </entry> + <entry> radius of circle </entry> + <entry> radius('((0,0),2.0)'::circle) </entry> + </row> + <row> + <entry> width(box) </entry> + <entry> float8 </entry> + <entry> horizontal size </entry> + <entry> width('((0,0),(1,1))'::box) </entry> + </row> + </tbody> + </tgroup> + </table> + </para> - <Para> - <TABLE TOCENTRY="1"> - <TITLE>Geometric Type Conversion Functions</TITLE> - <TGROUP COLS="4"> - <THEAD> - <ROW> - <ENTRY>Function</ENTRY> - <ENTRY>Returns</ENTRY> - <ENTRY>Description</ENTRY> - <ENTRY>Example</ENTRY> - </ROW> - </THEAD> - <TBODY> - <ROW> - <ENTRY> box(circle) </ENTRY> - <ENTRY> box </ENTRY> - <ENTRY> convert circle to box </ENTRY> - <ENTRY> box('((0,0),2.0)'::circle) </ENTRY> - </ROW> - <ROW> - <ENTRY> box(point,point) </ENTRY> - <ENTRY> box </ENTRY> - <ENTRY> convert points to box </ENTRY> - <ENTRY> box('(0,0)'::point,'(1,1)'::point) </ENTRY> - </ROW> - <ROW> - <ENTRY> box(polygon) </ENTRY> - <ENTRY> box </ENTRY> - <ENTRY> convert polygon to box </ENTRY> - <ENTRY> box('((0,0),(1,1),(2,0))'::polygon) </ENTRY> - </ROW> - <ROW> - <ENTRY> circle(box) </ENTRY> - <ENTRY> circle </ENTRY> - <ENTRY> convert to circle </ENTRY> - <ENTRY> circle('((0,0),(1,1))'::box) </ENTRY> - </ROW> - <ROW> - <ENTRY> circle(point,float8) </ENTRY> - <ENTRY> circle </ENTRY> - <ENTRY> convert to circle </ENTRY> - <ENTRY> circle('(0,0)'::point,2.0) </ENTRY> - </ROW> - <ROW> - <ENTRY> lseg(box) </ENTRY> - <ENTRY> lseg </ENTRY> - <ENTRY> convert diagonal to lseg </ENTRY> - <ENTRY> lseg('((-1,0),(1,0))'::box) </ENTRY> - </ROW> - <ROW> - <ENTRY> lseg(point,point) </ENTRY> - <ENTRY> lseg </ENTRY> - <ENTRY> convert to lseg </ENTRY> - <ENTRY> lseg('(-1,0)'::point,'(1,0)'::point) </ENTRY> - </ROW> - <ROW> - <ENTRY> path(polygon) </ENTRY> - <ENTRY> point </ENTRY> - <ENTRY> convert to path </ENTRY> - <ENTRY> path('((0,0),(1,1),(2,0))'::polygon) </ENTRY> - </ROW> - <ROW> - <ENTRY> point(circle) </ENTRY> - <ENTRY> point </ENTRY> - <ENTRY> convert to point (center) </ENTRY> - <ENTRY> point('((0,0),2.0)'::circle) </ENTRY> - </ROW> - <ROW> - <ENTRY> point(lseg,lseg) </ENTRY> - <ENTRY> point </ENTRY> - <ENTRY> convert to point (intersection) </ENTRY> - <ENTRY> point('((-1,0),(1,0))'::lseg,'((-2,-2),(2,2))'::lseg) </ENTRY> - </ROW> - <ROW> - <ENTRY> point(polygon) </ENTRY> - <ENTRY> point </ENTRY> - <ENTRY> center of polygon </ENTRY> - <ENTRY> point('((0,0),(1,1),(2,0))'::polygon) </ENTRY> - </ROW> - <ROW> - <ENTRY> polygon(box) </ENTRY> - <ENTRY> polygon </ENTRY> - <ENTRY> convert to polygon with 12 points </ENTRY> - <ENTRY> polygon('((0,0),(1,1))'::box) </ENTRY> - </ROW> - <ROW> - <ENTRY> polygon(circle) </ENTRY> - <ENTRY> polygon </ENTRY> - <ENTRY> convert to polygon with 12 points </ENTRY> - <ENTRY> polygon('((0,0),2.0)'::circle) </ENTRY> - </ROW> - <ROW> - <ENTRY> polygon(npts,circle) </ENTRY> - <ENTRY> polygon </ENTRY> - <ENTRY> convert to polygon with npts points </ENTRY> - <ENTRY> polygon(12,'((0,0),2.0)'::circle) </ENTRY> - </ROW> - <ROW> - <ENTRY> polygon(path) </ENTRY> - <ENTRY> polygon </ENTRY> - <ENTRY> convert to polygon </ENTRY> - <ENTRY> polygon('((0,0),(1,1),(2,0))'::path) </ENTRY> - </ROW> - </TBODY> - </TGROUP> - </TABLE> - </Para> + <para> + <table tocentry="1"> + <title>Geometric Type Conversion Functions</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Function</entry> + <entry>Returns</entry> + <entry>Description</entry> + <entry>Example</entry> + </row> + </thead> + <tbody> + <row> + <entry> box(circle) </entry> + <entry> box </entry> + <entry> convert circle to box </entry> + <entry> box('((0,0),2.0)'::circle) </entry> + </row> + <row> + <entry> box(point,point) </entry> + <entry> box </entry> + <entry> convert points to box </entry> + <entry> box('(0,0)'::point,'(1,1)'::point) </entry> + </row> + <row> + <entry> box(polygon) </entry> + <entry> box </entry> + <entry> convert polygon to box </entry> + <entry> box('((0,0),(1,1),(2,0))'::polygon) </entry> + </row> + <row> + <entry> circle(box) </entry> + <entry> circle </entry> + <entry> convert to circle </entry> + <entry> circle('((0,0),(1,1))'::box) </entry> + </row> + <row> + <entry> circle(point,float8) </entry> + <entry> circle </entry> + <entry> convert to circle </entry> + <entry> circle('(0,0)'::point,2.0) </entry> + </row> + <row> + <entry> lseg(box) </entry> + <entry> lseg </entry> + <entry> convert diagonal to lseg </entry> + <entry> lseg('((-1,0),(1,0))'::box) </entry> + </row> + <row> + <entry> lseg(point,point) </entry> + <entry> lseg </entry> + <entry> convert to lseg </entry> + <entry> lseg('(-1,0)'::point,'(1,0)'::point) </entry> + </row> + <row> + <entry> path(polygon) </entry> + <entry> point </entry> + <entry> convert to path </entry> + <entry> path('((0,0),(1,1),(2,0))'::polygon) </entry> + </row> + <row> + <entry> point(circle) </entry> + <entry> point </entry> + <entry> convert to point (center) </entry> + <entry> point('((0,0),2.0)'::circle) </entry> + </row> + <row> + <entry> point(lseg,lseg) </entry> + <entry> point </entry> + <entry> convert to point (intersection) </entry> + <entry> point('((-1,0),(1,0))'::lseg, '((-2,-2),(2,2))'::lseg) </entry> + </row> + <row> + <entry> point(polygon) </entry> + <entry> point </entry> + <entry> center of polygon </entry> + <entry> point('((0,0),(1,1),(2,0))'::polygon) </entry> + </row> + <row> + <entry> polygon(box) </entry> + <entry> polygon </entry> + <entry> convert to polygon with 12 points </entry> + <entry> polygon('((0,0),(1,1))'::box) </entry> + </row> + <row> + <entry> polygon(circle) </entry> + <entry> polygon </entry> + <entry> convert to 12-point polygon </entry> + <entry> polygon('((0,0),2.0)'::circle) </entry> + </row> + <row> + <entry> polygon(<replaceable class="parameter">npts</replaceable>,circle) </entry> + <entry> polygon </entry> + <entry> convert to <replaceable class="parameter">npts</replaceable> polygon </entry> + <entry> polygon(12,'((0,0),2.0)'::circle) </entry> + </row> + <row> + <entry> polygon(path) </entry> + <entry> polygon </entry> + <entry> convert to polygon </entry> + <entry> polygon('((0,0),(1,1),(2,0))'::path) </entry> + </row> + </tbody> + </tgroup> + </table> + </para> - <Para> - <TABLE TOCENTRY="1"> - <TITLE>Geometric Upgrade Functions</TITLE> - <TGROUP COLS="4"> - <THEAD> - <ROW> - <ENTRY>Function</ENTRY> - <ENTRY>Returns</ENTRY> - <ENTRY>Description</ENTRY> - <ENTRY>Example</ENTRY> - </ROW> - </THEAD> - <TBODY> - <ROW> - <ENTRY> isoldpath(path) </ENTRY> - <ENTRY> path </ENTRY> - <ENTRY> test path for pre-v6.1 form </ENTRY> - <ENTRY> isoldpath('(1,3,0,0,1,1,2,0)'::path) </ENTRY> - </ROW> - <ROW> - <ENTRY> revertpoly(polygon) </ENTRY> - <ENTRY> polygon </ENTRY> - <ENTRY> convert pre-v6.1 polygon </ENTRY> - <ENTRY> revertpoly('((0,0),(1,1),(2,0))'::polygon) </ENTRY> - </ROW> - <ROW> - <ENTRY> upgradepath(path) </ENTRY> - <ENTRY> path </ENTRY> - <ENTRY> convert pre-v6.1 path </ENTRY> - <ENTRY> upgradepath('(1,3,0,0,1,1,2,0)'::path) </ENTRY> - </ROW> - <ROW> - <ENTRY> upgradepoly(polygon) </ENTRY> - <ENTRY> polygon </ENTRY> - <ENTRY> convert pre-v6.1 polygon </ENTRY> - <ENTRY> upgradepoly('(0,1,2,0,1,0)'::polygon) </ENTRY> - </ROW> - </TBODY> - </TGROUP> - </TABLE> - </Para> + <para> + <table tocentry="1"> + <title>Geometric Upgrade Functions</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Function</entry> + <entry>Returns</entry> + <entry>Description</entry> + <entry>Example</entry> + </row> + </thead> + <tbody> + <row> + <entry> isoldpath(path) </entry> + <entry> path </entry> + <entry> test path for pre-v6.1 form </entry> + <entry> isoldpath('(1,3,0,0,1,1,2,0)'::path) </entry> + </row> + <row> + <entry> revertpoly(polygon) </entry> + <entry> polygon </entry> + <entry> convert pre-v6.1 polygon </entry> + <entry> revertpoly('((0,0),(1,1),(2,0))'::polygon) </entry> + </row> + <row> + <entry> upgradepath(path) </entry> + <entry> path </entry> + <entry> convert pre-v6.1 path </entry> + <entry> upgradepath('(1,3,0,0,1,1,2,0)'::path) </entry> + </row> + <row> + <entry> upgradepoly(polygon) </entry> + <entry> polygon </entry> + <entry> convert pre-v6.1 polygon </entry> + <entry> upgradepoly('(0,1,2,0,1,0)'::polygon) </entry> + </row> + </tbody> + </tgroup> + </table> + </para> </sect1> <sect1> <title id="cidr-funcs">IP V4 Functions</title> - <Para> - <TABLE TOCENTRY="1"> - <TITLE><ProductName>Postgres</ProductName>IP V4 Functions</TITLE> - <TGROUP COLS="4"> - <THEAD> - <ROW> - <ENTRY>Function</ENTRY> - <ENTRY>Returns</ENTRY> - <ENTRY>Description</ENTRY> - <ENTRY>Example</ENTRY> - </ROW> - </THEAD> - <TBODY> - <ROW> - <ENTRY> broadcast(cidr) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> construct broadcast address as text </ENTRY> - <ENTRY> broadcast('192.168.1.5/24') ==> '192.168.1.255' </ENTRY> - </ROW> - <ROW> - <ENTRY> broadcast(inet) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> construct broadcast address as text </ENTRY> - <ENTRY> broadcast('192.168.1.5/24') ==> '192.168.1.255' </ENTRY> - </ROW> - <ROW> - <ENTRY> host(inet) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> extract host address as text </ENTRY> - <ENTRY> host('192.168.1.5/24') ==> '192.168.1.5' </ENTRY> - </ROW> - <ROW> - <ENTRY> masklen(cidr) </ENTRY> - <ENTRY> int4 </ENTRY> - <ENTRY> calculate netmask length </ENTRY> - <ENTRY> masklen('192.168.1.5/24') ==> 24</ENTRY> - </ROW> - <ROW> - <ENTRY> masklen(inet) </ENTRY> - <ENTRY> int4 </ENTRY> - <ENTRY> calculate netmask length </ENTRY> - <ENTRY> masklen('192.168.1.5/24') ==> 24 </ENTRY> - </ROW> - <ROW> - <ENTRY> netmask(inet) </ENTRY> - <ENTRY> text </ENTRY> - <ENTRY> construct netmask as text </ENTRY> - <ENTRY> netmask('192.168.1.5/24') ==> '255.255.255.0' </ENTRY> - </ROW> - </TBODY> - </TGROUP> - </TABLE> - </Para> + <para> + <table tocentry="1"> + <title><productname>Postgres</productname>IP V4 Functions</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Function</entry> + <entry>Returns</entry> + <entry>Description</entry> + <entry>Example</entry> + </row> + </thead> + <tbody> + <row> + <entry> broadcast(cidr) </entry> + <entry> text </entry> + <entry> construct broadcast address as text </entry> + <entry> broadcast('192.168.1.5/24') </entry> + </row> + <row> + <entry> broadcast(inet) </entry> + <entry> text </entry> + <entry> construct broadcast address as text </entry> + <entry> broadcast('192.168.1.5/24') </entry> + </row> + <row> + <entry> host(inet) </entry> + <entry> text </entry> + <entry> extract host address as text </entry> + <entry> host('192.168.1.5/24') </entry> + </row> + <row> + <entry> masklen(cidr) </entry> + <entry> int4 </entry> + <entry> calculate netmask length </entry> + <entry> masklen('192.168.1.5/24') </entry> + </row> + <row> + <entry> masklen(inet) </entry> + <entry> int4 </entry> + <entry> calculate netmask length </entry> + <entry> masklen('192.168.1.5/24') </entry> + </row> + <row> + <entry> netmask(inet) </entry> + <entry> text </entry> + <entry> construct netmask as text </entry> + <entry> netmask('192.168.1.5/24') </entry> + </row> + </tbody> + </tgroup> + </table> + </para> - </Sect1> + </sect1> </chapter> diff --git a/doc/src/sgml/lobj.sgml b/doc/src/sgml/lobj.sgml index c6c63d66bea0f9d0f591fea3eef17c9f14ded38e..10bdc90eca717b85e08f77a245aabac34dc2d551 100644 --- a/doc/src/sgml/lobj.sgml +++ b/doc/src/sgml/lobj.sgml @@ -1,68 +1,74 @@ -<Chapter Id="largeObjects"> -<Title>Large Objects</Title> - -<Para> - In <ProductName>Postgres</ProductName>, data values are stored in tuples and - individual tuples cannot span data pages. Since the size of - a data page is 8192 bytes, the upper limit on the size - of a data value is relatively low. To support the storage - of larger atomic values, <ProductName>Postgres</ProductName> provides a large - object interface. This interface provides file - oriented access to user data that has been declared to - be a large type. - This section describes the implementation and the - programmatic and query language interfaces to <ProductName>Postgres</ProductName> - large object data. -</Para> - -<Sect1> -<Title>Historical Note</Title> - -<Para> - Originally, <ProductName>Postgres 4.2</ProductName> supported three standard + <chapter id="largeObjects"> + <title id="largeObjects-title">Large Objects</title> + + <para> + In <productname>Postgres</productname>, + data values are stored in tuples and + individual tuples cannot span data pages. Since the size of + a data page is 8192 bytes, the upper limit on the size + of a data value is relatively low. To support the storage + of larger atomic values, + <productname>Postgres</productname> provides a large + object interface. This interface provides file + oriented access to user data that has been declared to + be a large type. + This section describes the implementation and the + programmatic and query language interfaces to + <productname>Postgres</productname> + large object data. + </para> + +<sect1> +<title>Historical Note</title> + +<para> + Originally, <productname>Postgres 4.2</productname> supported three standard implementations of large objects: as files external - to <ProductName>Postgres</ProductName>, as <Acronym>UNIX</Acronym> files managed by <ProductName>Postgres</ProductName>, and as data - stored within the <ProductName>Postgres</ProductName> database. It causes + to <productname>Postgres</productname>, as + <acronym>ym>U</acronym>ym> files managed by <productname>Postgres</productname>, and as data + stored within the <productname>Postgres</productname> database. It causes considerable confusion among users. As a result, we only - support large objects as data stored within the <ProductName>Postgres</ProductName> - database in <ProductName>PostgreSQL</ProductName>. Even though it is slower to + support large objects as data stored within the <productname>Postgres</productname> + database in <productname>PostgreSQL</productname>. Even though it is slower to access, it provides stricter data integrity. For historical reasons, this storage scheme is referred to as Inversion large objects. (We will use Inversion and large objects interchangeably to mean the same thing in this section.) -</Para> -</Sect1> +</para> +</sect1> -<Sect1> -<Title>Inversion Large Objects</Title> +<sect1> +<title>Inversion Large Objects</title> -<Para> +<para> The Inversion large object implementation breaks large objects up into "chunks" and stores the chunks in tuples in the database. A B-tree index guarantees fast searches for the correct chunk number when doing random access reads and writes. -</Para> -</Sect1> +</para> +</sect1> -<Sect1> -<Title>Large Object Interfaces</Title> +<sect1> +<title>Large Object Interfaces</title> -<Para> - The facilities <ProductName>Postgres</ProductName> provides to access large +<para> + The facilities <productname>Postgres</productname> provides to access large objects, both in the backend as part of user-defined functions or the front end as part of an application using the interface, are described below. (For users - familiar with <ProductName>Postgres 4.2</ProductName>, <ProductName>PostgreSQL</ProductName> has a new set of + familiar with <productname>Postgres 4.2</productname>, + <productname>PostgreSQL</productname> has a new set of functions providing a more coherent interface. The interface is the same for dynamically-loaded C functions as well as for XXX LOST TEXT? WHAT SHOULD GO HERE??. - The <ProductName>Postgres</ProductName> large object interface is modeled after - the <Acronym>UNIX</Acronym> file system interface, with analogues of - <Function>open(2)</Function>, <Function>read(2)</Function>, <Function>write(2)</Function>, - <Function>lseek(2)</Function>, etc. User + The <productname>Postgres</productname> large object interface is modeled after + the <acronym>UNIX</acronym> file system interface, with analogues of + <function>open(2)</function>, <function>read(2)</function>, +<function>write(2)</function>, + <function>lseek(2)</function>, etc. User functions call these routines to retrieve only the data of interest from a large object. For example, if a large object type called mugshot existed that stored @@ -72,81 +78,82 @@ the beard that appeared there, if any. The entire large object value need not be buffered, or even examined, by the beard function. - Large objects may be accessed from dynamically-loaded <Acronym>C</Acronym> + Large objects may be accessed from dynamically-loaded <acronym>C</acronym> functions or database client programs that link the - library. <ProductName>Postgres</ProductName> provides a set of routines that + library. <productname>Postgres</productname> provides a set of routines that support opening, reading, writing, closing, and seeking on large objects. -</Para> +</para> -<Sect2> -<Title>Creating a Large Object</Title> +<sect2> +<title>Creating a Large Object</title> -<Para> +<para> The routine -<ProgramListing> +<programlisting> Oid lo_creat(PGconn *conn, int mode) -</ProgramListing> +</programlisting> creates a new large object. The mode is a bitmask describing several different attributes of the new object. The symbolic constants listed here are defined in -<FileName> +<filename> PGROOT/src/backend/libpq/libpq-fs.h -</FileName> +</filename> The access type (read, write, or both) is controlled by - OR ing together the bits <Acronym>INV_READ</Acronym> and <Acronym>INV_WRITE</Acronym>. If + OR ing together the bits <acronym>INV_READ</acronym> and +<acronym>INV_WRITE</acronym>. If the large object should be archived -- that is, if historical versions of it should be moved periodically to - a special archive relation -- then the <Acronym>INV_ARCHIVE</Acronym> bit + a special archive relation -- then the <acronym>INV_ARCHIVE</acronym> bit should be set. The low-order sixteen bits of mask are the storage manager number on which the large object should reside. For sites other than Berkeley, these bits should always be zero. The commands below create an (Inversion) large object: -<ProgramListing> +<programlisting> inv_oid = lo_creat(INV_READ|INV_WRITE|INV_ARCHIVE); -</ProgramListing> -</Para> -</Sect2> +</programlisting> +</para> +</sect2> -<Sect2> -<Title>Importing a Large Object</Title> +<sect2> +<title>Importing a Large Object</title> -<Para> -To import a <Acronym>UNIX</Acronym> file as +<para> +To import a <acronym>UNIX</acronym> file as a large object, call -<ProgramListing> +<programlisting> Oid lo_import(PGconn *conn, text *filename) -</ProgramListing> - The filename argument specifies the <Acronym>UNIX</Acronym> pathname of +</programlisting> + The filename argument specifies the <acronym>UNIX</acronym> pathname of the file to be imported as a large object. -</Para> -</Sect2> +</para> +</sect2> -<Sect2> -<Title>Exporting a Large Object</Title> +<sect2> +<title>Exporting a Large Object</title> -<Para> +<para> To export a large object - into <Acronym>UNIX</Acronym> file, call -<ProgramListing> + into <acronym>UNIX</acronym> file, call +<programlisting> int lo_export(PGconn *conn, Oid lobjId, text *filename) -</ProgramListing> +</programlisting> The lobjId argument specifies the Oid of the large object to export and the filename argument specifies - the <Acronym>UNIX</Acronym> pathname of the file. -</Para> -</Sect2> + the <acronym>UNIX</acronym> pathname of the file. +</para> +</sect2> -<Sect2> -<Title>Opening an Existing Large Object</Title> +<sect2> +<title>Opening an Existing Large Object</title> -<Para> +<para> To open an existing large object, call -<ProgramListing> +<programlisting> int lo_open(PGconn *conn, Oid lobjId, int mode, ...) -</ProgramListing> +</programlisting> The lobjId argument specifies the Oid of the large object to open. The mode bits control whether the object is opened for reading INV_READ), writing or @@ -154,64 +161,65 @@ int lo_open(PGconn *conn, Oid lobjId, int mode, ...) A large object cannot be opened before it is created. lo_open returns a large object descriptor for later use in lo_read, lo_write, lo_lseek, lo_tell, and lo_close. -</Para> -</Sect2> +</para> +</sect2> -<Sect2> -<Title>Writing Data to a Large Object</Title> +<sect2> +<title>Writing Data to a Large Object</title> -<Para> +<para> The routine -<ProgramListing> +<programlisting> int lo_write(PGconn *conn, int fd, char *buf, int len) -</ProgramListing> +</programlisting> writes len bytes from buf to large object fd. The fd argument must have been returned by a previous lo_open. The number of bytes actually written is returned. In the event of an error, the return value is negative. -</Para> -</Sect2> +</para> +</sect2> -<Sect2> -<Title>Seeking on a Large Object</Title> +<sect2> +<title>Seeking on a Large Object</title> -<Para> +<para> To change the current read or write location on a large object, call -<ProgramListing> +<programlisting> int lo_lseek(PGconn *conn, int fd, int offset, int whence) -</ProgramListing> +</programlisting> This routine moves the current location pointer for the large object described by fd to the new location specified by offset. The valid values for .i whence are SEEK_SET SEEK_CUR and SEEK_END. -</Para> -</Sect2> +</para> +</sect2> -<Sect2> -<Title>Closing a Large Object Descriptor</Title> +<sect2> +<title>Closing a Large Object Descriptor</title> -<Para> +<para> A large object may be closed by calling -<ProgramListing> +<programlisting> int lo_close(PGconn *conn, int fd) -</ProgramListing> +</programlisting> where fd is a large object descriptor returned by - lo_open. On success, <Acronym>lo_close</Acronym> returns zero. On error, + lo_open. On success, <acronym>lo_close</acronym> returns zero. On error, the return value is negative. -</Para> +</para> </sect2> -</Sect1> +</sect1> -<Sect1> -<Title>Built in registered functions</Title> +<sect1> +<title>Built in registered functions</title> -<Para> - There are two built-in registered functions, <Acronym>lo_import</Acronym> - and <Acronym>lo_export</Acronym> which are convenient for use in <Acronym>SQL</Acronym> +<para> + There are two built-in registered functions, <acronym>lo_import</acronym> + and <acronym>lo_export</acronym> which are convenient for use + in <acronym>SQL</acronym> queries. Here is an example of their use -<ProgramListing> +<programlisting> CREATE TABLE image ( name text, raster oid @@ -222,33 +230,33 @@ INSERT INTO image (name, raster) SELECT lo_export(image.raster, "/tmp/motd") from image WHERE name = 'beautiful image'; -</ProgramListing> -</Para> -</Sect1> +</programlisting> +</para> +</sect1> -<Sect1> -<Title>Accessing Large Objects from LIBPQ</Title> +<sect1> +<title>Accessing Large Objects from LIBPQ</title> -<Para> +<para> Below is a sample program which shows how the large object interface in LIBPQ can be used. Parts of the program are commented out but are left in the source for the readers benefit. This program can be found in -<FileName> +<filename> ../src/test/examples -</FileName> +</filename> Frontend applications which use the large object interface in LIBPQ should include the header file libpq/libpq-fs.h and link with the libpq library. -</Para> -</Sect1> +</para> +</sect1> -<Sect1> -<Title>Sample Program</Title> +<sect1> +<title>Sample Program</title> -<Para> -<ProgramListing> +<para> +<programlisting> /*-------------------------------------------------------------- * * testlo.c-- @@ -479,8 +487,25 @@ SELECT lo_export(image.raster, "/tmp/motd") from image PQfinish(conn); exit(0); } -</ProgramListing> -</Para> - -</Sect1> -</Chapter> +</programlisting> +</para> + +</sect1> +</chapter> + +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:nil +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +sgml-parent-document:nil +sgml-default-dtd-file:"./reference.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:"/usr/lib/sgml/catalog" +sgml-local-ecat-files:nil +End: +--> diff --git a/doc/src/sgml/release.sgml b/doc/src/sgml/release.sgml index 1d3f2c661ea187c0724b839e6d27acdcb40e5862..c6ccb00402f2c32e0fa93784510f9e853e7e7329 100644 --- a/doc/src/sgml/release.sgml +++ b/doc/src/sgml/release.sgml @@ -23,7 +23,7 @@ </para> <para> - Here is a brief summary of some of the more noticable changes: + Here is a brief summary of the more notable changes: <variablelist> <varlistentry> @@ -188,16 +188,16 @@ <para> Because readers in 6.5 don't lock data, regardless of transaction isolation level, data read by one transaction can be overwritten by - another. In the other words, if a row is returned by + another. In other words, if a row is returned by <command>SELECT</command> it doesn't mean that this row really exists at the time it is returned (i.e. sometime after the statement or - transaction began) nor that the row is protected from deletion or - update by concurrent transactions before the current transaction does + transaction began) nor that the row is protected from being deleted or + updated by concurrent transactions before the current transaction does a commit or rollback. </para> <para> - To ensure the actual existance of a row and protect it against + To ensure the actual existence of a row and protect it against concurrent updates one must use <command>SELECT FOR UPDATE</command> or an appropriate <command>LOCK TABLE</command> statement. This should be taken into account when porting applications from previous releases of @@ -205,7 +205,8 @@ </para> <para> - Keep above in mind if you are using contrib/refint.* triggers for + Keep the above in mind if you are using + <filename>contrib/refint.*</filename> triggers for referential integrity. Additional technics are required now. One way is to use <command>LOCK parent_table IN SHARE ROW EXCLUSIVE MODE</command> command if a transaction is going to update/delete a primary key and @@ -2634,6 +2635,7 @@ Initial release. <programlisting> Time System 02:00 Dual Pentium Pro 180, 224MB, UW-SCSI, Linux 2.0.36, gcc 2.7.2.3 -O2 -m486 + 04:38 Sparc Ultra 1 143MHz, 64MB, Solaris 2.6 </programlisting> </para>