<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -888,9 +888,32 @@ static void validate_async_query( VALUE obj )
 
 static VALUE simulate_disconnect( VALUE obj )
 {
-  MYSQL* m = GetHandler(obj);
-  mysql_library_end();
-  return Qnil;
+    MYSQL* m = GetHandler(obj);
+    mysql_library_end();
+    return Qnil;
+}
+
+static int begins_with_insensitive(char *candidate, char *check_for_in_upper_case)
+{
+    /* skip  opening whitespace --tab is 11, newline is 12, cr is 15, space 32 */
+    char *where_at = candidate;
+    while( ((*where_at &gt;= 11 &amp;&amp; *where_at &lt;= 15) || (*where_at == 32)) &amp;&amp; (where_at != 0)) 
+  	  where_at++;
+
+    char *where_at_in_test = check_for_in_upper_case;
+    while(*where_at_in_test)
+    {
+  	  int candidate_char = *where_at;
+	  if(candidate_char == 0)
+		  return 0; /* end of line */
+	  if(candidate_char &gt;= 97 &amp;&amp; candidate_char &lt; 122) /* then it's upper case --lower case ify it */
+		  candidate_char -= 32;
+          if(candidate_char != *where_at_in_test)
+		  return 0;
+	  where_at_in_test++;
+	  where_at++;
+	}
+    return 1;
 }
 
 /* send_query(sql) */
@@ -910,7 +933,22 @@ static VALUE send_query(VALUE obj, VALUE sql)
       mysql_raise(m);
 	}
 	
-	async_in_progress_set( obj, Qtrue );
+	/* what about http://dev.mysql.com/doc/refman/5.0/en/implicit-commit.html and more? */
+	if( 
+	  begins_with_insensitive(RSTRING_PTR(sql), &quot;SET &quot;) ||
+	  begins_with_insensitive(RSTRING_PTR(sql), &quot;BEGIN&quot;) ||
+	  begins_with_insensitive(RSTRING_PTR(sql), &quot;START TRANSACTION&quot;) ||
+	  begins_with_insensitive(RSTRING_PTR(sql), &quot;ROLLBACK&quot;) ||
+	  begins_with_insensitive(RSTRING_PTR(sql), &quot;LOCK &quot;) ||
+	  begins_with_insensitive(RSTRING_PTR(sql), &quot;UNLOCK &quot;) ||
+	  begins_with_insensitive(RSTRING_PTR(sql), &quot;USE &quot;) ||
+	  begins_with_insensitive(RSTRING_PTR(sql), &quot;COMMIT&quot;) )
+	  {
+		/* do not mark an async in progress --they used send_query for something that doesn't necessarily have a result--is this allowable? */
+	   async_in_progress_set( obj, Qfalse ); 
+	} else {
+	  async_in_progress_set( obj, Qtrue );
+	}
 	return Qnil;
 }
 </diff>
      <filename>ext/mysql.c</filename>
    </modified>
    <modified>
      <diff>@@ -23,4 +23,9 @@ m.safe_query( 'select sleep(1)' )#raises
 m.close
 m.connect('localhost','root')
 m.safe_query( 'select sleep(1)' )
-m.safe_query( 'select sleep(1)' )#raises
\ No newline at end of file
+m.safe_query( 'select sleep(1)' )#raises
+m.simulate_disconnect
+m.safe_query( 'BEGIN' )
+m.safe_query( 'select sleep(1)' )
+m.get_result()
+m.safe_query( 'COMMIT' )
\ No newline at end of file</diff>
      <filename>test/out_of_sync_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9d66a3b71e91688e4b4a90d056dbc8bbbb88dc7f</id>
    </parent>
  </parents>
  <author>
    <name>Lourens Naude</name>
    <email>lourens@methodmissing.com</email>
  </author>
  <url>http://github.com/oldmoe/mysqlplus/commit/1af85383ebc32f7f189f37b91e5932a7c398a034</url>
  <id>1af85383ebc32f7f189f37b91e5932a7c398a034</id>
  <committed-date>2008-10-19T15:17:42-07:00</committed-date>
  <authored-date>2008-10-19T15:17:42-07:00</authored-date>
  <message>Applied Roger's async validation patch, with a minimal test case</message>
  <tree>f54d21933c6e53d0cb1e76e32fd6253f6b1cc937</tree>
  <committer>
    <name>Lourens Naude</name>
    <email>lourens@methodmissing.com</email>
  </committer>
</commit>
