You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2018/04/27 18:41:18 UTC
[3/4] phoenix git commit: PHOENIX-4711 Unable to set property on
table with VARBINARY as last column
PHOENIX-4711 Unable to set property on table with VARBINARY as last column
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/4b0feaee
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/4b0feaee
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/4b0feaee
Branch: refs/heads/4.x-HBase-1.3
Commit: 4b0feaee2deb3c90c58a4e5a7a726bfbf72466fa
Parents: 45ace77
Author: James Taylor <jt...@salesforce.com>
Authored: Thu Apr 26 17:13:48 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Fri Apr 27 11:41:05 2018 -0700
----------------------------------------------------------------------
.../apache/phoenix/end2end/AlterTableIT.java | 12 ++++++-----
.../apache/phoenix/schema/MetaDataClient.java | 22 +++++++++++---------
2 files changed, 19 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/4b0feaee/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
index dd895dc..b1949ed 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
@@ -116,12 +116,14 @@ public class AlterTableIT extends ParallelStatsDisabledIT {
Connection conn = DriverManager.getConnection(getUrl(), props);
conn.setAutoCommit(false);
- try {
- String ddl = "CREATE TABLE " + dataTableFullName +
- " (a_string varchar not null, a_binary varbinary not null, col1 integer" +
- " CONSTRAINT pk PRIMARY KEY (a_string, a_binary)) " + tableDDLOptions;
- createTestTable(getUrl(), ddl);
+ String ddl = "CREATE TABLE " + dataTableFullName +
+ " (a_string varchar not null, a_binary varbinary not null, col1 integer" +
+ " CONSTRAINT pk PRIMARY KEY (a_string, a_binary)) " + tableDDLOptions;
+ createTestTable(getUrl(), ddl);
+
+ conn.createStatement().execute("ALTER TABLE " + dataTableFullName + " SET DISABLE_WAL = true");
+ try {
ddl = "ALTER TABLE " + dataTableFullName + " ADD b_string VARCHAR NULL PRIMARY KEY";
PreparedStatement stmt = conn.prepareStatement(ddl);
stmt.execute();
http://git-wip-us.apache.org/repos/asf/phoenix/blob/4b0feaee/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index b15072a..a3d2baf 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -3259,16 +3259,18 @@ public class MetaDataClient {
int position = table.getColumns().size();
List<PColumn> currentPKs = table.getPKColumns();
- PColumn lastPK = currentPKs.get(currentPKs.size()-1);
- // Disallow adding columns if the last column is VARBIANRY.
- if (lastPK.getDataType() == PVarbinary.INSTANCE || lastPK.getDataType().isArrayType()) {
- throw new SQLExceptionInfo.Builder(SQLExceptionCode.VARBINARY_LAST_PK)
- .setColumnName(lastPK.getName().getString()).build().buildException();
- }
- // Disallow adding columns if last column is fixed width and nullable.
- if (lastPK.isNullable() && lastPK.getDataType().isFixedWidth()) {
- throw new SQLExceptionInfo.Builder(SQLExceptionCode.NULLABLE_FIXED_WIDTH_LAST_PK)
- .setColumnName(lastPK.getName().getString()).build().buildException();
+ if (numCols > 0) {
+ PColumn lastPK = currentPKs.get(currentPKs.size()-1);
+ // Disallow adding columns if the last column is VARBIANRY.
+ if (lastPK.getDataType() == PVarbinary.INSTANCE || lastPK.getDataType().isArrayType()) {
+ throw new SQLExceptionInfo.Builder(SQLExceptionCode.VARBINARY_LAST_PK)
+ .setColumnName(lastPK.getName().getString()).build().buildException();
+ }
+ // Disallow adding columns if last column is fixed width and nullable.
+ if (lastPK.isNullable() && lastPK.getDataType().isFixedWidth()) {
+ throw new SQLExceptionInfo.Builder(SQLExceptionCode.NULLABLE_FIXED_WIDTH_LAST_PK)
+ .setColumnName(lastPK.getName().getString()).build().buildException();
+ }
}