Nathan Bird | 1 Feb 2010 19:35
Favicon

ODBC ownership tweak on database-list-{tables,views}

I've committed a change in the development branch that changes how
ownership is treated on the ODBC backend. The most important aspect of
this is that I can run the test suites on SqlServer 2000,2005. If anyone
using ODBC can confirm this doesn't cause any problems that would be nice.

Since ODBC doesn't expose the owner we now use that parameter to filter
on schema since that's what tends to be exposed. Some DBs like mssql
2000 conflate the two so at least there it works nicely.  These
functions now strip out all the system tables that I know about for
those two which makes it match the clsql docs of  "only returning user
tables if no owner is specified."

I don't yet have a sqlserver2008 or Access system setup so there may be
other system tables on those two that need to be ignored. If anyone that
has those could run on an empty database
(clsql:list-views)
(clsql:list-tables)
and report any system tables that it is still returning that would be handy.

The test suites still have a lot of failures on those backends... but we
can whittle now.

To get a copy of the development branch:

#clone the repo, skip this if you already have it.
git clone git://git.b9.com/clsql.git
cd clsql
#create and checkout a new branch 'development' based on the origin's.
git checkout -b development origin/development
(Continue reading)

Jason H | 1 Feb 2010 20:52
Picon

Re: .mdb file + :odbc + drop-index => belly up



On Sun, Jan 31, 2010 at 9:38 AM, Nathan Bird <nathan <at> acceleration.net> wrote:
Jason H wrote:
> After creating an index with:
>   (create-index [cftypeid] :on [cellfeature] :attributes '([typeid]))
> either
>   (drop-index [cftypeid] :on [cellfeature])
> or
>   (drop-index [cftypeid])
> will drop me into the debugger:
>
>   A database error occurred: NIL / 42000
>   [Microsoft][ODBC Microsoft Access Driver] Syntax error in DROP TABLE
> or DROP INDEX.
>   [Condition of type SQL-DATABASE-ERROR]
>
>   Backtrace:
>   3: (ODBC-DBI:SQL "DROP INDEX CFTYPEID")[:EXTERNAL]
>
> More background info:
>   1. CLSQL 4.3.0
>   2. SBCL 1.0.33.4 win32
>   3. Using :ODBC database type to clsql:connect to a .mdb file.

It looks like it is issuing just "DROP INDEX CFTYPEID", which appears to
be incorrect for Access: http://www.w3schools.com/SQl/sql_drop.asp

My guess is when you use the
(drop-index [cftypeid] :on [cellfeature]) variant you get "DROP INDEX
CELLFEATURE.CFTYPEID"  or is the actual sql expression the same whether
you provide :on or not?

Confirmed by START-SQL-RECORDING, the actual sql expression is always
"DROP INDEX CFTYPEID" whether :ON is provided or not.
Right now, I just use (QUERY "DROP INDEX an-index ON a-table").
Best,
Jason
_______________________________________________
CLSQL mailing list
CLSQL@...
http://lists.b9.com/cgi-bin/mailman/listinfo/clsql
Andras Simon | 2 Feb 2010 16:56
Picon
Favicon

cmucl compilation problem

While trying to compile clsql 4.3.3 with cmucl on linux-x86, I get the
following

;/home/simon/.fasls/cmu-snapshot_2010-02_(20a_unicode)-linux-i486/home/simon/lisp_packages/clbuild/source/clsql/uffi/clsql-uffi.sse2f written.
; Compilation finished in 0:00:00.
; Loading
   #P"/home/simon/.fasls/cmu-snapshot_2010-02_(20a_unicode)-linux-i486/home/simon/lisp_packages/clbuild/source/clsql/uffi/clsql-uffi.sse2f".

Undefined foreign symbol: "atol64"
    [Condition of type KERNEL:SIMPLE-PROGRAM-ERROR]

I'm not sure if it's a problem with clsql or cmucl.

Andras
Andras Simon | 2 Feb 2010 17:41
Picon
Favicon

sbcl compilation problem

This time it's sbcl (again, clsql v 4.3.3.,
linux-x86):

;/home/simon/.fasls/sbcl-1.0.30-2.fc12-linux-x86/home/simon/lisp_packages/clbuild/source/clsql/db-postgresql/postgresql-sql.fasl written
; compilation finished in 0:00:03.991
WARNING:
    COMPILE-FILE warned while performing #<COMPILE-OP NIL {B0A8949}> on
    #<CL-SOURCE-FILE "postgresql-sql" {B0402C1}>.

debugger invoked on a ASDF:COMPILE-FAILED in thread #<THREAD "initial thread"
RUNNING {A903811}>:
   erred while invoking #<COMPILE-OP NIL {B0A8949}> on
   #<CL-SOURCE-FILE "postgresql-sql" {B0402C1}>

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
   0: [TRY-RECOMPILING] Try recompiling postgresql-sql
   1: [RETRY          ] Retry performing #<ASDF:COMPILE-OP NIL {B0A8949}> on
                        #<ASDF:CL-SOURCE-FILE "postgresql-sql" {B0402C1}>.
   2: [ACCEPT         ] Continue, treating #<ASDF:COMPILE-OP NIL {B0A8949}> on
                        #<ASDF:CL-SOURCE-FILE "postgresql-sql" {B0402C1}> as
                        having been successful.
   3: [ABORT          ] Exit debugger, returning to top level.

((SB-PCL::FAST-METHOD ASDF:PERFORM (ASDF:COMPILE-OP ASDF:CL-SOURCE-FILE))
  #<unavailable argument>
  #<unavailable argument>
  #<ASDF:COMPILE-OP NIL {B0A8949}>
  #<ASDF:CL-SOURCE-FILE "postgresql-sql" {B0402C1}>)
0] back

0: ((SB-PCL::FAST-METHOD ASDF:PERFORM (ASDF:COMPILE-OP ASDF:CL-SOURCE-FILE))
     #<unavailable argument>
     #<unavailable argument>
     #<ASDF:COMPILE-OP NIL {B0A8949}>
     #<ASDF:CL-SOURCE-FILE "postgresql-sql" {B0402C1}>)
1: ((LAMBDA
         (SB-PCL::.PV. SB-PCL::.NEXT-METHOD-CALL. SB-PCL::.ARG0.
          SB-PCL::.ARG1.))
     #<unavailable argument>
     #<unavailable argument>
     #<ASDF:COMPILE-OP NIL {B0A8949}>
     #<ASDF:CL-SOURCE-FILE "postgresql-sql" {B0402C1}>)
2: ((SB-PCL::FAST-METHOD ASDF:PERFORM ASDF:AROUND
      (ASDF:COMPILE-OP ASDF:CL-SOURCE-FILE))
     #<unavailable argument>
     #S(SB-PCL::FAST-METHOD-CALL
        :FUNCTION #<CLOSURE # {AFAB4A5}>
        :PV NIL
        :NEXT-METHOD-CALL NIL
        :ARG-INFO (2))
     #<ASDF:COMPILE-OP NIL {B0A8949}>
     #<ASDF:CL-SOURCE-FILE "postgresql-sql" {B0402C1}>)

etc.

Here's what I see while sbcl is compiling postgresql-sql.lisp

[...]

; file:
   /home/simon/lisp_packages/clbuild/source/clsql/db-postgresql/postgresql-sql.lisp
; in:
;      DEFMETHOD DATABASE-WRITE-LARGE-OBJECT (T STRING POSTGRESQL-DATABASE)
;     (=
;      (PGSQL:LO-WRITE CLSQL-POSTGRESQL::PTR CLSQL-POSTGRESQL::FD
;                      CLSQL-POSTGRESQL::DATA LENGTH)
;      LENGTH)
; ==>
;   LENGTH
; 
; note: deleting unreachable code
; 
; note: deleting unreachable code

;     (IF CLSQL-POSTGRESQL::RESULT "commit" "rollback")
; ==>
;   "commit"
; 
; note: deleting unreachable code

;     (PGSQL:LO-WRITE CLSQL-POSTGRESQL::PTR CLSQL-POSTGRESQL::FD
;                     CLSQL-POSTGRESQL::DATA LENGTH)
; --> BLOCK LET LET LET LET CFFI-SYS:%FOREIGN-FUNCALL
; --> CFFI-SYS::%%FOREIGN-FUNCALL ALIEN-FUNCALL
; --> SB-C::INVOKE-WITH-SAVED-FP-AND-PC LAMBDA FUNCTION
; --> SB-ALIEN-INTERNALS:NATURALIZE LET LET LET LET
; --> SB-ALIEN-INTERNALS:MAYBE-WITH-PINNED-OBJECTS PROGN SB-C:%ALIEN-FUNCALL
; ==>
;   (SB-ALIEN-INTERNALS:DEPORT #:G833
;                              '#<SB-ALIEN::ALIEN-SYSTEM-AREA-POINTER-TYPE
;     SYSTEM-AREA-POINTER>)
; 
; caught WARNING:
;   Asserted type SB-SYS:SYSTEM-AREA-POINTER conflicts with derived type
;   (VALUES STRING &OPTIONAL).
;   See also:
;     The SBCL Manual, Node "Handling of
Types"

[...]

;/home/simon/.fasls/sbcl-1.0.30-2.fc12-linux-x86/home/simon/lisp_packages/clbuild/source/clsql/db-postgresql/postgresql-sql.fasl written
; compilation finished in 0:00:03.991
WARNING:
    COMPILE-FILE warned while performing #<COMPILE-OP NIL {B0A8949}> on
    #<CL-SOURCE-FILE "postgresql-sql" {B0402C1}>.

Andras
Andras Simon | 2 Feb 2010 21:41
Picon
Favicon

Re: cmucl compilation problem


On Tue, 2 Feb 2010, Andras Simon wrote:

> Undefined foreign symbol: "atol64"
>   [Condition of type KERNEL:SIMPLE-PROGRAM-ERROR]
>

It looks like clsql_uffi.so doesn't get loaded. Manually loading it seems to
help.

Andras
Nathan Bird | 2 Feb 2010 22:11
Favicon

iso-timestring fix / proposal for saner timezones

This is one that we've had problems with and was also reported in the
survey.

iso-timestring used to output
      YYYY-MM-DD HH:MM:SS,,UUUUUU

This was an invalid format because there are the two commas and because
3 usec would be output as xx,,3 instead of xx.000003.  These invalid
timestamps were also unparseable by the
clsql:parse-timestring/parse-iso-8601-time functions.

It now outputs
      YYYY-MM-DD HH:MM:SS.UUUUUU
which should be a valid iso8601 timestamp and is parseable by
parse-timestring et al. Additionally, it does not print the ".UUUUUU"
part if there are no microseconds; useful for the databases that don't
support fractional seconds.

Patches that get us this far and a lot of tests to try and show it are
in the development branch.

The rest of this email documents a bug still present in clsql and offers
a proposal of how to fix it.
 * clsql:wall-time objects don't carry a timezone.
 * clsql-sys:parse-timestring:
  * with a timezone - shift by TZ into UTC so we don't have to store the
timezone information.
  * w/o a timezone (iso says it should be considered local) are parsed
directly into wall-time - no timezone shifting
 * Sending to databases
   * Many databases don't have any timezone info: ODBC, mysql,
sqlserver, some postgres datatypes.  We send and retrieve timezoneless.
This pretty much works.
   * databases' datatypes-with-a-timezone that receive a
timestring-without-a-timezone (what we currently output) read as local
in server's timezone; this is iso8601 behavior. When it is printed to
send back to CLSQL, the DB will add the timezone which clsql reads into
UTC resulting in a shift every roundtrip.  E.g. I send '2010-02-02' to
db, server reads, stores, and sends back (correctly) '2010-02-02
00:00:00-5' which CLSQL then parses as #<WALL-TIME: 2010-02-02
05:00:00.000000>. Through multiple trips loading and saving the data, it
will walk forward to the next day.

We propose adding some zone information to wall-times--or subclass
'iso-time'. It is a nullable slot that keeps track of what time zone
information was present when parsed. Parsing doesn't automatically shift
timezone to UTC. When printing a wall-time, if it has timezone info, we
print it in in the standard format, if it doesn't have timezone
information we print it as a local time which continues current behavior.

We add an explicit function to shift a wall-time's timezone to UTC,
updating the timezone field to keep track of that. All the math
functions would probably call that function before doing their own
operation to ease consistency of operations.

With this dates that are stored in fields with timezone data in the
database will retain that information and survive round trips. Entering
new dates from strings without timezone information will rely on setting
the db server or connection variable to the appropriate timezone. If you
are sticking those into a timezoneless field it should continue to work
as before.

--

-- 
Nathan Bird
nathan@...
http://www.acceleration.net/
Custom Programming, Design, Hosting, and Broadband.
Carlos Konstanski | 2 Feb 2010 22:26

Re: iso-timestring fix / proposal for saner timezones

On Tue, 2 Feb 2010, Nathan Bird wrote:

> Date: Tue, 02 Feb 2010 16:11:51 -0500
> From: Nathan Bird <nathan@...>
> To: clsql@...
> Subject: [CLSQL] iso-timestring fix / proposal for saner timezones
> 
> This is one that we've had problems with and was also reported in the
> survey.
>
> iso-timestring used to output
>      YYYY-MM-DD HH:MM:SS,,UUUUUU
>
> This was an invalid format because there are the two commas and because
> 3 usec would be output as xx,,3 instead of xx.000003.  These invalid
> timestamps were also unparseable by the
> clsql:parse-timestring/parse-iso-8601-time functions.
>
> It now outputs
>      YYYY-MM-DD HH:MM:SS.UUUUUU
> which should be a valid iso8601 timestamp and is parseable by
> parse-timestring et al. Additionally, it does not print the ".UUUUUU"
> part if there are no microseconds; useful for the databases that don't
> support fractional seconds.
>
> Patches that get us this far and a lot of tests to try and show it are
> in the development branch.
>
> The rest of this email documents a bug still present in clsql and offers
> a proposal of how to fix it.
> * clsql:wall-time objects don't carry a timezone.
> * clsql-sys:parse-timestring:
>  * with a timezone - shift by TZ into UTC so we don't have to store the
> timezone information.
>  * w/o a timezone (iso says it should be considered local) are parsed
> directly into wall-time - no timezone shifting
> * Sending to databases
>   * Many databases don't have any timezone info: ODBC, mysql,
> sqlserver, some postgres datatypes.  We send and retrieve timezoneless.
> This pretty much works.
>   * databases' datatypes-with-a-timezone that receive a
> timestring-without-a-timezone (what we currently output) read as local
> in server's timezone; this is iso8601 behavior. When it is printed to
> send back to CLSQL, the DB will add the timezone which clsql reads into
> UTC resulting in a shift every roundtrip.  E.g. I send '2010-02-02' to
> db, server reads, stores, and sends back (correctly) '2010-02-02
> 00:00:00-5' which CLSQL then parses as #<WALL-TIME: 2010-02-02
> 05:00:00.000000>. Through multiple trips loading and saving the data, it
> will walk forward to the next day.
>
>
> We propose adding some zone information to wall-times--or subclass
> 'iso-time'. It is a nullable slot that keeps track of what time zone
> information was present when parsed. Parsing doesn't automatically shift
> timezone to UTC. When printing a wall-time, if it has timezone info, we
> print it in in the standard format, if it doesn't have timezone
> information we print it as a local time which continues current behavior.
>
> We add an explicit function to shift a wall-time's timezone to UTC,
> updating the timezone field to keep track of that. All the math
> functions would probably call that function before doing their own
> operation to ease consistency of operations.
>
> With this dates that are stored in fields with timezone data in the
> database will retain that information and survive round trips. Entering
> new dates from strings without timezone information will rely on setting
> the db server or connection variable to the appropriate timezone. If you
> are sticking those into a timezoneless field it should continue to work
> as before.
>
> -- 
> Nathan Bird
> nathan@...
> http://www.acceleration.net/
> Custom Programming, Design, Hosting, and Broadband.

Thank you for the iso-timestring format fix, and the test of the
material re: timezones sounds great!

Carlos
Mackram Raydan | 2 Feb 2010 22:40
Picon

Connection pool issues with clsql

Hey everyone,

I am attempting to use the clsql in a production enviroment that is running Ubuntu 9.04 server edition (64 bit). In order to have good performance I am attempting to use a pool of connections however I am faced with the problem that every time I attempt to do a connection disconnect to return the thread to the pool I get an error and the whole thing crashes. Without pooling the system runs fine. Any one faced such a thing before?

Any help is much appreciated.

Regards,

Mackram Raydan

Company: www.imagimate.com
Website: www.trailoflight.net

"An invasion of armies can be resisted, but not an idea whose time has come." Victor Hugo
_______________________________________________
CLSQL mailing list
CLSQL@...
http://lists.b9.com/cgi-bin/mailman/listinfo/clsql
Carlos Konstanski | 2 Feb 2010 22:54

Re: Connection pool issues with clsql

On Tue, 2 Feb 2010, Mackram Raydan wrote:

> Date: Tue, 2 Feb 2010 23:40:23 +0200
> From: Mackram Raydan <mackram@...>
> To: clsql <clsql@...>
> Subject: [CLSQL] Connection pool issues with clsql
> 
> Hey everyone,
>
> I am attempting to use the clsql in a production enviroment that is running
> Ubuntu 9.04 server edition (64 bit). In order to have good performance I am
> attempting to use a pool of connections however I am faced with the problem
> that every time I attempt to do a connection disconnect to return the thread
> to the pool I get an error and the whole thing crashes. Without pooling the
> system runs fine. Any one faced such a thing before?
>
> Any help is much appreciated.
>
> Regards,
>
> Mackram Raydan
>
> Company: www.imagimate.com
> Website: www.trailoflight.net
>
> "An invasion of armies can be resisted, but not an idea whose time has
> come." Victor Hugo

I may have run into this a long time ago, if memory serves. It was too
long ago to be relevant today (I hope). Anyway, I abandoned connection
pooling, and adopted the methodology of opening a connection at the
beginning of a request, using that connection for the lifetime of the
request, and closing it at the end. Things run fast if you avoid
opening and closing connections during a transaction (I use the word
"transaction" loosely here to mean "all the stuff that happens during
one user operation, or request").

Carlos
Nathan Bird | 2 Feb 2010 23:12
Favicon

Re: Connection pool issues with clsql

On 2/2/2010 4:54 PM, Carlos Konstanski wrote:
> On Tue, 2 Feb 2010, Mackram Raydan wrote:
>
>> Date: Tue, 2 Feb 2010 23:40:23 +0200
>> From: Mackram Raydan <mackram@...>
>> To: clsql <clsql@...>
>> Subject: [CLSQL] Connection pool issues with clsql
>>
>> Hey everyone,
>>
>> I am attempting to use the clsql in a production enviroment that is
>> running
>> Ubuntu 9.04 server edition (64 bit). In order to have good
>> performance I am
>> attempting to use a pool of connections however I am faced with the
>> problem
>> that every time I attempt to do a connection disconnect to return the
>> thread
>> to the pool I get an error and the whole thing crashes. Without
>> pooling the
>> system runs fine. Any one faced such a thing before?
>>
>> Any help is much appreciated.
>>
>> Regards,
>>
>> Mackram Raydan
>>
>> Company: www.imagimate.com
>> Website: www.trailoflight.net
>>
>> "An invasion of armies can be resisted, but not an idea whose time has
>> come." Victor Hugo
>
> I may have run into this a long time ago, if memory serves. It was too
> long ago to be relevant today (I hope). Anyway, I abandoned connection
> pooling, and adopted the methodology of opening a connection at the
> beginning of a request, using that connection for the lifetime of the
> request, and closing it at the end. Things run fast if you avoid
> opening and closing connections during a transaction (I use the word
> "transaction" loosely here to mean "all the stuff that happens during
> one user operation, or request").
>
> Carlos
> _______________________________________________
> CLSQL mailing list
> CLSQL@...
> http://lists.b9.com/cgi-bin/mailman/listinfo/clsql

From what I recall looking at, connection pooling still has some
potential for race conditions from here:
http://lists.b9.com/pipermail/clsql/2009-June/001717.html.

Also if you are using view-class objects, each object stores its
connection and uses that one, so if you return a connection to the pool
it can still be referenced and used by an object even as another object
is trying to use that same connection in a different thread. I.e. don't
let objects outlive a connection to the database.

Also there are a couple of patches here:
http://github.com/UnwashedMeme/clsql/commits/uncontroversial/sql/pool.lisp
that have not yet been merged into master (they're on the list) attempt
to verify that a connection gotten from the database is still in working
order--normally another query to the database to ensure validity. This
still tends to be faster than building a new connection altogether.

--

-- 
Nathan Bird
nathan@...
http://www.acceleration.net/ 
Custom Programming, Design, Hosting, and Broadband.

Gmane