Re: New pg_lsn type doesn't have hash/btree opclasses

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема Re: New pg_lsn type doesn't have hash/btree opclasses
Дата
Msg-id CAB7nPqRWprhP0BpaN3-3ER1AZ1s6yjryx=kb28TRkLQj2yff9w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: New pg_lsn type doesn't have hash/btree opclasses  (Andres Freund <andres@2ndquadrant.com>)
Ответы Re: New pg_lsn type doesn't have hash/btree opclasses
Re: New pg_lsn type doesn't have hash/btree opclasses
Список pgsql-hackers
On Wed, May 7, 2014 at 8:07 AM, Andres Freund <andres@2ndquadrant.com> wrote:
> On 2014-05-06 22:49:07 +0900, Michael Paquier wrote:
> FWIW, the format you're using makes applying the patch including the
> commit message relatively hard. Consider using git format-patch.
Could you be clearer? By applying a filterdiff command or by using git
diff? The latter has been used for this patch.

>> +/* handler for btree index operator */
>> +Datum
>> +pg_lsn_cmp(PG_FUNCTION_ARGS)
>> +{
>> +     XLogRecPtr lsn1 = PG_GETARG_LSN(0);
>> +     XLogRecPtr lsn2 = PG_GETARG_LSN(1);
>> +
>> +     PG_RETURN_INT32(lsn1 == lsn2);
>> +}
>
> This doesn't look correct. A cmp routine needs to return -1, 0, 1 when a
> < b, a = b, a > b respectively. You'll only return 0 and 1 here.
Thanks, I recalled that this morning as well... And my 2nd patch uses
this flow instead:
+Datum
+pg_lsn_cmp(PG_FUNCTION_ARGS)
+{
+       XLogRecPtr lsn1 = PG_GETARG_LSN(0);
+       XLogRecPtr lsn2 = PG_GETARG_LSN(1);
+
+       if (lsn1 < lsn2)
+               PG_RETURN_INT32(-1);
+       if (lsn1 > lsn2)
+               PG_RETURN_INT32(1);
+       PG_RETURN_INT32(0);
+}

>> +/* hash index support */
>> +Datum
>> +pg_lsn_hash(PG_FUNCTION_ARGS)
>> +{
>> +     XLogRecPtr lsn = PG_GETARG_LSN(0);
>> +
>> +     return hashint8(lsn);
>> +}
>
> That can't be right either. There's at least two things wrong here:
> a) hashint8 takes PG_FUNCTION_ARGS, not a Datum
In this case you may consider changing timestamp_hash@time.c and
time_hash@date.c as well :)
-- 
Michael



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: New pg_lsn type doesn't have hash/btree opclasses
Следующее
От: Andres Freund
Дата:
Сообщение: Re: New pg_lsn type doesn't have hash/btree opclasses