pgsql: Add record_image_ops opclass for matview concurrent refresh.

Started by Kevin Grittnerover 12 years ago2 messages
#1Kevin Grittner
kgrittn@postgresql.org

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.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/f566515192461acd8d9c232f48ddac3fc965cfd8

Modified Files
--------------
contrib/citext/expected/citext.out | 41 +++
contrib/citext/expected/citext_1.out | 41 +++
contrib/citext/sql/citext.sql | 23 ++
doc/src/sgml/func.sgml | 111 +++++--
src/backend/commands/matview.c | 10 +-
src/backend/utils/adt/rowtypes.c | 494 ++++++++++++++++++++++++++++++
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_amop.h | 10 +
src/include/catalog/pg_amproc.h | 1 +
src/include/catalog/pg_opclass.h | 1 +
src/include/catalog/pg_operator.h | 14 +
src/include/catalog/pg_opfamily.h | 1 +
src/include/catalog/pg_proc.h | 12 +-
src/include/utils/builtins.h | 7 +
src/test/regress/expected/matview.out | 22 +-
src/test/regress/expected/opr_sanity.out | 7 +-
src/test/regress/sql/matview.sql | 15 +-
17 files changed, 775 insertions(+), 37 deletions(-)

--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers

#2Kevin Grittner
kgrittn@ymail.com
In reply to: Kevin Grittner (#1)
1 attachment(s)
Re: [COMMITTERS] pgsql: Add record_image_ops opclass for matview concurrent refresh.

Kevin Grittner <kgrittn@postgresql.org> wrote:

Add record_image_ops opclass for matview concurrent refresh.

The buildfarm pointed out that I had not handled pass-by-value data
types correctly.  Fixed based on advice from Robert.  We'll see
whether that clears up the part of the buildfarm breakage
attributed to this patch.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Attachments:

record_image_ops-byvalue.difftext/x-diff; name=record_image_ops-byvalue.diffDownload
diff --git a/src/backend/utils/adt/rowtypes.c b/src/backend/utils/adt/rowtypes.c
index 0bcbb5d..7925ce2 100644
--- a/src/backend/utils/adt/rowtypes.c
+++ b/src/backend/utils/adt/rowtypes.c
@@ -1464,9 +1464,8 @@ record_image_cmp(PG_FUNCTION_ARGS)
 			}
 			else if (tupdesc1->attrs[i1]->attbyval)
 			{
-				cmpresult = memcmp(&(values1[i1]),
-								   &(values2[i2]),
-								   tupdesc1->attrs[i1]->attlen);
+				if (values1[i1] != values2[i2])
+					cmpresult = (values1[i1] < values2[i2]) ? -1 : 1;
 			}
 			else
 			{
@@ -1695,9 +1694,7 @@ record_image_eq(PG_FUNCTION_ARGS)
 			}
 			else if (tupdesc1->attrs[i1]->attbyval)
 			{
-				result = (memcmp(&(values1[i1]),
-								 &(values2[i2]),
-								 tupdesc1->attrs[i1]->attlen) == 0);
+				result = (values1[i1] == values2[i2]);
 			}
 			else
 			{