提交 81625085 authored 作者: Thomas Mueller's avatar Thomas Mueller

Trying to convert a VARCHAR to UUID will now fail if the text contains a…

Trying to convert a VARCHAR to UUID will now fail if the text contains a character that is not a hex digit, '-', or not a whitespace.
上级 c9e8941a
......@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>TriggerAdapter: in "before" triggers, values can be changed using the ResultSet.updateX methods.
<ul><li>Trying to convert a VARCHAR to UUID will now fail if the text contains
a character that is not a hex digit, '-', or not a whitespace.
</li><li>TriggerAdapter: in "before" triggers, values can be changed using the ResultSet.updateX methods.
</li><li>Creating a table with column data type NULL now works (even if not very useful).
</li><li>ALTER TABLE ALTER COLUMN no longer copies the data for widening conversions
(for example if only the precision was increased) unless necessary.
......
......@@ -10,6 +10,8 @@ import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.UUID;
import org.h2.constant.ErrorCode;
import org.h2.message.DbException;
import org.h2.util.Utils;
import org.h2.util.MathUtils;
import org.h2.util.StringUtils;
......@@ -100,8 +102,10 @@ public class ValueUuid extends Value {
continue;
} else if (c >= 'A' && c <= 'F') {
low = (low << 4) | (c - 'A' + 0xa);
} else {
} else if (c <= ' ') {
continue;
} else {
throw DbException.get(ErrorCode.DATA_CONVERSION_ERROR_1, s);
}
if (j++ == 15) {
high = low;
......
--- special grammar and test cases ---------------------------------------------------------------------------------------------
call cast('null' as uuid);
> exception
create table test(name varchar(255));
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论