Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUxxX-0004RD-O7 for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Oct 2020 20:10:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kUxxW-0007Mh-Hm for pgsql-bugs@arkaria.postgresql.org; Tue, 20 Oct 2020 20:10:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUxxW-0007JD-BM for pgsql-bugs@lists.postgresql.org; Tue, 20 Oct 2020 20:10:14 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUxxU-0004aZ-AW for pgsql-bugs@lists.postgresql.org; Tue, 20 Oct 2020 20:10:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09KKAAn4674893; Tue, 20 Oct 2020 16:10:10 -0400 From: Tom Lane To: 1250kv <1250kv@gmail.com> cc: PostgreSQL mailing lists Subject: Re: ECPG bug: "unterminated quoted identifier" In-reply-to: References: <652858.1603214598@sss.pgh.pa.us> Comments: In-reply-to 1250kv <1250kv@gmail.com> message dated "Tue, 20 Oct 2020 21:18:04 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <674891.1603224610.1@sss.pgh.pa.us> Date: Tue, 20 Oct 2020 16:10:10 -0400 Message-ID: <674892.1603224610@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 1250kv <1250kv@gmail.com> writes: > EXEC SQL char *bar = foo; I think it's pure luck that that doesn't throw an error. You should not be using the EXEC SQL prefix for something that isn't a SQL command. Anyway, the problem you're hitting here is that as soon as you say EXEC SQL, the syntax rules for quoted strings change. This is not well documented, and I think it's got some bugs in itself [1], but "EXEC SQL char *bar = "aaa\"bbb";" is just wrong. You can't use C literal syntax inside a SQL code segment, whether or not the command would work otherwise. regards, tom lane [1] https://www.postgresql.org/message-id/673825.1603223178%40sss.pgh.pa.us