Commit Graph

64 Commits

Author SHA1 Message Date
dan sinclair 9d49728c30 add em_fiber spec 2010-11-26 22:42:09 -05:00
Brian Lopez d48846f13b add support for :read_timeout to be set on a connection 2010-11-09 12:27:04 -08:00
Brian Lopez 1057f976d0 ensure the query is a string earlier in the Mysql2::Client#query codepath for 1.9 2010-10-31 10:11:59 -07:00
Brian Lopez 410e914411 only run the EM specs if EM is installed 2010-10-17 17:34:34 -07:00
Brian Lopez 22c9ff48a8 some more rspec2 changes, organize rake tasks 2010-10-17 16:51:14 -07:00
Brian Lopez ba4f3612b6 move to rspec2 2010-10-17 16:34:09 -07:00
Brian Lopez c394122fd9 add some more defaults to the connect flags 2010-10-14 23:38:25 -07:00
Brian Lopez a17ba07c75 a couple of minor updates to connection management with some specs 2010-10-06 10:33:52 -07:00
Anton Mironov 687487d5a5 Detach before executing callbacks.
This allows to make queries in callbacks.
2010-09-28 13:47:19 +08:00
Brian Lopez 2ae908c512 make sure we don't hit a race condition if this EM spec is taking longer to run than normal 2010-09-27 13:25:10 -07:00
Brian Lopez 98fbeb6f64 add aliases for Mysql compatibility 2010-09-01 11:42:16 -07:00
Brian Lopez ae6c33a13f add cache_rows option to enable/disable internal row caching for results 2010-08-27 12:08:48 -07:00
Brian Lopez 3b2e7602a0 formatting fix so I collapse in TM 2010-08-24 09:27:29 -07:00
Eric Wong 1100288eba avoid stack overflow when escaping large strings
Attempting to escape large, untrusted strings cause stack
overflows (easier under Ruby 1.9 using pthreads) leading to
SystemStackError on small overflows and segmentation faults on
large overflows.  Instead of allocating on the stack, we'll
allocate a string buffer from the heap.

This has the unfortunate effect of reducing escape performance
for common cases, but in my experience SQL escaping isn't much
of a bottleneck.

For reference, Ruby 1.9.2-p0 with pthreads gets a stack size of
512K and the default process stack size is 8MB on both x86 and
x86_64 Linux.
2010-08-24 05:24:35 +00:00
Brian Lopez a19888e939 Make sure we switch over to the DateTime class for DATETIME/TIMESTAMP columns that are out of the supported range for 32bit platforms 2010-08-20 12:07:27 -07:00
Aaron Patterson ce77899848 connection flags can be passed to the constructor 2010-08-20 09:56:36 -07:00
Aaron Patterson 864cf0f291 exposing client flags 2010-08-20 09:36:15 -07:00
Eric Wong 8bfbfa2708 fix signal handling when waiting on queries
This reverts the single-threaded select() optimization from
commits 9a63a587c0 and
0190457dbd.

Under Ruby 1.9, the reverted optimization caused signal handlers
to be delayed until the socket became readable.

Under Ruby 1.8, matters are worse as receiving a signal during
select() causes Errno::EINTR to be raised.

There is now a (somewhat fragile) spec for testing signal
handling during a "SELECT sleep(2)" query.

Furthermore, the performance difference I measured on
benchmark/thread_alone.rb was negligible (over 1000 iterations)
between the two:

Ruby 1.8.7-p249
  Rehearsal ----------------------------------------------------
  select             0.040000   0.020000   0.060000 (  0.119448)
  rb_thread_select   0.050000   0.020000   0.070000 (  0.132091)
  ------------------------------------------- total: 0.130000sec

                         user     system      total        real
  select             0.030000   0.030000   0.060000 (  0.116471)
  rb_thread_select   0.050000   0.020000   0.070000 (  0.119874)

Ruby 1.9.2-p0
  Rehearsal ----------------------------------------------------
  select             0.050000   0.030000   0.080000 (  0.134208)
  rb_thread_select   0.080000   0.000000   0.080000 (  0.141316)
  ------------------------------------------- total: 0.160000sec

                         user     system      total        real
  select             0.050000   0.020000   0.070000 (  0.123325)
  rb_thread_select   0.060000   0.010000   0.070000 (  0.124075)

Benchmarks were performed on an _empty_ mysql2_test table to
maximize the relative time for the select(2)-related code path
(vs reading data).  The test was run on Debian Lenny, x86_64 and
a stock 2.6.35.2 Linux kernel.  Hardware was a Core2 Duo @
1.6GHz with the performance CPU governor while on AC power
to eliminate CPU speed fluctuations during the test.
2010-08-18 20:13:13 -07:00
Lourens Naudé d9153b82fc Save on coercion overhead for zero value decimal and float column values 2010-08-11 11:25:20 -07:00
Lourens Naudé c5d9b7ff65 Introduce test case for Mysql2::Client in multi-threaded environments 2010-08-11 11:25:20 -07:00
Brian Lopez 254f42f502 no need for AR specs since the adapter was moved to Rails core 2010-08-09 22:11:47 -07:00
Brian Lopez 2514fafa53 add :cast_booleans option for automatically casting tinyint(1) fields into true/false for ruby 2010-08-05 00:39:11 -07:00
Brian Lopez c0cf2f13a0 let's try that again - libmysql only allows one query be sent at a time per connection, bail early if that's attempted 2010-08-03 20:37:49 -07:00
Brian Lopez 5f81996122 fixes for 1.9 2010-08-02 02:07:11 -07:00
Brian Lopez fc6c24a20c add support for configuring which timezone Time objects should be created in 2010-08-02 01:20:03 -07:00
Brian Lopez 36c243be71 Add cascading options hash at Mysql2::Client.default_query_options, which can be overridden by passing options to Mysql2::Client#query and/or Mysql2::Result#each
Tune up specs, benchmarks and AR adapter to conform
2010-08-01 20:20:48 -07:00
Brian Lopez 9eb3917328 get rid of some warnings 2010-07-29 23:22:42 -07:00
Brian Lopez c614c89216 remove spec checking for exception raised when closing a closed connection as we don't do that anymore 2010-07-21 13:14:43 -07:00
Brian Lopez cd1a2bf9ff Revert "force reconnect behavior to true, remove open connection checks since libmysql will handle this for us now"
This reverts commit 70a7298dc3.
2010-07-21 12:13:27 -07:00
Brian Lopez 70a7298dc3 force reconnect behavior to true, remove open connection checks since libmysql will handle this for us now 2010-07-21 11:47:16 -07:00
Brian Lopez edb742fee7 check for and support field-level encodings
raise an exception for invalid encodings passed to Mysql2::Client#new
2010-07-10 23:15:54 -07:00
Brian Lopez e385e7cf6b Initial refactor of encoding support to ensure we map Ruby encodings to MySQL encodings properly. 2010-07-08 22:22:20 -07:00
Aaron Patterson a265d36571 spec helper is in the load path, so no need for expand_path funny business 2010-07-06 15:41:44 -07:00
Aaron Patterson 04b9fe17cc made extension more rake-compiler friendly, made the spec task depend on "compile" 2010-06-30 08:20:42 +08:00
Brian Lopez fdf3e53933 add Mysql2::Client#fields method 2010-06-19 16:24:02 -07:00
Brian Lopez d033823b3c respect Encoding.default_internal for strings returned by Mysql2::Client#info and Mysql2::Client#server_info 2010-06-14 18:14:28 -07:00
Brian Lopez 6751a98873 use Encoding.default_internal 2010-06-13 15:50:03 -07:00
Brian Lopez ef37f7ef76 spec fix for ruby 1.9.2+ 2010-06-13 14:50:02 -07:00
Brian Lopez d4beaf3059 apply proper fix for timezone support, and fix specs accordingly 2010-06-08 15:16:37 -07:00
Brian Lopez 82718e6dad fix specs under 1.9.2 preview3 2010-06-01 23:40:16 -07:00
Brian Lopez c7e9ecdcbd fix timezone handling in the AR adapter 2010-06-01 11:17:59 -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 46021b9351 fix boolean casts 2010-05-10 01:18:05 -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
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
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 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 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 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