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
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
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
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
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
3155cb799e
fix copy-paste fail found by @marius
2010-04-09 08:56:30 -07:00
Brian Lopez
8f93f830c1
add affected_rows method (mysql_affected_rows)
2010-04-07 09:47:45 -07:00
Brian Lopez
e20df5c140
add last_id method (last_insert_id)
2010-04-07 09:36:36 -07:00
Brian Lopez
3a32dc79ec
reconnect by default
2010-04-07 09:23:14 -07:00
Brian Lopez
7131752757
add initial async query support
2010-04-07 09:16:30 -07:00
Brian Lopez
80a8602fbb
borrow the more flexible extconf from the mysqlplus project
2010-04-07 07:03:31 -07:00
Brian Lopez
11216551cd
typo
2010-04-06 15:32:36 -07:00
Brian Lopez
db454d3f15
initial stab at finding mysql headers easier
2010-04-06 15:26:09 -07:00
Brian Lopez
ec40ee8f06
add ssl support
2010-04-05 23:30:36 -07:00
Brian Lopez
807f0a2730
slight change to socket monitoring loop per code-review from @tmm1
2010-04-05 21:13:13 -07:00
Brian Lopez
3357d3b077
show who we're talking about ;)
2010-04-05 20:53:32 -07:00
Brian Lopez
c2fd214cb4
convert over to mysql_send_query/mysql_read_query_result non-blocking API
2010-04-05 20:51:59 -07:00
Brian Lopez
7bac2c520a
add Mysql2::Error exception type, use it
2010-04-04 23:46:42 -07:00
Brian Lopez
9b59478cf6
allow access to file descriptor in C, EventMachine anyone? ;)
2010-04-04 23:31:32 -07:00
Brian Lopez
c439865a1f
remove invalid errors for valid queries without results
2010-04-04 12:58:41 -07:00
Brian Lopez
cdb4137979
whitespace
2010-04-04 12:17:40 -07:00
Brian Lopez
0a733a1f02
finally add real date/time/datetime parsing
2010-04-03 16:51:10 -07:00
Brian Lopez
b820100249
add Mysql2::Client#info and Mysql2::Client#server_info methods
2010-04-03 12:15:16 -07:00
Brian Lopez
677c309963
compare length of original and escaped string, if they match return the original
2010-04-03 01:42:15 -07:00
Brian Lopez
1b9e35712f
add support for setting MYSQL_OPT_CONNECT_TIMEOUT setting
2010-04-03 01:36:30 -07:00
Brian Lopez
2f380fd0ff
bugfix or escape method
2010-04-03 01:35:41 -07:00
Brian Lopez
799f9809d0
must connect with a user, show errors again
2010-04-02 20:24:13 -07:00
Brian Lopez
82e2a1de21
add initial support for connecting with options
2010-04-02 20:14:29 -07:00
Brian Lopez
6c76cbbda0
return the actual value for TINY fields - let the caller coerce into bool
2010-04-02 16:32:18 -07:00
Brian Lopez
559bd3d426
reorg vars
2010-04-02 16:14:03 -07:00
Brian Lopez
872bdb0caf
rename method to each, seek dataset to beginning on each call of #each
2010-04-02 15:32:58 -07:00
Brian Lopez
d90e2a3187
remove fetch_row(s) methods, mixin Enumerable
2010-04-02 11:18:13 -07:00
Brian Lopez
b5f22d7c05
check charsetnr flag as well
2010-04-01 14:45:58 -07:00
Brian Lopez
bbf7585d09
use binary encoding on fields that have the binary flag set
2010-04-01 14:29:20 -07:00
Brian Lopez
bd25b31731
formatting
2010-04-01 12:58:31 -07:00
Brian Lopez
858523d7a9
force string encoding to utf8 in 1.9
2010-04-01 12:56:49 -07:00
Brian Lopez
953f547f79
some misc cleanup
2010-04-01 12:04:48 -07:00
Brian Lopez
631456fc58
add escape method
2010-04-01 11:44:59 -07:00
Brian Lopez
7e64570770
turn off debug symbols again, put back benchmark script
2010-03-31 08:56:07 -07:00
Brian Lopez
26619b10b6
misc updates
2010-03-30 23:54:07 -07:00
Brian Lopez
1848b0da4a
mostly flesh out mysql type to ruby type conversion mapping
2010-03-30 23:30:06 -07:00
Brian Lopez
c844c66046
add initial type checking and ruby object creation from resultset
2010-03-30 17:55:16 -07:00
Brian Lopez
ce559dded2
temporarily print error msgs to stdout
2010-03-30 16:41:02 -07:00
Brian Lopez
736c0d6cd3
result hash keys can be symbols using the :symbolize_keys option with #fetch_row, #fetch_rows or #each. Renamed extension from MySQL to Mysql2. Initial Rakefile and spec dir
2010-03-30 09:56:24 -07:00
Brian Lopez
8713288574
renaming again ;)
2010-03-30 09:20:55 -07:00
Brian Lopez
e6ab4c089a
move files into ext/
2010-03-30 09:19:05 -07:00