pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedHow can I retrieve attribute category with attribute Oid in C function?
5+ messages / 2 participants
[nested] [flat]
* How can I retrieve attribute category with attribute Oid in C function?
@ 2018-05-14 07:30 a <372660931@qq.com>
0 siblings, 1 reply; 5+ messages in thread
From: a @ 2018-05-14 07:30 UTC (permalink / raw)
To: pgsql-general
Hi I am writing something that would need to identify the attribute category inside a C function, now I may need a way of fast access it, but the information is not stored in FormData_pg_attribute structure.
Can anyone help? Thanks a lot!!!
Shore
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How can I retrieve attribute category with attribute Oid in C function?
@ 2018-05-14 08:11 Laurenz Albe <laurenz.albe@cybertec.at>
parent: a <372660931@qq.com>
0 siblings, 1 reply; 5+ messages in thread
From: Laurenz Albe @ 2018-05-14 08:11 UTC (permalink / raw)
To: a <372660931@qq.com>; pgsql-general
a wrote:
> Hi I am writing something that would need to identify the attribute category inside a C function,
> now I may need a way of fast access it, but the information is not stored in FormData_pg_attribute structure.
Are you talking about pg_type.typcategory?
That is accessible from FormData_pg_type.
You'd have to look up atttypid in the TYPEOID cache.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How can I retrieve attribute category with attribute Oid in Cfunction?
@ 2018-05-14 08:18 a <372660931@qq.com>
parent: Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 1 reply; 5+ messages in thread
From: a @ 2018-05-14 08:18 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general
hey thank you!!
could you provide some more detail information??
What function should I use to get FormData_pg_type structure??
thanks a lot
------------------ Original message ------------------
From: "Laurenz Albe";
Sendtime: Monday, May 14, 2018 4:11 PM
To: "a"<372660931@qq.com>; "pgsql-general";
Subject: Re: How can I retrieve attribute category with attribute Oid in Cfunction?
a wrote:
> Hi I am writing something that would need to identify the attribute category inside a C function,
> now I may need a way of fast access it, but the information is not stored in FormData_pg_attribute structure.
Are you talking about pg_type.typcategory?
That is accessible from FormData_pg_type.
You'd have to look up atttypid in the TYPEOID cache.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How can I retrieve attribute category with attribute Oid in Cfunction?
@ 2018-05-14 08:23 a <372660931@qq.com>
parent: a <372660931@qq.com>
0 siblings, 1 reply; 5+ messages in thread
From: a @ 2018-05-14 08:23 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; pgsql-general
BTW, I searched another function called "lookup_type_cache", which will return a pointer of structure of "TypeCacheEntry".
The structure contains "TypeCacheEntry.typtype" that may also help to identify the type.
But I'm concerning about possible memory leak and allocation stuff. Is it safe to just declare a pointer and call this function??
------------------ Original ------------------
From: "372660931@qq.com";<372660931@qq.com>;
Date: May 14, 2018
To: "Laurenz Albe"<laurenz.albe@cybertec.at>; "pgsql-general"<pgsql-general@postgresql.org>;
Subject: Re: How can I retrieve attribute category with attribute Oid in Cfunction?
hey thank you!!
could you provide some more detail information??
What function should I use to get FormData_pg_type structure??
thanks a lot
------------------ Original message ------------------
From: "Laurenz Albe";
Sendtime: Monday, May 14, 2018 4:11 PM
To: "a"<372660931@qq.com>; "pgsql-general";
Subject: Re: How can I retrieve attribute category with attribute Oid in Cfunction?
a wrote:
> Hi I am writing something that would need to identify the attribute category inside a C function,
> now I may need a way of fast access it, but the information is not stored in FormData_pg_attribute structure.
Are you talking about pg_type.typcategory?
That is accessible from FormData_pg_type.
You'd have to look up atttypid in the TYPEOID cache.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: How can I retrieve attribute category with attribute Oid in Cfunction?
@ 2018-05-14 08:51 Laurenz Albe <laurenz.albe@cybertec.at>
parent: a <372660931@qq.com>
0 siblings, 0 replies; 5+ messages in thread
From: Laurenz Albe @ 2018-05-14 08:51 UTC (permalink / raw)
To: a <372660931@qq.com>; pgsql-general
a wrote:
> could you provide some more detail information??
>
> What function should I use to get FormData_pg_type structure??
>
> BTW, I searched another function called "lookup_type_cache", which will return a pointer of structure of "TypeCacheEntry".
>
> The structure contains "TypeCacheEntry.typtype" that may also help to
identify the type.
>
> But I'm concerning about possible memory leak and allocation stuff. Is it safe to just declare a pointer and call this function??
In "logicalrep_write_typ" in src/backend/replication/logical/proto.c
you can find an example how to get the pg_type values from the OID.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2018-05-14 08:51 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14 07:30 How can I retrieve attribute category with attribute Oid in C function? a <372660931@qq.com>
2018-05-14 08:11 ` Laurenz Albe <laurenz.albe@cybertec.at>
2018-05-14 08:18 ` Re: How can I retrieve attribute category with attribute Oid in Cfunction? a <372660931@qq.com>
2018-05-14 08:23 ` Re: How can I retrieve attribute category with attribute Oid in Cfunction? a <372660931@qq.com>
2018-05-14 08:51 ` Re: How can I retrieve attribute category with attribute Oid in Cfunction? Laurenz Albe <laurenz.albe@cybertec.at>
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