Drizzled Public API Documentation

systab_variable_ms.h

00001 /* Copyright (C) 2009 PrimeBase Technologies GmbH, Germany
00002  *
00003  * PrimeBase Media Stream for MySQL
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00018  *
00019  * Barry Leslie
00020  *
00021  * System variables table.
00022  *
00023  */
00024 
00025 #pragma once
00026 #ifndef __SYSTAB_VARIABLES_H__
00027 #define __SYSTAB_VARIABLES_H__
00028 
00029 #include "cslib/CSMutex.h"
00030 
00031 #include "defs_ms.h"
00032 #include "system_table_ms.h"
00033 #include "discover_ms.h"
00034 
00035 #define RESTORE_DUMP_VAR "Restoring-Dump"
00036 #define BACKUP_NUMBER_VAR "Backup-Number"
00037 #define VARIABLES_TABLE_NAME "pbms_variable"
00038 class MSVariableTable : public MSOpenSystemTable {
00039 public:
00040   MSVariableTable(MSSystemTableShare *share, TABLE *table);
00041   ~MSVariableTable();
00042 
00043   void use();
00044   void unuse();
00045   void seqScanInit();
00046   bool seqScanNext(char *buf);
00047   int getRefLen() { return sizeof(iVariableIndex);}
00048   void seqScanPos(unsigned char *pos);
00049   void seqScanRead(unsigned char *pos, char *buf);
00050 
00051   void updateRow(char *old_data, char *new_data);
00052 
00053   static void saveTable(MSDatabase *db);
00054   static void loadTable(MSDatabase *db);
00055   static void transferTable(MSDatabase *from_db, MSDatabase *to_db);
00056   static void setVariable(MSDatabase *db, const char *name, const char *value);
00057   static CSStringBuffer *dumpTable(MSDatabase *db);
00058   static void restoreTable(MSDatabase *db, const char *data, size_t size, bool reload = true);
00059   static void removeTable(CSString *db_path);
00060 
00061   static const uint8_t tableID = 0X04; // A unique id for the MSVariableTable dump data
00062   static const uint16_t tableVersion = 0X0001; // The current version of the table
00063 
00064 private:
00065   uint32_t      iVariableIndex;
00066   static CSLock gVarLock;
00067     
00068 };
00069 
00070 extern DT_FIELD_INFO pbms_variable_info[];
00071 extern DT_KEY_INFO pbms_variable_keys[];
00072 
00073 #endif // __SYSTAB_VARIABLES_H__