diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs | 57 |
1 files changed, 52 insertions, 5 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs index d72cc2d..d418a6d 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs | |||
@@ -23,6 +23,8 @@ namespace OpenSim.DataStore.SqliteStorage | |||
23 | private const string shapeSelect = "select * from primshapes"; | 23 | private const string shapeSelect = "select * from primshapes"; |
24 | 24 | ||
25 | private DataSet ds; | 25 | private DataSet ds; |
26 | private SqliteDataAdapter primDa; | ||
27 | private SqliteDataAdapter shapeDa; | ||
26 | 28 | ||
27 | public void Initialise(string dbfile, string dbname) | 29 | public void Initialise(string dbfile, string dbname) |
28 | { | 30 | { |
@@ -31,24 +33,59 @@ namespace OpenSim.DataStore.SqliteStorage | |||
31 | SqliteConnection conn = new SqliteConnection(dbfile); | 33 | SqliteConnection conn = new SqliteConnection(dbfile); |
32 | 34 | ||
33 | SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); | 35 | SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn); |
34 | SqliteDataAdapter primDa = new SqliteDataAdapter(primSelectCmd); | 36 | primDa = new SqliteDataAdapter(primSelectCmd); |
37 | // SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa); | ||
35 | 38 | ||
36 | SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn); | 39 | SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn); |
37 | SqliteDataAdapter shapeDa = new SqliteDataAdapter(shapeSelectCmd); | 40 | shapeDa = new SqliteDataAdapter(shapeSelectCmd); |
41 | // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa); | ||
38 | 42 | ||
39 | ds = new DataSet(); | 43 | ds = new DataSet(); |
40 | 44 | ||
41 | // We fill the data set, now we've got copies in memory for the information | 45 | // We fill the data set, now we've got copies in memory for the information |
42 | // TODO: see if the linkage actually holds. | 46 | // TODO: see if the linkage actually holds. |
43 | primDa.FillSchema(ds, SchemaType.Mapped, "PrimSchema"); | 47 | primDa.FillSchema(ds, SchemaType.Source, "PrimSchema"); |
44 | primDa.Fill(ds, "prims"); | 48 | primDa.Fill(ds, "prims"); |
49 | DataTable prims = ds.Tables["prims"]; | ||
50 | prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; | ||
51 | setupPrimCommands(primDa); | ||
45 | 52 | ||
46 | shapeDa.FillSchema(ds, SchemaType.Mapped, "ShapeSchema"); | 53 | shapeDa.FillSchema(ds, SchemaType.Source, "ShapeSchema"); |
47 | shapeDa.Fill(ds, "primshapes"); | 54 | shapeDa.Fill(ds, "primshapes"); |
48 | 55 | ||
49 | return; | 56 | return; |
50 | } | 57 | } |
51 | 58 | ||
59 | private void setupPrimCommands(SqliteDataAdapter da) | ||
60 | { | ||
61 | SqliteCommand delete = new SqliteCommand("delete from prims where UUID=@UUID"); | ||
62 | SqliteParameterCollection parms = delete.Parameters; | ||
63 | parms.Add("@UUID", SqlDbType.VarChar); | ||
64 | parms["@UUID"].SourceVersion=DataRowVersion.Original; | ||
65 | da.DeleteCommand = delete; | ||
66 | |||
67 | |||
68 | string sql = "insert into prims(" + | ||
69 | "UUID, CreationDate, Name, PositionX, PositionY, PositionZ" + | ||
70 | ") values(@UUID, @CreationDate, @Name, @PositionX, @PositionY, @PositionZ)"; | ||
71 | SqliteCommand insert = new SqliteCommand(sql); | ||
72 | parms = insert.Parameters; | ||
73 | parms.Add("@UUID", SqlDbType.VarChar); | ||
74 | parms.Add("@CreationDate", SqlDbType.Int); | ||
75 | parms.Add("@Name", SqlDbType.VarChar); | ||
76 | parms.Add("@PositionX", SqlDbType.Float); | ||
77 | parms.Add("@PositionY", SqlDbType.Float); | ||
78 | parms.Add("@PositionZ", SqlDbType.Float); | ||
79 | parms["@UUID"].SourceVersion=DataRowVersion.Original; | ||
80 | da.InsertCommand = insert; | ||
81 | |||
82 | // throw away for now until the rest works | ||
83 | string updateSQL = "update prims set name='update'"; | ||
84 | SqliteCommand update = new SqliteCommand(updateSQL); | ||
85 | da.UpdateCommand = update; | ||
86 | |||
87 | } | ||
88 | |||
52 | private void StoreSceneObject(SceneObject obj) | 89 | private void StoreSceneObject(SceneObject obj) |
53 | { | 90 | { |
54 | 91 | ||
@@ -89,13 +126,23 @@ namespace OpenSim.DataStore.SqliteStorage | |||
89 | } | 126 | } |
90 | } | 127 | } |
91 | 128 | ||
129 | private void commit() | ||
130 | { | ||
131 | DataTable prims = ds.Tables["prims"]; | ||
132 | DataTable shapes = ds.Tables["shapes"]; | ||
133 | |||
134 | |||
135 | } | ||
136 | |||
92 | public void StoreObject(SceneObject obj) | 137 | public void StoreObject(SceneObject obj) |
93 | { | 138 | { |
94 | foreach (Primitive prim in obj.Children.Values) | 139 | foreach (Primitive prim in obj.Children.Values) |
95 | { | 140 | { |
96 | addPrim(prim); | 141 | addPrim(prim); |
97 | } | 142 | } |
98 | MainLog.Instance.Verbose("Dump of prims: {0}", ds.GetXml()); | 143 | |
144 | primDa.Update(ds, "prims"); | ||
145 | MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); | ||
99 | } | 146 | } |
100 | 147 | ||
101 | 148 | ||