Petter Gustad | 19 Apr 2013 14:57

"No source tables supplied to select statement."


I keep getting the above error if I define the following form inside a
function. I have the SQL reader macros enabled:

REGLIB> (get-macro-character #\[ )
#<FUNCTION CLSQL-SYS::SQL-READER-OPEN>
NIL

If I simply run it it in the REPL it works as expected:

REGLIB> (first (clsql:select [max [id]] :from [regrun] :flatp t :field-names nil :database *database*))
1338

But if I embed it inside a function it will not work:

REGLIB> (defun get-latest-regrun-id (&optional (db *database*))
  "return the id of the latest regrun"
  (first (clsql:select [max [id]] 
 		       :from [regrun]
		       :flatp t 
		       :field-names nil
		       :database db)))

STYLE-WARNING: redefining REGLIB::GET-LATEST-REGRUN-ID in DEFUN
GET-LATEST-REGRUN-ID
REGLIB> (get-latest-regrun *database*)
; Evaluation aborted on #<SIMPLE-ERROR "No source tables supplied to select statement." {1007195083}>.

The result is the same if I compile the function either in SLIME or by
using asdf:load-system.
(Continue reading)

Ben Hyde | 29 Mar 2013 12:38
Picon
Favicon
Gravatar

ccl += weak hash


diff --git a/sql/utils.lisp b/sql/utils.lisp
index 39ee349..2f3c1db 100644
--- a/sql/utils.lisp
+++ b/sql/utils.lisp
 <at>  <at>  -443,7 +443,7  <at>  <at>  removed. keys are searched with #'MEMBER"
     ;;clearing mechanism. If you are on an implementation that doesn't support
     ;;weak hash tables then you're memory may accumulate.

-    #-(or sbcl allegro clisp lispworks)
+    #-(or sbcl allegro clisp lispworks ccl)
     (warn "UNSAFE! use of weak hash on implementation without support. (see clsql/sql/utils.lisp to add)")

     (make-hash-table
 <at>  <at>  -451,6 +451,7  <at>  <at>  removed. keys are searched with #'MEMBER"
       #+clisp     :weak      #+clisp :value
       #+lispworks :weak-kind #+lispworks :value
       #+sbcl :weakness #+sbcl :value
+      #+ccl :weak #+ccl :value
       , <at> args)
     ))
Ben Hyde | 28 Mar 2013 02:04
Picon
Favicon
Gravatar

clsql-sys::|view-class-slot-autoincrement-sequence|

Loading clsql into ccl doesn't work out well:

cl-user> (handler-case (ql:quickload "clsql") (error (e) (princ e)))
To load "clsql":
  Load 1 ASDF system:
    clsql
; Loading "clsql"
Undefined function clsql-sys::|view-class-slot-autoincrement-sequence| called with arguments (#<view-class-direct-slot-definition for instance slot clsql-sys::view-database #x302001C1DC1D>) .
...

No doubt more knowledgable eyes will scoff, but this fix allowed me to move onto the next puzzle:

diff --git a/sql/metaclasses.lisp b/sql/metaclasses.lisp
index 1c9a6c5..830cf2c 100644
--- a/sql/metaclasses.lisp
+++ b/sql/metaclasses.lisp
<at> <at> -482,7 +482,7 <at> <at> implementations."
 
          (macrolet
              ((safe-copy-value (name &optional default)
-                (let ((fn (intern (format nil "~A~A" 'view-class-slot- name ))))
+                (let ((fn (intern (format nil "~ <at> :(~A~A~)" 'view-class-slot- name ))))
                   `(setf (slot-value esd ',name)
                     (or (when (slot-boundp dsd ',name)
                           (delistify-dsd (,fn dsd)))

_______________________________________________
CLSQL mailing list
CLSQL@...
http://lists.b9.com/cgi-bin/mailman/listinfo/clsql
Nicolas Neuss | 7 Mar 2013 15:15
Picon
Favicon

Password authentification failed after Quicklis update

Hi,

I am using clsql/postgresql and after doing a (ql:update-all-dists) I
cannot connect anymore to my databases with clsql.

While trying to connect to database localhost/noten/neuss
  using database-type POSTGRESQL-SOCKET:
  Error POSTGRESQL-LOGIN-ERROR / FATAL:  password authentication failed for user "neuss"

  has occurred.
   [Condition of type SQL-CONNECTION-ERROR]

I searched the web and found that in December last year a change in MD5
broke authentification.  Is this bug still active?  Does anyone have a
fix?

Thank you,

Nicolas
Brian Sorg | 6 Mar 2013 18:45

Running a procedural query ?

I am trying to run a query through ODBC on a Mssql Server 2008 database. The query runs on the database as expected, however it is support to return a single row of results which vary depending on the results of the query. I have tested the sql query directly against the database and it runs as expected, however with running it using clsql:query it only returns the number 1 instead of the expected list of results. Is there a step I am missing with my call? The following is an example of what I am trying to run:

---------------------------------------------------------------
(clsql:with-database (*default-database* *mssql-connect-writer-spec* :database-type :odbc
                                         :if-exists :new :make-default nil)
  (clsql:set-autocommit nil)
  (clsql:query "
DECLARE <at> batchID INT
DECLARE <at> batchIDNext INT
DECLARE <at> result INT
DECLARE <at> errorMessage VARCHAR(255)


-- Start the transaction process here
BEGIN TRANSACTION

-- Try attempts to run the code inside of the try, if it fails it is caught by the CATCH, the CATCH must immediately follow the TRY
BEGIN TRY
        SELECT <at> batchID = next_value from autoincrement a where a.company_id = 'TMS' and a.tablename = 'cash_batch' and a.fieldname = 'id'

        SELECT <at> batchIDNext = ( <at> batchID + 1)

        update autoincrement set next_value= <at> batchIDNext where company_id='TMS' and tablename='cash_batch' and fieldname='id' and next_value= <at> batchID

        INSERT INTO cash_batch(company_id, amount, amount_c, amount_d, amount_n, amount_r, glid, id, receipt_date)
                       values ('TMS','hi','USD',null,50.00,1.0000,'2015000000', <at> batchID,'2013-03-05 12:31:45')

END TRY
BEGIN CATCH
        -- TRANCOUNT checks how many transaction steps are currently uncommitted, so if there was an error roll them back which sets <at> <at> TRANCOUNT to zero
        IF <at> <at> TRANCOUNT > 0
           BEGIN
              ROLLBACK TRANSACTION;
              SELECT <at> result = -1;
              SELECT <at> errorMessage = ERROR_MESSAGE();
           END

END CATCH

-- If there were errors <at> <at> TRANCOUNT will be rolled back to zero, Otherwise commit and return the batch id
IF <at> <at> TRANCOUNT > 0
    BEGIN
        COMMIT TRANSACTION;
        SELECT <at> result = <at> batchID;
        SELECT <at> errorMessage = 'ok';
    END    

SELECT <at> result as resultid, <at> errorMessage as message;"
   :result-types '(:int :string)))

-------------------------------------------------------------

Thanks,

--
Brian Sorg
Director and Founder Liberating Insight LLC
brian.sorg <at> liberatinginsight.com
Office: 260.918.0490
Mobile: 260.602.1086
www.liberatinginsight.com
_______________________________________________
CLSQL mailing list
CLSQL@...
http://lists.b9.com/cgi-bin/mailman/listinfo/clsql
Faré | 21 Feb 2013 04:55
Picon
Gravatar

clsql and asdf3

Free variable and/or forward reference to special variables = Bug that
prevents compilation with ASDF3.
Same for functions that remain undefined by end of system.

—♯ƒ • François-René ÐVB Rideau •Reflection&Cybernethics• http://fare.tunes.org
The most exciting phrase to hear in science, the one that heralds new
discoveries, is not "Eureka!" (I found it!) but "That's funny ..."
                — Isaac Asimov

; compilation unit finished
;   Undefined functions:
;     CLSQL-SYS::%SLOT-STOREDP CLSQL-SYS::%SLOT-VALUE-LIST
;   Undefined variables:
;     CLSQL-HELPER:*CONNECTION-SETTINGS*
CLSQL-HELPER::*DEFAULT-LOG-FN* CLSQL-HELPER::*RECORD-THIS-DIRTY-SLOT*
CLSQL-HELPER:+A-DAY+ CLSQL-HELPER:+A-MINUTE+ CLSQL-HELPER:+A-MONTH+
CLSQL-HELPER:+A-NEGATIVE-DAY+ CLSQL-HELPER:+A-NEGATIVE-HOUR+
CLSQL-HELPER:+A-NEGATIVE-MINUTE+ CLSQL-HELPER:+A-NEGATIVE-MONTH+
CLSQL-HELPER:+A-NEGATIVE-SECOND+ CLSQL-HELPER:+A-NEGATIVE-YEAR+
CLSQL-HELPER:+A-SECOND+ CLSQL-HELPER:+A-YEAR+ CLSQL-HELPER:+AN-HOUR+
;   caught 15 WARNING conditions
;   caught 4 STYLE-WARNING conditions
Unhandled SERIOUS-CONDITION of type COMPILE-FAILED-ERROR is signaled:
Lisp compilation failed

_______________________________________________
CLSQL mailing list
CLSQL <at> b9.com
http://lists.b9.com/cgi-bin/mailman/listinfo/clsql
Frank Grex | 21 Jan 2013 20:09
Favicon
Gravatar

oracle long type

Hi I have noticed that clsql-oracle interface does not fetch a query where 
the column is of type LONG. It returns only an epmpty string! Is this 
something know? Is there a workaround for it? Thanks
Russ Tyndall | 6 Dec 2012 20:22
Favicon
Gravatar

OODML Refactor

Over the last couple weeks I have worked through a refactor of the
sql/oodml.lisp code file.

My goals were:
  * unify codepaths for the update-*-from-* functions where possible
  * general cleanup and documentation
  * reduce complexity and improve readability (through smaller,
    functions with less nesting)
  * convert data passed around in cons & lists to instead be
    objects (for readability and in some cases efficiency)

Along the way I found that almost all of the iteration constructs in
the language were used, often nested and in a not-terribly-readable
way.  I chose to standardize on loop unless it was a very simple use
of a different construct, so that hopefully most of the code in this
file looks like the rest of the code in this file.

Normalized view-classes are now better documented as to what
assumptions need to be met.  Also many cases of recursion were
converted to iterative approaches (by recursing in one place and
producing a list that can be iterated over everywhere else). This
separation of concerns simplified the implementation of many other
functions.

While I attempted to minimize semantic differences, I documented any
changes in the ChangeLog entry.  The biggest change was to
update-objects-joins, which now operates on immediate join slots by
default and accepts keywords for :deferred and :all as well as an
explicit list of slots.

After the refactor, I ran some speed tests that implied with fair
certainty that my refactoring did not reduce performance (for my
common workloads).  The test suite in clsql has the same number of
failures (for the backends I can test) as it did before the refactor
(see LATEST-TEST-RESULTS).  I also ran the test-suites for various
of our other projects that make use of clsql and its oodml.  We have
also been using this branch in our projects for a week or so.

I have pushed this branch to github[1] for public review. Please check
it out and report any problems you have. We intend to push this to
git.b9.org for a new clsql release soon. I think a point release
should be fine for this.

[1] https://github.com/UnwashedMeme/clsql/tree/oodml-refactor

You can clone that branch directly:
`git clone https://github.com/UnwashedMeme/clsql.git -b oodml-refactor 
clsql-oodml`

  or checkout a new branch in your existing repo:
`git fetch https://github.com/UnwashedMeme/clsql.git oodml-refactor;
  git checkout -b oodml-refactor FETCH_HEAD`

Cheers,
Russ Tyndall
Acceleration.net
J Phelps | 6 Nov 2012 01:13

SQL parsing irregularity when using SQL reader syntax.

Platform: Postgres/Linux

Reproduction:

(let ((my-string (make-string 1 :initial-element #\Nul)))
   (select [foo] :from [bar] :where [= [foo] my-string]))

You should get an error about an unterminated string constant, caused by the nul
character eventually being treated as a C-string terminating nul. Discovered by
a hacker who was trying to SQL-inject me.
Raymond de Lacaze | 26 Oct 2012 00:22
Picon
Favicon

Error: Attempt to call #("clsql_mysql_field_flags".....

Folks,

 

Has anyone seen or been able to resolve the following error:

 

CLSQL-SYS(6): (create-table [vertices] '(([vertexID] integer)([name] (string 45))))

Error: Attempt to call

       #("clsql_mysql_field_flags" 1669840587 0 2 1669840587) for which

       the definition has not yet been (or is no longer) loaded.

  [condition type: SIMPLE-ERROR]

 

 

I initially had problems compiling CLSQL via ASDF and ultimately had to download a file called libmysql.dll and place it in the db-mysql and uffi subdirectories.

 

I am able to connect to my database server and run certain commands like list-tables and insert-records. However other lisp function such as create-table or select result in the above error.

 

For the record I am running this on a Windows 7 machine, using MySQL Server 5.5 and Allegro Common Lisp 9.0

 

Any clues or suggestions would be most appreciated, as I am pretty knew to both MySQL and CLSQL.

 

Below is a short transcript of a short session demonstrating that some things are in fact working!

 

CL-USER(1): ;; Setting (stream-external-format *terminal-io*) to :emacs-mule.

 

CL-USER(2): (in-package :clsql-sys)

#<The CLSQL-SYS package>

 

CLSQL-SYS(3): (CONNECT '("localhost" "Graph" "root" "*******”) :database-type :mysql)

#<CLSQL-MYSQL:MYSQL-DATABASE localhost/Graph/root OPEN <at> #x214f3de2>

 

CLSQL-SYS(4): (list-tables)

("edges")

 

CLSQL-SYS(5): (file-enable-sql-reader-syntax)

T

 

CLSQL-SYS(6): (create-table [vertices] '(([vertexID] integer)([name] (string 45))))

Error: Attempt to call

       #("clsql_mysql_field_flags" 1669840587 0 2 1669840587) for which

       the definition has not yet been (or is no longer) loaded.

  [condition type: SIMPLE-ERROR]

 

 

Thanks!

 

Ray,

 

Raymond Pierre de Lacaze

rpl-/KLN2IFiNzJAfugRpC6u6w@public.gmane.org

_______________________________________________
CLSQL mailing list
CLSQL@...
http://lists.b9.com/cgi-bin/mailman/listinfo/clsql
Alexandre Paes | 18 Sep 2012 02:40
Picon

CLSQL-MYSQL on Lispworks for OSX

Hi everyone,

I'm having a slight problem when trying to load clsql-mysql on lispworks in OSX. Basically I'm using 
Quicklisp for loading libraries. loading CLSQL with quicklisp works without a problem by issuing:

CL-USER> (ql:quickload "clsql")
; Loading system definition from /Users/user/quicklisp/dists/quicklisp/software/uffi-20120520-
git/uffi.asd into
; #<The ASDF1 package, 0/16 internal, 0/16 external>
; Registering #<SYSTEM "uffi">
To load "clsql":
 Load 1 ASDF system:
   clsql
; Loading "clsql"

("clsql")

When I try to load CLSQL-MYSQL this is what happens:

CL-USER> (ql:quickload "clsql-mysql")
Error: Couldn't load foreign libraries "libmysqlclient", "libmysql". (searched CLSQL-SYS:*FOREIGN-LIBRARY-
SEARCH-PATHS*)
...

So I added libmysql.dylib folder to clsql-sys:*foreign-library-search-paths* with the following command:

CL-USER> (push #p"/usr/local/mysql/lib/" clsql-sys:*foreign-library-search-paths*)
(#P"/usr/local/mysql/lib/" #P"/Users/user/quicklisp/dists/quicklisp/software/clsql-20120520-git/db-
mysql/" #P"/Users/user/quicklisp/dists/quicklisp/software/clsql-20120520-git/uffi/")

After this, loading CLSQL-MYSQL goes like this:

CL-USER> (ql:quickload "clsql-mysql")
To load "clsql-mysql":
 Load 1 ASDF system:
   clsql-mysql
; Loading "clsql-mysql"

Error: Undefined function MYSQL:MYSQL-GET-CLIENT-INFO in form (SYMBOL-FUNCTION MYSQL:MYSQL-
GET-CLIENT-INFO).
 1 (continue) Take the function definition of another function name.
...

I am not finding any way to solve this problem since I'm not all that versed in Common Lisp and can't seem 
to understand this error not able to find much help googling for this error.

Is there someone using CLSQL-MYSQL on Lispworks for OSX that can provide some help on how to make it 
all work? Thanks in advance for any help.

Best regards,
Alexandre Paes

Gmane