This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch 4.16
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.16 by this push:
new 2ad8dbb PHOENIX-6534 Upgrades from pre 4.10 versions are broken
2ad8dbb is described below
commit 2ad8dbb44fc15ca4cfeb10f85f504844073ed862
Author: Istvan Toth <[email protected]>
AuthorDate: Tue Sep 7 18:24:21 2021 +0200
PHOENIX-6534 Upgrades from pre 4.10 versions are broken
---
.../java/org/apache/phoenix/schema/MetaDataClient.java | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
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 f78deb3..e785d58 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
@@ -957,12 +957,15 @@ public class MetaDataClient {
} else {
colUpsert.setString(18, column.getExpressionStr());
}
- if (column.getColumnQualifierBytes() == null) {
- colUpsert.setNull(19, Types.VARBINARY);
- } else {
- colUpsert.setBytes(19, column.getColumnQualifierBytes());
+ //Do not try to set extra columns when using
ALTER_SYSCATALOG_TABLE_UPGRADE
+ if (colUpsert.getParameterMetaData().getParameterCount() > 18) {
+ if (column.getColumnQualifierBytes() == null) {
+ colUpsert.setNull(19, Types.VARBINARY);
+ } else {
+ colUpsert.setBytes(19, column.getColumnQualifierBytes());
+ }
+ colUpsert.setBoolean(20, column.isRowTimestamp());
}
- colUpsert.setBoolean(20, column.isRowTimestamp());
colUpsert.execute();
}
@@ -3902,7 +3905,10 @@ public class MetaDataClient {
Map<String, Integer> changedCqCounters = new
HashMap<>(numCols);
if (numCols > 0 ) {
StatementContext context = new StatementContext(new
PhoenixStatement(connection), resolver);
- String addColumnSqlToUse = INSERT_COLUMN_CREATE_TABLE;
+ String addColumnSqlToUse = connection.isRunningUpgrade()
+ &&
tableName.equals(PhoenixDatabaseMetaData.SYSTEM_CATALOG_TABLE)
+ &&
schemaName.equals(PhoenixDatabaseMetaData.SYSTEM_CATALOG_SCHEMA) ?
ALTER_SYSCATALOG_TABLE_UPGRADE
+ : INSERT_COLUMN_CREATE_TABLE;
try (PreparedStatement colUpsert =
connection.prepareStatement(addColumnSqlToUse)) {
short nextKeySeq = SchemaUtil.getMaxKeySeq(table);
for ( ColumnDef colDef : columnDefs) {