Commit Graph

50 Commits

Author SHA1 Message Date
Peter Eisentraut 9583aea9d0 Fix collateral damage from previous (rev 1.49) patch. 2001-05-06 21:15:51 +00:00
Peter Eisentraut 645ebc0403 Repair misbehavior of \! with immediately following argument that contains
spaces (e.g., '\!ls -l').  Also correct a comment.
2001-04-18 20:53:08 +00:00
Bruce Momjian 9e1552607a pgindent run. Make it all clean. 2001-03-22 04:01:46 +00:00
Tatsuo Ishii 2bc2738fc4 Fix a bug in psql. unescape() does not work for multi-byte encodings. 2001-02-17 10:03:33 +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
Bruce Momjian d7f0b7ef6e Here is an update on the Win32 patch. Modified files are 'config.h.win32'
and two 'win32.mak'. Addresses the following:

1) Oops. Spelled fcntl.h wrong in the last one. D'uh.
2) PG_VERSION changed to be defined with " around it. psql/command.c failed
to compile without that.
3) Changed makefiles to use "/MD" and link both psql and libpq.dll against
MSVCRT.DLL instead of a static library. This takes care of the
crash-upon-free in psql.

I *think* this is what is on the "Open 7.1 Items" list as "Magnus Hagander
ODBC Issues?". It has nothing to do with ODBC, but it's the only issue I've
been involved with...

Magnus Hagander
2001-01-27 21:49:59 +00:00
Bruce Momjian bd0a767eab Here is a patch to make the current snapshot compile on Win32 (native, libpq
and psql) again. Changes are:
1) psql requires the includes of "io.h" and "fcntl.h" in command.c in order
to make a call to open() work (io.h for _open(), fcntl.h for the O_xxx)
2) PG_VERSION is no longer defined in version.h[.in], but in configure.in.
Since we don't do configure on native win32, we need to put it in
config.h.win32 :-(
3) Added define of SYSCONFDIR to config.h.win32 - libpq won't compile
without it. This functionality is *NOT* tested - it's just defined as "" for
now. May work, may not.
4) DEF_PGPORT renamed to DEF_PGPORT_STR

I have done the "basic tests" on it - it connects to a database, and I can
run queries. Haven't tested any of the fancier functions (yet).

However, I stepped on a much bigger problem when fixing psql to work. It no
longer works when linked against the .DLL version of libpq (which the
Makefile does for it). I have left it linked against this version anyway,
pending the comments I get on this mail :-)
The problem is that there are strings being allocated from libpq.dll using
PQExpBuffers (for example, initPQExpBuffer() on line 92 of input.c). These
are being allocated using the malloc function used by libpq.dll. This
function *may* be different from the malloc function used by psql.exe - only
the resulting pointer must be valid. And with the default linking methods,
it *WILL* be different. Later, psql.exe tries to free() this string, at
which point it crashes because the free() function can't find the allocated
block (it's on the allocated blocks list used by the runtime lib of
libpq.dll).

Shouldn't the right thing to do be to have psql call termPQExpBuffer() on
the data instead? As it is now, gets_fromFile() will just return the pointer
received from the PQExpBuffer.data (this may well be present at several
places - this is the one I was bitten by so far). Isn't that kind of
"accessing the internals of the PQExpBuffer structure" wrong? Instead,
perhaps it shuold make a copy of the string, adn then termPQExpBuffer() it?
In that case, the string will have been allocated from within the same
library as the free() is called.

I can get it to work just fine by doing this - changing from (around line
100 of input.c):
and the same a bit further down in the same function.

But, as I said above, this may be at more places in the code? Perhaps
someone more familiar to it could comment on that?


What do you think shuld be done about this? Personally, I go by the "If you
allocate a piece of memory using an interface, use the same interface to
free it", but the question is how to make it work :-)


Also, AFAIK this only affects psql.exe, so the changes made to the libpq
this patch are required no matter how the other issue is handled.

Regards,
 Magnus
2001-01-24 03:42:38 +00:00
Peter Eisentraut 874b4fd618 Remove incorrect assert. 2000-12-30 14:47:06 +00:00
Tom Lane a27b691e29 Ensure that all uses of <ctype.h> functions are applied to unsigned-char
values, whether the local char type is signed or not.  This is necessary
for portability.  Per discussion on pghackers around 9/16/00.
2000-12-03 20:45:40 +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
Peter Eisentraut ca1c7e662f Silence warning 2000-11-26 11:09:32 +00:00
Bruce Momjian 63edc5c4e0 Fix security problem with psql \e where temp file could be an existing
symlink created by someone else, and therefore modifyable by someone else.
2000-11-25 06:21:54 +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 239f74d28d psql forgot to close connection before re-issuing password prompt.
([BUGS] psql can crash the backend on login, 2000-09-03)
2000-09-17 20:33:45 +00:00
Peter Eisentraut 5da7e533f7 Don't strip trailing backslashes from a line. Treat them more reasonably. 2000-07-17 18:24:33 +00:00
Bruce Momjian ecef326850 Fix \pset null to use ', not ". 2000-06-26 14:16:34 +00:00
Bruce Momjian 4624b84cf2 Small cleanup of file. 2000-05-12 00:54:53 +00:00
Peter Eisentraut 5e4d8be18b psql: suppress warnings about too many arguments if the command is not valid in the first place 2000-05-05 09:38:40 +00:00
Peter Eisentraut 3d62fbc4eb squished \dS+ bug pointed out by Mike Mascari 2000-04-16 20:04:51 +00:00
Peter Eisentraut aae70b2dca more psql bug squashing:
\copy without arguments failed
commands with too many arguments were too silent
2000-04-16 15:46:40 +00:00
Peter Eisentraut ffc9812451 fixed another psql \e bug (handle newlines as whitespace)
repaired psql option scanning bug (special treatment to \g |pipe)
fixed ipcclean makefile
made configure look for Perl to handle psql help build gracefully
2000-04-14 23:43:44 +00:00
Bruce Momjian 52f77df613 Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
Bruce Momjian 354a39bc44 Clean up temp files from \e. 2000-04-11 17:35:50 +00:00
Peter Eisentraut a9f37f16d2 Fixed bug with repeated \e in psql (failed to clear buffers correctly) 2000-03-27 21:11:37 +00:00
Peter Eisentraut 7d392f257b Fixed psql -c "\slashcmd" 2000-03-18 22:48:29 +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
Tatsuo Ishii 320d3e06ee Fixes for \encoding command.
1) freeing null pointer
	2) invalid encoding info may be stored into psql variable
	3) fix indentation
2000-02-21 02:05:12 +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
Tatsuo Ishii eb089e7f76 Add new backslash command \eset and \eshow. 2000-02-19 05:01:16 +00:00
Bruce Momjian 78693c89d7 Clean up include files use in psql. 2000-02-16 13:15:26 +00:00
Peter Eisentraut 9ceb5d8a7b Fixed psql double quoting of SQL ids
Fixed libpq printing functions
2000-02-07 23:10:11 +00:00
Tatsuo Ishii b304b4a90e Change function name PQclientencoding to PQclientEncoding since
it seems more suitable for the naming convention in libpq.
2000-02-05 12:27:56 +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 49581f9848 updated install file
updated date/time types doc
fixed small psql bug
removed libpq code that lower-cased db names
make notice when long identifier is truncated
2000-01-23 01:27:39 +00:00
Peter Eisentraut fa5400c0a4 added ALTER TABLE DROP COLUMN, early version 2000-01-22 14:20:56 +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
Tatsuo Ishii bfbd58ce13 Adapt to the changes of libpq(eliminateing using putenv()). 2000-01-15 05:38:50 +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
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
Jan Wieck a27542c3a8 Added a fflush(stdout) to the \p command required for the
multisession test tool.

Jan
1999-12-10 00:26:35 +00:00
Bruce Momjian 47e51683e6 I pulled this one out via CVS, I hope you can make use of it:
Peter.
1999-11-29 05:28:11 +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 db12a63ef1 The \p\g fix didn't turn out to be so bad. It even works in other
circumstances:
=> select * from foo\x\t\pset border 0 \p\g\\select * from bar;

Also the release prep update so the sql_help.h is generated before
packaging.

Peter.
1999-11-13 02:04:54 +00:00
Bruce Momjian 2a24ec6f16 In the spirit of TODO item
* Add use of 'const' for varibles in source tree
(which is misspelled, btw.)
I went through the front-end libpq code and did so. This affects in
particular the various accessor functions (such as PQdb() and
PQgetvalue()) as well as, by necessity, the internal helpers they use.

I have been really thorough in that regard, perhaps some people will find
it annoying that things like
char * foo = PQgetvalue(res, 0, 0)
will generate a warning. On the other hand it _should_ generate one. This
is no real compatibility break, although a few clients will have to be
fixed to suppress warnings. (Which again would be in the spirit of the
above TODO.)

In addition I replaced some int's by size_t's and removed some warnings
(and generated some new ones -- grmpf!). Also I rewrote PQoidStatus (so it
actually honors the const!) and supplied a new function PQoidValue that
returns a proper Oid type. This is only front-end stuff, none of the
communicaton stuff was touched.


The psql patch also adds some new consts to honor the new libpq situation,
as well as fixes a fatal condition that resulted when using the -V
(--version) option and there is no database listening.


So, to summarize, the psql you should definitely put in (with or without
the libpq). If you think I went too far with the const-mania in libpq, let
me know and I'll make adjustments. If you approve it, I will also update
the docs.

        -Peter

--
Peter Eisentraut                  Sernanders vaeg 10:115
1999-11-11 00:10:14 +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