TclSqueak - new life for Tcl.
New Version mysqltcl 3.052 (10.2012)
mysqltcl was described in March LinuxFocus online magazine
I have put all source code to github. Also the branch (pstamtent) for prepared statement support that I have never finished.
New in Version 3.052
New in Version 3.051
New in Version 3.04
New in Version 3.03
New in Version 3.02
New in Version 3.01
Complete Change Log
|version||-encoding value||write data||read data||2.14||option encoding not exists||Tcl_UtfToExternal [encoding system]||Tcl_NewByteArrayObj||2.20||encoding not set||Tcl_UtfToExternal [encoding system]||Tcl_ExternalToUtf [encoding system]||-encoding binary||Tcl_GetByteArrayFromObj||Tcl_NewByteArrayObj||-encoding iso8859-1||Tcl_UtfToExternal iso8859-1||Tcl_ExternalToUtf iso8859-1|
Thanks to Jean-Luc Fontaine http://jfontain.free.fr for some patches.
Thanks to Alexander Schoepe for initial patch for -encoding option support.
Please conntact by bugs reports, installing problems or if you want to develop next version. Bugs Reports (email@example.com)
export CPP=/usr/bin/cpp ./configure --with-tcl=/usr/local/lib/tcl8.3 --with-tclinclude=/usr/local/include/tcl8.3 --with-mysql-include=/usr/local/include/mysql --with-mysql-lib=/usr/local/lib/mysql make make installInstalling under OpenBSD 3.1. Thanks to Fredrick Leitz.
LDFLAGS="-I/usr/local/lib/mysql -I/usr/local/lib/tcl8.3" CPPFLAGS="-I/usr/local/include/mysql -I/usr/local/include/tcl8.3/generic" export LDFLAGS CPPFLAGS ./configure make make install
./configure CC=gcc --with-mysql-include=/Library/MySQL/include/mysql --with-mysql-lib=/Library/MySQL/lib/mysql/thanks to Justin Dewind
./configure --with-mysql-include=/sw/include/mysql --with-mysql-lib=/sw/lib/mysql --with-tcl=/sw/lib --with-tclinclude=/sw/includethanks to eric lebel
This error happens when you have used mysqlexec command with SQL select command, that normally should return result set. The next mysql command (mysqlsel mysqlexec mysqlmap) causes that error. You can use mysqlexec only for (INSER, DELETE and UPDATA Sql commands). For SELECT command you should use mysqlsel mysqlquerry mysqlmap mysqreceive.
Segmentation fault by connecting mysql with version earlier than 3.23.50
The earlier version of mysql have had bug in mysql_option function that was fixed in 3.23.50 see mysql changes log News 3.23.50. This can happens to Debian user of very old and "very stable" release. If you do not want to upgrade your system, please use mysqltcl 2.50 or later or comment out the line from mysqltcl.c file. Then the .my.cnf file will be not recognized.
How mysqltcl handles UNI-coded (UTF8) strings till version 2.14?
All sql statments are converted to external representation by using
Tcl_UtfToExternalDString function before sending to database.
This function use character set specified by [encoding system] variable.
All data read from database are treated as byte array. (By using function
If you want to convert this data to your representation use tcl function [encoding convertto ?encoding? string].
In Version 2.20 another way was chosen please read manual section mysqlconnect option -encoding.
The compilation and installation was OK but I got the message: "couldn't load file "libmysqltcl2.12.so": libmysqltcl2.12.so: cannot open shared object file: No such file or directory"
mysqltcl is dynamical linked with libmysqlclient. If the libmysqlclient library is not in the dynamical library path mysqltcl could not be loaded. Try "ldd libmysqltcl2.12.so" to see all dependences.
ldd libmysqltcl2.12.so libmysqlclient.so.10 => /usr/local/mysql/lib/mysql/libmysqlclient.so.10 (0x40007000) libc.so.6 => /lib/libc.so.6 (0x40030000) libz.so.1 => /lib/libz.so.1 (0x40143000) libcrypt.so.1 => /lib/libcrypt.so.1 (0x40152000) libnsl.so.1 => /lib/libnsl.so.1 (0x40180000) libm.so.6 => /lib/libm.so.6 (0x40196000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)You can adapt LD_LIBRARY_PATH environment variable to the libmysqlclient library. You can also try to link libmysqlclient statical. You must adapt Makefile for it.
I got also following message from sun user:
However, the correct fix is NOT to adjust LD_LIBRARY_PATH; see LDPATH for details of why that is a bad solution. Rather, one needs to adjust the configure options to embed the path to the required library in the referring library. On Solaris 11, I use this configuration line:
./configure LIBS=-R/opt/mysql/mysql/lib --with-mysql-include=/opt/mysql/mysql/include --with-mysql-lib=/opt/mysql/mysql/lib --enable-shared --with-tcl=/opt/ActiveTcl-8.5/lib --with-tclinclude=/opt/ActiveTcl-8.5/includeand the LIBS setting does the right thing in that regard. Something similar is the right way to handle this problem under Linux, as well.
I get the message: "sh: syntax error at line 1: `;' unexpected" by make install
This problem was reported by Sun and Compaq Tru64 machines. It seems the shell on this machines have another syntax then linux shell. I have seen in news groups that problem also by another linux projects. To solve the problem you should set some magic environment variable to change compatibility behaviour of your shell. If someone has near information please mail me it. There are 2 important files that you can also copy manual.
I can not find tclmysqlsh (Tcl with mysqltcl shell) provided in earlier versions
You should use package mechanisms. It is more portable and the right way in Tcl.
package require mysqltcl
I become some differences in encoding by receiving results from (mysqlsel $sql -list, mysqlsel $sql -flatlist, mysqlnext)
mysql $sql -list returns list of list. mysql $sql -flatlist returns a list. mysqlnext returns a list. Even if you retrieve one row and one column you becomes list structures. If you handle such results as string when tcl must convert the list to string. It is better to use lindex command to access directly the list elements (even then there are only one element) to avoid internal types converting. (Such converting can also change the encoding of the string elements)
set result [lindex [lindex [mysqlsel $handle "select blob from pictures where id=2" -list] 0] 0] set result [lindex [mysqlsel $handle "select blob from pictures where id=2" -flatlist] 0] mysqlsel $handle "select blob from pictures where id=2" set result [lindex [mysqlnext $handle] 0]There are some problems by retrieving binary data from mysql by some installations.
By problems you should use.
mysqlconnect -encoding binaryUp from version 2.20 mysql use symetric read and write. That means you do not need to uses enocding converting. But consider if you write binary data to mysql they are converted to system encoding that means you write binary and they can be in mysql as utf-8. See exmaple in tests/binarytest.tcl.
encoding convertfrom [encoding system] $sql_read_dataProblems by build static linked mysqltcl on Solaris; with option --enable-mysqlstatic
The configuration script with this option work good only for Linux. I have not found any way to make it machine independent.
Jean-Luc have reporterted an alternative manually way to static compile mysqltcl on Solaris 5.9
$ ld -G -o libmysqltcl2.40.so mysqltcl.o /usr/local/mysql/lib/libmysqlclient.a -lz -lcrypt -lnsl -lm -L/home/mysql/tcltk/lib -ltclstub8.4 -lc -lsocket -ldl