Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 58096B5DBC8 for ; Thu, 13 Oct 2011 23:10:56 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 02786-10 for ; Fri, 14 Oct 2011 02:10:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0-rc2 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 273A2B5DBC4 for ; Thu, 13 Oct 2011 23:10:48 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p9E2Afng011635; Thu, 13 Oct 2011 22:10:41 -0400 (EDT) To: Bruce Momjian cc: Josh Berkus , pgsql-bugs@postgresql.org Subject: Re: psql's \copy incompatible with :variables In-reply-to: <201110140139.p9E1dHN00659@momjian.us> References: <201110140139.p9E1dHN00659@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Thu, 13 Oct 2011 21:39:17 -0400" Date: Thu, 13 Oct 2011 22:10:41 -0400 Message-ID: <11634.1318558241@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.404 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.504 X-Spam-Level: X-Archive-Number: 201110/114 X-Sequence-Number: 31384 Bruce Momjian writes: > Josh Berkus wrote: >> Note that psql variables work perfectly fine with COPY. It's just \copy >> which seems to be misbehaving. > The problem is that none of the backslash commands interpret variables: Nonsense. regression=# \set foo bar regression=# \d foo Did not find any relation named "foo". regression=# \d :foo Did not find any relation named "bar". \copy is different because it uses OT_WHOLE_LINE mode to read the argument, and that doesn't expand :variable references. I'd be a bit leery of changing that. regards, tom lane