提交 850bee14 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use specified PK name in inline constraint definition

上级 36dfb831
......@@ -6727,6 +6727,7 @@ public class Parser {
cols[0].columnName = column.getName();
AlterTableAddConstraint pk = new AlterTableAddConstraint(
session, schema, false);
pk.setConstraintName(constraintName);
pk.setPrimaryKeyHash(hash);
pk.setType(CommandInterface.ALTER_TABLE_ADD_CONSTRAINT_PRIMARY_KEY);
pk.setTableName(tableName);
......
......@@ -102,7 +102,8 @@ public class TestScript extends TestBase {
"uuid", "varchar", "varchar-ignorecase" }) {
testScript("datatypes/" + s + ".sql");
}
for (String s : new String[] { "alterTableAdd", "alterTableDropColumn", "createView", "dropSchema" }) {
for (String s : new String[] { "alterTableAdd", "alterTableDropColumn", "createView", "createTable",
"dropSchema" }) {
testScript("ddl/" + s + ".sql");
}
for (String s : new String[] { "insertIgnore", "mergeUsing", "script", "with" }) {
......
......@@ -86,3 +86,18 @@ INSERT INTO TEST VALUES (10, 20, 30, 40);
DROP TABLE TEST;
> ok
CREATE TABLE TEST();
> ok
ALTER TABLE TEST ADD A INT CONSTRAINT PK_1 PRIMARY KEY;
> ok
SELECT CONSTRAINT_NAME, CONSTRAINT_TYPE FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS;
> CONSTRAINT_NAME CONSTRAINT_TYPE
> --------------- ---------------
> PK_1 PRIMARY KEY
> rows: 1
DROP TABLE TEST;
> ok
-- Copyright 2004-2018 H2 Group. Multiple-Licensed under the MPL 2.0,
-- and the EPL 1.0 (http://h2database.com/html/license.html).
-- Initial Developer: H2 Group
--
CREATE TABLE TEST(A INT CONSTRAINT PK_1 PRIMARY KEY);
> ok
SELECT CONSTRAINT_NAME, CONSTRAINT_TYPE FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS;
> CONSTRAINT_NAME CONSTRAINT_TYPE
> --------------- ---------------
> PK_1 PRIMARY KEY
> rows: 1
DROP TABLE TEST;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论