Re: record identical operator - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: record identical operator
Date
Msg-id 1379357594.10627.YahooMailNeo@web162906.mail.bf1.yahoo.com
Whole thread Raw
In response to Re: record identical operator  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-hackers
Merlin Moncure <mmoncure@gmail.com> wrote:
> Kevin Grittner <kgrittn@ymail.com> wrote:

>> I don't recall seeing anyone posting regarding the existing
>> undocumented record comparison operators.

> This behavior came about via a gripe of mine (but mostly courtesy
> Tom Lane_:
> http://www.postgresql.org/message-id/6EE64EF3AB31D5448D0007DD34EEB34101AEF5@Herge.rcsinc.local
>
> It brought row-wise comparon closer- (if not exactly to-) SQL
> spec.  The underlying use-case is to do ISAM-like record
> iteration over the index.  "index" being the operative word.

Indeed.  The documented behavior complies with the spec (and is
extremely useful!), but only fully matches the behavior when one of
the arguments is a row value constructor.  The documentation sort
of acknowledges this by describing the arguments not as "row" or
"record", but as "row_constructor".  Comparison operators which
followed those exact rules would not be usable for indexing, so we
have slightly different semantics to support that.  I have no gripe
whatsoever with any of that.  I'm even OK with not documenting this
behavior, since it might do more to confuse than elucidate.  I did
ask the question, because if we choose not to document the behavior
of record comparisons based around the concept of "record equals",
I don't think it makes sense to document record comparisons based
around the concept of "record image equals".  That is the
terminology used in the function names and opfamily, but I have
been using "identical" in discussion, which perhaps has confused
the issue.

If we take documentation of record comparisons farther, we need to
be prepared to explain why this is correct (because it is required
by spec):

test=# select row(1, null::text) = row(1, null::text);
 ?column?
----------
 
(1 row)

... but this is also correct (because otherwise indexes don't
work):

test=# select row(1, null::text) = row(1, null::text)::record;
 ?column?
----------
 t
(1 row)

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



pgsql-hackers by date:

Previous
From: Kevin Grittner
Date:
Subject: Re: record identical operator
Next
From: Josh Berkus
Date:
Subject: Re: git apply vs patch -p1