Newbie project: Detect attempts to run pg_dump etc on psql, \copy on server

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Newbie project: Detect attempts to run pg_dump etc on psql, \copy on server
Date: 2017-05-01 01:51:26
Message-ID: CAMsr+YGH4iAZebbuubEtiqEMgv9c0ynvL_Thgh3PHR2tr4fWFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This is a proposal for a new developer patch idea, in case someone's interested.

Keeping an eye on Stack Overflow has shown me that quite a few people
seem to get confused by pg_dump and pg_restore being command line
tools, not psql commands.

It'd be interesting if psql detected this and gave a useful error.
Ideally before they enter ; to terminate the line, since they're
probably following instructions that won't show one.

A related patch would be to have the parser detect \copy and other
psql backslash metacommands run as SQL queries on the server and
report a useful error. For \copy, it would HINT to look at their
client's manual for COPY support or user server-side COPY. For others
it'd say these are psql commands not postgres commands and only work
in the psql client.

One might argue that we don't need to pad things _this_ much for new
users. But I see users getting confused by psql metacommands vs
postgres server commands a lot. Similarly by pg_dump and pg_restore
being shell programs.

If it can be done at minimal cost to everyone else, it might be worth
it. Just an idea.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Browse pgsql-hackers by date

  From Date Subject
Next Message Petr Jelinek 2017-05-01 01:54:49 Re: snapbuild woes
Previous Message Andres Freund 2017-05-01 01:35:29 Re: snapbuild woes