Обсуждение: Re: [HACKERS] Namespace of array of user defined types is confused by the parser in insert?

Поиск
Список
Период
Сортировка

Re: [HACKERS] Namespace of array of user defined types is confused by the parser in insert?

От
Andrew Dunstan
Дата:
[redirected to pgsql-general]


On 04/23/2012 09:42 AM, Krzysztof Nienartowicz wrote:
> Hello,
> Sorry for re-posting - I initially posted this in pgsql.sql - probably
> this group is more appropriate.


pgsql-general probably would be best. -hackers is for discussion of
internals and development, not for usage questions.


[types have namespaces]

> Is there any way of avoid this error different than having a single
> type defined for all schemas?
> Any hints appreciated..


Probably your best bet is to put the types explicitly in the public
namespace when they are created, instead of relying on the search path
that happens to be in force at the time:

    create type public.foo as ( ...);


Then, assuming that public is in your search path they will be picked up
properly when used. Alternatively, you can namespace qualify them when used:

    create type public.bar as (f1 public.foo[], ...);



cheers

andrew

Re: [HACKERS] Namespace of array of user defined types is confused by the parser in insert?

От
Krzysztof Nienartowicz
Дата:
> pgsql-general probably would be best. -hackers is for discussion of internals and development, not for usage
questions.

ok, thank you.

>
> [types have namespaces]
>
>
>> Is there any way of avoid this error different than having a single
>> type defined for all schemas?
>> Any hints appreciated..
>
>
>
> Probably your best bet is to put the types explicitly in the public
> namespace when they are created, instead of relying on the search path that
> happens to be in force at the time:
>
>   create type public.foo as ( ...);

Yes, I did it in the end, but such a solution makes things risky if
the types evolve and the namespaces might hold different schema
versions.
This error occurs when there is no search_path overlap, i.e. roles
have only their own namespace search_path, even without public path
set.

>
>
> Then, assuming that public is in your search path they will be picked up
> properly when used. Alternatively, you can namespace qualify them when used:
>
>   create type public.bar as (f1 public.foo[], ...);

These types are qualified when created - the error does not happen on
creation - there are two types in two different namespaces - it
happens only on insert where it is not possible to qualify the type's
namespace.
It looks like a bug in the planner to me.

Thanks,
Krzysztof

>
>
>
> cheers
>
> andrew

Re: [HACKERS] Namespace of array of user defined types is confused by the parser in insert?

От
Andrew Dunstan
Дата:

On 04/24/2012 05:12 AM, Krzysztof Nienartowicz wrote:
>
> These types are qualified when created - the error does not happen on
> creation - there are two types in two different namespaces - it
> happens only on insert where it is not possible to qualify the type's
> namespace.
> It looks like a bug in the planner to me.
>

If it is please present a self-contained case demonstrating the bug,
preferably using psql rather than JDBC. Was all this done with the same
user / search path throughout the session (no connection pooling, for
example)? A complete log of the session (with log_statements,
log_connections and log_disconnections all turned on) might also help.

cheers

andrew