Myscsh: a Scheme implementation of the MySQL protocol

What is Myscsh?

Myscsh is an implementation of the MySQL client/server protocol written entirely in Scheme. This package provides functions to connect to a MySQL database server, authenticate, send queries, and receive and parse result sets. The API is quite low-level: it's just about reading and parsing messages and sending messages. Future versions of Myscsh will include a higher-level API for convenient database programming. Myscsh implements the MySQL 4.1 protocol (which has the internal protocol version number 10) and has been tested in conjunction with a MySQL 4.1 server on Linux. It might work with a 5.x server as well, but that's completely untested. It won't work with 3.20 servers, that's for sure.

Using the low-level API of Myscsh requires a bit of knowledge of the MySQL client/server protocol. There are several documents (1, 2) describing the protocol. These documents have been very helpful while developing Myscsh.

Why an implementation of the protocol?

An alternative approach for connecting to MySQL is to use the functions the C library libmysqlclient.so provides. A lot of language implementation provide bindings to this library. So this is a well-tested approach. However, here are some reasons for implementing the protocol in Scheme:

Implementing the protocol is not a particular original idea: For example, there is a Ruby implementation of the 3.20 protocol.

Download

Version 0.1 as a gzipped tar file: myscsh-0.1.tar.gz

Requirements and installation

I developed and tested Myscsh on Scheme 48 1.3 and scsh 0.6.7 and should work without right out of the box with these implementations.

There is no special installation procedure. The only thing to do is open packages.scm in an editor, search for this line:

(define mysql-connection mysql-connection-scsh)
and change it to
(define mysql-connection mysql-connection-s48)
when you are using Scheme 48, or, for scsh users, leave it untouched. You may want to comment out the unused package definition mysql-connection-s48 when you are using scsh (and vice versa) to prevent the system from writing some uninteresting warning messages about undefined packages. Yes, that's a hack.

Source code repository

The latest version of the source code resides in a darcs repository at this address:
http://www-pu.informatik.uni-tuebingen.de/users/knauel/sw/myscsh/

Known bugs, limitations

Some things that may cause trouble:

Some things that have not been implemented or tested yet:

Future work

Bug reports, questions, patches, and author's address

Please send bug reports, questions, patches directly to the author of Myscsh

Eric Knauel
knauel@informatik.uni-tuebingen.de

or to the scsh mailing-list:

scsh-users@scsh.net

ChangeLog

Sat Oct  7 15:01:21 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add README

Sat Oct  7 13:53:03 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add interface definition for MYSQL-LOW, move test code to a separate file

Sat Oct  7 13:46:47 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add comment to tests.scm

Sat Oct  7 12:43:48 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add copyright notice and BSD license

Sat Oct  7 12:33:05 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add a few comments to packages.scm

Sat Oct  7 11:05:07 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add an implementation of the network code using the Scheme 48 API

Sat Oct  7 11:04:30 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Remove internal defines in do-login

Sat Oct  7 10:57:05 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Don't use non-standard \t in strings

Sat Oct  7 10:24:25 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Move scsh specific network code to a separate module

Sat Oct  7 10:06:04 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Get rid of the CML dependency (and read with timeout)

Sat Oct  7 09:49:09 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Rename fields of connection record

Tue Oct  3 04:43:34 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add a few more test cases

Tue Oct  3 04:42:39 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Fix a bug that caused READ-TABULAR-RESPONSE to drop one field packet

Tue Oct  3 04:42:08 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Remove a duplicate definition of READ-FIELD-PACKETS

Tue Oct  3 03:48:29 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add various finite types

Mon Oct  2 22:14:43 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add code to read result-sets

Sun Aug 27 03:09:34 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add implementation of pre-4.1 password scrambling algorithm

Sun Aug 27 03:01:06 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Remove unused functions

Sun Aug 27 02:59:43 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Use SRFI 42 for byte-vector stuff

Sun Aug 27 02:58:09 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Remove code that has been moved to MYSQL-UTILS

Sun Aug 27 02:55:35 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Collect various utility functions in a separate package

Sun Aug 27 02:54:36 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Extend SRFI 42 to handle byte-vectors

Wed Aug 16 00:11:08 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Code for readings simple response messages

Wed Aug 16 00:10:30 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Minore fixes

Fri Aug 25 21:22:03 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Revamp READ-nBIT-INTEGER functions

Mon Aug 21 21:43:44 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Implement the MySQL password algorithm
  
  Use the Scheme SHA1 implementation to actually implement the MySQL
  password crypting algorithm (as of protocol version 4.1).

Mon Aug 21 21:42:57 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add code to convert a hash value into a byte-vector

Mon Aug 14 22:57:35 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add test-suite for SHA1 code

Mon Aug 14 22:55:45 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Finish SHA1 implementation
  
  Fix padding and message preprocessing.  Add SHA1-HASH-STRING and
  SHA1-HASH-BYTEVECTOR and friends.  Get rid of debug output.

Mon Aug 14 22:55:23 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add package definition for SHA1

Sun Aug 13 14:56:16 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add preliminary version of SHA1 implementation
  
  Currently only works for messages that fit into a single message block.

Thu Aug  3 21:43:23 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Implement client-auth message
  
  Add code for assembling client auth messages.  Only supports
  empty passwords at the moment.
  

Mon Jul 31 11:08:16 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Import the Scheme48 enum-set implementation

Tue Jul 18 21:56:15 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Add package definition

Tue May  9 09:08:52 MST 2006  Eric Knauel <knauel@informatik.uni-tuebingen.de>
  * Basic support for reading the server greeting

Eric Knauel
Last modified: Sat Oct 7 15:34:46 CEST 2006