psql Week 2

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: psql Week 2
Date: 1999-10-11 19:43:16
Message-ID: Pine.LNX.4.10.9910112123420.832-100000@peter-e.yi.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Here's the long-awaited next edition. For those who must get their hands
on some code I have a tarball at
http://www.pathwaynet.com/~peter/psql.tar.bz2
It includes a file RELEASENOTES which should help you get started.

CHANGELOG

* Sorted out -e and -E: -e toggles query echoing in non-interactive
mode (why would you want to echo queries in interactive mode?). -E
enables showing of queries sent behind your back and is independent
of -e.
* Sorted out usernames and passwords: Switch -U specifies username or
"?" for "prompt me". Switch -P is "prompt for password". Old -u is
equivalent to -U ? -P. Equivalent changes to \connect (e.g., \c - ?
= connect to current database and ask for new username (and prompting
for password iff -u or -P mode)).
* Command history is saved and loaded automatically. Also, history and
readline are separately enabled in the code. (like anyone needs that)
* Allow versioned startup files (like .psqlrc-6.6.0), at least during
development.
* psql now has internal variables. Use \set and \unset to
set/unset/display them. The amount of internal state got out of hand,
so this should help. Most of the settings will be moved to some
variable. (The implementation is currently quite naive, but
encapsulated well to change it later on.)
* -q switch is now equivalent to setting variable quiet. Audited what
messages should be quieted, what are errors, what is normal output,
what is query output.
* Copy-in now has customizable prompt as well.
* Wrote a better strtok, with quoting capabilities, which is now used
to parse the options of the slash commands. (This will break
backward compatibility if you use filenames with spaces and quotes
since they will now be interpreted differently. Too bad.)
* Cleaned up various \d<x> commands. The queries are now
human-readable in -E mode. (Also they now show up in -E mode, and
not in -e mode!)
* -E mode is now the variable echo_secret. If you set the variable to
'noexec' then the "backdoor" queries will only be displayed, not
executed. (Nice if you just want to study the queries.)
* If a connection goes bad during query execution, PQreset is
attempted. If it still is bad, then an _interactive_ session will be
in unconnected mode. (Changed prompt to reflect that.)
* Ctrl-C only sends cancel request if query in progress (otherwise
default action = terminate program). This removes a major annoyance
(I hope).
* Refined \c[onnect]'ion failures: Non-interactive scripts will
terminate, even recursively. However, if the underlying session was
an interactive one, it does not terminate. The database connection
will be lost, however.
* Password prompts are automatic (both startup and \connect). Can
still use -P switch, but that might prove unnecessary. [ Cheers to
Roland R.! ]
* Implemented \lo_import, \lo_export, \lo_unlink, \lo_list. (Still
needs some refinement, though.)
* Can now use \copy with oids and delimiters. No binary, yet.

TODO LIST

* generalized backslash command handling (struct, no ..else if...)
* new printing routines
* rewrite mainloop parser, strip comments
* single line mode doesn't take slash commands
* make scripts bomb out (optionally) on query error
* remove Rollback warnings in lo_ ops
* \default(s?) command
* allow several \ cmds on a line (add '\' to strtokx delims?, windows?)

SIDE NOTES

1. Since the new animal is now probably going to be 7.0, let's provide a
psql that's worthy of that name, er, number. I hope I can lay a
framework with this, but there are still a few months I think, so ideas
are welcome.

1.a) On a related note, since the core developers have more important
issues to worry about, I wouldn't mind maintaining/accompanying/taking
care of/keeping an eye on/whatever psql until release (and possibly
thereafter).

2. What about including an snprintf() into the source tree similar what is
done with strdup()? (No, don't look at me, it totally escapes me how to
do that and I don't want to cheat and look at the GNU sources for
obvious reasons.)

--
Peter Eisentraut Sernanders vaeg 10:115
peter_e(at)gmx(dot)net 75262 Uppsala
http://yi.org/peter-e/ Sweden

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 1999-10-11 19:52:14 bison
Previous Message Bruce Momjian 1999-10-11 19:20:45 pginterface/pgeasy