From 604b786d89a321e8f9f67dbf855dce26e4ce56f6 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 19 Sep 2007 23:16:30 +0000 Subject: * A feeble attempt at adding Grid db support to SQLite, just adding some code based on User db. Nothing hot-wired though. --- OpenSim/Framework/Data.SQLite/SQLiteManager.cs | 70 +++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) (limited to 'OpenSim/Framework/Data.SQLite/SQLiteManager.cs') diff --git a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs index 207fc82..f73f480 100644 --- a/OpenSim/Framework/Data.SQLite/SQLiteManager.cs +++ b/OpenSim/Framework/Data.SQLite/SQLiteManager.cs @@ -30,10 +30,11 @@ using System.Collections.Generic; using System.Data; using System.Data.SQLite; using libsecondlife; +using OpenSim.Framework.Console; namespace OpenSim.Framework.Data.SQLite { - class SQLiteManager + class SQLiteManager : SQLiteBase { IDbConnection dbcon; @@ -88,6 +89,73 @@ namespace OpenSim.Framework.Data.SQLite return (IDbCommand)dbcommand; } + private bool TestTables(SQLiteConnection conn) + { + SQLiteCommand cmd = new SQLiteCommand("SELECT * FROM regions", conn); + SQLiteDataAdapter pDa = new SQLiteDataAdapter(cmd); + DataSet tmpDS = new DataSet(); + try + { + pDa.Fill(tmpDS, "regions"); + } + catch (Mono.Data.SqliteClient.SqliteSyntaxException) + { + MainLog.Instance.Verbose("DATASTORE", "SQLite Database doesn't exist... creating"); + InitDB(conn); + } + return true; + } + + private DataTable createRegionsTable() + { + DataTable regions = new DataTable("regions"); + + createCol(regions, "regionHandle", typeof(ulong)); + createCol(regions, "regionName", typeof(System.String)); + createCol(regions, "uuid", typeof(System.String)); + + createCol(regions, "regionRecvKey", typeof(System.String)); + createCol(regions, "regionSecret", typeof(System.String)); + createCol(regions, "regionSendKey", typeof(System.String)); + + createCol(regions, "regionDataURI", typeof(System.String)); + createCol(regions, "serverIP", typeof(System.String)); + createCol(regions, "serverPort", typeof(System.String)); + createCol(regions, "serverURI", typeof(System.String)); + + + createCol(regions, "locX", typeof( uint)); + createCol(regions, "locY", typeof( uint)); + createCol(regions, "locZ", typeof( uint)); + + createCol(regions, "eastOverrideHandle", typeof( ulong )); + createCol(regions, "westOverrideHandle", typeof( ulong )); + createCol(regions, "southOverrideHandle", typeof( ulong )); + createCol(regions, "northOverrideHandle", typeof( ulong )); + + createCol(regions, "regionAssetURI", typeof(System.String)); + createCol(regions, "regionAssetRecvKey", typeof(System.String)); + createCol(regions, "regionAssetSendKey", typeof(System.String)); + + createCol(regions, "regionUserURI", typeof(System.String)); + createCol(regions, "regionUserRecvKey", typeof(System.String)); + createCol(regions, "regionUserSendKey", typeof(System.String)); + + // Add in contraints + regions.PrimaryKey = new DataColumn[] { regions.Columns["UUID"] }; + return regions; + } + + private void InitDB(SQLiteConnection conn) + { + string createUsers = defineTable(createRegionsTable()); + SQLiteCommand pcmd = new SQLiteCommand(createUsers, conn); + conn.Open(); + pcmd.ExecuteNonQuery(); + conn.Close(); + } + + /// /// Reads a region row from a database reader /// -- cgit v1.1