comparison src/sqlite.sml @ 1682:ac141fbb313a

'ORDER BY RANDOM' (based on a patch from Ron de Bruijn)
author Adam Chlipala <adam@chlipala.net>
date Thu, 02 Feb 2012 11:40:10 -0500
parents 3e7c7e200713
children 59b07fdae1ff
comparison
equal deleted inserted replaced
1681:e8a84494d2c0 1682:ac141fbb313a
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
253 box [string "static void uw_db_prepare(uw_context ctx) { }", 253 box [string "static void uw_db_prepare(uw_context ctx) { }",
254 newline, 254 newline,
255 string "static void uw_db_validate(uw_context ctx) { }"], 255 string "static void uw_db_validate(uw_context ctx) { }"],
256 newline, 256 newline,
257 newline, 257 newline,
258 258
259 string "static void uw_db_init(uw_context ctx) {", 259 string "static void uw_db_init(uw_context ctx) {",
260 newline, 260 newline,
261 string "sqlite3 *sqlite;", 261 string "sqlite3 *sqlite;",
262 newline, 262 newline,
263 string "sqlite3_stmt *stmt;", 263 string "sqlite3_stmt *stmt;",
306 string "sqlite3_finalize(stmt);", 306 string "sqlite3_finalize(stmt);",
307 newline], 307 newline],
308 string "}", 308 string "}",
309 newline, 309 newline,
310 newline, 310 newline,
311 311
312 string "conn = calloc(1, sizeof(uw_conn));", 312 string "conn = calloc(1, sizeof(uw_conn));",
313 newline, 313 newline,
314 string "conn->conn = sqlite;", 314 string "conn->conn = sqlite;",
315 newline, 315 newline,
316 string "uw_set_db(ctx, conn);", 316 string "uw_set_db(ctx, conn);",
818 fun p_cast (s, _) = s 818 fun p_cast (s, _) = s
819 819
820 fun p_blank _ = "?" 820 fun p_blank _ = "?"
821 821
822 val () = addDbms {name = "sqlite", 822 val () = addDbms {name = "sqlite",
823 randomFunction = "RANDOM",
823 header = Config.sqheader, 824 header = Config.sqheader,
824 link = "-lsqlite3", 825 link = "-lsqlite3",
825 init = init, 826 init = init,
826 p_sql_type = p_sql_type, 827 p_sql_type = p_sql_type,
827 query = query, 828 query = query,