func.sgml
上传用户:blenddy
上传日期:2007-01-07
资源大小:6495k
文件大小:21k
源码类别:

数据库系统

开发平台:

Unix_Linux

  1.  <chapter id="functions">
  2.   <title id="functions-title">Functions</title>
  3.   <abstract>
  4.    <para>
  5.     Describes the built-in functions available
  6.     in <productname>Postgres</productname>.
  7.    </para>
  8.   </abstract>
  9.   <para>
  10.    Many data types have functions available for conversion to other related types.
  11.    In addition, there are some type-specific functions. Some functions are also
  12.    available through operators and may be documented as operators only.
  13.   </para>
  14.   <sect1>
  15.    <title id="sql-funcs">SQL Functions</title>
  16.    <para>
  17.     <quote><acronym>SQL</acronym> functions</quote> are constructs
  18.     defined by the <acronym>SQL92</acronym> standard which have
  19.     function-like syntax but which can not be implemented as simple
  20.     functions. 
  21.    </para>
  22.    <para>
  23.     <table tocentry="1">
  24.      <title>SQL Functions</title>
  25.      <tgroup cols="4">
  26.       <thead>
  27.        <row>
  28. <entry>Function</entry>
  29. <entry>Returns</entry>
  30. <entry>Description</entry>
  31. <entry>Example</entry>
  32.        </row>
  33.       </thead>
  34.       <tbody>
  35.        <row>
  36. <entry> COALESCE(<replaceable class="parameter">list</replaceable>) </entry>
  37. <entry> non-NULL </entry>
  38. <entry> return first non-NULL value in list </entry>
  39. <entry> COALESCE(<replaceable class="parameter">r"</replaceable>le>, <replaceable
  40.   class="parameter">c2</replaceable> + 5, 0) </entry>
  41.        </row>
  42.        <row>
  43. <entry> IFNULL(<replaceable class="parameter">input</replaceable>,<replaceable class="parameter">non-NULL substitute</replaceable>) </entry>
  44. <entry> non-NULL </entry>
  45. <entry> return second argument if first is NULL </entry>
  46. <entry> IFNULL(<replaceable class="parameter">c1</replaceable>, 'N/A')</entry>
  47.        </row>
  48.        <row>
  49. <entry> CASE WHEN <replaceable class="parameter">expr</replaceable> THEN <replaceable class="parameter">expr</replaceable> [...] ELSE <replaceable class="parameter">expr</replaceable> END </entry>
  50. <entry> <replaceable class="parameter">expr</replaceable> </entry>
  51. <entry> return expression for first true clause </entry>
  52. <entry> CASE WHEN <replaceable class="parameter">c1</replaceable> = 1 THEN 'match' ELSE 'no match' END </entry>
  53.        </row>
  54.       </tbody>
  55.      </tgroup>
  56.     </table>
  57.    </para>
  58.   </sect1>
  59.   <sect1>
  60.    <title id="math-funcs">Mathematical Functions</title>
  61.    <para>
  62.     <table tocentry="1">
  63.      <title>Mathematical Functions</title>
  64.      <tgroup cols="4">
  65.       <thead>
  66.        <row>
  67. <entry>Function</entry>
  68. <entry>Returns</entry>
  69. <entry>Description</entry>
  70. <entry>Example</entry>
  71.        </row>
  72.       </thead>
  73.       <tbody>
  74.        <row>
  75. <entry> dexp(float8) </entry>
  76. <entry> float8 </entry>
  77. <entry> raise e to the specified exponent </entry>
  78. <entry> dexp(2.0) </entry>
  79.        </row>
  80.        <row>
  81. <entry> dpow(float8,float8) </entry>
  82. <entry> float8 </entry>
  83. <entry> raise a number to the specified exponent </entry>
  84. <entry> dpow(2.0, 16.0) </entry>
  85.        </row>
  86.        <row>
  87. <entry> float(int) </entry>
  88. <entry> float8 </entry>
  89. <entry> convert integer to floating point </entry>
  90. <entry> float(2) </entry>
  91.        </row>
  92.        <row>
  93. <entry> float4(int) </entry>
  94. <entry> float4 </entry>
  95. <entry> convert integer to floating point </entry>
  96. <entry> float4(2) </entry>
  97.        </row>
  98.        <row>
  99. <entry> integer(float) </entry>
  100. <entry> int </entry>
  101. <entry> convert floating point to integer </entry>
  102. <entry> integer(2.0) </entry>
  103.        </row>
  104.       </tbody>
  105.      </tgroup>
  106.     </table>
  107.    </para>
  108.   </sect1>
  109.   <sect1>
  110.    <title>String Functions</title>
  111.    <para>
  112.     SQL92 defines string functions with specific syntax. Some of these
  113.     are implemented using other <productname>Postgres</productname> functions.
  114.     The supported string types for <acronym>SQL92</acronym> are
  115.     <type>char</type>, <type>varchar</type>, and <type>text</type>.
  116.    </para>
  117.    <para>
  118.     <table tocentry="1">
  119.      <title><acronym>SQL92</acronym> String Functions</title>
  120.      <tgroup cols="4">
  121.       <thead>
  122.        <row>
  123. <entry>Function</entry>
  124. <entry>Returns</entry>
  125. <entry>Description</entry>
  126. <entry>Example</entry>
  127.        </row>
  128.       </thead>
  129.       <tbody>
  130.        <row>
  131. <entry> char_length(string) </entry>
  132. <entry> int4 </entry>
  133. <entry> length of string </entry>
  134. <entry> char_length('jose') </entry>
  135.        </row>
  136.        <row>
  137. <entry> character_length(string) </entry>
  138. <entry> int4 </entry>
  139. <entry> length of string </entry>
  140. <entry> char_length('jose') </entry>
  141.        </row>
  142.        <row>
  143. <entry> lower(string) </entry>
  144. <entry> string </entry>
  145. <entry> convert string to lower case </entry>
  146. <entry> lower('TOM') </entry>
  147.        </row>
  148.        <row>
  149. <entry> octet_length(string) </entry>
  150. <entry> int4 </entry>
  151. <entry> storage length of string </entry>
  152. <entry> octet_length('jose') </entry>
  153.        </row>
  154.        <row>
  155. <entry> position(string in string) </entry>
  156. <entry> int4 </entry>
  157. <entry> location of specified substring </entry>
  158. <entry> position('o' in 'Tom') </entry>
  159.        </row>
  160.        <row>
  161. <entry> substring(string [from int] [for int]) </entry>
  162. <entry> string </entry>
  163. <entry> extract specified substring </entry>
  164. <entry> substring('Tom' from 2 for 2) </entry>
  165.        </row>
  166.        <row>
  167. <entry> trim([leading|trailing|both] [string] from string) </entry>
  168. <entry> string </entry>
  169. <entry> trim characters from string </entry>
  170. <entry> trim(both 'x' from 'xTomx') </entry>
  171.        </row>
  172.        <row>
  173. <entry> upper(text) </entry>
  174. <entry> text </entry>
  175. <entry> convert text to upper case </entry>
  176. <entry> upper('tom') </entry>
  177.        </row>
  178.       </tbody>
  179.      </tgroup>
  180.     </table>
  181.    </para>
  182.    <para>
  183.     Many additional string functions are available for text, varchar(), and char() types.
  184.     Some are used internally to implement the SQL92 string functions listed above.
  185.    </para>
  186.    <para>
  187.     <table tocentry="1">
  188.      <title>String Functions</title>
  189.      <tgroup cols="4">
  190.       <thead>
  191.        <row>
  192. <entry>Function</entry>
  193. <entry>Returns</entry>
  194. <entry>Description</entry>
  195. <entry>Example</entry>
  196.        </row>
  197.       </thead>
  198.       <tbody>
  199.        <row>
  200. <entry> char(text) </entry>
  201. <entry> char </entry>
  202. <entry> convert text to char type </entry>
  203. <entry> char('text string') </entry>
  204.        </row>
  205.        <row>
  206. <entry> char(varchar) </entry>
  207. <entry> char </entry>
  208. <entry> convert varchar to char type </entry>
  209. <entry> char(varchar 'varchar string') </entry>
  210.        </row>
  211.        <row>
  212. <entry> initcap(text) </entry>
  213. <entry> text </entry>
  214. <entry> first letter of each word to upper case </entry>
  215. <entry> initcap('thomas') </entry>
  216.        </row>
  217.        <row>
  218. <entry> lpad(text,int,text) </entry>
  219. <entry> text </entry>
  220. <entry> left pad string to specified length </entry>
  221. <entry> lpad('hi',4,'??') </entry>
  222.        </row>
  223.        <row>
  224. <entry> ltrim(text,text) </entry>
  225. <entry> text </entry>
  226. <entry> left trim characters from text </entry>
  227. <entry> ltrim('xxxxtrim','x') </entry>
  228.        </row>
  229.        <row>
  230. <entry> textpos(text,text) </entry>
  231. <entry> text </entry>
  232. <entry> locate specified substring </entry>
  233. <entry> position('high','ig') </entry>
  234.        </row>
  235.        <row>
  236. <entry> rpad(text,int,text) </entry>
  237. <entry> text </entry>
  238. <entry> right pad string to specified length </entry>
  239. <entry> rpad('hi',4,'x') </entry>
  240.        </row>
  241.        <row>
  242. <entry> rtrim(text,text) </entry>
  243. <entry> text </entry>
  244. <entry> right trim characters from text </entry>
  245. <entry> rtrim('trimxxxx','x') </entry>
  246.        </row>
  247.        <row>
  248. <entry> substr(text,int[,int]) </entry>
  249. <entry> text </entry>
  250. <entry> extract specified substring </entry>
  251. <entry> substr('hi there',3,5) </entry>
  252.        </row>
  253.        <row>
  254. <entry> text(char) </entry>
  255. <entry> text </entry>
  256. <entry> convert char to text type </entry>
  257. <entry> text('char string') </entry>
  258.        </row>
  259.        <row>
  260. <entry> text(varchar) </entry>
  261. <entry> text </entry>
  262. <entry> convert varchar to text type </entry>
  263. <entry> text(varchar 'varchar string') </entry>
  264.        </row>
  265.        <row>
  266. <entry> translate(text,from,to) </entry>
  267. <entry> text </entry>
  268. <entry> convert character in string </entry>
  269. <entry> translate('12345', '1', 'a') </entry>
  270.        </row>
  271.        <row>
  272. <entry> varchar(char) </entry>
  273. <entry> varchar </entry>
  274. <entry> convert char to varchar type </entry>
  275. <entry> varchar('char string') </entry>
  276.        </row>
  277.        <row>
  278. <entry> varchar(text) </entry>
  279. <entry> varchar </entry>
  280. <entry> convert text to varchar type </entry>
  281. <entry> varchar('text string') </entry>
  282.        </row>
  283.       </tbody>
  284.      </tgroup>
  285.     </table>
  286.    </para>
  287.    <para>
  288.     Most functions explicitly defined for text will work for char() and varchar() arguments.
  289.    </para>
  290.   </sect1>
  291.   <sect1>
  292.    <title>Date/Time Functions</title>
  293.    <para>
  294.     The date/time functions provide a powerful set of tools
  295.     for manipulating various date/time types.
  296.    </para>
  297.    <para>
  298.     <table tocentry="1">
  299.      <title>Date/Time Functions</title>
  300.      <tgroup cols="4">
  301.       <thead>
  302.        <row>
  303. <entry>Function</entry>
  304. <entry>Returns</entry>
  305. <entry>Description</entry>
  306. <entry>Example</entry>
  307.        </row>
  308.       </thead>
  309.       <tbody>
  310.        <row>
  311. <entry> abstime(datetime) </entry>
  312. <entry> abstime </entry>
  313. <entry> convert to abstime </entry>
  314. <entry> abstime('now'::datetime) </entry>
  315.        </row>
  316.        <row>
  317. <entry> age(datetime,datetime) </entry>
  318. <entry> timespan </entry>
  319. <entry> preserve months and years </entry>
  320. <entry> age('now','1957-06-13'::datetime) </entry>
  321.        </row>
  322.        <row>
  323. <entry> datetime(abstime) </entry>
  324. <entry> datetime </entry>
  325. <entry> convert to datetime </entry>
  326. <entry> datetime('now'::abstime) </entry>
  327.        </row>
  328.        <row>
  329. <entry> datetime(date) </entry>
  330. <entry> datetime </entry>
  331. <entry> convert to datetime </entry>
  332. <entry> datetime('today'::date) </entry>
  333.        </row>
  334.        <row>
  335. <entry> datetime(date,time) </entry>
  336. <entry> datetime </entry>
  337. <entry> convert to datetime </entry>
  338. <entry> datetime('1998-02-24'::datetime, '23:07'::time); </entry>
  339.   </row>
  340.        <row>
  341. <entry> date_part(text,datetime) </entry>
  342. <entry> float8 </entry>
  343. <entry> portion of date </entry>
  344. <entry> date_part('dow','now'::datetime) </entry>
  345.        </row>
  346.        <row>
  347. <entry> date_part(text,timespan) </entry>
  348. <entry> float8 </entry>
  349. <entry> portion of time </entry>
  350. <entry> date_part('hour','4 hrs 3 mins'::timespan) </entry>
  351.        </row>
  352.        <row>
  353. <entry> date_trunc(text,datetime) </entry>
  354. <entry> datetime </entry>
  355. <entry> truncate date </entry>
  356. <entry> date_trunc('month','now'::abstime) </entry>
  357.        </row>
  358.        <row>
  359. <entry> isfinite(abstime) </entry>
  360. <entry> bool </entry>
  361. <entry> a finite time? </entry>
  362. <entry> isfinite('now'::abstime) </entry>
  363.        </row>
  364.        <row>
  365. <entry> isfinite(datetime) </entry>
  366. <entry> bool </entry>
  367. <entry> a finite time? </entry>
  368. <entry> isfinite('now'::datetime) </entry>
  369.        </row>
  370.        <row>
  371. <entry> isfinite(timespan) </entry>
  372. <entry> bool </entry>
  373. <entry> a finite time? </entry>
  374. <entry> isfinite('4 hrs'::timespan) </entry>
  375.        </row>
  376.        <row>
  377. <entry> reltime(timespan) </entry>
  378. <entry> reltime </entry>
  379. <entry> convert to reltime </entry>
  380. <entry> reltime('4 hrs'::timespan) </entry>
  381.        </row>
  382.        <row>
  383. <entry> timespan(reltime) </entry>
  384. <entry> timespan </entry>
  385. <entry> convert to timespan </entry>
  386. <entry> timespan('4 hours'::reltime) </entry>
  387.        </row>
  388.       </tbody>
  389.      </tgroup>
  390.     </table>
  391.    </para>
  392.    <para>
  393.     For the
  394.     <function>date_part</function> and <function>date_trunc</function>
  395.     functions, arguments can be
  396.     `year', `month', `day', `hour', `minute', and `second',
  397.     as well as the more specialized quantities
  398.     `decade', `century', `millenium', `millisecond', and `microsecond'.
  399.     <function>date_part</function> allows `dow'
  400.     to return day of week and `epoch' to return seconds since 1970
  401.     (for <type>datetime</type>)
  402.     or 'epoch' to return total elapsed seconds (for <type>timespan</type>).
  403.    </para>
  404.   </sect1>
  405.   <sect1>
  406.    <title>Geometric Functions</title>
  407.    <para>
  408.     The geometric types point, box, lseg, line, path, polygon, and
  409.     circle have a large set of native support functions.
  410.    </para>
  411.    <para>
  412.     <table tocentry="1">
  413.      <title>Geometric Functions</title>
  414.      <tgroup cols="4">
  415.       <thead>
  416.        <row>
  417. <entry>Function</entry>
  418. <entry>Returns</entry>
  419. <entry>Description</entry>
  420. <entry>Example</entry>
  421.        </row>
  422.       </thead>
  423.       <tbody>
  424.        <row>
  425. <entry> area(box) </entry>
  426. <entry> float8 </entry>
  427. <entry> area of box </entry>
  428. <entry> area('((0,0),(1,1))'::box) </entry>
  429.        </row>
  430.        <row>
  431. <entry> area(circle) </entry>
  432. <entry> float8 </entry>
  433. <entry> area of circle </entry>
  434. <entry> area('((0,0),2.0)'::circle) </entry>
  435.        </row>
  436.        <row>
  437. <entry> box(box,box) </entry>
  438. <entry> box </entry>
  439. <entry> boxes to intersection box </entry>
  440. <entry> box('((0,0),(1,1))','((0.5,0.5),(2,2))') </entry>
  441.        </row>
  442.        <row>
  443. <entry> center(box) </entry>
  444. <entry> point </entry>
  445. <entry> center of object </entry>
  446. <entry> center('((0,0),(1,2))'::box) </entry>
  447.        </row>
  448.        <row>
  449. <entry> center(circle) </entry>
  450. <entry> point </entry>
  451. <entry> center of object </entry>
  452. <entry> center('((0,0),2.0)'::circle) </entry>
  453.        </row>
  454.        <row>
  455. <entry> diameter(circle) </entry>
  456. <entry> float8 </entry>
  457. <entry> diameter of circle </entry>
  458. <entry> diameter('((0,0),2.0)'::circle) </entry>
  459.        </row>
  460.        <row>
  461. <entry> height(box) </entry>
  462. <entry> float8 </entry>
  463. <entry> vertical size of box </entry>
  464. <entry> height('((0,0),(1,1))'::box) </entry>
  465.        </row>
  466.        <row>
  467. <entry> isclosed(path) </entry>
  468. <entry> bool </entry>
  469. <entry> a closed path? </entry>
  470. <entry> isclosed('((0,0),(1,1),(2,0))'::path) </entry>
  471.        </row>
  472.        <row>
  473. <entry> isopen(path) </entry>
  474. <entry> bool </entry>
  475. <entry> an open path? </entry>
  476. <entry> isopen('[(0,0),(1,1),(2,0)]'::path) </entry>
  477.        </row>
  478.        <row>
  479. <entry> length(lseg) </entry>
  480. <entry> float8 </entry>
  481. <entry> length of line segment </entry>
  482. <entry> length('((-1,0),(1,0))'::lseg) </entry>
  483.        </row>
  484.        <row>
  485. <entry> length(path) </entry>
  486. <entry> float8 </entry>
  487. <entry> length of path </entry>
  488. <entry> length('((0,0),(1,1),(2,0))'::path) </entry>
  489.        </row>
  490.        <row>
  491. <entry> pclose(path) </entry>
  492. <entry> path </entry>
  493. <entry> convert path to closed </entry>
  494. <entry> popen('[(0,0),(1,1),(2,0)]'::path) </entry>
  495.        </row>
  496.        <row>
  497. <entry> point(lseg,lseg) </entry>
  498. <entry> point </entry>
  499. <entry> intersection </entry>
  500. <entry> point('((-1,0),(1,0))'::lseg,'((-2,-2),(2,2))'::lseg) </entry>
  501.        </row>
  502.        <row>
  503. <entry> points(path) </entry>
  504. <entry> int4 </entry>
  505. <entry> number of points </entry>
  506. <entry> points('[(0,0),(1,1),(2,0)]'::path) </entry>
  507.        </row>
  508.        <row>
  509. <entry> popen(path) </entry>
  510. <entry> path </entry>
  511. <entry> convert path to open </entry>
  512. <entry> popen('((0,0),(1,1),(2,0))'::path) </entry>
  513.        </row>
  514.        <row>
  515. <entry> radius(circle) </entry>
  516. <entry> float8 </entry>
  517. <entry> radius of circle </entry>
  518. <entry> radius('((0,0),2.0)'::circle) </entry>
  519.        </row>
  520.        <row>
  521. <entry> width(box) </entry>
  522. <entry> float8 </entry>
  523. <entry> horizontal size </entry>
  524. <entry> width('((0,0),(1,1))'::box) </entry>
  525.        </row>
  526.       </tbody>
  527.      </tgroup>
  528.     </table>
  529.    </para>
  530.    <para>
  531.     <table tocentry="1">
  532.      <title>Geometric Type Conversion Functions</title>
  533.      <tgroup cols="4">
  534.       <thead>
  535.        <row>
  536. <entry>Function</entry>
  537. <entry>Returns</entry>
  538. <entry>Description</entry>
  539. <entry>Example</entry>
  540.        </row>
  541.       </thead>
  542.       <tbody>
  543.        <row>
  544. <entry> box(circle) </entry>
  545. <entry> box </entry>
  546. <entry> convert circle to box </entry>
  547. <entry> box('((0,0),2.0)'::circle) </entry>
  548.        </row>
  549.        <row>
  550. <entry> box(point,point) </entry>
  551. <entry> box </entry>
  552. <entry> convert points to box </entry>
  553. <entry> box('(0,0)'::point,'(1,1)'::point) </entry>
  554.        </row>
  555.        <row>
  556. <entry> box(polygon) </entry>
  557. <entry> box </entry>
  558. <entry> convert polygon to box </entry>
  559. <entry> box('((0,0),(1,1),(2,0))'::polygon) </entry>
  560.        </row>
  561.        <row>
  562. <entry> circle(box) </entry>
  563. <entry> circle </entry>
  564. <entry> convert to circle </entry>
  565. <entry> circle('((0,0),(1,1))'::box) </entry>
  566.        </row>
  567.        <row>
  568. <entry> circle(point,float8) </entry>
  569. <entry> circle </entry>
  570. <entry> convert to circle </entry>
  571. <entry> circle('(0,0)'::point,2.0) </entry>
  572.        </row>
  573.        <row>
  574. <entry> lseg(box) </entry>
  575. <entry> lseg </entry>
  576. <entry> convert diagonal to lseg </entry>
  577. <entry> lseg('((-1,0),(1,0))'::box) </entry>
  578.        </row>
  579.        <row>
  580. <entry> lseg(point,point) </entry>
  581. <entry> lseg </entry>
  582. <entry> convert to lseg </entry>
  583. <entry> lseg('(-1,0)'::point,'(1,0)'::point) </entry>
  584.        </row>
  585.        <row>
  586. <entry> path(polygon) </entry>
  587. <entry> point </entry>
  588. <entry> convert to path </entry>
  589. <entry> path('((0,0),(1,1),(2,0))'::polygon) </entry>
  590.        </row>
  591.        <row>
  592. <entry> point(circle) </entry>
  593. <entry> point </entry>
  594. <entry> convert to point (center) </entry>
  595. <entry> point('((0,0),2.0)'::circle) </entry>
  596.        </row>
  597.        <row>
  598. <entry> point(lseg,lseg) </entry>
  599. <entry> point </entry>
  600. <entry> convert to point (intersection) </entry>
  601. <entry> point('((-1,0),(1,0))'::lseg, '((-2,-2),(2,2))'::lseg) </entry>
  602.        </row>
  603.        <row>
  604. <entry> point(polygon) </entry>
  605. <entry> point </entry>
  606. <entry> center of polygon </entry>
  607. <entry> point('((0,0),(1,1),(2,0))'::polygon) </entry>
  608.        </row>
  609.        <row>
  610. <entry> polygon(box) </entry>
  611. <entry> polygon </entry>
  612. <entry> convert to polygon with 12 points </entry>
  613. <entry> polygon('((0,0),(1,1))'::box) </entry>
  614.        </row>
  615.        <row>
  616. <entry> polygon(circle) </entry>
  617. <entry> polygon </entry>
  618. <entry> convert to 12-point polygon </entry>
  619. <entry> polygon('((0,0),2.0)'::circle) </entry>
  620.        </row>
  621.        <row>
  622. <entry> polygon(<replaceable class="parameter">npts</replaceable>,circle) </entry>
  623. <entry> polygon </entry>
  624. <entry> convert to <replaceable class="parameter">npts</replaceable> polygon </entry>
  625. <entry> polygon(12,'((0,0),2.0)'::circle) </entry>
  626.        </row>
  627.        <row>
  628. <entry> polygon(path) </entry>
  629. <entry> polygon </entry>
  630. <entry> convert to polygon </entry>
  631. <entry> polygon('((0,0),(1,1),(2,0))'::path) </entry>
  632.        </row>
  633.       </tbody>
  634.      </tgroup>
  635.     </table>
  636.    </para>
  637.    <para>
  638.     <table tocentry="1">
  639.      <title>Geometric Upgrade Functions</title>
  640.      <tgroup cols="4">
  641.       <thead>
  642.        <row>
  643. <entry>Function</entry>
  644. <entry>Returns</entry>
  645. <entry>Description</entry>
  646. <entry>Example</entry>
  647.        </row>
  648.       </thead>
  649.       <tbody>
  650.        <row>
  651. <entry> isoldpath(path) </entry>
  652. <entry> path </entry>
  653. <entry> test path for pre-v6.1 form </entry>
  654. <entry> isoldpath('(1,3,0,0,1,1,2,0)'::path) </entry>
  655.        </row>
  656.        <row>
  657. <entry> revertpoly(polygon) </entry>
  658. <entry> polygon </entry>
  659. <entry> convert pre-v6.1 polygon </entry>
  660. <entry> revertpoly('((0,0),(1,1),(2,0))'::polygon) </entry>
  661.        </row>
  662.        <row>
  663. <entry> upgradepath(path) </entry>
  664. <entry> path </entry>
  665. <entry> convert pre-v6.1 path </entry>
  666. <entry> upgradepath('(1,3,0,0,1,1,2,0)'::path) </entry>
  667.        </row>
  668.        <row>
  669. <entry> upgradepoly(polygon) </entry>
  670. <entry> polygon </entry>
  671. <entry> convert pre-v6.1 polygon </entry>
  672. <entry> upgradepoly('(0,1,2,0,1,0)'::polygon) </entry>
  673.        </row>
  674.       </tbody>
  675.      </tgroup>
  676.     </table>
  677.    </para>
  678.   </sect1>
  679.   <sect1>
  680.    <title id="cidr-funcs">IP V4 Functions</title>
  681.    <para>
  682.     <table tocentry="1">
  683.      <title><productname>Postgres</productname>IP V4 Functions</title>
  684.      <tgroup cols="4">
  685.       <thead>
  686.        <row>
  687. <entry>Function</entry>
  688. <entry>Returns</entry>
  689. <entry>Description</entry>
  690. <entry>Example</entry>
  691.        </row>
  692.       </thead>
  693.       <tbody>
  694.        <row>
  695. <entry> broadcast(cidr) </entry>
  696. <entry> text </entry>
  697. <entry> construct broadcast address as text </entry>
  698. <entry> broadcast('192.168.1.5/24') </entry>
  699.        </row>
  700.        <row>
  701. <entry> broadcast(inet) </entry>
  702. <entry> text </entry>
  703. <entry> construct broadcast address as text </entry>
  704. <entry> broadcast('192.168.1.5/24') </entry>
  705.        </row>
  706.        <row>
  707. <entry> host(inet) </entry>
  708. <entry> text </entry>
  709. <entry> extract host address as text </entry>
  710. <entry> host('192.168.1.5/24') </entry>
  711.        </row>
  712.        <row>
  713. <entry> masklen(cidr) </entry>
  714. <entry> int4 </entry>
  715. <entry> calculate netmask length </entry>
  716. <entry> masklen('192.168.1.5/24') </entry>
  717.        </row>
  718.        <row>
  719. <entry> masklen(inet) </entry>
  720. <entry> int4 </entry>
  721. <entry> calculate netmask length </entry>
  722. <entry> masklen('192.168.1.5/24') </entry>
  723.        </row>
  724.        <row>
  725. <entry> netmask(inet) </entry>
  726. <entry> text </entry>
  727. <entry> construct netmask as text </entry>
  728. <entry> netmask('192.168.1.5/24') </entry>
  729.        </row>
  730.       </tbody>
  731.      </tgroup>
  732.     </table>
  733.    </para>
  734.   </sect1>
  735.  </chapter>
  736. <!-- Keep this comment at the end of the file
  737. Local variables:
  738. mode: sgml
  739. sgml-omittag:nil
  740. sgml-shorttag:t
  741. sgml-minimize-attributes:nil
  742. sgml-always-quote-attributes:t
  743. sgml-indent-step:1
  744. sgml-indent-data:t
  745. sgml-parent-document:nil
  746. sgml-default-dtd-file:"./reference.ced"
  747. sgml-exposed-tags:nil
  748. sgml-local-catalogs:"/usr/lib/sgml/catalog"
  749. sgml-local-ecat-files:nil
  750. End:
  751. -->