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

Commit5d2cf6a

Browse files
committed
TCL_ARRAYS option patches from Massimo Dal Zotto
1 parentf134a1a commit5d2cf6a

File tree

2 files changed

+79
-36
lines changed

2 files changed

+79
-36
lines changed

‎src/backend/utils/adt/arrayfuncs.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.35 1999/01/1706:18:45 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.36 1999/01/1721:12:55 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -699,8 +699,10 @@ array_out(ArrayType *v, Oid element_type)
699699
for (tmp=values[i];*tmp;tmp++)
700700
{
701701
overall_length+=1;
702+
#ifndefTCL_ARRAYS
702703
if (*tmp=='"')
703704
overall_length+=1;
705+
#endif
704706
}
705707
overall_length+=1;
706708
}
@@ -729,6 +731,7 @@ array_out(ArrayType *v, Oid element_type)
729731
if (!typbyval)
730732
{
731733
strcat(p,"\"");
734+
#ifndefTCL_ARRAYS
732735
l=strlen(p);
733736
for (tmp=values[k];*tmp;tmp++)
734737
{
@@ -737,6 +740,9 @@ array_out(ArrayType *v, Oid element_type)
737740
p[l++]=*tmp;
738741
}
739742
p[l]='\0';
743+
#else
744+
strcat(p,values[k]);
745+
#endif
740746
strcat(p,"\"");
741747
}
742748
else

‎src/interfaces/libpgtcl/pgtclCmds.c

Lines changed: 72 additions & 35 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/pgtclCmds.c,v 1.38 1998/10/14 15:17:51 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.39 1999/01/17 21:12:55 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -472,39 +472,50 @@ Pg_exec(ClientData cData, Tcl_Interp * interp, int argc, char *argv[])
472472
get information about the results of a query
473473
474474
syntax:
475-
pg_result result ?option?
475+
476+
pg_result result ?option?
476477
477478
the options are:
478-
-status
479-
the status of the result
480-
-error
481-
the error message, if the status indicates error; otherwise an empty string
482-
-conn
483-
the connection that produced the result
484-
-oid
485-
if command was an INSERT, the OID of the inserted tuple
486-
-numTuples
487-
the number of tuples in the query
488-
-numAttrs
489-
returns the number of attributes returned by the query
490-
-assign arrayName
491-
assign the results to an array, using subscripts of the form
492-
(tupno,attributeName)
493-
-assignbyidx arrayName ?appendstr?
494-
assign the results to an array using the first field's value as a key.
495-
All but the first field of each tuple are stored, using subscripts of the form
496-
(field0value,attributeNameappendstr)
497-
-getTuple tupleNumber
498-
returns the values of the tuple in a list
499-
-tupleArray tupleNumber arrayName
500-
stores the values of the tuple in array arrayName, indexed
501-
by the attributes returned
502-
-attributes
503-
returns a list of the name/type pairs of the tuple attributes
504-
-lAttributes
505-
returns a list of the {name type len} entries of the tuple attributes
506-
-clear
507-
clear the result buffer. Do not reuse after this
479+
480+
-statusthe status of the result
481+
482+
-errorthe error message, if the status indicates error; otherwise
483+
an empty string
484+
485+
-connthe connection that produced the result
486+
487+
-oidif command was an INSERT, the OID of the inserted tuple
488+
489+
-numTuplesthe number of tuples in the query
490+
491+
-numAttrsreturns the number of attributes returned by the query
492+
493+
-assign arrayName
494+
assign the results to an array, using subscripts of the form
495+
(tupno,attributeName)
496+
497+
-assignbyidx arrayName ?appendstr?
498+
assign the results to an array using the first field's value
499+
as a key.
500+
All but the first field of each tuple are stored, using
501+
subscripts of the form (field0value,attributeNameappendstr)
502+
503+
-getTuple tupleNumber
504+
returns the values of the tuple in a list
505+
506+
-tupleArray tupleNumber arrayName
507+
stores the values of the tuple in array arrayName, indexed
508+
by the attributes returned
509+
510+
-attributes
511+
returns a list of the name/type pairs of the tuple attributes
512+
513+
-lAttributes
514+
returns a list of the {name type len} entries of the tuple
515+
attributes
516+
517+
-clearclear the result buffer. Do not reuse after this
518+
508519
**********************************/
509520
int
510521
Pg_result(ClientDatacData,Tcl_Interp*interp,intargc,char*argv[])
@@ -621,15 +632,24 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[])
621632
*/
622633
for (tupno=0;tupno<PQntuples(result);tupno++)
623634
{
624-
constchar*field0=PQgetvalue(result,tupno,0);
625-
char*workspace=malloc(strlen(field0)+strlen(appendstr)+210);
635+
constchar*field0=
636+
#ifdefTCL_ARRAYS
637+
tcl_value(PQgetvalue(result,tupno,0));
638+
#else
639+
PQgetvalue(result,tupno,0);
640+
#endif
641+
char*workspace=malloc(strlen(field0)+strlen(appendstr)+210);
626642

627643
for (i=1;i<PQnfields(result);i++)
628644
{
629645
sprintf(workspace,"%s,%.200s%s",field0,PQfname(result,i),
630646
appendstr);
631647
if (Tcl_SetVar2(interp,arrVar,workspace,
648+
#ifdefTCL_ARRAYS
649+
tcl_value(PQgetvalue(result,tupno,i)),
650+
#else
632651
PQgetvalue(result,tupno,i),
652+
#endif
633653
TCL_LEAVE_ERR_MSG)==NULL)
634654
{
635655
free(workspace);
@@ -654,8 +674,15 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[])
654674
Tcl_AppendResult(interp,"argument to getTuple cannot exceed number of tuples - 1",0);
655675
returnTCL_ERROR;
656676
}
677+
#ifdefTCL_ARRAYS
678+
for (i=0;i<PQnfields(result);i++)
679+
{
680+
Tcl_AppendElement(interp,tcl_value(PQgetvalue(result,tupno,i)));
681+
}
682+
#else
657683
for (i=0;i<PQnfields(result);i++)
658684
Tcl_AppendElement(interp,PQgetvalue(result,tupno,i));
685+
#endif
659686
returnTCL_OK;
660687
}
661688
elseif (strcmp(opt,"-tupleArray")==0)
@@ -674,7 +701,11 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[])
674701
for (i=0;i<PQnfields(result);i++)
675702
{
676703
if (Tcl_SetVar2(interp,argv[4],PQfname(result,i),
704+
#ifdefTCL_ARRAYS
705+
tcl_value(PQgetvalue(result,tupno,i)),
706+
#else
677707
PQgetvalue(result,tupno,i),
708+
#endif
678709
TCL_LEAVE_ERR_MSG)==NULL)
679710
returnTCL_ERROR;
680711
}
@@ -1302,7 +1333,13 @@ Pg_select(ClientData cData, Tcl_Interp * interp, int argc, char **argv)
13021333
Tcl_SetVar2(interp,argv[3],".tupno",buffer,0);
13031334

13041335
for (column=0;column<ncols;column++)
1305-
Tcl_SetVar2(interp,argv[3],info[column].cname,PQgetvalue(result,tupno,column),0);
1336+
Tcl_SetVar2(interp,argv[3],info[column].cname,
1337+
#ifdefTCL_ARRAYS
1338+
tcl_value(PQgetvalue(result,tupno,column)),
1339+
#else
1340+
PQgetvalue(result,tupno,column),
1341+
#endif
1342+
0);
13061343

13071344
Tcl_SetVar2(interp,argv[3],".command","update",0);
13081345

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp