1
/* Copyright (C) 2009 PrimeBase Technologies GmbH, Germany
3
* PrimeBase Media Stream for MySQL
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
#include "cslib/CSConfig.h"
28
#include <sys/types.h>
33
//#include "mysql_priv.h"
34
#include "cslib/CSGlobal.h"
35
#include "cslib/CSStrUtil.h"
41
#include "repository_ms.h"
42
#include "database_ms.h"
43
#include "compactor_ms.h"
44
#include "open_table_ms.h"
45
#include "discover_ms.h"
46
#include "transaction_ms.h"
47
#include "systab_variable_ms.h"
48
#include "backup_ms.h"
51
#include "systab_enabled_ms.h"
54
DT_FIELD_INFO pbms_enabled_info[]=
56
{"Name", 32, NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET, NOT_NULL_FLAG, "PBMS enabled engine name"},
57
{"IsServer", 3, NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET, NOT_NULL_FLAG, "Enabled at server level."},
58
{"Transactional", 5, NULL, MYSQL_TYPE_VARCHAR, &UTF8_CHARSET, NOT_NULL_FLAG, "Does the engine support transactions."},
59
{"API-Version", NOVAL, NULL, MYSQL_TYPE_LONG, NULL, NOT_NULL_FLAG, "The PBMS enabled api version used."},
60
{NULL,NOVAL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
63
DT_KEY_INFO pbms_enabled_keys[]=
65
{"pbms_enabled_pk", PRI_KEY_FLAG, {"Name", NULL}},
71
* -------------------------------------------------------------------------
74
//-----------------------
75
MSEnabledTable::MSEnabledTable(MSSystemTableShare *share, TABLE *table):
76
MSOpenSystemTable(share, table),
81
//-----------------------
82
MSEnabledTable::~MSEnabledTable()
86
//-----------------------
87
void MSEnabledTable::seqScanInit()
91
//-----------------------
92
bool MSEnabledTable::seqScanNext(char *buf)
94
TABLE *table = mySQLTable;
97
MY_BITMAP *save_write_set;
99
const PBMSEngineRec *eng;
103
eng = MSEngine::getEngineInfoAt(iEnabledIndex++);
107
save_write_set = table->write_set;
108
table->write_set = NULL;
111
memset(buf, 0xFF, table->getNullBytes());
113
memset(buf, 0xFF, table->s->null_bytes);
116
for (Field **field=GET_TABLE_FIELDS(table) ; *field ; field++) {
118
save = curr_field->ptr;
119
#if MYSQL_VERSION_ID < 50114
120
curr_field->ptr = (byte *) buf + curr_field->offset();
123
curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->getTable()->getInsertRecord());
125
curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
129
switch (curr_field->field_name[0]) {
131
ASSERT(strcmp(curr_field->field_name, "Name") == 0);
132
curr_field->store(eng->ms_engine_name, strlen(eng->ms_engine_name), &UTF8_CHARSET);
133
setNotNullInRecord(curr_field, buf);
137
ASSERT(strcmp(curr_field->field_name, "IsServer") == 0);
138
if (eng->ms_internal)
143
curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
144
setNotNullInRecord(curr_field, buf);
148
ASSERT(strcmp(curr_field->field_name, "Transactional") == 0);
149
if (eng->ms_internal || eng->ms_version < 2 )
151
else if (eng->ms_has_transactions)
156
curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
157
setNotNullInRecord(curr_field, buf);
161
ASSERT(strcmp(curr_field->field_name, "API-Version") == 0);
162
curr_field->store(eng->ms_version, true);
166
curr_field->ptr = save;
169
table->write_set = save_write_set;
173
//-----------------------
174
void MSEnabledTable::seqScanPos(unsigned char *pos )
176
int32_t index = iEnabledIndex -1;
178
index = 0; // This is probably an error condition.
180
mi_int4store(pos, index);
183
//-----------------------
184
void MSEnabledTable::seqScanRead(unsigned char *pos , char *buf)
186
iEnabledIndex = mi_uint4korr(pos);