Drizzled Public API Documentation

systab_enabled_ms.cc
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 dump table.
00022  *
00023  */
00024 #ifndef DRIZZLED
00025 
00026 #include "cslib/CSConfig.h"
00027 
00028 #include <sys/types.h>
00029 #include <sys/stat.h>
00030 #include <stdlib.h>
00031 #include <time.h>
00032 
00033 //#include "mysql_priv.h"
00034 #include "cslib/CSGlobal.h"
00035 #include "cslib/CSStrUtil.h"
00036 
00037 #include "ha_pbms.h"
00038 //#include <plugin.h>
00039 
00040 #include "mysql_ms.h"
00041 #include "repository_ms.h"
00042 #include "database_ms.h"
00043 #include "compactor_ms.h"
00044 #include "open_table_ms.h"
00045 #include "discover_ms.h"
00046 #include "transaction_ms.h"
00047 #include "systab_variable_ms.h"
00048 #include "backup_ms.h"
00049 
00050 
00051 #include "systab_enabled_ms.h"
00052 
00053 
00054 DT_FIELD_INFO pbms_enabled_info[]=
00055 {
00056   {"Name",      32,   NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET,  NOT_NULL_FLAG,  "PBMS enabled engine name"},
00057   {"IsServer",    3,    NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET,          NOT_NULL_FLAG,  "Enabled at server level."},
00058   {"Transactional", 5,    NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET,          NOT_NULL_FLAG,  "Does the engine support transactions."},
00059   {"API-Version",   NOVAL,  NULL, MYSQL_TYPE_LONG,    NULL,             NOT_NULL_FLAG,  "The PBMS enabled api version used."},
00060   {NULL,NOVAL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
00061 };
00062 
00063 DT_KEY_INFO pbms_enabled_keys[]=
00064 {
00065   {"pbms_enabled_pk", PRI_KEY_FLAG, {"Name", NULL}},
00066   {NULL, 0, {NULL}}
00067 };
00068 
00069 
00070 /*
00071  * -------------------------------------------------------------------------
00072  * DUMP TABLE
00073  */
00074 //-----------------------
00075 MSEnabledTable::MSEnabledTable(MSSystemTableShare *share, TABLE *table):
00076 MSOpenSystemTable(share, table),
00077 iEnabledIndex(0)
00078 {
00079 }
00080 
00081 //-----------------------
00082 MSEnabledTable::~MSEnabledTable()
00083 {
00084 }
00085 
00086 //-----------------------
00087 void MSEnabledTable::seqScanInit()
00088 {
00089   iEnabledIndex = 0;
00090 }
00091 //-----------------------
00092 bool MSEnabledTable::seqScanNext(char *buf)
00093 {
00094   TABLE   *table = mySQLTable;
00095   Field   *curr_field;
00096   byte    *save;
00097   MY_BITMAP *save_write_set;
00098   const char *yesno;
00099   const PBMSEngineRec *eng;
00100   
00101   enter_();
00102   
00103   eng = MSEngine::getEngineInfoAt(iEnabledIndex++);
00104   if (!eng)
00105     return_(false);
00106   
00107   save_write_set = table->write_set;
00108   table->write_set = NULL;
00109 
00110 #ifdef DRIZZLED
00111   memset(buf, 0xFF, table->getNullBytes());
00112 #else
00113   memset(buf, 0xFF, table->s->null_bytes);
00114 #endif
00115 
00116   for (Field **field=GET_TABLE_FIELDS(table) ; *field ; field++) {
00117     curr_field = *field;
00118     save = curr_field->ptr;
00119 #if MYSQL_VERSION_ID < 50114
00120     curr_field->ptr = (byte *) buf + curr_field->offset();
00121 #else
00122 #ifdef DRIZZLED
00123     curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->getTable()->getInsertRecord());
00124 #else
00125     curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
00126 #endif
00127 #endif
00128 
00129     switch (curr_field->field_name[0]) {
00130       case 'N':
00131         ASSERT(strcmp(curr_field->field_name, "Name") == 0);
00132         curr_field->store(eng->ms_engine_name, strlen(eng->ms_engine_name), &UTF8_CHARSET);
00133         setNotNullInRecord(curr_field, buf);
00134         break;
00135 
00136       case 'I':
00137         ASSERT(strcmp(curr_field->field_name, "IsServer") == 0);
00138         if (eng->ms_internal)
00139           yesno = "Yes";
00140         else
00141           yesno = "No";
00142           
00143         curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
00144         setNotNullInRecord(curr_field, buf);
00145         break;
00146 
00147       case 'T': 
00148         ASSERT(strcmp(curr_field->field_name, "Transactional") == 0);
00149         if (eng->ms_internal || eng->ms_version < 2 )
00150           yesno = "Maybe";
00151         else if (eng->ms_has_transactions)
00152           yesno = "Yes";
00153         else
00154           yesno = "No";
00155           
00156         curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
00157         setNotNullInRecord(curr_field, buf);
00158         break;
00159 
00160       case 'A':
00161         ASSERT(strcmp(curr_field->field_name, "API-Version") == 0);
00162         curr_field->store(eng->ms_version, true);
00163         break;
00164 
00165     }
00166     curr_field->ptr = save;
00167   }
00168 
00169   table->write_set = save_write_set;
00170   return_(true);
00171 }
00172 
00173 //-----------------------
00174 void MSEnabledTable::seqScanPos(unsigned char *pos )
00175 {
00176   int32_t index = iEnabledIndex -1;
00177   if (index < 0)
00178     index = 0; // This is probably an error condition.
00179     
00180   mi_int4store(pos, index);
00181 }
00182 
00183 //-----------------------
00184 void MSEnabledTable::seqScanRead(unsigned char *pos , char *buf)
00185 {
00186   iEnabledIndex = mi_uint4korr(pos);
00187   seqScanNext(buf);
00188 }
00189 
00190 #endif // DRIZZLED
00191 
00192