Re: [HACKERS] pltcl - lastoid

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: bob(at)redivi(dot)com
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] pltcl - lastoid
Date: 2001-08-02 15:46:05
Message-ID: 200108021546.f72Fk5F27152@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Patch applied. Thanks.

> I noticed that pltcl didn't have any way to get to SPI_lastoid like plpgsql does.. I started using pltcl a lot because I like to decide when and how my queries get planned.. so I put one together really quick
>
> Sorry I don't have the original around to make a quick diff, but its a very small change... I think this should be in the next release, there's no reason not to have it.
>
> its a function with no expected arguments, so you can use it like:
> spi_exec "INSERT INTO mytable(columns...) VALUES(values..)"
> set oid [spi_lastoid]
> spi_exec "SELECT mytable_id from mytable WHERE oid=$oid"
>
> It just didn't make sense for me to use plpgsql and pltcl, or just screw them both and use SPI from C
>
> these changes are for src/pl/tcl/pltcl.c
>
> /* start C code */
>
> /* forward declaration */
> static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp,
> int argc, char *argv[]);
>
> /* this needs to go in in pltcl_init_interp with the rest of 'em */
> Tcl_CreateCommand(interp, "spi_lastoid",
> pltcl_SPI_lastoid, NULL, NULL);
>
>
> /**********************************************************************
> * pltcl_SPI_lastoid() - return the last oid. To
> * be used after insert queries
> **********************************************************************/
> static int
> pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp,
> int argc, char *argv[])
> {
> char buf[64];
> sprintf(buf,"%d",SPI_lastoid);
> Tcl_SetResult(interp, buf, TCL_VOLATILE);
> return TCL_OK;
> }
>
> /* end C code */
>
> -bob
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Attachment Content-Type Size
unknown_filename text/plain 3.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-08-02 15:46:36 Re: plpgsql: RAISE <level> <expr> <params>
Previous Message Bruce Momjian 2001-08-02 15:35:45 Re: Re: What needs to be done?

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2001-08-02 15:47:55 Re: WIN32 errno patch
Previous Message Bruce Momjian 2001-08-02 15:44:18 Re: ODBC Boolean handling