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 1k6pxF-00042D-7w for pgsql-general@arkaria.postgresql.org; Sat, 15 Aug 2020 06:46:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k6pxD-0003k1-OV for pgsql-general@arkaria.postgresql.org; Sat, 15 Aug 2020 06:46:11 +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 1k6pxD-0003ju-Bj for pgsql-general@lists.postgresql.org; Sat, 15 Aug 2020 06:46:11 +0000 Received: from mxout3.rambler.ru ([81.19.78.102]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k6px8-0002gi-Oe for pgsql-general@postgresql.org; Sat, 15 Aug 2020 06:46:10 +0000 Received: from saddam1.rambler.ru (saddam1.rambler.ru [10.32.16.1]) by mxout3.rambler.ru (Postfix) with ESMTP id 528DB7C0345; Sat, 15 Aug 2020 09:46:03 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rambler.ru; s=mail; t=1597473963; bh=VB6oWoFk5EGDjOX0PdCj7sHFaV93pdT8e7+WLvkjGSU=; h=From:To:Cc:Reply-To:Subject:Date:In-Reply-To:References; b=WfgMzPslrf2cr0/68iNityaoyWk6YJLUb/TBqlPEga0lZL8l2D3cw//B9njcvMG5L 4n/rP4OXum+K8cBC7+1p0vxyJ6WMoxqicvJET7EI+ZBWY2J7qj8Ca6wouc0+ujnhL4 nXA/4v+kekinUxKOQN1G2mCz65aFOgMiOF6O1m6o= Received: from localhost.localdomain (localhost [127.0.0.1]) by saddam1.rambler.ru (Postfix) with ESMTP id 311895A68F5; Sat, 15 Aug 2020 09:46:03 +0300 (MSK) Received: from [93.123.182.191] by mail.rambler.ru with HTTP; Sat, 15 Aug 2020 09:46:03 +0300 From: "Aleksey M Boltenkov" To: tgl@sss.pgh.pa.us Cc: "pgsql-general" Reply-To: "Aleksey M Boltenkov" Subject: RE: bug in psql? Date: Sat, 15 Aug 2020 09:46:03 +0300 Content-Transfer-Encoding: 7bit Content-Type: multipart/alternative; boundary="_----------=_15974739632961491" In-Reply-To: <849647.1597470992@sss.pgh.pa.us> Message-Id: <1597473963.149369.29614.15174@mail.rambler.ru> MIME-Version: 1.0 References: <849647.1597470992@sss.pgh.pa.us> X-Mailer: Rambler WebMail, http://mail.rambler.ru/ X-Rambler-User: holybolt@rambler.ru/93.123.182.191 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --_----------=_15974739632961491 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; format="flowed" 15.08.2020, 08:56, Tom Lane "Aleksey M Boltenkov" writes: > Is this a bug? > pg01:5432 postgres@db=3D# select 'any expression'any expression\d+; No. The "\d+;" is taken as a backslash command, and is executed. The rest of what you typed is still waiting in the query buffer. It's bit weird perhaps, since \d seems like a "do-something" command rather than a query buffer editing command. But psql uses the same rules for both cases. regards, tom lane Yes, i have used it for a long, but it was always wellformed, so malformed = query was some kind of surprise. select format('insert into x.y ( field, ... ) select val, ... from %I.%I on conflict ( constraint ) do nothing;\dti+ x.y*', (regexp_match(tablename, '\d[\d_]+$'))[1], schemaname, tablename) from pg_tables where schemaname = =3D 'x' and tablename ~ '^y' order by 1; insert into x.y ( field, ... ) select '2020_07_29'::date, field, ... from x.y_archive_2020_07_29 on conflict ( constraint ) do nothing;\dti+ x.y_new_scheme* insert into x.y ( field, ... ) select '2020_08_05'::date, field, ... from x.y_archive_2020_08_05 on conflict ( constraint ) do nothing;\dti+ x.y_new_scheme* insert into x.y ( field, ... ) select '2020_08_12'::date, field, ... from x.y_archive_2020_08_12 on conflict ( constraint ) do nothing;\dti+ x.y_new_scheme* \gexec Aleksey M Boltenkov. --_----------=_15974739632961491 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"
15.08.2020, 08:56, Tom Lane <tgl@sss.pgh.pa.us= >
"Aleksey M Boltenkov" <holybolt@rambler.ru> writes: > Is this a bug?

> pg01:5432 postgres@db=3D# select 'any expression'any expression\d+;
=
No.   The "\d+;" is taken as a backslash command, and is exe= cuted.
The rest of what you typed is still waiting in the query buffer.=

It's bit weird perhaps, since \d seems like a "do-something"
= command rather than a query buffer editing command.   But
psq= l uses the same rules for both cases.

    &nbs= p;              = ;       regards, tom lane
=
Yes, i have used it for a long,= but it was always wellformed, so malformed query was some kind of surprise= .

select format('insert = into x.y ( field, ... ) select val, ... from %I.%I on conflict ( constraint= ) do nothing;\dti+ x.y*', (regexp_match(tablename, '\d[\d_]+$'))[1], schem= aname, tablename) from pg_tables where schemaname =3D 'x' and tablename ~ '= ^y' order by 1;

insert into x= .y ( field, ... ) select '2020_07_29'::date, field, ... from x.y_archive_20= 20_07_29 on conflict ( constraint ) do nothing;\dti+ x.y_new_scheme*
in= sert into x.y ( field, ... ) select '2020_08_05'::date, field, ... from x.y= _archive_2020_08_05 on conflict ( constraint ) do nothing;\dti+ x.y_new_sch= eme*
insert into x.y ( field, ... ) select '2020_08_12'::date, field, .= .. from x.y_archive_2020_08_12 on conflict ( constraint ) do nothing;\dti+ = x.y_new_scheme*

\gexec



=
Aleksey M Boltenkov.

= --_----------=_15974739632961491--