提交 bbf4df6f authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Pass Mode to convert() methods in all DML commands

上级 6092aecf
......@@ -14,6 +14,7 @@ import org.h2.command.Command;
import org.h2.command.CommandInterface;
import org.h2.command.Prepared;
import org.h2.engine.GeneratedKeys;
import org.h2.engine.Mode;
import org.h2.engine.Right;
import org.h2.engine.Session;
import org.h2.engine.UndoLogRecord;
......@@ -151,6 +152,7 @@ public class Insert extends Prepared implements ResultTarget {
generatedKeys.initialize(table);
int listSize = list.size();
if (listSize > 0) {
Mode mode = session.getDatabase().getMode();
int columnLen = columns.length;
for (int x = 0; x < listSize; x++) {
session.startStatementWithinTransaction();
......@@ -166,7 +168,7 @@ public class Insert extends Prepared implements ResultTarget {
// e can be null (DEFAULT)
e = e.optimize(session);
try {
Value v = c.convert(e.getValue(session), session.getDatabase().getMode());
Value v = c.convert(e.getValue(session), mode);
newRow.setValue(index, v);
if (e instanceof SequenceValue) {
generatedKeys.add(c);
......@@ -239,11 +241,12 @@ public class Insert extends Prepared implements ResultTarget {
private Row addRowImpl(Value[] values) {
Row newRow = table.getTemplateRow();
setCurrentRowNumber(++rowNumber);
Mode mode = session.getDatabase().getMode();
for (int j = 0, len = columns.length; j < len; j++) {
Column c = columns[j];
int index = c.getColumnId();
try {
Value v = c.convert(values[j], session.getDatabase().getMode());
Value v = c.convert(values[j], mode);
newRow.setValue(index, v);
} catch (DbException ex) {
throw setRow(ex, rowNumber, getSQL(values));
......
......@@ -13,6 +13,7 @@ import org.h2.command.Command;
import org.h2.command.CommandInterface;
import org.h2.command.Prepared;
import org.h2.engine.GeneratedKeys;
import org.h2.engine.Mode;
import org.h2.engine.Right;
import org.h2.engine.Session;
import org.h2.engine.UndoLogRecord;
......@@ -88,6 +89,7 @@ public class Merge extends Prepared {
session.getUser().checkRight(targetTable, Right.UPDATE);
setCurrentRowNumber(0);
GeneratedKeys generatedKeys = session.getGeneratedKeys();
Mode mode = session.getDatabase().getMode();
if (!valuesExpressionList.isEmpty()) {
// process values in list
count = 0;
......@@ -104,7 +106,7 @@ public class Merge extends Prepared {
if (e != null) {
// e can be null (DEFAULT)
try {
Value v = c.convert(e.getValue(session));
Value v = c.convert(e.getValue(session), mode);
newRow.setValue(index, v);
if (e instanceof SequenceValue) {
generatedKeys.add(c);
......@@ -134,7 +136,7 @@ public class Merge extends Prepared {
Column c = columns[j];
int index = c.getColumnId();
try {
Value v = c.convert(r[j]);
Value v = c.convert(r[j], mode);
newRow.setValue(index, v);
} catch (DbException ex) {
throw setRow(ex, count, getSQL(r));
......
......@@ -12,6 +12,7 @@ import org.h2.api.Trigger;
import org.h2.command.Command;
import org.h2.command.CommandInterface;
import org.h2.command.Prepared;
import org.h2.engine.Mode;
import org.h2.engine.Right;
import org.h2.engine.Session;
import org.h2.engine.UndoLogRecord;
......@@ -82,6 +83,7 @@ public class Replace extends Prepared {
session.getUser().checkRight(table, Right.INSERT);
session.getUser().checkRight(table, Right.UPDATE);
setCurrentRowNumber(0);
Mode mode = session.getDatabase().getMode();
if (!list.isEmpty()) {
count = 0;
for (int x = 0, size = list.size(); x < size; x++) {
......@@ -95,7 +97,7 @@ public class Replace extends Prepared {
if (e != null) {
// e can be null (DEFAULT)
try {
Value v = c.convert(e.getValue(session));
Value v = c.convert(e.getValue(session), mode);
newRow.setValue(index, v);
} catch (DbException ex) {
throw setRow(ex, count, getSQL(expr));
......@@ -119,7 +121,7 @@ public class Replace extends Prepared {
Column c = columns[j];
int index = c.getColumnId();
try {
Value v = c.convert(r[j]);
Value v = c.convert(r[j], mode);
newRow.setValue(index, v);
} catch (DbException ex) {
throw setRow(ex, count, getSQL(r));
......
......@@ -131,7 +131,7 @@ public class Update extends Prepared {
} else if (newExpr == ValueExpression.getDefault()) {
newValue = table.getDefaultValue(session, column);
} else {
newValue = column.convert(newExpr.getValue(session));
newValue = column.convert(newExpr.getValue(session), session.getDatabase().getMode());
}
newRow.setValue(i, newValue);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论