提交 9cbd604d authored 作者: Thomas Mueller's avatar Thomas Mueller

boolean getX > isX

上级 32aef28f
...@@ -3393,7 +3393,7 @@ public class Parser { ...@@ -3393,7 +3393,7 @@ public class Parser {
int type = dataType.type; int type = dataType.type;
Column column = new Column(columnName, type, precision, scale, displaySize); Column column = new Column(columnName, type, precision, scale, displaySize);
if (templateColumn != null) { if (templateColumn != null) {
column.setNullable(templateColumn.getNullable()); column.setNullable(templateColumn.isNullable());
column.setDefaultExpression(session, templateColumn.getDefaultExpression()); column.setDefaultExpression(session, templateColumn.getDefaultExpression());
int selectivity = templateColumn.getSelectivity(); int selectivity = templateColumn.getSelectivity();
if (selectivity != Constants.SELECTIVITY_DEFAULT) { if (selectivity != Constants.SELECTIVITY_DEFAULT) {
...@@ -3774,8 +3774,7 @@ public class Parser { ...@@ -3774,8 +3774,7 @@ public class Parser {
columns.add(new Column(c, Value.STRING)); columns.add(new Column(c, Value.STRING));
} }
int id = database.allocateObjectId(true, true); int id = database.allocateObjectId(true, true);
recursiveTable = schema.createTable(tempViewName, id, columns, false, true, false, Index.EMPTY_HEAD, session); recursiveTable = schema.createTable(tempViewName, id, columns, true, false, true, false, Index.EMPTY_HEAD, session);
recursiveTable.setTemporary(true);
session.addLocalTempTable(recursiveTable); session.addLocalTempTable(recursiveTable);
String querySQL = StringCache.getNew(sqlCommand.substring(parseIndex)); String querySQL = StringCache.getNew(sqlCommand.substring(parseIndex));
read("AS"); read("AS");
...@@ -4616,7 +4615,7 @@ public class Parser { ...@@ -4616,7 +4615,7 @@ public class Parser {
} else { } else {
String columnName = readColumnIdentifier(); String columnName = readColumnIdentifier();
Column column = parseColumnForTable(columnName); Column column = parseColumnForTable(columnName);
if (column.getAutoIncrement() && column.getPrimaryKey()) { if (column.isAutoIncrement() && column.isPrimaryKey()) {
column.setPrimaryKey(false); column.setPrimaryKey(false);
IndexColumn[] cols = new IndexColumn[]{new IndexColumn()}; IndexColumn[] cols = new IndexColumn[]{new IndexColumn()};
cols[0].columnName = column.getName(); cols[0].columnName = column.getName();
......
...@@ -249,7 +249,7 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -249,7 +249,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
} }
// parent relationship is already set with addConstraint // parent relationship is already set with addConstraint
constraint.setComment(comment); constraint.setComment(comment);
if (table.getTemporary() && !table.getGlobalTemporary()) { if (table.isTemporary() && !table.isGlobalTemporary()) {
session.addLocalTempTableConstraint(constraint); session.addLocalTempTableConstraint(constraint);
} else { } else {
db.addSchemaObject(session, constraint); db.addSchemaObject(session, constraint);
...@@ -305,7 +305,7 @@ public class AlterTableAddConstraint extends SchemaCommand { ...@@ -305,7 +305,7 @@ public class AlterTableAddConstraint extends SchemaCommand {
} }
private boolean canUseUniqueIndex(Index idx, Table table, IndexColumn[] cols) { private boolean canUseUniqueIndex(Index idx, Table table, IndexColumn[] cols) {
if (idx.getTable() != table || !idx.getIndexType().getUnique()) { if (idx.getTable() != table || !idx.getIndexType().isUnique()) {
return false; return false;
} }
Column[] indexCols = idx.getColumns(); Column[] indexCols = idx.getColumns();
......
...@@ -113,7 +113,7 @@ public class AlterTableAlterColumn extends SchemaCommand { ...@@ -113,7 +113,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
Sequence sequence = oldColumn == null ? null : oldColumn.getSequence(); Sequence sequence = oldColumn == null ? null : oldColumn.getSequence();
switch (type) { switch (type) {
case NOT_NULL: { case NOT_NULL: {
if (!oldColumn.getNullable()) { if (!oldColumn.isNullable()) {
// no change // no change
break; break;
} }
...@@ -123,7 +123,7 @@ public class AlterTableAlterColumn extends SchemaCommand { ...@@ -123,7 +123,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
break; break;
} }
case NULL: { case NULL: {
if (oldColumn.getNullable()) { if (oldColumn.isNullable()) {
// no change // no change
break; break;
} }
...@@ -147,9 +147,9 @@ public class AlterTableAlterColumn extends SchemaCommand { ...@@ -147,9 +147,9 @@ public class AlterTableAlterColumn extends SchemaCommand {
oldColumn.setSequence(null); oldColumn.setSequence(null);
oldColumn.setDefaultExpression(session, null); oldColumn.setDefaultExpression(session, null);
oldColumn.setConvertNullToDefault(false); oldColumn.setConvertNullToDefault(false);
if (oldColumn.getNullable() && !newColumn.getNullable()) { if (oldColumn.isNullable() && !newColumn.isNullable()) {
checkNoNullValues(); checkNoNullValues();
} else if (!oldColumn.getNullable() && newColumn.getNullable()) { } else if (!oldColumn.isNullable() && newColumn.isNullable()) {
checkNullable(); checkNullable();
} }
convertToIdentityIfRequired(newColumn); convertToIdentityIfRequired(newColumn);
...@@ -185,7 +185,7 @@ public class AlterTableAlterColumn extends SchemaCommand { ...@@ -185,7 +185,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
} }
private void convertToIdentityIfRequired(Column c) { private void convertToIdentityIfRequired(Column c) {
if (c.getAutoIncrement()) { if (c.isAutoIncrement()) {
c.setOriginalSQL("IDENTITY"); c.setOriginalSQL("IDENTITY");
} }
} }
...@@ -232,13 +232,14 @@ public class AlterTableAlterColumn extends SchemaCommand { ...@@ -232,13 +232,14 @@ public class AlterTableAlterColumn extends SchemaCommand {
newColumns.remove(position); newColumns.remove(position);
newColumns.add(position, newColumn); newColumns.add(position, newColumn);
} }
// create a table object in order to get the SQL statement // create a table object in order to get the SQL statement
// can't just use this table, because most column objects are 'shared' // can't just use this table, because most column objects are 'shared'
// with the old table // with the old table
// still need a new id because using 0 would mean: the new table tries // still need a new id because using 0 would mean: the new table tries
// to use the rows of the table 0 (the meta table) // to use the rows of the table 0 (the meta table)
int id = db.allocateObjectId(true, true); int id = db.allocateObjectId(true, true);
TableData newTable = getSchema().createTable(tempName, id, newColumns, table.isPersistIndexes(), table.isPersistData(), false, Index.EMPTY_HEAD, session); TableData newTable = getSchema().createTable(tempName, id, newColumns, table.isTemporary(), table.isPersistIndexes(), table.isPersistData(), false, Index.EMPTY_HEAD, session);
newTable.setComment(table.getComment()); newTable.setComment(table.getComment());
StringBuilder buff = new StringBuilder(); StringBuilder buff = new StringBuilder();
buff.append(newTable.getCreateSQL()); buff.append(newTable.getCreateSQL());
...@@ -263,8 +264,12 @@ public class AlterTableAlterColumn extends SchemaCommand { ...@@ -263,8 +264,12 @@ public class AlterTableAlterColumn extends SchemaCommand {
} }
buff.append(" FROM ").append(table.getSQL()); buff.append(" FROM ").append(table.getSQL());
String newTableSQL = buff.toString(); String newTableSQL = buff.toString();
String newTableName = newTable.getName();
Schema newTableSchema = newTable.getSchema();
newTable.removeChildrenAndResources(session);
execute(newTableSQL, true); execute(newTableSQL, true);
newTable = (TableData) newTable.getSchema().getTableOrView(session, newTable.getName()); newTable = (TableData) newTableSchema.getTableOrView(session, newTableName);
ObjectArray<String> triggers = ObjectArray.newInstance(); ObjectArray<String> triggers = ObjectArray.newInstance();
for (DbObject child : table.getChildren()) { for (DbObject child : table.getChildren()) {
if (child instanceof Sequence) { if (child instanceof Sequence) {
...@@ -384,7 +389,7 @@ public class AlterTableAlterColumn extends SchemaCommand { ...@@ -384,7 +389,7 @@ public class AlterTableAlterColumn extends SchemaCommand {
continue; continue;
} }
IndexType indexType = index.getIndexType(); IndexType indexType = index.getIndexType();
if (indexType.getPrimaryKey() || indexType.getHash()) { if (indexType.isPrimaryKey() || indexType.isHash()) {
throw Message.getSQLException(ErrorCode.COLUMN_IS_PART_OF_INDEX_1, index.getSQL()); throw Message.getSQLException(ErrorCode.COLUMN_IS_PART_OF_INDEX_1, index.getSQL());
} }
} }
......
...@@ -44,7 +44,7 @@ public class AlterTableRename extends SchemaCommand { ...@@ -44,7 +44,7 @@ public class AlterTableRename extends SchemaCommand {
throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, newTableName); throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, newTableName);
} }
session.getUser().checkRight(oldTable, Right.ALL); session.getUser().checkRight(oldTable, Right.ALL);
if (oldTable.getTemporary()) { if (oldTable.isTemporary()) {
throw Message.getUnsupportedException("TEMP TABLE"); throw Message.getUnsupportedException("TEMP TABLE");
} }
db.renameSchemaObject(session, oldTable, newTableName); db.renameSchemaObject(session, oldTable, newTableName);
......
...@@ -131,7 +131,7 @@ public class CreateTable extends SchemaCommand { ...@@ -131,7 +131,7 @@ public class CreateTable extends SchemaCommand {
} }
ObjectArray<Sequence> sequences = ObjectArray.newInstance(); ObjectArray<Sequence> sequences = ObjectArray.newInstance();
for (Column c : columns) { for (Column c : columns) {
if (c.getAutoIncrement()) { if (c.isAutoIncrement()) {
int objId = getObjectId(true, true); int objId = getObjectId(true, true);
c.convertAutoIncrementToSequence(session, getSchema(), objId, temporary); c.convertAutoIncrementToSequence(session, getSchema(), objId, temporary);
} }
...@@ -141,9 +141,8 @@ public class CreateTable extends SchemaCommand { ...@@ -141,9 +141,8 @@ public class CreateTable extends SchemaCommand {
} }
} }
int id = getObjectId(true, true); int id = getObjectId(true, true);
TableData table = getSchema().createTable(tableName, id, columns, persistIndexes, persistData, clustered, headPos, session); TableData table = getSchema().createTable(tableName, id, columns, temporary, persistIndexes, persistData, clustered, headPos, session);
table.setComment(comment); table.setComment(comment);
table.setTemporary(temporary);
table.setGlobalTemporary(globalTemporary); table.setGlobalTemporary(globalTemporary);
if (temporary && !globalTemporary) { if (temporary && !globalTemporary) {
if (onCommitDrop) { if (onCommitDrop) {
...@@ -167,7 +166,7 @@ public class CreateTable extends SchemaCommand { ...@@ -167,7 +166,7 @@ public class CreateTable extends SchemaCommand {
command.update(); command.update();
} }
if (asQuery != null) { if (asQuery != null) {
boolean old = session.getUndoLogEnabled(); boolean old = session.isUndoLogEnabled();
try { try {
session.setUndoLogEnabled(false); session.setUndoLogEnabled(false);
Insert insert = null; Insert insert = null;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论