func.sgml 39 KB
Newer Older
1 2
 <chapter id="functions">
  <title id="functions-title">Functions</title>
3

4 5 6 7 8 9
  <abstract>
   <para>
    Describes the built-in functions available
    in <productname>Postgres</productname>.
   </para>
  </abstract>
10

11
  <para>
12 13 14
   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.
15
  </para>
16

17 18
  <sect1>
   <title id="sql-funcs">SQL Functions</title>
19

20 21 22 23 24 25 26 27
   <para>
    <quote><acronym>SQL</acronym> functions</quote> are constructs
    defined by the <acronym>SQL92</acronym> standard which have
    function-like syntax but which can not be implemented as simple
    functions. 
   </para>

   <para>
28 29 30 31 32 33 34 35 36 37 38 39 40
    <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>
41 42 43 44
	<entry>COALESCE(<replaceable class="parameter">list</replaceable>)</entry>
	<entry>non-NULL</entry>
	<entry>return first non-NULL value in list</entry>
	<entry>COALESCE(rle, c2 + 5, 0)</entry>
45 46
       </row>
       <row>
47 48 49
	<entry>NULLIF(<replaceable class="parameter">input</replaceable>,<replaceable class="parameter">value</replaceable>)</entry>
	<entry><replaceable class="parameter">input</replaceable> or NULL</entry>
	<entry>return NULL if
50 51 52 53
	<replaceable class="parameter">input</replaceable> =
	<replaceable class="parameter">value</replaceable>,
	else <replaceable class="parameter">input</replaceable>
	</entry>
54
	<entry>NULLIF(c1, 'N/A')</entry>
55 56
       </row>
       <row>
57 58 59 60
	<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 WHEN clause</entry>
	<entry>CASE WHEN c1 = 1 THEN 'match' ELSE 'no match' END</entry>
61
       </row>
62 63 64 65 66 67 68 69 70
      </tbody>
     </tgroup>
    </table>
   </para>
  </sect1>

  <sect1>
   <title id="math-funcs">Mathematical Functions</title>

71 72 73 74 75 76 77 78 79 80 81 82 83 84
   <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>
85 86 87 88
	<entry>abs(float8)</entry>
	<entry>float8</entry>
	<entry>absolute value</entry>
	<entry>abs(-17.4)</entry>
89 90
       </row>
       <row>
91
	<entry>degrees(float8)</entry>
92
	<entry>float8</entry>
93 94
	<entry>radians to degrees</entry>
	<entry>degrees(0.5)</entry>
95 96
       </row>
       <row>
97 98 99 100
	<entry>exp(float8)</entry>
	<entry>float8</entry>
	<entry>raise e to the specified exponent</entry>
	<entry>exp(2.0)</entry>
101 102
       </row>
       <row>
103 104 105 106
	<entry>ln(float8)</entry>
	<entry>float8</entry>
	<entry>natural logarithm</entry>
	<entry>ln(2.0)</entry>
107 108
       </row>
       <row>
109 110 111 112
	<entry>log(float8)</entry>
	<entry>float8</entry>
	<entry>base 10 logarithm</entry>
	<entry>log(2.0)</entry>
113
       </row>
114 115 116 117 118 119
       <row>
	<entry>pi()</entry>
	<entry>float8</entry>
	<entry>fundamental constant</entry>
	<entry>pi()</entry>
       </row>
120
       <row>
121 122 123 124
	<entry>pow(float8,float8)</entry>
	<entry>float8</entry>
	<entry>raise a number to the specified exponent</entry>
	<entry>pow(2.0, 16.0)</entry>
125
       </row>
126 127 128 129 130 131
       <row>
	<entry>radians(float8)</entry>
	<entry>float8</entry>
	<entry>degrees to radians</entry>
	<entry>radians(45.0)</entry>
       </row>
132
       <row>
133 134 135 136
	<entry>round(float8)</entry>
	<entry>float8</entry>
	<entry>round to nearest integer</entry>
	<entry>round(42.4)</entry>
137
       </row>
138 139 140 141 142 143
       <row>
	<entry>sqrt(float8)</entry>
	<entry>float8</entry>
	<entry>square root</entry>
	<entry>sqrt(2.0)</entry>
       </row>
Tom Lane's avatar
Tom Lane committed
144 145 146 147 148 149
       <row>
	<entry>cbrt(float8)</entry>
	<entry>float8</entry>
	<entry>cube root</entry>
	<entry>cbrt(27.0)</entry>
       </row>
150
       <row>
151 152 153 154
	<entry>trunc(float8)</entry>
	<entry>float8</entry>
	<entry>truncate (towards zero)</entry>
	<entry>trunc(42.4)</entry>
155 156
       </row>
       <row>
157 158 159 160
	<entry>float(int)</entry>
	<entry>float8</entry>
	<entry>convert integer to floating point</entry>
	<entry>float(2)</entry>
161 162
       </row>
       <row>
163 164 165 166
	<entry>float4(int)</entry>
	<entry>float4</entry>
	<entry>convert integer to floating point</entry>
	<entry>float4(2)</entry>
167 168
       </row>
       <row>
169 170 171 172
	<entry>integer(float)</entry>
	<entry>int</entry>
	<entry>convert floating point to integer</entry>
	<entry>integer(2.0)</entry>
173 174 175 176 177
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>
178 179

   <para>
180 181
    Most of the functions listed for FLOAT8 are also available for
    type NUMERIC.
182
   </para>
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239

   <para>
    <table tocentry="1">
     <title>Transcendental 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>acos(float8)</entry>
	<entry>float8</entry>
	<entry>arccosine</entry>
	<entry>acos(10.0)</entry>
       </row>
       <row>
	<entry>asin(float8)</entry>
	<entry>float8</entry>
	<entry>arcsine</entry>
	<entry>asin(10.0)</entry>
       </row>
       <row>
	<entry>atan(float8)</entry>
	<entry>float8</entry>
	<entry>arctangent</entry>
	<entry>atan(10.0)</entry>
       </row>
       <row>
	<entry>atan2(float8,float8)</entry>
	<entry>float8</entry>
	<entry>arctangent</entry>
	<entry>atan3(10.0,20.0)</entry>
       </row>
       <row>
	<entry>cos(float8)</entry>
	<entry>float8</entry>
	<entry>cosine</entry>
	<entry>cos(0.4)</entry>
       </row>
       <row>
	<entry>cot(float8)</entry>
	<entry>float8</entry>
	<entry>cotangent</entry>
	<entry>cot(20.0)</entry>
       </row>
       <row>
	<entry>sin(float8)</entry>
	<entry>float8</entry>
	<entry>sine</entry>
	<entry>cos(0.4)</entry>
       </row>
       <row>
240
	<entry>tan(float8)</entry>
241
	<entry>float8</entry>
242 243
	<entry>tangent</entry>
	<entry>tan(0.4)</entry>
244
       </row>
245 246 247 248
      </tbody>
     </tgroup>
    </table>
   </para>
249

250
  </sect1>
251

252 253
  <sect1>
   <title>String Functions</title>
254

255
   <para>
256
    SQL92 defines string functions with specific syntax. Some of these
257
    are implemented using other <productname>Postgres</productname> functions.
258 259
    The supported string types for <acronym>SQL92</acronym> are
    <type>char</type>, <type>varchar</type>, and <type>text</type>.
260
   </para>
261

262 263 264 265 266 267 268 269 270 271 272 273 274 275
   <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>
276 277 278 279
	<entry>char_length(string)</entry>
	<entry>int4</entry>
	<entry>length of string</entry>
	<entry>char_length('jose')</entry>
280 281
       </row>
       <row>
282 283 284 285
	<entry>character_length(string)</entry>
	<entry>int4</entry>
	<entry>length of string</entry>
	<entry>char_length('jose')</entry>
286 287
       </row>
       <row>
288 289 290 291
	<entry>lower(string)</entry>
	<entry>string</entry>
	<entry>convert string to lower case</entry>
	<entry>lower('TOM')</entry>
292 293
       </row>
       <row>
294 295 296 297
	<entry>octet_length(string)</entry>
	<entry>int4</entry>
	<entry>storage length of string</entry>
	<entry>octet_length('jose')</entry>
298 299
       </row>
       <row>
300 301 302 303
	<entry>position(string in string)</entry>
	<entry>int4</entry>
	<entry>location of specified substring</entry>
	<entry>position('o' in 'Tom')</entry>
304 305
       </row>
       <row>
306 307 308 309
	<entry>substring(string [from int] [for int])</entry>
	<entry>string</entry>
	<entry>extract specified substring</entry>
	<entry>substring('Tom' from 2 for 2)</entry>
310 311
       </row>
       <row>
312 313 314 315
	<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>
316 317
       </row>
       <row>
318 319 320 321
	<entry>upper(text)</entry>
	<entry>text</entry>
	<entry>convert text to upper case</entry>
	<entry>upper('tom')</entry>
322 323 324 325 326
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>
327

328
   <para>
329 330
    Many additional string functions are available for text, varchar(), and char() types.
    Some are used internally to implement the SQL92 string functions listed above.
331
   </para>
332

333 334 335 336 337 338 339 340 341 342 343 344 345 346
   <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>
347 348 349 350
	<entry>char(text)</entry>
	<entry>char</entry>
	<entry>convert text to char type</entry>
	<entry>char('text string')</entry>
351 352
       </row>
       <row>
353 354 355 356
	<entry>char(varchar)</entry>
	<entry>char</entry>
	<entry>convert varchar to char type</entry>
	<entry>char(varchar 'varchar string')</entry>
357 358
       </row>
       <row>
359 360 361 362
	<entry>initcap(text)</entry>
	<entry>text</entry>
	<entry>first letter of each word to upper case</entry>
	<entry>initcap('thomas')</entry>
363 364
       </row>
       <row>
365 366 367 368
	<entry>lpad(text,int,text)</entry>
	<entry>text</entry>
	<entry>left pad string to specified length</entry>
	<entry>lpad('hi',4,'??')</entry>
369 370
       </row>
       <row>
371 372 373 374
	<entry>ltrim(text,text)</entry>
	<entry>text</entry>
	<entry>left trim characters from text</entry>
	<entry>ltrim('xxxxtrim','x')</entry>
375 376
       </row>
       <row>
377 378 379 380
	<entry>textpos(text,text)</entry>
	<entry>text</entry>
	<entry>locate specified substring</entry>
	<entry>position('high','ig')</entry>
381 382
       </row>
       <row>
383 384 385 386
	<entry>rpad(text,int,text)</entry>
	<entry>text</entry>
	<entry>right pad string to specified length</entry>
	<entry>rpad('hi',4,'x')</entry>
387 388
       </row>
       <row>
389 390 391 392
	<entry>rtrim(text,text)</entry>
	<entry>text</entry>
	<entry>right trim characters from text</entry>
	<entry>rtrim('trimxxxx','x')</entry>
393 394
       </row>
       <row>
395 396 397 398
	<entry>substr(text,int[,int])</entry>
	<entry>text</entry>
	<entry>extract specified substring</entry>
	<entry>substr('hi there',3,5)</entry>
399 400
       </row>
       <row>
401 402 403 404
	<entry>text(char)</entry>
	<entry>text</entry>
	<entry>convert char to text type</entry>
	<entry>text('char string')</entry>
405 406
       </row>
       <row>
407 408 409 410
	<entry>text(varchar)</entry>
	<entry>text</entry>
	<entry>convert varchar to text type</entry>
	<entry>text(varchar 'varchar string')</entry>
411 412
       </row>
       <row>
413 414 415 416
	<entry>translate(text,from,to)</entry>
	<entry>text</entry>
	<entry>convert character in string</entry>
	<entry>translate('12345', '1', 'a')</entry>
417 418
       </row>
       <row>
419 420 421 422
	<entry>varchar(char)</entry>
	<entry>varchar</entry>
	<entry>convert char to varchar type</entry>
	<entry>varchar('char string')</entry>
423 424
       </row>
       <row>
425 426 427 428
	<entry>varchar(text)</entry>
	<entry>varchar</entry>
	<entry>convert text to varchar type</entry>
	<entry>varchar('text string')</entry>
429 430 431 432 433
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>
434

435 436 437 438
   <para>
    Most functions explicitly defined for text will work for char() and varchar() arguments.
   </para>
  </sect1>
439

440 441
  <sect1>
   <title>Date/Time Functions</title>
442

443 444 445 446
   <para>
    The date/time functions provide a powerful set of tools
    for manipulating various date/time types.
   </para>
447

448 449 450 451 452 453 454 455 456 457 458 459 460 461
   <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>
462 463 464 465
	<entry>abstime(timestamp)</entry>
	<entry>abstime</entry>
	<entry>convert to abstime</entry>
	<entry>abstime(timestamp 'now')</entry>
466 467
       </row>
       <row>
468 469 470 471
	<entry>age(timestamp)</entry>
	<entry>interval</entry>
	<entry>preserve months and years</entry>
	<entry>age(timestamp '1957-06-13')</entry>
472 473
       </row>
       <row>
474 475 476 477
	<entry>age(timestamp,timestamp)</entry>
	<entry>interval</entry>
	<entry>preserve months and years</entry>
	<entry>age('now', timestamp '1957-06-13')</entry>
478 479
       </row>
       <row>
480 481 482 483
	<entry>timestamp(abstime)</entry>
	<entry>timestamp</entry>
	<entry>convert to timestamp</entry>
	<entry>timestamp(abstime 'now')</entry>
484 485
       </row>
       <row>
486 487 488 489 490 491 492 493 494 495 496
	<entry>timestamp(date)</entry>
	<entry>timestamp</entry>
	<entry>convert to timestamp</entry>
	<entry>timestamp(date 'today')</entry>
       </row>
       <row>
	<entry>timestamp(date,time)</entry>
	<entry>timestamp</entry>
	<entry>convert to timestamp</entry>
	<entry>timestamp(timestamp '1998-02-24',time '23:07');</entry>
       </row>
497
       <row>
498 499 500 501
	<entry>date_part(text,timestamp)</entry>
	<entry>float8</entry>
	<entry>portion of date</entry>
	<entry>date_part('dow',timestamp 'now')</entry>
502 503
       </row>
       <row>
504 505 506 507
	<entry>date_part(text,interval)</entry>
	<entry>float8</entry>
	<entry>portion of time</entry>
	<entry>date_part('hour',interval '4 hrs 3 mins')</entry>
508 509
       </row>
       <row>
510 511 512 513
	<entry>date_trunc(text,timestamp)</entry>
	<entry>timestamp</entry>
	<entry>truncate date</entry>
	<entry>date_trunc('month',abstime 'now')</entry>
514 515
       </row>
       <row>
516 517 518 519
	<entry>isfinite(abstime)</entry>
	<entry>bool</entry>
	<entry>a finite time?</entry>
	<entry>isfinite(abstime 'now')</entry>
520 521
       </row>
       <row>
522 523 524 525
	<entry>isfinite(timestamp)</entry>
	<entry>bool</entry>
	<entry>a finite time?</entry>
	<entry>isfinite(timestamp 'now')</entry>
526 527
       </row>
       <row>
528 529 530 531
	<entry>isfinite(interval)</entry>
	<entry>bool</entry>
	<entry>a finite time?</entry>
	<entry>isfinite(interval '4 hrs')</entry>
532 533
       </row>
       <row>
534 535 536 537
	<entry>reltime(interval)</entry>
	<entry>reltime</entry>
	<entry>convert to reltime</entry>
	<entry>reltime(interval '4 hrs')</entry>
538 539
       </row>
       <row>
540 541 542 543
	<entry>interval(reltime)</entry>
	<entry>interval</entry>
	<entry>convert to interval</entry>
	<entry>interval(reltime '4 hours')</entry>
544 545 546 547 548
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>
549

550
   <para>
551
    For the
552
    <function>date_part</function> and <function>date_trunc</function>
553 554 555 556
    functions, arguments can be
    `year', `month', `day', `hour', `minute', and `second',
    as well as the more specialized quantities
    `decade', `century', `millenium', `millisecond', and `microsecond'.
557 558
    <function>date_part</function> allows `dow'
    to return day of week and `epoch' to return seconds since 1970
559 560
    (for <type>timestamp</type>)
    or 'epoch' to return total elapsed seconds (for <type>interval</type>).
561
   </para>
562
  </sect1>
563

564 565 566
  
  <sect1>

567
   <title id="formatting-funcs">Formatting Functions</title>
568 569 570 571 572 573 574 575 576 577

   <note>
    <title>Author</title>
    <para>
     Written by 
     <ulink url="mailto:zakkr@zf.jcu.cz">Karel Zak</ulink>
     on 2000-01-24.
    </para>
   </note>
   <para>
578 579
    The <productname>Postgres</productname>
    formatting functions provide a powerful set of tools for converting 
580
    various datetypes (date/time, int, float, numeric) to formatted strings 
581 582 583 584 585 586 587 588
    and for converting from formatted strings to specific datetypes. 

    <note>
     <para>
      The second argument for all formatting functions is a template to
      be used for the conversion.
     </para>
    </note>
589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
   </para>

   <para>
    <table tocentry="1">
     <title>Formatting Functions</title>
     <tgroup cols="4">
      <thead>
       <row>
	<entry>Function</entry>
	<entry>Returns</entry>
	<entry>Description</entry>
	<entry>Example</entry>
       </row>
      </thead>
      <tbody>
       <row>
605 606 607 608
	<entry>to_char(timestamp, text)</entry>
	<entry>text</entry>
	<entry>convert timestamp to string</entry>
	<entry>to_char(timestamp 'now','HH12:MI:SS')</entry>
609 610
       </row>
       <row>
611 612 613 614
	<entry>to_char(int, text)</entry>
	<entry>text</entry>
	<entry>convert int4/int8 to string</entry>
	<entry>to_char(125, '999')</entry>
615 616
       </row>
       <row>
617 618 619 620
	<entry>to_char(float, text)</entry>
	<entry>text</entry>
	<entry>convert float4/float8 to string</entry>
	<entry>to_char(125.8, '999D9')</entry>
621 622
       </row>
       <row>
623 624 625 626
	<entry>to_char(numeric, text)</entry>
	<entry>text</entry>
	<entry>convert numeric to string</entry>
	<entry>to_char(numeric '-125.8', '999D99S')</entry>
627 628
       </row>
       <row>
629 630 631 632
	<entry>to_date(text, text)</entry>
	<entry>date</entry>
	<entry>convert string to date</entry>
	<entry>to_date('05 Dec 2000', 'DD Mon YYYY')</entry>
633 634
       </row>
       <row>
635 636 637 638
	<entry>to_timestamp(text, text)</entry>
	<entry>date</entry>
	<entry>convert string to timestamp</entry>
	<entry>to_timestamp('05 Dec 2000', 'DD Mon YYYY')</entry>
639 640
       </row>
       <row>
641 642 643 644
	<entry>to_number(text, text)</entry>
	<entry>numeric</entry>
	<entry>convert string to numeric</entry>
	<entry>to_number('12,454.8-', '99G999D9S')</entry>
645 646 647 648 649 650 651 652
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>

   <para>
    <table tocentry="1">
653
     <title>Templates for date/time conversions</title>
654 655 656
     <tgroup cols="2">
      <thead>
       <row>
657
	<entry>Template</entry>
658 659 660 661 662
	<entry>Description</entry>
       </row>
      </thead>
      <tbody>
       <row>
663 664
	<entry>HH</entry>
	<entry>hour of day (01-12)</entry>
665 666
       </row>
       <row>
667 668
	<entry>HH12</entry>
	<entry>hour of day (01-12)</entry>
669 670
       </row>       
       <row>
671 672
	<entry>MI</entry>
	<entry>minute (00-59)</entry>
673 674
       </row>   
       <row>
675 676
	<entry>SS</entry>
	<entry>second (00-59)</entry>
677 678
       </row>
       <row>
679 680
	<entry>SSSS</entry>
	<entry>seconds past midnight (0-86399)</entry>
681
       </row>
682 683 684 685 686 687 688 689
       <row>
	<entry>AM or A.M. or PM or P.M.</entry>
	<entry>meridian indicator (upper case)</entry>
       </row>
       <row>
	<entry>am or a.m. or pm or p.m.</entry>
	<entry>meridian indicator (lower case)</entry>
       </row>
690
       <row>
691 692
	<entry>Y,YYY</entry>
	<entry>year (4 and more digits) with comma</entry>
693 694
       </row>
       <row>
695 696
	<entry>YYYY</entry>
	<entry>year (4 and more digits)</entry>
697 698
       </row>
       <row>
699 700
	<entry>YYY</entry>
	<entry>last 3 digits of year</entry>
701 702
       </row>
       <row>
703 704
	<entry>YY</entry>
	<entry>last 2 digits of year</entry>
705 706
       </row>
       <row>
707 708
	<entry>Y</entry>
	<entry>last digit of year</entry>
709
       </row>
710 711 712 713 714 715 716 717
       <row>
	<entry>BC or B.C. or AD or A.D.</entry>
	<entry>year indicator (upper case)</entry>
       </row>
       <row>
	<entry>bc or b.c. or ad or a.d.</entry>
	<entry>year indicator (lower case)</entry>
       </row>
718
       <row>
719 720
	<entry>MONTH</entry>
	<entry>full upper case month name (9 chars)</entry>
721 722
       </row>
       <row>
723 724
	<entry>Month</entry>
	<entry>full mixed case month name (9 chars)</entry>
725 726
       </row>
       <row>
727 728
	<entry>month</entry>
	<entry>full lower case month name (9 chars)</entry>
729 730
       </row>
       <row>
731 732
	<entry>MON</entry>
	<entry>upper case abbreviated month name (3 chars)</entry>
733 734
       </row>
       <row>
735 736
	<entry>Mon</entry>
	<entry>abbreviated mixed case month name (3 chars)</entry>
737 738
       </row>
       <row>
739 740
	<entry>mon</entry>
	<entry>abbreviated lower case month name (3 chars)</entry>
741 742
       </row>
       <row>
743 744
	<entry>MM</entry>
	<entry>month (01-12)</entry>
745 746
       </row>
       <row>
747 748
	<entry>DAY</entry>
	<entry>full upper case day name (9 chars)</entry>
749 750
       </row>
       <row>
751 752
	<entry>Day</entry>
	<entry>full mixed case day name (9 chars)</entry>
753 754
       </row>
       <row>
755 756
	<entry>day</entry>
	<entry>full lower case day name (9 chars)</entry>
757 758
       </row>
       <row>
759 760
	<entry>DY</entry>
	<entry>abbreviated upper case day name (3 chars)</entry>
761 762
       </row>
       <row>
763 764
	<entry>Dy</entry>
	<entry>abbreviated mixed case day name (3 chars)</entry>
765 766
       </row>
       <row>
767 768
	<entry>dy</entry>
	<entry>abbreviated lower case day name (3 chars)</entry>
769 770
       </row>
       <row>
771 772
	<entry>DDD</entry>
	<entry>day of year (001-366)</entry>
773 774
       </row>
       <row>
775 776
	<entry>DD</entry>
	<entry>day of month (01-31)</entry>
777 778
       </row>
       <row>
779 780
	<entry>D</entry>
	<entry>day of week (1-7; SUN=1)</entry>
781 782
       </row>
       <row>
783 784
	<entry>W</entry>
	<entry>week of month</entry>
785 786
       </row> 
       <row>
787 788
	<entry>WW</entry>
	<entry>week number of year</entry>
789 790
       </row>
       <row>
791 792
	<entry>CC</entry>
	<entry>century (2 digits)</entry>
793 794
       </row>
       <row>
795 796
	<entry>J</entry>
	<entry>Julian Day (days since January 1, 4712 BC)</entry>
797 798
       </row>
       <row>
799 800
	<entry>Q</entry>
	<entry>quarter</entry>
801 802
       </row>
       <row>
803
	<entry>RM</entry>
804 805 806 807 808
	<entry>month in Roman Numerals (I-XII; I=JAN) - upper case</entry>
       </row>
       <row>
	<entry>rn</entry>
	<entry>month in Roman Numerals (I-XII; I=JAN) - lower case</entry>
809 810 811 812 813 814 815
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>

   <para>
816 817
    All templates allow the use of prefix and suffix modifiers. Modifiers are
    always valid for use in templates. The prefix 'FX' is a global modifier only.      
818 819 820 821
   </para>

   <para>
    <table tocentry="1">
822
     <title>Suffixes for templates for date/time to_char()</title>
823 824 825 826 827 828 829 830 831 832
     <tgroup cols="3">
      <thead>
       <row>
	<entry>Suffix</entry>
	<entry>Description</entry>
	<entry>Example</entry>
       </row>
      </thead>
      <tbody>
       <row>
833 834 835
	<entry>FM</entry>
	<entry>fill mode prefix</entry>
	<entry>FMMonth</entry>
836 837
       </row>
       <row>
838 839 840
	<entry>TH</entry>
	<entry>upper ordinal number suffix</entry>
	<entry>DDTH</entry>
841 842
       </row>	
       <row>
843 844 845
	<entry>th</entry>
	<entry>lower ordinal number suffix</entry>
	<entry>DDTH</entry>
846 847
       </row>
       <row>
848 849 850
	<entry>FX</entry>
	<entry>FiXed format global option (see below)</entry>
	<entry>FX Month DD Day</entry>
851 852
       </row>	
       <row>
853 854 855
	<entry>SP</entry>
	<entry>spell mode (not yet implemented)</entry>
	<entry>DDSP</entry>
856 857 858 859 860 861 862
       </row>       
      </tbody>
     </tgroup>
    </table>
   </para>

   <para>
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895
    Usage notes:

    <itemizedlist>
     <listitem>
      <para>
       <function>to_timestamp</function> and <function>to_date</function>
       skip blank space if the <literal>FX</literal> option is
       not use. <literal>FX</literal> Must be specified as the first item
       in the template.
      </para>
     </listitem>

     <listitem>
      <para>
       '\' - must be use as double \\, example '\\HH\\MI\\SS' 
      </para>
     </listitem>

     <listitem>
      <para>
       '"' - string between a quotation marks is skipen and not is parsed. 
       If you want write '"' to output you must use \\", example '\\"YYYY Month\\"'.
      </para>
     </listitem>

     <listitem>
      <para>
       text - the PostgreSQL's to_char() support text without '"', but string 
       between a quotation marks is fastly and you have guarantee, that a text 
       not will interpreted as a keyword (format-picture), exapmle '"Hello Year: "YYYY'.  
      </para>
     </listitem>
    </itemizedlist>
896
   </para>
897

898 899
   <para>
    <table tocentry="1">
900
     <title>Templates for to_char(<replaceable>numeric</replaceable>)</title>
901 902 903
     <tgroup cols="2">
      <thead>
       <row>
904
	<entry>Template</entry>
905 906 907 908 909
	<entry>Description</entry>
       </row>
      </thead>
      <tbody>
       <row>
910 911
	<entry>9</entry>
	<entry>value with the specified number of digits</entry>
912 913
       </row>
       <row>
914 915
	<entry>0</entry>
	<entry>value with leading zeros</entry>
916 917
       </row>
       <row>
918 919
	<entry>. (period)</entry>
	<entry>decimal point</entry>
920 921
       </row>       
       <row>
922 923
	<entry>, (comma)</entry>
	<entry>group (thousand) separator</entry>
924 925
       </row>
       <row>
926 927
	<entry>PR</entry>
	<entry>negative value in angle brackets</entry>
928 929
       </row>
       <row>
930 931
	<entry>S</entry>
	<entry>negative value with minus sign (use locales)</entry>
932 933
       </row>
       <row>
934 935
	<entry>L</entry>
	<entry>currency symbol (use locales)</entry>
936 937
       </row>
       <row>
938 939
	<entry>D</entry>
	<entry>decimal point (use locales)</entry>
940 941
       </row>
       <row>
942 943
	<entry>G</entry>
	<entry>group separator (use locales)</entry>
944 945
       </row>
       <row>
946 947
	<entry>MI</entry>
	<entry>minus sign on specified position (if number < 0)</entry>
948 949
       </row>
       <row>
950 951
	<entry>PL</entry>
	<entry>plus sign on specified position (if number > 0)</entry>
952 953
       </row>
       <row>
954 955
	<entry>SG</entry>
	<entry>plus/minus sign on specified position</entry>
956 957
       </row>
       <row>
958 959
	<entry>RN</entry>
	<entry>roman numeral (input between 1 and 3999)</entry>
960 961
       </row>
       <row>
962 963
	<entry>TH or th</entry>
	<entry>convert to ordinal number</entry>
964 965
       </row>
       <row>
966 967 968
	<entry>V</entry>
	<entry>Shift <replaceable>n</replaceable> digits (see
	 notes)</entry>
969 970
       </row>
       <row>
971 972
	<entry>EEEE</entry>
	<entry>science numbers. Now not supported.</entry>
973 974 975 976 977 978 979
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>

   <para>
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005
    Usage notes:

    <itemizedlist>
     <listitem>
      <para>
       A sign formatted using 'SG', 'PL' or 'MI' is not an anchor in
       the number; for example,
       to_char(-12, 'S9999') produces <literal>'  -12'</literal>,
       but to_char(-12, 'MI9999') produces <literal>'-  12'</literal>.
       The Oracle implementation does not allow the use of
       <literal>MI</literal> ahead of <literal>9</literal>, but rather
       requires that <literal>9</literal> preceeds
       <literal>MI</literal>.
      </para>
     </listitem>

     <listitem>
      <para>
       <literal>PL</literal>, <literal>SG</literal>, and
       <literal>TH</literal> are <productname>Postgres</productname>
       extensions. 
      </para>
     </listitem>

     <listitem>
      <para>
1006 1007 1008
       <literal>9</literal> specifies a value with the same number of 
       digits as there are <literal>9</literal>s. If a digit is
       not available use blank space.
1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032
      </para>
     </listitem>

     <listitem>
      <para>
       <literal>TH</literal> does not convert values less than zero
       and does not convert decimal numbers. <literal>TH</literal> is
       a <productname>Postgres</productname> extension.
      </para>
     </listitem>

     <listitem>
      <para>
       <literal>V</literal> effectively
       multiplies the input values by
       <literal>10^<replaceable>n</replaceable></literal>, where
       <replaceable>n</replaceable> is the number of digits following
       <literal>V</literal>. 
       <function>to_char</function> does not support the use of
       <literal>V</literal> combined with a decimal point
       (e.g. "99.9V99" is not allowed).
      </para>
     </listitem>
    </itemizedlist>
1033
   </para>   
1034 1035 1036

   <para>
    <table tocentry="1">
1037
     <title><function>to_char</function> Examples</title>
1038 1039 1040 1041 1042 1043 1044 1045 1046
     <tgroup cols="2">
      <thead>
       <row>
	<entry>Input</entry>
	<entry>Output</entry>
       </row>
      </thead>
      <tbody>
       <row>
1047 1048 1049
        <entry>to_char(now(),'Day, HH12:MI:SS')</entry>
        <entry><literal>'Tuesday  , 05:39:18'</literal></entry>
       </row>
1050
       <row>
1051 1052
        <entry>to_char(now(),'FMDay, HH12:MI:SS')</entry>
        <entry><literal>'Tuesday, 05:39:18'</literal></entry>
1053 1054
       </row>          
       <row>
1055 1056
        <entry>to_char(-0.1,'99.99')</entry>
        <entry><literal>' -.10'</literal></entry>
1057 1058
       </row>
       <row>
1059 1060
        <entry>to_char(-0.1,'FM9.99')</entry>
        <entry><literal>'-.1'</literal></entry>
1061 1062
       </row>
       <row>
1063 1064
        <entry>to_char(0.1,'0.9')</entry>
        <entry><literal>' 0.1'</literal></entry>
1065 1066
       </row>
       <row>
1067 1068
        <entry>to_char(12,'9990999.9')</entry>
        <entry><literal>'    0012.0'</literal></entry>
1069 1070
       </row>
       <row>
1071 1072
        <entry>to_char(12,'FM9990999.9')</entry>
        <entry><literal>'0012'</literal></entry>
1073 1074
       </row>
       <row>
1075 1076
        <entry>to_char(485,'999')</entry>
        <entry><literal>' 485'</literal></entry>
1077 1078
       </row>
       <row>
1079 1080
        <entry>to_char(-485,'999')</entry>
        <entry><literal>'-485'</literal></entry>
1081 1082
       </row>
       <row>
1083 1084
        <entry>to_char(485,'9 9 9')</entry>
        <entry><literal>' 4 8 5'</literal></entry>
1085 1086
       </row>
       <row>
1087 1088
        <entry>to_char(1485,'9,999')</entry>
        <entry><literal>' 1,485'</literal></entry>
1089 1090
       </row>
       <row>
1091 1092
        <entry>to_char(1485,'9G999')</entry>
        <entry><literal>' 1 485'</literal></entry>
1093 1094
       </row>
       <row>
1095 1096
        <entry>to_char(148.5,'999.999')</entry>
        <entry><literal>' 148.500'</literal></entry>
1097 1098
       </row>
       <row>
1099 1100
        <entry>to_char(148.5,'999D999')</entry>
        <entry><literal>' 148,500'</literal></entry>	 
1101 1102
       </row>
       <row>
1103 1104
        <entry>to_char(3148.5,'9G999D999')</entry>
        <entry><literal>' 3 148,500'</literal></entry>
1105 1106
       </row>
       <row>
1107 1108
        <entry>to_char(-485,'999S')</entry>
        <entry><literal>'485-'</literal></entry>
1109 1110
       </row>
       <row>		
1111 1112
        <entry>to_char(-485,'999MI')</entry>
        <entry><literal>'485-'</literal></entry>	
1113 1114
       </row>
       <row>
1115 1116
        <entry>to_char(485,'999MI')</entry>
        <entry><literal>'485'</literal></entry>		
1117 1118
       </row>
       <row>
1119 1120
        <entry>to_char(485,'PL999')</entry>
        <entry><literal>'+485'</literal></entry>	
1121 1122
       </row>
       <row>		
1123 1124
        <entry>to_char(485,'SG999')</entry>
        <entry><literal>'+485'</literal></entry>	
1125 1126
       </row>
       <row>
1127 1128
        <entry>to_char(-485,'SG999')</entry>
        <entry><literal>'-485'</literal></entry>	
1129 1130
       </row>
       <row>
1131 1132
        <entry>to_char(-485,'9SG99')</entry>
        <entry><literal>'4-85'</literal></entry>	
1133 1134
       </row>
       <row>
1135 1136
        <entry>to_char(-485,'999PR')</entry>
        <entry><literal>'&lt;485&gt;'</literal></entry>		
1137 1138
       </row>
       <row>
1139 1140
        <entry>to_char(485,'L999')</entry>
        <entry><literal>'DM 485</literal></entry>	 
1141 1142
       </row>
       <row>
1143 1144
        <entry>to_char(485,'RN')</entry>		
        <entry><literal>'        CDLXXXV'</literal></entry>
1145 1146
       </row>
       <row>
1147 1148
        <entry>to_char(485,'FMRN')</entry>	
        <entry><literal>'CDLXXXV'</literal></entry>
1149 1150
       </row>
       <row>
1151 1152
        <entry>to_char(5.2,'FMRN')</entry>
        <entry><literal>V</literal></entry>		
1153 1154
       </row>
       <row>
1155 1156
        <entry>to_char(482,'999th')</entry>
        <entry><literal>' 482nd'</literal></entry>				
1157 1158
       </row>
       <row>
1159 1160
        <entry>to_char(485, '"Good number:"999')</entry>
        <entry><literal>'Good number: 485'</literal></entry>
1161 1162
       </row>
       <row>
1163 1164
        <entry>to_char(485.8,'"Pre-decimal:"999" Post-decimal:" .999')</entry>
        <entry><literal>'Pre-decimal: 485 Post-decimal: .800'</literal></entry>
1165 1166
       </row>
       <row>
1167 1168
        <entry>to_char(12,'99V999')</entry>		
        <entry><literal>' 12000'</literal></entry>
1169 1170
       </row>
       <row>
1171 1172
        <entry>to_char(12.4,'99V999')</entry>
        <entry><literal>' 12400'</literal></entry>
1173 1174
       </row>
       <row>		
1175 1176
        <entry>to_char(12.45, '99V9')</entry>
        <entry><literal>' 125'</literal></entry>
1177 1178 1179 1180 1181 1182 1183 1184
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>
  </sect1>


1185 1186
  <sect1>
   <title>Geometric Functions</title>
1187

1188 1189 1190 1191
   <para>
    The geometric types point, box, lseg, line, path, polygon, and
    circle have a large set of native support functions.
   </para>
1192

1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206
   <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>
1207 1208 1209 1210
	<entry>area(object)</entry>
	<entry>float8</entry>
	<entry>area of circle, ...</entry>
	<entry>area(box '((0,0),(1,1))')</entry>
1211 1212
       </row>
       <row>
1213 1214 1215 1216
	<entry>box(box,box)</entry>
	<entry>box</entry>
	<entry>boxes to intersection box</entry>
	<entry>box(box '((0,0),(1,1))',box '((0.5,0.5),(2,2))')</entry>
1217 1218
       </row>
       <row>
1219 1220 1221 1222
	<entry>center(object)</entry>
	<entry>point</entry>
	<entry>center of circle, ...</entry>
	<entry>center(box '((0,0),(1,2))')</entry>
1223 1224
       </row>
       <row>
1225 1226 1227 1228
	<entry>diameter(circle)</entry>
	<entry>float8</entry>
	<entry>diameter of circle</entry>
	<entry>diameter(circle '((0,0),2.0)')</entry>
1229 1230
       </row>
       <row>
1231 1232 1233 1234
	<entry>height(box)</entry>
	<entry>float8</entry>
	<entry>vertical size of box</entry>
	<entry>height(box '((0,0),(1,1))')</entry>
1235 1236
       </row>
       <row>
1237 1238 1239 1240
	<entry>isclosed(path)</entry>
	<entry>bool</entry>
	<entry>a closed path?</entry>
	<entry>isclosed(path '((0,0),(1,1),(2,0))')</entry>
1241 1242
       </row>
       <row>
1243 1244 1245 1246
	<entry>isopen(path)</entry>
	<entry>bool</entry>
	<entry>an open path?</entry>
	<entry>isopen(path '[(0,0),(1,1),(2,0)]')</entry>
1247 1248
       </row>
       <row>
1249 1250 1251 1252
	<entry>length(object)</entry>
	<entry>float8</entry>
	<entry>length of line segment, ...</entry>
	<entry>length(path '((-1,0),(1,0))')</entry>
1253 1254
       </row>
       <row>
1255 1256 1257 1258
	<entry>length(path)</entry>
	<entry>float8</entry>
	<entry>length of path</entry>
	<entry>length(path '((0,0),(1,1),(2,0))')</entry>
1259 1260
       </row>
       <row>
1261 1262 1263 1264
	<entry>pclose(path)</entry>
	<entry>path</entry>
	<entry>convert path to closed</entry>
	<entry>popen(path '[(0,0),(1,1),(2,0)]')</entry>
1265
       </row>
1266 1267
<!--
Not defined by this name. Implements the intersection operator '#'
1268
       <row>
1269 1270 1271 1272
	<entry>point(lseg,lseg)</entry>
	<entry>point</entry>
	<entry>intersection</entry>
	<entry>point(lseg '((-1,0),(1,0))',lseg '((-2,-2),(2,2))')</entry>
1273
       </row>
1274
-->
1275
       <row>
1276 1277 1278 1279
	<entry>npoint(path)</entry>
	<entry>int4</entry>
	<entry>number of points</entry>
	<entry>npoints(path '[(0,0),(1,1),(2,0)]')</entry>
1280 1281
       </row>
       <row>
1282 1283 1284 1285
	<entry>popen(path)</entry>
	<entry>path</entry>
	<entry>convert path to open path</entry>
	<entry>popen(path '((0,0),(1,1),(2,0))')</entry>
1286 1287
       </row>
       <row>
1288 1289 1290 1291
	<entry>radius(circle)</entry>
	<entry>float8</entry>
	<entry>radius of circle</entry>
	<entry>radius(circle '((0,0),2.0)')</entry>
1292 1293
       </row>
       <row>
1294 1295 1296 1297
	<entry>width(box)</entry>
	<entry>float8</entry>
	<entry>horizontal size</entry>
	<entry>width(box '((0,0),(1,1))')</entry>
1298 1299 1300 1301 1302
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>
1303

1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317
   <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>
1318 1319 1320 1321
	<entry>box(circle)</entry>
	<entry>box</entry>
	<entry>convert circle to box</entry>
	<entry>box('((0,0),2.0)'::circle)</entry>
1322 1323
       </row>
       <row>
1324 1325 1326 1327
	<entry>box(point,point)</entry>
	<entry>box</entry>
	<entry>convert points to box</entry>
	<entry>box('(0,0)'::point,'(1,1)'::point)</entry>
1328 1329
       </row>
       <row>
1330 1331 1332 1333
	<entry>box(polygon)</entry>
	<entry>box</entry>
	<entry>convert polygon to box</entry>
	<entry>box('((0,0),(1,1),(2,0))'::polygon)</entry>
1334 1335
       </row>
       <row>
1336 1337 1338 1339
	<entry>circle(box)</entry>
	<entry>circle</entry>
	<entry>convert to circle</entry>
	<entry>circle('((0,0),(1,1))'::box)</entry>
1340 1341
       </row>
       <row>
1342 1343 1344 1345
	<entry>circle(point,float8)</entry>
	<entry>circle</entry>
	<entry>convert to circle</entry>
	<entry>circle('(0,0)'::point,2.0)</entry>
1346 1347
       </row>
       <row>
1348 1349 1350 1351
	<entry>lseg(box)</entry>
	<entry>lseg</entry>
	<entry>convert diagonal to lseg</entry>
	<entry>lseg('((-1,0),(1,0))'::box)</entry>
1352 1353
       </row>
       <row>
1354 1355 1356 1357
	<entry>lseg(point,point)</entry>
	<entry>lseg</entry>
	<entry>convert to lseg</entry>
	<entry>lseg('(-1,0)'::point,'(1,0)'::point)</entry>
1358 1359
       </row>
       <row>
1360 1361 1362 1363
	<entry>path(polygon)</entry>
	<entry>point</entry>
	<entry>convert to path</entry>
	<entry>path('((0,0),(1,1),(2,0))'::polygon)</entry>
1364 1365
       </row>
       <row>
1366 1367 1368 1369
	<entry>point(circle)</entry>
	<entry>point</entry>
	<entry>convert to point (center)</entry>
	<entry>point('((0,0),2.0)'::circle)</entry>
1370 1371
       </row>
       <row>
1372 1373 1374 1375
	<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>
1376 1377
       </row>
       <row>
1378 1379 1380 1381
	<entry>point(polygon)</entry>
	<entry>point</entry>
	<entry>center of polygon</entry>
	<entry>point('((0,0),(1,1),(2,0))'::polygon)</entry>
1382 1383
       </row>
       <row>
1384 1385 1386 1387
	<entry>polygon(box)</entry>
	<entry>polygon</entry>
	<entry>convert to polygon with 12 points</entry>
	<entry>polygon('((0,0),(1,1))'::box)</entry>
1388 1389
       </row>
       <row>
1390 1391 1392 1393
	<entry>polygon(circle)</entry>
	<entry>polygon</entry>
	<entry>convert to 12-point polygon</entry>
	<entry>polygon('((0,0),2.0)'::circle)</entry>
1394 1395
       </row>
       <row>
1396 1397 1398 1399
	<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>
1400 1401
       </row>
       <row>
1402 1403 1404 1405
	<entry>polygon(path)</entry>
	<entry>polygon</entry>
	<entry>convert to polygon</entry>
	<entry>polygon('((0,0),(1,1),(2,0))'::path)</entry>
1406 1407 1408 1409 1410
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>
1411

1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425
   <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>
1426 1427 1428 1429
	<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>
1430 1431
       </row>
       <row>
1432 1433 1434 1435
	<entry>revertpoly(polygon)</entry>
	<entry>polygon</entry>
	<entry>convert pre-v6.1 polygon</entry>
	<entry>revertpoly('((0,0),(1,1),(2,0))'::polygon)</entry>
1436 1437
       </row>
       <row>
1438 1439 1440 1441
	<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>
1442 1443
       </row>
       <row>
1444 1445 1446 1447
	<entry>upgradepoly(polygon)</entry>
	<entry>polygon</entry>
	<entry>convert pre-v6.1 polygon</entry>
	<entry>upgradepoly('(0,1,2,0,1,0)'::polygon)</entry>
1448 1449 1450 1451 1452
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>
1453
  </sect1>
1454

1455 1456
  <sect1>
   <title id="cidr-funcs">IP V4 Functions</title>
1457

1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471
   <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>
1472 1473 1474 1475
	<entry>broadcast(cidr)</entry>
	<entry>text</entry>
	<entry>construct broadcast address as text</entry>
	<entry>broadcast('192.168.1.5/24')</entry>
1476 1477
       </row>
       <row>
1478 1479 1480 1481
	<entry>broadcast(inet)</entry>
	<entry>text</entry>
	<entry>construct broadcast address as text</entry>
	<entry>broadcast('192.168.1.5/24')</entry>
1482 1483
       </row>
       <row>
1484 1485 1486 1487
	<entry>host(inet)</entry>
	<entry>text</entry>
	<entry>extract host address as text</entry>
	<entry>host('192.168.1.5/24')</entry>
1488 1489
       </row>
       <row>
1490 1491 1492 1493
	<entry>masklen(cidr)</entry>
	<entry>int4</entry>
	<entry>calculate netmask length</entry>
	<entry>masklen('192.168.1.5/24')</entry>
1494 1495
       </row>
       <row>
1496 1497 1498 1499
	<entry>masklen(inet)</entry>
	<entry>int4</entry>
	<entry>calculate netmask length</entry>
	<entry>masklen('192.168.1.5/24')</entry>
1500 1501
       </row>
       <row>
1502 1503 1504 1505
	<entry>netmask(inet)</entry>
	<entry>text</entry>
	<entry>construct netmask as text</entry>
	<entry>netmask('192.168.1.5/24')</entry>
1506 1507 1508 1509 1510
       </row>
      </tbody>
     </tgroup>
    </table>
   </para>
1511

1512
  </sect1>
1513

1514
 </chapter>
1515

1516 1517
<!-- Keep this comment at the end of the file
Local variables:
Thomas G. Lockhart's avatar
Thomas G. Lockhart committed
1518
mode:sgml
1519
sgml-omittag:nil
1520 1521 1522 1523 1524 1525 1526 1527
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
Thomas G. Lockhart's avatar
Thomas G. Lockhart committed
1528
sgml-local-catalogs:("/usr/lib/sgml/catalog")
1529 1530 1531
sgml-local-ecat-files:nil
End:
-->