DWIM mode for psql
Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.
You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:
docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t40370psql -h localhost -U postgresBuilt from patchset v1 (message #1), September 20, 2026 at 08:30 AM.
Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:
git clone --branch t40370_1 https://github.com/hackorum-dev/postgres.gitIn a checkout you already have, add the fork once:
git remote add hackorum https://github.com/hackorum-dev/postgres.gitthen, for this patchset and every later one:
git fetch hackorum t40370_1 && git checkout t40370_1Patchset v1 (message #1) is on t40370_1
Hello,
Building on the excellent work begun by commit e529cd4ffa60, I would
like to propose a do-what-I-mean mode for psql. Please find a POC
patch attached. It works like this:
postgres=# select datnaam from pg_database where ooid = 12917;
ERROR: column "datnaam" does not exist
LINE 1: select datnaam from pg_database where ooid = 12917;
^
HINT: Perhaps you meant to reference the column "pg_database.datname".
postgres=# YES
datname
----------
postgres
(1 row)
As you can see, by "shouting" a new keyword at the computer, it will
take its own hint and run the corrected query. To avoid having to do
this in two steps, you can also shout the whole query for the same
effect:
postgres=# SELECT DATNAAM FROM PG_DATABASE WHERE OOID = 12917;
datname
----------
postgres
(1 row)
The next version will be able to fix permissions problems and override
errors automatically as follows, though that is proving trickier to
get working. Example:
postgres=# SUDO DROP TABLE PG_DATABASS;
NO CARRIER
--
Thomas Munro
https://enterprisedb.com
On 2019-04-01 09:52:34 +1300, Thomas Munro wrote:
+/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version.
Indentation bug. You really need to work a bit more careful.
On Sun, Mar 31, 2019 at 5:04 PM Andres Freund <andres@anarazel.de> wrote:
On 2019-04-01 09:52:34 +1300, Thomas Munro wrote:
+/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version.Indentation bug. You really need to work a bit more careful.
The patch applies cleanly, and passes "make check", but it generated an
executable called "mongodb".
Should I have run "make maintainer-clean" first?
On 3/31/19 10:52 PM, Thomas Munro wrote:> Building on the excellent work
begun by commit e529cd4ffa60, I would
like to propose a do-what-I-mean mode for psql. Please find a POC
patch attached. It works like this:postgres=# select datnaam from pg_database where ooid = 12917;
ERROR: column "datnaam" does not exist
LINE 1: select datnaam from pg_database where ooid = 12917;
^
HINT: Perhaps you meant to reference the column "pg_database.datname".
postgres=# YES
datname
----------
postgres
(1 row)
I think it is potentially confusing that YES and NO does not look like
other psql commands. Let's pick something which is more in line with
existing commands like \y and \n.
Andreas
Hi Thomas,
Thanks for working on this.
On Mon, Apr 1, 2019 at 5:53 Thomas Munro <thomas.munro@gmail.com> wrote:
Hello,
Building on the excellent work begun by commit e529cd4ffa60, I would
like to propose a do-what-I-mean mode for psql. Please find a POC
patch attached. It works like this:postgres=# select datnaam from pg_database where ooid = 12917;
ERROR: column "datnaam" does not exist
LINE 1: select datnaam from pg_database where ooid = 12917;
^
HINT: Perhaps you meant to reference the column "pg_database.datname".
postgres=# YES
datname
----------
postgres
(1 row)As you can see, by "shouting" a new keyword at the computer, it will
take its own hint and run the corrected query. To avoid having to do
this in two steps, you can also shout the whole query for the same
effect:postgres=# SELECT DATNAAM FROM PG_DATABASE WHERE OOID = 12917;
datname
----------
postgres
(1 row)
Neat.
The next version will be able to fix permissions problems and override
errors automatically as follows, though that is proving trickier to
get working. Example:postgres=# SUDO DROP TABLE PG_DATABASS;
NO CARRIER
Have you tried rebooting the machine?
Thanks,
Amit
Show quoted text
Andreas Karlsson wrote
On 3/31/19 10:52 PM, Thomas Munro wrote:> Building on the excellent work
begun by commit e529cd4ffa60, I wouldlike to propose a do-what-I-mean mode for psql. Please find a POC
patch attached. It works like this:postgres=# select datnaam from pg_database where ooid = 12917;
ERROR: column "datnaam" does not exist
LINE 1: select datnaam from pg_database where ooid = 12917;
^
HINT: Perhaps you meant to reference the column "pg_database.datname".
postgres=# YES
datname
----------
postgres
(1 row)I think it is potentially confusing that YES and NO does not look like
other psql commands. Let's pick something which is more in line with
existing commands like \y and \n.Andreas
+1
Regards
-)))°>
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-hackers-f1928748.html