From: | "David E(dot) Wheeler" <david(at)kineticode(dot)com> |
---|---|
To: | David E(dot) Wheeler <david(at)kineticode(dot)com> |
Cc: | Jeff Davis <pgsql(at)j-davis(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Brendan Jurd <direvus(at)gmail(dot)com>, PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: When is a record NULL? |
Date: | 2009-07-24 22:47:39 |
Message-ID: | 2CA937FC-2501-442E-BB3E-879D12132370@kineticode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Jul 24, 2009, at 2:59 PM, David E. Wheeler wrote:
> FETCH have INTO rec_have;
> FETCH want INTO rec_want;
> WHILE NOT rec_have IS NULL OR NOT rec_want IS NULL LOOP
> IF rec_have IS DISTINCT FROM rec_want THEN
> RETURN false;
> END IF;
> rownum = rownum + 1;
> FETCH have INTO rec_have;
> FETCH want INTO rec_want;
> END LOOP;
> RETURN true;
Bah. It fails to do what I want when I pass cursors that return:
VALUES (NULL, NULL), (NULL, NULL)
VALUES (NULL, NULL)
So when it gets to that second row in the first cursor, it doesn't
know it's a row with NULLs as opposed to an empty row. So this bit:
WHILE NOT rec_have IS NULL OR NOT rec_want IS NULL LOOP
Obviously isn't detecting the difference. I tried
WHILE (NOT rec_have IS NULL AND rec_have IS DISTINCT FROM NULL)
OR (NOT rec_want IS NULL AND rec_want IS DISTINCT FROM NULL)
and
WHILE (NOT rec_have IS NULL AND NOT rec_have IS NOT DISTINCT FROM
NULL)
OR (NOT rec_want IS NULL AND NOT rec_want IS NOT DISTINCT FROM
NULL)
But they didn't work, either.
There's got to be a way to do this; better, there ought to be an easy
way to tell the difference. :-(
Thanks,
David
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-07-24 23:21:40 | Re: Non-blocking communication between a frontend and a backend (pqcomm) |
Previous Message | Robert Haas | 2009-07-24 22:39:10 | Re: SE-PostgreSQL Specifications |