1/* GCSSpecialQueries+SOGoCacheObject.m - this file is part of SOGo
2 *
3 * Copyright (C) 2012-2014 Inverse inc
4 *
5 * This file 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 3, or (at your option)
8 * any later version.
9 *
10 * This file 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; see the file COPYING.  If not, write to
17 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
19 */
20
21#import <Foundation/NSString.h>
22
23#import "GCSSpecialQueries+SOGoCacheObject.h"
24
25@interface GCSPostgreSQLSpecialQueries (SOGoObjectCache)
26@end
27
28@interface GCSMySQLSpecialQueries (SOGoObjectCache)
29@end
30
31@interface GCSOracleSpecialQueries (SOGoObjectCache)
32@end
33
34@implementation GCSSpecialQueries (SOGoObjectCache)
35
36/* FIXME: c_parent_path should be indexed */
37
38- (NSString *) createSOGoCacheGCSFolderTableWithName: (NSString *) tableName
39{
40  [self subclassResponsibility: _cmd];
41
42  return nil;
43}
44
45@end
46
47@implementation GCSPostgreSQLSpecialQueries (SOGoObjectCache)
48
49- (NSString *) createSOGoCacheGCSFolderTableWithName: (NSString *) tableName
50{
51  static NSString *sqlFolderFormat
52    = (@"CREATE TABLE %@ ("
53       @" c_path VARCHAR(255) PRIMARY KEY,"
54       @" c_parent_path VARCHAR(255),"
55       @" c_type SMALLINT NOT NULL,"
56       @" c_creationdate INT4 NOT NULL,"
57       @" c_lastmodified INT4 NOT NULL,"
58       @" c_version INT4 NOT NULL DEFAULT 0,"
59       @" c_deleted SMALLINT NOT NULL DEFAULT 0,"
60       @" c_content TEXT)");
61
62  return [NSString stringWithFormat: sqlFolderFormat, tableName];
63}
64
65@end
66
67@implementation GCSMySQLSpecialQueries (SOGoObjectCache)
68
69- (NSString *) createSOGoCacheGCSFolderTableWithName: (NSString *) tableName
70{
71  static NSString *sqlFolderFormat
72    = (@"CREATE TABLE %@ ("
73       @" c_path VARCHAR(255) PRIMARY KEY,"
74       @" c_parent_path VARCHAR(255),"
75       @" c_type TINYINT UNSIGNED NOT NULL,"
76       @" c_creationdate INT NOT NULL,"
77       @" c_lastmodified INT NOT NULL,"
78       @" c_version INT NOT NULL DEFAULT 0,"
79       @" c_deleted TINYINT NOT NULL DEFAULT 0,"
80       @" c_content LONGTEXT)");
81
82  return [NSString stringWithFormat: sqlFolderFormat, tableName];
83}
84
85@end
86
87@implementation GCSOracleSpecialQueries (SOGoObjectCache)
88
89- (NSString *) createSOGoCacheGCSFolderTableWithName: (NSString *) tableName
90{
91  static NSString *sqlFolderFormat
92    = (@"CREATE TABLE %@ ("
93       @" c_path VARCHAR2(255) PRIMARY KEY,"
94       @" c_parent_path VARCHAR2(255),"
95       @" c_type SMALLINT NOT NULL,"
96       @" c_creationdate INT4 NOT NULL,"
97       @" c_lastmodified INT4 NOT NULL,"
98       @" c_version INT4 NOT NULL DEFAULT 0,"
99       @" c_deleted SMALLINT NOT NULL DEFAULT 0,"
100       @" c_content CLOB)");
101
102  return [NSString stringWithFormat: sqlFolderFormat, tableName];
103}
104
105@end
106