chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] Collating prepared statements in sqlite3: bug?


From: Thomas Chust
Subject: Re: [Chicken-hackers] Collating prepared statements in sqlite3: bug?
Date: Sat, 15 May 2010 11:45:27 +0200

2010/5/15 Peter Danenberg <address@hidden>:
> When I attempt to collate a prepared statement, the arguments to the
> collation function are the names of the column and not the values
> thereof.
> [...]

Hello,

I just tested this on Linux with CHICKEN 4.5.0, SQLite3 3.6.22 and
version 3.5.1 of my sqlite3 egg: I cannot reproduce the problem.

> [...]
>  "SELECT * FROM test ORDER BY ? COLLATE COLLATETHIS LIMIT ? OFFSET ?;"
> [...]

What's strange about this statement is that it tries to order the data
by the first query parameter, which is a constant for purposes of the
SQL statement, and hence recent versions of SQLite3 will never call
the collation function at all, since the ordering between a single
constant value and itself must never change.

So maybe your version of SQLite3 does less optimization and continues
to call the collation function on two copies of the first query
parameter for every row in the table you query.

If you actually intended to make the column by which the query results
are ordered variable, the statement you used is not suitable for that
purpose, neither is any prepared statement. In that case you actually
have to construct and compile a new SQL string for every column by
which you want to sort.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]