pgtcl has no coresponding function to PQcmdTuples
pgtcl has no coresponding function to PQcmdTuples
От:
Artur Trzewik <mail@xdobry.de>
Дата:
Hi!
I have noticed that
pg_result $handle -numTuples
result always 0 after DELETE and UPDATE command
I have taken a look in the source code of pgtcl
and I see
# file pgtclCmds.c
else if (strcmp(opt, "-numTuples") == 0){ sprintf(interp->result, "%d", PQntuples(result)); return TCL_OK;}
it works only for SELECT commands.
There are no coresponding c-function call to PQcmdTuples
that return what I need in this moment.
I suggest to add new subcommand to pg_result -cmdTuples with
new code
else if (strcmp(opt, "-cmdTuples") == 0){ sprintf(interp->result, "%d", PQcmdTuples(result)); return TCL_OK;}
(better were to use Tcl_GetIndexFromObj an not strcmp,sprintf(interp->result,...) is also unsafe and very historical
It should be Tcl_SetObjResult(interp, Tcl_NewIntObj(PQcmdTuples(result)));
It do not look good
By the way.
pgtcl uses very old tcl interface (up to version 7)
using new interface would increase speed about 30-40%.
It also do not carry about UTF in new Tcl (new means about 2 years).
It hurts me to see that old tcl interfaces slow up tcl (and another say it is
slow).
I can upgrade it (I have done it for mysqltcl) if there are need for it.
I need conntact to pgtcl maintainer/autor.
best regards,
Artur Trzewik
Re: pgtcl has no coresponding function to PQcmdTuples
От:
Gerhard Hintermayer <g.hintermayer@inode.at>
Дата:
Artur Trzewik wrote: > Hi! > > I have noticed that > pg_result $handle -numTuples > result always 0 after DELETE and UPDATE command > > I have taken a look in the source code of pgtcl > and I see pg_execute is your friend, see below ... > > [...] > > (better were to use Tcl_GetIndexFromObj an not strcmp, > sprintf(interp->result,...) is also unsafe and very historical > It should be Tcl_SetObjResult(interp, Tcl_NewIntObj(PQcmdTuples(result))); > It do not look good > > By the way. > pgtcl uses very old tcl interface (up to version 7) > using new interface would increase speed about 30-40%. > It also do not carry about UTF in new Tcl (new means about 2 years). > It hurts me to see that old tcl interfaces slow up tcl (and another say it is > slow). > > I can upgrade it (I have done it for mysqltcl) if there are need for it. > I need conntact to pgtcl maintainer/autor. > > best regards, > Artur Trzewik Already done, see http://gborg.postgresql.org/project/pgtcl/ and also the announcement at c.l.t: http://groups.google.com/groups?q=pgtcl+group:comp.lang.tcl.*&hl=en&lr=&ie=UTF-8&safe=off&selm=1037426192.509154%40nntp1.bsj.jax.superconnect.net&rnum=1 -- Gerhard Hintermayer http://www.inode.at/g.hintermayer
Re: pgtcl has no coresponding function to PQcmdTuples
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
The attached patch implements -cmdTuples in the tcl interface. This
will be in 7.4.
---------------------------------------------------------------------------
Artur Trzewik wrote:
> Hi!
>
> I have noticed that
> pg_result $handle -numTuples
> result always 0 after DELETE and UPDATE command
>
> I have taken a look in the source code of pgtcl
> and I see
>
> # file pgtclCmds.c
>
> else if (strcmp(opt, "-numTuples") == 0)
> {
> sprintf(interp->result, "%d", PQntuples(result));
> return TCL_OK;
> }
>
> it works only for SELECT commands.
> There are no coresponding c-function call to PQcmdTuples
> that return what I need in this moment.
> I suggest to add new subcommand to pg_result -cmdTuples with
> new code
>
> else if (strcmp(opt, "-cmdTuples") == 0)
> {
> sprintf(interp->result, "%d", PQcmdTuples(result));
> return TCL_OK;
> }
>
> (better were to use Tcl_GetIndexFromObj an not strcmp,
> sprintf(interp->result,...) is also unsafe and very historical
> It should be Tcl_SetObjResult(interp, Tcl_NewIntObj(PQcmdTuples(result)));
> It do not look good
>
> By the way.
> pgtcl uses very old tcl interface (up to version 7)
> using new interface would increase speed about 30-40%.
> It also do not carry about UTF in new Tcl (new means about 2 years).
> It hurts me to see that old tcl interfaces slow up tcl (and another say it is
> slow).
>
> I can upgrade it (I have done it for mysqltcl) if there are need for it.
> I need conntact to pgtcl maintainer/autor.
>
> best regards,
> Artur Trzewik
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: doc/src/sgml/libpgtcl.sgml
===================================================================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/libpgtcl.sgml,v
retrieving revision 1.33
diff -c -c -r1.33 libpgtcl.sgml
*** doc/src/sgml/libpgtcl.sgml 15 Nov 2002 03:11:16 -0000 1.33
--- doc/src/sgml/libpgtcl.sgml 26 Nov 2002 21:36:55 -0000
***************
*** 728,733 ****
--- 728,743 ----
+
+
+
+
+ the number of tuples affected by the query.
+
+
+
+
+
Index: src/interfaces/libpgtcl/pgtclCmds.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/interfaces/libpgtcl/pgtclCmds.c,v
retrieving revision 1.69
diff -c -c -r1.69 pgtclCmds.c
*** src/interfaces/libpgtcl/pgtclCmds.c 17 Oct 2002 14:51:50 -0000 1.69
--- src/interfaces/libpgtcl/pgtclCmds.c 26 Nov 2002 21:37:00 -0000
***************
*** 506,511 ****
--- 506,513 ----
-numTuples the number of tuples in the query
+ -cmdTuples the number of tuples affected by the query
+
-numAttrs returns the number of attributes returned by the query
-assign arrayName
***************
*** 591,596 ****
--- 593,603 ----
sprintf(interp->result, "%d", PQntuples(result));
return TCL_OK;
}
+ else if (strcmp(opt, "-cmdTuples") == 0)
+ {
+ sprintf(interp->result, "%s", PQcmdTuples(result));
+ return TCL_OK;
+ }
else if (strcmp(opt, "-numAttrs") == 0)
{
sprintf(interp->result, "%d", PQnfields(result));
***************
*** 768,773 ****
--- 775,781 ----
"\t-conn\n",
"\t-oid\n",
"\t-numTuples\n",
+ "\t-cmdTuples\n",
"\t-numAttrs\n"
"\t-assign arrayVarName\n",
"\t-assignbyidx arrayVarName ?appendstr?\n",