World: r3wp
[MySQL]
older newer | first last |
Dockimbel 15-Nov-2008 [1025x2] | Here's an example showing the new possibilities combined (multiple queries support, setting custom delimiter and multiple results support) : db: open mysql://[root-:-localhost]/mysql db/locals/delimiter: "*;*" insert db "show tables; show databases" copy db ; <= returns tables block! copy db ; <= returns databases block! copy db ; <= returns none! |
Enjoy ! :-) | |
Oldes 26-Nov-2008 [1027] | It looks, that there is something wrong with MySQL procedures: using mysql.r mysql> CREATE PROCEDURE myproc() SELECT 'it works!'; mysql> call myproc(); +-----------+ | it works! | +-----------+ | it works! | +-----------+ 1 row(s) in set mysql> call myproc(); mysql> On the second run it returns nothing. using it in cheyenne gives error: Error Code : 800 Description : user error ! ERROR 1312 : PROCEDURE webcore.myproc can't return a result set in the given context Near : [do-sql 'webcore "call myproc();" txt 3195] Where : none |
Gabriele 27-Nov-2008 [1028] | the cheyenne error is probably because you need the new version of mysql:// that Doc posted a few days ago |
Dockimbel 27-Nov-2008 [1029x2] | Oldes: are you sure you're using the 1.3 beta mysql:// driver ? You can find it here : http://softinnov.org/tmp/mysql-protocol-41.r |
Calling stored procedures is not supported in driver versions < 1.3. | |
Oldes 27-Nov-2008 [1031x4] | I thought I'm, but the version was older.. now it's working fine:) |
But there must be a bug anyway .... the first one shows that.. next sql query after the procedure call returns none. | |
I've send more info into private in R3-alpha... anyway.. I wonder where it's possible to find some mysql protocol spec. Do you just do reverse engineering? | |
found it http://forge.mysql.com/wiki/MySQL_Internals_ClientServer_Protocol | |
Dockimbel 27-Nov-2008 [1035] | I used to reverse-engineer, but since 5.0(?) MySQL AB documents the protocol with sometimes (intentional?) blocking errors. |
Dockimbel 28-Nov-2008 [1036x3] | After analyzing the report you sent to me about issue with sproc. MySQL has a odd behaviour, it seems to always return 2 result sets for a sproc even when you're expecting only one (the second will then be empty). So, after calling a sproc you have to call COPY twice (or once after a SEND-SQL) to flush the remaining data. I'm looking in the driver to see if I can automate this flushing process. |
Improved version of MySQL driver 1.3 beta released at http://softinnov.org/tmp/mysql-protocol-41.r Changes: - Improved automatic flushing of unread data. Now you can forgot the second COPY on sproc calls (should be robust, but needs testing). - Multiple SQL requests are now sent as one packet by default. No more need to change the db/locals/delimiter value for 4.1+ servers. | |
I might drop out the SQL requests splitting code (and also the delimiter option) from the driver as now everything is sent as-is to the server. It might still be useful for big SQL files, not sure what the best strategy should be in such case (send file as one big packet, or split it and send each request one by one) ? | |
Dockimbel 3-Dec-2008 [1039x2] | Bugfix revision for MySQL driver 1.3 beta at http://softinnov.org/tmp/mysql-protocol-41.r Changes: - Fixed a regression bug appearing when trying to open a connection without a database name. - Fixed "port not open" error after automatic reconnection. |
The change I did on [Fri 21:21] version on the way SQL requests with multiples statements are sent to the server, might not be a good idea for sending big SQL batch files to the server. The previous method (slicing SQL requests and sending them one by one to the server) wasn't that bad (could allow streaming the reading of a big SQL file from disk). Maybe it should be good to let the user choose how the driver should send multiple SQL queries. | |
Will 3-Dec-2008 [1041] | Thanks Dock! 8) |
Gabriele 3-Dec-2008 [1042] | http://softinnov.org/tmp/mysql-protocol-41.r |
Will 3-Dec-2008 [1043] | here is updated wrapper, http://reboot.ch/rebol/mysql-wrapper.txt |
AdrianS 3-Dec-2008 [1044] | Will, what does the wrapper do compared to the MySQL driver? |
Will 3-Dec-2008 [1045x3] | it is just a utilities wrapper that works on top of the mysql-protocol.r, it makes queriing mysql more rebolish |
;without wrapper: do http://softinnov.org/tmp/mysql-protocol-41.r db: open mysql://localhost/db1 nodes: send-sql/named {SELECT `id` `name` `data` FROM `node`} node: send-sql/named {SELECT `id` `name` `data` FROM `node` WHERE `id`='1'} ;with wrapper: do http://softinnov.org/tmp/mysql-protocol-41.r do http://reboot.ch/rebol/mysql-wrapper.txt .db/databases: [ db1 mysql://localhost/db1 db2 mysql://localhost/db2 ] .db/use 'db1 nodes: .db/get/all 'node [id name data] none node: .db/get 'node [id name data] [{`id`=?} 1] ;if you follow the rule to name your primary-key "id", ;you can use this shorter version: node: .db/get 'node [id name data] 1 ;/debug is your friend, use it to see the generated query | |
.db/get/debug 'node 'id 1 ; "SELECT `id` FROM `node` WHERE id=1.0 LIMIT 0,1" | |
AdrianS 3-Dec-2008 [1048] | thanks - is there a page somewhere describing it in more detail? |
Will 3-Dec-2008 [1049x3] | sorry it is still rought and there is no docs, thought some comments in the code exists, I use it in production so, solid it must be. |
and I will be glad to answer any questions and add feature requests 8) | |
use /debug it will print query to the console without sending it to the server so you can play and understand how it works | |
Graham 12-Dec-2008 [1052x3] | just installed mysql on ubuntu 8.1 but can't login ... |
get "Access denied for user ['root'-:-'localhost'] (using password: No ) | |
I thought root was automatically created with no password?? | |
Dockimbel 13-Dec-2008 [1055] | What does read dns://127.0.0.1 give you? It may be related to a mismatch in the localhost name mapping, so you have to add access rights for root@... (or [root-:-127-:-0-:-0-:-1]) in MySQL to workaround that issue. |
Graham 13-Dec-2008 [1056] | I think that someone had setup a password ... so I purged mysql, deleted my.cnf and reinstalled. That worked. |
Gabriele 18-Dec-2008 [1057x5] | Doc, the read-packet function in mysql-protocol.r is missing one word in the /local list. Line 538: |
read-packet: func [port [port!] /local packet-len pl status][ | |
should be: | |
read-packet: func [port [port!] /local packet-len pl status tmp][ | |
(mysql-protocol-41.r) | |
Dockimbel 18-Dec-2008 [1062] | Thanks for the report, I'll fix that in the next beta release. There's also other fixes from Will pending. |
ManuM 23-Dec-2008 [1063] | . . |
[unknown: 5] 23-Dec-2008 [1064] | I have installed mySQL and Oracle as part of my studies for improving TretbaseDB. I'm curious from others that use mySQL with REBOL as to what they dislike about the interoperablility or what they like most about it. |
amacleod 13-Jan-2009 [1065] | I'm trying to upload a binary (image) file to a mysql DB. When I retrieve it teh binary data seems to have changed and I can not display the image. I was able to do it with sqlite with no problem. I'm using the mediumblob field type for the image data... Any ideas what I might be doing wrong? |
Will 13-Jan-2009 [1066] | ca you diff the binary data of the image before you send it to db and after retriving it? also once the data is inserted thru mysql-protocol can you retrive the image from the db with another client and see if it works? |
amacleod 13-Jan-2009 [1067] | diff? |
Will 13-Jan-2009 [1068x4] | http://en.wikipedia.org/wiki/Diff |
can you diff.. | |
btw, I suggest not to store images in the db, store it somewhere on your hardrive and put in the db a pointer to the file, if you really need it and do not find ehat's wrong, ping me in the weekend and I can test that here, althougt I use other binary data with mysql-protocol with no problem, not sure if it apply but check also encodings for mysql storage, etc | |
ehat -> what | |
amacleod 13-Jan-2009 [1072] | I got it.... I have to convert it back to binary. ("to-binary") I assumed that if I was giving it a binary file it would remain in binary just as sqlite treated it....The field attributes state "binary". Thanks for the help, Will! |
Davide 1-Mar-2009 [1073] | Is there a MySQL guru around ? I need to optimize this query: SELECT A.cod, A.date , SUM(B.amount) AS amount, COUNT( * ) AS numrow FROM A INNER JOIN A AS B ON A.cod=B.cod AND B.date <= A.date WHERE A.cod IS NOT NULL GROUP BY A.cod, A.date This return "running sums" (partial sum for every date and every cod). Both cod and date are indexed. In a table of about 100'000 records it takes 104 sec to complete while in SQL server 2005 (the same query, on the same data, on the same index ) it takes 3 sec ! I've tried to use MyIsam, InnoDB, MEMORY storage, and used BOTH btree and hash index. I've tried to FORCE Index for Join and Group too. Any suggest ? |
Oldes 2-Mar-2009 [1074] | is there any reason why you join A on A? also.. have you tried to EXPLAIN the query? http://dev.mysql.com/doc/refman/5.0/en/explain.html |
older newer | first last |