Re: [HACKERS] pg_type.typname of array types.
Hey Florian, Thank you very much! 2010/12/8 Florian Pflug f...@phlo.org On Dec8, 2010, at 11:35 , Dmitriy Igrishin wrote: Is it guaranteed that name of array types in pg_type system catalog will always be prefixed by underscore or this convention can be changed in future ? What's the advantage of letting your code depend on this? Within SQL, I suggest you write type[] to denote type's array type. In the catalog, each pg_type row contains a references the corresponding array type (by OID) in the field typarray. BTW, when querying pg_type, instead of adding another join to pg_type to get the array type's name, you can simply cast the typarray field to regtype. That way, should the array type happen to lie in a schema not in your search_path, the name will even be correctly schema-qualified. (In fact, it's not the cast which does the translation but rather the implicit conversion from regtype to cstring that happens when the result is transferred to the client. For further information, you might want to check out the documentation of the various reg* types provided by postgres). Hope that helps, Florian Pflug -- // Dmitriy.
Re: [HACKERS] pg_type.typname of array types.
On 12/08/2010 05:35 AM, Dmitriy Igrishin wrote: Hey hackers@, Is it guaranteed that name of array types in pg_type system catalog will always be prefixed by underscore or this convention can be changed in future ? It is not guaranteed today, let alone in the future, that the array type for x will be _x for any x. Consider: andrew=# create type _foo as (x int); create type foo as (y text);select typname from pg_type where oid = (select typarray from pg_type where typname = 'foo'); CREATE TYPE CREATE TYPE typname - ___foo (1 row) cheers andrew -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] pg_type.typname of array types.
Dmitriy Igrishin dmit...@gmail.com writes: Is it guaranteed that name of array types in pg_type system catalog will always be prefixed by underscore No. Read the code, or the documentation. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] pg_type.typname of array types.
Hey Andrew, Finally convinced. Thanks! 2010/12/8 Andrew Dunstan and...@dunslane.net On 12/08/2010 05:35 AM, Dmitriy Igrishin wrote: Hey hackers@, Is it guaranteed that name of array types in pg_type system catalog will always be prefixed by underscore or this convention can be changed in future ? It is not guaranteed today, let alone in the future, that the array type for x will be _x for any x. Consider: andrew=# create type _foo as (x int); create type foo as (y text);select typname from pg_type where oid = (select typarray from pg_type where typname = 'foo'); CREATE TYPE CREATE TYPE typname - ___foo (1 row) cheers andrew -- // Dmitriy.
Re: [HACKERS] pg_type.typname of array types.
Hey Tom, Thanks you too. I always read the documentation, but don't want (yes, don't want) to read a lot of code to get the answer on simple question because life is too short for it. I think that people should helps each other :-) 2010/12/8 Tom Lane t...@sss.pgh.pa.us Dmitriy Igrishin dmit...@gmail.com writes: Is it guaranteed that name of array types in pg_type system catalog will always be prefixed by underscore No. Read the code, or the documentation. regards, tom lane -- // Dmitriy.
Re: [HACKERS] pg_type.typname of array types.
Dmitriy Igrishin dmit...@gmail.com writes: I always read the documentation, but don't want (yes, don't want) to read a lot of code to get the answer on simple question because life is too short for it. I think that people should helps each other :-) Fine, but that sort of question doesn't belong on pgsql-hackers. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] pg_type.typname of array types.
On Wed, Dec 8, 2010 at 11:09 AM, Tom Lane t...@sss.pgh.pa.us wrote: Dmitriy Igrishin dmit...@gmail.com writes: I always read the documentation, but don't want (yes, don't want) to read a lot of code to get the answer on simple question because life is too short for it. I think that people should helps each other :-) Fine, but that sort of question doesn't belong on pgsql-hackers. Right. Perhaps it's useful to quote the description of the list[1]: The PostgreSQL developers team lives here. Discussion of current development issues, problems and bugs, and proposed new features. If your question cannot be answered by people in the other lists, and it is likely that only a developer will know the answer, you may re-post your question in this list. You must try elsewhere first! -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company [1] http://archives.postgresql.org/pgsql-hackers/ -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] pg_type.typname of array types.
Okay, I understand you hint, Tom and Robert. Sorry to trouble. I've ask here because I thought that exactly only developer will know the answer on my question: is it guaranteed ... ?. Many thanks to Florian and Andrew for detailed explanations, advice and etc without pointing me to the sources. Respect! :-) 2010/12/8 Robert Haas robertmh...@gmail.com On Wed, Dec 8, 2010 at 11:09 AM, Tom Lane t...@sss.pgh.pa.us wrote: Dmitriy Igrishin dmit...@gmail.com writes: I always read the documentation, but don't want (yes, don't want) to read a lot of code to get the answer on simple question because life is too short for it. I think that people should helps each other :-) Fine, but that sort of question doesn't belong on pgsql-hackers. Right. Perhaps it's useful to quote the description of the list[1]: The PostgreSQL developers team lives here. Discussion of current development issues, problems and bugs, and proposed new features. If your question cannot be answered by people in the other lists, and it is likely that only a developer will know the answer, you may re-post your question in this list. You must try elsewhere first! -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company [1] http://archives.postgresql.org/pgsql-hackers/ -- // Dmitriy.
[HACKERS] pg_type.typname of array types.
Hey hackers@, Is it guaranteed that name of array types in pg_type system catalog will always be prefixed by underscore or this convention can be changed in future ? Thanks. -- // Dmitriy.
Re: [HACKERS] pg_type.typname of array types.
On Dec8, 2010, at 11:35 , Dmitriy Igrishin wrote: Is it guaranteed that name of array types in pg_type system catalog will always be prefixed by underscore or this convention can be changed in future ? What's the advantage of letting your code depend on this? Within SQL, I suggest you write type[] to denote type's array type. In the catalog, each pg_type row contains a references the corresponding array type (by OID) in the field typarray. BTW, when querying pg_type, instead of adding another join to pg_type to get the array type's name, you can simply cast the typarray field to regtype. That way, should the array type happen to lie in a schema not in your search_path, the name will even be correctly schema-qualified. (In fact, it's not the cast which does the translation but rather the implicit conversion from regtype to cstring that happens when the result is transferred to the client. For further information, you might want to check out the documentation of the various reg* types provided by postgres). Hope that helps, Florian Pflug -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers