Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8A297475B07 for ; Tue, 26 Nov 2002 16:39:42 -0500 (EST) Received: from candle.pha.pa.us (momjian.navpoint.com [207.106.42.251]) by postgresql.org (Postfix) with ESMTP id C16CF4758E1 for ; Tue, 26 Nov 2002 16:39:40 -0500 (EST) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id gAQLdY021298; Tue, 26 Nov 2002 16:39:34 -0500 (EST) From: Bruce Momjian Message-Id: <200211262139.gAQLdY021298@candle.pha.pa.us> Subject: Re: pgtcl has no coresponding function to PQcmdTuples In-Reply-To: <200211231642.58326.artur2@xdobry.de> To: Artur Trzewik Date: Tue, 26 Nov 2002 16:39:34 -0500 (EST) Cc: pgsql-interfaces@postgresql.org X-Mailer: ELM [version 2.4ME+ PL99 (25)] MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=ELM1038346774-20950-0_ Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/121 X-Sequence-Number: 3369 --ELM1038346774-20950-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII 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 --ELM1038346774-20950-0_ Content-Transfer-Encoding: 7bit Content-Type: text/plain Content-Disposition: inline; filename="/bjm/diff" 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", --ELM1038346774-20950-0_--