~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2010-07-04 20:02:43 UTC
  • mfrom: (1548.2.40 drizzle_pbms)
  • mto: This revision was merged to the branch mainline in revision 1644.
  • Revision ID: mordred@inaugust.com-20100704200243-2vkq9gi6ysauj2tb
Merge PBMS from Barry.

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
#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",         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}
 
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
        memset(buf, 0xFF, table->s->null_bytes);
 
111
        for (Field **field=GET_TABLE_FIELDS(table) ; *field ; field++) {
 
112
                curr_field = *field;
 
113
                save = curr_field->ptr;
 
114
#if MYSQL_VERSION_ID < 50114
 
115
                curr_field->ptr = (byte *) buf + curr_field->offset();
 
116
#else
 
117
                curr_field->ptr = (byte *) buf + curr_field->offset(curr_field->table->record[0]);
 
118
#endif
 
119
 
 
120
                switch (curr_field->field_name[0]) {
 
121
                        case 'N':
 
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);
 
125
                                break;
 
126
 
 
127
                        case 'I':
 
128
                                ASSERT(strcmp(curr_field->field_name, "IsServer") == 0);
 
129
                                if (eng->ms_internal)
 
130
                                        yesno = "Yes";
 
131
                                else
 
132
                                        yesno = "No";
 
133
                                        
 
134
                                curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
 
135
                                setNotNullInRecord(curr_field, buf);
 
136
                                break;
 
137
 
 
138
                        case 'T': 
 
139
                                ASSERT(strcmp(curr_field->field_name, "Transactional") == 0);
 
140
                                if (eng->ms_internal || eng->ms_version < 2 )
 
141
                                        yesno = "Maybe";
 
142
                                else if (eng->ms_has_transactions)
 
143
                                        yesno = "Yes";
 
144
                                else
 
145
                                        yesno = "No";
 
146
                                        
 
147
                                curr_field->store(yesno, strlen(yesno), &UTF8_CHARSET);
 
148
                                setNotNullInRecord(curr_field, buf);
 
149
                                break;
 
150
 
 
151
                        case 'A':
 
152
                                ASSERT(strcmp(curr_field->field_name, "API-Version") == 0);
 
153
                                curr_field->store(eng->ms_version, true);
 
154
                                break;
 
155
 
 
156
                }
 
157
                curr_field->ptr = save;
 
158
        }
 
159
 
 
160
        table->write_set = save_write_set;
 
161
        return_(true);
 
162
}
 
163
 
 
164
//-----------------------
 
165
void MSEnabledTable::seqScanPos(uint8_t *pos)
 
166
{
 
167
        int32_t index = iEnabledIndex -1;
 
168
        if (index < 0)
 
169
                index = 0; // This is probably an error condition.
 
170
                
 
171
        mi_int4store(pos, index);
 
172
}
 
173
 
 
174
//-----------------------
 
175
void MSEnabledTable::seqScanRead(uint8_t *pos, char *buf)
 
176
{
 
177
        iEnabledIndex = mi_uint4korr(pos);
 
178
        seqScanNext(buf);
 
179
}
 
180
 
 
181
#endif // DRIZZLED
 
182
 
 
183