r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[MySQL]

Dockimbel
10-Jan-2006
[509]
MySQL server protocol has changed since 4.1.0 (with a big evolution 
starting from 4.1.1) and is not compatible with the older protocol. 
Strangely, server v5 allow clients to connect with the older (pre-4.1) 
protocol providing the good flags...(that's odd). Need more investigation 
to see if the old driver can still be used reliably with v5.
Pekr
10-Jan-2006
[510x3]
maybe better as a refinement of scramble itself ...
that is what I wanted to ask - did it really change?
I thought there is v9 and v10 protocols, and that only change was 
for auth. scheme ...
Dockimbel
10-Jan-2006
[513x2]
From 4.1.1, there's a lot of changes in the protocol, mainly a lot 
of new fields.
The protocol number hasn't been incremented, the server and client 
code in libmysql is messy...
Pekr
10-Jan-2006
[515x3]
so this is not accurate? http://www.redferni.uklinux.net/mysql/MySQL-Protocol.html
it seems to me as proper description of all communication phases 
...
well - so why it works so far for me?
Dockimbel
10-Jan-2006
[518]
yes it is, AFAICT. But it's protocol 4.1.1+, not the old one that 
is implemented in my driver.
Pekr
10-Jan-2006
[519x3]
aha, so actually what I did is that I extended parser for greetings 
phase, and also updated some locals table, watching carefully where 
such items are used - so far so good ...
I would be able to write it according to specs imo according to above 
protocol, but - I don't understand rebol port model, so :-(
and also - I would fire all old scrambler :-) but then old pre 4.11 
users would be at ends :-)
Dockimbel
10-Jan-2006
[522]
The server has still the support code for all protocol versions. 
That's why the old code is working, but according to the flags, (especially 
protocol_41), it should have rejected your connection. That's why 
I found it odd that your code was working. Anyway, let try to use 
this to make it work with the older code.
Pekr
10-Jan-2006
[523]
or do you think that checksum/secure could be used even for older 
mysql versions? I wonder if their scheme used sha1 in old days?
Dockimbel
10-Jan-2006
[524]
no, it wasn't 'sha1, it was a "poor man" hashing method.
Pekr
10-Jan-2006
[525]
I think I know why ... maybe :-) ..... simply put, I don't send protocol_41 
back after the greetings phase ...
Dockimbel
10-Jan-2006
[526]
Yes, I guess that's the trigger.
Pekr
10-Jan-2006
[527x2]
hmm, I will try to change that here :-)
latest version: http://www.rebol.cz/mysql/mysql-protocol-new.r
Dockimbel
10-Jan-2006
[529x2]
Ok, I'll make some changes to your code to make it work properly 
with 3.x and 4.1.x+ versions, then I'll launch my unit tests and 
see if it  is ok.
Your code doesn't deal with empty passwords, I'll fix that.
Pekr
10-Jan-2006
[531]
I know ... thanks ....!!!
Dockimbel
10-Jan-2006
[532x4]
New My
New MySQL driver version 1.0.0 supporting server v4.1.1+ : http://softinnov.org/tmp/mysql-protocol.r
This is a beta release, please report here any bugs.
This driver has not been tested with server version 3.x.
Dockimbel
11-Jan-2006
[536]
Softinnov.org was down for a couple of hours for server PSU replacement. 
The download link works now again.
Coccinelle
12-Jan-2006
[537]
Dock, if you publish a new version of mysql-protocol.r, it's time 
to make the correction of the bug in the init function, the longlong 
conversion and in the data reading initialization.
Pekr
12-Jan-2006
[538x3]
what bugs?
have you any fixes?
what is wrong with init, longlong conversion and in data reading 
initialisation in particular?
Coccinelle
12-Jan-2006
[541]
The init function fails with this for eaxample :

   open join mysql://user:[password-:-my-:-super-:-server]/my-db? "select * 
   from my-table"
or something like that I don't remember
Pekr
12-Jan-2006
[542x2]
I would expect that - why is your db query part of opening sequence?
with read, it would make sense ...
Coccinelle
12-Jan-2006
[544]
Yes perhaps, it fails also with read
Pekr
12-Jan-2006
[545]
I am of course for fixing all possible bugs, but just now simply 
everything seems to work, we are able to connect to new dbs, that 
was main point ...
Coccinelle
12-Jan-2006
[546x3]
Here is the correction of the init function :
;------ Public interface ------

    init: func [port [port!] spec /local scheme args][

;    	either args: find spec #"?" [                              
                   ; removed

;    		spec: sys-copy/part spec args                             
 ; removed

;    		fast-query: dehex sys-copy next args                   ; removed

;    	][                                                         
                                       ; removed

;    		fast-query: none                                          
              ; removed

;    	]                                                          
                                        ; removed
        if url? spec [net-utils/url-parser/parse-url port spec] 
        scheme: port/scheme 
        port/url: spec 
        if none? port/host [

            net-error reform ["No network server for" scheme "is specified"]
        ] 
        if none? port/port-id [

            net-error reform ["No port address for" scheme "is specified"]
        ]

     either all [port/target args: find port/target #"?"] [           
                   ; added

      port/target: sys-copy/part port/target args                      
       ; added

      fast-query: dehex sys-copy next args                             
       ; added

     ][                                                               
                                                 ; added

      fast-query: none                                                 
                       ; added

     ]                                                                
                                                 ; added
        if none? port/target [

      net-error reform ["No database name for" scheme "is specified"]
        ]
        if none? port/user [port/user: make string! 0]
        if none? port/pass [port/pass: make string! 0]
        if port/pass = "?" [port/pass: ask/hide "Password: "]
    ]
For the lonlong conversion, the conversion model is initialized to 
none. It should be initialized to integer like this :
	conv-model: [
		decimal			[to decimal!]
		tiny			[to integer!]
		short			[to integer!]
		long			[to integer!]
		float			[to decimal!]
		double			none
		null			none
		timestamp		none
;		longlong		none		; Removed
		longlong		[to integer!]	; Added
		int24			[to integer!]
		date			[to date!]
		time			[to time!]
		datetime		[to date!]
		year			[to integer!]
		newdate			none
		enum			none
		set				none
		tiny-blob		none
		medium-blob		none
		long-blob		none
		blob			none
		var-string		none
		string			none
	]
And the last bug is that the "byte" word is not initialized to none 
and this cause a problem but I don't remember the effect :
;------ Data reading ------


;	b0: b1: b2: b3: int: int24: long: string: field: len: none	; Removed

 b0: b1: b2: b3: int: int24: long: byte: string: field: len: none	; 
 Added
Pekr
12-Jan-2006
[549x3]
nice - so, let's wait what Doc thinks about it ....
the truth is, that I met with no problem so far using current scheme 
....
but as I said - I am not sure, if ?query-here should work for other 
than 'read attempt .... 'open should imo only be provided with url 
plus target db, not query itself ...
Coccinelle
12-Jan-2006
[552x2]
I sent the bug and the correction to Doc some (many) month ago.
Here is the exact bug caused by the initi function (the bug was already 
found in november 2003)
>> db: open mysql://narg:?@host/bicycle
** Access Error: Cannot connect to narg
** Where: open-proto
** Near: db: open mysql://narg:?@host/bicycle
Dockimbel
12-Jan-2006
[554x5]
Fix #1 : Byte word added to local context.
Longlong conversion: I don't agree with you. The server returns a 
64-bits integer that you're casting to 32-bits integer, so your losing 
half of the data. Btw, even casting it to decimal! which is 64-bits 
wide won't be accurate because of the integer to floating point conversion 
issues. That's why I've left it to none (means keep it in raw string! 
format) and let each user decide how to process it. (The driver provides 
the 'change-type-handler global function to change that easily)
Fix #2 : port init now correctly handle '?' marker. I've used your 
patch as is. Works well with all my tests. Thanks for providing the 
fix for this long standing bug.
If anyone has some other patches, let publish it here. I'll wait 
a few more days before closing the beta state and declaring this 
version the new stable one.
New version 1.0.1 including these fixes available (http://softinnov.org/tmp/mysql-protocol.r).