You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sa...@apache.org on 2015/10/17 01:17:39 UTC
phoenix git commit: PHOENIX-2326 Fix upgrade from 4.x to 4.6 and
update MetadataProtocol with new versions
Repository: phoenix
Updated Branches:
refs/heads/4.x-HBase-0.98 567218ad2 -> 61b30c924
PHOENIX-2326 Fix upgrade from 4.x to 4.6 and update MetadataProtocol with new versions
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/61b30c92
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/61b30c92
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/61b30c92
Branch: refs/heads/4.x-HBase-0.98
Commit: 61b30c924de60b0531ba310821591fbc2f1db474
Parents: 567218a
Author: Samarth <sa...@apache.org>
Authored: Fri Oct 16 16:17:02 2015 -0700
Committer: Samarth <sa...@apache.org>
Committed: Fri Oct 16 16:17:02 2015 -0700
----------------------------------------------------------------------
.../phoenix/coprocessor/MetaDataProtocol.java | 3 +-
.../query/ConnectionQueryServicesImpl.java | 13 +++++---
.../apache/phoenix/schema/MetaDataClient.java | 33 +++++++++++++++++---
3 files changed, 38 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/61b30c92/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
index 7d65eb2..7cc4123 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
@@ -62,7 +62,6 @@ public abstract class MetaDataProtocol extends MetaDataService {
public static final long MIN_TABLE_TIMESTAMP = 0;
- public static final long MIN_SYSTEM_TABLE_TIMESTAMP = MIN_TABLE_TIMESTAMP + 8;
public static final int DEFAULT_MAX_META_DATA_VERSIONS = 1000;
public static final int DEFAULT_MAX_STAT_DATA_VERSIONS = 3;
public static final boolean DEFAULT_META_DATA_KEEP_DELETED_CELLS = true;
@@ -74,7 +73,7 @@ public abstract class MetaDataProtocol extends MetaDataService {
public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_3_0 = MIN_TABLE_TIMESTAMP + 7;
public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_5_0 = MIN_TABLE_TIMESTAMP + 8;
public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0 = MIN_TABLE_TIMESTAMP + 9;
-
+ public static final long MIN_SYSTEM_TABLE_TIMESTAMP = MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0;
// TODO: pare this down to minimum, as we don't need duplicates for both table and column errors, nor should we need
// a different code for every type of error.
// ENTITY_ALREADY_EXISTS, ENTITY_NOT_FOUND, NEWER_ENTITY_FOUND, ENTITY_NOT_IN_REGION, CONCURRENT_MODIFICATION
http://git-wip-us.apache.org/repos/asf/phoenix/blob/61b30c92/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index bd21f20..c54d244 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -1936,9 +1936,6 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
long currentServerSideTableTimeStamp = e.getTable().getTimeStamp();
String columnsToAdd = "";
- if (currentServerSideTableTimeStamp < MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0) {
- columnsToAdd += PhoenixDatabaseMetaData.IS_ROW_TIMESTAMP + " " + PBoolean.INSTANCE.getSqlTypeName();
- }
if(currentServerSideTableTimeStamp < MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_3_0) {
// We know that we always need to add the STORE_NULLS column for 4.3 release
columnsToAdd = ", " + PhoenixDatabaseMetaData.STORE_NULLS + " " + PBoolean.INSTANCE.getSqlTypeName();
@@ -1980,7 +1977,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
// Ugh..need to assign to another local variable to keep eclipse happy.
PhoenixConnection newMetaConnection = addColumnsIfNotExists(metaConnection,
PhoenixDatabaseMetaData.SYSTEM_CATALOG,
- MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP, columnsToAdd);
+ MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_3_0, columnsToAdd);
metaConnection = newMetaConnection;
}
@@ -1989,7 +1986,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
+ PInteger.INSTANCE.getSqlTypeName();
try {
metaConnection = addColumn(metaConnection, PhoenixDatabaseMetaData.SYSTEM_CATALOG,
- MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP, columnsToAdd, false);
+ MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_5_0, columnsToAdd, false);
upgradeTo4_5_0(metaConnection);
} catch (ColumnAlreadyExistsException ignored) {
/*
@@ -2018,6 +2015,12 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
conn.close();
}
}
+ if (currentServerSideTableTimeStamp < MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0) {
+ columnsToAdd = PhoenixDatabaseMetaData.IS_ROW_TIMESTAMP + " " + PBoolean.INSTANCE.getSqlTypeName();
+ metaConnection = addColumn(metaConnection, PhoenixDatabaseMetaData.SYSTEM_CATALOG,
+ MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0, columnsToAdd, false);
+ }
+
}
int nSaltBuckets = ConnectionQueryServicesImpl.this.props.getInt(QueryServices.SEQUENCE_SALT_BUCKETS_ATTRIB,
QueryServicesOptions.DEFAULT_SEQUENCE_TABLE_SALT_BUCKETS);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/61b30c92/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 341b07d..77ca2c3 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
@@ -282,7 +282,9 @@ public class MetaDataClient {
INDEX_STATE + "," +
INDEX_DISABLE_TIMESTAMP +
") VALUES (?, ?, ?, ?, ?)";
- private static final String INSERT_COLUMN =
+ //TODO: merge INSERT_COLUMN_CREATE_TABLE and INSERT_COLUMN_ALTER_TABLE column when
+ // the new major release is out.
+ private static final String INSERT_COLUMN_CREATE_TABLE =
"UPSERT INTO " + SYSTEM_CATALOG_SCHEMA + ".\"" + SYSTEM_CATALOG_TABLE + "\"( " +
TENANT_ID + "," +
TABLE_SCHEM + "," +
@@ -304,6 +306,27 @@ public class MetaDataClient {
COLUMN_DEF + "," +
IS_ROW_TIMESTAMP +
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
+ private static final String INSERT_COLUMN_ALTER_TABLE =
+ "UPSERT INTO " + SYSTEM_CATALOG_SCHEMA + ".\"" + SYSTEM_CATALOG_TABLE + "\"( " +
+ TENANT_ID + "," +
+ TABLE_SCHEM + "," +
+ TABLE_NAME + "," +
+ COLUMN_NAME + "," +
+ COLUMN_FAMILY + "," +
+ DATA_TYPE + "," +
+ NULLABLE + "," +
+ COLUMN_SIZE + "," +
+ DECIMAL_DIGITS + "," +
+ ORDINAL_POSITION + "," +
+ SORT_ORDER + "," +
+ DATA_TABLE_NAME + "," + // write this both in the column and table rows for access by metadata APIs
+ ARRAY_SIZE + "," +
+ VIEW_CONSTANT + "," +
+ IS_VIEW_REFERENCED + "," +
+ PK_NAME + "," + // write this both in the column and table rows for access by metadata APIs
+ KEY_SEQ + "," +
+ COLUMN_DEF +
+ ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
private static final String UPDATE_COLUMN_POSITION =
"UPSERT INTO " + SYSTEM_CATALOG_SCHEMA + ".\"" + SYSTEM_CATALOG_TABLE + "\" ( " +
TENANT_ID + "," +
@@ -681,7 +704,9 @@ public class MetaDataClient {
} else {
colUpsert.setString(18, column.getExpressionStr());
}
- colUpsert.setBoolean(19, column.isRowTimestamp());
+ if (colUpsert.getParameterMetaData().getParameterCount() > 18) {
+ colUpsert.setBoolean(19, column.isRowTimestamp());
+ }
colUpsert.execute();
}
@@ -1713,7 +1738,7 @@ public class MetaDataClient {
}
}
- PreparedStatement colUpsert = connection.prepareStatement(INSERT_COLUMN);
+ PreparedStatement colUpsert = connection.prepareStatement(INSERT_COLUMN_CREATE_TABLE);
Map<String, PName> familyNames = Maps.newLinkedHashMap();
boolean isPK = false;
boolean rowTimeStampColumnAlreadyFound = false;
@@ -2485,7 +2510,7 @@ public class MetaDataClient {
}
int numPkColumnsAdded = 0;
- PreparedStatement colUpsert = connection.prepareStatement(INSERT_COLUMN);
+ PreparedStatement colUpsert = connection.prepareStatement(INSERT_COLUMN_ALTER_TABLE);
List<PColumn> columns = Lists.newArrayListWithExpectedSize(columnDefs.size());
Set<String> colFamiliesForPColumnsToBeAdded = new LinkedHashSet<>();