psql Week 4

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

Alrighty, this is it. I submit this to your scrutiny in the hope that it
will prove useful and reliable.

The source is at <http://www.pathwaynet.com/~peter/psql-final.tar.gz>
(49k). In a perfect world you could just drop the directory into your
source tree and configure and compile again. Whether or not it is a
perfect world we will find out soon enough, I suppose.

Three patches are included in the tarball. One is a minor libpq fix which
I submitted the other day already and which is mandatory. (I now see it is
in the current tree already). Two more are to put a test of getopt_long
in the autoconf business. Other than that the changes are restricted to
the psql directory.

I'm going to do some more work on it but those should be localized
changes. Here are a few unresolved issues:

* It is now consistently possible to put several slash commands on a line,
even mixed with SQL, such as:
=> select * from \t \o file.out \x \\ my_table \g
This might cause a problem in Windows, if you need to write, for example,
\o \temp\dir. The fix would be to write \o '\temp\dir' (as opposed to \o
"\temp\dir", because that would be subject to substitutions like \t =>
tab). As this might be cumbersome I give the option to the Windows
community: disable things like the above command line completely or quote
your stuff. It's a tradeoff.
(On the other hand, I was at some point under the impression that
in C on Windows you could actually use forward slashes in your file names
which would be converted by some magic layer, thus making this a
non-issue.(?))

* Slash commands can only have up to 16 options. This is purely my own
laziness. Of course, no single slash command actually uses more than three
options, but it sure is unsatisfying.

* The \d* command silently disappeared. It's previous semantics where
"show everything" but I'm not quite sure what that should be short of
rewriting pg_dump.

* Heaven help you if you want to compile this under Windows. I don't have
Windows, so some porter will have to take care of that.

I am writing DocBook documentation right now and an updated version should
be available within 48 hours. For a starter here is a session that
attempts to illustrate a couple of the quoting and substitution features:

play=> \set foo 'bar'
play=> \echo $foo
bar
play=> \echo bla$foo
bla$foo
play=> \echo "bla${foo}bla"
blabarbla
play=> \echo 'bla${foo}bla'
bla${foo}bla
play=> \echo "a\nb"
a
b
play=> \echo 'a\nb'
a\nb
play=> \echo `uname -rms`
Linux 2.2.12 i586
play=> \set sql_interpol '#'
play=> \set singlestep on
play=> \set blah `/usr/games/fortune`
play=> insert into foo values (0, '#blah#');
***(Single step mode: Verify query)*********************************************
QUERY: insert into foo values (0, 'Everything you read in newspapers is
absolutely true, except for that
rare story of which you happen to have first-hand knowledge.
-- Erwin Knoll')
***(press return to proceed or enter x and return to cancel)********************
x

If you use the large object operations, your previous transaction will be
rolled back. To change this do \set lo_transaction 'commit' or \set
lo_transaction 'nothing' (in which case you must provide your own
BEGIN/END block).

Most other stuff can be determined from \? or -?, respectively, and also
from the changelogs I posted in the past.

Enjoy!

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

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-10-26 16:46:54 Re: [HACKERS] Function-manager redesign: second draft (long)
Previous Message Bruce Momjian 1999-10-26 16:31:33 Re: [HACKERS] Current source from CVS won't compile.