~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbms/src/systab_enabled_ms.cc

  • Committer: Mark Atwood
  • Date: 2011-12-20 02:32:53 UTC
  • mfrom: (2469.1.1 drizzle-build)
  • Revision ID: me@mark.atwood.name-20111220023253-bvu0kr14kwsdvz7g
mergeĀ lp:~brianaker/drizzle/deprecate-pbms

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2009 PrimeBase Technologies GmbH, Germany
2
 
 *
3
 
 * PrimeBase Media Stream for MySQL
4
 
 *
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.
9
 
 *
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.
14
 
 *
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
18
 
 *
19
 
 * Barry Leslie
20
 
 *
21
 
 * System dump table.
22
 
 *
23
 
 */
24
 
#ifndef DRIZZLED
25
 
 
26
 
#include "cslib/CSConfig.h"
27
 
 
28
 
#include <sys/types.h>
29
 
#include <sys/stat.h>
30
 
#include <stdlib.h>
31
 
#include <time.h>
32
 
 
33
 
//#include "mysql_priv.h"
34
 
#include "cslib/CSGlobal.h"
35
 
#include "cslib/CSStrUtil.h"
36
 
 
37
 
#include "ha_pbms.h"
38
 
//#include <plugin.h>
39
 
 
40
 
#include "mysql_ms.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"
49
 
 
50
 
 
51
 
#include "systab_enabled_ms.h"
52
 
 
53
 
 
54
 
DT_FIELD_INFO pbms_enabled_info[]=
55
 
{
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}
61
 
};
62
 
 
63
 
DT_KEY_INFO pbms_enabled_keys[]=
64
 
{
65
 
        {"pbms_enabled_pk", PRI_KEY_FLAG, {"Name", NULL}},
66
 
        {NULL, 0, {NULL}}
67
 
};
68
 
 
69
 
 
70
 
/*
71
 
 * -------------------------------------------------------------------------
72
 
 * DUMP TABLE
73
 
 */
74
 
//-----------------------
75
 
MSEnabledTable::MSEnabledTable(MSSystemTableShare *share, TABLE *table):
76
 
MSOpenSystemTable(share, table),
77
 
iEnabledIndex(0)
78
 
{
79
 
}
80
 
 
81
 
//-----------------------
82
 
MSEnabledTable::~MSEnabledTable()
83
 
{
84
 
}
85
 
 
86
 
//-----------------------
87
 
void MSEnabledTable::seqScanInit()
88
 
{
89
 
        iEnabledIndex = 0;
90
 
}
91
 
//-----------------------
92
 
bool MSEnabledTable::seqScanNext(char *buf)
93
 
{
94
 
        TABLE           *table = mySQLTable;
95
 
        Field           *curr_field;
96
 
        byte            *save;
97
 
        MY_BITMAP       *save_write_set;
98
 
        const char *yesno;
99
 
        const PBMSEngineRec *eng;
100
 
        
101
 
        enter_();
102
 
        
103
 
        eng = MSEngine::getEngineInfoAt(iEnabledIndex++);
104
 
        if (!eng)
105
 
                return_(false);
106
 
        
107
 
        save_write_set = table->write_set;
108
 
        table->write_set = NULL;
109
 
 
110
 
#ifdef DRIZZLED
111
 
        memset(buf, 0xFF, table->getNullBytes());
112
 
#else
113
 
        memset(buf, 0xFF, table->s->null_bytes);
114
 
#endif
115
 
 
116
 
        for (Field **field=GET_TABLE_FIELDS(table) ; *field ; field++) {
117
 
                curr_field = *field;
118
 
                save = curr_field->ptr;
119
 
#if MYSQL_VERSION_ID < 50114
120
 
                curr_field->ptr = (byte *) buf + curr_field->offset();
121
 
#else
122
 
#ifdef DRIZZLED
123
 
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->getTable()->getInsertRecord());
124
 
#else
125
 
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
126
 
#endif
127
 
#endif
128
 
 
129
 
                switch (curr_field->field_name[0]) {
130
 
                        case 'N':
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);
134
 
                                break;
135
 
 
136
 
                        case 'I':
137
 
                                ASSERT(strcmp(curr_field->field_name, "IsServer") == 0);
138
 
                                if (eng->ms_internal)
139
 
                                        yesno = "Yes";
140
 
                                else
141
 
                                        yesno = "No";
142
 
                                        
143
 
                                curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
144
 
                                setNotNullInRecord(curr_field, buf);
145
 
                                break;
146
 
 
147
 
                        case 'T': 
148
 
                                ASSERT(strcmp(curr_field->field_name, "Transactional") == 0);
149
 
                                if (eng->ms_internal || eng->ms_version < 2 )
150
 
                                        yesno = "Maybe";
151
 
                                else if (eng->ms_has_transactions)
152
 
                                        yesno = "Yes";
153
 
                                else
154
 
                                        yesno = "No";
155
 
                                        
156
 
                                curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
157
 
                                setNotNullInRecord(curr_field, buf);
158
 
                                break;
159
 
 
160
 
                        case 'A':
161
 
                                ASSERT(strcmp(curr_field->field_name, "API-Version") == 0);
162
 
                                curr_field->store(eng->ms_version, true);
163
 
                                break;
164
 
 
165
 
                }
166
 
                curr_field->ptr = save;
167
 
        }
168
 
 
169
 
        table->write_set = save_write_set;
170
 
        return_(true);
171
 
}
172
 
 
173
 
//-----------------------
174
 
void MSEnabledTable::seqScanPos(unsigned char *pos )
175
 
{
176
 
        int32_t index = iEnabledIndex -1;
177
 
        if (index < 0)
178
 
                index = 0; // This is probably an error condition.
179
 
                
180
 
        mi_int4store(pos, index);
181
 
}
182
 
 
183
 
//-----------------------
184
 
void MSEnabledTable::seqScanRead(unsigned char *pos , char *buf)
185
 
{
186
 
        iEnabledIndex = mi_uint4korr(pos);
187
 
        seqScanNext(buf);
188
 
}
189
 
 
190
 
#endif // DRIZZLED
191
 
 
192