1 30 31 32 package org.hsqldb; 33 34 import java.lang.reflect.Constructor ; 35 36 import org.hsqldb.lib.IntValueHashMap; 37 38 44 56 class DatabaseInformation { 57 58 protected static final int SYSTEM_BESTROWIDENTIFIER = 0; 60 protected static final int SYSTEM_CATALOGS = 1; 61 protected static final int SYSTEM_COLUMNPRIVILEGES = 2; 62 protected static final int SYSTEM_COLUMNS = 3; 63 protected static final int SYSTEM_CROSSREFERENCE = 4; 64 protected static final int SYSTEM_INDEXINFO = 5; 65 protected static final int SYSTEM_PRIMARYKEYS = 6; 66 protected static final int SYSTEM_PROCEDURECOLUMNS = 7; 67 protected static final int SYSTEM_PROCEDURES = 8; 68 protected static final int SYSTEM_SCHEMAS = 9; 69 protected static final int SYSTEM_SUPERTABLES = 10; 70 protected static final int SYSTEM_SUPERTYPES = 11; 71 protected static final int SYSTEM_TABLEPRIVILEGES = 12; 72 protected static final int SYSTEM_TABLES = 13; 73 protected static final int SYSTEM_TABLETYPES = 14; 74 protected static final int SYSTEM_TYPEINFO = 15; 75 protected static final int SYSTEM_UDTATTRIBUTES = 16; 76 protected static final int SYSTEM_UDTS = 17; 77 protected static final int SYSTEM_USERS = 18; 78 protected static final int SYSTEM_VERSIONCOLUMNS = 19; 79 80 protected static final int SYSTEM_ALIASES = 20; 82 protected static final int SYSTEM_BYTECODE = 21; 83 protected static final int SYSTEM_CACHEINFO = 22; 84 protected static final int SYSTEM_CLASSPRIVILEGES = 23; 85 protected static final int SYSTEM_SESSIONINFO = 24; 86 protected static final int SYSTEM_PROPERTIES = 25; 87 protected static final int SYSTEM_SESSIONS = 26; 88 protected static final int SYSTEM_TRIGGERCOLUMNS = 27; 89 protected static final int SYSTEM_TRIGGERS = 28; 90 protected static final int SYSTEM_ALLTYPEINFO = 29; 91 92 protected static final int SYSTEM_VIEWS = 30; 94 95 protected static final int SYSTEM_TEXTTABLES = 31; 97 98 protected static final int SYSTEM_SEQUENCES = 32; 100 protected static final int SYSTEM_USAGE_PRIVILEGES = 33; 101 102 protected static final int SYSTEM_CHECK_CONSTRAINTS = 34; 104 protected static final int SYSTEM_TABLE_CONSTRAINTS = 35; 105 106 protected static final int SYSTEM_CHECK_COLUMN_USAGE = 36; 108 protected static final int SYSTEM_CHECK_ROUTINE_USAGE = 37; 109 protected static final int SYSTEM_CHECK_TABLE_USAGE = 38; 110 protected static final int SYSTEM_VIEW_COLUMN_USAGE = 39; 111 protected static final int SYSTEM_VIEW_TABLE_USAGE = 40; 112 protected static final int SYSTEM_VIEW_ROUTINE_USAGE = 41; 113 114 protected static final int SYSTEM_AUTHORIZATIONS = 42; 116 protected static final int SYSTEM_COLLATIONS = 43; 117 protected static final int SYSTEM_ROLE_AUTHORIZATION_DESCRIPTORS = 44; 118 protected static final int SYSTEM_SCHEMATA = 45; 119 120 121 protected static final String [] sysTableNames = { 122 "SYSTEM_BESTROWIDENTIFIER", "SYSTEM_CATALOGS", "SYSTEM_COLUMNPRIVILEGES", "SYSTEM_COLUMNS", "SYSTEM_CROSSREFERENCE", "SYSTEM_INDEXINFO", "SYSTEM_PRIMARYKEYS", "SYSTEM_PROCEDURECOLUMNS", "SYSTEM_PROCEDURES", "SYSTEM_SCHEMAS", "SYSTEM_SUPERTABLES", "SYSTEM_SUPERTYPES", "SYSTEM_TABLEPRIVILEGES", "SYSTEM_TABLES", "SYSTEM_TABLETYPES", "SYSTEM_TYPEINFO", "SYSTEM_UDTATTRIBUTES", "SYSTEM_UDTS", "SYSTEM_USERS", "SYSTEM_VERSIONCOLUMNS", 143 "SYSTEM_ALIASES", "SYSTEM_BYTECODE", "SYSTEM_CACHEINFO", "SYSTEM_CLASSPRIVILEGES", "SYSTEM_SESSIONINFO", "SYSTEM_PROPERTIES", "SYSTEM_SESSIONS", "SYSTEM_TRIGGERCOLUMNS", "SYSTEM_TRIGGERS", "SYSTEM_ALLTYPEINFO", 155 "SYSTEM_VIEWS", 157 158 "SYSTEM_TEXTTABLES", 160 161 "SYSTEM_SEQUENCES", "SYSTEM_USAGE_PRIVILEGES", 164 165 "SYSTEM_CHECK_CONSTRAINTS", "SYSTEM_TABLE_CONSTRAINTS", 169 "SYSTEM_CHECK_COLUMN_USAGE", "SYSTEM_CHECK_ROUTINE_USAGE", "SYSTEM_CHECK_TABLE_USAGE", "SYSTEM_VIEW_COLUMN_USAGE", "SYSTEM_VIEW_TABLE_USAGE", "SYSTEM_VIEW_ROUTINE_USAGE", 177 "SYSTEM_AUTHORIZATIONS", "SYSTEM_COLLATIONS", "SYSTEM_ROLE_AUTHORIZATION_DESCRIPTORS", "SYSTEM_SCHEMATA" 183 }; 267 268 269 protected static final IntValueHashMap sysTableNamesMap; 270 271 static { 272 sysTableNamesMap = new IntValueHashMap(47); 273 274 for (int i = 0; i < sysTableNames.length; i++) { 275 sysTableNamesMap.put(sysTableNames[i], i); 276 } 277 } 278 279 static int getSysTableID(String token) { 280 return sysTableNamesMap.get(token, -1); 281 } 282 283 284 protected final Database database; 285 286 290 protected boolean isDirty = true; 291 292 298 protected boolean withContent = false; 299 300 310 static final DatabaseInformation newDatabaseInformation(Database db) 311 throws HsqlException { 312 313 Class clazz = null; 314 315 try { 316 clazz = Class.forName("org.hsqldb.DatabaseInformationFull"); 317 } catch (Exception e) { 318 try { 319 clazz = Class.forName("org.hsqldb.DatabaseInformationMain"); 320 } catch (Exception e2) {} 321 } 322 323 try { 324 Class [] ctorParmTypes = new Class []{ Database.class }; 325 Object [] ctorParms = new Object []{ db }; 326 Constructor ctor = clazz.getDeclaredConstructor(ctorParmTypes); 327 328 return (DatabaseInformation) ctor.newInstance(ctorParms); 329 } catch (Exception e) {} 330 331 return new DatabaseInformation(db); 332 } 333 334 342 DatabaseInformation(Database db) throws HsqlException { 343 database = db; 344 } 345 346 352 final boolean isSystemTable(String name) { 353 return sysTableNamesMap.containsKey(name); 354 } 355 356 367 Table getSystemTable(Session session, String name) throws HsqlException { 368 return null; 369 } 370 371 387 final void setDirty() { 388 isDirty = true; 389 } 390 391 398 final void setWithContent(boolean withContent) { 399 this.withContent = withContent; 400 } 401 } 402 | Popular Tags |