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 1k6q2r-0004GW-P7 for pgsql-general@arkaria.postgresql.org; Sat, 15 Aug 2020 06:52:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k6q2q-0001Je-ND for pgsql-general@arkaria.postgresql.org; Sat, 15 Aug 2020 06:52:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k6q2q-0001JV-FJ for pgsql-general@lists.postgresql.org; Sat, 15 Aug 2020 06:52:00 +0000 Received: from mxout2.rambler.ru ([81.19.78.101]) by magus.postgresql.org with esmtps (TLS1.1:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1k6q2k-0003EK-GL for pgsql-general@postgresql.org; Sat, 15 Aug 2020 06:51:57 +0000 Received: from saddam1.rambler.ru (saddam1.rambler.ru [10.32.16.1]) by mxout2.rambler.ru (Postfix) with ESMTP id F10F48DC13D; Sat, 15 Aug 2020 09:51:53 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rambler.ru; s=mail; t=1597474313; bh=JnANY+M/+9N5M3fRiMb1XlvUwTTkNUyVN2JkeemJBVI=; h=From:To:Cc:Reply-To:Subject:Date:In-Reply-To:References; b=HWsdevIumCiYNFYMDN/yH2pMaTnn3c7vhMR0UQPWPkHQmKn1tDV3kI7XD5WlPlFdy +bvNpwo7Pu+MUgFOiUHaeDiSn5nGu7GTXknLeTkMw8VLWFSkI6YKFKPZmbB21C9OvU 3loA69UKpMboyf7KFpooq5GczP9c/HsRFR4BeJ68= Received: from localhost.localdomain (localhost [127.0.0.1]) by saddam1.rambler.ru (Postfix) with ESMTP id D81575A68F7; Sat, 15 Aug 2020 09:51:53 +0300 (MSK) Received: from [93.123.182.191] by mail.rambler.ru with HTTP; Sat, 15 Aug 2020 09:51:53 +0300 From: "Aleksey M Boltenkov" To: holybolt@rambler.ru Cc: "pgsql-general" , tgl@sss.pgh.pa.us Reply-To: "Aleksey M Boltenkov" Subject: RE: bug in psql? Date: Sat, 15 Aug 2020 09:51:53 +0300 Content-Transfer-Encoding: 7bit Content-Type: multipart/alternative; boundary="_----------=_1597474313307667" In-Reply-To: <1597473963.149369.29614.15174@mail.rambler.ru> Message-Id: <1597474313.828133.30766.37520@mail.rambler.ru> MIME-Version: 1.0 References: <1597473963.149369.29614.15174@mail.rambler.ru> 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. --_----------=_1597474313307667 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; format="flowed" 15.08.2020, 09:46, Aleksey M Boltenkov 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. Sorry, \gexec does not work, copy and paste. Aleksey M Boltenkov. --_----------=_1597474313307667 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="utf-8"
15.08.2020, 09:46, Aleksey M Boltenkov <holybo= lt@rambler.ru>
15.0= 8.2020, 08:56, Tom Lane <tgl@sss.pgh.pa.us>
"Aleksey M Boltenkov" <holybolt@rambler.ru> writes:
&g= t; Is this a bug?

> pg01:5432 postgres@db=3D# select 'any expression'any e= xpression\d+;

No.   The "\d+;" is taken as a backslash c= ommand, 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.

 &nbs= p;             =            regards, tom l= ane
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 o= n 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 in= to x.y ( field, ... ) select '2020_07_29'::date, field, ... from x.y_archiv= e_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, fiel= d, ... from x.y_archive_2020_08_12 on conflict ( constraint ) do nothing;\d= ti+ x.y_new_scheme*

\gexec


Aleksey M Boltenkov.
Sorry, \gexec does not work, copy and paste.

Aleksey M Boltenkov.


= --_----------=_1597474313307667--