示例#1
0
 // CRUD functions
 public void CreateDB(string dbName, DatabaseDefinition dbDef = null)
 {
     try {
         TXN_BEGIN(dbName: dbName);
         DataFunctions.CreateDB(activeDStore, dbName, dbDef);
     }
     finally {
         TXN_END();
     }
 }
示例#2
0
        private void VerifyLocksTable(DataStore dstore)
        {
            logger.Debug("VerifyLocksTable");

            // ensure connection database
            DatabaseDefinition connDbDef;

            try {
                // if db exists we're good
                connDbDef = DataFunctions.ReadDB(dstore, connDbName);
            }
            catch {
                // otherwise create it
                var newConnDbDef = new DatabaseDefinition(dbName: connDbName)
                {
                    Description = "Internal DB"
                };

                // create the connection management database
                DataFunctions.CreateDB(dstore, connDbName, newConnDbDef);
            }

            // ensue locks table
            TableDefinition locksTableDef;

            try {
                // if table exists we're good
                locksTableDef = DataFunctions.ReadTable(dstore, connDbName, connDbLocksTableName);
            }
            catch {
                // otherwise create it
                // locks have fields for dbname, tablename and record keys but they're not wired
                // - to allow implicit locking of nonexisting entries
                // - to remove the need to update wires when new tables and dbs are created
                var newlocksTableDef = new TableDefinition()
                {
                    Fields = new List <Field>()
                    {
                        new UUIDField(connDbLockUUIDField),
                        new TextField(connDbLockSourceField),
                        new TextField(connDbLockRequesterField),
                        new UUIDField(connDbLockConnUUIDField),
                        new TextField(connDbLockDBField),
                        new TextField(connDbLockTableField),
                        new TextField(connDbLockRecordKeyField),
                    },
                    Description     = "Locks Table",
                    IsHidden        = true,
                    SupportsHistory = false
                };

                // create transaction locks table
                DataFunctions.CreateTable(dstore, connDbName, connDbLocksTableName, newlocksTableDef);
            }
        }