1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-04 20:11:56 +03:00

Changes to libpgtcl submitted by: wieck@sapserv.debis.de (Jan Wieck)

Adds:

    -lAttributes

        Returns another format of the results attribute list. Per
        attribute a sublist  of  {{attname}  atttype  attlen}  is
        returned  and  an  empty  string  if  no attributes where
        received.

    -numAttrs

        Returns the number of attributes in the result.
This commit is contained in:
Marc G. Fournier
1996-10-30 06:18:42 +00:00
parent 582982e613
commit 552620c8b2
7 changed files with 369 additions and 120 deletions

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.2 1996/10/07 21:19:06 scrappy Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.3 1996/10/30 06:18:38 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,92 +19,145 @@
#include "pgtclCmds.h"
/*
* PG_Init
* Pgtcl_Init
* initialization package for the PGLITE Tcl package
*
*/
int
Pg_Init (Tcl_Interp *interp)
/*
* Tidy up forgotten postgres connection at Tcl_Exit
*/
void
Pgtcl_AtExit (ClientData cData)
{
/* register all pgtcl commands */
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);
}
Tcl_DeleteHashTable(&(cd->dbh_hash));
Tcl_DeleteHashTable(&(cd->res_hash));
Tcl_DeleteExitHandler(Pgtcl_AtExit, cData);
}
/*
* Tidy up forgotten postgres connections on Interpreter deletion
*/
void
Pgtcl_Shutdown (ClientData cData, Tcl_Interp *interp)
{
Pgtcl_AtExit(cData);
}
int
Pgtcl_Init (Tcl_Interp *interp)
{
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);
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);
/* register all pgtcl commands */
Tcl_CreateCommand(interp,
"pg_connect",
Pg_connect,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_disconnect",
Pg_disconnect,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_exec",
Pg_exec,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_select",
Pg_select,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_result",
Pg_result,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_lo_open",
Pg_lo_open,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_lo_close",
Pg_lo_close,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_lo_read",
Pg_lo_read,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_lo_write",
Pg_lo_write,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_lo_lseek",
Pg_lo_lseek,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_lo_creat",
Pg_lo_creat,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_lo_tell",
Pg_lo_tell,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_lo_unlink",
Pg_lo_unlink,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_lo_import",
Pg_lo_import,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_CreateCommand(interp,
"pg_lo_export",
Pg_lo_export,
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
Tcl_PkgProvide(interp, "Pgtcl", "1.0");
return TCL_OK;
}
int
Pgtcl_SafeInit (Tcl_Interp *interp)
{
return Pgtcl_Init(interp);
}