Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIKjE-0001o3-P1 for pgsql-sql@arkaria.postgresql.org; Wed, 09 Oct 2019 22:46:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iIKjD-0006JL-1X for pgsql-sql@arkaria.postgresql.org; Wed, 09 Oct 2019 22:46:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIKjC-0006JC-M2 for pgsql-sql@lists.postgresql.org; Wed, 09 Oct 2019 22:46:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iIKjA-0001HH-8M for pgsql-sql@postgresql.org; Wed, 09 Oct 2019 22:46:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x99MkcC8017816; Wed, 9 Oct 2019 18:46:38 -0400 From: Tom Lane To: Alex Williams cc: "pgsql-sql@postgresql.org" Subject: Re: pg_dump compatibility level / use create view instead of create table/rule In-reply-to: <18dWrRFcmR7qHhsVTvYfGuRT8Tx5LijYQ72SeMWaya_0FiBkS5BFiYTa47R5WVTlADzXAqI85sZgkKPFVdJP2UWsUwJty3KuZ4eZvlVXO-I=@protonmail.com> References: <30565.1570597261@sss.pgh.pa.us> <18dWrRFcmR7qHhsVTvYfGuRT8Tx5LijYQ72SeMWaya_0FiBkS5BFiYTa47R5WVTlADzXAqI85sZgkKPFVdJP2UWsUwJty3KuZ4eZvlVXO-I=@protonmail.com> Comments: In-reply-to Alex Williams message dated "Wed, 09 Oct 2019 21:39:52 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17814.1570661198.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 09 Oct 2019 18:46:38 -0400 Message-ID: <17815.1570661198@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alex Williams writes: > Ugh, sorry again, missed one more part, here is the full error for the c= reate table in the log: > pg_restore: [archiver (db)] Error from TOC entry 11240; 1259 42703182 TA= BLE my_view postgres > pg_restore: [archiver (db)] could not execute query: ERROR: syntax erro= r at or near "REPLICA" > LINE 19: ...E ONLY my_view REPLICA ID... > ^ > Command was: CREATE TABLE my_view ( > product character varying(255), > product_id integer, > payer... This seems to be a chunk of a command like ALTER TABLE ONLY my_view REPLICA IDENTITY FULL; (or possibly REPLICA IDENTITY NOTHING), which pg_dump will emit if the table has a non-default relreplident setting. I do not, however, understand your statement that this is a view. AFAIK views should never have non-default relreplident settings, and besides that, the TOC entry description says it's a table not a view. (If it's a materialized view, it could have relreplident, but its TOC entry still shouldn't say TABLE.) Anyway it's hardly surprising that 9.2 is choking on that syntax; it doesn't have the REPLICA IDENTITY feature. pg_dump actually is taking some pity on you here, in that it's emitting this as a separate ALTER TABLE command, not as part of CREATE TABLE directly. This means you just need to get 9.2 to ignore the error on the ALTER TABLE and keep plugging. I think what you need to do is something like pg_restore to stdout and then pipe stdout to psql, rather than connecting directly to the target server. Another fix, if this table was only accidentally labeled with a replica identity (which I'm suspecting because you don't seem to recognize the feature), is to get rid of the marking in the source database: ALTER TABLE ONLY my_view REPLICA IDENTITY DEFAULT; regards, tom lane