diff options
author | Sean Dague | 2007-08-08 17:59:16 +0000 |
---|---|---|
committer | Sean Dague | 2007-08-08 17:59:16 +0000 |
commit | 48ad7ca9057edd046370831b5a5604befe355426 (patch) | |
tree | 0b5d732dd9aa8445334239e94f6f8bf6ef41343f | |
parent | Added checks to the last commit to make sure the xml files exist before it tr... (diff) | |
download | opensim-SC_OLD-48ad7ca9057edd046370831b5a5604befe355426.zip opensim-SC_OLD-48ad7ca9057edd046370831b5a5604befe355426.tar.gz opensim-SC_OLD-48ad7ca9057edd046370831b5a5604befe355426.tar.bz2 opensim-SC_OLD-48ad7ca9057edd046370831b5a5604befe355426.tar.xz |
databits are actually flowing to disk
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs | 84 |
1 files changed, 50 insertions, 34 deletions
diff --git a/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs b/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs index d418a6d..b3d8f14 100644 --- a/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs +++ b/OpenSim/Region/Storage/OpenSim.DataStore.Sqlite/SqliteDataStore.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.DataStore.SqliteStorage | |||
48 | primDa.Fill(ds, "prims"); | 48 | primDa.Fill(ds, "prims"); |
49 | DataTable prims = ds.Tables["prims"]; | 49 | DataTable prims = ds.Tables["prims"]; |
50 | prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; | 50 | prims.PrimaryKey = new DataColumn[] { prims.Columns["UUID"] }; |
51 | setupPrimCommands(primDa); | 51 | setupPrimCommands(primDa, conn); |
52 | 52 | ||
53 | shapeDa.FillSchema(ds, SchemaType.Source, "ShapeSchema"); | 53 | shapeDa.FillSchema(ds, SchemaType.Source, "ShapeSchema"); |
54 | shapeDa.Fill(ds, "primshapes"); | 54 | shapeDa.Fill(ds, "primshapes"); |
@@ -56,34 +56,60 @@ namespace OpenSim.DataStore.SqliteStorage | |||
56 | return; | 56 | return; |
57 | } | 57 | } |
58 | 58 | ||
59 | private void setupPrimCommands(SqliteDataAdapter da) | 59 | private SqliteParameter createSqliteParameter(string name, DbType type) |
60 | { | 60 | { |
61 | SqliteCommand delete = new SqliteCommand("delete from prims where UUID=@UUID"); | 61 | SqliteParameter param = new SqliteParameter(); |
62 | SqliteParameterCollection parms = delete.Parameters; | 62 | param.ParameterName = ":" + name; |
63 | parms.Add("@UUID", SqlDbType.VarChar); | 63 | param.DbType = type; |
64 | parms["@UUID"].SourceVersion=DataRowVersion.Original; | 64 | param.SourceColumn = name; |
65 | da.DeleteCommand = delete; | 65 | param.SourceVersion = DataRowVersion.Current; |
66 | return param; | ||
67 | } | ||
66 | 68 | ||
69 | private void setupPrimCommands(SqliteDataAdapter da, SqliteConnection conn) | ||
70 | { | ||
71 | SqliteParameter UUID = createSqliteParameter("UUID", DbType.String); | ||
72 | SqliteParameter Name = createSqliteParameter("Name", DbType.String); | ||
73 | SqliteParameter CreationDate = createSqliteParameter("CreationDate", DbType.Int32); | ||
74 | SqliteParameter PositionX = createSqliteParameter("PositionX", DbType.Double); | ||
75 | SqliteParameter PositionY = createSqliteParameter("PositionY", DbType.Double); | ||
76 | SqliteParameter PositionZ = createSqliteParameter("PositionZ", DbType.Double); | ||
67 | 77 | ||
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 | 78 | ||
82 | // throw away for now until the rest works | 79 | SqliteCommand delete = new SqliteCommand("delete from prims where UUID=:UUID"); |
83 | string updateSQL = "update prims set name='update'"; | 80 | delete.Connection = conn; |
84 | SqliteCommand update = new SqliteCommand(updateSQL); | 81 | |
85 | da.UpdateCommand = update; | 82 | SqliteCommand insert = |
83 | new SqliteCommand("insert into prims(" + | ||
84 | "UUID, CreationDate, Name, PositionX, PositionY, PositionZ" + | ||
85 | ") values(:UUID, :CreationDate, :Name, :PositionX, :PositionY, :PositionZ)"); | ||
86 | insert.Connection = conn; | ||
87 | |||
88 | SqliteCommand update = | ||
89 | new SqliteCommand("update prims" + | ||
90 | "set CreationDate=:CreationDate, Name=:Name, PositionX=:PositionX, " + | ||
91 | "PositionY=:PositionY, PositionZ=:PositionZ where UUID=:UUID"); | ||
92 | update.Connection = conn; | ||
93 | |||
94 | delete.Parameters.Add(UUID); | ||
95 | |||
96 | insert.Parameters.Add(UUID); | ||
97 | insert.Parameters.Add(Name); | ||
98 | insert.Parameters.Add(CreationDate); | ||
99 | insert.Parameters.Add(PositionX); | ||
100 | insert.Parameters.Add(PositionY); | ||
101 | insert.Parameters.Add(PositionZ); | ||
102 | |||
103 | update.Parameters.Add(UUID); | ||
104 | update.Parameters.Add(Name); | ||
105 | update.Parameters.Add(CreationDate); | ||
106 | update.Parameters.Add(PositionX); | ||
107 | update.Parameters.Add(PositionY); | ||
108 | update.Parameters.Add(PositionZ); | ||
86 | 109 | ||
110 | da.DeleteCommand = delete; | ||
111 | da.InsertCommand = insert; | ||
112 | da.UpdateCommand = update; | ||
87 | } | 113 | } |
88 | 114 | ||
89 | private void StoreSceneObject(SceneObject obj) | 115 | private void StoreSceneObject(SceneObject obj) |
@@ -126,14 +152,6 @@ namespace OpenSim.DataStore.SqliteStorage | |||
126 | } | 152 | } |
127 | } | 153 | } |
128 | 154 | ||
129 | private void commit() | ||
130 | { | ||
131 | DataTable prims = ds.Tables["prims"]; | ||
132 | DataTable shapes = ds.Tables["shapes"]; | ||
133 | |||
134 | |||
135 | } | ||
136 | |||
137 | public void StoreObject(SceneObject obj) | 155 | public void StoreObject(SceneObject obj) |
138 | { | 156 | { |
139 | foreach (Primitive prim in obj.Children.Values) | 157 | foreach (Primitive prim in obj.Children.Values) |
@@ -145,8 +163,6 @@ namespace OpenSim.DataStore.SqliteStorage | |||
145 | MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); | 163 | MainLog.Instance.Verbose("Dump of prims:", ds.GetXml()); |
146 | } | 164 | } |
147 | 165 | ||
148 | |||
149 | |||
150 | public void RemoveObject(LLUUID obj) | 166 | public void RemoveObject(LLUUID obj) |
151 | { | 167 | { |
152 | // TODO: remove code | 168 | // TODO: remove code |