comparison src/mysql.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
256 newline, 256 newline,
257 newline, 257 newline,
258 string "mysql_free_result(res);", 258 string "mysql_free_result(res);",
259 newline, 259 newline,
260 newline, 260 newline,
261 261
262 string "if (mysql_query(conn->conn, \"", 262 string "if (mysql_query(conn->conn, \"",
263 string q'', 263 string q'',
264 string "\")) {", 264 string "\")) {",
265 newline, 265 newline,
266 box [string "mysql_close(conn->conn);", 266 box [string "mysql_close(conn->conn);",
501 box [string "static void uw_db_prepare(uw_context ctx) { }", 501 box [string "static void uw_db_prepare(uw_context ctx) { }",
502 newline, 502 newline,
503 string "static void uw_db_validate(uw_context ctx) { }"], 503 string "static void uw_db_validate(uw_context ctx) { }"],
504 newline, 504 newline,
505 newline, 505 newline,
506 506
507 string "static void uw_db_init(uw_context ctx) {", 507 string "static void uw_db_init(uw_context ctx) {",
508 newline, 508 newline,
509 string "MYSQL *mysql = mysql_init(NULL);", 509 string "MYSQL *mysql = mysql_init(NULL);",
510 newline, 510 newline,
511 string "uw_conn *conn;", 511 string "uw_conn *conn;",
827 string (Int.toString i), 827 string (Int.toString i),
828 string "].is_null = &is_null", 828 string "].is_null = &is_null",
829 string (Int.toString i), 829 string (Int.toString i),
830 string ";", 830 string ";",
831 newline, 831 newline,
832 832
833 case t of 833 case t of
834 Nullable t => buffers t 834 Nullable t => buffers t
835 | _ => buffers t, 835 | _ => buffers t,
836 newline] 836 newline]
837 end) cols, 837 end) cols,
1121 string (Int.toString i), 1121 string (Int.toString i),
1122 string "].buffer = &in_buffer", 1122 string "].buffer = &in_buffer",
1123 string (Int.toString i), 1123 string (Int.toString i),
1124 string ";", 1124 string ";",
1125 newline] 1125 newline]
1126 1126
1127 | _ => box [string "in[", 1127 | _ => box [string "in[",
1128 string (Int.toString i), 1128 string (Int.toString i),
1129 string "].buffer = &arg", 1129 string "].buffer = &arg",
1130 string (Int.toString (i + 1)), 1130 string (Int.toString (i + 1)),
1131 string ";", 1131 string ";",
1135 string (Int.toString i), 1135 string (Int.toString i),
1136 string "].buffer_type = ", 1136 string "].buffer_type = ",
1137 string (p_buffer_type t), 1137 string (p_buffer_type t),
1138 string ";", 1138 string ";",
1139 newline, 1139 newline,
1140 1140
1141 case t of 1141 case t of
1142 Nullable t => box [string "in[", 1142 Nullable t => box [string "in[",
1143 string (Int.toString i), 1143 string (Int.toString i),
1144 string "].is_null = &in_is_null", 1144 string "].is_null = &in_is_null",
1145 string (Int.toString i), 1145 string (Int.toString i),
1175 newline, 1175 newline,
1176 buffers t, 1176 buffers t,
1177 newline], 1177 newline],
1178 string "}", 1178 string "}",
1179 newline] 1179 newline]
1180 1180
1181 | _ => buffers t, 1181 | _ => buffers t,
1182 newline] 1182 newline]
1183 end) inputs, 1183 end) inputs,
1184 newline, 1184 newline,
1185 1185
1402 string (Int.toString i), 1402 string (Int.toString i),
1403 string "].buffer = &in_buffer", 1403 string "].buffer = &in_buffer",
1404 string (Int.toString i), 1404 string (Int.toString i),
1405 string ";", 1405 string ";",
1406 newline] 1406 newline]
1407 1407
1408 | _ => box [string "in[", 1408 | _ => box [string "in[",
1409 string (Int.toString i), 1409 string (Int.toString i),
1410 string "].buffer = &arg", 1410 string "].buffer = &arg",
1411 string (Int.toString (i + 1)), 1411 string (Int.toString (i + 1)),
1412 string ";", 1412 string ";",
1423 Channel => box [string "in[", 1423 Channel => box [string "in[",
1424 string (Int.toString i), 1424 string (Int.toString i),
1425 string "].is_unsigned = 1;", 1425 string "].is_unsigned = 1;",
1426 newline] 1426 newline]
1427 | _ => box [], 1427 | _ => box [],
1428 1428
1429 case t of 1429 case t of
1430 Nullable t => box [string "in[", 1430 Nullable t => box [string "in[",
1431 string (Int.toString i), 1431 string (Int.toString i),
1432 string "].is_null = &in_is_null", 1432 string "].is_null = &in_is_null",
1433 string (Int.toString i), 1433 string (Int.toString i),
1463 newline, 1463 newline,
1464 buffers t, 1464 buffers t,
1465 newline], 1465 newline],
1466 string "}", 1466 string "}",
1467 newline] 1467 newline]
1468 1468
1469 | _ => buffers t, 1469 | _ => buffers t,
1470 newline] 1470 newline]
1471 end) inputs, 1471 end) inputs,
1472 newline, 1472 newline,
1473 1473
1527 1527
1528 fun p_blank _ = "?" 1528 fun p_blank _ = "?"
1529 1529
1530 val () = addDbms {name = "mysql", 1530 val () = addDbms {name = "mysql",
1531 header = Config.msheader, 1531 header = Config.msheader,
1532 randomFunction = "RAND",
1532 link = "-lmysqlclient", 1533 link = "-lmysqlclient",
1533 init = init, 1534 init = init,
1534 p_sql_type = p_sql_type, 1535 p_sql_type = p_sql_type,
1535 query = query, 1536 query = query,
1536 queryPrepared = queryPrepared, 1537 queryPrepared = queryPrepared,