pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgtcl has no coresponding function to PQcmdTuples
3+ messages / 3 participants
[nested] [flat]

* pgtcl has no coresponding function to PQcmdTuples
@ 2002-11-23 15:44 Artur Trzewik <mail@xdobry.de>
  2002-11-26 19:43 ` Re: pgtcl has no coresponding function to PQcmdTuples Gerhard Hintermayer <g.hintermayer@inode.at>
  2002-11-26 21:39 ` Re: pgtcl has no coresponding function to PQcmdTuples Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 2 replies; 3+ messages in thread

From: Artur Trzewik @ 2002-11-23 15:44 UTC (permalink / raw)
  To: pgsql-interfaces

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




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pgtcl has no coresponding function to PQcmdTuples
  2002-11-23 15:44 pgtcl has no coresponding function to PQcmdTuples Artur Trzewik <mail@xdobry.de>
@ 2002-11-26 19:43 ` Gerhard Hintermayer <g.hintermayer@inode.at>
  1 sibling, 0 replies; 3+ messages in thread

From: Gerhard Hintermayer @ 2002-11-26 19:43 UTC (permalink / raw)
  To: pgsql-interfaces

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&saf...


-- 
Gerhard Hintermayer
http://www.inode.at/g.hintermayer




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: pgtcl has no coresponding function to PQcmdTuples
  2002-11-23 15:44 pgtcl has no coresponding function to PQcmdTuples Artur Trzewik <mail@xdobry.de>
@ 2002-11-26 21:39 ` Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Bruce Momjian @ 2002-11-26 21:39 UTC (permalink / raw)
  To: Artur Trzewik <mail@xdobry.de>; +Cc: pgsql-interfaces


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",
^ permalink raw reply [nested|flat] 3+ messages in thread


end of thread, other threads:[~2002-11-26 21:39 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-11-23 15:44 pgtcl has no coresponding function to PQcmdTuples Artur Trzewik <mail@xdobry.de>
2002-11-26 19:43 ` Gerhard Hintermayer <g.hintermayer@inode.at>
2002-11-26 21:39 ` Bruce Momjian <pgman@candle.pha.pa.us>

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