~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/pbxt/src/systab_xt.h

  • Committer: Brian Aker
  • Date: 2011-03-24 23:14:46 UTC
  • mfrom: (2246.4.12 foreach)
  • Revision ID: brian@tangent.org-20110324231446-7q1gydkglys73nft
Merge in XTF

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2008 PrimeBase Technologies GmbH, Germany
2
 
 *
3
 
 * PrimeBase XT
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
 
 * Paul McCullagh
20
 
 *
21
 
 * 2007-07-18
22
 
 *
23
 
 * H&G2JCtL
24
 
 *
25
 
 * PBXT System tables.
26
 
 *
27
 
 */
28
 
 
29
 
/*
30
 
 
31
 
DROP TABLE IF EXISTS pbms_repository;
32
 
CREATE TABLE pbms_repository (
33
 
        Repository_id     INT COMMENT 'The reppository file number',
34
 
        Repo_blob_offset  BIGINT COMMENT 'The offset of the BLOB in the repository file',
35
 
        Blob_size         BIGINT COMMENT 'The size of the BLOB in bytes',
36
 
        Head_size         SMALLINT UNSIGNED COMMENT 'The size of the BLOB header - preceeds the BLOB data',
37
 
        Access_code       INT COMMENT 'The 4-byte authorisation code required to access the BLOB - part of the BLOB URL',
38
 
        Creation_time     TIMESTAMP COMMENT 'The time the BLOB was created',
39
 
        Last_ref_time     TIMESTAMP COMMENT 'The last time the BLOB was referenced',
40
 
        Last_access_time  TIMESTAMP COMMENT 'The last time the BLOB was accessed (read)',
41
 
        Content_type      CHAR(128) COMMENT 'The content type of the BLOB - returned by HTTP GET calls',
42
 
        Blob_data         LONGBLOB COMMENT 'The data of this BLOB'
43
 
) ENGINE=PBMS;
44
 
 
45
 
        PRIMARY KEY (Repository_id, Repo_blob_offset)
46
 
 
47
 
DROP TABLE IF EXISTS pbms_reference;
48
 
CREATE TABLE pbms_reference (
49
 
        Table_name        CHAR(64) COMMENT 'The name of the referencing table',
50
 
        Blob_id           BIGINT COMMENT 'The BLOB reference number - part of the BLOB URL',
51
 
        Column_name       CHAR(64) COMMENT 'The column name of the referencing field',
52
 
        Row_condition     VARCHAR(255) COMMENT 'This condition identifies the row in the table',
53
 
        Blob_url          VARCHAR(200) COMMENT 'The BLOB URL for HTTP GET access',
54
 
        Repository_id     INT COMMENT 'The repository file number of the BLOB',
55
 
        Repo_blob_offset  BIGINT COMMENT 'The offset in the repository file',
56
 
        Blob_size         BIGINT COMMENT 'The size of the BLOB in bytes',
57
 
        Deletion_time     TIMESTAMP COMMENT 'The time the BLOB was deleted',
58
 
        Remove_in         INT COMMENT 'The number of seconds before the reference/BLOB is removed perminently',
59
 
        Temp_log_id       INT COMMENT 'Temporary log number of the referencing deletion entry',
60
 
        Temp_log_offset   BIGINT COMMENT 'Temporary log offset of the referencing deletion entry'
61
 
) ENGINE=PBMS;
62
 
 
63
 
        PRIMARY KEY (Table_name, Blob_id, Column_name, Condition)
64
 
*/
65
 
 
66
 
#ifndef __SYSTAB_XT_H__
67
 
#define __SYSTAB_XT_H__
68
 
 
69
 
#include "ccutils_xt.h"
70
 
#include "discover_xt.h"
71
 
#include "thread_xt.h"
72
 
 
73
 
struct XTSystemTableShare;
74
 
struct XTDatabase;
75
 
 
76
 
class XTOpenSystemTable : public XTObject {
77
 
public:
78
 
        XTSystemTableShare              *ost_share;
79
 
        TABLE                                   *ost_my_table;
80
 
        struct XTDatabase               *ost_db;
81
 
 
82
 
        XTOpenSystemTable(XTThreadPtr self, struct XTDatabase *db, XTSystemTableShare *share, TABLE *table);
83
 
        virtual ~XTOpenSystemTable();
84
 
 
85
 
        virtual bool use() { return true; }
86
 
        virtual bool unuse() { return true; }
87
 
        virtual bool seqScanInit() { return true; }
88
 
        virtual bool seqScanNext(char *XT_UNUSED(buf), bool *eof) {
89
 
                *eof = true;
90
 
                return false;
91
 
        }
92
 
        virtual int     getRefLen() { return 4; }
93
 
        virtual xtWord4 seqScanPos(xtWord1 *XT_UNUSED(buf)) {
94
 
                return 0;
95
 
        }
96
 
        virtual bool seqScanRead(xtWord4 XT_UNUSED(rec_id), char *XT_UNUSED(buf)) {
97
 
                return true;
98
 
        }
99
 
 
100
 
private:
101
 
};
102
 
 
103
 
class XTLocationTable : public XTOpenSystemTable {
104
 
        u_int   lt_index;
105
 
 
106
 
public:
107
 
        XTLocationTable(XTThreadPtr self, struct XTDatabase *db, XTSystemTableShare *share, TABLE *table);
108
 
        virtual ~XTLocationTable();
109
 
 
110
 
        virtual bool use();
111
 
        virtual bool unuse();
112
 
        virtual bool seqScanInit();
113
 
        virtual bool seqScanNext(char *buf, bool *eof);
114
 
        virtual void loadRow(char *buf, xtWord4 row_id);
115
 
        virtual xtWord4 seqScanPos(xtWord1 *buf);
116
 
        virtual bool seqScanRead(xtWord4 rec_id, char *buf);
117
 
};
118
 
 
119
 
class XTStatisticsTable : public XTOpenSystemTable {
120
 
        u_int                           tt_index;
121
 
        XTStatisticsRec         tt_statistics;
122
 
 
123
 
public:
124
 
        XTStatisticsTable(XTThreadPtr self, struct XTDatabase *db, XTSystemTableShare *share, TABLE *table);
125
 
        virtual ~XTStatisticsTable();
126
 
 
127
 
        virtual bool use();
128
 
        virtual bool unuse();
129
 
        virtual bool seqScanInit();
130
 
        virtual bool seqScanNext(char *buf, bool *eof);
131
 
        virtual void loadRow(char *buf, xtWord4 row_id);
132
 
        virtual xtWord4 seqScanPos(xtWord1 *buf);
133
 
        virtual bool seqScanRead(xtWord4 rec_id, char *buf);
134
 
};
135
 
 
136
 
typedef struct XTSystemTableShare {
137
 
        u_int                                           sts_id;
138
 
        const char                                      *sts_path;
139
 
        THR_LOCK                                        *sts_my_lock;
140
 
        DT_FIELD_INFO                           *sts_info;
141
 
        DT_KEY_INFO                                     *sts_keys;
142
 
        xtBool                                          sts_exists;
143
 
 
144
 
        static void                                     startUp(XTThreadPtr self);
145
 
        static void                                     shutDown(XTThreadPtr self);
146
 
        
147
 
        static bool                                     isSystemTable(const char *table_path);
148
 
        static void                                     setSystemTableDeleted(const char *table_path);
149
 
        static bool                                     doesSystemTableExist();
150
 
        static void                                     createSystemTables(XTThreadPtr self, struct XTDatabase *db);
151
 
        static XTOpenSystemTable        *openSystemTable(XTThreadPtr self, const char *table_path, TABLE *table);
152
 
        static void                                     releaseSystemTable(XTOpenSystemTable *tab);
153
 
} XTSystemTableShareRec, *XTSystemTableSharePtr;
154
 
 
155
 
#endif