1
/* Copyright (c) 2008 PrimeBase Technologies GmbH, Germany
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
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'
45
PRIMARY KEY (Repository_id, Repo_blob_offset)
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'
63
PRIMARY KEY (Table_name, Blob_id, Column_name, Condition)
66
#ifndef __SYSTAB_XT_H__
67
#define __SYSTAB_XT_H__
69
#include "ccutils_xt.h"
70
#include "discover_xt.h"
71
#include "thread_xt.h"
73
struct XTSystemTableShare;
76
class XTOpenSystemTable : public XTObject {
78
XTSystemTableShare *ost_share;
80
struct XTDatabase *ost_db;
82
XTOpenSystemTable(XTThreadPtr self, struct XTDatabase *db, XTSystemTableShare *share, TABLE *table);
83
virtual ~XTOpenSystemTable();
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) {
92
virtual int getRefLen() { return 4; }
93
virtual xtWord4 seqScanPos(xtWord1 *XT_UNUSED(buf)) {
96
virtual bool seqScanRead(xtWord4 XT_UNUSED(rec_id), char *XT_UNUSED(buf)) {
103
class XTLocationTable : public XTOpenSystemTable {
107
XTLocationTable(XTThreadPtr self, struct XTDatabase *db, XTSystemTableShare *share, TABLE *table);
108
virtual ~XTLocationTable();
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);
119
class XTStatisticsTable : public XTOpenSystemTable {
121
XTStatisticsRec tt_statistics;
124
XTStatisticsTable(XTThreadPtr self, struct XTDatabase *db, XTSystemTableShare *share, TABLE *table);
125
virtual ~XTStatisticsTable();
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);
136
typedef struct XTSystemTableShare {
138
const char *sts_path;
139
THR_LOCK *sts_my_lock;
140
DT_FIELD_INFO *sts_info;
141
DT_KEY_INFO *sts_keys;
144
static void startUp(XTThreadPtr self);
145
static void shutDown(XTThreadPtr self);
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;