Re: What's wrong with this query?

From: Martin Gainty <mgainty(at)hotmail(dot)com>
To: <spam_eater(at)gmx(dot)net>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: What's wrong with this query?
Date: 2009-06-22 00:20:04
Message-ID: BLU142-W18FF4AB7EF477BEDBC7FA9AE390@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


testcase for a null uuid?

thanks,
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

> To: pgsql-general(at)postgresql(dot)org
> From: spam_eater(at)gmx(dot)net
> Subject: Re: [GENERAL] What's wrong with this query?
> Date: Mon, 22 Jun 2009 00:37:41 +0200
>
> Mike Christensen wrote on 22.06.2009 00:10:
> > I just tracked down a bug in my software due to an "unexpected" behavior
> > in Postgres.. Can someone clarify why this doesn't work (I haven't
> > tried it on MSSQL or anything else, so I'm not sure if this is the
> > official SQL standard or anything)..
> >
> > CREATE TABLE test
> > (
> > value uuid
> > );
> >
> > INSERT INTO test VALUES ('00000000-0000-0000-0000-000000000000');
> > INSERT INTO test VALUES ('11111111-1111-1111-1111-111111111111');
> > INSERT INTO test VALUES (null);
> >
> > select * from test where value != '00000000-0000-0000-0000-000000000000';
> >
> > What I expect to get is two rows: the
> > '11111111-1111-1111-1111-111111111111' row and the null row, as both
> > those values are in fact not '00000000-0000-0000-0000-000000000000'.
> > However, I only get the first one.
> >
> That is standard behaviour.
> A comparison with a NULL value always returns false (and that is not a Postgres
> speciality).
>
> You need to use
>
> select *
> from test
> where value != '00000000-0000-0000-0000-000000000000'
> or value is null;
>
> Thomas
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

_________________________________________________________________
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2009-06-22 01:08:29 Re: postgresql-8.3.7 unexpected connection closures
Previous Message Craig Ringer 2009-06-21 23:26:56 Re: cursors, temp tables, dynamic sql technique (was and is: looping over a small record set over and over in a function)