Put debugging assertions into sql::Statement.

Pulls out the core of gbillock's http://codereview.chromium.org/8283002/
- Move NOTREACHED and similar checks into the sql:: implementation code.
- Add malformed SQL checks to Connection::Execute.
- Add SQL-checking convenience methods to Connection.

The general idea is that the sql:: framework assumes valid statements,
rather than having client code contain scattered ad-hoc (and thus
inconsistent) checks.

This version puts back Statement operator overloading and loosy-goosy
Execute() calls to allow other code to be updated in small batches.

[email protected],[email protected],[email protected] 
BUG=none
TEST=sql_unittests,unit_tests:*Table*.*


Review URL: http://codereview.chromium.org/8899012

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114118 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/sql/meta_table.cc b/sql/meta_table.cc
index c4736ef..1aef7f6 100644
--- a/sql/meta_table.cc
+++ b/sql/meta_table.cc
@@ -51,8 +51,7 @@
 
 bool MetaTable::SetValue(const char* key, const std::string& value) {
   Statement s;
-  if (!PrepareSetStatement(&s, key))
-    return false;
+  PrepareSetStatement(&s, key);
   s.BindString(1, value);
   return s.Run();
 }
@@ -68,9 +67,7 @@
 
 bool MetaTable::SetValue(const char* key, int value) {
   Statement s;
-  if (!PrepareSetStatement(&s, key))
-    return false;
-
+  PrepareSetStatement(&s, key);
   s.BindInt(1, value);
   return s.Run();
 }
@@ -86,8 +83,7 @@
 
 bool MetaTable::SetValue(const char* key, int64 value) {
   Statement s;
-  if (!PrepareSetStatement(&s, key))
-    return false;
+  PrepareSetStatement(&s, key);
   s.BindInt64(1, value);
   return s.Run();
 }
@@ -123,26 +119,17 @@
   return version;
 }
 
-bool MetaTable::PrepareSetStatement(Statement* statement, const char* key) {
+void MetaTable::PrepareSetStatement(Statement* statement, const char* key) {
   DCHECK(db_ && statement);
   statement->Assign(db_->GetCachedStatement(SQL_FROM_HERE,
       "INSERT OR REPLACE INTO meta (key,value) VALUES (?,?)"));
-  if (!statement->is_valid()) {
-    NOTREACHED() << db_->GetErrorMessage();
-    return false;
-  }
   statement->BindCString(0, key);
-  return true;
 }
 
 bool MetaTable::PrepareGetStatement(Statement* statement, const char* key) {
   DCHECK(db_ && statement);
   statement->Assign(db_->GetCachedStatement(SQL_FROM_HERE,
       "SELECT value FROM meta WHERE key=?"));
-  if (!statement->is_valid()) {
-    NOTREACHED() << db_->GetErrorMessage();
-    return false;
-  }
   statement->BindCString(0, key);
   if (!statement->Step())
     return false;