Unverified 提交 dccd19ef authored 作者: Noel Grandin's avatar Noel Grandin 提交者: GitHub

Merge pull request #1185 from grandinj/objectid_in_prepared

Improve naming of the object id field in Prepared
......@@ -59,7 +59,7 @@ public abstract class Prepared {
* object is not stored, {@code -1} if object is stored and its ID is
* already read, {@code >0} if object is stored and its id is not yet read.
*/
private int objectId;
private int persistedObjectId;
private int currentRowNumber;
private int rowScanCount;
/**
......@@ -244,13 +244,13 @@ public abstract class Prepared {
/**
* Get the object id to use for the database object that is created in this
* statement. This id is only set when the object is persistent.
* statement. This id is only set when the object is already persisted.
* If not set, this method returns 0.
*
* @return the object id or 0 if not set
*/
protected int getCurrentObjectId() {
int id = objectId;
protected int getPersistedObjectId() {
int id = persistedObjectId;
return id >= 0 ? id : 0;
}
......@@ -262,13 +262,13 @@ public abstract class Prepared {
* @return the object id
*/
protected int getObjectId() {
int id = objectId;
int id = persistedObjectId;
if (id == 0) {
id = session.getDatabase().allocateObjectId();
} else if (id < 0) {
throw DbException.throwInternalError("Prepared.getObjectId() was called before");
}
objectId = -1;
persistedObjectId = -1;
return id;
}
......@@ -295,12 +295,12 @@ public abstract class Prepared {
}
/**
* Set the object id for this statement.
* Set the persisted object id for this statement.
*
* @param i the object id
*/
public void setObjectId(int i) {
this.objectId = i;
public void setPersistedObjectId(int i) {
this.persistedObjectId = i;
this.create = false;
}
......
......@@ -418,7 +418,7 @@ public class Set extends Prepared {
}
case SetTypes.TRACE_LEVEL_FILE:
session.getUser().checkAdmin();
if (getCurrentObjectId() == 0) {
if (getPersistedObjectId() == 0) {
// don't set the property when opening the database
// this is for compatibility with older versions, because
// this setting was persistent
......@@ -427,7 +427,7 @@ public class Set extends Prepared {
break;
case SetTypes.TRACE_LEVEL_SYSTEM_OUT:
session.getUser().checkAdmin();
if (getCurrentObjectId() == 0) {
if (getPersistedObjectId() == 0) {
// don't set the property when opening the database
// this is for compatibility with older versions, because
// this setting was persistent
......@@ -552,7 +552,7 @@ public class Set extends Prepared {
}
addOrUpdateSetting(name,expression.getValue(session).getString(),0);
} catch (Exception e) {
//Errors during start are ignored to allow to open the database
//Errors during start are ignored to allow to open the database
if (database.isStarting()) {
database.getTrace(Trace.DATABASE).error(e, "{0}: failed to set authenticator during database start ",expression.toString());
} else {
......
......@@ -54,7 +54,7 @@ public class MetaRecord implements Comparable<MetaRecord> {
DatabaseEventListener listener) {
try {
Prepared command = systemSession.prepare(sql);
command.setObjectId(id);
command.setPersistedObjectId(id);
command.update();
} catch (DbException e) {
e = e.addSQL(sql);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论