clsql trouble in SBCL

2.3k views Asked by At

I'm trying to get clsql working (used to use cl-mysql, but looking at alternatives). Just attempting to play around at this point, and I'm getting stopped at connect

(connect '("localhost" "test" "user" "password") :database-type :mysql)

gets me

erred while invoking #<COMPILE-OP (:VERBOSE NIL) {BDFF0B9}> on
#<CLSQL-UFFI-SOURCE-FILE "clsql-uffi" "uffi" "clsql_uffi">
   [Condition of type ASDF:OPERATION-ERROR]

Backtrace:
  0: ((SB-PCL::FAST-METHOD ASDF:PERFORM (ASDF:COMPILE-OP CLSQL-UFFI-SYSTEM::CLSQL-UFFI-SOURCE-FILE)) ..)
  1: ((LAMBDA (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0. SB-PCL::.ARG1.)) ..)
  2: ((LAMBDA ()))
  3: ((FLET SB-THREAD::WITH-RECURSIVE-LOCK-THUNK))
  4: ((FLET #:WITHOUT-INTERRUPTS-BODY-[CALL-WITH-RECURSIVE-LOCK]324))
  5: (SB-THREAD::CALL-WITH-RECURSIVE-LOCK ..)
  6: ((FLET SB-C::WITH-IT))
  7: ((SB-PCL::FAST-METHOD ASDF:OPERATE (T T)) #<unavailable argument> #<unavailable argument> ASDF:LOAD-OP :CLSQL-MYSQL)[:EXTERNAL]
  8: ((LAMBDA (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0. SB-PCL::.ARG1. SB-INT:&MORE SB-PCL::.DFUN-MORE-CONTEXT. SB-PCL::.DFUN-MORE-COUNT.)) ..)
  9: (CONNECT ("localhost" "test" "user" "password"))[:EXTERNAL]
 10: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CONNECT '("localhost" "test" "user" "password") :DATABASE-TYPE :MYSQL) #<NULL-LEXENV>)
 11: ((LAMBDA ()))
 --more--

If I follow the accept restarts (trimmed above for brevity) all the way through, I eventually get to

Attempt to call an undefined alien function.
   [Condition of type SB-KERNEL::UNDEFINED-ALIEN-FUNCTION-ERROR]

Restarts:
 0: [RETRY] Retry SLIME interactive evaluation request.
 1: [ABORT] Return to SLIME's top level.
 2: [TERMINATE-THREAD] Terminate this thread (#<THREAD "worker" RUNNING {BD63789}>)

Backtrace:
  0: (SB-KERNEL::UNDEFINED-ALIEN-FUNCTION-ERROR)
  1: ("foreign function: #x806774B")
  2: ("foreign function: #x8052F2D")
  3: ("foreign function: #x80565C9")
  4: ((SB-PCL::FAST-METHOD CLSQL-SYS:DATABASE-CONNECT (T (EQL :MYSQL))) #<unavailable argument> #<unavailable argument> ("localhost" "test" "user" "password") :MYSQL)
  5: (CONNECT ("localhost" "test" "user" "password"))[:EXTERNAL]
  6: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CONNECT '("localhost" "test" "user" "password") :DATABASE-TYPE :MYSQL) #<NULL-LEXENV>)
  7: ((LAMBDA ()))
 --more--

I'm using SBCL 1.0.40.0, Debian 6.0, clsql was installed using quicklisp and mysql v14.14 (although I doubt this is an issue with mysql).

2

There are 2 answers

1
Inaimathi On BEST ANSWER

It turns out I had to do

apt-get install cl-sql

This was necessary despite the fact that I already had libmysqlclient-dev and had installed clsql through quicklisp (which looked like it had all the correct c files with it). After doing this, I was able to connect to a local mysql server using

(connect '("localhost" "test" "user" "password") :database-type :mysql)

As a note, it still threw a couple warnings on my 64-bit system (no problems on my 32 bit machine); using the accept restart (sorry, Xach) got it to a seemingly working state.

I have no idea how, in detail, this fixed the problem; if someone can explain it, answer and I'll upvote+accept (assuming your explanation is correct).

EDIT: Similar problem on another machine had me frustrated for about 30 minutes. It seems like this should be assumed, but if you're building a system from bare metal, make sure you install gcc. If you don't, it prevents clsql-uffi from compiling its components for obvious reasons. When the process fails this way, you get the same compilation error as in the question, so cover your bases.

2
Xach On

Don't use the accept restart. It means "Keep going even though something is screwed up," and that's rarely if ever what you want to do.

Do you have the mysql development libraries installed? Do you have libmysqlclient.so?

One thing to try: start a fresh sbcl and quickload "clsql-uffi", then trace clsql-uffi::find-and-load-foreign-library, then (clsql:connect nil :database-type 'mysql) to see if it's finding what you need, based on the trace output.