public MetaRecord(DbObject obj) { id = obj.getId(); objectType = obj.getType(); sql = obj.getCreateSQL(); }
private void updateMetaAndFirstLevelChildren(ServerSession session, DbObject obj) { List<DbObject> list = obj.getChildren(); Comment comment = findComment(obj); if (comment != null) { DbException.throwInternalError(); } updateMeta(session, obj); // remember that this scans only one level deep! if (list != null) { for (DbObject o : list) { if (o.getCreateSQL() != null) { updateMeta(session, o); } } } }
@Override public int update() { synchronized (getSchema().getLock(DbObjectType.TABLE_OR_VIEW)) { Database db = session.getDatabase(); session.getUser().checkRight(table, Right.ALL); table.checkSupportAlter(); // we need to update CHECK constraint // since it might reference the name of the column Expression newCheckExpr = (Expression) column.getCheckConstraint(session, newName); table.renameColumn(column, newName); column.removeCheckConstraint(); SingleColumnResolver resolver = new SingleColumnResolver(column); column.addCheckConstraint(session, newCheckExpr, resolver); table.setModified(); db.updateMeta(session, table); for (DbObject child : table.getChildren()) { if (child.getCreateSQL() != null) { db.updateMeta(session, child); } } } return 0; }