List:Summer of Code« Previous MessageNext Message »
From:Dobos D. Calin Date:March 20 2008 10:12am
Subject:Re: Adding Lua support to the mysql command-line client
View as plain text  
Hello,

Congratulations for being a 2008 GSoC mentoring organization.

My name is Calin Dobos and I am interested in the MySQL/Lua integration
project.

I have read the wiki and I am still a bit confused about some aspects of
this 
embedding. Most important, the goal.

Embedding the lua VM into the mySQL command line would create a
full-featured 
Lua interpreter. Which is pretty much the same thing as the official lua 
interpreter, in which we could "require mysql". A Google search for "mysql
lua"
returns a list of some projects that may have some of the functionality
already
(I admit, I haven't really checked them yet). Bridging two separate clients
wouldn't be so straightforward (intermediate files, maybe pipes). But the
lua
interpreter with a mysql module might do just fine by itself. Loops,
variables,
arrays,they're already there. We don't need a MySQL command line just to
run 
scripts.

So, taking this nihilistic approach, it comes down to creating a
full-featured
lua module.

On the other side, we shall not forget that embedding is not just about
running
scripts, but about handling the state of the program and making the best of
it 
afterwards. If we are to embed lua into the command line, it needs to have
some
really neat features.

My quick approach at this time would be keeping the client and VM in
separate
layers, connected by simple calls like:

> run script_name
> exec direct lua commands
> store lua_variable sql_command
> show lua_variable

,which are to be added to the client.

Access the other way round could be either provided by simple wrapper
functions 
of the C API,like mysql.store_result(),mysql.query() or some
friendlier-looking
functions.

The connection should be shared between the VM and the client.
The store command would normally create a table(which is what makes Lua so 
powerful in the first place).But I'm not sure what the impact 3 tables of
10000
rows each would have on performance (I never tried that).

Another idea would be to create a "virtual" lua table,which would associate
the
lua_variable with the select command,so every time the table is used,the
command
is actually invoked (more like a macro). I guess this kind of object could
still
provide access by index (like a normal table).Also, I think we could easily
name
it a View. :)

A great thing about embedding Lua is that it offers general file IO. One
could
easily write a script that exports the database into some exotic file
format or,
say , script to analyze some data and then selectively insert it into the
appropriate table. But then again, this is not something a scripting
language
couldn't do by itself. However, a good reason that I do found for embedding
is
having startup/exit scripts, which could perform some repetitive or
conditional
tasks automatically, but still leave the familiar command line to the user.

These are some of my ideas at this time. I may be extremely wrong. 
Feedback appreciated.

Best regards,
Calin Dobos
Computer Science, UAIC, Romania



Thread
Adding Lua support to the mysql command-line clientKishoreKumar Bairi18 Mar
  • Re: Adding Lua support to the mysql command-line clientGiuseppe Maxia18 Mar
Re: Adding Lua support to the mysql command-line clientDobos D . Calin20 Mar
  • Re: Adding Lua support to the mysql command-line clientJim Winstead21 Mar