Commit Graph

267 Commits

Author SHA1 Message Date
Bruce Momjian f766b376f1 Add fflush of stdout when outputing query. 2003-07-31 04:23:40 +00:00
Peter Eisentraut c154fc3a20 Apply message style guide to frontend programs. 2003-07-23 08:47:41 +00:00
Tom Lane f9ebf36970 Update psql for some features of new FE/BE protocol. There is a
client-side AUTOCOMMIT mode now: '\set AUTOCOMMIT off' supports
SQL-spec commit behavior.  Get rid of LO_TRANSACTION hack --- the
LO operations just work now, using libpq's ability to track the
transaction status.  Add a VERBOSE variable to control verboseness
of error message display, and add a %T prompt-string code to show
current transaction-block status.  Superuser state display in the
prompt string correctly follows SET SESSION AUTHORIZATION commands.
Control-C works to get out of COPY IN state.
2003-06-28 00:12:40 +00:00
Bruce Momjian b14295cfe4 Attached is the complete diff against current CVS.
Compiles on BCC 5.5 and VC++ 6.0 (with warnings).

Karl Waclawek
2003-06-12 08:15:29 +00:00
Bruce Momjian ef2ba42717 Attached is a patch that enhances the output of psql's HTML mode.
The output now validates as HTML 4.01 Strict, XHTML 1.0 strict,
and XHTML 1.1 (assuming you wrap it in a valid html/body document).

It also wraps the output of PGRES_COMMAND_OK if the HTML tag is on,
for full compliance: this is why html_escaped_print has to be
externalized.

Greg Sabino Mullane greg@turnstep.com
2003-06-12 07:52:51 +00:00
Bruce Momjian f1792b932c Use PQfreemem() consistently, and document its use for Notify.
Keep PQfreeNotify() around for binary compatibility.
2003-03-25 02:44:36 +00:00
Bruce Momjian 4422fe6017 Remove compile warning. 2003-03-20 15:39:53 +00:00
Bruce Momjian add932ee91 I'm continuing to work on cleaning up code in psql. As things appear
now, my changes seem to work.  Some possible minor bugs got squished
on the way but I can't be sure without more feedback from people who
really put the code to the test.

The new patch mostly simplifies variable handling and reduces code
duplication.  Changes in the command parser eliminate some redundant
variables (boolean state + depth counter), replaces some
"else if" constructs with switches, and so on.  It is meant to be
applied together with my previous patch, although I hope they don't
conflict; I went back to the CVS version for this one.

One more thing I thought should perhaps be changed: an IGNOREEOF
value of n will ignore only n-1 EOFs.  I didn't want to touch this
for fear of breaking existing applications, but it does seem a tad
illogical.

Jeroen T. Vermeulen
2003-03-20 06:43:35 +00:00
Bruce Momjian be1c6e7529 Here's some changes I made last night to psql's common.c (as found in
7.3.2).  It removes some code duplication and #ifdeffing, and some
unstructured ugliness such as tacky breaks and an unneeded continue.
Breaks up a large function into smaller functions and reduces required
nesting levels, and kills a variable or two.

Jeroen T. Vermeulen
2003-03-20 06:00:12 +00:00
Bruce Momjian e733510d5d > Mph. It fails for me too when I use --enable-integer-datetimes. Looks
> like that patch still needs some work...

Yeah.  I'm really, really, *really* sorry for submitting it in the state
it was in.  I shouldn't have done that just before moving to another
country.  I found the problem last night, but couldn't get to a Net
connection until now.

The problem is in src/bin/psql/common.c, around line 250-335 somewhere
depending on the version.  The 2nd and 3rd clauses of the "while" loop
condition:

        (rstatus == PGRES_COPY_IN) &&
        (rstatus == PGRES_COPY_OUT))

should of course be:

        (rstatus != PGRES_COPY_IN) &&
        (rstatus != PGRES_COPY_OUT))

Jeroen T. Vermeulen
2003-03-20 04:49:18 +00:00
Peter Eisentraut cf1cf89649 Make the printing code somewhat more independent by not relying on
functions and global variables from the rest of psql.  Also clean up some
data type mismatches created by the last pager patch.
2003-03-18 22:15:44 +00:00
Tom Lane e4704001ea This patch fixes a bunch of spelling mistakes in comments throughout the
PostgreSQL source code.

Neil Conway
2003-03-10 22:28:22 +00:00
Tom Lane 4fff132d1b Revert patch that broke \d commands, until it can be fixed. 2003-02-21 21:34:27 +00:00
Bruce Momjian 1eb9fd49d1 Here's some changes I made last night to psql's common.c (as found in
7.3.2).  It removes some code duplication and #ifdeffing, and some
unstructured ugliness such as tacky breaks and an unneeded continue.
Breaks up a large function into smaller functions and reduces required
nesting levels, and kills a variable or two.

Jeroen T. Vermeulen
2003-02-19 03:54:39 +00:00
Tom Lane 9f1f2bfb66 Fix various places where global s/NOTICE/WARNING/ was applied with too
much enthusiasm.
2003-01-07 22:23:17 +00:00
Bruce Momjian b26dfbb0e3 Here is a patch that does just that, while maintaining the
"traditional" behavior, so the change should be transparent. Use the
command "\pset pager always" to turn it on. Anything else does the
normal toggle between "on" and "off"

Greg Sabino Mullane
2002-11-08 19:12:21 +00:00
Bruce Momjian 6d8c3d4eb3 Add popen/pclose -> _popen/_pclose() mapping for Win32. 2002-10-29 19:35:33 +00:00
Bruce Momjian b093f8825d Fix include files for new PageOutput call. 2002-10-24 01:33:50 +00:00
Bruce Momjian 641b658c26 Page \h output and centralize psql paging code in PageOutput(). 2002-10-23 19:23:57 +00:00
Tom Lane f4a7c257dc Fix unintentional breakage of COPY TO/FROM stdin. Mea culpa. 2002-10-15 16:44:21 +00:00
Tom Lane 951ec872c7 Fix psql to cope with autocommit off, at least during startup.
Behavior of backslash commands (especially for large objects)
may still require some thought.
2002-10-15 02:24:16 +00:00
Bruce Momjian a0bf2503ea The attached patch fixes a number of issues related to compiling the
client
utilities (libpq.dll and psql.exe) for win32 (missing defines,
adjustments to
includes, pedantic casting, non-existent functions) per:
   http://developer.postgresql.org/docs/postgres/install-win32.html.

It compiles cleanly under Windows 2000 using Visual Studio .net. Also
compiles clean and passes all regression tests (regular and contrib)
under Linux.

In addition to a review by the usual suspects, it would be very
desirable for  someone well versed in the peculiarities of win32 to take
a look.

Joe Conway
2002-10-03 17:09:42 +00:00
Tom Lane f7978c6f1d Avoid overflow for large elapsed times in \timing output. Per
Kenji Sugita.
2002-09-14 19:46:01 +00:00
Bruce Momjian e50f52a074 pgindent run. 2002-09-04 20:31:48 +00:00
Peter Eisentraut 7292131c66 Enable locale, so case conversion (identifier processing) and number
formatting (\timing) works correctly.  Change "Total time" to "Time"
since there is nothing that "total" refers to.  Remove non-multibyte
code.
2002-08-27 20:16:49 +00:00
Tom Lane 8be9bd83ac psql prints its version number in its startup message, per recent
discussion.  Also, cause the \timing command to display time in a
format consistent with the backend's EXPLAIN ANALYZE output.
2002-08-10 19:35:01 +00:00
Bruce Momjian 7015111a19 Move simple_prompt() into its own file to be shared with psql and pg_dump. 2002-07-06 20:12:30 +00:00
Bruce Momjian 92288a1cf9 Change made to elog:
o  Change all current CVS messages of NOTICE to WARNING.  We were going
to do this just before 7.3 beta but it has to be done now, as you will
see below.

o Change current INFO messages that should be controlled by
client_min_messages to NOTICE.

o Force remaining INFO messages, like from EXPLAIN, VACUUM VERBOSE, etc.
to always go to the client.

o Remove INFO from the client_min_messages options and add NOTICE.

Seems we do need three non-ERROR elog levels to handle the various
behaviors we need for these messages.

Regression passed.
2002-03-06 06:10:59 +00:00
Bruce Momjian 25b0b09fd3 Add \timing patch to psql. Times all queries.
Greg Sabino Mullane
2002-03-05 00:01:03 +00:00
Bruce Momjian ea08e6cd55 New pgindent run with fixes suggested by Tom. Patch manually reviewed,
initdb/regression tests pass.
2001-11-05 17:46:40 +00:00
Bruce Momjian b81844b173 pgindent run on all C files. Java run to follow. initdb/regression
tests pass.
2001-10-25 05:50:21 +00:00
Tom Lane 4fec55af6c Fix several problems with simple_prompt() --- the nastiest being that
the entered password would get echoed on some platforms, eg HPUX.
We have enough copies of this code that I'm thinking it ought to be
moved into libpq, but that's a task for another day.
2001-10-18 21:57:11 +00:00
Bruce Momjian 66b77dbcd6 Prompt for password from /dev/tty and fall back to stdin/stderr. 2001-10-15 16:40:27 +00:00
Peter Eisentraut 0acd843c05 Finish German translation, edit (original) messages a bit. 2001-06-08 23:53:48 +00:00
Peter Eisentraut e542036461 Native Language Support (NLS)
Use --enable-nls to turn it on; see installation instructions for details.
See developer's guide how to make use of it in programs and how to add
translations.

psql sources have been almost fully prepared and an incomplete German
translation has been provided.  In the backend, only elog() calls are
currently translatable, and the provided German translation file is more
of a placeholder.
2001-06-02 18:25:18 +00:00
Peter Eisentraut 15a6cd0091 If the password prompt goes to stderr, then the trailing newline should
also go there.
2001-04-15 00:43:37 +00:00
Tom Lane ea7b4f1f04 Ensure previous setting of pset.queryFout is restored after a failed
backslash-g command.
2001-03-01 18:34:29 +00:00
Tom Lane d08741eab5 Restructure the key include files per recent pghackers discussion: there
are now separate files "postgres.h" and "postgres_fe.h", which are meant
to be the primary include files for backend .c files and frontend .c files
respectively.  By default, only include files meant for frontend use are
installed into the installation include directory.  There is a new make
target 'make install-all-headers' that adds the whole content of the
src/include tree to the installed fileset, for use by people who want to
develop server-side code without keeping the complete source tree on hand.
Cleaned up a whole lot of crufty and inconsistent header inclusions.
2001-02-10 02:31:31 +00:00
Tom Lane 5491233f52 Ensure that 'errno' is saved and restored by all signal handlers that
might change it.  Experimentation shows that the signal handler call
mechanism does not save/restore errno for you, at least not on Linux
or HPUX, so this is definitely a real risk.
2000-12-18 17:33:42 +00:00
Peter Eisentraut 207f6ed3f1 Print the error message before attempting to reset the connection after a
backend crash.
2000-12-15 17:54:43 +00:00
Tom Lane 9c5327b99b Pay attention to failure returns from fgets() in all cases.
Avoid infinite loop prompting for password at stdin EOF.
2000-11-27 02:20:36 +00:00
Tom Lane e8a72c0db2 Prevent simple_prompt() from locking up in a tight loop at stdin EOF. 2000-11-27 01:28:40 +00:00
Bruce Momjian ebd61ac03f Remove -k unix socketpath option from client side, allow hostname with
leading slash to behave as a unix socket path.
2000-11-13 23:37:54 +00:00
Bruce Momjian 2150c2edf1 UUNET is looking into offering PostgreSQL as a part of a managed web
hosting product, on both shared and dedicated machines.  We currently
offer Oracle and MySQL, and it would be a nice middle-ground.
However, as shipped, PostgreSQL lacks the following features we need
that MySQL has:

1. The ability to listen only on a particular IP address.  Each
   hosting customer has their own IP address, on which all of their
   servers (http, ftp, real media, etc.) run.
2. The ability to place the Unix-domain socket in a mode 700 directory.
   This allows us to automatically create an empty database, with an
   empty DBA password, for new or upgrading customers without having
   to interactively set a DBA password and communicate it to (or from)
   the customer.  This in turn cuts down our install and upgrade times.
3. The ability to connect to the Unix-domain socket from within a
   change-rooted environment.  We run CGI programs chrooted to the
   user's home directory, which is another reason why we need to be
   able to specify where the Unix-domain socket is, instead of /tmp.
4. The ability to, if run as root, open a pid file in /var/run as
   root, and then setuid to the desired user.  (mysqld -u can almost
   do this; I had to patch it, too).

The patch below fixes problem 1-3.  I plan to address #4, also, but
haven't done so yet.  These diffs are big enough that they should give
the PG development team something to think about in the meantime :-)
Also, I'm about to leave for 2 weeks' vacation, so I thought I'd get
out what I have, which works (for the problems it tackles), now.

With these changes, we can set up and run PostgreSQL with scripts the
same way we can with apache or proftpd or mysql.

In summary, this patch makes the following enhancements:

1. Adds an environment variable PGUNIXSOCKET, analogous to MYSQL_UNIX_PORT,
   and command line options -k --unix-socket to the relevant programs.
2. Adds a -h option to postmaster to set the hostname or IP address to
   listen on instead of the default INADDR_ANY.
3. Extends some library interfaces to support the above.
4. Fixes a few memory leaks in PQconnectdb().

The default behavior is unchanged from stock 7.0.2; if you don't use
any of these new features, they don't change the operation.

David J. MacKenzie
2000-11-13 15:18:15 +00:00
Peter Eisentraut ef6164de1d Revert removal of signed, volatile, and signal handler arg type tests. 2000-08-29 09:36:51 +00:00
Peter Eisentraut 79abd73eee Remove configure tests for `signed', `volatile', and signal handler args;
the harm potential outweighs the possible benefits.
2000-08-27 19:00:41 +00:00
Peter Eisentraut 6fb9d2e347 Version number now set in configure, available through Makefile.global
and config.h. Adjusted all referring code.

Scrapped pg_version and changed initdb accordingly. Integrated
src/utils/version.c into src/backend/utils/init/miscinit.c. Changed all
callers.

Set version number to `7.1devel'. (Non-numeric version suffixes now allowed.)
2000-07-02 15:21:27 +00:00
Bruce Momjian 52f77df613 Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
Peter Eisentraut 8de482a847 Added configure test for readline's filename_completion_function
Completed psql's \? help
2000-03-05 13:30:20 +00:00
Peter Eisentraut c75adac757 More fixes for psql ^C handling, especially during copy. Still doesn't
cope so well with copy to but that will have to wait for the next release.

Also added -X option to prevent reading .psqlrc startup file.
2000-03-01 21:10:05 +00:00
Peter Eisentraut c8009959c9 Fixed psql's Control-C handling when COPY in progress 2000-02-21 19:40:42 +00:00
Peter Eisentraut 718bb2cc9c Moved psql \eset and \eshow to \encoding
Improved psql's Ctrl-C handling
Fixed configure test for sigsetjmp that now even recognizes it if it's a macro
2000-02-20 14:28:28 +00:00
Tom Lane e79b2dd5e7 Fix missing \n in some psql_error calls. 2000-02-20 02:37:40 +00:00
Bruce Momjian 78693c89d7 Clean up include files use in psql. 2000-02-16 13:15:26 +00:00
Peter Eisentraut 9672d38f91 Adjusted psql echoing options (-a and -e) 2000-02-13 21:45:15 +00:00
Peter Eisentraut 9ceb5d8a7b Fixed psql double quoting of SQL ids
Fixed libpq printing functions
2000-02-07 23:10:11 +00:00
Peter Eisentraut 2b84cbb60f A few minor psql enhancements
Initdb help correction
Changed end/abort to commit/rollback and changed related notices
Commented out way old printing functions in libpq
Fixed a typo in alter table / alter column
2000-01-29 16:58:54 +00:00
Peter Eisentraut 65e0051843 another round of user interface cleanups
removed pg_id
fixed a few bugs in the scripts
2000-01-19 20:08:36 +00:00
Peter Eisentraut f565cf41ab another set of cleanups 2000-01-18 23:30:24 +00:00
Bruce Momjian 0cb6bc70ce Hi!
Here is a patch to bring both libpq and psql to a state where it compiles on
win32 (native) again. A lot of things have changed, and I have not been able
to keep up with them all, so it has been broken for quite a while.
After this patch, at least it compiles. It also talks "basic talk" to the
server, but I have not yet tested all things. Sending queries, and using
e.g. \d or \dt works fine. The rest will have to be tested further.
It also bumps the version on libpq.dll to 7.0.

Everything should be enclosed in #ifdef WIN32, unless I have missed
something. Except for one or maybe two places where I have moved a #include
that should not be used on win32 from the "global area" into a "#ifndef
WIN32 area".


//Magnus
2000-01-18 19:05:31 +00:00
Peter Eisentraut 7c9390caa1 Fixed psql variables vs array syntax, as well as minor psql enhancements 2000-01-14 22:18:03 +00:00
Tom Lane 0e6d72db55 Make PSQLexec's behavior on loss of connection more reasonable;
report original error before attempting reset, not after.
2000-01-14 05:28:31 +00:00
Peter Eisentraut f6689a328f Fixed a few "fixes" and bugs. Adjusted messages and options to GNU suggestions. 2000-01-12 19:36:36 +00:00
Bruce Momjian 77a4729936 This should fix the \e (\p, \g, ...) behaviour on an empty query buffer.
Also, minor tweakage of tab completion, and I hope the output is flushed
on time now.

--
Peter Eisentraut                  Sernanders väg 10:115
1999-12-10 03:59:30 +00:00
Bruce Momjian 78bc83fedf * Includes tab completion. It's not magic, but it's very cool. At any
rate
  it's better than what used to be there.

* Does proper SQL "host variable" substitution as pointed out by Andreas
  Zeugwetter (thanks): select * from :foo; Also some changes in how ':'
  and ';' are treated (escape with \ to send to backend). This does
_not_
  affect the '::' cast operator, but perhaps others that contain : or ;
  (but there are none right now).

* To show description with a <something> listing, append '?' to command
  name, e.g., \df?. This seemed to be the convenient and logical
solution.
  Or append a '+' to see more useless information, e.g., \df+.

* Fixed fflush()'ing bug pointed out by Jan during the regression test
  discussion.

* Added LastOid variable. This ought to take care of TODO item "Add a
  function to return the last inserted oid, for use in psql scripts"
  (under CLIENTS)
  E.g.,
insert into foo values(...);
insert into bar values(..., :LastOid);
\echo $LastOid

* \d command shows constraints, rules, and triggers defined on the table
  (in addition to indices)

* Various fixes, optimizations, corrections

* Documentation update as well


Note: This now requires snprintf(), which, if necessary, is taken from
src/backend/port. This is certainly a little weird, but it should
suffice
until a source tree cleanup is done.

Enjoy.

--
Peter Eisentraut                  Sernanders väg 10:115
1999-11-26 04:24:17 +00:00
Bruce Momjian 0e6652e673 psql cleanup 1999-11-04 23:14:30 +00:00
Bruce Momjian a45195a191 Major psql overhaul by Peter Eisentraut. 1999-11-04 21:56:02 +00:00