On Mon, Oct 04, 2010 at 11:12:37AM -0400, Tom Lane wrote:
> 
> > I'm affraid we cannot just use = here:
> 
> I think "$1 is not distinct from $2" would be more appropriate, if you

Right. Except, that will not work in Oracle, so we couldn't use one
syntax for both.

> expect the "null, null, x, y" case to work like that.  Also, a possibly
> bigger issue is that this formulation of decode() requires all four
> inputs to be of the same data type.  Logically it would be sufficient
> for the first two to be of one type and the second two of some other
> type --- but I don't know whether Oracle works that way, or whether
> there are any places in Spacewalk that care.

I prefer not to do the decode compatibility function in PostgreSQL for
now and see if we can manage to just rewrite the decode to

        case when ... then ... end

blocks -- that should give us code which runs both on Oracle and
PostgreSQL. If that proves too hard, we can always add the decode
later.

> >> +create or replace
> >> +function nvl(input integer, replace_with integer) returns integer
> >> +as $$
> >> +        SELECT COALESCE(NULLIF($1,0), $2);
> >> +$$
> >> +LANGUAGE SQL;
> 
> > I'm affraid the nullif is not correct here:
> 
> I think that nvl is just equivalent to coalesce($1,$2), no?  Also

Yes, that's what I've tried to say. Of course, for varchars we needed
that check for empty string to be compatible with the use of nvl in
our code, but for other types it should be just plain coalesce.

> I'd be inclined to declare the arguments and results as anyelement
> rather than hard-wiring them to integer.

Nod.

-- 
Jan Pazdziora
Principal Software Engineer, Satellite Engineering, Red Hat

_______________________________________________
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to