From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: COPY vs. INSERT |
Date: | 2001-06-21 20:28:51 |
Message-ID: | 22584.993155331@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
darcy(at)druid(dot)net (D'Arcy J.M. Cain) writes:
>> Obviously it isn't. Care to show us the code?
> Sure. ftp://ftp.vex.net/pub/glaccount.
PG_FUNCTION_INFO_V1(glaccount_cmp);
Datum
glaccount_cmp(PG_FUNCTION_ARGS)
{
glaccount *a1 = (glaccount *) PG_GETARG_POINTER(0);
glaccount *a2 = (glaccount *) PG_GETARG_POINTER(1);
PG_RETURN_BOOL(do_cmp(a1, a2));
}
The btree comparison function needs to return 1/0/-1, not boolean.
Try PG_RETURN_INT32().
PG_FUNCTION_INFO_V1(glaccount_eq);
Datum
glaccount_eq(PG_FUNCTION_ARGS)
{
glaccount *a1 = (glaccount *) PG_GETARG_POINTER(0);
glaccount *a2 = (glaccount *) PG_GETARG_POINTER(1);
PG_RETURN_BOOL (!do_cmp(a1, a2));
}
PG_FUNCTION_INFO_V1(glaccount_ne);
Datum
glaccount_ne(PG_FUNCTION_ARGS)
{
glaccount *a1 = (glaccount *) PG_GETARG_POINTER(0);
glaccount *a2 = (glaccount *) PG_GETARG_POINTER(1);
PG_RETURN_BOOL (!!do_cmp(a1, a2));
}
While these two are not actually wrong, that sort of coding always
makes me itch. Seems like
PG_RETURN_BOOL (do_cmp(a1, a2) == 0);
PG_RETURN_BOOL (do_cmp(a1, a2) != 0);
respectively would be cleaner, more readable, and more like the other
comparison functions. I've always thought that C's lack of distinction
between booleans and integers was a bad design decision; indeed, your
cmp bug kinda proves the point, no?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Olivier PRENANT | 2001-06-21 20:32:13 | psql+openssl+uniware7 |
Previous Message | Tom Lane | 2001-06-21 20:02:11 | Re: [GENERAL] Call for alpha testing: planner statistics revisions |