Add minimal C example and SQL registration example for custom table access methods.

Lists: pgsql-docspgsql-hackers
From: Phil Eaton <phil(at)eatonphil(dot)com>
To: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Add minimal C example and SQL registration example for custom table access methods.
Date: 2023-11-02 17:58:42
Message-ID: CAByiw+r+CS-ojBDP7Dm=9YeOLkZTXVnBmOe_ajK=en8C_zB3_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

Hello!

I was looking into table access methods recently and found the
existing page a bit sparse. Here's a small patch adding a little more
example code to the table access methods page.

Let me know if there's anything I can do to fix my patch up!

Cheers,
Phil

Attachment Content-Type Size
v1-0001-Add-minimal-C-example-and-SQL-registration-exampl.patch application/octet-stream 2.8 KB

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: Phil Eaton <phil(at)eatonphil(dot)com>
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2023-11-11 21:17:26
Message-ID: CA+renyUC+sYP6Oj-bvwLF9H+b3eqAwGKUW3WP+Es4UBXkg04YQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

On Sat, Nov 11, 2023 at 1:00 PM Phil Eaton <phil(at)eatonphil(dot)com> wrote:
> I was looking into table access methods recently and found the
> existing page a bit sparse. Here's a small patch adding a little more
> example code to the table access methods page.

I agree this is a helpful addition for people exploring table AMs. The
patch applies and builds. No spelling/grammar errors. Integrates
smoothly with the surrounding text.

I didn't write a full table AM (maybe someday! :-) but I put the
example code into a new extension and made sure it builds. I don't
think this snippet is likely to go out of date, but is there anything
we do in doc examples to test that? (I'm not aware of anything.)

There is no commitfest entry yet. Phil, would you mind adding one? (It
will need to be against the Jan 2024 commitfest.) I started one myself
but I don't think you're registered yet so I couldn't enter you as the
patch author. Let me know if you have any trouble.

+1 from me!

Regards,
Paul


From: Roberto Mello <roberto(dot)mello(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2023-11-15 23:28:24
Message-ID: 170009090469.2631681.9401767800677948331.pgcf@coridan.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

Suggestion:

In the C example you added you mention in the comment:

+ /* Methods from TableAmRoutine omitted from example, but all
+ non-optional ones must be provided here. */

Perhaps you could provide a "see <xyz>" to point the reader finding your example where he could find these non-optional methods he must provide?

Nitpicking a little: your patch appears to change more lines than it does, because it added line breaks earlier in the lines. I would generally avoid that unless there's good reason to do so.


From: Tristen Raab <tristen(dot)raab(at)highgo(dot)ca>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-01-26 19:56:37
Message-ID: 170629899743.1131.10530730698967721601.pgcf@coridan.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

The following review has been posted through the commitfest application:
make installcheck-world: tested, passed
Implements feature: not tested
Spec compliant: not tested
Documentation: tested, passed

Hello,

I've reviewed your patch and it applies correctly and the documentation builds without any error. The built documentation also looks good with no formatting errors. It's always great to see more examples when reading through documentation so I think this patch is a good addition.

thanks,

-----------------------
Tristen Raab
Highgo Software Canada
www.highgo.ca


From: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
To: Roberto Mello <roberto(dot)mello(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-01-26 20:02:59
Message-ID: CAFcNs+oZYizW7-X_MmSjFeaxtHamb6Z38zBUKDUtfuKJ8yjipA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

On Wed, Nov 15, 2023 at 8:29 PM Roberto Mello <roberto(dot)mello(at)gmail(dot)com>
wrote:
>
> Suggestion:
>
> In the C example you added you mention in the comment:
>
> + /* Methods from TableAmRoutine omitted from example, but all
> + non-optional ones must be provided here. */
>
> Perhaps you could provide a "see <xyz>" to point the reader finding your
example where he could find these non-optional methods he must provide?
>
> Nitpicking a little: your patch appears to change more lines than it
does, because it added line breaks earlier in the lines. I would generally
avoid that unless there's good reason to do so.

Hey folks,

There is a previous patch [1] around the same topic. What about joining
efforts on pointing these documentation changes to the proposed test module?

[1] https://commitfest.postgresql.org/46/4588/

--
Fabrízio de Royes Mello


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: fabriziomello(at)gmail(dot)com, phil(at)eatonphil(dot)com
Cc: Roberto Mello <roberto(dot)mello(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-03-22 17:40:03
Message-ID: CA+TgmoYpVaqoZ6dZoH+gnMpxQv-6U9keKiaPHy_NjqhiZr96VA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

On Fri, Jan 26, 2024 at 3:03 PM Fabrízio de Royes Mello
<fabriziomello(at)gmail(dot)com> wrote:
> On Wed, Nov 15, 2023 at 8:29 PM Roberto Mello <roberto(dot)mello(at)gmail(dot)com> wrote:
> > Suggestion:
> >
> > In the C example you added you mention in the comment:
> >
> > + /* Methods from TableAmRoutine omitted from example, but all
> > + non-optional ones must be provided here. */
> >
> > Perhaps you could provide a "see <xyz>" to point the reader finding your example where he could find these non-optional methods he must provide?
> >
> > Nitpicking a little: your patch appears to change more lines than it does, because it added line breaks earlier in the lines. I would generally avoid that unless there's good reason to do so.
>
> Hey folks,
>
> There is a previous patch [1] around the same topic. What about joining efforts on pointing these documentation changes to the proposed test module?
>
> [1] https://commitfest.postgresql.org/46/4588/

Looking over this thread, I see that it was moved from pgsql-docs to
pgsql-hackers while at the same time dropping the original poster from
the Cc list. That seems rather unfortunate. I suspect there's a pretty
good chance that Phil Eaton hasn't seen any of the replies other than
the first one from Paul Jungwirth, which is also the only one that
didn't ask for anything to be changed.

Re-adding Phil. Phil, you should have a look over
https://www.postgresql.org/message-id/flat/CAByiw%2Br%2BCS-ojBDP7Dm%3D9YeOLkZTXVnBmOe_ajK%3Den8C_zB3_g%40mail.gmail.com
and respond to the various emails and probably update the patch
somehow. Note that feature freeze is in 2 weeks, so if we can't reach
agreement on what is to be done here soon, this will have to wait for
the next cycle, or later.

--
Robert Haas
EDB: http://www.enterprisedb.com


From: Phil Eaton <phil(at)eatonphil(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: fabriziomello(at)gmail(dot)com, Roberto Mello <roberto(dot)mello(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-05-03 17:35:31
Message-ID: CAByiw+o9uKi=qAuZ=4TtqRqGO8-OLMRS9fVx-UwZPEdT8SshFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

Thanks Robert for mentioning this! I indeed did not notice the switch.

> Nitpicking a little: your patch appears to change more lines than it does, because it added line breaks earlier in the lines. I would generally avoid that unless there's good reason to do so.

Thanks! I'm not sure why that happened since I normally run
fill-region in emacs and when I re-ran it now, it looked as it used
to. I've fixed it up in this patch.

> Perhaps you could provide a "see <xyz>" to point the reader finding your example where he could find these non-optional methods he must provide?

Since the responses were positive, I've taken the liberty to extend
the sample code by simply including all the stub methods and the full
struct. Marking which methods are optional and not.

If that looks like too much, I can revert back. Perhaps only
mentioning the struct like we do for the index AM here:
https://www.postgresql.org/docs/current/index-api.html. However, as a
reader, I feel like the full stubs are a bit more useful.

Happy for feedback. Updated patch is attached.

Cheers,
Phil

On Fri, Mar 22, 2024 at 1:40 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
> On Fri, Jan 26, 2024 at 3:03 PM Fabrízio de Royes Mello
> <fabriziomello(at)gmail(dot)com> wrote:
> > On Wed, Nov 15, 2023 at 8:29 PM Roberto Mello <roberto(dot)mello(at)gmail(dot)com> wrote:
> > > Suggestion:
> > >
> > > In the C example you added you mention in the comment:
> > >
> > > + /* Methods from TableAmRoutine omitted from example, but all
> > > + non-optional ones must be provided here. */
> > >
> > > Perhaps you could provide a "see <xyz>" to point the reader finding your example where he could find these non-optional methods he must provide?
> > >
> > > Nitpicking a little: your patch appears to change more lines than it does, because it added line breaks earlier in the lines. I would generally avoid that unless there's good reason to do so.
> >
> > Hey folks,
> >
> > There is a previous patch [1] around the same topic. What about joining efforts on pointing these documentation changes to the proposed test module?
> >
> > [1] https://commitfest.postgresql.org/46/4588/
>
> Looking over this thread, I see that it was moved from pgsql-docs to
> pgsql-hackers while at the same time dropping the original poster from
> the Cc list. That seems rather unfortunate. I suspect there's a pretty
> good chance that Phil Eaton hasn't seen any of the replies other than
> the first one from Paul Jungwirth, which is also the only one that
> didn't ask for anything to be changed.
>
> Re-adding Phil. Phil, you should have a look over
> https://www.postgresql.org/message-id/flat/CAByiw%2Br%2BCS-ojBDP7Dm%3D9YeOLkZTXVnBmOe_ajK%3Den8C_zB3_g%40mail.gmail.com
> and respond to the various emails and probably update the patch
> somehow. Note that feature freeze is in 2 weeks, so if we can't reach
> agreement on what is to be done here soon, this will have to wait for
> the next cycle, or later.
>
> --
> Robert Haas
> EDB: http://www.enterprisedb.com

Attachment Content-Type Size
v2-0001-Add-boilerplate-C-code-and-SQL-registration-examp.patch application/octet-stream 14.5 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Phil Eaton <phil(at)eatonphil(dot)com>
Cc: fabriziomello(at)gmail(dot)com, Roberto Mello <roberto(dot)mello(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-05-14 18:46:01
Message-ID: CA+TgmoZn6EJB1o8M2NWPGRzqYU+c1GB8rAC78MM1+qrfFL6VGw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

On Fri, May 3, 2024 at 1:35 PM Phil Eaton <phil(at)eatonphil(dot)com> wrote:
> Happy for feedback. Updated patch is attached.

I took a look at this patch and I don't think this is a very good
idea, for two reasons:

1. We change the table access method interface definitions not all
that infrequently, so I think this will become out of date, and fail
to get updated.

2. Writing a table access method is really hard, and if you need this
in order to be able to attempt it, you're probably shouldn't be
attmempting it.

I wouldn't mind patching the documentation to add the SQL part of
this; that seems short enough, non-obvious enough, and sufficiently
unlikely to change that I can believe it would be a worthwhile
addition. But there have been 21 commits to tableam.h in the last 6
months and most of those would have needed to update this example, and
I think it's very likely that some of them would have forgotten it.

--
Robert Haas
EDB: http://www.enterprisedb.com


From: Phil Eaton <phil(at)eatonphil(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: fabriziomello(at)gmail(dot)com, Roberto Mello <roberto(dot)mello(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-05-14 19:02:03
Message-ID: CAByiw+pXAA+1c3zbi0LmFFckwnBKVXb0gYtWxdsDpoik6zyecg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

> I took a look at this patch and I don't think this is a very good
> idea,

No problem! I've dropped the v2 code additions and stuck with the v1
attempt plus feedback.

Thank you!

Phil

Attachment Content-Type Size
v3-0001-Add-minimal-C-example-and-SQL-registration-exampl.patch application/octet-stream 2.8 KB

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Phil Eaton <phil(at)eatonphil(dot)com>
Cc: fabriziomello(at)gmail(dot)com, Roberto Mello <roberto(dot)mello(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-05-14 20:07:09
Message-ID: CA+TgmoYnSuSydAHS-EQEFDcdyQUty9sWv3ejPHcEzjFRQPqiMg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

On Tue, May 14, 2024 at 3:02 PM Phil Eaton <phil(at)eatonphil(dot)com> wrote:
> > I took a look at this patch and I don't think this is a very good
> > idea,
>
> No problem! I've dropped the v2 code additions and stuck with the v1
> attempt plus feedback.

That looks more reasonable. I'd like to quibble with this text:

+. Here is an example of how to register an extension that provides a
+ table access method handler:

I think this should say something more like "Here is how an extension
SQL script might create a table access method handler". I'm not sure
if we have a standard term in our documentation that should be used
instead of "extension SQL script"; perhaps look for similar examples,
or the documentation of extensions themselves, and copy the wording.

Shouldn't "mem_tableam_handler" be "my_tableam_handler"?

--
Robert Haas
EDB: http://www.enterprisedb.com


From: Phil Eaton <phil(at)eatonphil(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: fabriziomello(at)gmail(dot)com, Roberto Mello <roberto(dot)mello(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-05-24 18:10:53
Message-ID: CAByiw+rQdWE_R36m9q0+EBbx-hn05jFsiM8WttJKXyRcpBW27g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

> I think this should say something more like "Here is how an extension
> SQL script might create a table access method handler".

Fair point. It is referred to elsewhere [0] in docs as a "script
file", so I've done that.

> Shouldn't "mem_tableam_handler" be "my_tableam_handler"?

Sorry about that, fixed.

[0] https://www.postgresql.org/docs/current/extend-extensions.html

Phil

Attachment Content-Type Size
v4-0001-Add-minimal-C-example-and-SQL-registration-exampl.patch application/octet-stream 2.7 KB

From: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
To: Phil Eaton <phil(at)eatonphil(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Roberto Mello <roberto(dot)mello(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-05-24 18:59:08
Message-ID: CAFcNs+rh8HKC8mW8NTvRRCpBkGziyjOBAMc_n_uvzLh-by5AmA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

On Fri, May 24, 2024 at 3:11 PM Phil Eaton <phil(at)eatonphil(dot)com> wrote:

> > I think this should say something more like "Here is how an extension
> > SQL script might create a table access method handler".
>
> Fair point. It is referred to elsewhere [0] in docs as a "script
> file", so I've done that.
>
> > Shouldn't "mem_tableam_handler" be "my_tableam_handler"?
>
> Sorry about that, fixed.
>
> [0] https://www.postgresql.org/docs/current/extend-extensions.html
>
> Phil
>

Nice... LGTM!

--
Fabrízio de Royes Mello


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: fabriziomello(at)gmail(dot)com
Cc: Phil Eaton <phil(at)eatonphil(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Roberto Mello <roberto(dot)mello(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-07-25 20:00:17
Message-ID: [email protected]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

I noticed that there were two CF entries pointing at this thread:

https://commitfest.postgresql.org/48/4655/
https://commitfest.postgresql.org/48/4973/

That doesn't seem helpful, so I've marked the second one "Withdrawn".

regards, tom lane


From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
Cc: Phil Eaton <phil(at)eatonphil(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Roberto Mello <roberto(dot)mello(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-10-07 06:50:26
Message-ID: [email protected]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

On Fri, May 24, 2024 at 03:59:08PM -0300, Fabrízio de Royes Mello wrote:
> Nice... LGTM!

I have noticed that this was still in the CF. After fixing a couple
of inconsistencies in the markups and the names, trimming down the
list of headers to avoid rot and adding a static in from of the const,
the result looked pretty much OK, so applied.
--
Michael


From: Phil Eaton <phil(at)eatonphil(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Roberto Mello <roberto(dot)mello(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add minimal C example and SQL registration example for custom table access methods.
Date: 2024-10-07 12:17:49
Message-ID: CAByiw+qA9Rr0HuYE3MMOxJLMDvNQ9CZfeWqX3iXabT_=2TX3jw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-docs pgsql-hackers

Glad to hear it. Thank you!

On Mon, Oct 7, 2024 at 2:50 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Fri, May 24, 2024 at 03:59:08PM -0300, Fabrízio de Royes Mello wrote:
> > Nice... LGTM!
>
> I have noticed that this was still in the CF. After fixing a couple
> of inconsistencies in the markups and the names, trimming down the
> list of headers to avoid rot and adding a static in from of the const,
> the result looked pretty much OK, so applied.
> --
> Michael