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

Commit83c9ec7

Browse files
committed
Last changes to src from Dr. George *wipes brow*
1 parent2206b58 commit83c9ec7

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

‎src/interfaces/libpgtcl/Makefile

Lines changed: 3 additions & 2 deletions
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.1.1.1 1996/07/09 06:22:16 scrappy Exp $
10+
# $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/Makefile,v 1.2 1996/07/23 03:38:42 scrappy Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -20,7 +20,8 @@ CFLAGS+= -I$(HEADERDIR) \
2020
-I$(srcdir)/backend/include\
2121
-I$(srcdir)/backend\
2222
-I$(CURDIR)\
23-
-I$(TCL_INCDIR)
23+
-I$(TCL_INCDIR)\
24+
-I$(srcdir)/libpq
2425

2526
ifdefKRBVERS
2627
CFLAGS+=$(KRBFLAGS)

‎src/interfaces/libpgtcl/pgtclCmds.c

Lines changed: 26 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/pgtclCmds.c,v 1.1.1.1 1996/07/09 06:22:16 scrappy Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.2 1996/07/23 03:38:44 scrappy Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -194,6 +194,8 @@ Pg_exec(AlientData cData, Tcl_Interp *interp, int argc, char* argv[])
194194
the connection that produced the result
195195
-assign arrayName
196196
assign the results to an array
197+
-assignbyidx arrayName
198+
assign the results to an array using the first field as a key
197199
-numTuples
198200
the number of tuples in the query
199201
-attributes
@@ -211,6 +213,7 @@ Pg_result(ClientData cData, Tcl_Interp *interp, int argc, char* argv[])
211213
char*opt;
212214
inti;
213215
inttupno;
216+
charprearrayInd[MAX_MESSAGE_LEN];
214217
chararrayInd[MAX_MESSAGE_LEN];
215218
char*arrVar;
216219

@@ -268,6 +271,27 @@ Pg_result(ClientData cData, Tcl_Interp *interp, int argc, char* argv[])
268271
Tcl_AppendResult(interp,arrVar,0);
269272
returnTCL_OK;
270273
}
274+
elseif (strcmp(opt,"-assignbyidx")==0) {
275+
if (argc!=4) {
276+
Tcl_AppendResult(interp,"-assignbyidx option must be followed by a variable name",0);
277+
returnTCL_ERROR;
278+
}
279+
arrVar=argv[3];
280+
/* this assignment assigns the table of result tuples into a giant
281+
array with the name given in the argument,
282+
the indices of the array or (tupno,attrName)*/
283+
for (tupno=0;tupno<PQntuples(result);tupno++) {
284+
sprintf(prearrayInd,"%s",PQgetvalue(result,tupno,0));
285+
for (i=1;i<PQnfields(result);i++) {
286+
sprintf(arrayInd,"%s,%s",prearrayInd,PQfname(result,i));
287+
Tcl_SetVar2(interp,arrVar,arrayInd,
288+
PQgetvalue(result,tupno,i),
289+
TCL_LEAVE_ERR_MSG);
290+
}
291+
}
292+
Tcl_AppendResult(interp,arrVar,0);
293+
returnTCL_OK;
294+
}
271295
elseif (strcmp(opt,"-getTuple")==0) {
272296
if (argc!=4) {
273297
Tcl_AppendResult(interp,"-getTuple option must be followed by a tuple number",0);
@@ -307,6 +331,7 @@ Pg_result(ClientData cData, Tcl_Interp *interp, int argc, char* argv[])
307331
"\t-status\n",
308332
"\t-conn\n",
309333
"\t-assign arrayVarName\n",
334+
"\t-assignbyidx arrayVarName\n",
310335
"\t-numTuples\n",
311336
"\t-attributes\n"
312337
"\t-getTuple tupleNumber\n",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp