Commit Graph

101 Commits

Author SHA1 Message Date
Lourens Naudé
931765ee05 Extract a GET_ENCODING macro 2010-08-11 11:25:20 -07:00
Luis Lavena
4c27a1e4fc extconf detect properly mingw. 2010-08-12 02:19:04 +08:00
Brian Lopez
5a9ca9c76f app_timezone defaults to nil 2010-08-09 14:50:58 -07:00
Brian Lopez
b448b98146 move -Wextra to development flags area 2010-08-06 11:19:34 -07:00
Brian Lopez
99af726a58 application_timezone is allowed to be nil 2010-08-06 00:01:09 -07:00
Brian Lopez
ad34357e57 convert :timezone option into two new ones
:database_timezone - the timezone (:utc or :local) Mysql2 will assume time/datetime fields are stored in the db. This modifies what initial timezone your Time objects will be in when creating them from libmysql in C
and
:application_timezone - the timezone (:utc or :local) you'd finally like the Time objects converted to before you get them
2010-08-05 22:50:45 -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
12c022c8aa move most previously global symbols to static to prevent conflicts (thanks for catching this Eric) 2010-08-04 19:32:14 -07:00
Brian Lopez
2bb8721e84 respect :symbolize_keys option for Mysql2::Result#fields if it's called before the first row is built 2010-08-04 00:54:05 -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
1a70e83a74 Revert "libmysql only allows one query be sent at a time per connection, bail early if that's attempted"
This reverts commit 3ff7baa5f8.
2010-08-03 20:22:44 -07:00
Brian Lopez
3ff7baa5f8 libmysql only allows one query be sent at a time per connection, bail early if that's attempted 2010-08-03 20:21:51 -07:00
Brian Lopez
94ae2a781d no need to carry over options twice as we're already doing it up in rb_mysql_client_async_result 2010-08-03 19:04:30 -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
6142336e59 use a default (year 2000) for TIME field casting to a Time object, like AR does 2010-08-01 20:23:27 -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
c6230c3cec pluck out Mysql2::Client definition into it's own c/h file 2010-07-29 23:25:15 -07:00
Brian Lopez
dd138de8e1 invalidate the file descriptor on close 2010-07-28 11:31:32 -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
9ab1c90d2b don't raise exception on close, for a closed connection 2010-07-20 09:12:47 -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
d8f5f4de1d on second thought, we should make sure we were given a string earlier on 2010-07-10 10:32:46 -07:00
Brian Lopez
645b9a1bef no need to Check_Type in these spots since we're using StringValuePtr as well 2010-07-09 09:59:48 -07:00
Brian Lopez
ab032b99db make sure the query string is converted to the connection's encoding before it's handed to libmysql 2010-07-08 22:51:19 -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
c38525d11a extracting Mysql2::Result class to be inside result.c 2010-07-06 14:21:58 -07:00
Aaron Patterson
a6b1247ede partial implementation of result in Ruby 2010-07-06 13:16:49 -07:00
Aaron Patterson
74e99bae5f refactoring initialize to be done in ruby, adding setter methods for connection options 2010-07-04 19:29:12 -07:00
Aaron Patterson
e7b43a8c41 StringValuePtr() will automatically do Check_Type() for us 2010-07-02 09:58:46 -07:00
Aaron Patterson
ff55ef5c87 remove mysql2_client_wrapper struct, refactor open connection requirement to a macro 2010-07-01 10:01:19 -07:00
Aaron Patterson
8c96aa1fcd refactoring C to use the allocate function 2010-07-01 09:15:52 -07:00
Aaron Patterson
6ef738200d moving the error class to ruby 2010-06-30 10:10:59 -07:00
Aaron Patterson
0b36eae450 moving requires to the .rb files 2010-06-30 09:36:42 -07:00
Aaron Patterson
3468f12a83 small refactor of extconf.rb 2010-06-30 08:53:34 +08: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
bd3c39f819 formatting 2010-06-11 08:51:55 -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
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
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
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