writing a MIN(RECORD) aggregate

Поиск
Список
Период
Сортировка
От Sam Mason
Тема writing a MIN(RECORD) aggregate
Дата
Msg-id 20080320192332.GF6870@frubble.xen.chris-lamb.co.uk
обсуждение исходный текст
Ответы Re: writing a MIN(RECORD) aggregate  (Decibel! <decibel@decibel.org>)
Список pgsql-hackers
Hi,

I'm trying to write a version of the MIN aggregate for values of RECORD
type.  I'm somewhat stuck on getting type information about the argument
out, I can determine how many attributes it's got but I can't seem to do
any better than that.  Does anyone have any good pointers into the code
for places to help me understand what's happening?

The reason for doing this is mainly because I think it'd be nicer to be
doing things like:
 SELECT i, (MIN((j,k))).k FROM tbl GROUP BY i;

instead of:
 SELECT DISTINCT ON (i) i, k FROM tbl ORDER BY i,j,k;

Which as far as I can tell should produce identical results, except the
first has cleaner semantics.  It also allows you to combine MIN and MAX
in the same query, giving the value of k for the smallest and largest j
in this example--requiring two queries if it was done using the DISTINCT
ON method.

 Sam


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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Unique Constraints using Non-Unique Indexes
Следующее
От: Simon Riggs
Дата:
Сообщение: Sort Refinement