Thread: How to add a new pg oid?
> 2023年9月5日 22:29,jacktby jacktby <jacktby@gmail.com> 写道: > I’m trying to add a new data type for my pg. How to do that? Can you give me more details or an example?
On Tue, 5 Sept 2023 at 18:13, jacktby jacktby <jacktby@gmail.com> wrote: > > I’m trying to add a new data type for my pg. How to do that? Can you give me more details or an example? You could get started by looking at the documentation on custom SQL types with https://www.postgresql.org/docs/current/sql-createtype.html, or look at the comments in pg_type.dat and the comments on TypInfo in bootstrap.c on how the built-in types are created and managed. Lastly, you could look at pg_class and the genbki documentation if you want to add new catalog types. Kind regards, Matthias van de Meent Neon (https://neon.tech)
OIDs don't exist independently of the data they are associated with. Give more context if you want a better answer. Or just go look at the source code commits for when the last time something needing an OID got added to the core catalog.
David J.
On Tue, Sep 5, 2023, 11:17 jacktby jacktby <jacktby@gmail.com> wrote:
> 2023年9月5日 22:29,jacktby jacktby <jacktby@gmail.com> 写道:
>
I’m trying to add a new data type for my pg. How to do that? Can you give me more details or an example
Use create type and let the system deal with it. Otherwise, no, I don't have that knowledge.
David J.
2023年9月6日 01:47,David G. Johnston <david.g.johnston@gmail.com> 写道:OIDs don't exist independently of the data they are associated with. Give more context if you want a better answer. Or just go look at the source code commits for when the last time something needing an OID got added to the core catalog.David J.
{ oid => '111', array_type_oid => '6099', descr => 'similarity columns',
typname => 'similarity_columns', typlen => '-1', typlen => '-1', typbyval => 'f', typcategory => 'U',
typinput => 'byteain', typoutput => 'byteaout', typreceive => 'bytearecv',
typsend => 'byteasend', typalign => 'i', typstorage => 'x' },
I add above into pg_type.dat. And then I add execute “make install” and restart pg. And Then do below:
postgres=# SELECT typname from pg_type where typname like '%similarity%';
typname
---------
(0 rows)
I can’t get the type I added. What else I need to do?
I add below in bootstrap.c:2023年9月6日 18:19,jacktby jacktby <jacktby@gmail.com> 写道:2023年9月6日 01:47,David G. Johnston <david.g.johnston@gmail.com> 写道:OIDs don't exist independently of the data they are associated with. Give more context if you want a better answer. Or just go look at the source code commits for when the last time something needing an OID got added to the core catalog.David J.{ oid => '111', array_type_oid => '6099', descr => 'similarity columns',typname => 'similarity_columns', typlen => '-1', typlen => '-1', typbyval => 'f', typcategory => 'U',typinput => 'byteain', typoutput => 'byteaout', typreceive => 'bytearecv',typsend => 'byteasend', typalign => 'i', typstorage => 'x' },I add above into pg_type.dat. And then I add execute “make install” and restart pg. And Then do below:postgres=# SELECT typname from pg_type where typname like '%similarity%';typname---------(0 rows)I can’t get the type I added. What else I need to do?
static const struct typinfo TypInfo[] = {
{"similarity_columns", SimilarityColumns, 0, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, InvalidOid,
F_BYTEAIN, F_BYTEAOUT},
….
}
And then “make install” and restart pg.but still:
postgres=# SELECT typname from pg_type where typname like '%similarity%';
typname
---------
(0 rows)
Please give me help.
After initdb , I get it. Thanks2023年9月6日 18:50,jacktby jacktby <jacktby@gmail.com> 写道:I add below in bootstrap.c:2023年9月6日 18:19,jacktby jacktby <jacktby@gmail.com> 写道:2023年9月6日 01:47,David G. Johnston <david.g.johnston@gmail.com> 写道:OIDs don't exist independently of the data they are associated with. Give more context if you want a better answer. Or just go look at the source code commits for when the last time something needing an OID got added to the core catalog.David J.{ oid => '111', array_type_oid => '6099', descr => 'similarity columns',typname => 'similarity_columns', typlen => '-1', typlen => '-1', typbyval => 'f', typcategory => 'U',typinput => 'byteain', typoutput => 'byteaout', typreceive => 'bytearecv',typsend => 'byteasend', typalign => 'i', typstorage => 'x' },I add above into pg_type.dat. And then I add execute “make install” and restart pg. And Then do below:postgres=# SELECT typname from pg_type where typname like '%similarity%';typname---------(0 rows)I can’t get the type I added. What else I need to do?static const struct typinfo TypInfo[] = {{"similarity_columns", SimilarityColumns, 0, -1, false, TYPALIGN_INT, TYPSTORAGE_EXTENDED, InvalidOid,F_BYTEAIN, F_BYTEAOUT},….}And then “make install” and restart pg.but still:postgres=# SELECT typname from pg_type where typname like '%similarity%';typname---------(0 rows)Please give me help.