1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-08 00:47:37 +03:00
Files
postgres/src/interfaces/libpgtcl/pgtclCmds.h
Bruce Momjian 4b048fbfaa This patch covers several to-do items that I had for libpgtcl:
* It works under both Tcl 7.6 and Tcl 8.0 now.  (The code claims to
  work under Tcl 7.5 as well, but I have no way to test that ---
  if anyone still cares, please check it with 7.5.)

* pg_listen suppresses extra LISTEN commands and correctly sends an
  UNLISTEN when the last listen request for a relation is cancelled.
  (Note this means it will not work with pre-6.4 backends, but that
  was true already because it depends on the current libpq, which
  only speaks protocol 2.0.)

* Added -error option to pg_result so that there's some way to find
  out what you did wrong ;-)

* Miscellaneous cleanups of code comments and overenthusiastic #includes.

BTW, I bumped the package version number from 1.2 to 1.3.  Is this
premature?  Does someone run around and do that routinely before
each pgsql release?

			regards, tom lane
1998-09-21 01:02:04 +00:00

105 lines
3.7 KiB
C

/*-------------------------------------------------------------------------
*
* pgtclCmds.h--
* declarations for the C functions which implement pg_* tcl commands
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pgtclCmds.h,v 1.12 1998/09/21 01:02:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef PGTCLCMDS_H
#define PGTCLCMDS_H
#include "tcl.h"
#include "libpq-fe.h"
#define RES_HARD_MAX 128
#define RES_START 16
/*
* Each Pg_ConnectionId has a list of Pg_TclNotifies structs, one for each
* Tcl interpreter that has executed any pg_listens on the connection.
* We need this arrangement to be able to clean up if an interpreter is
* deleted while the connection remains open. A free side benefit is that
* multiple interpreters can be registered to listen for the same notify
* name. (All their callbacks will be called, but in an unspecified order.)
*/
typedef struct Pg_TclNotifies_s
{
struct Pg_TclNotifies_s *next; /* list link */
Tcl_Interp *interp; /* This Tcl interpreter */
/*
* NB: if interp == NULL, the interpreter is gone but we haven't yet
* got round to deleting the Pg_TclNotifies structure.
*/
Tcl_HashTable notify_hash; /* Active pg_listen requests */
} Pg_TclNotifies;
typedef struct Pg_ConnectionId_s
{
char id[32];
PGconn *conn;
int res_max; /* Max number of results allocated */
int res_hardmax; /* Absolute max to allow */
int res_count; /* Current count of active results */
int res_last; /* Optimize where to start looking */
int res_copy; /* Query result with active copy */
int res_copyStatus; /* Copying status */
PGresult **results; /* The results */
Pg_TclNotifies *notify_list;/* head of list of notify info */
int notifier_running; /* notify event source is live */
int notifier_socket; /* PQsocket on which notifier is listening */
} Pg_ConnectionId;
/* Values of res_copyStatus */
#define RES_COPY_NONE 0
#define RES_COPY_INPROGRESS 1
#define RES_COPY_FIN 2
/* **************************/
/* registered Tcl functions */
/* **************************/
extern int Pg_conndefaults(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_connect(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_disconnect(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_exec(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_select(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_result(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_lo_open(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_lo_close(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_lo_read(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_lo_write(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_lo_lseek(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_lo_creat(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_lo_tell(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_lo_unlink(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_lo_import(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_lo_export(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
extern int Pg_listen(
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
#endif /* PGTCLCMDS_H */