📄 basedatabase.java
字号:
if (rsel instanceof AggregateFunction) { throw new AxionException("use of aggregate function in expression is not allowed."); } leaf.setRight(rsel); } } else if(node instanceof InWhereNode) { InWhereNode in = (InWhereNode)node; if(null != in.getLeft()) { in.setLeft(resolveSelectable(in.getLeft(),tables)); } } else { throw new AxionException("Unrecognized WhereNode " + node); } } public Selectable resolveSelectable(Selectable selectable, TableIdentifier[] tables) throws AxionException { if(selectable instanceof ColumnIdentifier) { return resolveColumn((ColumnIdentifier)selectable,tables); } else if(selectable instanceof FunctionIdentifier) { return resolveFunctionIdentifier((FunctionIdentifier)selectable,tables); } else if(selectable instanceof ConcreteFunction) { return selectable; } else if(selectable instanceof BindVariable) { BindVariable bvar = (BindVariable)selectable; if(!bvar.isBound()) { throw new AxionException("Unbound variable found."); } else { return selectable; } } else if(selectable instanceof Literal) { return selectable; } else if(selectable instanceof ExpressionIdentifier) { // rahul added for evaluating expression return resolveExpression((ExpressionIdentifier)selectable,tables); } else if (selectable instanceof WhereNode) { resolveWhereNode((WhereNode)selectable, tables); return (selectable); } else { throw new AxionException("Couldn't resolve Selectable " + selectable); } } public void checkpoint() throws AxionException { Iterator tables = _tables.values().iterator(); while(tables.hasNext()) { Table table = (Table)(tables.next()); table.checkpoint(); } } public void createSequence(Sequence seq) throws AxionException { if (seq != null) { DatabaseSequenceEvent e = new DatabaseSequenceEvent(seq); Iterator i = getDatabaseModificationListeners().iterator(); while (i.hasNext()) { DatabaseModificationListener cur = (DatabaseModificationListener)i.next(); cur.sequenceAdded(e); } _sequences.put(seq.getName(), seq); seq.addSequenceModificationListener((SequenceModificationListener)_seqUpd); } } public void dropSequence(String name) { String uName = name.toUpperCase(); if (getSequence(uName) != null) { _sequences.remove(uName); } } public Sequence getSequence(String name) { Sequence result = null; if (name != null) { result = (Sequence)_sequences.get(name.toUpperCase()); } return result; } public TransactionManager getTransactionManager() { return _transactionManager; } public void addDatabaseModificationListener(DatabaseModificationListener l) { _listeners.add(l); } public List getDatabaseModificationListeners() { return _listeners; } //--------------------------------------------------------------- Protected protected Iterator getSequences() { return _sequences.values().iterator(); } protected int getSequenceCount() { return _sequences.size(); } protected Iterator getTables() { return _tables.values().iterator(); } protected void loadProperties(Properties props) throws AxionException { Enumeration enum = props.propertyNames(); while(enum.hasMoreElements()) { String key = (String)(enum.nextElement()); if(key.startsWith("type.")) { addDataType(key.substring("type.".length()),props.getProperty(key)); } else if(key.startsWith("function.")) { addFunction(key.substring("function.".length()),props.getProperty(key)); } else if(key.startsWith("index.")) { addIndexType(key.substring("index.".length()),props.getProperty(key)); } else if(key.equals("readonly")) { String val = props.getProperty(key); if("yes".equalsIgnoreCase(val) || "true".equalsIgnoreCase(val) || "on".equalsIgnoreCase(val)) { _readOnly = true; } else { _readOnly = false; } } else { _log.warn("Unrecognized property \"" + key + "\"."); } } } /** Callers should treat the returned Properties as immutable. */ protected static synchronized Properties getBaseProperties() { if(null == _props) { _props = new Properties(); // lets try the class loader that loaded me ClassLoader classLoader = BaseDatabase.class.getClassLoader(); InputStream in = classLoader.getResourceAsStream("axiondb.properties"); if(null == in) { _log.debug( "Couldn't find axiondb.properties via my system classloader, trying the context class loader" ); // lets try the context class loader classLoader = Thread.currentThread().getContextClassLoader(); in = classLoader.getResourceAsStream("axiondb.properties"); } if(null != in) { try { _props.load(in); } catch(Exception e) { _log.error("Exception while loading properties from CLASSPATH axiondb.properties",e); // PROPOGATE UP!?! } try { in.close(); } catch(Exception e) { } } else { _log.warn("Could not find axiondb.properties on the classpath."); } } return _props; } protected abstract Table createSystemTable(String name); //----------------------------------------------------------------- Private /** * Should get called by subclasses in constructors */ protected void createMetaDataTables() throws AxionException { Table columns = null; { columns = createSystemTable("AXION_COLUMNS"); columns.addColumn(new Column("TABLE_CAT",new StringType())); columns.addColumn(new Column("TABLE_SCHEM",new StringType())); columns.addColumn(new Column("TABLE_NAME",new StringType())); columns.addColumn(new Column("COLUMN_NAME",new StringType())); columns.addColumn(new Column("DATA_TYPE",new ShortType())); columns.addColumn(new Column("TYPE_NAME",new StringType())); columns.addColumn(new Column("COLUMN_SIZE",new IntegerType())); columns.addColumn(new Column("BUFFER_LENGTH",new IntegerType())); columns.addColumn(new Column("DECIMAL_DIGITS",new IntegerType())); columns.addColumn(new Column("NUM_PREC_RADIX",new IntegerType())); columns.addColumn(new Column("NULLABLE",new IntegerType())); columns.addColumn(new Column("REMARKS",new StringType())); columns.addColumn(new Column("COLUMN_DEF",new StringType())); columns.addColumn(new Column("SQL_DATA_TYPE",new IntegerType())); columns.addColumn(new Column("SQL_DATETIME_SUB",new IntegerType())); columns.addColumn(new Column("CHAR_OCTET_LENGTH",new IntegerType())); columns.addColumn(new Column("ORDINAL_POSITION",new IntegerType())); columns.addColumn(new Column("IS_NULLABLE",new StringType())); // yes, StringType "NO", "YES", "" } addDatabaseModificationListener(_colUpd); addTable(columns); Table tables = null; AxionTablesMetaTableUpdater updTables = new AxionTablesMetaTableUpdater(this); { tables = createSystemTable("AXION_TABLES"); tables.addColumn(new Column("TABLE_CAT", new StringType())); tables.addColumn(new Column("TABLE_SCHEM", new StringType())); tables.addColumn(new Column("TABLE_NAME", new StringType())); tables.addColumn(new Column("TABLE_TYPE", new StringType())); tables.addColumn(new Column("REMARKS", new StringType())); // bootstrap AXION_COLUMNS into AXION_TABLES Row row = updTables.createRowForAddedTable(columns); tables.addRow(row); } addDatabaseModificationListener(updTables); addTable(tables); { Table tableTypes = createSystemTable("AXION_TABLE_TYPES"); tableTypes.addColumn(new Column("TABLE_TYPE",new StringType())); String[] types = new String[] { Table.REGULAR_TABLE_TYPE, Table.SYSTEM_TABLE_TYPE }; for (int i = 0; i < types.length; i++) { SimpleRow row = new SimpleRow(1); row.set(0, types[i]); tableTypes.addRow(row); } addTable(tableTypes); } { Table catalogs = createSystemTable("AXION_CATALOGS"); catalogs.addColumn(new Column("TABLE_CAT",new StringType())); { SimpleRow row = new SimpleRow(1); row.set(0,""); catalogs.addRow(row); } addTable(catalogs); } { Table schemata = createSystemTable("AXION_SCHEMATA"); schemata.addColumn(new Column("TABLE_CAT",new StringType())); schemata.addColumn(new Column("TABLE_SCHEM",new StringType())); { SimpleRow row = new SimpleRow(2); row.set(0,""); row.set(1,""); schemata.addRow(row); } addTable(schemata); } { // XXX FIX ME XXX // these are a bit hacked Table types = createSystemTable("AXION_TYPES"); types.addColumn(new Column("TYPE_NAME",new StringType())); types.addColumn(new Column("DATA_TYPE",new ShortType()));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -