From f566515192461acd8d9c232f48ddac3fc965cfd8 Mon Sep 17 00:00:00 2001 From: Kevin Grittner Date: Wed, 9 Oct 2013 14:26:09 -0500 Subject: Add record_image_ops opclass for matview concurrent refresh. REFRESH MATERIALIZED VIEW CONCURRENTLY was broken for any matview containing a column of a type without a default btree operator class. It also did not produce results consistent with a non- concurrent REFRESH or a normal view if any column was of a type which allowed user-visible differences between values which compared as equal according to the type's default btree opclass. Concurrent matview refresh was modified to use the new operators to solve these problems. Documentation was added for record comparison, both for the default btree operator class for record, and the newly added operators. Regression tests now check for proper behavior both for a matview with a box column and a matview containing a citext column. Reviewed by Steve Singer, who suggested some of the doc language. --- doc/src/sgml/func.sgml | 111 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 85 insertions(+), 26 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 7dd1ef2ea15..c3090dd2b9f 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -12739,7 +12739,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2); See for details about the meaning - of a row-wise comparison. + of a row constructor comparison. @@ -12795,12 +12795,12 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2); See for details about the meaning - of a row-wise comparison. + of a row constructor comparison. - Row-wise Comparison + Single-row Comparison comparison @@ -12823,7 +12823,7 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2); See for details about the meaning - of a row-wise comparison. + of a row constructor comparison. @@ -12852,13 +12852,23 @@ WHERE EXISTS (SELECT 1 FROM tab2 WHERE col2 = tab1.col2); SOME + + composite type + comparison + + row-wise comparison comparison - row-wise + composite type + + + + comparison + row constructor @@ -13023,7 +13033,7 @@ AND - Row-wise Comparison + Row Constructor Comparison row_constructor operator row_constructor @@ -13033,20 +13043,25 @@ AND Each side is a row constructor, as described in . The two row values must have the same number of fields. - Each side is evaluated and they are compared row-wise. Row comparisons - are allowed when the operator is + Each side is evaluated and they are compared row-wise. Row constructor + comparisons are allowed when the operator is =, <>, <, <=, > or - >=, - or has semantics similar to one of these. (To be specific, an operator - can be a row comparison operator if it is a member of a B-tree operator - class, or is the negator of the = member of a B-tree operator - class.) + >=. + Every row element must be of a type which has a default B-tree operator + class or the attempted comparison may generate an error. + + + Errors related to the number or types of elements might not occur if + the comparison is resolved using earlier columns. + + + The = and <> cases work slightly differently from the others. Two rows are considered @@ -13104,20 +13119,64 @@ AND be either true or false, never null. - - - The SQL specification requires row-wise comparison to return NULL if the - result depends on comparing two NULL values or a NULL and a non-NULL. - PostgreSQL does this only when comparing the - results of two row constructors or comparing a row constructor to the - output of a subquery (as in ). - In other contexts where two composite-type values are compared, two - NULL field values are considered equal, and a NULL is considered larger - than a non-NULL. This is necessary in order to have consistent sorting - and indexing behavior for composite types. - - + + + Composite Type Comparison + + +record operator record + + + + The SQL specification requires row-wise comparison to return NULL if the + result depends on comparing two NULL values or a NULL and a non-NULL. + PostgreSQL does this only when comparing the + results of two row constructors (as in + ) or comparing a row constructor + to the output of a subquery (as in ). + In other contexts where two composite-type values are compared, two + NULL field values are considered equal, and a NULL is considered larger + than a non-NULL. This is necessary in order to have consistent sorting + and indexing behavior for composite types. + + + + Each side is evaluated and they are compared row-wise. Composite type + comparisons are allowed when the operator is + =, + <>, + <, + <=, + > or + >=, + or has semantics similar to one of these. (To be specific, an operator + can be a row comparison operator if it is a member of a B-tree operator + class, or is the negator of the = member of a B-tree operator + class.) The default behavior of the above operators is the same as for + IS [ NOT ] DISTINCT FROM for row constructors (see + ). + + + + To support matching of rows which include elements without a default + B-tree operator class, the following operators are defined for composite + type comparison: + *=, + *<>, + *<, + *<=, + *>, and + *>=. + These operators compare the internal binary representation of the two + rows. Two rows might have a different binary representation even + though comparisons of the two rows with the equality operator is true. + The ordering of rows under these comparision operators is deterministic + but not otherwise meaningful. These operators are used internally for + materialized views and might be useful for other specialized purposes + such as replication but are not intended to be generally useful for + writing queries. + -- cgit v1.2.3