How to add built-in func?
I only add below:
Datum fake_dinstance2(PG_FUNCTION_ARGS)
{
PG_RETURN_INT16(0);
}
in src/backend/utils/adt/int8.c, and the I run “make install”,
But I can’t find the fake_distance2 in src/backend/utils/fmgrtab.c which is
generated by src/backend/utils/Gen_fmgrtab.pl. What else do I need to add?
Hi,
I only add below:
Datum fake_dinstance2(PG_FUNCTION_ARGS)
{
PG_RETURN_INT16(0);
}
in src/backend/utils/adt/int8.c, and the I run “make install”,
But I can’t find the fake_distance2 in src/backend/utils/fmgrtab.c which is
generated by src/backend/utils/Gen_fmgrtab.pl. What else do I need to add?
If the goal is to add a function that can be executed by a user (e.g.
via psql) you have to add it to pg_proc.dat, or alternatively (and
often better) add a corresponding extension to /contrib/. You can find
a complete example here [1]/messages/by-id/CAAWbhmjcnoV7Xu6LHr_hxqWmVtehv404bvDye+QZcUDSg8NSKw@mail.gmail.com for instance, see v4-0001 patch and the
function pg_get_relation_publishing_info(). Make sure it has a proper
volatility [2]https://www.postgresql.org/docs/current/xfunc-volatility.html. The patch [3]/messages/by-id/CAJ7c6TMSat6qjPrrrK0tRTgZsdXwFAbkDn5gjeDtFnUFrjZX-g@mail.gmail.com -- Best regards, Aleksander Alekseev shows how to add an extension.
[1]: /messages/by-id/CAAWbhmjcnoV7Xu6LHr_hxqWmVtehv404bvDye+QZcUDSg8NSKw@mail.gmail.com
[2]: https://www.postgresql.org/docs/current/xfunc-volatility.html
[3]: /messages/by-id/CAJ7c6TMSat6qjPrrrK0tRTgZsdXwFAbkDn5gjeDtFnUFrjZX-g@mail.gmail.com -- Best regards, Aleksander Alekseev
--
Best regards,
Aleksander Alekseev
Hi
po 11. 9. 2023 v 17:59 odesílatel jacktby jacktby <jacktby@gmail.com>
napsal:
I only add below:
Datum fake_dinstance2(PG_FUNCTION_ARGS)
{
PG_RETURN_INT16(0);
}
in src/backend/utils/adt/int8.c, and the I run “make install”,
But I can’t find the fake_distance2 in src/backend/utils/fmgrtab.c which is
generated by src/backend/utils/Gen_fmgrtab.pl. What else do I need to add?
you need to add the function metadata to pg_proc.dat
For free oid use unused_oids script
Regards
Pavel
po 11. 9. 2023 v 18:18 odesílatel Pavel Stehule <pavel.stehule@gmail.com>
napsal:
Hi
po 11. 9. 2023 v 17:59 odesílatel jacktby jacktby <jacktby@gmail.com>
napsal:I only add below:
Datum fake_dinstance2(PG_FUNCTION_ARGS)
{
PG_RETURN_INT16(0);
}
in src/backend/utils/adt/int8.c, and the I run “make install”,
But I can’t find the fake_distance2 in src/backend/utils/fmgrtab.c which
is
generated by src/backend/utils/Gen_fmgrtab.pl. What else do I need to
add?you need to add the function metadata to pg_proc.dat
For free oid use unused_oids script
https://www.postgresql.org/docs/current/system-catalog-initial-data.html
https://www.highgo.ca/2021/03/04/how-to-create-a-system-information-function-in-postgresql/
Show quoted text
Regards
Pavel
2023年9月11日 23:51,Aleksander Alekseev <aleksander@timescale.com> 写道:
Hi,
I only add below:
Datum fake_dinstance2(PG_FUNCTION_ARGS)
{
PG_RETURN_INT16(0);
}
in src/backend/utils/adt/int8.c, and the I run “make install”,
But I can’t find the fake_distance2 in src/backend/utils/fmgrtab.c which is
generated by src/backend/utils/Gen_fmgrtab.pl. What else do I need to add?If the goal is to add a function that can be executed by a user (e.g.
via psql) you have to add it to pg_proc.dat, or alternatively (and
often better) add a corresponding extension to /contrib/. You can find
a complete example here [1] for instance, see v4-0001 patch and the
function pg_get_relation_publishing_info(). Make sure it has a proper
volatility [2]. The patch [3] shows how to add an extension.[1]: /messages/by-id/CAAWbhmjcnoV7Xu6LHr_hxqWmVtehv404bvDye+QZcUDSg8NSKw@mail.gmail.com
[2]: https://www.postgresql.org/docs/current/xfunc-volatility.html
[3]: /messages/by-id/CAJ7c6TMSat6qjPrrrK0tRTgZsdXwFAbkDn5gjeDtFnUFrjZX-g@mail.gmail.com
--
Best regards,
Aleksander Alekseev
I need to make it used for a new operator in my pg.
On 2023-09-11 12:28, jacktby jacktby wrote:
2023年9月11日 23:51,Aleksander Alekseev <aleksander@timescale.com> 写道:
often better) add a corresponding extension to /contrib/. You can find
a complete example here [1] for instance, see v4-0001 patch and the
function pg_get_relation_publishing_info(). Make sure it has a proper
volatility [2]. The patch [3] shows how to add an extension.[1]:
/messages/by-id/CAAWbhmjcnoV7Xu6LHr_hxqWmVtehv404bvDye+QZcUDSg8NSKw@mail.gmail.com
[2]: https://www.postgresql.org/docs/current/xfunc-volatility.html
[3]:
/messages/by-id/CAJ7c6TMSat6qjPrrrK0tRTgZsdXwFAbkDn5gjeDtFnUFrjZX-g@mail.gmail.com
--I need to make it used for a new operator in my pg.
You can implement both a function and an operator (and all that goes
with)
in an extension, without having to hack at all on PostgreSQL itself.
You can then, if it seems generally useful enough, offer that extension
to go in contrib/. If it's agreed to be something everyone should have,
it could then make its way into core.
Do you have it working as an extension yet? That can be a good way
to start, separating the difficulties you have to solve from the ones
you don't have to solve yet.
Regards,
-Chap
2023年9月12日 00:34,Chapman Flack <chap@anastigmatix.net> 写道:
On 2023-09-11 12:28, jacktby jacktby wrote:
2023年9月11日 23:51,Aleksander Alekseev <aleksander@timescale.com> 写道:
often better) add a corresponding extension to /contrib/. You can find
a complete example here [1] for instance, see v4-0001 patch and the
function pg_get_relation_publishing_info(). Make sure it has a proper
volatility [2]. The patch [3] shows how to add an extension.
[1]: /messages/by-id/CAAWbhmjcnoV7Xu6LHr_hxqWmVtehv404bvDye+QZcUDSg8NSKw@mail.gmail.com
[2]: https://www.postgresql.org/docs/current/xfunc-volatility.html
[3]: /messages/by-id/CAJ7c6TMSat6qjPrrrK0tRTgZsdXwFAbkDn5gjeDtFnUFrjZX-g@mail.gmail.com
--I need to make it used for a new operator in my pg.
You can implement both a function and an operator (and all that goes with)
in an extension, without having to hack at all on PostgreSQL itself.
You can then, if it seems generally useful enough, offer that extension
to go in contrib/. If it's agreed to be something everyone should have,
it could then make its way into core.Do you have it working as an extension yet? That can be a good way
to start, separating the difficulties you have to solve from the ones
you don't have to solve yet.Regards,
-Chap
I solved it , but I need to use it in my new grammar, so I have to add in into core. That’s necessary. Thanks. But My own storage engine is implemented by extension. Extension is a good idea and I’m using it now.