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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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", NULL, NULL, MYSQL_TYPE_LONG, NULL, NOT_NULL_FLAG, "The PBMS enabled api version used."},
60
{NULL,NULL, 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;
110
memset(buf, 0xFF, table->s->null_bytes);
111
for (Field **field=GET_TABLE_FIELDS(table) ; *field ; field++) {
113
save = curr_field->ptr;
114
#if MYSQL_VERSION_ID < 50114
115
curr_field->ptr = (byte *) buf + curr_field->offset();
117
curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
120
switch (curr_field->field_name[0]) {
122
ASSERT(strcmp(curr_field->field_name, "Name") == 0);
123
curr_field->store(eng->ms_engine_name, strlen(eng->ms_engine_name), &UTF8_CHARSET);
124
setNotNullInRecord(curr_field, buf);
128
ASSERT(strcmp(curr_field->field_name, "IsServer") == 0);
129
if (eng->ms_internal)
134
curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
135
setNotNullInRecord(curr_field, buf);
139
ASSERT(strcmp(curr_field->field_name, "Transactional") == 0);
140
if (eng->ms_internal || eng->ms_version < 2 )
142
else if (eng->ms_has_transactions)
147
curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
148
setNotNullInRecord(curr_field, buf);
152
ASSERT(strcmp(curr_field->field_name, "API-Version") == 0);
153
curr_field->store(eng->ms_version, true);
157
curr_field->ptr = save;
160
table->write_set = save_write_set;
164
//-----------------------
165
void MSEnabledTable::seqScanPos(uint8_t *pos)
167
int32_t index = iEnabledIndex -1;
169
index = 0; // This is probably an error condition.
171
mi_int4store(pos, index);
174
//-----------------------
175
void MSEnabledTable::seqScanRead(uint8_t *pos, char *buf)
177
iEnabledIndex = mi_uint4korr(pos);