提交 503350ba authored 作者: Thomas Mueller's avatar Thomas Mueller

Parser: sequenceName.NEXTVAL and CURRVAL did not respect the schema search path.

上级 8b13e264
......@@ -18,7 +18,8 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>The following sequence could throw the exception "Row not found when trying to delete":
<ul><li>Parser: sequenceName.NEXTVAL and CURRVAL did not respect the schema search path.
</li><li>The following sequence could throw the exception "Row not found when trying to delete":
start a transaction, insert many rows, delete many rows, rollback. The number of rows depends
on the cache size.
</li><li>The stack trace of very common exceptions is no longer written to the .trace.db file by default.
......
......@@ -2102,16 +2102,16 @@ public class Parser {
schema = session.getCurrentSchemaName();
}
if (readIf("NEXTVAL")) {
Sequence sequence = database.getSchema(schema).findSequence(objectName);
Sequence sequence = findSequence(schema, objectName);
if (sequence != null) {
return new SequenceValue(sequence);
}
} else if (readIf("CURRVAL")) {
Sequence sequence = database.getSchema(schema).findSequence(objectName);
Sequence sequence = findSequence(schema, objectName);
if (sequence != null) {
Function function = Function.getFunction(database, "CURRVAL");
function.setParameter(0, ValueExpression.get(ValueString.get(schema)));
function.setParameter(1, ValueExpression.get(ValueString.get(objectName)));
function.setParameter(0, ValueExpression.get(ValueString.get(sequence.getSchema().getName())));
function.setParameter(1, ValueExpression.get(ValueString.get(sequence.getName())));
function.doneWithParameters();
return function;
}
......@@ -4265,13 +4265,8 @@ public class Parser {
throw Message.getSQLException(ErrorCode.TABLE_OR_VIEW_NOT_FOUND_1, tableName);
}
private Sequence readSequence() throws SQLException {
// same algorithm than readTableOrView
String sequenceName = readIdentifierWithSchema(null);
if (schemaName != null) {
return getSchema().getSequence(sequenceName);
}
Sequence sequence = database.getSchema(session.getCurrentSchemaName()).findSequence(sequenceName);
private Sequence findSequence(String schemaName, String sequenceName) throws SQLException {
Sequence sequence = database.getSchema(schemaName).findSequence(sequenceName);
if (sequence != null) {
return sequence;
}
......@@ -4283,6 +4278,19 @@ public class Parser {
return sequence;
}
}
return null;
}
private Sequence readSequence() throws SQLException {
// same algorithm than readTableOrView
String sequenceName = readIdentifierWithSchema(null);
if (schemaName != null) {
return getSchema().getSequence(sequenceName);
}
Sequence sequence = findSequence(session.getCurrentSchemaName(), sequenceName);
if (sequence != null) {
return sequence;
}
throw Message.getSQLException(ErrorCode.SEQUENCE_NOT_FOUND_1, sequenceName);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论