Jeremy K. wrote:
driver + mysql411 is more compatible, but clearly isn’t good enough.
Use the C bindings.
jeremy
The problem in connecting is not in the AR adapter (I have checked the
parameters being passed in to the real_connect call) - it happens within
the real_connect method of the mysql.rb driver.
Looking harder at this, it is clear that the problem is not with the
driver in its original form (version 0.2.6) from
Ruby/MySQL
but with the patch applied to it to make it work with MySQL 4.1.1 and
above.
Whereas the mysql411.rb overlay that you used in the previous release
candidate did a check based on the MySQL version string, the patch looks
at flags in the @server_capabilities. The flags themselves look
sensible; for me, on first connection to MySQL 4.0.13, they are:
Server capabilities: 8236
Long password: false
Found rows: false
Long flag: true
Connect with db: true
No schema: false
Compress: true
ODBC: false
Local files: false
Ignore space: false
Protocol 41: false
Interactive: false
SSL: false
Ignore SIGPIPE: false
Transactions: true
Reserved: false
Secure connection: false
but the way they are being used to switch between old and new (4.1.1+)
behaviour is totally broken:
CLIENT_PROTOCOL_41 = 1 << 9
…
CLIENT_SECURE_CONNECTION = 1 << 15
…
PROTO_AUTH41 = CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION
…
if !@server_capabilities & PROTO_AUTH41 # ***** !!!
# old behaviour
else
# new behaviour
end
This broken condition (which always evaluates to false, because
@server_capabilities is a Fixnum, so !@server_capabilities is false)
appears in lines 130, 208, 273, 287, 405 and 419.
At line 144, there’s even:
if PROTO_AUTH41
(and the preceding line, from the original code:
if db and @server_capabilities & CLIENT_CONNECT_WITH_DB != 0 then
shows how to express these conditions properly).
So… it looks as if this patch was never tested with MySQL 4.0. Given
the elementary nature of the errors, the whole patch needs very careful
inspection.
regards
Justin