git commit: Phoenix-1275 SYSTEM.STATS table is not created when SYSTEM.CATALOG is already present
Repository: phoenix Updated Branches: refs/heads/3.0 7ebb87e7d -> 87fe59e5b Phoenix-1275 SYSTEM.STATS table is not created when SYSTEM.CATALOG is already present Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/87fe59e5 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/87fe59e5 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/87fe59e5 Branch: refs/heads/3.0 Commit: 87fe59e5bca692397771e4fdfe298e90eff49384 Parents: 7ebb87e Author: Ramkrishna Authored: Thu Sep 25 16:21:00 2014 +0530 Committer: Ramkrishna Committed: Thu Sep 25 16:21:00 2014 +0530 -- .../phoenix/query/ConnectionQueryServicesImpl.java | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/87fe59e5/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 0676e86..926407a 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 @@ -1295,9 +1295,6 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement ConnectionQueryServicesImpl.this, url, scnProps, newEmptyMetaData()); try { metaConnection.createStatement().executeUpdate(QueryConstants.CREATE_TABLE_METADATA); -// TODO : Get this from a configuration -metaConnection.createStatement().executeUpdate( - QueryConstants.CREATE_STATS_TABLE_METADATA); } catch (NewerTableAlreadyExistsException ignore) { // Ignore, as this will happen if the SYSTEM.CATALOG already exists at this fixed timestamp. // A TableAlreadyExistsException is not thrown, since the table only exists *after* this fixed timestamp. @@ -1326,6 +1323,14 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement metaConnection = addColumnsIfNotExists(metaConnection, PhoenixDatabaseMetaData.SEQUENCE_TABLE_NAME, MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP, newColumns); } +try { +metaConnection.createStatement().executeUpdate( + QueryConstants.CREATE_STATS_TABLE_METADATA); +} catch (NewerTableAlreadyExistsException ignore) { + +} catch (TableAlreadyExistsException ignore) { + +} } catch (Exception e) { if (e instanceof SQLException) { initializationException = (SQLException)e;
git commit: Phoenix-1275 SYSTEM.STATS table is not created when SYSTEM.CATALOG is already present
Repository: phoenix Updated Branches: refs/heads/4.0 1110aeddf -> b2bf3f523 Phoenix-1275 SYSTEM.STATS table is not created when SYSTEM.CATALOG is already present Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/b2bf3f52 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/b2bf3f52 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/b2bf3f52 Branch: refs/heads/4.0 Commit: b2bf3f5230666f311d23910dcb9abf17f615e868 Parents: 1110aed Author: Ramkrishna Authored: Thu Sep 25 16:04:32 2014 +0530 Committer: Ramkrishna Committed: Thu Sep 25 16:04:32 2014 +0530 -- .../query/ConnectionQueryServicesImpl.java | 26 ++-- 1 file changed, 19 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/b2bf3f52/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 987d200..a0fb614 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 @@ -17,10 +17,6 @@ */ package org.apache.phoenix.query; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CYCLE_FLAG; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LIMIT_REACHED_FLAG; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MAX_VALUE; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MIN_VALUE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES; import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA; @@ -1518,12 +1514,28 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement } try { metaConnection.createStatement().executeUpdate(QueryConstants.CREATE_SEQUENCE_METADATA); - -// TODO : Get this from a configuration +} catch (NewerTableAlreadyExistsException ignore) { +// Ignore, as this will happen if the SYSTEM.SEQUENCE already exists at this fixed timestamp. +// A TableAlreadyExistsException is not thrown, since the table only exists *after* this fixed timestamp. + +} catch (TableAlreadyExistsException ignore) { +// This will occur if we have an older SYSTEM.SEQUENCE, so we need to update it to include +// any new columns we've added. +String newColumns = PhoenixDatabaseMetaData.MIN_VALUE + " " + PDataType.LONG.getSqlTypeName() + ", " ++ PhoenixDatabaseMetaData.MAX_VALUE + " " + PDataType.LONG.getSqlTypeName() + ", " + PhoenixDatabaseMetaData.CYCLE_FLAG + " " ++ PDataType.BOOLEAN.getSqlTypeName() + ", " + PhoenixDatabaseMetaData.LIMIT_REACHED_FLAG + " " ++ PDataType.BOOLEAN.getSqlTypeName(); +metaConnection = addColumnsIfNotExists(metaConnection, + PhoenixDatabaseMetaData.SEQUENCE_TABLE_NAME, + MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP, newColumns); +} +try { metaConnection.createStatement().executeUpdate( QueryConstants.CREATE_STATS_TABLE_METADATA); } catch (NewerTableAlreadyExistsException ignore) { -} catch (TableAlreadyExistsException ignore) { + +} catch(TableAlreadyExistsException ignore) { + } } catch (Exception e) { if (e instanceof SQLException) {
git commit: Phoenix-1275 SYSTEM.STATS table is not created when SYSTEM.CATALOG is already present
Repository: phoenix Updated Branches: refs/heads/master 6908c90b5 -> 940b70d65 Phoenix-1275 SYSTEM.STATS table is not created when SYSTEM.CATALOG is already present Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/940b70d6 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/940b70d6 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/940b70d6 Branch: refs/heads/master Commit: 940b70d65495e93c67323ef93eca8191fecdfe98 Parents: 6908c90 Author: Ramkrishna Authored: Thu Sep 25 16:03:05 2014 +0530 Committer: Ramkrishna Committed: Thu Sep 25 16:03:05 2014 +0530 -- .../query/ConnectionQueryServicesImpl.java | 26 ++-- 1 file changed, 19 insertions(+), 7 deletions(-) -- http://git-wip-us.apache.org/repos/asf/phoenix/blob/940b70d6/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 2512178..dfd56bc 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 @@ -17,10 +17,6 @@ */ package org.apache.phoenix.query; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.CYCLE_FLAG; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LIMIT_REACHED_FLAG; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MAX_VALUE; -import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MIN_VALUE; import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.SYSTEM_CATALOG_NAME_BYTES; import static org.apache.phoenix.query.QueryServicesOptions.DEFAULT_DROP_METADATA; @@ -1518,12 +1514,28 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement } try { metaConnection.createStatement().executeUpdate(QueryConstants.CREATE_SEQUENCE_METADATA); - -// TODO : Get this from a configuration +} catch (NewerTableAlreadyExistsException ignore) { +// Ignore, as this will happen if the SYSTEM.SEQUENCE already exists at this fixed timestamp. +// A TableAlreadyExistsException is not thrown, since the table only exists *after* this fixed timestamp. + +} catch (TableAlreadyExistsException ignore) { +// This will occur if we have an older SYSTEM.SEQUENCE, so we need to update it to include +// any new columns we've added. +String newColumns = PhoenixDatabaseMetaData.MIN_VALUE + " " + PDataType.LONG.getSqlTypeName() + ", " ++ PhoenixDatabaseMetaData.MAX_VALUE + " " + PDataType.LONG.getSqlTypeName() + ", " + PhoenixDatabaseMetaData.CYCLE_FLAG + " " ++ PDataType.BOOLEAN.getSqlTypeName() + ", " + PhoenixDatabaseMetaData.LIMIT_REACHED_FLAG + " " ++ PDataType.BOOLEAN.getSqlTypeName(); +metaConnection = addColumnsIfNotExists(metaConnection, + PhoenixDatabaseMetaData.SEQUENCE_TABLE_NAME, + MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP, newColumns); +} +try { metaConnection.createStatement().executeUpdate( QueryConstants.CREATE_STATS_TABLE_METADATA); } catch (NewerTableAlreadyExistsException ignore) { -} catch (TableAlreadyExistsException ignore) { + +} catch(TableAlreadyExistsException ignore) { + } } catch (Exception e) { if (e instanceof SQLException) {