pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Artur Trzewik <mail@xdobry.de>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: pgtcl has no coresponding function to PQcmdTuples
Date: Tue, 26 Nov 2002 16:39:34 -0500 (EST)
Message-ID: <200211262139.gAQLdY021298@candle.pha.pa.us> (raw)
In-Reply-To: <200211231642.58326.artur2@xdobry.de>


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

Attachments:

/bjm/diff (text/plain, 1.9K) download 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 ---- </VARLISTENTRY> <VARLISTENTRY> <TERM> + <option>-cmdTuples</option> + </TERM> + <LISTITEM> + <PARA> + the number of tuples affected by the query. + </PARA> + </LISTITEM> + </VARLISTENTRY> + <VARLISTENTRY> + <TERM> <option>-numAttrs</option> </TERM> <LISTITEM> 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",

view thread (3+ messages)

Message-ID: <200211262139.gAQLdY021298@candle.pha.pa.us>
Permalink:  ../200211262139.gAQLdY021298@candle.pha.pa.us/
Also on:    postgresql.org/message-id/200211262139.gAQLdY021298@candle.pha.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: pgman@candle.pha.pa.us, mail@xdobry.de
  Subject: Re: pgtcl has no coresponding function to PQcmdTuples
  In-Reply-To: <200211262139.gAQLdY021298@candle.pha.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox