Erlang Mailing Lists

Author Message

<  Erlyweb mailing list  ~  Fwd: [PATCH] Add last_insert_id parsing to mysql_conn

Guest
Posted: Mon Jan 28, 2008 5:06 am Reply with quote
Guest
This is the second patch (apply it after the first one).


Summary:
- This is so we can insert Transactions with proper linking between them
---
erlang/mysql/include/mysql.hrl | 1 +
erlang/mysql/src/mysql_conn.erl | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/erlang/mysql/include/mysql.hrl b/erlang/mysql/include/mysql.hrl
index aee5611..1e27152 100644
--- a/erlang/mysql/include/mysql.hrl
+++ b/erlang/mysql/include/mysql.hrl
@@ -3,4 +3,5 @@
{fieldinfo=[],
rows=[],
affectedrows=0,
+ last_insert_id,
error=""}).
diff --git a/erlang/mysql/src/mysql_conn.erl b/erlang/mysql/src/mysql_conn.erl
index 779fd8f..078dd2a 100644
--- a/erlang/mysql/src/mysql_conn.erl
+++ b/erlang/mysql/src/mysql_conn.erl
@@ -652,8 +652,10 @@ get_query_response(LogFun, RecvPid, Version) ->
case Fieldcount of
0 ->
%% No Tabular data
- {AffectedRows, _Rest2} = decode_length(Rest),
- {updated, #mysql_result{affectedrows=AffectedRows}};
+ {AffectedRows, Rest2} = decode_length(Rest),
+ {InsertId, _Rest3} = decode_length(Rest2),
+ {updated, #mysql_result{affectedrows=AffectedRows,
+ last_insert_id = InsertId}};
255 ->
<<_Code:16/little, Message/binary>> = Rest,
{error, #mysql_result{error=Message}};
--
1.5.3.2

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum