/** * Get the table alias name. If no alias is specified, the table name is * returned. * * @return the alias name */ @Override public String getTableAlias() { if (alias != null) { return alias; } return table.getName(); }
@Override public String getTableName() { Table table = column.getTable(); return table == null ? null : table.getName(); }
/** * Add a local temporary table to this session. * * @param table the table to add * @throws DbException if a table with this name already exists */ public void addLocalTempTable(Table table) { if (localTempTables == null) { localTempTables = database.newStringMap(); } if (localTempTables.get(table.getName()) != null) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, table.getSQL()+" AS "+table.getName()); } modificationId++; localTempTables.put(table.getName(), table); }
/** * Drop and remove the given local temporary table from this session. * * @param table the table */ public void removeLocalTempTable(Table table) { // Exception thrown in org.h2.engine.Database.removeMeta if line below // is missing with TestGeneralCommonTableQueries database.lockMeta(this); modificationId++; localTempTables.remove(table.getName()); synchronized (database) { table.removeChildrenAndResources(this); } }
@Override public String toString() { return "page[" + getPos() + "] data leaf table:" + index.getId() + " " + index.getTable().getName() + " entries:" + entryCount + " parent:" + parentPageId + (firstOverflowPageId == 0 ? "" : " overflow:" + firstOverflowPageId) + " keys:" + Arrays.toString(keys) + " offsets:" + Arrays.toString(offsets); }
/** * @param tbl Table. */ public GridSqlTable(Table tbl) { this(tbl.getSchema().getName(), tbl.getName(), tbl); }
private ArrayList<Table> getTablesByName(Session session, String tableName) { if (database.getMode().lowerCaseIdentifiers) { tableName = StringUtils.toUpperEnglish(tableName); } ArrayList<Table> tables = database.getTableOrViewByName(tableName); for (Table temp : session.getLocalTempTables()) { if (temp.getName().equals(tableName)) { tables.add(temp); } } return tables; }
append('.').append(table.getName()). append('\n');
if (obj.getName() != null) { if (database.getDependentTable(obj, obj) == null) { database.removeSchemaObject(session, obj);
private synchronized void load() { if (triggerCallback != null) { return; } try { Session sysSession = database.getSystemSession(); Connection c2 = sysSession.createConnection(false); Object obj; if (triggerClassName != null) { obj = JdbcUtils.loadUserClass(triggerClassName).newInstance(); } else { obj = loadFromSource(); } triggerCallback = (Trigger) obj; triggerCallback.init(c2, getSchema().getName(), getName(), table.getName(), before, typeMask); } catch (Throwable e) { // try again later triggerCallback = null; throw DbException.get(ErrorCode.ERROR_CREATING_TRIGGER_OBJECT_3, e, getName(), triggerClassName != null ? triggerClassName : "..source..", e.toString()); } }
@Override public int update() { session.commit(true); Database db = session.getDatabase(); Table oldTable = getSchema().findTableOrView(session, oldTableName); if (oldTable == null) { if (ifTableExists) { return 0; } throw DbException.get(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, oldTableName); } session.getUser().checkRight(oldTable, Right.ALL); Table t = getSchema().findTableOrView(session, newTableName); if (t != null && hidden && newTableName.equals(oldTable.getName())) { if (!t.isHidden()) { t.setHidden(hidden); oldTable.setHidden(true); db.updateMeta(session, oldTable); } return 0; } if (t != null || newTableName.equals(oldTable.getName())) { throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, newTableName); } if (oldTable.isTemporary()) { throw DbException.getUnsupportedException("temp table"); } db.renameSchemaObject(session, oldTable, newTableName); return 0; }
/** * Convert a value to this column's type using the given {@link Mode}. * <p> * Use this method in case the conversion is Mode-dependent. * * @param v the value * @param mode the database {@link Mode} to use * @return the value */ public Value convert(Value v, Mode mode) { try { return v.convertTo(type, MathUtils.convertLongToInt(precision), mode, this, getEnumerators()); } catch (DbException e) { if (e.getErrorCode() == ErrorCode.DATA_CONVERSION_ERROR_1) { String target = (table == null ? "" : table.getName() + ": ") + getCreateSQL(); throw DbException.get( ErrorCode.DATA_CONVERSION_ERROR_1, e, v.getSQL() + " (" + target + ")"); } throw e; } }
for (int i = 0; i < columns.length; i++) { String key = table.getSchema().getName() + "." + table.getName() + "." + columns[i].getName(); variableNames.add(key); session.setVariable(key,
for (Column column : indexedColumns) { ExpressionColumn expr = new ExpressionColumn(session.getDatabase(), table.getSchema().getName(), table.getName(), column.getName()); for (int i = 0; i < columns.length; i++) {
String baseName = table.getName(); String tempName = db.getTempTableName(baseName, session); Column[] columns = table.getColumns(); execute("DROP TABLE " + newTable.getName(), true); throw DbException.get(ErrorCode.VIEW_IS_INVALID_2, e, getSQL(), e.getMessage()); String tableName = table.getName(); ArrayList<TableView> dependentViews = new ArrayList<>(table.getDependentViews()); for (TableView view : dependentViews) {
throw DbException.get(ErrorCode.CONCURRENT_UPDATE_1, table.getName());
throw DbException.get(ErrorCode.CONCURRENT_UPDATE_1, table.getName());
throw DbException.get(ErrorCode.CONCURRENT_UPDATE_1, table.getName());
throw DbException.get(ErrorCode.CONCURRENT_UPDATE_1, targetTable.getName());
identifier(table.getSchema().getName()),