Re: record datatype comparisons - Mailing list pgsql-sql

From Andrew Sullivan
Subject Re: record datatype comparisons
Date
Msg-id 20061101143235.GB25856@phlogiston.dyndns.org
Whole thread Raw
In response to Re: record datatype comparisons  (Volkan YAZICI <yazicivo@ttnet.net.tr>)
List pgsql-sql
On Tue, Oct 31, 2006 at 11:58:08PM +0200, Volkan YAZICI wrote:
> On Oct 31 06:49, Alvaro Herrera wrote:
> > > select 
> > >   (select (1,2)) 
> > > is distinct from 
> > >   (select (1,2)) 
> > > ;

> > alvherre=# select
> >   row(1,2)
> > is distinct from
> >   row(1,2)
> 
> What's the difference between "SELECT (1, 2);" and "SELECT ROW(1, 2);"?

It's not the difference between SELECT (1,2) and SELECT ROW(1,2)
that's relevant, but the difference between SELECT (SELECT (1,2)) and
SELECT ROW(1,2).  

The row's datatype(s) is(are) defined.  The record's datatype isn't. 
So you can have an equality operator for the row.  You can see this
from the error message when you do this:

testing=# SELECT ROW(1,2) is distinct from ROW ('a','b');
ERROR:  invalid input syntax for integer: "a"

This is part of the subtle difference between the record and row
datatypes.

A

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
The plural of anecdote is not data.    --Roger Brinner


pgsql-sql by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: record datatype comparisons
Next
From: Craig Servin
Date:
Subject: Statement Triggers and access to other rows in the transaction