Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(865)

Unified Diff: sql/connection.cc

Issue 10989063: Changed DB to store node positions as Ordinals. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Implemented feedback changes. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index ea3dacbb6ba025dc248590a40031cc4a508541f4..ac19d4c8fdde1518854cfc4628cbf52d37c46ca8 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -11,8 +11,8 @@
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
-#include "sql/statement.h"
#include "third_party/sqlite/sqlite3.h"
+#include "sql/statement.h"
rlarocque 2012/10/01 21:45:55 This should be in alphabetical order.
vishwath 2012/10/02 01:06:33 Done.
namespace {
@@ -455,6 +455,29 @@ bool Connection::DoesColumnExist(const char* table_name,
return false;
}
+ColType Connection::GetColumnType(char* table_name,
+ int column_index) const {
+ std::string sql("PRAGMA TABLE INFO(");
+ sql.append(table_name);
+ sql.append(")");
+
+ Statement statement(GetUntrackedStatement(sql.c_str()));
+ for(int i = 0; i <= column_index; i++)
+ statement.Step();
+
+ std::string column_type = statement.ColumnString(2);
rlarocque 2012/10/01 21:45:55 When I suggested the PRAGMA TABLE INFO, it didn't
vishwath 2012/10/02 01:06:33 It turns out that the returned information is of a
rlarocque 2012/10/02 01:39:50 Not quite what I had in mind, but that looks OK.
+ if(column_type == "INTEGER")
+ return COLUMN_TYPE_INTEGER;
+ else if(column_type == "FLOAT")
+ return COLUMN_TYPE_FLOAT;
+ else if(column_type == "TEXT")
+ return COLUMN_TYPE_TEXT;
+ else if(column_type == "BLOB")
+ return COLUMN_TYPE_BLOB;
+
+ return COLUMN_TYPE_NULL;
+}
+
int64 Connection::GetLastInsertRowId() const {
if (!db_) {
DLOG(FATAL) << "Illegal use of connection without a db";

Powered by Google App Engine
This is Rietveld 408576698