head	1.24;
access;
symbols
	Version_2_1:1.15
	Version_2:1.7
	C_Demo_1:1.6;
locks; strict;
comment	@ * @;


1.24
date	92.08.03.18.17.51;	author mer;	state Exp;
branches;
next	1.23;

1.23
date	92.07.15.05.07.24;	author mao;	state Exp;
branches;
next	1.22;

1.22
date	92.05.07.23.35.05;	author clarsen;	state Exp;
branches;
next	1.21;

1.21
date	92.04.21.13.16.10;	author clarsen;	state Exp;
branches;
next	1.20;

1.20
date	92.04.03.16.30.44;	author clarsen;	state Exp;
branches;
next	1.19;

1.19
date	92.02.25.15.28.33;	author clarsen;	state Exp;
branches;
next	1.18;

1.18
date	91.11.13.08.47.08;	author clarsen;	state Exp;
branches;
next	1.17;

1.17
date	91.11.07.22.12.47;	author mer;	state Exp;
branches;
next	1.16;

1.16
date	91.03.21.21.17.35;	author kemnitz;	state Exp;
branches;
next	1.15;

1.15
date	91.02.26.19.27.12;	author cimarron;	state Exp;
branches;
next	1.14;

1.14
date	91.02.23.23.40.48;	author cimarron;	state Exp;
branches;
next	1.13;

1.13
date	91.02.20.00.30.56;	author cimarron;	state Exp;
branches;
next	1.12;

1.12
date	91.02.10.18.23.29;	author cimarron;	state Exp;
branches;
next	1.11;

1.11
date	91.01.12.17.56.05;	author mao;	state Exp;
branches;
next	1.10;

1.10
date	90.08.23.20.15.20;	author cimarron;	state Exp;
branches;
next	1.9;

1.9
date	90.08.21.09.32.57;	author choi;	state Exp;
branches;
next	1.8;

1.8
date	90.08.17.08.54.41;	author cimarron;	state Exp;
branches;
next	1.7;

1.7
date	90.07.12.14.57.46;	author kemnitz;	state Version_2;
branches;
next	1.6;

1.6
date	89.09.05.17.15.54;	author mao;	state C_Demo_1;
branches;
next	1.5;

1.5
date	89.08.31.20.29.13;	author dillon;	state Exp;
branches;
next	1.4;

1.4
date	89.08.30.18.59.38;	author ong;	state Exp;
branches;
next	1.3;

1.3
date	89.03.22.17.35.27;	author muir;	state Stab;
branches;
next	1.2;

1.2
date	89.03.01.17.46.20;	author dillon;	state Exp;
branches;
next	1.1;

1.1
date	89.01.17.05.55.17;	author cimarron;	state Exp;
branches;
next	;


desc
@@


1.24
log
@pq_getstr really returns an integer
@
text
@/* ----------------------------------------------------------------
 *   FILE
 *	libpq.h
 *
 *   DESCRIPTION
 *	POSTGRES LIBPQ buffer structure definitions.
 *
 *   NOTES
 *	This file contains definitions for structures and
 *	externs for functions used by both frontend applications
 *	and the POSTGRES backend.  See the files libpq-fe.h and
 *	libpq-be.h for frontend/backend specific information
 *
 *   IDENTIFICATION
 *	$Header: /private/mer/pg/src/lib/H/tmp/RCS/libpq.h,v 1.23 1992/07/15 05:07:24 mao Exp mer $
 * ----------------------------------------------------------------
 */

#ifndef LibpqIncluded 	/* include this file only once. */
#define LibpqIncluded 	1

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "tmp/simplelists.h"
#include "utils/exc.h"

/* ----------------
 * PQArgBlock --
 *	Information (pointer to array of this structure) required
 *	for the PQfn() call.
 * ----------------
 */
typedef struct {
    int len;
    int isint;
    union {
        int *ptr;	/* can't use void (dec compiler barfs)	*/
	int integer;
    } u;
} PQArgBlock;

/* ----------------
 * TypeBlock --
 * 	Information about an attribute.
 * ----------------
 */
#define NameLength 16

typedef struct TypeBlock {
    char name[NameLength];	/* name of the attribute */
    int adtid;			/* adtid of the type */
    int adtsize;		/* adtsize of the type */
} TypeBlock;

/* ----------------
 * TupleBlock --
 *	Data of a tuple.
 * ----------------
 */
#define TupleBlockSize 100

typedef struct TupleBlock {
    char **values[TupleBlockSize];	/* an array of tuples */
    int *lengths[TupleBlockSize];       /* an array of length vec. foreach
					   tuple */
    struct TupleBlock *next;		/* next tuple block */
    int    tuple_index;			/* current tuple index */
} TupleBlock;

/* ----------------
 * GroupBuffer --
 * 	A group of tuples with the same attributes.
 * ----------------
 */
typedef struct GroupBuffer {
    int no_tuples;		/* number of tuples in this group */
    int no_fields;		/* number of attributes */
    TypeBlock *types;  		/* types of the attributes */
    TupleBlock *tuples;		/* tuples in this group */
    struct GroupBuffer *next;	/* next group */
} GroupBuffer;

/* ----------------
 * PortalBuffer --
 *	Data structure of a portal buffer.  
 * ----------------
 */
typedef struct PortalBuffer {
    int rule_p;			/* 1 if this is an asynchronized portal. */
    int no_tuples;		/* number of tuples in this portal buffer */
    int no_groups;		/* number of tuple groups */
    GroupBuffer *groups;	/* tuple groups */
} PortalBuffer;

/* ----------------
 * PortalEntry --
 *	an entry in the global portal table
 *
 * Note: the portalcxt is only meaningful for PQcalls made from
 *       within a postgres backend.  frontend apps should ignore it.
 * ----------------
 */
#define PortalNameLength 32

typedef struct PortalEntry {
    char 	  name[PortalNameLength]; /* name of this portal */
    PortalBuffer  *portal;	          /* tuples contained in this portal */
    Pointer	  portalcxt;	          /* memory context (for backend) */
    Pointer	  result;	          /* result for PQexec */
} PortalEntry;

#define MAXPORTALS 10

extern PortalEntry *portals[];

/*
 *  Asynchronous notification
 */
typedef struct PQNotifyList {
    char relname[16];		/* name of relation containing data */
    int be_pid;			/* process id of backend */
    int valid;			/* has this already been handled by user. */
    SLNode Node;
} PQNotifyList;

/*
 * Exceptions.
 */

#define libpq_raise(X, Y) ExcRaise((Exception *)(X), (ExcDetail) (Y),\
				   (ExcData)0, (ExcMessage) 0)

extern Exception MemoryError, PortalError, PostquelError, ProtocolError;

/* 
 * POSTGRES backend dependent Constants. 
 */

#define initstr_length 256
#define error_msg_length 4096
#define command_length 20
#define remark_length 80
#define portal_name_length 16

extern    char PQerrormsg[error_msg_length];
/*
 * External functions.
 */
extern void pqdebug ARGS((char *target, char *msg));
extern void pqdebug2 ARGS((char *target, char *msg1, char *msg2));
extern void PQtrace ARGS(());
extern void PQuntrace ARGS(());
extern int PQnportals ARGS((int rule_p));
extern void PQpnames ARGS((char **pnames, int rule_p));
extern PortalBuffer *PQparray ARGS((char *pname));
extern int PQrulep ARGS((PortalBuffer *portal));
extern int PQntuples ARGS((PortalBuffer *portal));
extern int PQninstances ARGS((PortalBuffer *portal));
extern int PQngroups ARGS((PortalBuffer *portal));
extern int PQntuplesGroup ARGS((PortalBuffer *portal, int group_index));
extern int PQninstancesGroup ARGS((PortalBuffer *portal, int group_index));
extern int PQnfieldsGroup ARGS((PortalBuffer *portal, int group_index));
extern int PQfnumberGroup ARGS((PortalBuffer *portal, int group_index, char *field_name));
extern char *PQfnameGroup ARGS((PortalBuffer *portal, int group_index, int field_number));
extern GroupBuffer *PQgroup ARGS((PortalBuffer *portal, int tuple_index));
extern int PQgetgroup ARGS((PortalBuffer *portal, int tuple_index));
extern int PQnfields ARGS((PortalBuffer *portal, int tuple_index));
extern int PQfnumber ARGS((PortalBuffer *portal, int tuple_index, char *field_name));
extern char *PQfname ARGS((PortalBuffer *portal, int tuple_index, int field_number));
extern int PQftype ARGS((PortalBuffer *portal, int tuple_index, int field_number));
extern int PQsametype ARGS((PortalBuffer *portal, int tuple_index1, int tuple_index2));
extern char *PQgetvalue ARGS((PortalBuffer *portal, int tuple_index, int field_number));
extern int PQgetlength ARGS((PortalBuffer *portal, int tuple_index, int field_number));
extern void PQclear ARGS((char *pname));
void PQcleanNotify ARGS((void ));
void PQnotifies_init ARGS((void ));
PQNotifyList *PQnotifies ARGS((void ));
void PQremoveNotify ARGS((PQNotifyList *nPtr ));
void PQappendNotify ARGS((char *relname , int pid ));

extern caddr_t pbuf_alloc ARGS((size_t size));
extern void pbuf_free ARGS((caddr_t pointer));
extern PortalBuffer *pbuf_addPortal ARGS(());
extern GroupBuffer *pbuf_addGroup ARGS((PortalBuffer *portal));
extern TypeBlock *pbuf_addTypes ARGS((int n));
extern TupleBlock *pbuf_addTuples ARGS(());
extern char **pbuf_addTuple ARGS((int n));
extern char *pbuf_addValues ARGS((int n));
extern int *pbuf_addTupleValueLengths ARGS((int n));
extern PortalEntry *pbuf_addEntry ARGS(());
extern void pbuf_freeEntry ARGS((int i));
extern void pbuf_freeTypes ARGS((TypeBlock *types));
extern void pbuf_freeTuples ARGS((TupleBlock *tuples, int no_tuples, int no_fields));
extern void pbuf_freeGroup ARGS((GroupBuffer *group));
extern void pbuf_freePortal ARGS((PortalBuffer *portal));
extern int pbuf_getIndex ARGS((char *pname));
extern PortalEntry *pbuf_setup ARGS((char *pname));
extern void pbuf_close ARGS((char *pname));
extern GroupBuffer *pbuf_findGroup ARGS((PortalBuffer *portal, int group_index));
extern pbuf_findFnumber ARGS((GroupBuffer *group, char *field_name));
extern void pbuf_checkFnumber ARGS((GroupBuffer *group, int field_number));
extern char *pbuf_findFname ARGS((GroupBuffer *group, int field_number));
extern void pq_init ARGS((int fd));
extern void pq_gettty ARGS((int tp));
extern int pq_getport ARGS(());
extern void pq_close ARGS(());
extern void pq_flush ARGS(());
extern int pq_getstr ARGS((char *s, int maxlen));
extern int pq_getnchar ARGS((char *s, int off, int maxlen));
extern int pq_getint ARGS((int b));
extern void pq_putstr ARGS((char *s));
extern void pq_putnchar ARGS((char *s, int n));
extern void pq_putint ARGS((int i, int b));
extern int pq_getinaddr ARGS((struct sockaddr_in *sin, char *host, int port));
extern int pq_getinserv ARGS((struct sockaddr_in *sin, char *host, char *serv));
int pq_connect ARGS((char *dbname , char *user , char *args , char *hostName , char *debugTty , char *execFile , int portName ));
extern int pq_accept ARGS(());
    
#endif LibpqIncluded
@


1.23
log
@checking in changes made by case that i erroneously backed out.
case's messages were:
add attribute length info to tupleblock structure, prototypes,
more proto
@
text
@d15 1
a15 1
 *	$Header: /private/mao/postgres/src/lib/H/tmp/RCS/libpq.h,v 1.25 1992/07/15 02:03:44 clarsen Exp $
d209 1
a209 1
extern void pq_getstr ARGS((char *s, int maxlen));
@


1.22
log
@pq_getnchar
@
text
@d15 1
a15 1
 *	$Header: /private/clarsen/postgres/src/lib/H/tmp/RCS/libpq.h,v 1.21 1992/04/21 13:16:10 clarsen Exp clarsen $
d65 2
d174 1
d190 1
@


1.21
log
@make PQerrormsg available
@
text
@d15 1
a15 1
 *	$Header: RCS/libpq.h,v 1.20 92/04/03 16:30:44 clarsen Exp Locker: clarsen $
d206 1
a206 1
extern void pq_getnchar ARGS((char *s, int off, int maxlen));
@


1.20
log
@include simplelists.h in libpq.h
@
text
@d15 1
a15 1
 *	$Header: RCS/libpq.h,v 1.19 92/02/25 15:28:33 clarsen Exp Locker: clarsen $
d144 1
@


1.19
log
@async portals.
@
text
@d15 1
a15 1
 *	$Header: RCS/libpq.h,v 1.18 91/11/13 08:47:08 clarsen Exp Locker: clarsen $
d25 1
@


1.18
log
@
prototypes
@
text
@d15 1
a15 1
 *	$Header: RCS/libpq.h,v 1.17 91/11/07 22:12:47 mer Exp Locker: clarsen $
d115 10
d171 6
@


1.17
log
@fix prototype syntax error
@
text
@d15 1
a15 1
 *	$Header: /users/mer/postgres/src/lib/H/tmp/RCS/libpq.h,v 1.16 1991/03/21 21:17:35 kemnitz Exp mer $
d118 2
a119 1
#define libpq_raise(X, Y) ExcRaise((X), (Y))
d141 1
a141 1
extern void PQpnames ARGS((int pnames, int rule_p));
d195 1
a195 1
extern int pq_connect ARGS((char *host, char *port));
@


1.16
log
@error messages in the backend can be 4K long - they are here now as well.
@
text
@d15 1
a15 1
 *	$Header: RCS/libpq.h,v 1.15 91/02/26 19:27:12 cimarron Exp Locker: kemnitz $
d171 1
a171 1
extern void pbuf_freeTuples ARGS((int no_ tuples, int no_tuples, int no_fields));
@


1.15
log
@libpq changes for PQfn and renaming pg_relation to pg_class in catalogs
@
text
@d15 1
a15 1
 *	$Header: RCS/libpq.h,v 1.14 91/02/23 23:40:48 cimarron Exp $
d127 1
a127 1
#define error_msg_length 80
@


1.14
log
@PQexec() now works correctly in the backend
@
text
@d15 1
a15 1
 *	$Header: RCS/libpq.h,v 1.13 91/02/20 00:30:56 cimarron Exp $
d144 1
d147 1
@


1.13
log
@changed declarations to reflect new fe/be portal routines
@
text
@d15 1
a15 1
 *	$Header$
d27 1
a27 1
/*
d31 1
a32 1

d42 1
a42 1
/* 
d45 1
d55 1
a55 1
/*
d58 1
d68 1
a68 1
/*
d71 1
d81 1
a81 1
/* 
d84 1
d93 7
a99 2
/*
 * Define global variables used by LIBPQ.
d101 1
d104 4
a107 2
    char name[NameLength];
    PortalBuffer *portal;
@


1.12
log
@reorganization of libpq routines to provide
 PQexec and PQfn functionality from both the front
 end applications and the postgres backend.
@
text
@d1 16
a16 25
/* 
 * POSTGRES Data Base Management System
 * 
 * Copyright (c) 1989 Regents of the University of California
 * 
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for educational, research, and non-profit purposes and
 * without fee is hereby granted, provided that the above copyright
 * notice appear in all copies and that both that copyright notice and
 * this permission notice appear in supporting documentation, and that
 * the name of the University of California not be used in advertising
 * or publicity pertaining to distribution of the software without
 * specific, written prior permission.  Permission to incorporate this
 * software into commercial products can be obtained from the Campus
 * Software Office, 295 Evans Hall, University of California, Berkeley,
 * Ca., 94720.  The University of California makes no representations
 * about the suitability of this software for any purpose.  It is
 * provided "as is" without express or implied warranty.
 */ 
/*
 * libpq.h -- 
 *	POSTGRES frontend LIBPQ buffer structure definitions.
 *
 * Identification:
 *	$Header: RCS/libpq.h,v 1.11 91/01/12 17:56:05 mao Exp Locker: cimarron $
d24 1
d63 1
d123 4
a126 11
extern PortalBuffer *addPortal ARGS((void));
extern GroupBuffer *addGroup ARGS((PortalBuffer *portal));
extern TypeBlock *addTypes ARGS((int n));
extern TupleBlock *addTuples ARGS((void));
extern char **addTuple ARGS((int n));
extern char *addValues ARGS((int n));
extern PortalEntry *addPortalEntry ARGS((void));
extern void freePortalEntry ARGS((int i));
extern void freePortal ARGS((PortalBuffer *portal));
extern PortalBuffer *portal_setup ARGS((char *pname));
extern void portal_close ARGS((char *pname));
d128 1
a128 1
extern void PQpnames ARGS((char **pnames, int rule_p));
d137 2
a138 1
extern int PQftypeGroup ();
a143 1
extern int PQgetgroup ARGS((PortalBuffer *portal, int tuple_index));
d145 39
a183 50
extern void PQerror ();

extern char *PQdb ARGS((void));
extern void PQsetdb ARGS((char *dbname));
extern void PQreset ARGS((void));
extern void PQfinish ARGS((void));
extern void PQtrace ARGS((void));
extern void PQuntrace ARGS((void));
extern void pqdebug ARGS((char *target, char *msg));
extern void pqdebug2 ARGS((char *target, char *msg1, char *msg2));
extern void read_initstr ARGS((void));
extern char *process_portal ARGS((int rule_p));
extern void read_remark ARGS((char id[]));
extern char *PQfn ARGS((int fnid, void *result_buf, int result_len, int result_is_int, PQArgBlock *args, int nargs));
extern char *PQexec ARGS((char *query));
extern void InitVacuumDemon ARGS((String host, String database, String terminal, String option, String port, String vacuum));


/*
 *The following internal variables of libqp can be accessed by the programmer:
 */
extern
char    *PQhost;                /* the machine on which POSTGRES backend
                                   is running */
extern
char    *PQport;         	/* the communication port with the
                                   POSTGRES backend */
extern
char    *PQtty;                 /* the tty on PQhost backend message
                                   is displayed */
extern
char    *PQoption;              /* the optional arguments to POSTGRES
                                   backend */
extern
char    *PQdatabase;            /* the POSTGRES database to access */

extern
int     PQportset;          	/* 1 if the communication with backend
                                   is set */
extern
int     PQxactid ;           	/* the transaction id of the current
                                   transaction */
extern
char    *PQinitstr;      	/* the initialization string passed
                                   to backend */
extern
int     PQtracep;           	/* 1 to print out debugging message */


#endif	/* ifndef LibpqIncluded */
@


1.11
log
@remove duplicate def of portal_name_length
@
text
@d25 1
a25 1
 *	$Header: RCS/libpq.h,v 1.10 90/08/23 20:15:20 cimarron Exp Locker: mao $
d167 2
a168 2
extern pqdebug ARGS((char *target, char *msg));
extern pqdebug2 ARGS((char *target, char *msg1, char *msg2));
d171 1
a171 1
extern read_remark ARGS((char id[]));
@


1.10
log
@version of libpq.h from Igor Metz
@
text
@d25 1
a25 1
 *	$Header: RCS/libpq.h,v 1.7 90/07/12 14:57:46 kemnitz Exp $
a122 1
#define portal_name_length 16
@


1.9
log
@on line 155, "int n args" corrected to "PQArgBlock *args".
@
text
@d1 19
d25 1
a25 1
 *	$Header: RCS/libpq.h,v 1.8 90/08/17 08:54:41 cimarron Exp Locker: choi $
a32 1

d131 21
a151 21
extern PortalBuffer *addPortal ();
extern GroupBuffer *addGroup ();
extern TypeBlock *addTypes ();
extern TupleBlock *addTuples ();
extern char **addTuple ();
extern char *addValues ();
extern PortalEntry *addPortalEntry ();
extern void freePortalEntry ();
extern void freePortal ();
extern PortalBuffer *portal_setup ();
extern void portal_close ();
extern int PQnportals ();
extern void PQpnames ();
extern PortalBuffer *PQparray ();
extern int PQrulep ();
extern int PQntuples ();
extern int PQngroups ();
extern int PQntuplesGroup ();
extern int PQnfieldsGroup ();
extern int PQfnumberGroup ();
extern char *PQfnameGroup ();
d153 7
a159 7
extern int PQnfields ();
extern int PQfnumber ();
extern char *PQfname ();
extern int PQftype ();
extern int PQsametype ();
extern int PQgetgroup ();
extern char *PQgetvalue ();
d176 31
@


1.8
log
@added pathnames to #include statements
@
text
@d6 1
a6 1
 *	$Header: RCS/libpq.h,v 1.7 90/07/12 14:57:46 kemnitz Version_2 Locker: cimarron $
d155 1
a155 1
extern char *PQfn ARGS((int fnid, void *result_buf, int result_len, int result_is_int, int n args, int nargs));
@


1.7
log
@Changed macro libpq_raise to use the right ExcRaise.
@
text
@d6 1
a6 1
 *	$Header: RCS/libpq.h,v 1.6 89/09/05 17:15:54 mao C_Demo_1 Locker: kemnitz $
d14 2
a15 1
#include "exc.h"
@


1.6
log
@Working version of C-only demo
@
text
@d6 1
a6 1
 *	$Header: RCS/libpq.h,v 1.5 89/08/31 20:29:13 dillon Exp $
d94 1
a94 1
#define libpq_raise(X, Y)	raise4((X), 0, NULL, (Y))
@


1.5
log
@dec compiler barfs on void *
@
text
@d6 1
a6 1
 *	$Header: RCS/libpq.h,v 1.4 89/08/30 18:59:38 ong Exp Locker: dillon $
@


1.4
log
@fixed to work with C backend.
@
text
@d6 1
a6 1
 *	$Header: /n/postgres/a/postgres/ong/postgres/src/lib/libpq/RCS/libpq.h,v 1.3 89/03/22 17:35:27 muir Stab $
d26 1
a26 1
        void *ptr;
@


1.3
log
@copyright removal
@
text
@d6 1
a6 1
 *	$Header: /usr6/postgres/muir/postgres/src/lib/libpq/RCS/libpq.h,v 1.2 89/03/01 17:46:20 dillon Exp $
d14 1
a15 2
#include "exception.h"

a140 6
extern char *PQdb ();
extern void PQsetdb ();
extern void PQreset ();
extern void PQfinish ();
extern void PQtrace ();
extern void PQuntrace ();
d142 16
a157 1
extern char *PQexec ();
@


1.2
log
@Add structures and extern for PQfn()
@
text
@a0 27

; /*
; * 
; * POSTGRES Data Base Management System
; * 
; * Copyright (c) 1988 Regents of the University of California
; * 
; * Permission to use, copy, modify, and distribute this software and its
; * documentation for educational, research, and non-profit purposes and
; * without fee is hereby granted, provided that the above copyright
; * notice appear in all copies and that both that copyright notice and
; * this permission notice appear in supporting documentation, and that
; * the name of the University of California not be used in advertising
; * or publicity pertaining to distribution of the software without
; * specific, written prior permission.  Permission to incorporate this
; * software into commercial products can be obtained from the Campus
; * Software Office, 295 Evans Hall, University of California, Berkeley,
; * Ca., 94720 provided only that the the requestor give the University
; * of California a free licence to any derived software for educational
; * and research purposes.  The University of California makes no
; * representations about the suitability of this software for any
; * purpose.  It is provided "as is" without express or implied warranty.
; * 
; */



d6 1
a6 1
 *	$Header: libpq.h,v 1.1 89/01/17 05:55:17 dillon Locked $
@


1.1
log
@Initial revision
@
text
@d33 1
a33 1
 *	$Header: libpq.h,v 1.1 88/11/11 16:37:51 postgres Exp $
d43 15
@
