Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit552620c

Browse files
committed
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.
1 parent582982e commit552620c

File tree

7 files changed

+368
-119
lines changed

7 files changed

+368
-119
lines changed

‎src/interfaces/libpgtcl/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile,v 1.2 1996/07/23 03:38:42 scrappy Exp $
10+
# $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile,v 1.3 1996/10/30 06:18:36 scrappy Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -23,6 +23,8 @@ CFLAGS+= -I$(HEADERDIR) \
2323
-I$(TCL_INCDIR)\
2424
-I$(srcdir)/libpq
2525

26+
LIBLDLIBS+= -L$(LIBDIR) -lpq
27+
2628
ifdefKRBVERS
2729
CFLAGS+=$(KRBFLAGS)
2830
endif

‎src/interfaces/libpgtcl/libpgtcl.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: libpgtcl.h,v 1.1.1.1 1996/07/09 06:22:16 scrappy Exp $
9+
* $Id: libpgtcl.h,v 1.2 1996/10/30 06:18:37 scrappy Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -16,6 +16,7 @@
1616

1717
#include"tcl.h"
1818

19-
externintPg_Init (Tcl_Interp*interp);
19+
externintPgtcl_Init (Tcl_Interp*interp);
20+
externintPgtcl_SafeInit (Tcl_Interp*interp);
2021

2122
#endif/* LIBPGTCL_H */

‎src/interfaces/libpgtcl/pgtcl.c

Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.2 1996/10/07 21:19:06 scrappy Exp $
12+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.3 1996/10/30 06:18:38 scrappy Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -19,92 +19,145 @@
1919
#include"pgtclCmds.h"
2020

2121
/*
22-
*PG_Init
22+
*Pgtcl_Init
2323
* initialization package for the PGLITE Tcl package
2424
*
2525
*/
2626

27+
/*
28+
* Tidy up forgotten postgres connection at Tcl_Exit
29+
*/
30+
void
31+
Pgtcl_AtExit (ClientDatacData)
32+
{
33+
Pg_clientData*cd= (Pg_clientData*)cData;
34+
Tcl_HashEntry*hent;
35+
Tcl_HashSearchhsearch;
36+
Pg_ConnectionId*connid;
37+
PGconn*conn;
38+
39+
while((hent=Tcl_FirstHashEntry(&(cd->dbh_hash),&hsearch))!=NULL) {
40+
connid= (Pg_ConnectionId*)Tcl_GetHashValue(hent);
41+
conn=connid->conn;
42+
PgDelConnectionId(cd,connid->id);
43+
PQfinish(conn);
44+
}
45+
46+
Tcl_DeleteHashTable(&(cd->dbh_hash));
47+
Tcl_DeleteHashTable(&(cd->res_hash));
48+
49+
Tcl_DeleteExitHandler(Pgtcl_AtExit,cData);
50+
}
51+
52+
/*
53+
* Tidy up forgotten postgres connections on Interpreter deletion
54+
*/
55+
void
56+
Pgtcl_Shutdown (ClientDatacData,Tcl_Interp*interp)
57+
{
58+
Pgtcl_AtExit(cData);
59+
}
60+
2761
int
28-
Pg_Init (Tcl_Interp*interp)
62+
Pgtcl_Init (Tcl_Interp*interp)
2963
{
30-
/* register all pgtcl commands */
64+
Pg_clientData*cd;
65+
66+
/* Create and initialize the client data area */
67+
cd= (Pg_clientData*)ckalloc(sizeof(Pg_clientData));
68+
Tcl_InitHashTable(&(cd->dbh_hash),TCL_STRING_KEYS);
69+
Tcl_InitHashTable(&(cd->res_hash),TCL_STRING_KEYS);
70+
cd->dbh_count=0L;
71+
cd->res_count=0L;
72+
73+
/* Arrange for tidy up when interpreter is deleted or Tcl exits */
74+
Tcl_CallWhenDeleted(interp,Pgtcl_Shutdown, (ClientData)cd);
75+
Tcl_CreateExitHandler(Pgtcl_AtExit, (ClientData)cd);
3176

77+
/* register all pgtcl commands */
3278
Tcl_CreateCommand(interp,
3379
"pg_connect",
3480
Pg_connect,
35-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
81+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
3682

3783
Tcl_CreateCommand(interp,
3884
"pg_disconnect",
3985
Pg_disconnect,
40-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
86+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
4187

4288
Tcl_CreateCommand(interp,
4389
"pg_exec",
4490
Pg_exec,
45-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
91+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
4692

4793
Tcl_CreateCommand(interp,
4894
"pg_select",
4995
Pg_select,
50-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
96+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
5197

5298
Tcl_CreateCommand(interp,
5399
"pg_result",
54100
Pg_result,
55-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
101+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
56102

57103
Tcl_CreateCommand(interp,
58104
"pg_lo_open",
59105
Pg_lo_open,
60-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
106+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
61107

62108
Tcl_CreateCommand(interp,
63109
"pg_lo_close",
64110
Pg_lo_close,
65-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
111+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
66112

67113
Tcl_CreateCommand(interp,
68114
"pg_lo_read",
69115
Pg_lo_read,
70-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
116+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
71117

72118
Tcl_CreateCommand(interp,
73119
"pg_lo_write",
74120
Pg_lo_write,
75-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
121+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
76122

77123
Tcl_CreateCommand(interp,
78124
"pg_lo_lseek",
79125
Pg_lo_lseek,
80-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
126+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
81127

82128
Tcl_CreateCommand(interp,
83129
"pg_lo_creat",
84130
Pg_lo_creat,
85-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
131+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
86132

87133
Tcl_CreateCommand(interp,
88134
"pg_lo_tell",
89135
Pg_lo_tell,
90-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
136+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
91137

92138
Tcl_CreateCommand(interp,
93139
"pg_lo_unlink",
94140
Pg_lo_unlink,
95-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
141+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
96142

97143
Tcl_CreateCommand(interp,
98144
"pg_lo_import",
99145
Pg_lo_import,
100-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
146+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
101147

102148
Tcl_CreateCommand(interp,
103149
"pg_lo_export",
104150
Pg_lo_export,
105-
(ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
151+
(ClientData)cd, (Tcl_CmdDeleteProc*)NULL);
106152

153+
Tcl_PkgProvide(interp,"Pgtcl","1.0");
154+
107155
returnTCL_OK;
108156
}
109157

110158

159+
int
160+
Pgtcl_SafeInit (Tcl_Interp*interp)
161+
{
162+
returnPgtcl_Init(interp);
163+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp