pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Melvin Davidson <melvin6925@gmail.com>
To: DiasCosta <diascosta@diascosta.org>
Cc: Łukasz Jarych <jaryszek@gmail.com>
Cc: pgsql-general@postgresql.org >> PG-General Mailing List <pgsql-general@postgresql.org>
Subject: Re: Cloning schemas
Date: Mon, 9 Jul 2018 11:56:02 -0700
Message-ID: <635f1be9-284c-1a49-af20-36823e46fd1a@aklaver.com> (raw)
In-Reply-To: <CANu8FiyGaryragUWXa5u=csvULcbSy-Az9kUqA2r22JdaRzktw@mail.gmail.com>
References: <CAGv31ofHAE49iTQ4_Q_AiTduoVscQWXKfZanYU0yQP8HyxPJvQ@mail.gmail.com>
	<63460.1530538220@sss.pgh.pa.us>
	<CAGv31od+cuXFttW4FmVGPBJBvjbNBpwgeuhNKfDmqLGqyQMY-Q@mail.gmail.com>
	<c941ac40-83cb-9d7b-e0f5-82f48f98cd95@aklaver.com>
	<CAGv31odxm_oYK77sdByTh=i-u-5_13CCz2nGTie4mgnovcdM2Q@mail.gmail.com>
	<CANu8FizWiVke-W7j2a-JMKxVwhFUOGjAUnX756Jt5jOJdFnD5A@mail.gmail.com>
	<CAGv31odHuHpY3N8U3eyzOK8qCjdoxu78gTovuxKoKNsyb+5QOA@mail.gmail.com>
	<CANu8FizwHA5qDrS8do2kVR7oEcCCdy4V7HXHd9OLgHo23YXztA@mail.gmail.com>
	<dc9c8e39-6b3a-dce3-c51b-c31ef0dffb4e@diascosta.org>
	<CANu8FiyK5SN0Dq_AmoNOQ0+HCR5PoTKmun42+=VV1Q4QqDa4bA@mail.gmail.com>
	<13cb7f8b-4f3f-b079-f282-73bd48595a07@diascosta.org>
	<a88871b6-de8e-efa6-c85d-260ed4df55ba@diascosta.org>
	<CANu8FiyGaryragUWXa5u=csvULcbSy-Az9kUqA2r22JdaRzktw@mail.gmail.com>

On 07/09/2018 09:49 AM, Melvin Davidson wrote:
> 
> 
> On Mon, Jul 9, 2018 at 12:32 PM, DiasCosta <diascosta@diascosta.org 
> <mailto:diascosta@diascosta.org>> wrote:
> 
>     Hi Melvin,
> 
>     Trying run 9.6 clone_schema on a different schema and I get the
>     following error:
> 
>     NOTICE:  search path = {public,pg_catalog}
>     CONTEXT:  PL/pgSQL function clone_schema(text,text,boolean) line 79
>     at RAISE
>     ERROR:  relation "bilhetica_logic_schema.idx_unq_cod_operador_aml"
>     does not exist
>     CONTEXT:  SQL statement "COMMENT ON INDEX
>     bilhetica_logic_schema.idx_unq_cod_operador_aml IS 'garante
>     unicidade do Cod_Operador_AML';"
>     PL/pgSQL function clone_schema(text,text,boolean) line 401 at EXECUTE
>     ********** Error **********
> 
>     ERROR: relation "bilhetica_logic_schema.idx_unq_cod_operador_aml"
>     does not exist
>     SQL state: 42P01
>     Context: SQL statement "COMMENT ON INDEX
>     bilhetica_logic_schema.idx_unq_cod_operador_aml IS 'garante
>     unicidade do Cod_Operador_AML';"
>     PL/pgSQL function clone_schema(text,text,boolean) line 401 at EXECUTE
> 
> 
>     Can you help me, please?
>     Thanks in advance
>     Dias Costa
> 
> 
> Dias
>  > NOTICE:  search path = {public,pg_catalog}
>  >ERROR: relation "bilhetica_logic_schema.idx_unq_cod_operador_aml" does 
> not exist
> 
> This is not related to the clone_schema function. It looks like you may 
> have corruption in your syste catalogs,
> Try reindexing your system_catalogs.

Or from clone_schema.sql:

EXECUTE 'CREATE TABLE ' || buffer || ' (LIKE ' || 
quote_ident(source_schema) || '.' || quote_ident(object)
         || ' INCLUDING ALL)';

https://www.postgresql.org/docs/10/static/sql-createtable.html

"LIKE source_table [ like_option ... ]

...

Indexes, PRIMARY KEY, UNIQUE, and EXCLUDE constraints on the original 
table will be created on the new table only if INCLUDING INDEXES is 
specified. <*/Names for the new indexes and constraints are chosen 
according to the default rules, regardless of how the originals were 
named. (This behavior avoids possible duplicate-name failures for the 
new indexes.)/*>

...
INCLUDING ALL is an abbreviated form of INCLUDING COMMENTS INCLUDING 
CONSTRAINTS INCLUDING DEFAULTS INCLUDING IDENTITY INCLUDING INDEXES 
INCLUDING STATISTICS INCLUDING STORAGE.

..."

See tagged part(<*/ /*>) part above. I could see where the indexes in 
the new schema have new names while the index comments in the old schema 
refer to the old name. Then you would get the error the OP showed.

> 
> REINDEX VERBOSE SYSTEM  <your_database_name>;
> 
> 
> 
> -- 
> *Melvin Davidson**
> Maj. Database & Exploration Specialist**
> Universe Exploration Command – UXC***
> Employment by invitation only!


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (35+ messages)  latest in thread

Message-ID: <635f1be9-284c-1a49-af20-36823e46fd1a@aklaver.com>
Permalink:  ../635f1be9-284c-1a49-af20-36823e46fd1a@aklaver.com/
Also on:    postgresql.org/message-id/635f1be9-284c-1a49-af20-36823e46fd1a@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, melvin6925@gmail.com, diascosta@diascosta.org, jaryszek@gmail.com
  Subject: Re: Cloning schemas
  In-Reply-To: <635f1be9-284c-1a49-af20-36823e46fd1a@aklaver.com>
  References: <CAGv31ofHAE49iTQ4_Q_AiTduoVscQWXKfZanYU0yQP8HyxPJvQ@mail.gmail.com> <63460.1530538220@sss.pgh.pa.us> <CAGv31od+cuXFttW4FmVGPBJBvjbNBpwgeuhNKfDmqLGqyQMY-Q@mail.gmail.com> <c941ac40-83cb-9d7b-e0f5-82f48f98cd95@aklaver.com> <CAGv31odxm_oYK77sdByTh=i-u-5_13CCz2nGTie4mgnovcdM2Q@mail.gmail.com> <CANu8FizWiVke-W7j2a-JMKxVwhFUOGjAUnX756Jt5jOJdFnD5A@mail.gmail.com> <CAGv31odHuHpY3N8U3eyzOK8qCjdoxu78gTovuxKoKNsyb+5QOA@mail.gmail.com> <CANu8FizwHA5qDrS8do2kVR7oEcCCdy4V7HXHd9OLgHo23YXztA@mail.gmail.com> <dc9c8e39-6b3a-dce3-c51b-c31ef0dffb4e@diascosta.org> <CANu8FiyK5SN0Dq_AmoNOQ0+HCR5PoTKmun42+=VV1Q4QqDa4bA@mail.gmail.com> <13cb7f8b-4f3f-b079-f282-73bd48595a07@diascosta.org> <a88871b6-de8e-efa6-c85d-260ed4df55ba@diascosta.org> <CANu8FiyGaryragUWXa5u=csvULcbSy-Az9kUqA2r22JdaRzktw@mail.gmail.com> <635f1be9-284c-1a49-af20-36823e46fd1a@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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