Commit Graph

151 Commits

Author SHA1 Message Date
Brian Lopez 48db8907be optimize casting to it only happens for default values 2010-05-14 16:23:03 -07:00
Brian Lopez 86b9ffefe9 fix another typo in the AR adapter 2010-05-14 12:36:22 -07:00
Brian Lopez 24a6393d7f fix a few typos in the Sequel adapter 2010-05-13 02:04:49 -07:00
Brian Lopez cf87d9d783 fix typo 2010-05-13 00:18:21 -07:00
Brian Lopez 6b285dcd85 minor refactor to casting code to better match what the MysqlAdapter does, removing unneeded checks 2010-05-13 00:13:55 -07:00
Brian Lopez 1f7ff62c8b update gemspec to include new error spec 2010-05-12 23:50:00 -07:00
Brian Lopez ea56862ec4 add sql_state and error_number methods to Mysql2::Error 2010-05-12 23:40:18 -07:00
Brian Lopez 87f23f4db4 no need to force GC 2010-05-12 23:37:20 -07:00
Brian Lopez 6736071ff1 assign Qnil for safety 2010-05-12 23:05:55 -07:00
Brian Lopez 69b9c587ad make sure we raise exceptions early and often if the connection has been closed 2010-05-12 23:05:33 -07:00
Brian Lopez a577f09fb0 make sure we override index creation for mysql 2010-05-12 22:34:53 -07:00
Brian Lopez 5b41082aba use new close method for disconnecting where we can 2010-05-12 22:09:06 -07:00
Brian Lopez e01c7581e5 unfortunately ActiveRecord does casting *all over the place* so I need to also fully override type_cast_code as well 2010-05-12 21:24:52 -07:00
Brian Lopez af2dd0d7f9 give Eric props for his work 2010-05-12 14:14:52 -07:00
Brian Lopez fc6c4641e8 bump version in gemspec 2010-05-12 14:09:47 -07:00
Brian Lopez a03b776037 Version bump to 0.1.5 2010-05-12 14:09:30 -07:00
Eric Wong ec00873181 make Mysql2::Client destructor safely non-blocking
Since sending a QUIT message to the MySQL server is more of a
formality than a hard requirement in a TCP-based protocol, we'll
just fire-and-forget the message to avoid any chance of blocking
the interpreter during the GC finalizer phase.  Since the socket
will be closed immediately afterwards, there's no long-term
side-effects from making the socket non-blocking.

We do this instead of using rb_thread_blocking_region because
the GVL is already destroyed by the time the ObjectSpace
finalizers are called under 1.9.
2010-05-10 14:16:53 -07:00
Brian Lopez 46021b9351 fix boolean casts 2010-05-10 01:18:05 -07:00
Brian Lopez 1dc3410a24 finally fix casting/attributes issue due to a lexical typo 2010-05-09 23:48:49 -07:00
Brian Lopez 10df5216c8 fix gemspec 2010-05-07 08:26:06 -07:00
Brian Lopez 6e977f756f add casting support in the AR driver specifically for handling default column values - this is a temporary (but working) fix as I'm looking into how I can do this in C 2010-05-07 00:21:54 -07:00
Brian Lopez 03c8d5dcea update benchmark results in readme 2010-05-06 16:42:03 -07:00
Brian Lopez edd8aa2773 Merge remote branch 'origin/master' into thread-signal-safety 2010-05-06 16:37:02 -07:00
Brian Lopez 30e06479e0 add raw driver benchmark with casting for the mysql gem 2010-05-06 00:17:00 -07:00
Brian Lopez d9200c43b4 add raw driver benchmark with casting for the mysql gem 2010-05-06 00:09:18 -07:00
Eric Wong f2a731e0a7 Fix memory leak from the result wrapper struct itself
Data_Make_Struct always allocates memory for us, so we
need to explicitly free the pointer in the function we
pass to the GC, not just objects internal to us.

Without this change, a slow but constant growth can be
seen with the trivial code below:

    x = Mysql2::Client.new
    loop { x.query "select 1" }
2010-05-05 18:26:29 -07:00
Eric Wong 4ac62c1333 correctly free the wrapped result in case of EOF
This is a followup to aa9f435141
which made the same change 10 lines down.
2010-05-05 17:59:14 -07:00
Eric Wong 1d92db8aab add Mysql2::Client#close method
This allows users to (manually) avoid the tricky case of hitting
a socket write during GC and potentially blocking the
interpreter during GC.  An explicit `close' is also useful in
situations where server resources are limited and a client only
needs to connect for a limited time.
2010-05-05 17:38:08 -07:00
Eric Wong f7a6b49cbd [cleanup] make all C symbols static
Other than the Init_$extension() function, the only reason
to have public symbols is for large C extensions that need
to span multiple .c files and we're not one of them.
2010-05-05 15:38:43 -07:00
Eric Wong 081eea9a9c [cleanup] quiet down warnings
This can help us notice real bugs in our code sooner.

Some of the unused variable warnings are pedantic from our usage
of -Wextra, but GCC >= 3 provides us with a handy attribute we
can use to mark variables unused.  -Wextra is also a default
flag for 1.9.2dev, so we might as well get used to it.
2010-05-05 15:30:34 -07:00
Eric Wong 59a823b6d5 release GVL for possibly blocking mysql_* library calls
There are still some corner-case calls which may cause
network activity and block the socket, but the majority
of reads/writes on the socket will release the GVL under
1.9 and be signal-safe under all versions of Ruby.

We'll also make a note of all functions calls that passed
visual inspection and add FIXME for a few more corner
cases we still need to fix.
2010-05-05 14:26:22 -07:00
Eric Wong fa213c9892 wrap mysql_real_connect with rb_thread_blocking_region
mysql_real_connect() is a blocking function that issues
blocking-but-interruptible connect(), read(), and write() system
calls.  So we'll allow other threads in the VM to run while
calling it since it can block indefinitely.

This introduces a rb_thread_blocking_region() wrapper for 1.8
which ensures any received signals can be handled gracefully
while inside blocking function calls.
2010-05-05 11:57:37 -07:00
Brian Lopez 33e0b9ea51 fix bug in show_variable method of AR adapter 2010-05-04 09:02:11 -07:00
Brian Lopez dfca514562 make specs a little finer grained, fix a few issues found along the way 2010-04-29 10:01:25 -07:00
Brian Lopez 61e748ddc4 add another check for valid datetime/timestamps. move to sscanf for datetime parsing 2010-04-29 00:45:22 -07:00
Brian Lopez 869783107d add undefined ref to PRIMARY const in AR adapter 2010-04-27 22:44:18 -07:00
Brian Lopez 46020e5ef5 add initial Sequel adapter 2010-04-25 23:13:27 -07:00
Brian Lopez 428eb7e79b Revert "Revert "for DATE columns, return ruby Date object instead of Time (didn't realize I could create them from y,m,d integers without ActiveSupport)""
This reverts commit 5e4080e4e5.
2010-04-25 21:45:40 -07:00
Brian Lopez f6d62225ee update AR benchmark to better reflect typecasting 2010-04-25 21:45:26 -07:00
Brian Lopez 39cfbe9824 updating files for 0.1.4 release 2010-04-23 17:49:19 -07:00
Brian Lopez deb8f43d93 Version bump to 0.1.4 2010-04-23 17:36:12 -07:00
Brian Lopez 30f1ff55fc bring the rest of the mysql adapter in, making the mysql2 adapter stand-alone 2010-04-23 00:33:22 -07:00
Brian Lopez a3bcec4fb4 wording clarification on readme 2010-04-22 14:24:19 -07:00
Brian Lopez 06fd523608 update benchmark results in readme 2010-04-22 13:57:34 -07:00
Brian Lopez 5e4080e4e5 Revert "for DATE columns, return ruby Date object instead of Time (didn't realize I could create them from y,m,d integers without ActiveSupport)"
The Date class is sooooo sllooowwww :)
Will probably look into bringing in http://github.com/rtomayko/date-performance at some point.

This reverts commit 51babb3362.
2010-04-22 12:37:05 -07:00
Brian Lopez c05138e328 build and use a cache of field names for results 2010-04-22 11:56:18 -07:00
Brian Lopez aa9f435141 fix a stupid bug when freeing the C result 2010-04-22 11:55:03 -07:00
Brian Lopez 51babb3362 for DATE columns, return ruby Date object instead of Time (didn't realize I could create them from y,m,d integers without ActiveSupport) 2010-04-21 10:28:25 -07:00
Brian Lopez eefa443c2e Implement a local resultset cache so we can free the mysql C result once we've cached it's rows in ruby land.
This allows the caller to iterate over the Mysql2::Result instance as many times as they want, lazily pulling what rows are needed from the mysql C result.
2010-04-21 01:40:28 -07:00
Brian Lopez efc66b6c06 update benchmark scripts 2010-04-21 01:31:46 -07:00