~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to plugin/pbms/src/table_ms.h

  • Committer: Bazaar Package Importer
  • Author(s): Monty Taylor
  • Date: 2010-10-02 14:17:48 UTC
  • mfrom: (1.1.1 upstream)
  • mto: (2.1.17 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20101002141748-m6vbfbfjhrw1153e
Tags: 2010.09.1802-1
* New upstream release.
* Removed pid-file argument hack.
* Updated GPL-2 address to be new address.
* Directly copy in drizzledump.1 since debian doesn't have sphinx 1.0 yet.
* Link to jquery from libjs-jquery. Add it as a depend.
* Add drizzled.8 symlink to the install files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2008 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
 * Original author: Paul McCullagh
 
20
 * Continued development: Barry Leslie
 
21
 *
 
22
 * 2007-06-26
 
23
 *
 
24
 * H&G2JCtL
 
25
 *
 
26
 * Contains the information about a table.
 
27
 *
 
28
 */
 
29
 
 
30
#ifndef __TABLE_MS_H__
 
31
#define __TABLE_MS_H__
 
32
 
 
33
#include "defs_ms.h"
 
34
 
 
35
#define MS_TABLE_FILE_MAGIC                     0x1234ABCD
 
36
#define MS_TABLE_FILE_VERSION           1
 
37
#define MS_TABLE_FILE_HEAD_SIZE         128
 
38
 
 
39
class MSOpenTable;
 
40
class MSDatabase;
 
41
class CSHTTPOutputStream;
 
42
 
 
43
typedef struct MSTableHead {
 
44
        CSDiskValue4                    th_magic_4;                                                     /* Table magic number. */
 
45
        CSDiskValue2                    th_version_2;                                           /* The header version. */
 
46
        CSDiskValue2                    th_head_size_2;                                         /* The size of the header. */
 
47
        CSDiskValue8                    th_free_list_8;
 
48
 
 
49
        /* These 3 fields are written together by prepareToDelete()! */
 
50
        CSDiskValue4                    th_del_time_4;                                          /* The time this table was deleted. */
 
51
        CSDiskValue4                    th_temp_log_id_4;                                       /* The temp log entry for this deleted table. */
 
52
        CSDiskValue4                    th_temp_log_offset_4;
 
53
 
 
54
        CSDiskValue4                    th_reserved_4;
 
55
} MSTableHeadRec, *MSTableHeadPtr;
 
56
 
 
57
/* File offset = th_size_4 + (Blob ID - 1) * sizeof(MSTableBlobRec) */ 
 
58
typedef struct MSTableBlob {
 
59
        CSDiskValue1                    tb_status_1;                                            /* 0 = free, 1 = inuse*/
 
60
 
 
61
        /* These 3 fields are written together: */
 
62
        CSDiskValue3                    tb_repo_id_3;                                           /* File ID (non-zero). */
 
63
        CSDiskValue6                    tb_offset_6;                                            /* Offset into the file of the BLOB. */
 
64
        CSDiskValue2                    tb_header_size_2;                                       /* Size of the header section of the blob. */
 
65
 
 
66
        CSDiskValue6                    tb_size_6;                                                      /* Size of the BLOB data. (Where ever it may be stored.) */ 
 
67
        CSDiskValue4                    tb_auth_code_4;                                         /* BLOB authorisation code. */
 
68
} MSTableBlobRec, *MSTableBlobPtr;
 
69
 
 
70
typedef struct MSTableFreeBlob {
 
71
        CSDiskValue4                    tf_null_4;                                                      /* Set to zero */
 
72
        CSDiskValue6                    tf_next_6;                                                      /* Next record in the free list. */
 
73
} MSTableFreeBlobRec, *MSTableFreeBlobPtr;
 
74
 
 
75
class MSTable : public CSSharedRefObject {
 
76
public:
 
77
        CSString        *myTableName;
 
78
        uint32_t                myTableID;
 
79
        MSDatabase      *myDatabase;
 
80
 
 
81
        MSTable();
 
82
        virtual ~MSTable();
 
83
 
 
84
        CSPath *getTableFile(const char *table_name, bool to_delete);
 
85
 
 
86
        CSPath *getTableFile();
 
87
 
 
88
        CSFile *openTableFile();
 
89
        
 
90
        void prepareToDelete();
 
91
 
 
92
        uint64_t createBlobHandle(MSOpenTable *otab, uint32_t repo_id, uint64_t file_offset, uint64_t size, uint16_t head_size, uint32_t auth_code);
 
93
 
 
94
        uint64_t findBlobHandle(MSOpenTable *otab, uint32_t repo_id, uint64_t file_offset, uint64_t size, uint16_t head_size, uint32_t auth_code);
 
95
 
 
96
        void setBlobHandle(MSOpenTable *otab, uint64_t blob_id, uint32_t repo_id, uint64_t file_offset, uint64_t size, uint16_t head_size, uint32_t auth_code);
 
97
 
 
98
        void updateBlobHandle(MSOpenTable *otab, uint64_t blob_id, uint32_t repo_id, uint64_t offset, uint16_t head_size);
 
99
 
 
100
        bool readBlobHandle(MSOpenTable *otab, uint64_t blob_id, uint32_t *auth_code, uint32_t *repo_id, uint64_t *offset, uint64_t *data_size, uint16_t *head_size, bool throw_error);
 
101
 
 
102
        void freeBlobHandle(MSOpenTable *otab, uint64_t blob_id, uint32_t repo_id, uint64_t file_offset, uint32_t auth_code);
 
103
 
 
104
        /* Make this object hashable: */
 
105
        virtual CSObject *getKey();
 
106
        virtual int compareKey(CSObject *);
 
107
        virtual uint32_t hashKey();
 
108
 
 
109
        off64_t getTableFileSize() { return iTableFileSize; }
 
110
        CSString *getTableName();
 
111
        bool isToDelete() { return iToDelete; }
 
112
        void getDeleteInfo(uint32_t *log, uint32_t *offs, time_t *tim);
 
113
        bool isNoTable() { return myTableName->length() == 0; }
 
114
 
 
115
private:
 
116
        off64_t         iTableFileSize;
 
117
        size_t          iTableHeadSize;
 
118
        off64_t         iFreeList;
 
119
        bool            iToDelete;
 
120
        uint32_t                iTabDeleteTime;
 
121
        uint32_t                iTabTempLogID;
 
122
        uint32_t                iTabTempLogOffset;
 
123
 
 
124
public:
 
125
        static MSTable *newTable(uint32_t tab_id, CSString *name, MSDatabase *db, off64_t file_size, bool to_delete);
 
126
 
 
127
        static MSTable *newTable(uint32_t tab_id, const char *name, MSDatabase *db, off64_t file_size, bool to_delete); 
 
128
};
 
129
 
 
130
#endif