Update of /cvsroot/monetdb/clients/src/mapilib
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv22392/src/mapilib
Modified Files:
Mapi.mx
Log Message:
add support for mapi_get_last_id
The last_id is a values supplied by the server on single row inserts
into tables which have one auto_increment (and alike) column.
Index: Mapi.mx
===================================================================
RCS file: /cvsroot/monetdb/clients/src/mapilib/Mapi.mx,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- Mapi.mx 17 Nov 2007 18:39:38 -0000 1.26
+++ Mapi.mx 9 Dec 2007 12:48:17 -0000 1.27
@@ -207,6 +207,7 @@
@item mapi_get_monet_version() @tab MonetDB version name
@item mapi_get_motd() @tab Get server welcome message
@item mapi_get_row_count() @tab Number of rows in cache or -1
[EMAIL PROTECTED] mapi_get_last_id() @tab last inserted id of an
auto_increment (or alike) column
@item mapi_get_trace() @tab Get trace flag
@item mapi_get_user() @tab Current user name
@item mapi_log() @tab Keep log of client/server interaction
@@ -435,6 +436,13 @@
If possible, return the number of rows in the last select call. A -1
is returned if this information is not available.
[EMAIL PROTECTED] lng mapi_get_last_id(Mapi mid)
+
+If possible, return the last inserted id of auto_increment (or alike) column.
+A -1 is returned if this information is not available. We restrict this to
+single row inserts and one auto_increment column per table. If the restrictions
+do not hold, the result is unspecified.
+
@item int mapi_rows_affected(MapiHdl hdl)
Return the number of rows affected by a database update command
@@ -918,6 +926,7 @@
int tableid; /* SQL id of current result set */
int querytype; /* type of SQL query */
int row_count;
+ lng last_id;
int fieldcnt;
int maxfields;
char *errorstr; /* error from server */
@@ -1107,6 +1116,7 @@
mapi_export int mapi_fetch_all_rows(MapiHdl hdl);
mapi_export int mapi_get_field_count(MapiHdl hdl);
mapi_export int mapi_get_row_count(MapiHdl hdl);
+mapi_export lng mapi_get_last_id(MapiHdl hdl);
mapi_export int mapi_rows_affected(MapiHdl hdl);
mapi_export char *mapi_fetch_field(MapiHdl hdl, int fnr);
@@ -1475,6 +1485,7 @@
result->errorstr = NULL;
result->row_count = 0;
+ result->last_id = -1;
result->fieldcnt = 0;
result->maxfields = 0;
@@ -3393,6 +3404,7 @@
break;
case Q_UPDATE:
result->row_count = strtol(nline, &nline, 0);
+ result->last_id = strtol(nline, &nline, 0);
break;
case Q_TABLE:
case Q_PREPARE:{
@@ -4768,6 +4780,13 @@
return hdl->result ? hdl->result->row_count : 0;
}
+lng
+mapi_get_last_id(MapiHdl hdl)
+{
+ mapi_hdl_check(hdl, "mapi_get_last_id");
+ return hdl->result ? hdl->result->last_id : -1;
+}
+
char *
mapi_get_name(MapiHdl hdl, int fnr)
{
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins