Index: doc/src/sgml/pltcl.sgml
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/pltcl.sgml,v
retrieving revision 2.11
diff -c -r2.11 pltcl.sgml
*** doc/src/sgml/pltcl.sgml 2001/06/09 02:19:07 2.11
--- doc/src/sgml/pltcl.sgml 2001/08/01 19:32:04
***************
*** 395,400 ****
--- 395,412 ----
+
+ spi_lastoid
+
+ spi_lastoid
+
+
+ Returns the OID of the last query if it was an INSERT.
+
+
+
+
+
spi_exec ?-count n? ?-array name? query ?loop-body?
Index: src/pl/tcl/pltcl.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/pl/tcl/pltcl.c,v
retrieving revision 1.37
diff -c -r1.37 pltcl.c
*** src/pl/tcl/pltcl.c 2001/06/09 02:19:07 1.37
--- src/pl/tcl/pltcl.c 2001/08/01 19:32:09
***************
*** 144,149 ****
--- 144,151 ----
int tupno, HeapTuple tuple, TupleDesc tupdesc);
static void pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
Tcl_DString *retval);
+ static int pltcl_SPI_lastoid(ClientData cdata, Tcl_Interp *interp,
+ int argc, char *argv[]);
/*
* This routine is a crock, and so is everyplace that calls it. The problem
***************
*** 251,257 ****
pltcl_SPI_prepare, NULL, NULL);
Tcl_CreateCommand(interp, "spi_execp",
pltcl_SPI_execp, NULL, NULL);
!
#ifdef ENABLE_PLTCL_UNKNOWN
/************************************************************
* Try to load the unknown procedure from pltcl_modules
--- 253,261 ----
pltcl_SPI_prepare, NULL, NULL);
Tcl_CreateCommand(interp, "spi_execp",
pltcl_SPI_execp, NULL, NULL);
! Tcl_CreateCommand(interp, "spi_lastoid",
! pltcl_SPI_lastoid, NULL, NULL);
!
#ifdef ENABLE_PLTCL_UNKNOWN
/************************************************************
* Try to load the unknown procedure from pltcl_modules
***************
*** 2270,2275 ****
--- 2274,2294 ----
************************************************************/
memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart));
sprintf(buf, "%d", ntuples);
+ Tcl_SetResult(interp, buf, TCL_VOLATILE);
+ return TCL_OK;
+ }
+
+
+ /**********************************************************************
+ * 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,"%u",SPI_lastoid);
Tcl_SetResult(interp, buf, TCL_VOLATILE);
return TCL_OK;
}