Commit Graph

491 Commits

Author SHA1 Message Date
Bruce Momjian 8408f65252 Rework libpq threaded SIGPIPE handling to avoid interference with
calling applications.  This is done by blocking sigpipe in the libpq
thread and using sigpending/sigwait to possibily discard any sigpipe we
generated.
2004-12-02 15:32:54 +00:00
Bruce Momjian ee9007a2e1 Allow libpq to build on MS Visual Studio .NET 2003 on Windows XP. 2004-12-01 23:42:26 +00:00
Tom Lane 44e8a968e3 Invent a new, more thread-safe version of PQrequestCancel, called PQcancel.
Use this new function in psql.  Implement query cancellation in psql for
Windows.  Code by Magnus Hagander, documentation and minor editorialization
by Tom Lane.
2004-10-30 23:11:27 +00:00
Bruce Momjian 4eb1165ff3 No need to set errorMessage length --- already set in goto target. 2004-10-29 19:30:02 +00:00
Bruce Momjian 08510856a4 Set errorMessage length in PQrequestCancel() in all places. 2004-10-29 17:53:13 +00:00
Tom Lane 7627b91cd5 Set the close-on-exec flag for libpq's socket to the backend, to avoid
any possible problems from child programs executed by the client app.
Per suggestion from Elliot Lee of Red Hat.
2004-10-21 20:23:19 +00:00
Tom Lane cc6a90e4af Remove dllist.c from libpq. It's overkill for what libpq needs; we can
just stick a list-link into struct PGnotify instead.  Result is a smaller
faster and more robust library (mainly because we reduce the number of
malloc's and free's involved in notify processing), plus less pollution
of application link-symbol namespace.
2004-10-16 22:52:55 +00:00
Bruce Momjian b6b71b85bc Pgindent run for 8.0. 2004-08-29 05:07:03 +00:00
Bruce Momjian da9a8649d8 Update copyright to 2004. 2004-08-29 04:13:13 +00:00
Bruce Momjian 84f878f5cd Don't use get_home_path so libpq doesn't pull path.c into the library. 2004-08-19 00:00:34 +00:00
Bruce Momjian 1abf13db3c Add get_home_path() to use USERPROFILE on Win32 and HOME on Unix. 2004-08-18 02:59:12 +00:00
Tom Lane 109d7aff73 Fix linking problem when enabling thread safety on Darwin: uninitialized
global variables are problematic on this platform.  Simplest solution
seems to be to initialize pthread key variable to 0.  Also, rename this
variable and check_sigpipe_handler to something involving "pq" to
avoid gratuitous pollution of application namespace.
2004-08-17 04:24:23 +00:00
Tom Lane f79fbb2bec Add PQserverVersion() to libpq to provide more-convenient access to
the server version number.  This commit also removes bogus DOS line
endings from libpqddll.def.

Greg Sabino Mullane
2004-08-11 18:06:01 +00:00
Bruce Momjian f4c5e06edf > win32 doesn't support a static initializer for mutexes, thus the first
> user must initialize the lock. The problem are concurrent "first" users
> - the pthread_mutex_t initialization must be synchronized.
> The current implementation is broken, the attached patches fixes that:
> mutex_initlock is a spinlock. If the pthread_mutex_t mutex is not
> initialized, then the spinlock is acquired, if the pthread_mutex_t is
> initialized if it's not yet initialized and then the spinlock is dropped.

Manfred Spraul
2004-07-12 14:23:28 +00:00
Bruce Momjian a29d26a3cd Back out thread fix until I get clarification. 2004-07-12 14:16:28 +00:00
Bruce Momjian a41463e31c win32 doesn't support a static initializer for mutexes, thus the first
user must initialize the lock. The problem are concurrent "first" users
- the pthread_mutex_t initialization must be synchronized.
The current implementation is broken, the attached patches fixes that:
mutex_initlock is a spinlock. If the pthread_mutex_t mutex is not
initialized, then the spinlock is acquired, if the pthread_mutex_t is
initialized if it's not yet initialized and then the spinlock is
dropped.

Manfred Spraul
2004-07-12 14:11:17 +00:00
Bruce Momjian af70d57825 Enable thread safety for win32.mak build of PostgreSQL.
Andreas Pflug
2004-06-19 04:22:17 +00:00
Bruce Momjian 6cc4175b25 Attached is a patch that takes care of the PATHSEP issue. I made a more
extensive change then what was suggested. I found the file path.c that
contained a lot of "Unix/Windows" agnostic functions so I added a function
there instead and removed the PATHSEP declaration in exec.c altogether. All
to keep things from scattering all over the code.

I also took the liberty of changing the name of the functions
"first_path_sep" and "last_path_sep". Where I come from (and I'm apparently
not alone given the former macro name PATHSEP), they should be called
"first_dir_sep" and "last_dir_sep". The new function I introduced, that
actually finds path separators, is now the "first_path_sep". The patch
contains changes on all affected places of course.

I also changed the documentation on dynamic_library_path to reflect the
chagnes.

Thomas Hallgren
2004-06-10 22:26:24 +00:00
Bruce Momjian cd8b0fc5f1 Change PGETC to PGSYSCONFDIR and PGLOCALE to PGLOCALEDIR, per Peter. 2004-06-08 13:49:23 +00:00
Bruce Momjian 6870843339 Add PGETC (for pg_service.conf) and PGLOCALE (for locale dir)
environment variable processing to libpq.

The patch also adds code to our client apps so we set the environment
variable directly based on our binary location, unless it is already
set. This will allow our applications to emit proper locale messages
that are generated in libpq.
2004-06-03 00:07:38 +00:00
Bruce Momjian 97d625dd1c *) inet_(client|server)_(addr|port)() and necessary documentation for
the four functions.


> Also, please justify the temp-related changes.  I was not aware that we
> had any breakage there.

patch-tmp-schema.txt contains the following bits:

*) Changes pg_namespace_aclmask() so that the superuser is always able
to create objects in the temp namespace.
*) Changes pg_namespace_aclmask() so that if this is a temp namespace,
objects are only allowed to be created in the temp namespace if the
user has TEMP privs on the database.  This encompasses all object
creation, not just TEMP tables.
*) InitTempTableNamespace() checks to see if the current user, not the
session user, has access to create a temp namespace.

The first two changes are necessary to support the third change.  Now
it's possible to revoke all temp table privs from non-super users and
limiting all creation of temp tables/schemas via a function that's
executed with elevated privs (security definer).  Before this change,
it was not possible to have a setuid function to create a temp
table/schema if the session user had no TEMP privs.

patch-area-path.txt contains:

*) Can now determine the area of a closed path.


patch-dfmgr.txt contains:

*) Small tweak to add the library path that's being expanded.

I was using $lib/foo.so and couldn't easily figure out what the error
message, "invalid macro name in dynamic library path" meant without
looking through the source code.  With the path in there, at least I
know where to start looking in my config file.

Sean Chittenden
2004-05-26 18:35:51 +00:00
Tom Lane 13f96c4b6b Put path configuration information into a .h file instead of cluttering
several different module Makefiles with it.  Also, do any adjustment
of installation paths during configure, rather than every time Makefile.global
is read.
2004-05-21 20:56:50 +00:00
Bruce Momjian 6daf396879 Add thread locking to SSL and Kerberos connections.
I have removed the docs mentioning that SSL and Kerberos are not
thread-safe.

Manfred Spraul
2004-03-24 03:45:00 +00:00
Bruce Momjian 60a068b389 Move non-blocking code into its own /port file, for code clarity. 2004-03-10 21:12:49 +00:00
Bruce Momjian 0150dbdce5 Allow libpq to do thread-safe SIGPIPE handling. This allows it to
ignore SIGPIPE from send() in libpq, but terminate on any other SIGPIPE,
unless the user installs their own signal handler.

This is a minor fix because the only time you get SIGPIPE from libpq's
send() is when the backend dies.
2004-01-09 02:02:43 +00:00
Neil Conway 192ad63bd7 More janitorial work: remove the explicit casting of NULL literals to a
pointer type when it is not necessary to do so.

For future reference, casting NULL to a pointer type is only necessary
when (a) invoking a function AND either (b) the function has no prototype
OR (c) the function is a varargs function.
2004-01-07 18:56:30 +00:00
Bruce Momjian 580cae7567 Prevent service dbname from defaulting to service name, per bug report
from Michael Fuhr
2003-12-19 21:50:54 +00:00
PostgreSQL Daemon 969685ad44 $Header: -> $PostgreSQL Changes ... 2003-11-29 19:52:15 +00:00
Tom Lane f2f7107024 Must free the pgParameterStatus chain in freePGconn(). My fault,
well spotted by Neil Conway.
2003-10-18 05:02:06 +00:00
Tom Lane b4966453f6 Do not return from PQrequestCancel until postmaster has finished
processing the request; this ensures that the request won't be taken
to cancel a subsequently-issued query.  Race condition originally
noted by Oliver Jowett in the context of JDBC, but libpq has it too.
2003-10-02 19:52:44 +00:00
Peter Eisentraut 6f57d63cb4 Message wording improvements 2003-09-22 00:23:35 +00:00
Bruce Momjian 2dc9437160 Enable Win32 to compile libpq again, and enable SSL compiles on that
platform.

Andreas Pflug
2003-09-05 02:08:36 +00:00
Bruce Momjian f3c3deb7d0 Update copyrights to 2003. 2003-08-04 02:40:20 +00:00
Bruce Momjian 089003fb46 pgindent run. 2003-08-04 00:43:34 +00:00
Tom Lane 57c08791d1 Code review for sslmode patch: eliminate memory leak, avoid giving a
completely useless error message in 'allow' case, don't retry connection
at the sendauth stage (by then the server will either let us in or not,
no point in wasting cycles on another try in the other SSL state).
2003-08-01 21:27:27 +00:00
Tom Lane 81b5c8a136 A visit from the message-style police ... 2003-07-28 00:09:16 +00:00
Bruce Momjian 9df48371c2 here are the patches for psql on Win32:
psql4win32.patch  - changes in the psql source code
  psql-ref.patch    - changes in the documentation psql-ref.sgml
                      (for new builtin variable WIN32_CONSOLE)

To apply them use "patch -p 1" in the root directory of the
postgres source directory.

These patches fix the following problems of psql on Win32
(all changes only have effect #ifdef WIN32):

  a) Problem:  Static library libpq.a did not work
     Solution: Added WSAStartup() in fe-connect.c

  b) Problem:  Secret Password was echoed by psql
     Solution: Password echoing disabled in sprompt.c

  c) Problem:  8bit characters were displayed/interpreted wrong in psql
               This is due to the fact that the Win32 "console" uses a
               different encoding than the rest of the Windows system
     Solution: Introduced a new psql variable WIN32_CONSOLE
               When set with "\set WIN32_console", the function OemToChar()
               is applied after reading input and CharToOem() before
               displaying Output

Christoph Dalitz
2003-07-27 03:32:26 +00:00
Bruce Momjian 397831e103 At long last I put together a patch to support 4 client SSL negotiation
modes (and replace the requiressl boolean). The four options were first
spelled out by Magnus Hagander <mha@sollentuna.net> on 2000-08-23 in email
to pgsql-hackers, archived here:

http://archives.postgresql.org/pgsql-hackers/2000-08/msg00639.php

My original less-flexible patch and the ensuing thread are archived at:

http://dbforums.com/t623845.html

Attached is a new patch, including documentation.

To sum up, there's a new client parameter "sslmode" and environment
variable "PGSSLMODE", with these options:

sslmode   description
-------   -----------
disable   Unencrypted non-SSL only
allow     Negotiate, prefer non-SSL
prefer    Negotiate, prefer SSL (default)
require   Require SSL

The only change to the server is a new pg_hba.conf line type,
"hostnossl", for specifying connections that are not allowed to use SSL
(for example, to prevent servers on a local network from accidentally
using SSL and wasting cycles). Thus the 3 pg_hba.conf line types are:

pg_hba.conf line types
----------------------
host       applies to either SSL or regular connections
hostssl    applies only to SSL connections
hostnossl  applies only to regular connections

These client and server options, the postgresql.conf ssl = false option,
and finally the possibility of compiling with no SSL support at all,
make quite a range of combinations to test. I threw together a test
script to try many of them out. It's in a separate tarball with its
config files, a patch to psql so it'll announce SSL connections even in
absence of a tty, and the test output. The test is especially informative
when run on the same tty the postmaster was started on, so the FATAL:
errors during negotiation are interleaved with the psql client output.

I saw Tom write that new submissions for 7.4 have to be in before midnight
local time, and since I'm on the east coast in the US, this just makes it
in before the bell. :)

Jon Jensen
2003-07-26 13:50:02 +00:00
Tom Lane df63503dc2 Have a go at fixing various outstanding portability issues in code that
was modified for IPv6.  Use a robust definition of struct sockaddr_storage,
do a proper configure test to see if ss_len exists, don't assume that
getnameinfo() will handle AF_UNIX sockets, don't trust getaddrinfo to
return the protocol we ask for, etc.  This incorporates several outstanding
patches from Kurt Roeckx, but I'm to blame for anything that doesn't
work ...
2003-07-23 23:30:41 +00:00
Tom Lane ab5c775116 Change pqInternalNotice to accept a format string and args instead of
just a preformatted message; per suggestion by Sean Chittenden.
2003-06-23 19:20:25 +00:00
Bruce Momjian 408625321c Remove crypt.h from fe-connect.c --- not needed, and caused problems on
Solaris with Open SSL version 0.9.7b
2003-06-23 17:03:19 +00:00
Tom Lane efc3a25bb0 Update libpq to make new features of FE/BE protocol available to
client applications.  Some editorial work on libpq.sgml, too.
2003-06-21 21:51:35 +00:00
Tom Lane 5fc9f3d574 We neglected to set conn->raddr.salen, leading to breakage of CANCEL
and probably other stuff.
2003-06-20 04:09:12 +00:00
Bruce Momjian a16a031411 Make libpq thread-safe with configure --with-threads option.
Lee Kindness
2003-06-14 17:49:54 +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 dc4ee8a833 Back out patch that got bundled into another patch. 2003-06-12 08:11:07 +00:00
Bruce Momjian a647e30ba3 New patch with corrected README attached.
Also quickly added mention that it may be a qualified schema name.

Rod Taylor
2003-06-12 08:02:57 +00:00
Bruce Momjian b4cea00a1f IPv6 cleanups.
Kurt Roeckx
Andrew Dunstan
2003-06-12 07:36:51 +00:00
Tom Lane cdfb3d9981 freeaddrinfo2() does need two parameters after all, per comment by
Kurt Roeckx.  Add some documentation to try to prevent others from
repeating my mistake.
2003-06-09 17:59:19 +00:00
Tom Lane 6bdb7aa4db libpq can now talk to either 3.0 or 2.0 protocol servers. It first tries
protocol 3, then falls back to 2 if postmaster rejects the startup packet
with an old-format error message.  A side benefit of the rewrite is that
SSL-encrypted connections can now be made without blocking.  (I think,
anyway, but do not have a good way to test.)
2003-06-08 17:43:00 +00:00
Bruce Momjian 12c9423832 Allow Win32 to compile under MinGW. Major changes are:
Win32 port is now called 'win32' rather than 'win'
        add -lwsock32 on Win32
        make gethostname() be only used when kerberos4 is enabled
        use /port/getopt.c
        new /port/opendir.c routines
        disable GUC unix_socket_group on Win32
        convert some keywords.c symbols to KEYWORD_P to prevent conflict
        create new FCNTL_NONBLOCK macro to turn off socket blocking
        create new /include/port.h file that has /port prototypes, move
          out of c.h
        new /include/port/win32_include dir to hold missing include files
        work around ERROR being defined in Win32 includes
2003-05-15 16:35:30 +00:00
Tom Lane 16503e6fa4 Extended query protocol: parse, bind, execute, describe FE/BE messages.
Only lightly tested as yet, since libpq doesn't know anything about 'em.
2003-05-05 00:44:56 +00:00
Tom Lane 11def6906b Missed some corner cases (PGSERVICE mostly)... 2003-04-28 04:52:13 +00:00
Tom Lane 092133beb3 Okay, I've had it with PQsetdbLogin having slightly different defaults
than PQconnectdb.  Reimplement the former to use the same code as the
latter.  Fix documentation omissions while at it.
2003-04-28 04:29:12 +00:00
Tom Lane 9cbaf72177 In the continuing saga of FE/BE protocol revisions, add reporting of
initial values and runtime changes in selected parameters.  This gets
rid of the need for an initial 'select pg_client_encoding()' query in
libpq, bringing us back to one message transmitted in each direction
for a standard connection startup.  To allow server version to be sent
using the same GUC mechanism that handles other parameters, invent the
concept of a never-settable GUC parameter: you can 'show server_version'
but it's not settable by any GUC input source.  Create 'lc_collate' and
'lc_ctype' never-settable parameters so that people can find out these
settings without need for pg_controldata.  (These side ideas were all
discussed some time ago in pgsql-hackers, but not yet implemented.)
2003-04-25 19:45:10 +00:00
Bruce Momjian db7e46a76d Use closesocket() for all socket/pipe closing, because Win32 requires
it, and map that to close() on Unix.
2003-04-25 01:24:00 +00:00
Tom Lane f690920a75 Infrastructure for upgraded error reporting mechanism. elog.c is
rewritten and the protocol is changed, but most elog calls are still
elog calls.  Also, we need to contemplate mechanisms for controlling
all this functionality --- eg, how much stuff should appear in the
postmaster log?  And what API should libpq expose for it?
2003-04-24 21:16:45 +00:00
Tom Lane 5ed27e35f3 Another round of protocol changes. Backend-to-frontend messages now all
have length words.  COPY OUT reimplemented per new protocol: it doesn't
need \. anymore, thank goodness.  COPY BINARY to/from frontend works,
at least as far as the backend is concerned --- libpq's PQgetline API
is not up to snuff, and will have to be replaced with something that is
null-safe.  libpq uses message length words for performance improvement
(no cycles wasted rescanning long messages), but not yet for error
recovery.
2003-04-22 00:08:07 +00:00
Tom Lane bd8d441775 Second round of FE/BE protocol changes. Frontend->backend messages now
have length counts, and COPY IN data is packetized into messages.
2003-04-19 00:02:30 +00:00
Tom Lane cb7fb3ca95 First phase of FE/BE protocol modifications: new StartupPacket layout
with variable-width fields.  No more truncation of long user names.
Also, libpq can now send its environment-variable-driven SET commands
as part of the startup packet, saving round trips to server.
2003-04-17 22:26:02 +00:00
Bruce Momjian d46e643822 Add Win32 path handling for / vs. \ and drive letters. 2003-04-04 20:42:13 +00:00
Tom Lane 1da6eb7fda Whack getaddrinfo() patch around until it works, more or less, on
machines without IPv6.  Or at least it works on HPUX 10.20 ...
2003-04-02 00:49:28 +00:00
Peter Eisentraut 82a91eb54e Simplify the socket handling code by supplying a replacement getaddrinfo()
function if the OS doesn't provide one.
2003-03-29 11:31:52 +00:00
Bruce Momjian 44aba28020 PGRES_POLLING_ACTIVE is unused, keep for backward compatibility.
Lennert Buytenhek
2003-03-20 06:23:30 +00:00
Peter Eisentraut 9384dc6e59 Improve error message. 2003-03-18 22:11:48 +00:00
Bruce Momjian 93b408ef86 Reorder crypt.h include for SunOS compile problem.
Fred Houweling
2003-03-17 17:58:57 +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
Tatsuo Ishii e2a618fe25 Fix for GUC client_encoding variable not being handled
correctly. See following thread for more details.

Subject: [HACKERS] client_encoding directive is ignored in postgresql.conf
From: Tatsuo Ishii <t-ishii@sra.co.jp>
Date: Wed, 29 Jan 2003 22:24:04 +0900 (JST)
2003-02-19 14:31:26 +00:00
Tom Lane e8a10dc7e9 Fix some of the breakage from the IPV6 patch. 2003-02-14 01:24:26 +00:00
Tom Lane 4ec457ad58 Fix regression in .pgpass support. From Neil Conway. 2003-01-30 19:49:54 +00:00
Bruce Momjian fe7f8f2b91 Fix pgpass to work with PQconnectDB().
Backpatch to 7.3.X.

Report from ljb.
2003-01-08 21:33:27 +00:00
Bruce Momjian 9270f1cdaa Only set the database name if we find a match in the services file. 2003-01-08 16:21:53 +00:00
Bruce Momjian c859cda782 Document libpq service capability, and add sample file. 2003-01-07 04:25:29 +00:00
Bruce Momjian c9cf982038 Enable IPv6 libpq 'hostaddr' addresses. Update docs. 2003-01-06 22:48:16 +00:00
Bruce Momjian c3e9699f21 Enable IPv6 connections to the server, and add pg_hba.conf IPv6 entries
if the OS supports it.  Code will still compile on non-IPv6-aware
machines (feature added by Bruce).

Nigel Kukard
2003-01-06 03:18:27 +00:00
Bruce Momjian abf6f48319 pgindent fe-connect.c --- done to make IPv6 patch easier to apply. 2002-12-19 19:30:24 +00:00
Bruce Momjian 38ffbb95d5 Back out V6 code, caused postmaster startup failure. 2002-12-06 04:37:05 +00:00
Bruce Momjian 8fc86dd593 We have just finished porting the old KAME IPv6 patch over to
postgresql version 7.3, but yea... this patch adds full IPv6
support to postgres. I've tested it out on 7.2.3 and has
been running perfectly stable.

CREDITS:
 The KAME Project  (Initial patch)
 Nigel Kukard  <nkukard@lbsd.net>
 Johan Jordaan  <johanj@lando.co.za>
2002-12-06 03:46:37 +00:00
Tom Lane 2908a838ac Code review for connection timeout patch. Avoid unportable assumption
that tv_sec is signed; return a useful error message on timeout failure;
honor PGCONNECT_TIMEOUT environment variable in PQsetdbLogin; make code
obey documentation statement that timeout=0 means no timeout.
2002-10-24 23:35:55 +00:00
Bruce Momjian ec64390e91 Fix from Joe on timeout code. 2002-10-16 04:38:00 +00:00
Bruce Momjian facb720073 Fix connection_timeout to use time() and handle timeout == 1.
Code cleanup.
2002-10-16 02:55:30 +00:00
Tom Lane e258a2b436 Fix libpq startup code to work correctly in autocommit off mode.
In passing, fix breakage for case where PGCLIENTENCODING is set in
environment.
2002-10-15 01:48:25 +00:00
Bruce Momjian 9eada51012 libpq connection_timeout doesn't do subsecond timing, so make the code
clear on that point.
2002-10-14 17:15:11 +00:00
Bruce Momjian 3258484d03 Add tv_sec change for connection timeout suggested by author. 2002-10-11 04:41:59 +00:00
Bruce Momjian 6a7bb0afbc Prevent tv_sec from becoming negative in connection timeout code. 2002-10-11 04:12:14 +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
Peter Eisentraut 2972fd5d83 Translation updates, some messages tweaked. 2002-09-22 20:57:21 +00:00
Bruce Momjian 847f8b39d7 Fix printf() quote handling and improper exit(), per Tom. 2002-09-06 02:33:47 +00:00
Bruce Momjian e06f4c65b4 Fix compile error. 2002-09-05 22:24:23 +00:00
Bruce Momjian 5fc10c3d17 Remove PGPASSWORDFILE and default to always trying $HOME/.pgpass.
Cleanup up memory allocation for $HOME in related psql places.

Update mention of $HOME/.pgpass in the docs;  add mention in pg_dumpall.
2002-09-05 22:05:50 +00:00
Bruce Momjian e50f52a074 pgindent run. 2002-09-04 20:31:48 +00:00
Tom Lane df40e28850 Fix off-by-one allocation error in PasswordFromFile(), per Gordon Runkle. 2002-08-30 05:28:50 +00:00
Bruce Momjian 40f2eec503 > > > > If you want to put in security restrictions that are actually useful,
> > > > where is the code to verify that PGPASSWORDFILE points at a
> > > > non-world-readable file?  That needs to be there now, not later, or
> > > > we'll have people moaning about backward compatibility when we finally
> > > > do plug that hole.

Alvaro Herrera
2002-08-29 23:06:32 +00:00
Tatsuo Ishii ed7baeaf4d Remove #ifdef MULTIBYTE per hackers list discussion. 2002-08-29 07:22:30 +00:00
Bruce Momjian a1c218cae4 The attached patch implements the password packet length sanity check
(using an elog(LOG) ), as well as includes a few more comment fixes.

Neil Conway
2002-08-27 16:21:51 +00:00
Bruce Momjian 840deabfe0 More connection timeout cleanups. 2002-08-27 15:02:50 +00:00
Bruce Momjian 4e723e6717 Cleanup of libpq connection timeout code. 2002-08-27 14:49:52 +00:00
Bruce Momjian 5bf6af6cf4 Add includes for prototype using timeval. 2002-08-18 01:35:40 +00:00
Bruce Momjian 1c69f13447 Clean up compile warnings. 2002-08-18 00:06:01 +00:00
Bruce Momjian f0ed4311b6 Add libpq connection timeout parameter.
Denis A Ustimenko
2002-08-17 12:33:18 +00:00
Bruce Momjian 7f4981f4af I'm giving a try at some TODO items. Currently it's the turn of the
PGPASSWORDFILE environment variable.  I have modified libpq to make use
of this variable.  I present the first cut here.

Currently the format for the file should be

host:port:database:user:password

Alvaro Herrera
2002-08-15 02:56:19 +00:00
Bruce Momjian b6d2faaf24 Hello, i noticed that win32 native stopped working/compiling after the SSL merge
.
So i took the opportunity to fix some stuff:

1. Made the thing compile (typos & needed definitions) with the new pqsecure_* s
tuff, and added fe-secure.c to the win32.mak makefile.
2. Fixed some MULTIBYTE compile errors (when building without MB support).
3. Made it do that you can build with debug info: "nmake -f win32.mak DEBUG=1".
4. Misc small compiler speedup changes.

The resulting .dll has been tested in production, and everything seems ok.
I CC:ed -hackers because i'm not sure about two things:

1. In libpq-int.h I typedef ssize_t as an int because Visual C (v6.0)
doesn't de fine ssize_t. Is that ok, or is there any standard about what
type should be use d for ssize_t?

2. To keep the .dll api consistent regarding MULTIBYTE I just return -1
in fe-connect.c:PQsetClientEncoding() instead of taking away the whole
function. I wonder if i should do any compares with the
conn->client_encoding and return 0 if not hing would have changed (if so
how do i check that?).

Regards

Magnus Naeslund
2002-07-20 05:43:31 +00:00
Tatsuo Ishii eb335a034b I have committed many support files for CREATE CONVERSION. Default
conversion procs and conversions are added in initdb. Currently
supported conversions are:

UTF-8(UNICODE) <--> SQL_ASCII, ISO-8859-1 to 16, EUC_JP, EUC_KR,
		    EUC_CN, EUC_TW, SJIS, BIG5, GBK, GB18030, UHC,
		    JOHAB, TCVN

EUC_JP <--> SJIS
EUC_TW <--> BIG5
MULE_INTERNAL <--> EUC_JP, SJIS, EUC_TW, BIG5

Note that initial contents of pg_conversion system catalog are created
in the initdb process. So doing initdb required is ideal, it's
possible to add them to your databases by hand, however. To accomplish
this:

psql -f your_postgresql_install_path/share/conversion_create.sql your_database

So I did not bump up the version in cataversion.h.

TODO:
Add more conversion procs
Add [CASCADE|RESTRICT] to DROP CONVERSION
Add tuples to pg_depend
Add regression tests
Write docs
Add SQL99 CONVERT command?
--
Tatsuo Ishii
2002-07-18 02:02:30 +00:00
Bruce Momjian d84fe82230 Update copyright to 2002. 2002-06-20 20:29:54 +00:00
Tom Lane 32fecad80a Clean up gcc warnings. Avoid the bad habit of putting externs in .c
files rather than a header file where they belong.  Pay some modicum
of attention to picking global routine names that aren't likely to
conflict with surrounding applications.
2002-06-15 22:06:09 +00:00
Bruce Momjian 19570420f5 UPDATED PATCH:
Attached are a revised set of SSL patches.  Many of these patches
are motivated by security concerns, it's not just bug fixes.  The key
differences (from stock 7.2.1) are:

*) almost all code that directly uses the OpenSSL library is in two
   new files,

     src/interfaces/libpq/fe-ssl.c
     src/backend/postmaster/be-ssl.c

   in the long run, it would be nice to merge these two files.

*) the legacy code to read and write network data have been
   encapsulated into read_SSL() and write_SSL().  These functions
   should probably be renamed - they handle both SSL and non-SSL
   cases.

   the remaining code should eliminate the problems identified
   earlier, albeit not very cleanly.

*) both front- and back-ends will send a SSL shutdown via the
   new close_SSL() function.  This is necessary for sessions to
   work properly.

   (Sessions are not yet fully supported, but by cleanly closing
   the SSL connection instead of just sending a TCP FIN packet
   other SSL tools will be much happier.)

*) The client certificate and key are now expected in a subdirectory
   of the user's home directory.  Specifically,

	- the directory .postgresql must be owned by the user, and
	  allow no access by 'group' or 'other.'

	- the file .postgresql/postgresql.crt must be a regular file
	  owned by the user.

	- the file .postgresql/postgresql.key must be a regular file
	  owned by the user, and allow no access by 'group' or 'other'.

   At the current time encrypted private keys are not supported.
   There should also be a way to support multiple client certs/keys.

*) the front-end performs minimal validation of the back-end cert.
   Self-signed certs are permitted, but the common name *must*
   match the hostname used by the front-end.  (The cert itself
   should always use a fully qualified domain name (FDQN) in its
   common name field.)

   This means that

	  psql -h eris db

   will fail, but

	  psql -h eris.example.com db

   will succeed.  At the current time this must be an exact match;
   future patches may support any FQDN that resolves to the address
   returned by getpeername(2).

   Another common "problem" is expiring certs.  For now, it may be
   a good idea to use a very-long-lived self-signed cert.

   As a compile-time option, the front-end can specify a file
   containing valid root certificates, but it is not yet required.

*) the back-end performs minimal validation of the client cert.
   It allows self-signed certs.  It checks for expiration.  It
   supports a compile-time option specifying a file containing
   valid root certificates.

*) both front- and back-ends default to TLSv1, not SSLv3/SSLv2.

*) both front- and back-ends support DSA keys.  DSA keys are
   moderately more expensive on startup, but many people consider
   them preferable than RSA keys.  (E.g., SSH2 prefers DSA keys.)

*) if /dev/urandom exists, both client and server will read 16k
   of randomization data from it.

*) the server can read empheral DH parameters from the files

     $DataDir/dh512.pem
     $DataDir/dh1024.pem
     $DataDir/dh2048.pem
     $DataDir/dh4096.pem

   if none are provided, the server will default to hardcoded
   parameter files provided by the OpenSSL project.

Remaining tasks:

*) the select() clauses need to be revisited - the SSL abstraction
   layer may need to absorb more of the current code to avoid rare
   deadlock conditions.  This also touches on a true solution to
   the pg_eof() problem.

*) the SIGPIPE signal handler may need to be revisited.

*) support encrypted private keys.

*) sessions are not yet fully supported.  (SSL sessions can span
   multiple "connections," and allow the client and server to avoid
   costly renegotiations.)

*) makecert - a script that creates back-end certs.

*) pgkeygen - a tool that creates front-end certs.

*) the whole protocol issue, SASL, etc.

 *) certs are fully validated - valid root certs must be available.
    This is a hassle, but it means that you *can* trust the identity
    of the server.

 *) the client library can handle hardcoded root certificates, to
    avoid the need to copy these files.

 *) host name of server cert must resolve to IP address, or be a
    recognized alias.  This is more liberal than the previous
    iteration.

 *) the number of bytes transferred is tracked, and the session
    key is periodically renegotiated.

 *) basic cert generation scripts (mkcert.sh, pgkeygen.sh).  The
    configuration files have reasonable defaults for each type
    of use.

Bear Giles
2002-06-14 04:23:17 +00:00
Bruce Momjian eb43af3210 Back out SSL changes. Newer patch available. 2002-06-14 04:09:37 +00:00
Bruce Momjian a9bd17616e Attached are a revised set of SSL patches. Many of these patches
are motivated by security concerns, it's not just bug fixes.  The key
differences (from stock 7.2.1) are:

*) almost all code that directly uses the OpenSSL library is in two
   new files,

     src/interfaces/libpq/fe-ssl.c
     src/backend/postmaster/be-ssl.c

   in the long run, it would be nice to merge these two files.

*) the legacy code to read and write network data have been
   encapsulated into read_SSL() and write_SSL().  These functions
   should probably be renamed - they handle both SSL and non-SSL
   cases.

   the remaining code should eliminate the problems identified
   earlier, albeit not very cleanly.

*) both front- and back-ends will send a SSL shutdown via the
   new close_SSL() function.  This is necessary for sessions to
   work properly.

   (Sessions are not yet fully supported, but by cleanly closing
   the SSL connection instead of just sending a TCP FIN packet
   other SSL tools will be much happier.)

*) The client certificate and key are now expected in a subdirectory
   of the user's home directory.  Specifically,

	- the directory .postgresql must be owned by the user, and
	  allow no access by 'group' or 'other.'

	- the file .postgresql/postgresql.crt must be a regular file
	  owned by the user.

	- the file .postgresql/postgresql.key must be a regular file
	  owned by the user, and allow no access by 'group' or 'other'.

   At the current time encrypted private keys are not supported.
   There should also be a way to support multiple client certs/keys.

*) the front-end performs minimal validation of the back-end cert.
   Self-signed certs are permitted, but the common name *must*
   match the hostname used by the front-end.  (The cert itself
   should always use a fully qualified domain name (FDQN) in its
   common name field.)

   This means that

	  psql -h eris db

   will fail, but

	  psql -h eris.example.com db

   will succeed.  At the current time this must be an exact match;
   future patches may support any FQDN that resolves to the address
   returned by getpeername(2).

   Another common "problem" is expiring certs.  For now, it may be
   a good idea to use a very-long-lived self-signed cert.

   As a compile-time option, the front-end can specify a file
   containing valid root certificates, but it is not yet required.

*) the back-end performs minimal validation of the client cert.
   It allows self-signed certs.  It checks for expiration.  It
   supports a compile-time option specifying a file containing
   valid root certificates.

*) both front- and back-ends default to TLSv1, not SSLv3/SSLv2.

*) both front- and back-ends support DSA keys.  DSA keys are
   moderately more expensive on startup, but many people consider
   them preferable than RSA keys.  (E.g., SSH2 prefers DSA keys.)

*) if /dev/urandom exists, both client and server will read 16k
   of randomization data from it.

*) the server can read empheral DH parameters from the files

     $DataDir/dh512.pem
     $DataDir/dh1024.pem
     $DataDir/dh2048.pem
     $DataDir/dh4096.pem

   if none are provided, the server will default to hardcoded
   parameter files provided by the OpenSSL project.

Remaining tasks:

*) the select() clauses need to be revisited - the SSL abstraction
   layer may need to absorb more of the current code to avoid rare
   deadlock conditions.  This also touches on a true solution to
   the pg_eof() problem.

*) the SIGPIPE signal handler may need to be revisited.

*) support encrypted private keys.

*) sessions are not yet fully supported.  (SSL sessions can span
   multiple "connections," and allow the client and server to avoid
   costly renegotiations.)

*) makecert - a script that creates back-end certs.

*) pgkeygen - a tool that creates front-end certs.

*) the whole protocol issue, SASL, etc.

 *) certs are fully validated - valid root certs must be available.
    This is a hassle, but it means that you *can* trust the identity
    of the server.

 *) the client library can handle hardcoded root certificates, to
    avoid the need to copy these files.

 *) host name of server cert must resolve to IP address, or be a
    recognized alias.  This is more liberal than the previous
    iteration.

 *) the number of bytes transferred is tracked, and the session
    key is periodically renegotiated.

 *) basic cert generation scripts (mkcert.sh, pgkeygen.sh).  The
    configuration files have reasonable defaults for each type
    of use.

Bear Giles
2002-06-14 03:56:47 +00:00
Bruce Momjian 394eec1068 Fix for EINTR returns from Win9X socket operations:
In summary, if a software writer implements timer events or other events
 which generate a signal with a timing fast enough to occur while libpq
is inside connect(), then connect returns -EINTR.  The code following
the connect call does not handle this and generates an error message.
The sum result is that the pg_connect() fails.  If the timer or other
event is right on the window of the connect() completion time, the
pg_connect() may appear to work sporadically.  If the event is too slow,
 pg_connect() will appear to always work and if the event is too fast,
pg_connect() will always fail.

David Ford
2002-04-15 23:34:17 +00:00
Tom Lane 78ab803402 Don't bother to request SSL connection over a Unix socket, since the
postmaster won't accept the request anyway.  (If your kernel can't
be trusted, SSL will not help you.)
2002-03-02 00:49:22 +00:00
Tom Lane 15c21bf8e1 Defend against possibility that SSL error reporting mechanism returns
a NULL pointer.  Per report from Stephen Pillinger 8-Nov-01.
2001-11-11 02:09:05 +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 6783b2372e Another pgindent run. Fixes enum indenting, and improves #endif
spacing.  Also adds space for one-line comments.
2001-10-28 06:26:15 +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
Tatsuo Ishii 227767112c Commit Karel's patch.
-------------------------------------------------------------------
Subject: Re: [PATCHES] encoding names
From: Karel Zak <zakkr@zf.jcu.cz>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-patches <pgsql-patches@postgresql.org>
Date: Fri, 31 Aug 2001 17:24:38 +0200

On Thu, Aug 30, 2001 at 01:30:40AM +0200, Peter Eisentraut wrote:
> > 		- convert encoding 'name' to 'id'
>
> I thought we decided not to add functions returning "new" names until we
> know exactly what the new names should be, and pending schema

 Ok, the patch not to add functions.

> better
>
>     ...(): encoding name too long

 Fixed.

 I found new bug in command/variable.c in parse_client_encoding(), nobody
probably never see this error:

if (pg_set_client_encoding(encoding))
{
	elog(ERROR, "Conversion between %s and %s is not supported",
                     value, GetDatabaseEncodingName());
}

because pg_set_client_encoding() returns -1 for error and 0 as true.
It's fixed too.

 IMHO it can be apply.

		Karel
PS:

    * following files are renamed:

src/utils/mb/Unicode/KOI8_to_utf8.map  -->
        src/utils/mb/Unicode/koi8r_to_utf8.map

src/utils/mb/Unicode/WIN_to_utf8.map  -->
        src/utils/mb/Unicode/win1251_to_utf8.map

src/utils/mb/Unicode/utf8_to_KOI8.map -->
        src/utils/mb/Unicode/utf8_to_koi8r.map

src/utils/mb/Unicode/utf8_to_WIN.map -->
        src/utils/mb/Unicode/utf8_to_win1251.map

   * new file:

src/utils/mb/encname.c

   * removed file:

src/utils/mb/common.c

--
 Karel Zak  <zakkr@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/

 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz
2001-09-06 04:57:30 +00:00
Bruce Momjian 5db5c2db61 > Ok, where's a "system dependent hack" :)
> It seems that win9x doesn't have the "netmsg.dll" so it defaults to "normal"
> FormatMessage.
> I wonder if one could load wsock32.dll or winsock.dll on those systems
> instead of netmsg.dll.
>
> Mikhail, could you please test this code on your nt4 system?
> Could someone else test this code on a win98/95 system?
>
> It works on win2k over here.

It works on win2k here too but not on win98/95 or winNT.
Anyway, attached is the patch which uses Magnus's my_sock_strerror
function (renamed to winsock_strerror). The only difference is that
I put the code to load and unload netmsg.dll in the libpqdll.c
(is this OK Magnus?).

Mikhail Terekhov
2001-08-21 20:39:54 +00:00
Bruce Momjian 2637f887e7 Remove some unneeded dashes from libpq comments. 2001-08-17 15:11:15 +00:00
Bruce Momjian da45a0bdb7 Add 4-byte MD5 salt. 2001-08-17 02:59:20 +00:00
Bruce Momjian 38bb1abcda Use MD5 for wire protocol encryption for >= 7.2 client/server.
Allow pg_shadow to be MD5 encrypted.
Add ENCRYPTED/UNENCRYPTED option to CREATE/ALTER user.
Add password_encryption postgresql.conf option.
Update wire protocol version to 2.1.
2001-08-15 18:42:16 +00:00
Tom Lane 2b769c8212 Fix residual breakage from Windows socket-errno patch: the routines
that should use regular errno, not WSAGetLastError(), now do so again.
2001-08-03 22:11:39 +00:00
Tom Lane 6d0d838ceb Remove WIN32_NON_BLOCKING_CONNECTIONS tests, since we don't need 'em
anymore.
2001-07-31 02:14:49 +00:00
Bruce Momjian ca5a516279 I downloaded new source for lib (only few hours old !!!), and made
changes on this new source to make non-blocking connection work. I
tested it, and PQSendQuery and PQGetResult are working fine.

In win32.h I added one line:
#define snprintf _snprintf

Darko Prenosil
2001-07-21 04:32:42 +00:00
Bruce Momjian 8c79f3c4a3 i've spotted a following problem using DBD::Pg under win32. winsock
functions do not set errno, so some normal conditions are treated as
fatal errors. e.g. fetching large tuples fails, as at some point recv()
returns EWOULDBLOCK. here's a patch, which replaces errno with
WSAGetLastError(). i've tried to to affect non-win32 code.

Dmitry Yurtaev
2001-07-20 17:45:06 +00:00
Peter Eisentraut 1bd3dd0c5f Fix fault in message. 2001-07-16 20:05:51 +00:00
Peter Eisentraut 1a17447be1 NLS for libpq. Clean up the message formats and change the documentation
accordingly.
2001-07-15 13:45:04 +00:00
Peter Eisentraut 1e9e5defc2 Use CONNECTION_OK to determine whether startup phase is complete. 2001-07-06 19:04:23 +00:00
Peter Eisentraut e77aaade34 Repair libpq to follow protocol by not sending Terminate messages before
the startup exchange is complete.  Also make sure that packets defined as
single bytes aren't sent with a trailing '\0'.
2001-07-06 17:58:53 +00:00
Tom Lane 98f7515696 On Cygwin, do initial connect() call in blocking mode, per report from
Jason Tishler.
2001-03-31 23:14:37 +00:00
Bruce Momjian 7cf952e7b4 Fix comments that were mis-wrapped, for Tom Lane. 2001-03-23 04:49:58 +00:00
Bruce Momjian 0686d49da0 Remove dashes in comments that don't need them, rewrap with pgindent. 2001-03-22 06:16:21 +00:00
Bruce Momjian 9e1552607a pgindent run. Make it all clean. 2001-03-22 04:01:46 +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 623bf843d2 Change Copyright from PostgreSQL, Inc to PostgreSQL Global Development Group. 2001-01-24 19:43:33 +00:00
Tom Lane e41b8a0fdd On further thought, we need a defense against empty PGPORT here too. 2000-12-31 18:23:21 +00:00
Tom Lane 45f92179d9 Ignore PGPORT environment variable if it is an empty string. 2000-12-31 18:15:58 +00:00
Tatsuo Ishii 1deb6e7d41 Fix PQsetdbLogin() backward compatibility problem.
If pghost == "" and pgport == "" then PQsetdbLogin() fails with a
error message:

 Is the postmaster running locally
        and accepting connections on Unix socket '/tmp/.s.PGSQL.0'?

I see many applications such as PHP fails due to this behavior.
Now if pgport == "", then it is assumed to be a DEF_PGPORT_STR. This
is the same behavior as the version prior 7.1.
2000-12-22 07:59:32 +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
Tom Lane 06dde51ef0 Silence compiler warning. 2000-12-07 02:04:30 +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 b7c3784417 Repair residual sillinesses from UUNET virtual host/socket path patch.
I hope all the dust has settled out now ...
2000-11-30 23:20:51 +00:00
Peter Eisentraut ef54e0d08e Remove remaining unixsocket-setting interfaces, since the host parameter
does that.  Disable URL-style connection parameter specification code,
which doesn't work.
2000-11-30 18:32:52 +00:00
Bruce Momjian 5173fc411f Remove PQunixsocket, per Peter's recommendation. PQhost shows the socket directory. 2000-11-28 06:53:33 +00:00
Bruce Momjian f6a756e49a Make PQhost return socket path. 2000-11-27 21:12:25 +00:00
Tatsuo Ishii afde2acc50 Recongizing PGCLIENTENCODING has been broken since 7.0. 2000-11-17 04:22:52 +00:00
Bruce Momjian 026643a6e7 Rename PortName to PortNumber. 2000-11-14 01:15:06 +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
Tatsuo Ishii 6862a05364 Fix for missing EUC_TW encoding 2000-11-04 02:27:56 +00:00
Tatsuo Ishii 0b10d35e2b Avoid dependency on backend's multibyte module as possible.
Now frontend/libpq has its own version of pg_encoding_to_char
and pg_char_to_encoding.
2000-10-30 10:31:46 +00:00
Bruce Momjian 8111329b87 Back out xti.h portion of the patch. 2000-10-23 14:50:44 +00:00
Peter Eisentraut fba790ad58 Makeover for Unixware 7.1.1
* Makefile: Add more standard targets.  Improve shell redirection in GNU
make detection.
* src/backend/access/transam/rmgr.c: Fix incorrect(?) C.
* src/backend/libpq/pqcomm.c (StreamConnection): Work around accept() bug.
* src/include/port/unixware.h: ...with help from here.
* src/backend/nodes/print.c (plannode_type): Remove some "break"s after
"return"s.
* src/backend/tcop/dest.c (DestToFunction): ditto.
* src/backend/nodes/readfuncs.c: Add proper prototypes.
* src/backend/utils/adt/numutils.c (pg_atoi): Cope specially with strtol()
setting EINVAL. This saves us from creating an extra set of regression test
output for the affected systems.
* src/include/storage/s_lock.h (tas): Correct prototype.
* src/interfaces/libpq/fe-connect.c (parseServiceInfo): Don't use variable
as dimension in array definition.
* src/makefiles/Makefile.unixware: Add support for GCC.
* src/template/unixware: same here
* src/test/regress/expected/abstime-solaris-1947.out: Adjust whitespace.
* src/test/regress/expected/horology-solaris-1947.out: Part of this file
was evidently missing.
* src/test/regress/pg_regress.sh: Fix shell.  mkdir -p returns non-zero if
the directory exists.
* src/test/regress/resultmap: Add entries for Unixware.
2000-10-22 22:15:13 +00:00
Peter Eisentraut 179b8e5722 Locate the file pg_service.conf in the directory configured as --syconfdir
(i.e., /usr/local/pgsql/etc by default).
2000-10-17 17:43:13 +00:00
Bruce Momjian f2ef4df4a3 TNS:
I prepared and tested a patch vs. 7.0.2, and it works fine. I've added
another option which allows users to have their own service file in
~/.pg_service.conf, which might come handy sometimes.

Mario Weilguni
2000-10-17 01:00:58 +00:00
Bruce Momjian 0f07d644a3 The configure script fails to find <netinet/tcp.h>.
As a result, backend/libpq/pqcomm.c and interfaces/libpq/fe-connect.c
fail to compile.

The <netinet/tcp.h> header needs to be preceded by <netinet/in.h>, at
least on IRIX, Solaris and AIX.  The simple configure test fails.
(That header on Linux is idempotent.)

The basic problem is that <netinet/tcp.h> is a BSD header.  The
correct header for TCP internals such as TCP_NODELAY on a UNIX system
is <xti.h>.  By UNIX I mean UNIX95 (aka XPG4v2 or SUSv1) or later.
The current UNIX standard (UNIX98 aka SUSv2) is available online at
<http://www.opengroup.org/onlinepubs/7908799/>.

The fix is to add header support for <xti.h> into configure.in and
config.h.in.

The 2 files which conditionally include <netinet/tcp.h> need also to
conditionally include <xti.h>.

Pete Forman
2000-10-14 23:56:59 +00:00
Peter Eisentraut 7c5a444f53 Treat empty connection parameters as is, in particular to enable overriding
environment variables with "nothing".  Empty host parameter indicates
Unix socket.
2000-10-03 19:16:17 +00:00
Bruce Momjian 2737974085 Cleanup of fe-connect ifdef platform problem added with beos. 2000-10-03 03:39:46 +00:00
Bruce Momjian 87c0e623ba New diff that now covers the entire tree. Applying this gets postgresql
working on the VERY latest version of BeOS.  I'm sure there will be
alot of comments, but then if there weren't I'd be disappointed!

Thanks for your continuing efforts to get this into your tree.

Haven't bothered with the new files as they haven't changed.

BTW Peter, the compiler is "broken" about the bool define and so on.
I'm filing a bug report to try and get it addressed.  Hopefully then we
can tidy up the code a bit.

I await the replies with interest :)

David Reid
2000-10-03 03:11:26 +00:00
Peter Eisentraut 664ce79dd8 Fixes for Cygwin, with help from Pete Forman <gsez020@kryten.bedford.waii.com>.
Update the installation instructions (formerly misnamed "FAQ"), add configure
checks for some headers rather than having users copy stubs manually (ugh!).
Use Autoconf check for exe extension.  This also avoids inheriting the value
of $(X) from the environment.
2000-09-27 15:17:57 +00:00
Bruce Momjian 7bc654bb16 SSL patch from Magnus 2000-08-30 14:54:24 +00:00
Peter Eisentraut 9b3d66ecbd Introduce HAVE_UNIX_SOCKETS symbol to replace repeatedly listing all the
unsupported platforms.
2000-08-20 10:55:35 +00:00
Peter Eisentraut 74618e2b82 Another round of those unportable config/build changes :-/
* Add option to build with OpenSSL out of the box. Fix thusly exposed
  bit rot. Although it compiles now, getting this to do something
  useful is left as an exercise.

* Fix Kerberos options to defer checking for required libraries until
  all the other libraries are checked for.

* Change default odbcinst.ini and krb5.srvtab path to PREFIX/etc.

* Install work around for Autoconf's install-sh relative path anomaly.
  Get rid of old INSTL_*_OPTS variables, now that we don't need them
  anymore.

* Use `gunzip -c' instead of g?zcat. Reportedly broke on AIX.

* Look for only one of readline.h or readline/readline.h, not both.

* Make check for PS_STRINGS cacheable. Don't test for the header files
  separately.

* Disable fcntl(F_SETLK) test on Linux.

* Substitute the standard GCC warnings set into CFLAGS in configure,
  don't add it on in Makefile.global.

* Sweep through contrib tree to teach makefiles standard semantics.

... and in completely unrelated news:

* Make postmaster.opts arbitrary options-aware. I still think we need to
  save the environment as well.
2000-07-09 13:14:19 +00:00
Peter Eisentraut 44d1abebb4 Big warnings cleanup for Solaris/GCC. Down to about 40 now, but
we'll get there one day.

Use `cat' to create aclocal.m4, not `aclocal'. Some people don't
have automake installed.

Only run the autoconf rule in the top-level GNUmakefile if the
invoker specified `make configure', don't run it automatically
because of CVS timestamp skew.
2000-06-14 18:18:01 +00:00
Peter Eisentraut 06cd0f1a32 Substituted new configure test for types of accept()
Interfaced a lot of the custom tests to the config.cache, in the process
made them separate macros and grouped them out into files. Made naming
adjustments.

Removed a couple of useless/unused configure tests.

Disabled C++ by default. C++ is no more special than Perl, Python, and Tcl.
And it breaks equally often. :(
2000-06-11 11:40:09 +00:00
Peter Eisentraut 6a68f42648 The heralded `Grand Unified Configuration scheme' (GUC)
That means you can now set your options in either or all of $PGDATA/configuration,
some postmaster option (--enable-fsync=off), or set a SET command. The list of
options is in backend/utils/misc/guc.c, documentation will be written post haste.

pg_options is gone, so is that pq_geqo config file. Also removed were backend -K,
-Q, and -T options (no longer applicable, although -d0 does the same as -Q).

Added to configure an --enable-syslog option.

changed all callers from TPRINTF to elog(DEBUG)
2000-05-31 00:28:42 +00:00
Tom Lane 1f0aff03c0 Remove calls to getprotobyname(), which we now know leaks memory on
some platforms --- and I also see that it is documented as not thread-
safe on HPUX and possibly other platforms.  No good reason not to just
use IPPROTO_TCP constant from <netinet/in.h> instead.
2000-05-21 21:19:53 +00:00
Bruce Momjian 52f77df613 Ye-old pgindent run. Same 4-space tabs. 2000-04-12 17:17:23 +00:00
Tom Lane 0edcee3459 Fold PQsetenv working state into PGconn, rather than trying to maintain
it in a separate object.  There's no value in keeping the state separate,
and it creates dangling-pointer problems.  Also, remove PQsetenv routines
from public API, until and unless they are redesigned to have a safer
interface.  Since they were never part of the documented API before 7.0,
it's unlikely that anyone is calling them.
2000-03-24 01:39:55 +00:00
Bruce Momjian b2d867fb08 Some points for portability improvements:
1. C++ style comments in C source for ecpg ( // comment )
2. compiler finds wrong include file extern.h in ecpg/lib/descriptor.c
from
include path instead of workdir (rename it ?)
3. fe-connect getsockopt takes a socklen_t as fifth arg not int (use
SOCKET_SIZE_TYPE instead)
4. char vs unsigned char in psql calls to libpq
5. empty define that results in an empty but terminated line ( ; )

Now for all but point 3 I can supply changes to the
compiler flags, to make the compiler less pedantic.
Or is someone interested in the complications ?

in the meantime can someone apply the attached patch ?

Andreas
2000-03-23 17:27:36 +00:00
Tom Lane a71daab4b4 Change PQconndefaults() to return a malloc'd array, instead of a static
array.  This allows processing of conninfo strings to be made thread-safe,
at the cost of a small memory leak in applications that use
PQconndefaults() and are not updated to free the returned array via
the new PQconninfoFree() function.  But PQconndefaults() is probably not
used very much, so this seems like a good compromise.
2000-03-11 03:08:37 +00:00
Bruce Momjian ce9f73c162 The following is required in order to make beta1 compile on the Win32
platform (psql and libpq):

The file "config.h.win32" in the include\ directory (from my patch from
2000-01-18) is missing from the tree. It needs to be put back :-)

The following patch has to be applied in the interfaces\libpq directory.


//Magnus
2000-02-24 15:53:12 +00:00
Jan Wieck da9501bddb Avoid race conditions in detection of EINPROGRESS during connect().
Jan
2000-02-21 12:26:19 +00:00
Tatsuo Ishii 4fec86f1f6 Fix nasty bug in setting client_encoding 2000-02-19 05:04:54 +00:00
Tom Lane b1577a7c78 New cost model for planning, incorporating a penalty for random page
accesses versus sequential accesses, a (very crude) estimate of the
effects of caching on random page accesses, and cost to evaluate WHERE-
clause expressions.  Export critical parameters for this model as SET
variables.  Also, create SET variables for the planner's enable flags
(enable_seqscan, enable_indexscan, etc) so that these can be controlled
more conveniently than via PGOPTIONS.

Planner now estimates both startup cost (cost before retrieving
first tuple) and total cost of each path, so it can optimize queries
with LIMIT on a reasonable basis by interpolating between these costs.
Same facility is a win for EXISTS(...) subqueries and some other cases.

Redesign pathkey representation to achieve a major speedup in planning
(I saw as much as 5X on a 10-way join); also minor changes in planner
to reduce memory consumption by recycling discarded Path nodes and
not constructing unnecessary lists.

Minor cleanups to display more-plausible costs in some cases in
EXPLAIN output.

Initdb forced by change in interface to index cost estimation
functions.
2000-02-15 20:49:31 +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 d4e62e5ded Change function name PQclientencoding to PQclientEncoding since
it seems more suitable for the naming convention in libpq.

New function PQsetClientEncoding added. It makes possible to change
the client encoding on the fly without setting PGCLIENTENCODING.
2000-02-05 12:33:22 +00:00
Bruce Momjian 5c25d60244 Add:
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc

to all files copyright Regents of Berkeley.  Man, that's a lot of files.
2000-01-26 05:58:53 +00:00
Bruce Momjian da5aba105f Remove Ops parameter from STATRELID cache lookup, for Tom Lane and
optimizer.
2000-01-24 02:12:58 +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
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
Bruce Momjian 10d7287ab9 Libpq non-blocking mode, from Alfred Perlstein 2000-01-18 06:09:24 +00:00
Tom Lane d00391e7ac Sigh, I'm an idiot ... I broke the async startup logic a couple days ago,
by creating a race condition.  It wasn't waiting for select() to say
write-ready immediately after connect, which meant that you might get
an unhelpful 'broken pipe' error message if connect failed, rather than
the intended error message.
2000-01-16 21:18:52 +00:00
Tatsuo Ishii 8fc386a2d8 Eliminate using putenv(). 2000-01-15 05:37:21 +00:00
Tom Lane 2af360ed1c Clean up some problems in new asynchronous-connection logic
in libpq --- mostly, poor response to error conditions.  You now actually
get to see the postmaster's 'The Data Base System is starting up' message,
which you didn't before.  I suspect the SSL code is still broken though.
2000-01-14 05:33:15 +00:00
Tom Lane 9de156f116 Type 'socklen_t' might be the right way to declare getsockopt()'s last
parameter in some flavor of Unix, but Linux, HPUX, and SunOS all say
it's int.  For now I'm just going to make it int so that I can compile.
If the other way is actually necessary on some Unix somewhere, I guess
we will need a configure test...
1999-12-02 00:26:15 +00:00
Bruce Momjian 3ab5b1f1e6 This patch (against the current CVS sources) adds to libpq the functions
PQconnectStart
PQconnectPoll
PQresetStart
PQresetPoll
PQsetenvStart
PQsetenvPoll
PQsetenvAbort

and brings into the published interface

PQsetenv.

The first four are asynchronous analogues of PQconnectdb and PQreset -
they allow an application to connect to the DB without blocking on
remote I/O.

The PQsetenv functions perform an environment negotiation with the
server.

Internal to libpq, pqReadReady and pqWriteReady have been made available
across the library (they were previously static functions inside
fe-misc.c).  A lot of internal rearrangement has been necessary to
support these changes.

The API documentation has been updated also.

Caveats:

  o  The Windows code does not default to using non-blocking sockets,
since I have no documentation: Define WIN32_NON_BLOCKING_CONNECTIONS to
do that.

  o  The SSL code still blocks.


Ewan Mellor.
1999-11-30 03:08:19 +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
Tom Lane 3b004b8e2e environment variable set by MULTIBYTE startup code should be
stored in malloc'd space, not in a static variable.  Otherwise environment
variable list is corrupted if libpq is dynamically unlinked...
1999-11-05 06:43:45 +00:00
Bruce Momjian 724bf74693 These are two minor corrections to libpq's PQsetNoticeProcessor function.
One, it now returns the previous hook. That way people don't have to dig
around in libpq-int.h for that information anymore. It previously
returned void, so there should be no incompatibilities.

Second, you cannot set the callback to NULL anymore. (Of course you can
still call it with NULL just to get the current hook.) The way libpq uses
the callback pointer, having a NULL there wasn't very healthy.

Peter Eisentraut
1999-10-26 04:49:00 +00:00
Bruce Momjian e0e7daef6d Lots of patches coming in from me today :-)
When drawing up a very simple "text-drawing" of how the negotiation is done,
I realised I had done this last part (fallback) in a very stupid way. Patch
#4 fixes this, and does it in a much better way.

Included is also the simple text-drawing of how the negotiation is done.

//Magnus
1999-09-27 03:13:16 +00:00
Tom Lane ab5cafa5d3 Update frontend libpq to remove limits on query lengths,
error/notice message lengths, and number of fields per tuple.  Add
pqexpbuffer.c/.h, a frontend version of backend's stringinfo module.
This is first step in applying Mike Ansley's long-query patches,
even though he didn't do any of these particular changes...
1999-08-31 01:37:37 +00:00
Bruce Momjian e259780b13 Enable WIN32 compilation of libpq. 1999-07-19 06:25:40 +00:00
Bruce Momjian e44c931801 Re-add getopt.h check, remove NT-specific tests for it. 1999-07-19 02:27:16 +00:00
Bruce Momjian 3406901a29 Move some system includes into c.h, and remove duplicates. 1999-07-17 20:18:55 +00:00
Bruce Momjian 4c65382596 Remove QUERY_LIMIT and documenation on same. Change _ALIGN to TYPEALIGN
for Irix.
1999-06-17 15:16:09 +00:00
Bruce Momjian 07842084fe pgindent run over code. 1999-05-25 16:15:34 +00:00
Bruce Momjian 210055ad61 here are some patches for 6.5.0 which I already submitted but have never
been applied. The patches are in the .tar.gz attachment at the end:

varchar-array.patch     this patch adds support for arrays of bpchar() and
                        varchar(), which where always missing from postgres.

                        These datatypes can be used to replace the _char4,
                        _char8, etc., which were dropped some time ago.

block-size.patch        this patch fixes many errors in the parser and other
                        program which happen with very large query statements
                        (> 8K) when using a page size larger than 8192.

                        This patch is needed if you want to submit queries
                        larger than 8K. Postgres supports tuples up to 32K
                        but you can't insert them because you can't submit
                        queries larger than 8K. My patch fixes this problem.

                        The patch also replaces all the occurrences of `8192'
                        and `1<<13' in the sources with the proper constants
                        defined in include files. You should now never find
                        8192 hardwired in C code, just to make code clearer.


--
Massimo Dal Zotto
1999-05-03 19:10:48 +00:00
Tatsuo Ishii c2d59497df change comparison char* and NULL to char* and '\0'. This should be
more portable way.
1999-03-29 08:19:36 +00:00
Marc G. Fournier 8c3e8a8a0e From: Tatsuo Ishii <t-ishii@sra.co.jp>
Ok. I made patches replacing all of "#if FALSE" or "#if 0" to "#ifdef
NOT_USED" for current. I have tested these patches in that the
postgres binaries are identical.
1999-02-21 03:49:55 +00:00
Bruce Momjian b4e7510e09 Enable bushy and right-hand queries by default. 1999-02-18 06:01:11 +00:00
Bruce Momjian 6724a50787 Change my-function-name-- to my_function_name, and optimizer renames. 1999-02-13 23:22:53 +00:00
Bruce Momjian f962514403 Reverse out const to libpq interface from D'Arcy. 1999-02-05 04:25:55 +00:00
Bruce Momjian a03b817373 Const fixes from D'Arcy. 1999-02-04 03:20:39 +00:00
Marc G. Fournier 2ae5d51668 From: Tatsuo Ishii <t-ishii@sra.co.jp>
Included patches fix a portability problem of unsetenv() used in
6.4.2 multi-byte support. unsetenv() is only avaliable on FreeBSD and
Linux so I decided to replace with putenv().
1999-01-27 01:18:23 +00:00
Bruce Momjian 7a6b562fdf Apply Win32 patch from Horak Daniel. 1999-01-17 06:20:06 +00:00
Tom Lane 4a6285ee44 Improve error message when connect() call fails:
report kernel's errno value.
1999-01-17 03:37:19 +00:00
Bruce Momjian aa3a1f46df New PGQUERY_LIMIT environment variable, and doc changes. 1998-10-14 05:31:50 +00:00
Marc G. Fournier 4fff1dada7 From: Peter Gucwa <pg@softcomputer.com>
Here are patches needed to complie under AIX 4.2.
I changed configure.in, pqcomm.c, config.h.in, and fe-connect.c.
Also I had to install flex because lex did not want to translate pgc.l.
1998-10-13 20:44:49 +00:00
Tom Lane 6428074e27 Update libpq to store an error message in PGresult, per pgsq-interfaces discussion of 21-Sep. 1998-10-01 01:40:26 +00:00
Bruce Momjian aa158a746c Fix memory leak from Tom Lane. 1998-09-20 04:51:12 +00:00
Bruce Momjian 1202ab259a Fixes for VC and libpq.
Magnus Hagander
1998-09-18 16:46:07 +00:00
Bruce Momjian f71d0cf64e Attached is a patch to remove the definitions of libpq's internal
structs from libpq-fe.h, as we previously discussed.

There turned out to be sloppy coding practices in more places than
I had realized :-(, but all in all I think it was a well-worth-while
exercise.

I ended up adding several routines to libpq's API in order to respond
to application requirements that were exposed by this work.  I owe the
docs crew updates for libpq.sgml to describe these changes.  I'm way too
tired to work on the docs tonight, however.

This is the last major change I intend to submit for 6.4.  I do want
to see if I can make libpgtcl work with Tcl 8.0 before we go final,
but hopefully that will be a minor bug fix.
1998-09-03 02:10:56 +00:00
Bruce Momjian fa1a8d6a97 OK, folks, here is the pgindent output. 1998-09-01 04:40:42 +00:00
Marc G. Fournier 9312033071 Date: Sun, 16 Aug 1998 14:56:48 -0400
From: Tom Lane <tgl@sss.pgh.pa.us>
Attached is a patch for this weekend's work on libpq.  I've dealt
with several issues:

        <for details: see message, in pgsql-patches archive for above data>
1998-08-17 03:50:43 +00:00
Bruce Momjian e6311b4ad0 The attached patch implements some changes that were discussed a
couple weeks ago on the hackers and interfaces lists:

1. When the backend sends a NOTICE message and closes the connection
   (typically, because it was told to by the postmaster after
   another backend coredumped), libpq will now print the notice
   and close the connection cleanly.  Formerly, the frontend app
   would usually terminate ungracefully due to a SIGPIPE.  (I am
   not sure if 6.3.2 behaved that way, but the current cvs sources
   do...)

2. libpq's various printouts to stderr are now fed through a single
   "notice processor" routine, which can be overridden by the
   application to direct notices someplace else.  This should ease
   porting libpq to Windows.

I also noticed and fixed a problem in PQprint: when sending output
to a pager subprocess, it would disable SIGPIPE in case the pager
terminates early (this is good) --- but afterwards it reset SIGPIPE
to SIG_DFL, rather than restoring the application's prior setting
(bad).

			regards, tom lane
1998-08-09 02:59:33 +00:00
Marc G. Fournier 5979d73841 From: t-ishii@sra.co.jp
As Bruce mentioned, this is due to the conflict among changes we made.
Included patches should fix the problem(I changed all MB to
MULTIBYTE). Please let me know if you have further problem.

P.S. I did not include pathces to configure and gram.c to save the
file size(configure.in and gram.y modified).
1998-07-26 04:31:41 +00:00
Marc G. Fournier bf00bbb0c4 I really hope that I haven't missed anything in this one...
From: t-ishii@sra.co.jp

Attached are patches to enhance the multi-byte support.  (patches are
against 7/18 snapshot)

* determine encoding at initdb/createdb rather than compile time

Now initdb/createdb has an option to specify the encoding. Also, I
modified the syntax of CREATE DATABASE to accept encoding option. See
README.mb for more details.

For this purpose I have added new column "encoding" to pg_database.
Also pg_attribute and pg_class are changed to catch up the
modification to pg_database.  Actually I haved added pg_database_mb.h,
pg_attribute_mb.h and pg_class_mb.h. These are used only when MB is
enabled. The reason having separate files is I couldn't find a way to
use ifdef or whatever in those files. I have to admit it looks
ugly. No way.

* support for PGCLIENTENCODING when issuing COPY command

commands/copy.c modified.

* support for SQL92 syntax "SET NAMES"

See gram.y.

* support for LATIN2-5
* add UNICODE regression test case
* new test suite for MB

New directory test/mb added.

* clean up source files

Basic idea is to have MB's own subdirectory for easier maintenance.
These are include/mb and backend/utils/mb.
1998-07-24 03:32:46 +00:00
Bruce Momjian 7b2b779a2a Add auto-size to screen to \d? commands. Use UNION to show all
\d? results in one query. Add \d? field search feature.  Rename MB
to MULTIBYTE.
1998-07-18 18:34:34 +00:00
Marc G. Fournier bd029bcb4a From: Tom Lane <tgl@sss.pgh.pa.us>
The attached patches respond to discussion that was on pgsql-hackers
around the beginning of June (see thread "libpgtcl bug (and symptomatic
treatment)").  The changes are:

1. Remove code in connectDB that throws away the password after making
a connection.  This doesn't really add much security IMHO --- a bad guy
with access to your client's address space can likely extract the
password anyway, to say nothing of what he might do directly.  And
there's the serious shortcoming that it prevents PQreset() from working
if the database requires a password.

2. Fix coredump problem: fe_sendauth did not guard against being handed
a NULL password pointer.  (This is the proximate cause of the coredump-
during-PQreset problem that Magosanyi Arpad complained of last month.)

3. Remove highly questionable "error recovery" logic in libpgtcl's
pg_exec statement.

I believe the consensus of the discussion last month was in favor of
#1 and #3, but I'm just now getting around to making the change.
I realized that #2 was a bug in process of looking at the change.
1998-07-09 03:32:10 +00:00
Marc G. Fournier a0659e3e2c From: Tom Lane <tgl@sss.pgh.pa.us>
Making PQrequestCancel safe to call in a signal handler turned out to be
much easier than I feared.  So here are the diffs.

Some notes:
  * I modified the postmaster's packet "iodone" callback interface to allow
    the callback routine to return a continue-or-drop-connection return
    code; this was necessary to allow the connection to be closed after
    receiving a Cancel, rather than proceeding to launch a new backend...
    Being a neatnik, I also made the iodone proc have a typechecked
    parameter list.
  * I deleted all code I could find that had to do with OOB.
  * I made some edits to ensure that all signals mentioned in the code
    are referred to symbolically not by numbers ("SIGUSR2" not "2").
    I think Bruce may have already done at least some of the same edits;
    I hope that merging these patches is not too painful.
1998-07-09 03:29:11 +00:00
Marc G. Fournier b27af0d94a From: "Dr. Michael Meskes" <meskes@online-club.de>
My first try at libpq. This one enables the two styles we agreed upon for
database descriptors.
1998-07-07 18:00:09 +00:00
Bruce Momjian 9f9644d01d win32 cleanup 1998-07-03 04:29:04 +00:00
Bruce Momjian c765b4b052 Hello!
Through some minor changes, I have been able to compile the libpq
client libraries on the Win32 platform. Since the libpq communications
part has been rewritten, this has become much easier. Enclosed is
a patch that will allow at least Microsoft Visual C++ to compile
libpq into both a static and a dynamic library.  I will take a look
at porting the psql frontend as well, but I figured it was a good
idea to send in these patches first - so no major changes are done
to the files before it gets applied (if it does).

Regards,
  Magnus Hagander
1998-07-03 04:24:16 +00:00
Bruce Momjian 8bad4e23a8 Remove un-needed include files. 1998-06-21 16:39:11 +00:00
Bruce Momjian cb7cbc16fa Hi, here are the patches to enhance existing MB handling. This time
I have implemented a framework of encoding translation between the
backend and the frontend. Also I have added a new variable setting
command:

SET CLIENT_ENCODING TO 'encoding';

Other features include:
	Latin1 support more 8 bit cleaness

See doc/README.mb for more details. Note that the pacthes are
against May 30 snapshot.

Tatsuo Ishii
1998-06-16 07:29:54 +00:00
Bruce Momjian 6bd323c6b3 Remove un-needed braces around single statements. 1998-06-15 19:30:31 +00:00
Bruce Momjian edbd51395c What I've done:
1. Rewritten libpq to allow asynchronous clients.

2. Implemented client side of cancel protocol in library,
   and patched psql.c to send a cancel request upon SIGINT.  The
   backend doesn't notice it yet :-(

3. Implemented 'Z' protocol message addition and renaming of
   copy in/out start messages.  These are implemented conditionally,
   ie, the client protocol version is checked; so the code should
   still work with 1.0 clients.

4. Revised protocol and libpq sgml documents (don't have an SGML
   compiler, though, so there may be some markup glitches here).


What remains to be done:

1. Implement addition of atttypmod field to RowDescriptor messages.
   The client-side code is there but ifdef'd out.  I have no idea
   what to change on the backend side.  The field should be sent
   only if protocol >= 2.0, of course.

2. Implement backend response to cancel requests received as OOB
   messages.  (This prolly need not be conditional on protocol
   version; just do it if you get SIGURG.)

3. Update libpq.3.  (I'm hoping this can be generated mechanically
   from libpq.sgml... if not, will do it by hand.)  Is there any
   other doco to fix?

4. Update non-libpq interfaces as necessary.  I patched libpgtcl
   so that it would compile, but haven't tested it.  Dunno what
   needs to be done with the other interfaces.

Have at it!

Tom Lane
1998-05-06 23:51:16 +00:00
Marc G. Fournier 5bdda53f12 From: Bryan Henderson <bryanh@giraffe-data.com>
Here's a fix for a tiny memory leak in PQsetdb/PQfinish.

(Analysis of a running program indicates there are several others, but
this is the only obvious one I saw in the code).
1998-04-21 04:00:06 +00:00
Bruce Momjian f07c7bf4e7 I have been troubled by a segmentation fault when reloading from
a dumpall.  This has been happening when a second \connect is
encountered.

The faulty code was in fe-connect.c, where the memory for the user
password was freed, but the pointer itself was not set to NULL.
Later, the memory was reused and the password appeared not to be
empty, so that an attempt was made to reference it.

Oliver Elphick
1998-03-26 23:46:14 +00:00
Bruce Momjian a32450a585 pgindent run before 6.3 release, with Thomas' requested changes. 1998-02-26 04:46:47 +00:00
Marc G. Fournier 7a33578436 From: Phil Thompson <phil@river-bank.demon.co.uk>
I haven't had final confirmation from Peter yet, but the attached patch
needs to be applied for the Beta otherwise password and crypt
authentication just won't work.

It puts back the loop in libpq and also fixes a couple of problems with
maintaining compatability with pre-6.3 drivers.
1998-01-31 21:27:28 +00:00
Marc G. Fournier 8e789e8ef1 From: Phil Thompson <phil@river-bank.demon.co.uk>
Attached is the patch to fix the warning messages from my code.  I also
fixed one which wasn't my code.  Apart from the usual warnings about the
bison/yacc generated code I only have one other warning message.  This
is in gramm.y around line 2234.  I wasn't sure of the fix.

I've also replaced all the calls to free() in gramm.y to calls to
pfree().  Without these I was getting backend crashes with GRANT.  This
might already have been fixed.
1998-01-29 03:24:36 +00:00
Marc G. Fournier 8a02b22e89 From: Peter T Mount <patches@maidast.demon.co.uk>
This has a problem when using any authentication other than trust or
ident.

Anything using libpq will hang, because the client will go into a loop
while connecting. The following patch simply comments out two lines (a do
and a while), removing the loop. Going through the new scheme, I can't see
why this do..while loop is in there.
1998-01-28 03:42:27 +00:00
Marc G. Fournier d5bbe2aca5 From: Phil Thompson <phil@river-bank.demon.co.uk>
I've completed the patch to fix the protocol and authentication issues I
was discussing a couple of weeks ago.  The particular changes are:

- the protocol has a version number
- network byte order is used throughout
- the pg_hba.conf file is used to specify what method is used to
  authenticate a frontend (either password, ident, trust, reject, krb4
  or krb5)
- support for multiplexed backends is removed
- appropriate changes to man pages
- the -a switch to many programs to specify an authentication service
  no longer has any effect
- the libpq.so version number has changed to 1.1

The new backend still supports the old protocol so old interfaces won't
break.
1998-01-26 01:42:53 +00:00
Marc G. Fournier c487962dd7 Fixes a free() problem under FreeBSD
Fixed pointed out by: jwieck@debis.com (Jan Wieck)
1998-01-23 02:31:18 +00:00
Marc G. Fournier 98c7cb11de From: Jan Wilhelm <Jan_Wilhelm@Physik.TU-Muenchen.DE>
a) psql dumps core when using -a password and PGUSER is set but PGPASSWORD
   not set.
1998-01-17 23:17:46 +00:00
Bruce Momjian cb3ce64f2e Cleanup of prototypes. FIx for PQtrace start/stop several times. 1998-01-14 15:48:51 +00:00
Vadim B. Mikheev 1fd402be54 Remove unused "option" from PQconnectdb(). 1998-01-13 14:57:25 +00:00
Marc G. Fournier 602b0d0c1c From: Goran Thyni <goran@bildbasen.se>
OK, here comes a patch, DBD::Pg (and possibly other 3rd party clients)
can connect to unix sockets.
Patch is against current source tree.

Background:
libpq set some policy for client, which it should not
IMHO. It prevent some 3rd party clients to connect with
unix domain sockets etc.
1998-01-13 04:24:10 +00:00
Bruce Momjian 5a5cb30096 Fix tolower loops to go in proper direction for cache. 1997-12-05 01:13:24 +00:00
Bruce Momjian 8d30b40843 Update description for PGHOST and unix domain sockets. Add warning for failed connections. 1997-12-04 20:32:35 +00:00
Bruce Momjian 7d2fafe636 Update description for PGHOST and unix domain sockets. Add warning for failed connections. 1997-12-04 20:26:37 +00:00
Marc G. Fournier 4c04f7724e From: todd brandys <brandys@eng3.hep.uiuc.edu>
An extension to the code to allow for a pg_password authentication database
that is *seperate* from the system password file
1997-12-04 00:28:15 +00:00
Bruce Momjian b05eddaaab Fix pg_dump, and libpq changes. 1997-12-01 22:02:49 +00:00
Bruce Momjian dfc1a6a848 Document pg_dump -z, clean up option list. Fix problem with libpq handling of field names uppercase code. 1997-12-01 21:01:24 +00:00
Thomas G. Lockhart 80c1e82232 Unscramble port selection logic to avoid compiler complaints about
uninitialized variables. I _think_ the logic is preserved...
1997-11-17 16:42:39 +00:00
Thomas G. Lockhart 3a73060ba5 Add other initialization environment variables:
PGCOSTHEAP, PGCOSTINDEX, PGRPLANS, PGGEQO
 (PGDATESTYLE, PGTZ already defined)
1997-11-14 15:38:31 +00:00
Thomas G. Lockhart 367089b0c1 Add PGTZ environment variable to initialization code.
Rename PG_DATESTYLE to PGDATESTYLE environment variable.
Move environment variable code to a different place so it now works!
Note that regression tests can now run with "setenv PGTZ PST8PDT"
 at the frontend rather than requiring the backend to have TZ set.
1997-11-10 15:41:58 +00:00
Bruce Momjian baeb8790ac Fix case issues with quotes. 1997-11-10 05:10:50 +00:00
Bruce Momjian c17fa36d3c Add Unix domain socket support, from Goran Thyni, goran@bildbasen.se 1997-11-07 20:52:15 +00:00
Bruce Momjian 3f365ba0fc Inline memset() as MemSet(). 1997-09-18 20:22:58 +00:00