Permalink
Browse files

r3435@asus: jeremy | 2005-12-10 13:40:43 -0800

 Apply [3274] to stable.  MySQL: fixes for the bundled mysql.rb driver.  Closes #3160.


git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/stable@3275 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 65e93a5 commit 4ef417cf963fb6e6ecb81140583d42d59507abe5 @jeremy jeremy committed Dec 10, 2005
Showing with 11 additions and 8 deletions.
  1. +2 −0 activerecord/CHANGELOG
  2. +9 −8 activerecord/lib/active_record/vendor/mysql.rb
@@ -1,5 +1,7 @@
*SVN*
+* MySQL: fixes for the bundled mysql.rb driver. #3160 [Justin Forder]
+
* MySQL, PostgreSQL: reconnect! also reconfigures the connection. Otherwise, the connection 'loses' its settings if it times out and is reconnected. #2978 [Shugo Maeda]
* SQLServer: fix obscure optimistic locking bug. #3068 [kajism@yahoo.com]
@@ -127,7 +127,8 @@ def real_connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, socket=nil, f
flag |= @client_flag | CLIENT_CAPABILITIES
flag |= CLIENT_CONNECT_WITH_DB if db
- if 0 == @server_capabilities & PROTO_AUTH41
+ @pre_411 = (0 == @server_capabilities & PROTO_AUTH41)
+ if @pre_411
data = Net::int2str(flag)+Net::int3str(@max_allowed_packet)+
(user||"")+"\0"+
scramble(passwd, @scramble_buff, @protocol_version==9)
@@ -141,7 +142,7 @@ def real_connect(host=nil, user=nil, passwd=nil, db=nil, port=nil, socket=nil, f
end
if db and @server_capabilities & CLIENT_CONNECT_WITH_DB != 0
- data << "\0" if 0 == @server_capabilities & PROTO_AUTH41
+ data << "\0" if @pre_411
data << db
@db = db.dup
end
@@ -202,7 +203,7 @@ def store_result()
end
def change_user(user="", passwd="", db="")
- if 0 == @server_capabilities & PROTO_AUTH41
+ if @pre_411
data = user+"\0"+scramble(passwd, @scramble_buff, @protocol_version==9)+"\0"+db
else
data = user+"\0"+scramble41(passwd, @scramble_buff)+db
@@ -267,7 +268,7 @@ def list_dbs(db=nil)
def list_fields(table, field=nil)
command COM_FIELD_LIST, "#{table}\0#{field}", true
- if 0 == @server_capabilities & PROTO_AUTH41
+ if @pre_411
f = read_rows 6
else
f = read_rows 7
@@ -281,7 +282,7 @@ def list_fields(table, field=nil)
def list_processes()
data = command COM_PROCESS_INFO
@field_count = get_length data
- if 0 == @server_capabilities & PROTO_AUTH41
+ if @pre_411
fields = read_rows 5
else
fields = read_rows 7
@@ -399,7 +400,7 @@ def read_query_result()
end
else
@extra_info = get_length(data, true)
- if 0 == @server_capabilities & PROTO_AUTH41
+ if @pre_411
fields = read_rows(5)
else
fields = read_rows(7)
@@ -413,7 +414,7 @@ def read_query_result()
def unpack_fields(data, long_flag_protocol)
ret = []
data.each do |f|
- if 0 == @server_capabilities & PROTO_AUTH41
+ if @pre_411
table = org_table = f[0]
name = f[1]
length = f[2][0]+f[2][1]*256+f[2][2]*256*256
@@ -440,8 +441,8 @@ def unpack_fields(data, long_flag_protocol)
decimals = f[6][9]
def_value = ""
max_length = 0
- ret << Field::new(table, org_table, name, length, type, flags, decimals, def_value, max_length)
end
+ ret << Field::new(table, org_table, name, length, type, flags, decimals, def_value, max_length)
end
ret
end

0 comments on commit 4ef417c

Please sign in to comment.