Re: How to reference a composite type in schemas not "public"?

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: a <372660931(at)qq(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to reference a composite type in schemas not "public"?
Date: 2018-06-14 13:26:15
Message-ID: c8d77241-0493-8c66-7ef5-9e220269c212@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 06/13/2018 08:34 PM, a wrote:
> Hi I have created some composite type:
>
> create type "MjorTbl".mort as(
> adjfac    float8,
> tablename text,
> subtype   text,
> improv  float8,
> selfac    slfc
> );
>
> The schema is different from public, while I would like to create table
> using the composite type, it reports a error:
>
> create type "MjorTbl".decrmt as(
> nodecrmt  int4,
> mortality "MjorTbl"."mort"
> );
>
> ERROR:  type "MjorTbl.mort" does not exist
> SQL state: 42704
>
> create type "MjorTbl".decrmt as(
> nodecrmt  int4,
> mortality mort
> );
>
> ERROR:  type "mort" does not exist
> SQL state: 42704
>
> How can I reference the created composite type correctly??

Well it works here:
select version();
version

------------------------------------------------------------------------------------
PostgreSQL 10.4 on x86_64-pc-linux-gnu, compiled by gcc (SUSE Linux)
4.8.5, 64-bit

create schema "MjorTbl";
CREATE SCHEMA

create type "MjorTbl".mort as(
adjfac float8,
tablename text,
subtype text,
improv float8
);
CREATE TYPE

create type "MjorTbl".decrmt as(
nodecrmt int4,
mortality "MjorTbl"."mort"
);
CREATE TYPE

You might have a permissions issue. In your original post where all the
commands run as the same user and from the same schema?

>
> Thanks
>
> Shore
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-06-14 13:37:04 Re: How to reference a composite type in schemas not "public"?
Previous Message Lawrence Jones 2018-06-14 13:03:30 Re: Impact of multixact "members" limit exceeded