Re: Some starter guidance?

Carlos Konstanski <[email protected]>
Newsgroups gmane.lisp.clsql.general
Message-ID <[email protected]>
On Tue, 20 Oct 2009, Peter Stirling wrote:

> Date: Tue, 20 Oct 2009 17:39:07 +0100
> From: Peter Stirling <[email protected]>
> To: [email protected]
> Subject: [CLSQL] Some starter guidance?
> 
> Hi,
>
> I'm writing a web-app in lisp as my first project, because it has
> reasonable complexity, but is something that I've done before (in
> Java/python/php). I have
>
> Since I'm not sure how it works[1], and already can write my own sql, I
> wanted to avoid using the [SQL] (at least to start with).
>
> However, looking through the documentation it seems that there is noThis
> prepared-statement style variable-substitution? (Hunting backwards
> through the mailing list archives there was [2] from April where he was
> told just to use the sql syntax stuff).
>
> In the interest of getting something working for the time being, I've
> been making query strings with (format ...), but I've been getting a
> (memory corruption?) error message for one innocuous looking query:
>
> * (clsql:query "update client_details set date_of_birth = '1981-05-07'")
>
> debugger invoked on a SB-SYS:MEMORY-FAULT-ERROR in thread #<THREAD
> "initial thread" RUNNING {1002669D11}>:
>  Unhandled memory fault at #x60.
>
> Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
>
> restarts (invokable by number or by possibly-abbreviated name):
>  0: [ABORT] Exit debugger, returning to top level.
>
> (SB-SYS:MEMORY-FAULT-ERROR)
>
> I've tried 'make clean', to no effect.
>
> I got clsql from clbuild, and sbcl is SBCL 1.0.18.debian on ubuntu,
> mysql is 5.0.75-0ubuntu10.2 (also the ubuntu package).
>
> Any help would be nice.
>
> ;; ========================================================
>
> [1] I tried to make a macro for locally enabling the syntax:
>
> (defmacro with-sql-syntax (&body body)
>  `(progn
>     (clsql:locally-enable-sql-reader-syntax)
>     ,@body
>     (clsql:locally-disable-sql-reader-syntax)))
>
> but it doesn't seem to do anything (i.e. compile errors), neither where
> I was intending to use it (wrapping (clsql:select inside functions), nor
> as wrapped around top-level defuns.
>
> [2] http://lists.b9.com/pipermail/clsql/2009-April/001698.html

The SB-SYS:MEMORY-FAULT-ERROR is probably a result of errors during
foreign function calls. I get them all the time at work, where I
connect to Oracle and MSSQL. Actually I don't think MSSQL is at issue
(because the FreeTDS driver is solid), but Oracle certainly is. But I
NEVER get this error at home, where I use Postgresql and the
cl-postgresql-socket interface. This interface uses no .so
objects. You might want to consider using Postgresql if at all
possible to minimize fat layers.

I don't know about the Ubuntu CLSQL package. You might need to run
sbcl as root and load the CLSQL library with:

   (asdf:operate 'asdf:load-op 'clsql-mysql)

to get CLSQL to build the .so files properly.

I can't help you with the rest; I wrote my own SQL API around
`clsql:query' and its partner `clsql:execute-command'.

Carlos Konstanski
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.