Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKWQk-00031y-V7 for pgsql-admin@arkaria.postgresql.org; Wed, 07 Nov 2018 22:36:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gKWQj-0001HX-4p for pgsql-admin@arkaria.postgresql.org; Wed, 07 Nov 2018 22:36:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKWQi-0001HP-Jf for pgsql-admin@lists.postgresql.org; Wed, 07 Nov 2018 22:36:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gKWQf-00051z-Cy for pgsql-admin@lists.postgresql.org; Wed, 07 Nov 2018 22:36:06 +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 wA7Ma2wI012038; Wed, 7 Nov 2018 17:36:02 -0500 From: Tom Lane To: Ron cc: pgsql-admin@lists.postgresql.org Subject: Re: query can't merge into table of the other schema In-reply-to: References: <1425722754.312953.1541603425493.ref@mail.yahoo.com> <1425722754.312953.1541603425493@mail.yahoo.com> Comments: In-reply-to Ron message dated "Wed, 07 Nov 2018 16:22:19 -0600" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <12035.1541630162.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Wed, 07 Nov 2018 17:36:02 -0500 Message-ID: <12036.1541630162@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Ron writes: > On 11/07/2018 09:10 AM, Pepe TD Vo wrote: >> *ERROR: "cidrdba.sc_date_in" is not a known variable* > That doesn't look like a "can't merge table from another schema" error. >> *LINE 13:    MERGE INTO cidrdba.sc_date_in prod* >> *               ^* >> *SQL state: 42601* >> *Character: 352* > What happens when you run the statement through psql? It will fail, of course, since there's no MERGE statement in Postgres. I think the reason for the weird error is that the plpgsql scanner is seeing the "INTO cidrdba.sc_date_in" part and trying to process that as an "INTO plpgsql-variable" clause, before it's fed the rest of the statement to the core parser, which is what would notice that MERGE isn't a known command. Maybe we could improve matters by reordering that processing, but it might be a lot of work for a small benefit. regards, tom lane