<commit_before>using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.LandManagement;
using OpenSim.Region.Environment;
using OpenSim.Region.Interfaces;
using OpenSim.Framework.Console;
using OpenSim.Framework.Types;
using OpenSim.Framework.Utilities;
using libsecondlife;

using System.Data;
using System.Data.SqlTypes;

using Mono.Data.SqliteClient;

namespace OpenSim.DataStore.MonoSqliteStorage
{
    public class MonoSqliteDataStore : IRegionDataStore
    {
        private const string primSelect = "select * from prims";
        private const string shapeSelect = "select * from primshapes";
        
        private DataSet ds;
        private SqliteDataAdapter primDa;
        private SqliteDataAdapter shapeDa;

        /***********************************************************************
         *
         *  Public Interface Functions
         *
         **********************************************************************/
        public void Initialise(string dbfile, string dbname)
        {
            string connectionString = "URI=file:" + dbfile + ",version=3";
            
            ds = new DataSet();

            MainLog.Instance.Verbose("DATASTORE", "Sqlite - connecting: " + dbfile);
            SqliteConnection conn = new SqliteConnection(connectionString);

            SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn);
            primDa = new SqliteDataAdapter(primSelectCmd);
            //            SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);

            SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn);
            shapeDa = new SqliteDataAdapter(shapeSelectCmd);
            // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa);


            // We fill the data set, now we've got copies in memory for the information
            // TODO: see if the linkage actually holds.
            // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema");
            TestTables(conn);
            
            ds.Tables.Add(createPrimTable());
            primDa.Fill(ds.Tables["prims"]);
            setupPrimCommands(primDa, conn);
            MainLog.Instance.Verbose("DATASTORE", "Populated Prim Definitions");

            ds.Tables.Add(createShapeTable());
            shapeDa.Fill(ds.Tables["primshapes"]);
            setupShapeCommands(shapeDa, conn);
            MainLog.Instance.Verbose("DATASTORE", "Populated Prim Shapes");

            return;
        }
<commit_msg>Added temporary fix for the sqlite datastore exception in windows .Net, Added a Try catch block around "shapeDa.Fill(ds.Tables["primshapes"]);" line. Seems if the database file is empty (ie opensim has just created it or nothing has been stored in it yet.) then the exception will be fired and catch, then opensim can continue and have no problems (it will still save prims fine), then on next restart if the database file has entries in it, the exception will no longer be thrown.<commit_after>using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.LandManagement;
using OpenSim.Region.Environment;
using OpenSim.Region.Interfaces;
using OpenSim.Framework.Console;
using OpenSim.Framework.Types;
using OpenSim.Framework.Utilities;
using libsecondlife;

using System.Data;
using System.Data.SqlTypes;

using Mono.Data.SqliteClient;

namespace OpenSim.DataStore.MonoSqliteStorage
{
    public class MonoSqliteDataStore : IRegionDataStore
    {
        private const string primSelect = "select * from prims";
        private const string shapeSelect = "select * from primshapes";
        
        private DataSet ds;
        private SqliteDataAdapter primDa;
        private SqliteDataAdapter shapeDa;

        /***********************************************************************
         *
         *  Public Interface Functions
         *
         **********************************************************************/
        public void Initialise(string dbfile, string dbname)
        {
            string connectionString = "URI=file:" + dbfile + ",version=3";
            
            ds = new DataSet();

            MainLog.Instance.Verbose("DATASTORE", "Sqlite - connecting: " + dbfile);
            SqliteConnection conn = new SqliteConnection(connectionString);

            SqliteCommand primSelectCmd = new SqliteCommand(primSelect, conn);
            primDa = new SqliteDataAdapter(primSelectCmd);
            //            SqliteCommandBuilder primCb = new SqliteCommandBuilder(primDa);

            SqliteCommand shapeSelectCmd = new SqliteCommand(shapeSelect, conn);
            shapeDa = new SqliteDataAdapter(shapeSelectCmd);
            // SqliteCommandBuilder shapeCb = new SqliteCommandBuilder(shapeDa);


            // We fill the data set, now we've got copies in memory for the information
            // TODO: see if the linkage actually holds.
            // primDa.FillSchema(ds, SchemaType.Source, "PrimSchema");
            TestTables(conn);

            ds.Tables.Add(createPrimTable());
            primDa.Fill(ds.Tables["prims"]);
            setupPrimCommands(primDa, conn);
            MainLog.Instance.Verbose("DATASTORE", "Populated Prim Definitions");

            ds.Tables.Add(createShapeTable());

            try
            {
                shapeDa.Fill(ds.Tables["primshapes"]);
            }
            catch (Exception)
            {
                MainLog.Instance.Verbose("DATASTORE", "Caught fill error on primshapes table");
            }

            setupShapeCommands(shapeDa, conn);
            MainLog.Instance.Verbose("DATASTORE", "Populated Prim Shapes");

            return;
        }

{'fraction_non_alphanumeric': 0.1284850520658381, 'fraction_numerical': 0.0003359086328518643, 'mean_word_length': 2.7666034155597723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7061504', 'n_tokens_mistral': 1503, 'n_tokens_neox': 1464, 'n_words': 398}