postgresql/src/include/libpq/libpq.h

80 lines
2.1 KiB
C
Raw Normal View History

/*-------------------------------------------------------------------------
*
* libpq.h
* POSTGRES LIBPQ buffer structure definitions.
*
*
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq.h,v 1.43 2001/01/24 19:43:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef LIBPQ_H
#define LIBPQ_H
#include <sys/types.h>
#include <netinet/in.h>
#include "lib/stringinfo.h"
#include "libpq/libpq-be.h"
/* ----------------
1999-05-25 18:15:34 +02:00
* PQArgBlock
* Information (pointer to array of this structure) required
* for the PQfn() call. (This probably ought to go somewhere else...)
* ----------------
*/
typedef struct
{
int len;
int isint;
union
{
int *ptr; /* can't use void (dec compiler barfs) */
int integer;
} u;
} PQArgBlock;
/*
* PQerrormsg[] is used only for error messages generated within backend
* libpq, none of which are remarkably long. Note that this length should
* NOT be taken as any indication of the maximum error message length that
* the backend can create! elog() can in fact produce extremely long messages.
*/
#define PQERRORMSG_LENGTH 1024
extern char PQerrormsg[PQERRORMSG_LENGTH]; /* in libpq/util.c */
/*
* External functions.
*/
/*
* prototypes for functions in pqcomm.c
*/
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 16:18:15 +01:00
extern int StreamServerPort(int family, char *hostName,
2000-11-14 02:15:06 +01:00
unsigned short portNumber, char *unixSocketName, int *fdP);
extern int StreamConnection(int server_fd, Port *port);
extern void StreamClose(int sock);
extern void pq_init(void);
extern int pq_getbytes(char *s, size_t len);
extern int pq_getstring(StringInfo s);
extern int pq_peekbyte(void);
extern int pq_putbytes(const char *s, size_t len);
extern int pq_flush(void);
extern int pq_putmessage(char msgtype, const char *s, size_t len);
1999-05-25 18:15:34 +02:00
extern void pq_startcopyout(void);
extern void pq_endcopyout(bool errorAbort);
/*
* prototypes for functions in util.c
*/
extern void pqdebug(char *fmt, char *msg);
extern void PQtrace(void);
extern void PQuntrace(void);
#endif /* LIBPQ_H */