Re: Custom tuplesorts for extensions

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: Maxim Orlov <orlovmg(at)gmail(dot)com>, Pavel Borisov <pashkin(dot)elfe(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Custom tuplesorts for extensions
Date: 2022-07-12 08:22:53
Message-ID: CAPpHfdsixwod0pKj-PhZBFyDD+QCJ2JM-xZz_WwNS1U+EXJa+A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, Matthias!

The revised patchset is attached.

On Wed, Jul 6, 2022 at 5:41 PM Matthias van de Meent
<boekewurm+postgres(at)gmail(dot)com> wrote:
> All of the patches are currently missing descriptive commit messages,
> which I think is critical for getting this committed. As for per-patch
> comments:
>
> 0001: This patch removes copytup, but it is not quite clear why -
> please describe the reasoning in the commit message.

Because spit of logic between Tuplesortstate.copytup() function and
tuplesort_put*() functions is unclear. It doesn't look like we need
an abstraction here, while all the work could be done in
tuplesort_put*().

> 0002: getdatum1 needs comments on what it does. From the name, it
> would return the datum1 from a sorttuple, but that's not what it does;
> a better name would be putdatum1 or populatedatum1.
>
> 0003: in the various tuplesort_put*tuple[values] functions, the datum1
> field is manually extracted. Shouldn't we use the getdatum1 functions
> from 0002 instead? We could use either them directly to allow
> inlining, or use the indirection through tuplesortstate.

getdatum1() was a bad name. Actually it restores original datum1
during rollback of abbreviations. I've replaced it with
removeabbrev(), which seems name to me and process many SortTuple's
during one call.

> 0004: Needs a commit message, but otherwise seems fine.

Commit message is added.

> 0005:
> > +struct TuplesortOps
>
> This struct has no comment on what it is. Something like "Public
> interface of tuplesort operators, containing data directly accessable
> to users of tuplesort" should suffice, but feel free to update the
> wording.
>
> > + void *arg;
> > +};
>
> This field could use a comment on what it is used for, and how to use it.
>
> > +struct Tuplesortstate
> > +{
> > + TuplesortOps ops;
>
> This field needs a comment too.
>
> 0006: Needs a commit message, but otherwise seems fine.

TuplesortOps was renamed to TuplesortPublic. Comments and commit
messages are added.

There are some places, which potentially could cause a slowdown. I'm
going to make some experiments with that.

------
Regards,
Alexander Korotkov

Attachment Content-Type Size
0001-Remove-Tuplesortstate.copytup-function-v2.patch application/x-patch 16.7 KB
0002-Add-new-Tuplesortstate.removeabbrev-function-v2.patch application/x-patch 10.4 KB
0003-Put-abbreviation-logic-into-puttuple_common-v2.patch application/x-patch 10.7 KB
0005-Split-TuplesortPublic-from-Tuplesortstate-v2.patch application/x-patch 69.6 KB
0004-Move-memory-management-away-from-writetup-and-tup-v2.patch application/x-patch 8.2 KB
0006-Split-tuplesortvariants.c-from-tuplesort.c-v2.patch application/x-patch 115.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message James Vanns 2022-07-12 08:23:22 Re: Weird behaviour with binary copy, arrays and column count
Previous Message tushar 2022-07-12 08:08:16 Re: replacing role-level NOINHERIT with a grant-level option