diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 92c1835ae3e..99f5311fd2d 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -13,7 +13,9 @@
PostgreSQL provides a large number of
- functions and operators for the built-in data types. Users can also
+ functions and operators for the built-in data types. This chapter
+ describes most of them, although additional special-purpose functions
+ appear in relevant sections of the manual. Users can also
define their own functions and operators, as described in
. The
psql commands \df and
@@ -21,6 +23,20 @@
available functions and operators, respectively.
+
+ The notation used throughout this chapter to describe the argument and
+ result data types of a function or operator is like this:
+
+repeat ( text, integer ) text
+
+ which says that the function repeat takes one text and
+ one integer argument and returns a result of type text. The right arrow
+ is also used to indicate the result of an example, thus:
+
+repeat('Pg', 4) PgPgPgPg
+
+
+
If you are concerned about portability then note that most of
the functions and operators described in this chapter, with the
@@ -29,9 +45,7 @@
SQL standard. Some of this extended functionality
is present in other SQL database management
systems, and in many cases this functionality is compatible and
- consistent between the various implementations. This chapter is also
- not exhaustive; additional functions appear in relevant sections of
- the manual.
+ consistent between the various implementations.
@@ -76,11 +90,11 @@
negation
-
- AND
- OR
- NOT
-
+
+boolean AND boolean boolean
+boolean OR boolean boolean
+NOT boolean boolean
+
SQL uses a three-valued logic system with true,
false, and null, which represents unknown
.
@@ -174,10 +188,11 @@
The operators AND and OR are
- commutative, that is, you can switch the left and right operand
- without affecting the result. But see for more information about the
- order of evaluation of subexpressions.
+ order of evaluation of subexpressions.)
@@ -206,33 +221,59 @@
- <
- less than
+
+ datatype < datatype
+ boolean
+
+ Less than
- >
- greater than
+
+ datatype > datatype
+ boolean
+
+ Greater than
- <=
- less than or equal to
+
+ datatype <= datatype
+ boolean
+
+ Less than or equal to
- >=
- greater than or equal to
+
+ datatype >= datatype
+ boolean
+
+ Greater than or equal to
- =
- equal
+
+ datatype = datatype
+ boolean
+
+ Equal
- <> or !=
- not equal
+
+ datatype <> datatype
+ boolean
+
+ Not equal
+
+
+
+
+ datatype != datatype
+ boolean
+
+ Not equal
@@ -240,20 +281,37 @@
- The != operator is converted to
- <> in the parser stage. It is not
- possible to implement != and
- <> operators that do different things.
+ <> is the standard SQL notation for not
+ equal
. != is an alias, which is converted
+ to <> at a very early stage of parsing.
+ Hence, it is not possible to implement !=
+ and <> operators that do different things.
- Comparison operators are available for all relevant data types.
- All comparison operators are binary operators that
- return values of type boolean; expressions like
+ These comparison operators are available for all built-in data types
+ that have a natural ordering, including numeric, string, and date/time
+ types. In addition, arrays, composite types, and ranges can be compared
+ if their component data types are comparable.
+
+
+
+ It is usually possible to compare values of related data
+ types as well; for example integer >
+ bigint will work. Some cases of this sort are implemented
+ directly by cross-type
comparison operators, but if no
+ such operator is available, the parser will coerce the less-general type
+ to the more-general type and apply the latter's comparison operator.
+
+
+
+ As shown above, all comparison operators are binary operators that
+ return values of type boolean. Thus, expressions like
1 < 2 < 3 are not valid (because there is
no < operator to compare a Boolean value with
- 3).
+ 3). Use the BETWEEN predicates
+ shown below to perform range tests.
@@ -264,93 +322,227 @@
Comparison Predicates
-
+
- Predicate
- Description
+
+ PredicateDescriptionExample(s)
+
- a BETWEEN x AND y
- between
+
+ datatype BETWEEN datatype AND datatype
+ boolean
+
+ Between (inclusive of the range endpoints).
+
+ 2 BETWEEN 1 AND 3
+ t
+
+ 2 BETWEEN 3 AND 1
+ f
+
- a NOT BETWEEN x AND y
- not between
+
+ datatype NOT BETWEEN datatype AND datatype
+ boolean
+
+ Not between (the negation of BETWEEN).
+
+ 2 NOT BETWEEN 1 AND 3
+ f
+
- a BETWEEN SYMMETRIC x AND y
- between, after sorting the comparison values
+
+ datatype BETWEEN SYMMETRIC datatype AND datatype
+ boolean
+
+ Between, after sorting the two endpoint values.
+
+ 2 BETWEEN SYMMETRIC 3 AND 1
+ t
+
- a NOT BETWEEN SYMMETRIC x AND y
- not between, after sorting the comparison values
+
+ datatype NOT BETWEEN SYMMETRIC datatype AND datatype
+ boolean
+
+ Not between, after sorting the two endpoint values.
+
+ 2 NOT BETWEEN SYMMETRIC 3 AND 1
+ f
+
- a IS DISTINCT FROM b
- not equal, treating null like an ordinary value
+
+ datatype IS DISTINCT FROM datatype
+ boolean
+
+ Not equal, treating null as a comparable value.
+
+ 1 IS DISTINCT FROM NULL
+ t (rather than NULL)
+
+ NULL IS DISTINCT FROM NULL
+ f (rather than NULL)
+
- a IS NOT DISTINCT FROM b
- equal, treating null like an ordinary value
+
+ datatype IS NOT DISTINCT FROM datatype
+ boolean
+
+ Equal, treating null as a comparable value.
+
+ 1 IS NOT DISTINCT FROM NULL
+ f (rather than NULL)
+
+ NULL IS NOT DISTINCT FROM NULL
+ t (rather than NULL)
+
- expression IS NULL
- is null
+
+ datatype IS NULL
+ boolean
+
+ Test whether value is null.
+
+ 1.5 IS NULL
+ f
+
- expression IS NOT NULL
- is not null
+
+ datatype IS NOT NULL
+ boolean
+
+ Test whether value is not null.
+
+ 'null' IS NOT NULL
+ t
+
- expression ISNULL
- is null (nonstandard syntax)
+
+ datatype ISNULL
+ boolean
+
+ Test whether value is null (nonstandard syntax).
+
- expression NOTNULL
- is not null (nonstandard syntax)
+
+ datatype NOTNULL
+ boolean
+
+ Test whether value is not null (nonstandard syntax).
+
- boolean_expression IS TRUE
- is true
+
+ boolean IS TRUE
+ boolean
+
+ Test whether boolean expression yields true.
+
+ true IS TRUE
+ t
+
+ NULL::boolean IS TRUE
+ f (rather than NULL)
+
- boolean_expression IS NOT TRUE
- is false or unknown
+
+ boolean IS NOT TRUE
+ boolean
+
+ Test whether boolean expression yields false or unknown.
+
+ true IS NOT TRUE
+ f
+
+ NULL::boolean IS NOT TRUE
+ t (rather than NULL)
+
- boolean_expression IS FALSE
- is false
+
+ boolean IS FALSE
+ boolean
+
+ Test whether boolean expression yields false.
+
+ true IS FALSE
+ f
+
+ NULL::boolean IS FALSE
+ f (rather than NULL)
+
- boolean_expression IS NOT FALSE
- is true or unknown
+
+ boolean IS NOT FALSE
+ boolean
+
+ Test whether boolean expression yields true or unknown.
+
+ true IS NOT FALSE
+ t
+
+ NULL::boolean IS NOT FALSE
+ t (rather than NULL)
+
- boolean_expression IS UNKNOWN
- is unknown
+
+ boolean IS UNKNOWN
+ boolean
+
+ Test whether boolean expression yields unknown.
+
+ true IS UNKNOWN
+ f
+
+ NULL::boolean IS UNKNOWN
+ t (rather than NULL)
+
- boolean_expression IS NOT UNKNOWN
- is true or false
+
+ boolean IS NOT UNKNOWN
+ boolean
+
+ Test whether boolean expression yields true or false.
+
+ true IS NOT UNKNOWN
+ t
+
+ NULL::boolean IS NOT UNKNOWN
+ f (rather than NULL)
+
@@ -360,6 +552,9 @@
BETWEEN
+
+ BETWEEN SYMMETRIC
+
The BETWEEN predicate simplifies range tests:
a BETWEEN x AND y
@@ -370,17 +565,6 @@
Notice that BETWEEN treats the endpoint values as included
in the range.
- NOT BETWEEN does the opposite comparison:
-
-a NOT BETWEEN x AND y
-
- is equivalent to
-
-a < x OR a > y
-
-
- BETWEEN SYMMETRIC
-
BETWEEN SYMMETRIC is like BETWEEN
except there is no requirement that the argument to the left of
AND be less than or equal to the argument on the right.
@@ -388,6 +572,24 @@
a nonempty range is always implied.
+
+ The various variants of BETWEEN are implemented in
+ terms of the ordinary comparison operators, and therefore will work for
+ any data type(s) that can be compared.
+
+
+
+
+ The use of AND in the BETWEEN
+ syntax creates an ambiguity with the use of AND as a
+ logical operator. To resolve this, only a limited set of expression
+ types are allowed as the second argument of a BETWEEN
+ clause. If you need to write a more complex sub-expression
+ in BETWEEN, write parentheses around the
+ sub-expression.
+
+
+
IS DISTINCT FROM
@@ -541,37 +743,43 @@
Comparison Functions
-
+
- Function
- Description
- Example
- Example Result
+
+ FunctionDescriptionExample(s)
+
+
-
-
- num_nonnulls
-
- num_nonnulls(VARIADIC "any")
+
+
+ num_nonnulls
+
+ num_nonnulls ( VARIADIC "any" )
+ integer
+
+ Returns the number of non-null arguments.
+
+ num_nonnulls(1, NULL, 2)
+ 2
- returns the number of non-null arguments
- num_nonnulls(1, NULL, 2)
- 2
-
-
- num_nulls
-
- num_nulls(VARIADIC "any")
+
+
+ num_nulls
+
+ num_nulls ( VARIADIC "any" )
+ integer
+
+ Returns the number of null arguments.
+
+ num_nulls(1, NULL, 2)
+ 1
- returns the number of null arguments
- num_nulls(1, NULL, 2)
- 1
@@ -591,160 +799,290 @@
- shows the available mathematical operators.
+ shows the mathematical
+ operators that are available for the standard numeric types.
+ Unless otherwise noted, operators shown as
+ accepting numeric_type are available for all
+ the types smallint, integer,
+ bigint, numeric, real,
+ and double precision.
+ Operators shown as accepting integral_type
+ are available for the types smallint, integer,
+ and bigint.
+ Operators shown as accepting numeric_or_dp
+ are available for the types numeric and double
+ precision.
+ Except where noted, each form of an operator returns the same data type
+ as its argument(s). Calls involving multiple argument data types, such
+ as integer + numeric,
+ are resolved by using the type appearing later in these lists.
Mathematical Operators
-
+
- Operator
- Description
- Example
- Result
+
+ OperatorDescriptionExample(s)
+
- +
- addition
- 2 + 3
- 5
+
+ numeric_type + numeric_type
+ numeric_type
+
+ Addition
+
+ 2 + 3
+ 5
+
- -
- subtraction
- 2 - 3
- -1
+
+ + numeric_type
+ numeric_type
+
+ Unary plus (no operation)
+
+ + 3.5
+ 3.5
+
- *
- multiplication
- 2 * 3
- 6
+
+ numeric_type - numeric_type
+ numeric_type
+
+ Subtraction
+
+ 2 - 3
+ -1
+
- /
- division (integer division truncates the result)
- 4 / 2
- 2
+
+ - numeric_type
+ numeric_type
+
+ Negation
+
+ - (-4)
+ 4
+
- %
- modulo (remainder)
- 5 % 4
- 1
+
+ numeric_type * numeric_type
+ numeric_type
+
+ Multiplication
+
+ 2 * 3
+ 6
+
- ^
- exponentiation (associates left to right)
- 2.0 ^ 3.0
- 8
+
+ numeric_type / numeric_type
+ numeric_type
+
+ Division (for integral types, division truncates the result towards
+ zero)
+
+ 5.0 / 2
+ 2.5000000000000000
+
+ 5 / 2
+ 2
+
+ (-5) / 2
+ -2
+
- |/
- square root
- |/ 25.0
- 5
+
+ numeric_type % numeric_type
+ numeric_type
+
+ Modulo (remainder); available for smallint,
+ integer, bigint, and numeric
+
+ 5 % 4
+ 1
+
- ||/
- cube root
- ||/ 27.0
- 3
+
+ numeric_or_dp ^ numeric_or_dp
+ numeric_or_dp
+
+ Exponentiation (unlike typical mathematical practice, multiple uses of
+ ^ will associate left to right)
+
+ 2 ^ 3
+ 8
+
+ 2 ^ 3 ^ 3
+ 512
+
- !
- factorial
- 5 !
- 120
+
+ |/ double precision
+ double precision
+
+ Square root
+
+ |/ 25.0
+ 5
+
- !!
- factorial (prefix operator)
- !! 5
- 120
+
+ ||/ double precision
+ double precision
+
+ Cube root
+
+ ||/ 64.0
+ 4
+
- @
- absolute value
- @ -5.0
- 5
+
+ bigint !
+ numeric
+
+ Factorial
+
+ 5 !
+ 120
+
- &
- bitwise AND
- 91 & 15
- 11
+
+ !! bigint
+ numeric
+
+ Factorial (as a prefix operator)
+
+ !! 5
+ 120
+
- |
- bitwise OR
- 32 | 3
- 35
+
+ @ numeric_type
+ numeric_type
+
+ Absolute value
+
+ @ -5.0
+ 5
+
- #
- bitwise XOR
- 17 # 5
- 20
+
+ integral_type & integral_type
+ integral_type
+
+ Bitwise AND
+
+ 91 & 15
+ 11
+
- ~
- bitwise NOT
- ~1
- -2
+
+ integral_type | integral_type
+ integral_type
+
+ Bitwise OR
+
+ 32 | 3
+ 35
+
- <<
- bitwise shift left
- 1 << 4
- 16
+
+ integral_type # integral_type
+ integral_type
+
+ Bitwise exclusive OR
+
+ 17 # 5
+ 20
+
- >>
- bitwise shift right
- 8 >> 2
- 2
+
+ ~ integral_type
+ integral_type
+
+ Bitwise NOT
+
+ ~1
+ -2
+
+
+
+
+
+ integral_type << integer
+ integral_type
+
+ Bitwise shift left
+
+ 1 << 4
+ 16
+
+
+
+
+
+ integral_type >> integer
+ integral_type
+
+ Bitwise shift right
+
+ 8 >> 2
+ 2
+
-
- The bitwise operators work only on integral data types and are also
- available for the bit
- string types bit and bit varying, as
- shown in .
-
-
shows the available
- mathematical functions. In the table, dp
- indicates double precision. Many of these functions
- are provided in multiple forms with different argument types.
+ mathematical functions.
+ Many of these functions are provided in multiple forms with different
+ argument types.
Except where noted, any given form of a function returns the same
- data type as its argument.
+ data type as its argument(s); cross-type cases are resolved in the
+ same way as explained above for operators.
The functions working with double precision data are mostly
implemented on top of the host system's C library; accuracy and behavior in
boundary cases can therefore vary depending on the host system.
@@ -752,415 +1090,478 @@
Mathematical Functions
-
+
- Function
- Return Type
- Description
- Example
- Result
+
+ FunctionDescriptionExample(s)
+
-
+
abs
- abs(x)
+ abs ( numeric_type )
+ numeric_type
+
+ Absolute value
+
+ abs(-17.4)
+ 17.4
- (same as input)
- absolute value
- abs(-17.4)
- 17.4
-
+
cbrt
- cbrt(dp)
+ cbrt ( double precision )
+ double precision
+
+ Cube root
+
+ cbrt(64.0)
+ 4
- dp
- cube root
- cbrt(27.0)
- 3
-
+
ceil
- ceil(dp or numeric)
+ ceil ( numeric_or_dp )
+ numeric_or_dp
+
+ Nearest integer greater than or equal to argument
+
+ ceil(42.2)
+ 43
+
+ ceil(-42.8)
+ -42
- (same as input)
- nearest integer greater than or equal to argument
- ceil(-42.8)
- -42
-
+
ceiling
- ceiling(dp or numeric)
+ ceiling ( numeric_or_dp )
+ numeric_or_dp
+
+ Nearest integer greater than or equal to argument (same
+ as ceil)
+
+ ceiling(95.3)
+ 96
- (same as input)
- nearest integer greater than or equal to argument (same as ceil)
- ceiling(-95.3)
- -95
-
+
degrees
- degrees(dp)
+ degrees ( double precision )
+ double precision
+
+ Converts radians to degrees
+
+ degrees(0.5)
+ 28.64788975654116
- dp
- radians to degrees
- degrees(0.5)
- 28.6478897565412
-
+
div
- div(y numeric,
- x numeric)
+ div ( y numeric,
+ x numeric )
+ numeric
+
+ Integer quotient of y/x
+ (truncates towards zero)
+
+ div(9,4)
+ 2
- numeric
- integer quotient of y/x
- div(9,4)
- 2
-
+
exp
- exp(dp or numeric)
+ exp ( numeric_or_dp )
+ numeric_or_dp
+
+ Exponential (e raised to the given power)
+
+ exp(1.0)
+ 2.7182818284590452
- (same as input)
- exponential
- exp(1.0)
- 2.71828182845905
-
+
floor
- floor(dp or numeric)
+ floor ( numeric_or_dp )
+ numeric_or_dp
+
+ Nearest integer less than or equal to argument
+
+ floor(42.8)
+ 42
+
+ floor(-42.8)
+ -43
- (same as input)
- nearest integer less than or equal to argument
- floor(-42.8)
- -43
-
+
gcd
- gcd(a, b)
-
- (same as argument types)
-
- greatest common divisor (the largest positive number that divides both
+ gcd ( numeric_type, numeric_type )
+ numeric_type
+
+ Greatest common divisor (the largest positive number that divides both
inputs with no remainder); returns 0 if both inputs
- are zero
+ are zero; available for integer, bigint,
+ and numeric
+
+ gcd(1071, 462)
+ 21
- gcd(1071, 462)
- 21
-
+
lcm
- lcm(a, b)
-
- (same as argument types)
-
- least common multiple (the smallest strictly positive number that is
+ lcm ( numeric_type, numeric_type )
+ numeric_type
+
+ Least common multiple (the smallest strictly positive number that is
an integral multiple of both inputs); returns 0 if
- either input is zero
+ either input is zero; available for integer,
+ bigint, and numeric
+
+ lcm(1071, 462)
+ 23562
- lcm(1071, 462)
- 23562
-
+
ln
- ln(dp or numeric)
+ ln ( numeric_or_dp )
+ numeric_or_dp
+
+ Natural logarithm
+
+ ln(2.0)
+ 0.6931471805599453
- (same as input)
- natural logarithm
- ln(2.0)
- 0.693147180559945
-
+
log
- log(dp or numeric)
+ log ( numeric_or_dp )
+ numeric_or_dp
+
+ Base 10 logarithm
+
+ log(100)
+ 2
- (same as input)
- base 10 logarithm
- log(100.0)
- 2
-
+
log10
- log10(dp or numeric)
+ log10 ( numeric_or_dp )
+ numeric_or_dp
+
+ Base 10 logarithm (same as log)
+
+ log10(1000)
+ 3
- (same as input)
- base 10 logarithm
- log10(100.0)
- 2
- log(b numeric,
- x numeric)
- numeric
- logarithm to base b
- log(2.0, 64.0)
- 6.0000000000
+
+ log ( b numeric,
+ x numeric )
+ numeric
+
+ Logarithm of x to base b
+
+ log(2.0, 64.0)
+ 6.0000000000
+
-
+
min_scale
- min_scale(numeric)
+ min_scale ( numeric )
+ integer
+
+ Minimum scale (number of fractional decimal digits) needed
+ to represent the supplied value precisely
+
+ min_scale(8.4100)
+ 2
- integer
- minimum scale (number of fractional decimal digits) needed
- to represent the supplied value
- min_scale(8.4100)
- 2
-
+
mod
- mod(y,
- x)
+ mod ( y numeric_type,
+ x numeric_type )
+ numeric_type
+
+ Remainder of y/x;
+ available for smallint, integer,
+ bigint, and numeric
+
+ mod(9,4)
+ 1
- (same as argument types)
- remainder of y/x
- mod(9,4)
- 1
-
+
pi
- pi()
+ pi ( )
+ double precision
+
+ Approximate value of π
+
+ pi()
+ 3.141592653589793
- dp
- π
constant
- pi()
- 3.14159265358979
-
+
power
- power(a dp,
- b dp)
+ power ( a numeric_or_dp,
+ b numeric_or_dp )
+ numeric_or_dp
+
+ a raised to the power of b
+
+ power(9, 3)
+ 729
- dp
- a raised to the power of b
- power(9.0, 3.0)
- 729
- power(a numeric,
- b numeric)
- numeric
- a raised to the power of b
- power(9.0, 3.0)
- 729
-
-
-
-
+
radians
- radians(dp)
+ radians ( double precision )
+ double precision
+
+ Converts degrees to radians
+
+ radians(45.0)
+ 0.7853981633974483
- dp
- degrees to radians
- radians(45.0)
- 0.785398163397448
-
+
round
- round(dp or numeric)
+ round ( numeric_or_dp )
+ numeric_or_dp
+
+ Rounds to nearest integer
+
+ round(42.4)
+ 42
- (same as input)
- round to nearest integer
- round(42.4)
- 42
- round(v numeric, s int)
- numeric
- round to s decimal places
- round(42.4382, 2)
- 42.44
+
+ round ( v numeric, s integer )
+ numeric
+
+ Rounds v to s decimal
+ places
+
+ round(42.4382, 2)
+ 42.44
+
-
+
scale
- scale(numeric)
+ scale ( numeric )
+ integer
+
+ Scale of the argument (the number of decimal digits in the fractional part)
+
+ scale(8.4100)
+ 4
- integer
- scale of the argument (the number of decimal digits in the fractional part)
- scale(8.4100)
- 4
-
+
sign
- sign(dp or numeric)
+ sign ( numeric_or_dp )
+ numeric_or_dp
+
+ Sign of the argument (-1, 0, or +1)
+
+ sign(-8.4)
+ -1
- (same as input)
- sign of the argument (-1, 0, +1)
- sign(-8.4)
- -1
-
+
sqrt
- sqrt(dp or numeric)
+ sqrt ( numeric_or_dp )
+ numeric_or_dp
+
+ Square root
+
+ sqrt(2)
+ 1.4142135623730951
- (same as input)
- square root
- sqrt(2.0)
- 1.4142135623731
-
+
trim_scale
- trim_scale(numeric)
+ trim_scale ( numeric )
+ numeric
+
+ Reduces the value's scale (number of fractional decimal digits) by
+ removing trailing zeroes
+
+ trim_scale(8.4100)
+ 8.41
- numeric
- reduce the scale (number of fractional decimal digits) by
- removing trailing zeroes
- trim_scale(8.4100)
- 8.41
-
+
trunc
- trunc(dp or numeric)
+ trunc ( numeric_or_dp )
+ numeric_or_dp
+
+ Truncates to integer (towards zero)
+
+ trunc(42.8)
+ 42
+
+ trunc(-42.8)
+ -42
- (same as input)
- truncate toward zero
- trunc(42.8)
- 42
- trunc(v numeric, s int)
- numeric
- truncate to s decimal places
- trunc(42.4382, 2)
- 42.43
+
+ trunc ( v numeric, s integer )
+ numeric
+
+ Truncates v to s
+ decimal places
+
+ trunc(42.4382, 2)
+ 42.43
+
-
+
width_bucket
- width_bucket(operand dp, b1 dp, b2 dp, count int)
- int
- return the bucket number to which operand would
- be assigned in a histogram having count equal-width
- buckets spanning the range b1 to b2;
- returns 0 or count+1 for
- an input outside the range
- width_bucket(5.35, 0.024, 10.06, 5)
- 3
+ width_bucket ( operand numeric_or_dp, low numeric_or_dp, high numeric_or_dp, count integer )
+ integer
+
+ Returns the number of the bucket in
+ which operand falls in a histogram
+ having count equal-width buckets spanning the
+ range low to high.
+ Returns 0
+ or count+1 for an input
+ outside that range.
+
+ width_bucket(5.35, 0.024, 10.06, 5)
+ 3
+
- width_bucket(operand numeric, b1 numeric, b2 numeric, count int)
- int
- return the bucket number to which operand would
- be assigned in a histogram having count equal-width
- buckets spanning the range b1 to b2;
- returns 0 or count+1 for
- an input outside the range
- width_bucket(5.35, 0.024, 10.06, 5)
- 3
-
-
-
- width_bucket(operand anyelement, thresholds anyarray)
- int
- return the bucket number to which operand would
- be assigned given an array listing the lower bounds of the buckets;
- returns 0 for an input less than the first lower bound;
- the thresholds array must be sorted,
- smallest first, or unexpected results will be obtained
- width_bucket(now(), array['yesterday', 'today', 'tomorrow']::timestamptz[])
- 2
+
+ width_bucket ( operand anyelement, thresholds anyarray )
+ integer
+
+ Returns the number of the bucket in
+ which operand falls given an array listing the
+ lower bounds of the buckets. Returns 0 for an
+ input less than the first lower
+ bound. operand and the array elements can be
+ of any type having standard comparison operators.
+ The thresholds array must be
+ sorted, smallest first, or unexpected results will be
+ obtained.
+
+ width_bucket(now(), array['yesterday', 'today', 'tomorrow']::timestamptz[])
+ 2
+
@@ -1174,36 +1575,44 @@
Random Functions
-
+
- Function
- Return Type
- Description
+
+ FunctionDescriptionExample(s)
+
+
-
+
random
- random()
+ random ( )
+ double precision
+
+ Returns a random value in the range 0.0 <= x < 1.0
+
+ random()
+ 0.897124072839091
- dp
- random value in the range 0.0 <= x < 1.0
-
+
setseed
- setseed(dp)
+ setseed ( double precision )
+ void
+
+ Sets the seed for subsequent random() calls;
+ argument must be between -1.0 and 1.0, inclusive
+
+ setseed(0.12345)
- void
- set seed for subsequent random() calls (value between -1.0 and
- 1.0, inclusive)
@@ -1214,17 +1623,15 @@
congruential algorithm. It is fast but not suitable for cryptographic
applications; see the module for a more
secure alternative.
- If setseed() is called, the results of
- subsequent random() calls in the current session are
- repeatable by re-issuing setseed() with the same
+ If setseed() is called, the series of results of
+ subsequent random() calls in the current session
+ can be repeated by re-issuing setseed() with the same
argument.
shows the
- available trigonometric functions. All these functions
- take arguments and return values of type double
- precision. Each of the trigonometric functions comes in
+ available trigonometric functions. Each of these functions comes in
two variants, one that measures angles in radians and one that
measures angles in degrees.
@@ -1232,143 +1639,260 @@
Trigonometric Functions
-
+
- Function (radians)
- Function (degrees)
- Description
+
+ FunctionDescriptionExample(s)
+
-
+
acos
- acos(x)
+
+ acos ( double precision )
+ double precision
+
+ Inverse cosine, result in radians
+
+ acos(1)
+ 0
-
-
- acosd
- acosd(x)
-
- inverse cosine
-
+
+
+ acosd
+
+ acosd ( double precision )
+ double precision
+
+ Inverse cosine, result in degrees
+
+ acosd(0.5)
+ 60
+
+
+
+
+
asin
- asin(x)
+ asin ( double precision )
+ double precision
+
+ Inverse sine, result in radians
+
+ asin(1)
+ 1.5707963267948966
-
+
+
+
+
asind
- asind(x)
+ asind ( double precision )
+ double precision
+
+ Inverse sine, result in degrees
+
+ asind(0.5)
+ 30
- inverse sine
-
+
atan
- atan(x)
+ atan ( double precision )
+ double precision
+
+ Inverse tangent, result in radians
+
+ atan(1)
+ 0.7853981633974483
-
+
+
+
+
atand
- atand(x)
+ atand ( double precision )
+ double precision
+
+ Inverse tangent, result in degrees
+
+ atand(1)
+ 45
- inverse tangent
-
+
atan2
- atan2(y,
- x)
+ atan2 ( y double precision,
+ x double precision )
+ double precision
+
+ Inverse tangent of
+ y/x,
+ result in radians
+
+ atan2(1,0)
+ 1.5707963267948966
-
+
+
+
+
atan2d
- atan2d(y,
- x)
+ atan2d ( y double precision,
+ x double precision )
+ double precision
+
+ Inverse tangent of
+ y/x,
+ result in degrees
+
+ atan2d(1,0)
+ 90
- inverse tangent of
- y/x
-
+
cos
- cos(x)
+ cos ( double precision )
+ double precision
+
+ Cosine, argument in radians
+
+ cos(0)
+ 1
-
+
+
+
+
cosd
- cosd(x)
+ cosd ( double precision )
+ double precision
+
+ Cosine, argument in degrees
+
+ cosd(60)
+ 0.5
- cosine
-
+
cot
- cot(x)
+ cot ( double precision )
+ double precision
+
+ Cotangent, argument in radians
+
+ cot(0.5)
+ 1.830487721712452
-
+
+
+
+
cotd
- cotd(x)
+ cotd ( double precision )
+ double precision
+
+ Cotangent, argument in degrees
+
+ cotd(45)
+ 1
- cotangent
-
+
sin
- sin(x)
+ sin ( double precision )
+ double precision
+
+ Sine, argument in radians
+
+ sin(1)
+ 0.8414709848078965
-
-
- sind
-
- sind(x)
-
- sine
-
+
+
+ sind
+
+ sind ( double precision )
+ double precision
+
+ Sine, argument in degrees
+
+ sind(30)
+ 0.5
+
+
+
+
+
tan
- tan(x)
+ tan ( double precision )
+ double precision
+
+ Tangent, argument in radians
+
+ tan(1)
+ 1.5574077246549023
-
+
+
+
+
tand
- tand(x)
+ tand ( double precision )
+ double precision
+
+ Tangent, argument in degrees
+
+ tand(45)
+ 1
- tangent
@@ -1387,89 +1911,110 @@
shows the
- available hyperbolic functions. All these functions
- take arguments and return values of type double
- precision.
+ available hyperbolic functions.
Hyperbolic Functions
-
+
- Function
- Description
- Example
- Result
+
+ FunctionDescriptionExample(s)
+
+
-
+
sinh
- sinh(x)
+ sinh ( double precision )
+ double precision
+
+ Hyperbolic sine
+
+ sinh(1)
+ 1.1752011936438014
- hyperbolic sine
- sinh(0)
- 0
+
-
+
cosh
- cosh(x)
+ cosh ( double precision )
+ double precision
+
+ Hyperbolic cosine
+
+ cosh(0)
+ 1
- hyperbolic cosine
- cosh(0)
- 1
+
-
+
tanh
- tanh(x)
+ tanh ( double precision )
+ double precision
+
+ Hyperbolic tangent
+
+ tanh(1)
+ 0.7615941559557649
- hyperbolic tangent
- tanh(0)
- 0
+
-
+
asinh
- asinh(x)
+ asinh ( double precision )
+ double precision
+
+ Inverse hyperbolic sine
+
+ asinh(1)
+ 0.881373587019543
- inverse hyperbolic sine
- asinh(0)
- 0
+
-
+
acosh
- acosh(x)
+ acosh ( double precision )
+ double precision
+
+ Inverse hyperbolic cosine
+
+ acosh(1)
+ 0
- inverse hyperbolic cosine
- acosh(1)
- 0
+
-
+
atanh
- atanh(x)
+ atanh ( double precision )
+ double precision
+
+ Inverse hyperbolic tangent
+
+ atanh(0.5)
+ 0.5493061443340548
- inverse hyperbolic tangent
- atanh(0)
- 0
diff --git a/doc/src/sgml/stylesheet-common.xsl b/doc/src/sgml/stylesheet-common.xsl
index 105ed1ce265..b772f876c17 100644
--- a/doc/src/sgml/stylesheet-common.xsl
+++ b/doc/src/sgml/stylesheet-common.xsl
@@ -50,10 +50,8 @@
-
- →
-
-
+
+→