# # patch "ChangeLog" # from [f5bfdf7c3ca1b53051a31b434a4233be723f1fba] # to [8660553a29b07571e429faf719cf633ed8bf745b] # # patch "database.cc" # from [fe6adbb653470b849f7a93a8cd2ac11bde9c7090] # to [9d64df5fbd6ea4685b9a556ad44ed025fd8d8242] # # patch "schema_migration.cc" # from [aa918744d273a47449f6fc9ea006c5119785617f] # to [0fbb5b522f316fd626766146e2196e3267ce29bf] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,9 @@ +2005-07-13 Derek Scherger + + * ChangeLog: + * database.cc: + * schema_migration.cc: merge cleanup + 2005-07-11 Nathaniel Smith * crypto_tests.cc: New SHA1 correctness tests from Kaushik Veeraraghavan. @@ -1584,533 +1590,8 @@ * tests/t_monotone_up.at: New test. * testsuite.at: Add it. -2005-05-24 Riccardo Ghetta - - * tests/t_merge_binary.at: new XFAIL test to cover monotone - inclination to algorithmically merge binary files. - -2005-05-23 Derek Scherger - - * database.cc (sqlite3_exec_printf, sqlite3_exec_vprintf): remove - (dump_table_cb): remove use of printf exec - (assert_sqlite3_ok): tweak error message format - * database_migration.cc (calculate_schema_id): - (move_table): - (migrate_client_merge_url_and_group): - (migrate_client_add_hashes_and_merkle_trees): - (migrate_client_to_revisions): - (migrate_client_to_epochs): - (migrate_client_to_vars): remove use of printf exec's - -2005-05-23 Timothy Brownawell - - Fix "automate stdio" input/output format according to ML discussion - * automate.cc: changed: automate_stdio - added: print_some_output, class my_stringbuf - * constants.{cc,hh}: add constant for automate stdio block size - * monotone.texi: update documentation - -2005-05-23 Nathaniel Smith - - * win32/terminal.cc (have_smart_terminal): Call _isatty on stderr, - not stdout. - -2005-05-23 Riccardo Ghetta - - * selectors.cc/.hh, database.cc: add two new selectors: - "earlier or equal than" and "later than". - * lua.cc/.hh, std-hooks.lua: create a new "expand_date" hook - * monotone.texi: document the changes - * testsuite.at, tests/t_selector_later_earlier.at: add specific tests - for the new selectors - -2005-05-21 Richard Levitte - - * Makefile.am: Make monotone.pdf and monotone.dvi depend on - version.texi. - -2005-05-21 Richard Levitte - - * monotone.texi: Add a note about the --brief option with - 'monotone log', and restructure the synopsis since it was getting - a bit silly with all possible variants. - -2005-05-21 Richard Levitte - - * commands.cc (log_certs): Add two arguments; a separator string - to be used in front of the second to last cert for multi-valued - cert types, a bool to say if each cert should be ended with a - newline. Overload with shortcuts. - (CMD(log)): Use the --brief option and implement it using the - shortcut variants of log_certs. - * monotone.cc, options.hh: Add the --brief option (OPT_BRIEF - internally). - * sanity.cc, sanity.hh (struct sanity): Add the member variable - and function to hold and set the brief flag. - -2005-05-21 Matt Johnston - - * tests/t_short_opts.at: remove the saved MT/log message - from the failed commit. - * Makefile.am: MAKEINFOFALGS to MAKEINFOFLAGS - -2005-05-21 Matt Johnston - - * commands.cc (commit): write the log message to MT/log - during the commit, so it will be available later if the commit - fails. - * work.{cc,hh} (write_user_log): new function - -2005-05-20 Nathaniel Smith - - * contrib/mtbrowse.sh: New file. - * contrib/README: Document it. Also, document some missed files, - and re-order listing. - * Makefile.am (EXTRA_DIST): Add several missing contrib/ files. - -2005-05-21 Grahame Bowland - - * automate.cc: (automate_certs) change "status" field - to "signature". Check whether each cert is trusted, and - output in the "trusted" field. - * testsuite.at: add t_automate_certs.at - * tests/t_automate_certs.at: Test that the output of - "automate certs" is consistent, and that we exit with - error when rev is incomplete or missing. - * monotone.texi: update output documentation for - "automate certs" - -2005-05-20 Emile Snyder - - * annotate.{hh,cc}: Rework to handle lineage dependent line - mappings and lines which split from a single line in a parent - revision into multiple lines in some descendent. Fixes bug where - some lines remained unannotated. Fixes wrong assignment of lines - bug. - * tests/t_annotate.at: Check no-changes since addition of file - case. - * tests/t_annotate_lineage_dependent.at - * tests/t_annotate_split_lines.at: New tests. - * testsuite.at: Add them. - -2005-05-20 Nathaniel Smith - - * monotone.texi (Network): Clarify that ports can be specified on - the command line to serve/pull/push/sync. - -2005-05-21 Matt Johnston - - * packet.cc (db_packet_writer::~impl, prerequisite.cleanup): - add code to remove up circular dependencies between prerequisite - and delayed_packet shared_ptrs upon destruction, so that unsatisified - dependency warnings are printed. - -2005-05-19 Matt Johnston - - * change_set.cc (merge_disjoint_analyses): handle the case where - a file is dropped on both sides but re-added on one. - * tests/t_drop_vs_dropadd.at: a test for it - * testsuite.at - -2005-05-19 Derek Scherger - - * commands.cc (checkout): rearrange to use --revision option - * monotone.1: - * monotone.texi: document checkout --revision option - * tests/t_attr.at: - * tests/t_attributes.at: - * tests/t_checkout_id_sets_branch.at: - * tests/t_checkout_noop_on_fail.at: - * tests/t_checkout_options.at: - * tests/t_cwork.at: - * tests/t_delete_dir.at: - * tests/t_delete_dir_patch.at: - * tests/t_empty_path.at: - * tests/t_i18n_file_data.at: - * tests/t_inodeprints_hook.at: - * tests/t_inodeprints_update.at: - * tests/t_largish_file.at: - * tests/t_lf_crlf.at: - * tests/t_monotone_up.at: - * tests/t_netsync_defaults.at: - * tests/t_netsync_set_defaults.at: - * tests/t_persistent_server_revision.at: - * tests/t_rename_added_in_rename.at: - * tests/t_rename_dir_cross_level.at: - * tests/t_rename_dir_patch.at: - * tests/t_single_char_filenames.at: - * tests/t_subdir_add.at: - * tests/t_subdir_attr.at: - * tests/t_subdir_drop.at: - * tests/t_subdir_rename.at: - * tests/t_subdir_revert.at: - * tests/t_tags.at: - * tests/t_update_off_branch.at: - * tests/t_versions.at: - * testsuite.at: add --revision option to checkout - -2005-05-18 Richard Levitte - - * ui.cc: Move the copyright and license section to the top of the - file, and add an emacs mode specifier. - * ui.cc (write_ticks): Change the counter ticker so the trailer - comes at the end of the counter line instead of the title line. - This is especially important for code that changes the trailer - a little now and then. - -2005-05-17 Grahame Bowland - - * commands.cc: add "automate certs ID" to the help string - for the automate command - * automate.cc: implement "automate certs". Add to the list - of commands available through "automate stdio". - * monotone.texi: document "automate certs" - -2005-05-17 Nathaniel Smith - - * monotone.texi (Network): Document 'serve' as taking more than - one collection argument. - -2005-05-15 graydon hoare - - * rcs_import.cc (note_state_at_branch_beginning): collect - branch beginning states into a single synthetic commit. - -2005-05-15 graydon hoare - - * rcs_import.cc: rewrite most of the branch logic to - address issues raised in bugs 13032 and 13063. - * tests/t_cvsimport_deleted_invar.at: un-XFAIL. - -2005-05-16 Matt Johnston - - * commands.cc (commit): change scope of the transaction guard so that - the transaction will fail before MT/revision is written (which could - leave a non-committed revision/bad working dir). - -2005-05-16 Grahame Bowland - - * monotone.texi: update "monotone log" documentation - * commands.cc: fix "monotone log" when run with no --revision args - -2005-05-15 Derek Scherger - - * tests/t_update_with_blocked_rename.at: new test - * testsuite.at: call it - -2005-05-15 Derek Scherger - - * netsync.cc (process_anonymous_cmd, process_auth_cmd): log - details of permissions allowed/denied - * tests/t_netsync_permissions.at: new test - * testsuite.at: call it - -2005-05-15 Richard Levitte - - * contrib/monotone-notify.pl (revision_is_in_branch): Another - place where --revision was missing. - -2005-05-14 Timothy Brownawell - - * contrib/monoprof.sh: Clean up variable definitions some. - - Add option --datadir, should now be usable without editing - variables to match system paths - - Add option --setup, generates most of the needed files - -2005-05-13 Timothy Brownawell - - Add "monotone automate stdio", to let the automation interface - take commands on standard input. - * automate.cc: (automate_stdio) New function. - (automate_command) Add it. - * commands.cc: Add to description for "automate". - * monotone.texi: Add to documentation. - -2005-05-13 Joel Reed - - * tests/t_unidiff3.at: opps. forgot to add this file which - should have been included as fix for bug 13072. - -2005-05-13 Joel Reed - - * diff_patch.cc, transforms.cc, testsuite.at: Patch from - address@hidden, who writes: "The attached patch should fix bug - 13072. I have no idea why the code in transform.cc insists on - adding an empty line in case the file is empty. Removing the code - didn't cause any regressions in the test suite and the - diff_patch.cc change corrects the output format. A new test case - is included as well." - -2005-05-13 Joel Reed - - * automate.cc: add automate attributes command - * commands.cc: add attributes subcommand helptext - * contrib/monotone.zsh_completion: use automate attributes - for completion of monotone attr and cleanup ignore files code - * tests/t_automate_attributes.at: add testcase - * testsuite.at: include new testcaes - -2005-05-13 Jon Bright - * testsuite.at (UNGZ): Change the way the ungzipping works on - Win32, in the hope that test 206 will no longer be given invalid - files. - -2005-05-12 Derek Scherger - - * automate.cc: bump version number to 1.0 - (struct inventory_item): add pre/post states - (inventory_paths): remove obsolete function - (inventory_pre_state, inventory_post_state, inventory_file_state, - inventory_renames): add fancy new functions - (automate_inventory): rework for new output format - * manifest.{cc,hh} (classify_paths): rename to ... - (classify_manifest_paths): ... this and work solely from manifest - * monotone.texi: (Automation): update inventory docs - * tests/t_automate_inventory.at: update for new format and add - some more tests - -2005-05-13 Matthew Gregan - - * HACKING: New file. First pass at a brief document to help - newcomers hack on monotone. - -2005-05-12 Riccardo Ghetta - - * options.hh (OPT_MSGFILE): New option. - * monotone.cc (message-file): New option. - (cpp_main): Handle it. - * app_state.{cc,hh} (set_message_file): New function. - * commands.cc (commit): Accept and handle new option. - * monotone.1, monotone.texi: Document it. - * tests/t_commit_message_file.at: New test. - * testsuite.at: Add it. - -2005-05-12 Timothy Brownawell - - * (20 files): Do not indent with both tabs and spaces in the same file. - -2005-05-13 Ulrich Drepper - - * rcs_import.cc (process_one_hunk): Improve handling of corrupt - RCS files. - -2005-05-13 Matthew Gregan - - * testsuite.at: Fix typo error in Win32 kill logic that was - causing the testsuites to hang on Win32 machines that don't have - pskill installed. - -2005-05-12 Matthew Gregan - - * file_io.cc (write_data_impl): Use portable boost::filesystem - calls in place of unlink(2)/remove(2). - -2005-05-12 Grahame Bowland - - * commands.cc: Modify the "log" command to accept multiple - revisions on command line, and display the log for all - of those revisions. - -2005-05-11 Nathaniel Smith - - * std_hooks.lua (ignore_file): Organize a bit more, add - patterns for autotools cache files, and darcs, codeville, git - metadata directories. - -2005-05-11 Timothy Brownawell - - * revision.cc (expand_dominators): Fix bitmap size-matching. - (find_common_ancestor_for_merge): Do not wait for ancestors - to be expanded to the beginning of time before expanding - dominators. Requires above fix for correct behavior. - * ChangeLog: Fix date on previous entry. - -2005-05-11 Timothy Brownawell - - * contrib/monoprof.sh: Add profiling test for "netsync large file". - Add options to only run specific profile tests. - -2005-05-11 Stanislav Karchebny - - * contrib/monotone-notify.pl: 'monotone log' takes a revision - through the --revision= option. - -2005-05-11 Richard Levitte - - * contrib/monotone-notify.pl: Change all occurences of $symbol' to - ${symbol}' to avoid a confusing Perl warning. - -2005-05-11 Joel Reed - - * contrib/monotone.zsh_completion: add zsh completion contrib. - -2005-05-11 Matt Johnston - - * tests/t_add_intermediate_MT_path.at: remove the drop dir part - * tests/t_delete_dir.at: add a note about re-enabling the above test - * tests/t_cvsimport3.at: ignore stderr - -2005-05-11 Matt Johnston - - * rcs_import.cc (find_branchpoint): if a branch is derived from two - differing parent branches, take the one closest to the trunk. - * tests/t_cvsimport3.at: add a test for cvs_importing where branches - come off a vendor import. - * testsuite.at: add it - -2005-05-11 Nathaniel Smith - - * work.cc (build_deletions): Disable delete_dir. - -2005-05-11 Matthew Gregan - - * constants.cc (constants::bufsz): Increase buffer size. Reduces - the runtime to tests/t_netsync_largish_file.at by four to seven - times on my test machines. - -2005-05-10 Timothy Brownawell - - * revision.cc: Make expand_{ancestors,dominators} twice as fast. - Loop over revisions in the other direction so that changes at the - frontier propogate fully in 1 pass, instead of one level at a time. - -2005-05-10 Timothy Brownawell - - * packet.{cc,hh}: Give packet_consumer and children a callback to call - after writing out a revision. - * netsync.cc: Use this callback to add a "revisions written" ticker, - to provide user feedback while sanity checking. - -2005-05-10 Timothy Brownawell - - * ui.cc: Make tick_write_count take less horizontal space - -2005-05-09 Nathaniel Smith - - * AUTHORS: Give Riccardo his real name. - * ChangeLog: Likewise. - -2005-05-09 Riccardo Ghetta - - * std_hooks.lua: Support kdiff3. - -2005-05-09 Matthew Gregan - - * lua.cc (loadstring, run_string): New parameter to identify the - source of the Lua string being loaded. - (add_{std,test}_hooks, load_rcfile): Pass an identity through. - -2005-05-09 Matthew Gregan - - * monotone.cc: Absolutify and tilde expand pid file. - -2005-05-09 Matthew Gregan - - * testsuite.at: Revert bogus changes committed in revision 9d478. - -2005-05-09 Matt Johnston - - * commands.cc (pid_file): use fs::path .empty() rather than ==, since - boost 1.31 doesn't seem to have the latter. - -2005-05-08 Matthew Gregan - - * lua.cc (report_error, load{file,string}): New member functions. - Error handling in call moved into report_error. - (call): Call report_error. - (run_{file,string}): Call load{file,string} member functions to - load Lua code into the VM. Allows us to report syntax errors when - loading rc files. - * testsuite.at: test_hooks.lua was calling nonexistent (obsolete) - strfind function and failing silently. The improved error - reporting from Lua caught this and cause testsuite failures. - -2005-05-08 Matthew Gregan - - * monotone.1: Document --pid-file option. Also make some minor - spelling and punctuation fixes. - -2005-05-08 Timothy Brownawell - * app_state.cc: {read,write}_options now print a warning instead of - failing on unreadable/unwritable MT/options . - * tests/t_unreadable_MT.at: add matching test - * testsuite.at: add test - * tests/README: Mention that new tests must be added to testsuite.at - * work.cc: (get_revision_id) Friendlier error message for - unreadable MT/revision . - -2005-05-08 Matthew Gregan - - * monotone.texi: Right words, wrong order. - * testsuite.at: Drop pid mapping trickery, it doesn't work - consistently. We now try and use SysInternal's pskill to kill the - process. If pskill is not available, we fall back to the old - 'kill all monotone processes' method. These changes affect - Win32/MingW only. - -2005-05-07 Matthew Gregan - - * commands.cc (pid_file): Remove leftover debugging output. - * configure.ac: Correct typos in TYPE_PID_T test. - * testsuite.at: Use some trickery on MingW/Cygwin to map the - Windows pid to the Cygwin pid. - * win32/process.cc (process_wait): Correct return type. - (process_spawn): Replace dropped cast on return. - -2005-05-07 Matt Johnston - - * change_set.cc: fix the code which skips deltas on deleted files, - it was looking at the merged filename not the ancestor - filename. - * tests/t_drop_vs_patch_rename.at: a test for the above fix - * testsuite.at: add it - -2005-05-06 Timothy Brownawell - - * contrib/monoprof.sh: Add lcad test. - Add options to pull/rebuild before profiling. - -2005-05-06 Nathaniel Smith - - * INSTALL: s/g++ 3.2 or 3.3/g++ 3.2 or later/. - -2005-05-06 Nathaniel Smith - - * monotone.1: - * monotone.texi (Commands, Importing from CVS, RCS): Clarify - cvs_import documentation on cvsroot vs. module issues. - -2005-05-05 Richard Levitte - - * AUTHORS: Add rghetta. - 2005-05-05 Matthew Gregan - * monotone.texi: Document --pid-file option for serve command. - * app_state.{cc,hh} (set_pidfile, pidfile): New function, new - member. - * commands.cc (pid_file): New class. - (CMD(serve)): Use pid_file. - * monotone.cc (coptions, cppmain): Add command-specific option - --pid-file. - * options.hh (OPT_PIDFILE): New option. - * {unix,win32}/process.cc (get_process_id): New function. - (process_{spawn,wait,kill}): Use pid_t. - * platform.hh (process_{spawn,wait,kill}): Use pid_t. - (get_process_id): New function - * configure.ac: Test for pid_t. - * lua.cc (monotone_{spawn,wait,kill}_for_lua): Use pid_t. - * testsuite.at: Update netsync kill functions to use pid file. - * tests/t_netsync_sigpipe.at: Update to use pid file. - * tests/t_netsync_single.at: Update to use pid file. - -2005-05-04 Nathaniel Smith - - * tests/t_monotone_up.at: New test. - * testsuite.at: Add it. - -2005-05-05 Matthew Gregan - * work.cc: Use attr_file_name rather than hardcoded strings. 2005-05-04 Brian Campbell --- database.cc +++ database.cc @@ -59,7 +59,7 @@ extern "C" { // some wrappers to ease migration const char *sqlite3_value_text_s(sqlite3_value *v); - const char *sqlite3_column_text_s(sqlite3_stmt*, int iCol); + const char *sqlite3_column_text_s(sqlite3_stmt*, int col); } database::database(fs::path const & fn) : @@ -72,7 +72,6 @@ schema("1509fd75019aebef5ac3da3a5edf1312393b70e9"), __sql(NULL), transaction_level(0) - {} void @@ -168,10 +167,7 @@ const char * errmsg = sqlite3_errmsg(s); - ostringstream oss; - oss << "sqlite error [" << errcode << "]: " << errmsg; - - throw oops(oss.str()); + E(errcode == SQLITE_OK, F("sqlite error [%d]: %s") % errcode % errmsg); } struct sqlite3 * @@ -284,9 +280,10 @@ I(string(vals[1]) == "table"); *(dump->out) << vals[2] << ";\n"; dump->table_name = string(vals[0]); - dump->table_name = string(vals[0]); - string query = "SELECT * FROM " + string(vals[0]); - int result = sqlite3_exec(dump->sql, query.c_str(), dump_row_cb, data, NULL); + string query = "SELECT * FROM " + string(vals[0]); + sqlite3_exec(dump->sql, query.c_str(), dump_row_cb, data, NULL); + assert_sqlite3_ok(dump->sql); + return 0; } static int @@ -318,13 +315,13 @@ "WHERE type='table' AND sql NOT NULL " "ORDER BY name", dump_table_cb, &req, NULL); - I(res == SQLITE_OK); + assert_sqlite3_ok(req.sql); res = sqlite3_exec(req.sql, "SELECT name, type, sql FROM sqlite_master " "WHERE type='index' AND sql NOT NULL " "ORDER BY name", dump_index_cb, &req, NULL); - I(res == SQLITE_OK); + assert_sqlite3_ok(req.sql); out << "COMMIT;\n"; } @@ -353,7 +350,7 @@ if (last_statement == 0) continue; string::size_type len = last_statement + 1 - tmp.c_str(); - execute(tmp.substr(0, len).c_str()); + sqlite3_exec(__sql, tmp.substr(0, len).c_str(), NULL, NULL, NULL); tmp.erase(0, len); } @@ -742,17 +739,16 @@ sqlite3_prepare(sql(), query, -1, &i->second.stmt, &tail); assert_sqlite3_ok(sql()); L(F("prepared statement %s\n") % query); - I(*tail == 0); // no support for multiple statements - } - // do it - rescode = sqlite3_get_table_vprintf(sql(), query, &result, &nrow, &ncol, &errmsg, ap); + // no support for multiple statements here + E(*tail == 0, + F("multiple statements in query: %s\n") % query); + } ncol = sqlite3_column_count(i->second.stmt); - if (want_cols != any_cols && ncol != want_cols) - throw oops((F("%s wanted %d columns, got %s") - % ctx % want_cols % ncol).str()); + E(want_cols == any_cols || want_cols == ncol, + F("wanted %d columns got %d in query: %s\n") % want_cols % ncol % query); // bind parameters for this execution @@ -765,7 +761,15 @@ char *value = va_arg(args, char *); // nb: transient will not be good for inserts with large data blobs // however, it's no worse than the previous '%q' stuff in this regard - L(F("binding %d with value '%s'\n") % param % value); + // might want to wrap this logging with --debug or --verbose to limit it + + string log = string(value); + + if (log.size() > constants::log_line_sz) + log = log.substr(0, constants::log_line_sz); + + L(F("binding %d with value '%s'\n") % param % log); + sqlite3_bind_text(i->second.stmt, param, value, -1, SQLITE_TRANSIENT); assert_sqlite3_ok(sql()); } @@ -780,7 +784,7 @@ for (int col = 0; col < ncol; col++) { const char * value = sqlite3_column_text_s(i->second.stmt, col); - if (!value) throw oops(ctx + "null result value"); + E(value, F("null result in query: %s\n") % query); row.push_back(value); //L(F("row %d col %d value='%s'\n") % nrow % col % value); } @@ -797,8 +801,8 @@ i->second.count++; - if (want_rows != any_rows && nrow != want_rows) - throw oops((F("%s wanted %d rows, got %s") % ctx % want_rows % nrow).str()); + E(want_rows == any_rows || want_rows == nrow, + F("wanted %d rows got %s in query: %s\n") % want_rows % nrow % query); } // general application-level logic @@ -877,7 +881,7 @@ database::count(string const & table) { results res; - std::string query="SELECT COUNT(*) FROM "+table; + string query = "SELECT COUNT(*) FROM " + table; fetch(res, one_col, one_row, query.c_str()); return lexical_cast(res[0][0]); } @@ -886,8 +890,8 @@ database::space_usage(string const & table, string const & concatenated_columns) { results res; - fetch(res, one_col, one_row, - ("SELECT SUM(LENGTH("+concatenated_columns+")) FROM "+table).c_str()); + string query = "SELECT SUM(LENGTH(" + concatenated_columns + ")) FROM " + table; + fetch(res, one_col, one_row, query.c_str()); return lexical_cast(res[0][0]); } @@ -895,9 +899,9 @@ database::get_ids(string const & table, set< hexenc > & ids) { results res; + string query = "SELECT id FROM " + table; + fetch(res, one_col, any_rows, query.c_str()); - fetch(res, one_col, any_rows, ("SELECT id FROM "+table).c_str()); - for (size_t i = 0; i < res.size(); ++i) { ids.insert(hexenc(res[i][0])); @@ -934,8 +938,8 @@ I(ident() != ""); I(base() != ""); results res; - fetch(res, one_col, one_row, - ("SELECT delta FROM "+table+" WHERE id = ? AND base = ?").c_str(), + string query = "SELECT delta FROM " + table + " WHERE id = ? AND base = ?"; + fetch(res, one_col, one_row, query.c_str(), ident().c_str(), base().c_str()); base64 > del_packed = res[0][0]; @@ -956,8 +960,8 @@ base64 > dat_packed; pack(dat, dat_packed); - execute(("INSERT INTO "+table+" VALUES(?, ?)").c_str(), - ident().c_str(), dat_packed().c_str()); + string insert = "INSERT INTO " + table + " VALUES(?, ?)"; + execute(insert.c_str(),ident().c_str(), dat_packed().c_str()); } void database::put_delta(hexenc const & ident, @@ -972,8 +976,8 @@ base64 > del_packed; pack(del, del_packed); - execute(("INSERT INTO "+table+" VALUES(?, ?, ?)").c_str(), - ident().c_str(), base().c_str(), del_packed().c_str()); + string insert = "INSERT INTO "+table+" VALUES(?, ?, ?)"; + execute(insert.c_str(), ident().c_str(), base().c_str(), del_packed().c_str()); } // static ticker cache_hits("vcache hits", "h", 1); @@ -1543,8 +1547,7 @@ // perform the actual SQL transactions to kill rev rid here L(F("Killing revision %s locally\n") % rid); execute("DELETE from revision_certs WHERE id = ?",rid.inner()().c_str()); - execute("DELETE from revision_ancestry WHERE child = ?", - rid.inner()().c_str()); + execute("DELETE from revision_ancestry WHERE child = ?", rid.inner()().c_str()); execute("DELETE from revisions WHERE id = ?",rid.inner()().c_str()); } @@ -1600,7 +1603,8 @@ { keys.clear(); results res; - fetch(res, one_col, any_rows, ("SELECT id from "+table).c_str()); + string query = "SELECT id FROM " + table; + fetch(res, one_col, any_rows, query.c_str()); for (size_t i = 0; i < res.size(); ++i) keys.push_back(res[i][0]); } @@ -1778,7 +1782,7 @@ hexenc thash; cert_hash_code(t, thash); - string insert = "INSERT INTO " + table + " VALUES(?, ?, ?, ?, ?, ?) "; + string insert = "INSERT INTO " + table + " VALUES(?, ?, ?, ?, ?, ?)"; execute(insert.c_str(), thash().c_str(), @@ -1848,8 +1852,8 @@ string const & table) { results res; - fetch(res, 5, any_rows, - ("SELECT id, name, value, keypair, signature FROM "+table).c_str()); + string query = "SELECT id, name, value, keypair, signature FROM " + table; + fetch(res, 5, any_rows, query.c_str()); results_to_certs(res, certs); } --- schema_migration.cc +++ schema_migration.cc @@ -152,15 +152,15 @@ { id.clear(); string tmp, tmp2; - int res = sqlite3_exec_printf(sql, - "SELECT sql FROM sqlite_master " - "WHERE type = 'table' OR type = 'index' " - // filter out NULL sql statements, because - // those are auto-generated indices (for - // UNIQUE constraints, etc.). - "AND sql IS NOT NULL " - "ORDER BY name", - &append_sql_stmt, &tmp, NULL); + int res = sqlite3_exec(sql, + "SELECT sql FROM sqlite_master " + "WHERE (type = 'table' OR type = 'index') " + // filter out NULL sql statements, because + // those are auto-generated indices (for + // UNIQUE constraints, etc.). + "AND sql IS NOT NULL " + "ORDER BY name", + &append_sql_stmt, &tmp, NULL); if (res != SQLITE_OK) { sqlite3_exec(sql, "ROLLBACK", NULL, NULL, NULL); @@ -707,14 +707,14 @@ { int res; - res = sqlite3_exec_printf(sql, - "CREATE TABLE db_vars\n" - "(\n" - "domain not null, -- scope of application of a var\n" - "name not null, -- var key\n" - "value not null, -- var value\n" - "unique(domain, name)\n" - ");", NULL, NULL, errmsg); + res = sqlite3_exec(sql, + "CREATE TABLE db_vars\n" + "(\n" + "domain not null, -- scope of application of a var\n" + "name not null, -- var key\n" + "value not null, -- var value\n" + "unique(domain, name)\n" + ");", NULL, NULL, errmsg); if (res != SQLITE_OK) return false; @@ -727,24 +727,24 @@ { int res; - res = sqlite3_exec_printf(sql, - "CREATE INDEX revision_ancestry__child " - "ON revision_ancestry (child)", - NULL, NULL, errmsg); + res = sqlite3_exec(sql, + "CREATE INDEX revision_ancestry__child " + "ON revision_ancestry (child)", + NULL, NULL, errmsg); if (res != SQLITE_OK) return false; - res = sqlite3_exec_printf(sql, - "CREATE INDEX revision_certs__id " - "ON revision_certs (id);", - NULL, NULL, errmsg); + res = sqlite3_exec(sql, + "CREATE INDEX revision_certs__id " + "ON revision_certs (id);", + NULL, NULL, errmsg); if (res != SQLITE_OK) return false; - res = sqlite3_exec_printf(sql, - "CREATE INDEX revision_certs__name_value " - "ON revision_certs (name, value);", - NULL, NULL, errmsg); + res = sqlite3_exec(sql, + "CREATE INDEX revision_certs__name_value " + "ON revision_certs (name, value);", + NULL, NULL, errmsg); if (res != SQLITE_OK) return false;