2001-11-22 11:18:52 +01:00
|
|
|
#ifndef pg_config_h_win32__
|
|
|
|
#define pg_config_h_win32__
|
2000-02-24 17:02:28 +01:00
|
|
|
/*
|
2001-08-24 16:07:50 +02:00
|
|
|
* Parts of pg_config.h that you get with autoconf on other systems
|
2000-02-24 17:02:28 +01:00
|
|
|
*/
|
2005-01-18 15:39:46 +01:00
|
|
|
#define PG_VERSION "8.1.0"
|
|
|
|
#define PG_VERSION_STR "8.1.0 (win32)"
|
2000-02-24 17:02:28 +01:00
|
|
|
|
2001-02-07 21:00:08 +01:00
|
|
|
#define DEF_PGPORT 5432
|
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 04:42:38 +01:00
|
|
|
#define DEF_PGPORT_STR "5432"
|
2001-02-07 21:00:08 +01:00
|
|
|
|
2000-02-24 17:02:28 +01:00
|
|
|
#define MAXIMUM_ALIGNOF 4
|
2001-02-07 21:00:08 +01:00
|
|
|
#define ACCEPT_TYPE_ARG3 int
|
|
|
|
|
2000-02-24 17:02:28 +01:00
|
|
|
#define MAXPGPATH 1024
|
|
|
|
|
2002-10-03 19:09:42 +02:00
|
|
|
#define INDEX_MAX_KEYS 32
|
|
|
|
|
2001-03-26 17:21:33 +02:00
|
|
|
#define HAVE_ATEXIT
|
2000-02-24 17:02:28 +01:00
|
|
|
#define HAVE_MEMMOVE
|
2001-07-12 00:12:43 +02:00
|
|
|
|
2003-06-12 10:15:29 +02:00
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#define HAVE_RANDOM
|
|
|
|
#endif
|
|
|
|
|
2001-11-22 11:18:52 +01:00
|
|
|
/* use _snprintf instead of snprintf */
|
2002-04-24 04:26:06 +02:00
|
|
|
#define HAVE_DECL_SNPRINTF 1
|
2001-11-22 11:18:52 +01:00
|
|
|
#define snprintf _snprintf
|
2002-01-22 20:02:40 +01:00
|
|
|
|
|
|
|
/* defines for dynamic linking on Win32 platform */
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
|
|
|
|
#if __GNUC__ && ! defined (__declspec)
|
|
|
|
#error You need egcs 1.1 or newer for compiling!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUILDING_DLL
|
|
|
|
#define DLLIMPORT __declspec (dllexport)
|
|
|
|
#else /* not BUILDING_DLL */
|
|
|
|
#define DLLIMPORT __declspec (dllimport)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#elif defined(WIN32) && defined(_MSC_VER) /* not CYGWIN */
|
|
|
|
|
|
|
|
#if defined(_DLL)
|
|
|
|
#define DLLIMPORT __declspec (dllexport)
|
|
|
|
#else /* not _DLL */
|
|
|
|
#define DLLIMPORT __declspec (dllimport)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else /* not CYGWIN, not MSVC */
|
|
|
|
|
|
|
|
#define DLLIMPORT
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-10-03 19:09:42 +02:00
|
|
|
#ifndef __CYGWIN__
|
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
2001-11-22 11:18:52 +01:00
|
|
|
#endif /* pg_config_h_win32__ */
|