~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Added the PBMS daemon plugin.

(Augen zu und durch!)

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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
18
 *
 
19
 * Barry Leslie
 
20
 *
 
21
 * System dump table.
 
22
 *
 
23
 */
 
24
#include "CSConfig.h"
 
25
 
 
26
#include <sys/types.h>
 
27
#include <sys/stat.h>
 
28
#include <stdlib.h>
 
29
#include <time.h>
 
30
 
 
31
#ifdef DRIZZLED
 
32
#include <drizzled/server_includes.h>
 
33
#include <drizzled/field/blob.h>
 
34
#endif
 
35
 
 
36
 
 
37
//#include "mysql_priv.h"
 
38
#include "CSGlobal.h"
 
39
#include "CSStrUtil.h"
 
40
 
 
41
#include "ha_pbms.h"
 
42
//#include <plugin.h>
 
43
 
 
44
#include "ms_mysql.h"
 
45
#include "Repository_ms.h"
 
46
#include "Database_ms.h"
 
47
#include "Compactor_ms.h"
 
48
#include "OpenTable_ms.h"
 
49
#include "Util_ms.h"
 
50
#include "Discover_ms.h"
 
51
#include "Transaction_ms.h"
 
52
#include "SysTab_variable.h"
 
53
#include "backup_ms.h"
 
54
 
 
55
 
 
56
#include "SysTab_enabled.h"
 
57
 
 
58
 
 
59
DT_FIELD_INFO pbms_enabled_info[]=
 
60
{
 
61
        {"Name",                        32,             NULL, MYSQL_TYPE_VARCHAR,       &UTF8_CHARSET,  NOT_NULL_FLAG,  "PBMS enabled engine name"},
 
62
        {"IsServer",            3,              NULL, MYSQL_TYPE_VARCHAR,       &UTF8_CHARSET,                                  NOT_NULL_FLAG,  "Enabled at server level."},
 
63
        {"Transactional",       5,              NULL, MYSQL_TYPE_VARCHAR,       &UTF8_CHARSET,                                  NOT_NULL_FLAG,  "Does the engine support transactions."},
 
64
        {"API-Version",         NULL,   NULL, MYSQL_TYPE_LONG,          NULL,                                                   NOT_NULL_FLAG,  "The PBMS enabled api version used."},
 
65
        {NULL,NULL, NULL, MYSQL_TYPE_STRING,NULL, 0, NULL}
 
66
};
 
67
 
 
68
DT_KEY_INFO pbms_enabled_keys[]=
 
69
{
 
70
        {"pbms_enabled_pk", PRI_KEY_FLAG, {"Name", NULL}},
 
71
        {NULL, 0, {NULL}}
 
72
};
 
73
 
 
74
 
 
75
/*
 
76
 * -------------------------------------------------------------------------
 
77
 * DUMP TABLE
 
78
 */
 
79
//-----------------------
 
80
MSEnabledTable::MSEnabledTable(MSSystemTableShare *share, TABLE *table):
 
81
MSOpenSystemTable(share, table),
 
82
iEnabledIndex(0)
 
83
{
 
84
}
 
85
 
 
86
//-----------------------
 
87
MSEnabledTable::~MSEnabledTable()
 
88
{
 
89
}
 
90
 
 
91
//-----------------------
 
92
void MSEnabledTable::seqScanInit()
 
93
{
 
94
        iEnabledIndex = 0;
 
95
}
 
96
//-----------------------
 
97
bool MSEnabledTable::seqScanNext(char *buf)
 
98
{
 
99
        TABLE           *table = mySQLTable;
 
100
        Field           *curr_field;
 
101
        byte            *save;
 
102
        MY_BITMAP       *save_write_set;
 
103
        const char *yesno;
 
104
        const PBMSEngineRec *eng;
 
105
        
 
106
        enter_();
 
107
        
 
108
        eng = MSEngine::getEngineInfoAt(iEnabledIndex++);
 
109
        if (!eng)
 
110
                return_(false);
 
111
        
 
112
        save_write_set = table->write_set;
 
113
        table->write_set = NULL;
 
114
 
 
115
        memset(buf, 0xFF, table->s->null_bytes);
 
116
        for (Field **field=table->field ; *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
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
 
123
#endif
 
124
 
 
125
                switch (curr_field->field_name[0]) {
 
126
                        case 'N':
 
127
                                ASSERT(strcmp(curr_field->field_name, "Name") == 0);
 
128
                                curr_field->store(eng->ms_engine_name, strlen(eng->ms_engine_name), &UTF8_CHARSET);
 
129
                                ms_my_set_notnull_in_record(curr_field, buf);
 
130
                                break;
 
131
 
 
132
                        case 'I':
 
133
                                ASSERT(strcmp(curr_field->field_name, "IsServer") == 0);
 
134
                                if (eng->ms_internal)
 
135
                                        yesno = "Yes";
 
136
                                else
 
137
                                        yesno = "No";
 
138
                                        
 
139
                                curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
 
140
                                ms_my_set_notnull_in_record(curr_field, buf);
 
141
                                break;
 
142
 
 
143
                        case 'T': 
 
144
                                ASSERT(strcmp(curr_field->field_name, "Transactional") == 0);
 
145
                                if (eng->ms_internal || eng->ms_version < 2 )
 
146
                                        yesno = "Maybe";
 
147
                                else if (eng->ms_has_transactions)
 
148
                                        yesno = "Yes";
 
149
                                else
 
150
                                        yesno = "No";
 
151
                                        
 
152
                                curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
 
153
                                ms_my_set_notnull_in_record(curr_field, buf);
 
154
                                break;
 
155
 
 
156
                        case 'A':
 
157
                                ASSERT(strcmp(curr_field->field_name, "API-Version") == 0);
 
158
                                curr_field->store(eng->ms_version, true);
 
159
                                break;
 
160
 
 
161
                }
 
162
                curr_field->ptr = save;
 
163
        }
 
164
 
 
165
        table->write_set = save_write_set;
 
166
        return_(true);
 
167
}
 
168
 
 
169
//-----------------------
 
170
void MSEnabledTable::seqScanPos(uint8_t *pos)
 
171
{
 
172
        int32_t index = iEnabledIndex -1;
 
173
        if (index < 0)
 
174
                index = 0; // This is probably an error condition.
 
175
                
 
176
        mi_int4store(pos, index);
 
177
}
 
178
 
 
179
//-----------------------
 
180
void MSEnabledTable::seqScanRead(uint8_t *pos, char *buf)
 
181
{
 
182
        iEnabledIndex = mi_uint4korr(pos);
 
183
        seqScanNext(buf);
 
184
}
 
185
 
 
186
 
 
187