From: Markur Sens <markursens@gmail.com>
To: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Additional accessors via the Extension API ?
Date: Sun, 20 Feb 2022 08:07:20 +0200
Message-ID: <6D4DE1F2-70C9-4BC4-92FD-0699BE0F8952@gmail.com> (raw)
Suppose I have defined an additional type in a PG extension.
Is it possible to add custom accessors to that type -much like jsonb does- but use an API/hook without touching the core PG grammar & parser?
Hypothetical Examples:
Assuming I have a TextFile type I’d like to implement syntax like:
(‘/home/me/a.txt’::TextFile).firstline
(‘/home/me/a.txt’::TextFile).lastline
(‘/home/me/a.txt’::TextFile).countlines()
(‘/home/me/a.txt’::TextFile).size()
(‘/home/me/a.txt’::TextFile).datemodified()
The only relevant patch I could find is [1] but it’s a dead-end
[1] https://www.postgresql.org/message-id/20210501072458.adqjoaqnmhg4l34l%40nol
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: markursens@gmail.com
Subject: Re: Additional accessors via the Extension API ?
In-Reply-To: <6D4DE1F2-70C9-4BC4-92FD-0699BE0F8952@gmail.com>
References: <6D4DE1F2-70C9-4BC4-92FD-0699BE0F8952@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox