mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Massive commit to run PGINDENT on all *.c and *.h files.
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* libpgtcl.h--
|
||||
* libpgtcl is a tcl package for front-ends to interface with pglite
|
||||
* It's the tcl equivalent of the old libpq C interface.
|
||||
* libpgtcl is a tcl package for front-ends to interface with pglite
|
||||
* It's the tcl equivalent of the old libpq C interface.
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: libpgtcl.h,v 1.2 1996/10/30 06:18:37 scrappy Exp $
|
||||
* $Id: libpgtcl.h,v 1.3 1997/09/07 05:03:06 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
#include "tcl.h"
|
||||
|
||||
extern int Pgtcl_Init (Tcl_Interp *interp);
|
||||
extern int Pgtcl_SafeInit (Tcl_Interp *interp);
|
||||
extern int Pgtcl_Init(Tcl_Interp * interp);
|
||||
extern int Pgtcl_SafeInit(Tcl_Interp * interp);
|
||||
|
||||
#endif /* LIBPGTCL_H */
|
||||
#endif /* LIBPGTCL_H */
|
||||
|
@ -1,15 +1,15 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* pgtcl.c--
|
||||
*
|
||||
* libpgtcl is a tcl package for front-ends to interface with pglite
|
||||
* It's the tcl equivalent of the old libpq C interface.
|
||||
*
|
||||
* libpgtcl is a tcl package for front-ends to interface with pglite
|
||||
* It's the tcl equivalent of the old libpq C interface.
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.7 1997/01/03 18:48:28 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.8 1997/09/07 05:03:09 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -23,8 +23,8 @@
|
||||
#include "pgtclId.h"
|
||||
|
||||
/*
|
||||
* Pgtcl_Init
|
||||
* initialization package for the PGLITE Tcl package
|
||||
* Pgtcl_Init
|
||||
* initialization package for the PGLITE Tcl package
|
||||
*
|
||||
*/
|
||||
|
||||
@ -32,153 +32,154 @@
|
||||
* Tidy up forgotten postgres connection at Tcl_Exit
|
||||
*/
|
||||
static void
|
||||
Pgtcl_AtExit (ClientData cData)
|
||||
Pgtcl_AtExit(ClientData cData)
|
||||
{
|
||||
Pg_clientData *cd = (Pg_clientData *)cData;
|
||||
Tcl_HashEntry *hent;
|
||||
Tcl_HashSearch hsearch;
|
||||
Pg_ConnectionId *connid;
|
||||
PGconn *conn;
|
||||
Pg_clientData *cd = (Pg_clientData *) cData;
|
||||
Tcl_HashEntry *hent;
|
||||
Tcl_HashSearch hsearch;
|
||||
Pg_ConnectionId *connid;
|
||||
PGconn *conn;
|
||||
|
||||
while((hent = Tcl_FirstHashEntry(&(cd->dbh_hash), &hsearch)) != NULL) {
|
||||
connid = (Pg_ConnectionId *)Tcl_GetHashValue(hent);
|
||||
conn = connid->conn;
|
||||
PgDelConnectionId(cd, connid->id);
|
||||
PQfinish(conn);
|
||||
}
|
||||
while ((hent = Tcl_FirstHashEntry(&(cd->dbh_hash), &hsearch)) != NULL)
|
||||
{
|
||||
connid = (Pg_ConnectionId *) Tcl_GetHashValue(hent);
|
||||
conn = connid->conn;
|
||||
PgDelConnectionId(cd, connid->id);
|
||||
PQfinish(conn);
|
||||
}
|
||||
|
||||
Tcl_DeleteHashTable(&(cd->dbh_hash));
|
||||
Tcl_DeleteHashTable(&(cd->res_hash));
|
||||
Tcl_DeleteHashTable(&(cd->notify_hash));
|
||||
Tcl_DeleteHashTable(&(cd->dbh_hash));
|
||||
Tcl_DeleteHashTable(&(cd->res_hash));
|
||||
Tcl_DeleteHashTable(&(cd->notify_hash));
|
||||
|
||||
Tcl_DeleteExitHandler(Pgtcl_AtExit, cData);
|
||||
Tcl_DeleteExitHandler(Pgtcl_AtExit, cData);
|
||||
}
|
||||
|
||||
/*
|
||||
* Tidy up forgotten postgres connections on Interpreter deletion
|
||||
*/
|
||||
static void
|
||||
Pgtcl_Shutdown (ClientData cData, Tcl_Interp *interp)
|
||||
Pgtcl_Shutdown(ClientData cData, Tcl_Interp * interp)
|
||||
{
|
||||
Pgtcl_AtExit(cData);
|
||||
Pgtcl_AtExit(cData);
|
||||
}
|
||||
|
||||
int
|
||||
Pgtcl_Init (Tcl_Interp *interp)
|
||||
Pgtcl_Init(Tcl_Interp * interp)
|
||||
{
|
||||
Pg_clientData *cd;
|
||||
Pg_clientData *cd;
|
||||
|
||||
/* Create and initialize the client data area */
|
||||
cd = (Pg_clientData *)ckalloc(sizeof(Pg_clientData));
|
||||
Tcl_InitHashTable(&(cd->dbh_hash), TCL_STRING_KEYS);
|
||||
Tcl_InitHashTable(&(cd->res_hash), TCL_STRING_KEYS);
|
||||
Tcl_InitHashTable(&(cd->notify_hash), TCL_STRING_KEYS);
|
||||
cd->dbh_count = 0L;
|
||||
cd->res_count = 0L;
|
||||
/* Create and initialize the client data area */
|
||||
cd = (Pg_clientData *) ckalloc(sizeof(Pg_clientData));
|
||||
Tcl_InitHashTable(&(cd->dbh_hash), TCL_STRING_KEYS);
|
||||
Tcl_InitHashTable(&(cd->res_hash), TCL_STRING_KEYS);
|
||||
Tcl_InitHashTable(&(cd->notify_hash), TCL_STRING_KEYS);
|
||||
cd->dbh_count = 0L;
|
||||
cd->res_count = 0L;
|
||||
|
||||
/* Arrange for tidy up when interpreter is deleted or Tcl exits */
|
||||
Tcl_CallWhenDeleted(interp, Pgtcl_Shutdown, (ClientData)cd);
|
||||
Tcl_CreateExitHandler(Pgtcl_AtExit, (ClientData)cd);
|
||||
/* Arrange for tidy up when interpreter is deleted or Tcl exits */
|
||||
Tcl_CallWhenDeleted(interp, Pgtcl_Shutdown, (ClientData) cd);
|
||||
Tcl_CreateExitHandler(Pgtcl_AtExit, (ClientData) cd);
|
||||
|
||||
/* register all pgtcl commands */
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_conndefaults",
|
||||
Pg_conndefaults,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
/* register all pgtcl commands */
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_conndefaults",
|
||||
Pg_conndefaults,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_connect",
|
||||
Pg_connect,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_connect",
|
||||
Pg_connect,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_disconnect",
|
||||
Pg_disconnect,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_exec",
|
||||
Pg_exec,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_select",
|
||||
Pg_select,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_result",
|
||||
Pg_result,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_open",
|
||||
Pg_lo_open,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_close",
|
||||
Pg_lo_close,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_disconnect",
|
||||
Pg_disconnect,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_read",
|
||||
Pg_lo_read,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_exec",
|
||||
Pg_exec,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_write",
|
||||
Pg_lo_write,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_select",
|
||||
Pg_select,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_lseek",
|
||||
Pg_lo_lseek,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_result",
|
||||
Pg_result,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_creat",
|
||||
Pg_lo_creat,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_open",
|
||||
Pg_lo_open,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_tell",
|
||||
Pg_lo_tell,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_close",
|
||||
Pg_lo_close,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_unlink",
|
||||
Pg_lo_unlink,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_read",
|
||||
Pg_lo_read,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_import",
|
||||
Pg_lo_import,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_export",
|
||||
Pg_lo_export,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_listen",
|
||||
Pg_listen,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_write",
|
||||
Pg_lo_write,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_notifies",
|
||||
Pg_notifies,
|
||||
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_lseek",
|
||||
Pg_lo_lseek,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_PkgProvide(interp, "Pgtcl", "1.0");
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_creat",
|
||||
Pg_lo_creat,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
return TCL_OK;
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_tell",
|
||||
Pg_lo_tell,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_unlink",
|
||||
Pg_lo_unlink,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_import",
|
||||
Pg_lo_import,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_lo_export",
|
||||
Pg_lo_export,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_listen",
|
||||
Pg_listen,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_CreateCommand(interp,
|
||||
"pg_notifies",
|
||||
Pg_notifies,
|
||||
(ClientData) cd, (Tcl_CmdDeleteProc *) NULL);
|
||||
|
||||
Tcl_PkgProvide(interp, "Pgtcl", "1.0");
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Pgtcl_SafeInit (Tcl_Interp *interp)
|
||||
Pgtcl_SafeInit(Tcl_Interp * interp)
|
||||
{
|
||||
return Pgtcl_Init(interp);
|
||||
return Pgtcl_Init(interp);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,11 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* pgtclCmds.h--
|
||||
* declarations for the C functions which implement pg_* tcl commands
|
||||
* declarations for the C functions which implement pg_* tcl commands
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pgtclCmds.h,v 1.6 1997/01/03 18:48:31 scrappy Exp $
|
||||
* $Id: pgtclCmds.h,v 1.7 1997/09/07 05:03:12 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -18,69 +18,89 @@
|
||||
#include "libpq-fe.h"
|
||||
#include "libpq/libpq-fs.h"
|
||||
|
||||
typedef struct Pg_clientData_s {
|
||||
Tcl_HashTable dbh_hash;
|
||||
Tcl_HashTable res_hash;
|
||||
Tcl_HashTable notify_hash;
|
||||
long dbh_count;
|
||||
long res_count;
|
||||
} Pg_clientData;
|
||||
typedef struct Pg_clientData_s
|
||||
{
|
||||
Tcl_HashTable dbh_hash;
|
||||
Tcl_HashTable res_hash;
|
||||
Tcl_HashTable notify_hash;
|
||||
long dbh_count;
|
||||
long res_count;
|
||||
} Pg_clientData;
|
||||
|
||||
|
||||
typedef struct Pg_ConnectionId_s {
|
||||
char id[32];
|
||||
PGconn *conn;
|
||||
Tcl_HashTable res_hash;
|
||||
} Pg_ConnectionId;
|
||||
typedef struct Pg_ConnectionId_s
|
||||
{
|
||||
char id[32];
|
||||
PGconn *conn;
|
||||
Tcl_HashTable res_hash;
|
||||
} Pg_ConnectionId;
|
||||
|
||||
|
||||
typedef struct Pg_ResultId_s {
|
||||
char id[32];
|
||||
PGresult *result;
|
||||
Pg_ConnectionId *connection;
|
||||
} Pg_ResultId;
|
||||
typedef struct Pg_ResultId_s
|
||||
{
|
||||
char id[32];
|
||||
PGresult *result;
|
||||
Pg_ConnectionId *connection;
|
||||
} Pg_ResultId;
|
||||
|
||||
|
||||
/* **************************/
|
||||
/* 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[]);
|
||||
extern int Pg_notifies(
|
||||
ClientData cData, Tcl_Interp *interp, int argc, char* argv[]);
|
||||
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[]);
|
||||
extern int
|
||||
Pg_notifies(
|
||||
ClientData cData, Tcl_Interp * interp, int argc, char *argv[]);
|
||||
|
||||
|
||||
#endif /*PGTCLCMDS_H*/
|
||||
|
||||
#endif /* PGTCLCMDS_H */
|
||||
|
@ -1,18 +1,18 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* pgtclId.c--
|
||||
* useful routines to convert between strings and pointers
|
||||
* Needed because everything in tcl is a string, but we want pointers
|
||||
* to data structures
|
||||
* useful routines to convert between strings and pointers
|
||||
* Needed because everything in tcl is a string, but we want pointers
|
||||
* to data structures
|
||||
*
|
||||
* ASSUMPTION: sizeof(long) >= sizeof(void*)
|
||||
* ASSUMPTION: sizeof(long) >= sizeof(void*)
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.3 1996/11/11 12:14:45 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.4 1997/09/07 05:03:13 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -29,39 +29,40 @@
|
||||
* Create the Id for a new connection and hash it
|
||||
*/
|
||||
void
|
||||
PgSetConnectionId(Pg_clientData *cd, char *id, PGconn *conn)
|
||||
PgSetConnectionId(Pg_clientData * cd, char *id, PGconn * conn)
|
||||
{
|
||||
Tcl_HashEntry *hent;
|
||||
Pg_ConnectionId *connid;
|
||||
int hnew;
|
||||
Tcl_HashEntry *hent;
|
||||
Pg_ConnectionId *connid;
|
||||
int hnew;
|
||||
|
||||
connid = (Pg_ConnectionId *)ckalloc(sizeof(Pg_ConnectionId));
|
||||
connid->conn = conn;
|
||||
Tcl_InitHashTable(&(connid->res_hash), TCL_STRING_KEYS);
|
||||
sprintf(connid->id, "pgc%ld", cd->dbh_count++);
|
||||
strcpy(id, connid->id);
|
||||
connid = (Pg_ConnectionId *) ckalloc(sizeof(Pg_ConnectionId));
|
||||
connid->conn = conn;
|
||||
Tcl_InitHashTable(&(connid->res_hash), TCL_STRING_KEYS);
|
||||
sprintf(connid->id, "pgc%ld", cd->dbh_count++);
|
||||
strcpy(id, connid->id);
|
||||
|
||||
hent = Tcl_CreateHashEntry(&(cd->dbh_hash), connid->id, &hnew);
|
||||
Tcl_SetHashValue(hent, (ClientData)connid);
|
||||
hent = Tcl_CreateHashEntry(&(cd->dbh_hash), connid->id, &hnew);
|
||||
Tcl_SetHashValue(hent, (ClientData) connid);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get back the connection from the Id
|
||||
*/
|
||||
PGconn *
|
||||
PgGetConnectionId(Pg_clientData *cd, char *id)
|
||||
PGconn *
|
||||
PgGetConnectionId(Pg_clientData * cd, char *id)
|
||||
{
|
||||
Tcl_HashEntry *hent;
|
||||
Pg_ConnectionId *connid;
|
||||
Tcl_HashEntry *hent;
|
||||
Pg_ConnectionId *connid;
|
||||
|
||||
hent = Tcl_FindHashEntry(&(cd->dbh_hash), id);
|
||||
if(hent == NULL) {
|
||||
return (PGconn *)NULL;
|
||||
}
|
||||
hent = Tcl_FindHashEntry(&(cd->dbh_hash), id);
|
||||
if (hent == NULL)
|
||||
{
|
||||
return (PGconn *) NULL;
|
||||
}
|
||||
|
||||
connid = (Pg_ConnectionId *)Tcl_GetHashValue(hent);
|
||||
return connid->conn;
|
||||
connid = (Pg_ConnectionId *) Tcl_GetHashValue(hent);
|
||||
return connid->conn;
|
||||
}
|
||||
|
||||
|
||||
@ -70,36 +71,39 @@ PgGetConnectionId(Pg_clientData *cd, char *id)
|
||||
* close all portals the user forgot.
|
||||
*/
|
||||
void
|
||||
PgDelConnectionId(Pg_clientData *cd, char *id)
|
||||
PgDelConnectionId(Pg_clientData * cd, char *id)
|
||||
{
|
||||
Tcl_HashEntry *hent;
|
||||
Tcl_HashEntry *hent2;
|
||||
Tcl_HashEntry *hent3;
|
||||
Tcl_HashSearch hsearch;
|
||||
Pg_ConnectionId *connid;
|
||||
Pg_ResultId *resid;
|
||||
Tcl_HashEntry *hent;
|
||||
Tcl_HashEntry *hent2;
|
||||
Tcl_HashEntry *hent3;
|
||||
Tcl_HashSearch hsearch;
|
||||
Pg_ConnectionId *connid;
|
||||
Pg_ResultId *resid;
|
||||
|
||||
hent = Tcl_FindHashEntry(&(cd->dbh_hash), id);
|
||||
if(hent == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
connid = (Pg_ConnectionId *)Tcl_GetHashValue(hent);
|
||||
|
||||
hent2 = Tcl_FirstHashEntry(&(connid->res_hash), &hsearch);
|
||||
while(hent2 != NULL) {
|
||||
resid = (Pg_ResultId *)Tcl_GetHashValue(hent2);
|
||||
PQclear(resid->result);
|
||||
hent3 = Tcl_FindHashEntry(&(cd->res_hash), resid->id);
|
||||
if(hent3 != NULL) {
|
||||
Tcl_DeleteHashEntry(hent3);
|
||||
hent = Tcl_FindHashEntry(&(cd->dbh_hash), id);
|
||||
if (hent == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ckfree(resid);
|
||||
hent2 = Tcl_NextHashEntry(&hsearch);
|
||||
}
|
||||
Tcl_DeleteHashTable(&(connid->res_hash));
|
||||
Tcl_DeleteHashEntry(hent);
|
||||
ckfree(connid);
|
||||
|
||||
connid = (Pg_ConnectionId *) Tcl_GetHashValue(hent);
|
||||
|
||||
hent2 = Tcl_FirstHashEntry(&(connid->res_hash), &hsearch);
|
||||
while (hent2 != NULL)
|
||||
{
|
||||
resid = (Pg_ResultId *) Tcl_GetHashValue(hent2);
|
||||
PQclear(resid->result);
|
||||
hent3 = Tcl_FindHashEntry(&(cd->res_hash), resid->id);
|
||||
if (hent3 != NULL)
|
||||
{
|
||||
Tcl_DeleteHashEntry(hent3);
|
||||
}
|
||||
ckfree(resid);
|
||||
hent2 = Tcl_NextHashEntry(&hsearch);
|
||||
}
|
||||
Tcl_DeleteHashTable(&(connid->res_hash));
|
||||
Tcl_DeleteHashEntry(hent);
|
||||
ckfree(connid);
|
||||
}
|
||||
|
||||
|
||||
@ -107,52 +111,57 @@ PgDelConnectionId(Pg_clientData *cd, char *id)
|
||||
* Create a new result Id and hash it
|
||||
*/
|
||||
void
|
||||
PgSetResultId(Pg_clientData *cd, char *id, char *connid_c, PGresult *res)
|
||||
PgSetResultId(Pg_clientData * cd, char *id, char *connid_c, PGresult * res)
|
||||
{
|
||||
Tcl_HashEntry *hent;
|
||||
Pg_ConnectionId *connid;
|
||||
Pg_ResultId *resid;
|
||||
int hnew;
|
||||
Tcl_HashEntry *hent;
|
||||
Pg_ConnectionId *connid;
|
||||
Pg_ResultId *resid;
|
||||
int hnew;
|
||||
|
||||
hent = Tcl_FindHashEntry(&(cd->dbh_hash), connid_c);
|
||||
if(hent == NULL) {
|
||||
connid = NULL;
|
||||
} else {
|
||||
connid = (Pg_ConnectionId *)Tcl_GetHashValue(hent);
|
||||
}
|
||||
hent = Tcl_FindHashEntry(&(cd->dbh_hash), connid_c);
|
||||
if (hent == NULL)
|
||||
{
|
||||
connid = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
connid = (Pg_ConnectionId *) Tcl_GetHashValue(hent);
|
||||
}
|
||||
|
||||
resid = (Pg_ResultId *)ckalloc(sizeof(Pg_ResultId));
|
||||
resid->result = res;
|
||||
resid->connection = connid;
|
||||
sprintf(resid->id, "pgr%ld", cd->res_count++);
|
||||
strcpy(id, resid->id);
|
||||
resid = (Pg_ResultId *) ckalloc(sizeof(Pg_ResultId));
|
||||
resid->result = res;
|
||||
resid->connection = connid;
|
||||
sprintf(resid->id, "pgr%ld", cd->res_count++);
|
||||
strcpy(id, resid->id);
|
||||
|
||||
hent = Tcl_CreateHashEntry(&(cd->res_hash), resid->id, &hnew);
|
||||
Tcl_SetHashValue(hent, (ClientData)resid);
|
||||
hent = Tcl_CreateHashEntry(&(cd->res_hash), resid->id, &hnew);
|
||||
Tcl_SetHashValue(hent, (ClientData) resid);
|
||||
|
||||
if(connid != NULL) {
|
||||
hent = Tcl_CreateHashEntry(&(connid->res_hash), resid->id, &hnew);
|
||||
Tcl_SetHashValue(hent, (ClientData)resid);
|
||||
}
|
||||
if (connid != NULL)
|
||||
{
|
||||
hent = Tcl_CreateHashEntry(&(connid->res_hash), resid->id, &hnew);
|
||||
Tcl_SetHashValue(hent, (ClientData) resid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get back the result pointer from the Id
|
||||
*/
|
||||
PGresult *
|
||||
PgGetResultId(Pg_clientData *cd, char *id)
|
||||
PGresult *
|
||||
PgGetResultId(Pg_clientData * cd, char *id)
|
||||
{
|
||||
Tcl_HashEntry *hent;
|
||||
Pg_ResultId *resid;
|
||||
Tcl_HashEntry *hent;
|
||||
Pg_ResultId *resid;
|
||||
|
||||
hent = Tcl_FindHashEntry(&(cd->res_hash), id);
|
||||
if(hent == NULL) {
|
||||
return (PGresult *)NULL;
|
||||
}
|
||||
hent = Tcl_FindHashEntry(&(cd->res_hash), id);
|
||||
if (hent == NULL)
|
||||
{
|
||||
return (PGresult *) NULL;
|
||||
}
|
||||
|
||||
resid = (Pg_ResultId *)Tcl_GetHashValue(hent);
|
||||
return resid->result;
|
||||
resid = (Pg_ResultId *) Tcl_GetHashValue(hent);
|
||||
return resid->result;
|
||||
}
|
||||
|
||||
|
||||
@ -160,27 +169,30 @@ PgGetResultId(Pg_clientData *cd, char *id)
|
||||
* Remove a result Id from the hash tables
|
||||
*/
|
||||
void
|
||||
PgDelResultId(Pg_clientData *cd, char *id)
|
||||
PgDelResultId(Pg_clientData * cd, char *id)
|
||||
{
|
||||
Tcl_HashEntry *hent;
|
||||
Tcl_HashEntry *hent2;
|
||||
Pg_ResultId *resid;
|
||||
Tcl_HashEntry *hent;
|
||||
Tcl_HashEntry *hent2;
|
||||
Pg_ResultId *resid;
|
||||
|
||||
hent = Tcl_FindHashEntry(&(cd->res_hash), id);
|
||||
if(hent == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
resid = (Pg_ResultId *)Tcl_GetHashValue(hent);
|
||||
if (resid->connection != NULL) {
|
||||
hent2 = Tcl_FindHashEntry(&(resid->connection->res_hash), id);
|
||||
if(hent2 != NULL) {
|
||||
Tcl_DeleteHashEntry(hent2);
|
||||
hent = Tcl_FindHashEntry(&(cd->res_hash), id);
|
||||
if (hent == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Tcl_DeleteHashEntry(hent);
|
||||
ckfree(resid);
|
||||
resid = (Pg_ResultId *) Tcl_GetHashValue(hent);
|
||||
if (resid->connection != NULL)
|
||||
{
|
||||
hent2 = Tcl_FindHashEntry(&(resid->connection->res_hash), id);
|
||||
if (hent2 != NULL)
|
||||
{
|
||||
Tcl_DeleteHashEntry(hent2);
|
||||
}
|
||||
}
|
||||
|
||||
Tcl_DeleteHashEntry(hent);
|
||||
ckfree(resid);
|
||||
}
|
||||
|
||||
|
||||
@ -188,20 +200,20 @@ PgDelResultId(Pg_clientData *cd, char *id)
|
||||
* Get the connection Id from the result Id
|
||||
*/
|
||||
void
|
||||
PgGetConnByResultId(Pg_clientData *cd, char *id, char *resid_c)
|
||||
PgGetConnByResultId(Pg_clientData * cd, char *id, char *resid_c)
|
||||
{
|
||||
Tcl_HashEntry *hent;
|
||||
Pg_ResultId *resid;
|
||||
Tcl_HashEntry *hent;
|
||||
Pg_ResultId *resid;
|
||||
|
||||
hent = Tcl_FindHashEntry(&(cd->res_hash), id);
|
||||
if(hent == NULL) {
|
||||
return;
|
||||
}
|
||||
hent = Tcl_FindHashEntry(&(cd->res_hash), id);
|
||||
if (hent == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resid = (Pg_ResultId *)Tcl_GetHashValue(hent);
|
||||
if (resid->connection != NULL) {
|
||||
strcpy(id, resid->connection->id);
|
||||
}
|
||||
resid = (Pg_ResultId *) Tcl_GetHashValue(hent);
|
||||
if (resid->connection != NULL)
|
||||
{
|
||||
strcpy(id, resid->connection->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* pgtclId.h--
|
||||
* useful routines to convert between strings and pointers
|
||||
* Needed because everything in tcl is a string, but often, pointers
|
||||
* to data structures are needed.
|
||||
*
|
||||
* useful routines to convert between strings and pointers
|
||||
* Needed because everything in tcl is a string, but often, pointers
|
||||
* to data structures are needed.
|
||||
*
|
||||
*
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: pgtclId.h,v 1.2 1996/10/30 06:18:42 scrappy Exp $
|
||||
* $Id: pgtclId.h,v 1.3 1997/09/07 05:03:14 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
extern void PgSetConnectionId(Pg_clientData *cd, char *id, PGconn *conn);
|
||||
extern PGconn *PgGetConnectionId(Pg_clientData *cd, char *id);
|
||||
extern void PgDelConnectionId(Pg_clientData *cd, char *id);
|
||||
extern void PgSetResultId(Pg_clientData *cd, char *id, char *connid, PGresult *res);
|
||||
extern PGresult *PgGetResultId(Pg_clientData *cd, char *id);
|
||||
extern void PgDelResultId(Pg_clientData *cd, char *id);
|
||||
extern void PgGetConnByResultId(Pg_clientData *cd, char *id, char *resid);
|
||||
extern void PgSetConnectionId(Pg_clientData * cd, char *id, PGconn * conn);
|
||||
extern PGconn *PgGetConnectionId(Pg_clientData * cd, char *id);
|
||||
extern void PgDelConnectionId(Pg_clientData * cd, char *id);
|
||||
extern void PgSetResultId(Pg_clientData * cd, char *id, char *connid, PGresult * res);
|
||||
extern PGresult *PgGetResultId(Pg_clientData * cd, char *id);
|
||||
extern void PgDelResultId(Pg_clientData * cd, char *id);
|
||||
extern void PgGetConnByResultId(Pg_clientData * cd, char *id, char *resid);
|
||||
|
Reference in New Issue
Block a user