pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aleksey M Boltenkov <holybolt@rambler.ru>
To: holybolt@rambler.ru
Cc: pgsql-general <pgsql-general@postgresql.org>
Cc: tgl@sss.pgh.pa.us
Subject: RE: bug in psql?
Date: Sat, 15 Aug 2020 09:51:53 +0300
Message-ID: <1597474313.828133.30766.37520@mail.rambler.ru> (raw)
In-Reply-To: <1597473963.149369.29614.15174@mail.rambler.ru>
References: <1597473963.149369.29614.15174@mail.rambler.ru>

  15.08.2020, 09:46, Aleksey M Boltenkov <holybolt@rambler.ru>

    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=# 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 =
  '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.

view thread (10+ messages)  latest in thread

Message-ID: <1597474313.828133.30766.37520@mail.rambler.ru>
Permalink:  ../1597474313.828133.30766.37520@mail.rambler.ru/
Also on:    postgresql.org/message-id/1597474313.828133.30766.37520@mail.rambler.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: holybolt@rambler.ru, tgl@sss.pgh.pa.us
  Subject: Re: bug in psql?
  In-Reply-To: <1597474313.828133.30766.37520@mail.rambler.ru>
  References: <1597473963.149369.29614.15174@mail.rambler.ru> <1597474313.828133.30766.37520@mail.rambler.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox