comparison src/sqlite.sml @ 1011:16f7cb0891b6

Initial support for char in SQL
author Adam Chlipala <adamc@hcoop.net>
date Thu, 22 Oct 2009 16:15:56 -0400
parents 034eeb099564
children ea9f03ac2710
comparison
equal deleted inserted replaced
1010:6b0f3853cc81 1011:16f7cb0891b6
34 fun p_sql_type t = 34 fun p_sql_type t =
35 case t of 35 case t of
36 Int => "integer" 36 Int => "integer"
37 | Float => "real" 37 | Float => "real"
38 | String => "text" 38 | String => "text"
39 | Char => "integer"
39 | Bool => "integer" 40 | Bool => "integer"
40 | Time => "text" 41 | Time => "text"
41 | Blob => "blob" 42 | Blob => "blob"
42 | Channel => "integer" 43 | Channel => "integer"
43 | Client => "integer" 44 | Client => "integer"
162 string "uw_sqlfmtFloat = \"%g%n\";", 163 string "uw_sqlfmtFloat = \"%g%n\";",
163 newline, 164 newline,
164 string "uw_Estrings = 0;", 165 string "uw_Estrings = 0;",
165 newline, 166 newline,
166 string "uw_sqlsuffixString = \"\";", 167 string "uw_sqlsuffixString = \"\";",
168 newline,
169 string "uw_sqlsuffixChar = \"\";",
167 newline, 170 newline,
168 string "uw_sqlsuffixBlob = \"\";", 171 string "uw_sqlsuffixBlob = \"\";",
169 newline, 172 newline,
170 string "uw_sqlfmtUint4 = \"%u%n\";", 173 string "uw_sqlfmtUint4 = \"%u%n\";",
171 newline], 174 newline],
368 | String => 371 | String =>
369 if wontLeakStrings then 372 if wontLeakStrings then
370 box [string "sqlite3_column_text(stmt, ", string (Int.toString i), string ")"] 373 box [string "sqlite3_column_text(stmt, ", string (Int.toString i), string ")"]
371 else 374 else
372 box [string "uw_strdup(ctx, sqlite3_column_text(stmt, ", string (Int.toString i), string "))"] 375 box [string "uw_strdup(ctx, sqlite3_column_text(stmt, ", string (Int.toString i), string "))"]
376 | Char => box [string "sqlite3_column_int(stmt, ", string (Int.toString i), string ")"]
373 | Bool => box [string "(uw_Basis_bool)sqlite3_column_int(stmt, ", string (Int.toString i), string ")"] 377 | Bool => box [string "(uw_Basis_bool)sqlite3_column_int(stmt, ", string (Int.toString i), string ")"]
374 | Time => box [string "uw_Basis_stringToTime_error(ctx, sqlite3_column_text(stmt, ", string (Int.toString i), string "))"] 378 | Time => box [string "uw_Basis_stringToTime_error(ctx, sqlite3_column_text(stmt, ", string (Int.toString i), string "))"]
375 | Blob => box [string "({", 379 | Blob => box [string "({",
376 newline, 380 newline,
377 string "char *data = (char *)sqlite3_column_blob(stmt, ", 381 string "char *data = (char *)sqlite3_column_blob(stmt, ",
521 | String => box [string "sqlite3_bind_text(stmt, ", 525 | String => box [string "sqlite3_bind_text(stmt, ",
522 string (Int.toString (i + 1)), 526 string (Int.toString (i + 1)),
523 string ", ", 527 string ", ",
524 arg, 528 arg,
525 string ", -1, SQLITE_TRANSIENT)"] 529 string ", -1, SQLITE_TRANSIENT)"]
530 | Char => box [string "sqlite3_bind_int(stmt, ",
531 string (Int.toString (i + 1)),
532 string ", ",
533 arg,
534 string ")"]
526 | Bool => box [string "sqlite3_bind_int(stmt, ", 535 | Bool => box [string "sqlite3_bind_int(stmt, ",
527 string (Int.toString (i + 1)), 536 string (Int.toString (i + 1)),
528 string ", ", 537 string ", ",
529 arg, 538 arg,
530 string ")"] 539 string ")"]