From: | Edmund Dengler <edmundd(at)eSentire(dot)com> |
---|---|
To: | Arthur Ward <award(at)dominionsciences(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: SET within a function? |
Date: | 2003-10-14 16:48:17 |
Message-ID: | Pine.BSO.4.58.0310141247380.12650@cyclops4.esentire.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
The problem I would face is that this still needs to be a sequential scan
in the table rather than an index lookup.
Regards,
Ed
On Tue, 14 Oct 2003, Arthur Ward wrote:
> > Is the rewrite only for the literal 'X = NULL' or will it do a test
> > against a value such as 'X = OLD.X' (and rewrite is OLD.X is NULL)?
> >
> > Is there any way to match NULLS to each other (as I am looking for a
> > literal row, not using NULL as the UNKNOWN). I suppose I could put in a
> > dummy value for the 'Not a valid value', but it seems to be quite awkward
> > when I really do want the NULL.
>
> I ended up writing an "equivalent" function for the project I'm working
> on. It goes like this in plpgsql:
>
> IF $1 IS NULL THEN
> RETURN $2 IS NULL;
> ELSIF $2 IS NULL THEN
> -- We already know $1 is not null.
> RETURN FALSE;
> ELSE
> -- Both args are not null.
> RETURN $1 = $2;
> END IF;
>
> That's the basic idea. I put a wrapper around this to generate a copy of
> it for all the data types used in my database.
>
From | Date | Subject | |
---|---|---|---|
Next Message | pw | 2003-10-14 16:54:44 | converting varchar date strings to date |
Previous Message | Arthur Ward | 2003-10-14 16:43:59 | Re: SET within a function? |