[3/4] phoenix git commit: PHOENIX-4711 Unable to set property on table with VARBINARY as last column

2018-04-27 Thread jamestaylor
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/2649410f
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2649410f
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2649410f

Branch: refs/heads/5.x-HBase-2.0
Commit: 2649410f51e4076dcf0d95b546c2ccc260dccbb1
Parents: 987ac8c
Author: James Taylor 
Authored: Thu Apr 26 17:13:48 2018 -0700
Committer: James Taylor 
Committed: Fri Apr 27 11:46:14 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/2649410f/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 4e731c1..db46663 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
@@ -117,12 +117,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/2649410f/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 bdb9236..60a7ca9 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
@@ -3261,16 +3261,18 @@ public class MetaDataClient {
 int position = table.getColumns().size();
 
 List 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)
+  

[3/4] phoenix git commit: PHOENIX-4711 Unable to set property on table with VARBINARY as last column

2018-04-27 Thread jamestaylor
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/ae8a6e8e
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/ae8a6e8e
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/ae8a6e8e

Branch: refs/heads/4.x-cdh5.11
Commit: ae8a6e8e672969579908bf9ded15cbace6059048
Parents: 82ad137
Author: James Taylor 
Authored: Thu Apr 26 17:13:48 2018 -0700
Committer: James Taylor 
Committed: Fri Apr 27 11:45:39 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/ae8a6e8e/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/ae8a6e8e/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 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)
+

[3/4] phoenix git commit: PHOENIX-4711 Unable to set property on table with VARBINARY as last column

2018-04-27 Thread jamestaylor
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/f7a15761
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f7a15761
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f7a15761

Branch: refs/heads/4.x-HBase-1.1
Commit: f7a15761249f0e46f03fc6019a4bfd78727bdb41
Parents: 0b34ab3
Author: James Taylor 
Authored: Thu Apr 26 17:13:48 2018 -0700
Committer: James Taylor 
Committed: Fri Apr 27 11:42:55 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/f7a15761/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/f7a15761/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 782f556..dcbe7e6 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
@@ -3251,16 +3251,18 @@ public class MetaDataClient {
 int position = table.getColumns().size();
 
 List 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)
+  

[3/4] phoenix git commit: PHOENIX-4711 Unable to set property on table with VARBINARY as last column

2018-04-27 Thread jamestaylor
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/c77a1508
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c77a1508
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c77a1508

Branch: refs/heads/4.x-HBase-1.2
Commit: c77a1508d0ee6eff9fb15b5c065c470e74597d8b
Parents: 616abb5
Author: James Taylor 
Authored: Thu Apr 26 17:13:48 2018 -0700
Committer: James Taylor 
Committed: Fri Apr 27 11:42:27 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/c77a1508/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/c77a1508/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 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)
+  

[3/4] phoenix git commit: PHOENIX-4711 Unable to set property on table with VARBINARY as last column

2018-04-27 Thread jamestaylor
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/a18fd1e1
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a18fd1e1
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a18fd1e1

Branch: refs/heads/master
Commit: a18fd1e133f5a2785e0ade236d72028b3d6854da
Parents: 49c0232
Author: James Taylor 
Authored: Thu Apr 26 17:13:48 2018 -0700
Committer: James Taylor 
Committed: Fri Apr 27 11:41:56 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/a18fd1e1/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/a18fd1e1/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 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)
+ 

[3/4] phoenix git commit: PHOENIX-4711 Unable to set property on table with VARBINARY as last column

2018-04-27 Thread jamestaylor
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 
Authored: Thu Apr 26 17:13:48 2018 -0700
Committer: James Taylor 
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 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)
+