|
31 | 31 | * ENHANCEMENTS, OR MODIFICATIONS.
|
32 | 32 | *
|
33 | 33 | * IDENTIFICATION
|
34 |
| - * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.37 2001/06/09 02:19:07 tgl Exp $ |
| 34 | + * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.38 2001/08/02 15:45:55 momjian Exp $ |
35 | 35 | *
|
36 | 36 | **********************************************************************/
|
37 | 37 |
|
@@ -144,6 +144,8 @@ static void pltcl_set_tuple_values(Tcl_Interp *interp, char *arrayname,
|
144 | 144 | int tupno, HeapTuple tuple, TupleDesc tupdesc);
|
145 | 145 | static void pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
|
146 | 146 | Tcl_DString *retval);
|
| 147 | +static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp, |
| 148 | + int argc, char *argv[]); |
147 | 149 |
|
148 | 150 | /*
|
149 | 151 | * This routine is a crock, and so is everyplace that calls it. The problem
|
@@ -251,7 +253,9 @@ pltcl_init_interp(Tcl_Interp *interp)
|
251 | 253 | pltcl_SPI_prepare, NULL, NULL);
|
252 | 254 | Tcl_CreateCommand(interp, "spi_execp",
|
253 | 255 | pltcl_SPI_execp, NULL, NULL);
|
254 |
| - |
| 256 | + Tcl_CreateCommand(interp, "spi_lastoid", |
| 257 | + pltcl_SPI_lastoid, NULL, NULL); |
| 258 | + |
255 | 259 | #ifdef ENABLE_PLTCL_UNKNOWN
|
256 | 260 | /************************************************************
|
257 | 261 | * Try to load the unknown procedure from pltcl_modules
|
@@ -2275,6 +2279,21 @@ pltcl_SPI_execp(ClientData cdata, Tcl_Interp *interp,
|
2275 | 2279 | }
|
2276 | 2280 |
|
2277 | 2281 |
|
| 2282 | +/********************************************************************** |
| 2283 | + * pltcl_SPI_lastoid() - return the last oid. To |
| 2284 | + * be used after insert queries |
| 2285 | + **********************************************************************/ |
| 2286 | +static int |
| 2287 | +pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp, |
| 2288 | + int argc, char *argv[]) |
| 2289 | +{ |
| 2290 | + char buf[64]; |
| 2291 | + sprintf(buf,"%u",SPI_lastoid); |
| 2292 | + Tcl_SetResult(interp, buf, TCL_VOLATILE); |
| 2293 | + return TCL_OK; |
| 2294 | +} |
| 2295 | + |
| 2296 | + |
2278 | 2297 | /**********************************************************************
|
2279 | 2298 | * pltcl_set_tuple_values() - Set variables for all attributes
|
2280 | 2299 | * of a given tuple
|
|
0 commit comments