提交 285a6831 authored 作者: Noel Grandin's avatar Noel Grandin

Improve naming of the object id field in Prepared

上级 9e734920
...@@ -54,7 +54,10 @@ public abstract class Prepared { ...@@ -54,7 +54,10 @@ public abstract class Prepared {
private long modificationMetaId; private long modificationMetaId;
private Command command; private Command command;
private int objectId; /**
* Used when we restore metadata at startup, this is the metadata object ID as persisted in the database.
*/
private int persistedObjectId;
private int currentRowNumber; private int currentRowNumber;
private int rowScanCount; private int rowScanCount;
/** /**
...@@ -239,27 +242,25 @@ public abstract class Prepared { ...@@ -239,27 +242,25 @@ public abstract class Prepared {
/** /**
* Get the object id to use for the database object that is created in this * 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. * If not set, this method returns 0.
* *
* @return the object id or 0 if not set * @return the object id or 0 if not set
*/ */
protected int getCurrentObjectId() { protected int getPersistedObjectId() {
return objectId; return persistedObjectId;
} }
/** /**
* Get the current object id, or get a new id from the database. The object * Get the current object id (ie. if it is already persisted), or get a new id from the database. The object
* id is used when creating new database object (CREATE statement). * id is used when creating new database object (CREATE statement).
* *
* @return the object id * @return the object id
*/ */
protected int getObjectId() { protected int getObjectId() {
int id = objectId; int id = persistedObjectId;
if (id == 0) { if (id == 0) {
id = session.getDatabase().allocateObjectId(); id = session.getDatabase().allocateObjectId();
} else {
objectId = 0;
} }
return id; return id;
} }
...@@ -287,12 +288,12 @@ public abstract class Prepared { ...@@ -287,12 +288,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 * @param i the object id
*/ */
public void setObjectId(int i) { public void setPersistedObjectId(int i) {
this.objectId = i; this.persistedObjectId = i;
this.create = false; this.create = false;
} }
......
...@@ -418,7 +418,7 @@ public class Set extends Prepared { ...@@ -418,7 +418,7 @@ public class Set extends Prepared {
} }
case SetTypes.TRACE_LEVEL_FILE: case SetTypes.TRACE_LEVEL_FILE:
session.getUser().checkAdmin(); session.getUser().checkAdmin();
if (getCurrentObjectId() == 0) { if (getPersistedObjectId() == 0) {
// don't set the property when opening the database // don't set the property when opening the database
// this is for compatibility with older versions, because // this is for compatibility with older versions, because
// this setting was persistent // this setting was persistent
...@@ -427,7 +427,7 @@ public class Set extends Prepared { ...@@ -427,7 +427,7 @@ public class Set extends Prepared {
break; break;
case SetTypes.TRACE_LEVEL_SYSTEM_OUT: case SetTypes.TRACE_LEVEL_SYSTEM_OUT:
session.getUser().checkAdmin(); session.getUser().checkAdmin();
if (getCurrentObjectId() == 0) { if (getPersistedObjectId() == 0) {
// don't set the property when opening the database // don't set the property when opening the database
// this is for compatibility with older versions, because // this is for compatibility with older versions, because
// this setting was persistent // this setting was persistent
...@@ -552,7 +552,7 @@ public class Set extends Prepared { ...@@ -552,7 +552,7 @@ public class Set extends Prepared {
} }
addOrUpdateSetting(name,expression.getValue(session).getString(),0); addOrUpdateSetting(name,expression.getValue(session).getString(),0);
} catch (Exception e) { } 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()) { if (database.isStarting()) {
database.getTrace(Trace.DATABASE).error(e, "{0}: failed to set authenticator during database start ",expression.toString()); database.getTrace(Trace.DATABASE).error(e, "{0}: failed to set authenticator during database start ",expression.toString());
} else { } else {
......
...@@ -54,7 +54,7 @@ public class MetaRecord implements Comparable<MetaRecord> { ...@@ -54,7 +54,7 @@ public class MetaRecord implements Comparable<MetaRecord> {
DatabaseEventListener listener) { DatabaseEventListener listener) {
try { try {
Prepared command = systemSession.prepare(sql); Prepared command = systemSession.prepare(sql);
command.setObjectId(id); command.setPersistedObjectId(id);
command.update(); command.update();
} catch (DbException e) { } catch (DbException e) {
e = e.addSQL(sql); e = e.addSQL(sql);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论