diff --git metastore/scripts/upgrade/mssql/020-HIVE-13395.mssql.sql metastore/scripts/upgrade/mssql/020-HIVE-13395.mssql.sql index 281014c0a9..a35fb75851 100644 --- metastore/scripts/upgrade/mssql/020-HIVE-13395.mssql.sql +++ metastore/scripts/upgrade/mssql/020-HIVE-13395.mssql.sql @@ -6,4 +6,4 @@ CREATE TABLE WRITE_SET ( WS_COMMIT_ID bigint NOT NULL, WS_OPERATION_TYPE char(1) NOT NULL ); -ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1) NULL; \ No newline at end of file +ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1) NOT NULL; \ No newline at end of file diff --git metastore/scripts/upgrade/mysql/035-HIVE-13395.mysql.sql metastore/scripts/upgrade/mysql/035-HIVE-13395.mysql.sql index 586caef53b..e4cf11fed9 100644 --- metastore/scripts/upgrade/mysql/035-HIVE-13395.mysql.sql +++ metastore/scripts/upgrade/mysql/035-HIVE-13395.mysql.sql @@ -7,4 +7,4 @@ CREATE TABLE WRITE_SET ( WS_OPERATION_TYPE char(1) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1); +ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1) NOT NULL; diff --git metastore/scripts/upgrade/mysql/050-HIVE-23211.mysql.sql metastore/scripts/upgrade/mysql/050-HIVE-23211.mysql.sql new file mode 100644 index 0000000000..a1a06e7551 --- /dev/null +++ metastore/scripts/upgrade/mysql/050-HIVE-23211.mysql.sql @@ -0,0 +1,3 @@ +-- Not updating possible NULL values, since if NULLs existing in this table, the upgrade should fail +ALTER TABLE TXN_COMPONENTS CHANGE TC_TXNID TC_TXNID bigint NOT NULL; +ALTER TABLE COMPLETED_TXN_COMPONENTS CHANGE CTC_TXNID CTC_TXNID bigint NOT NULL; \ No newline at end of file diff --git metastore/scripts/upgrade/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql metastore/scripts/upgrade/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql index 226f4b4449..1a5734216c 100644 --- metastore/scripts/upgrade/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql +++ metastore/scripts/upgrade/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql @@ -3,6 +3,7 @@ SELECT 'Upgrading MetaStore schema from 2.0.0 to 2.1.0' AS ' '; SOURCE 034-HIVE-13076.mysql.sql; SOURCE 035-HIVE-13395.mysql.sql; SOURCE 036-HIVE-13354.mysql.sql; +SOURCE 050-HIVE-23211.mysql.sql UPDATE VERSION SET SCHEMA_VERSION='2.1.0', VERSION_COMMENT='Hive release version 2.1.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 2.0.0 to 2.1.0' AS ' '; diff --git metastore/scripts/upgrade/oracle/035-HIVE-13395.oracle.sql metastore/scripts/upgrade/oracle/035-HIVE-13395.oracle.sql index ad1bbd9459..f1294eb3ab 100644 --- metastore/scripts/upgrade/oracle/035-HIVE-13395.oracle.sql +++ metastore/scripts/upgrade/oracle/035-HIVE-13395.oracle.sql @@ -7,4 +7,4 @@ CREATE TABLE WRITE_SET ( WS_OPERATION_TYPE char(1) NOT NULL ); -ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1); +ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1) NOT NULL; diff --git metastore/scripts/upgrade/oracle/039-HIVE-12274.oracle.sql metastore/scripts/upgrade/oracle/039-HIVE-12274.oracle.sql index af35684afc..34d35efd30 100644 --- metastore/scripts/upgrade/oracle/039-HIVE-12274.oracle.sql +++ metastore/scripts/upgrade/oracle/039-HIVE-12274.oracle.sql @@ -1,5 +1,5 @@ -- change PARAM_VALUE to CLOBs -ALTER TABLE COLUMNS_V2 ADD (TEMP CLOB); +ALTER TABLE COLUMNS_V2 ADD (TEMP CLOB NOT NULL); UPDATE COLUMNS_V2 SET TEMP=TYPE_NAME; ALTER TABLE COLUMNS_V2 DROP COLUMN TYPE_NAME; ALTER TABLE COLUMNS_V2 RENAME COLUMN TEMP TO TYPE_NAME; diff --git metastore/scripts/upgrade/postgres/034-HIVE-13395.postgres.sql metastore/scripts/upgrade/postgres/034-HIVE-13395.postgres.sql index 4dda2837b9..64009ec0b8 100644 --- metastore/scripts/upgrade/postgres/034-HIVE-13395.postgres.sql +++ metastore/scripts/upgrade/postgres/034-HIVE-13395.postgres.sql @@ -7,4 +7,4 @@ CREATE TABLE WRITE_SET ( WS_OPERATION_TYPE char(1) NOT NULL ); -ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1); \ No newline at end of file +ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1) NOT NULL; \ No newline at end of file diff --git standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.0.0-to-2.1.0.mssql.sql standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.0.0-to-2.1.0.mssql.sql index 623b352359..f45dc7949b 100644 --- standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.0.0-to-2.1.0.mssql.sql +++ standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.0.0-to-2.1.0.mssql.sql @@ -28,7 +28,7 @@ CREATE TABLE WRITE_SET ( WS_COMMIT_ID bigint NOT NULL, WS_OPERATION_TYPE char(1) NOT NULL ); -ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1) NULL; +ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1) NOT NULL; --:r 021-HIVE-13354.mssql.sql ALTER TABLE COMPACTION_QUEUE ADD CQ_TBLPROPERTIES nvarchar(2048) NULL; diff --git standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql index 2b58cf3fa4..53edaa2488 100644 --- standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql +++ standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql @@ -355,6 +355,11 @@ INSERT INTO TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID, T2W_WRITEID) UPDATE TXN_COMPONENTS SET TC_WRITEID = TC_TXNID; UPDATE COMPLETED_TXN_COMPONENTS SET CTC_WRITEID = CTC_TXNID; +-- HIVE-23211: Fix metastore schema differences between init scripts, and upgrade scripts +-- Not updating possible NULL values, since if NULLs existing in this table, the upgrade should fail +ALTER TABLE TXN_COMPONENTS ALTER COLUMN TC_TXNID bigint NOT NULL; +ALTER TABLE COMPLETED_TXN_COMPONENTS ALTER COLUMN CTC_TXNID bigint NOT NULL; + -- These lines need to be last. Insert any changes above. UPDATE VERSION SET SCHEMA_VERSION='3.0.0', VERSION_COMMENT='Hive release version 3.0.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 2.3.0 to 3.0.0' AS MESSAGE; diff --git standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql index c02ee21b50..b204d91d04 100644 --- standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql +++ standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql @@ -31,12 +31,16 @@ CREATE TABLE WRITE_SET ( WS_OPERATION_TYPE char(1) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1); +ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1) NOT NULL; -- SOURCE 036-HIVE-13354.mysql.sql; ALTER TABLE COMPACTION_QUEUE ADD CQ_TBLPROPERTIES varchar(2048); ALTER TABLE COMPLETED_COMPACTIONS ADD CC_TBLPROPERTIES varchar(2048); +-- SOURCE 050-HIVE-23211.mysql.sql; +ALTER TABLE TXN_COMPONENTS CHANGE TC_TXNID TC_TXNID bigint NOT NULL; +ALTER TABLE COMPLETED_TXN_COMPONENTS CHANGE CTC_TXNID CTC_TXNID bigint NOT NULL; + UPDATE VERSION SET SCHEMA_VERSION='2.1.0', VERSION_COMMENT='Hive release version 2.1.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 2.0.0 to 2.1.0' AS MESSAGE; diff --git standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.0.0-to-3.1.0.mysql.sql standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.0.0-to-3.1.0.mysql.sql index 3eae9f2850..ba89037c5e 100644 --- standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.0.0-to-3.1.0.mysql.sql +++ standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-3.0.0-to-3.1.0.mysql.sql @@ -48,7 +48,7 @@ CREATE TABLE MATERIALIZATION_REBUILD_LOCKS ( MRL_TBL_NAME VARCHAR(256) NOT NULL, MRL_LAST_HEARTBEAT BIGINT NOT NULL, PRIMARY KEY(MRL_TXN_ID) -); +) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- These lines need to be last. Insert any changes above. diff --git standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.2.0.oracle.sql standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.2.0.oracle.sql index c62ad6a662..42dc48f727 100644 --- standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.2.0.oracle.sql +++ standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.2.0.oracle.sql @@ -100,7 +100,7 @@ CREATE TABLE DBS "NAME" VARCHAR2(128) NULL, OWNER_NAME VARCHAR2(128) NULL, OWNER_TYPE VARCHAR2(10) NULL, - CTLG_NAME VARCHAR2(256) DEFAULT 'hive', + CTLG_NAME VARCHAR2(256) DEFAULT 'hive' NOT NULL, CREATE_TIME NUMBER (10) ); diff --git standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql index db398e5f66..01e996138b 100644 --- standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql +++ standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql @@ -100,8 +100,8 @@ CREATE TABLE DBS "NAME" VARCHAR2(128) NULL, OWNER_NAME VARCHAR2(128) NULL, OWNER_TYPE VARCHAR2(10) NULL, - CTLG_NAME VARCHAR2(256) DEFAULT 'hive', - CREATE_TIME NUMBER (10), + CTLG_NAME VARCHAR2(256) DEFAULT 'hive' NOT NULL, + CREATE_TIME NUMBER (10) DB_MANAGED_LOCATION_URI VARCHAR2(4000) NULL ); diff --git standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.0.0-to-2.1.0.oracle.sql standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.0.0-to-2.1.0.oracle.sql index f3a61f2518..3fa13c2bcd 100644 --- standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.0.0-to-2.1.0.oracle.sql +++ standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.0.0-to-2.1.0.oracle.sql @@ -29,7 +29,7 @@ CREATE TABLE WRITE_SET ( WS_OPERATION_TYPE char(1) NOT NULL ); -ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1); +ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1) NOT NULL; --@036-HIVE-13354.oracle.sql; ALTER TABLE COMPACTION_QUEUE ADD CQ_TBLPROPERTIES varchar(2048); diff --git standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql index 3e261af90f..a6dd445b11 100644 --- standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql +++ standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql @@ -341,6 +341,11 @@ UPDATE COMPLETED_TXN_COMPONENTS SET CTC_WRITEID = CTC_TXNID; ALTER TABLE TBLS ADD OWNER_TYPE VARCHAR2(10) NULL; +-- HIVE-23211: Fix metastore schema differences between init scripts, and upgrade scripts +-- Not updating possible NULL values, since if NULLs existing in this table, the upgrade should fail +ALTER TABLE TXN_COMPONENTS MODIFY (TC_TXNID NOT NULL); +ALTER TABLE COMPLETED_TXN_COMPONENTS MODIFY (CTC_TXNID NOT NULL); + -- These lines need to be last. Insert any changes above. UPDATE VERSION SET SCHEMA_VERSION='3.0.0', VERSION_COMMENT='Hive release version 3.0.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 2.3.0 to 3.0.0' AS Status from dual; diff --git standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.2.0.postgres.sql standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.2.0.postgres.sql index 337b0266f1..881065fad4 100644 --- standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.2.0.postgres.sql +++ standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.2.0.postgres.sql @@ -81,7 +81,7 @@ CREATE TABLE "DBS" ( "NAME" character varying(128) DEFAULT NULL::character varying, "OWNER_NAME" character varying(128) DEFAULT NULL::character varying, "OWNER_TYPE" character varying(10) DEFAULT NULL::character varying, - "CTLG_NAME" varchar(256) DEFAULT 'hive', + "CTLG_NAME" varchar(256) DEFAULT 'hive' NOT NULL, "CREATE_TIME" bigint ); diff --git standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql index e6e30160af..676f8751cb 100644 --- standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql +++ standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql @@ -81,7 +81,7 @@ CREATE TABLE "DBS" ( "NAME" character varying(128) DEFAULT NULL::character varying, "OWNER_NAME" character varying(128) DEFAULT NULL::character varying, "OWNER_TYPE" character varying(10) DEFAULT NULL::character varying, - "CTLG_NAME" varchar(256) DEFAULT 'hive', + "CTLG_NAME" varchar(256) DEFAULT 'hive' NOT NULL, "CREATE_TIME" bigint, "DB_MANAGED_LOCATION_URI" character varying(4000) ); diff --git standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.0.0-to-2.1.0.postgres.sql standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.0.0-to-2.1.0.postgres.sql index 4c23e8abc1..8aa1eff72a 100644 --- standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.0.0-to-2.1.0.postgres.sql +++ standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.0.0-to-2.1.0.postgres.sql @@ -29,7 +29,7 @@ CREATE TABLE WRITE_SET ( WS_OPERATION_TYPE char(1) NOT NULL ); -ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1); +ALTER TABLE TXN_COMPONENTS ADD TC_OPERATION_TYPE char(1) NOT NULL; --\i 035-HIVE-13354.postgres.sql; ALTER TABLE COMPACTION_QUEUE ADD CQ_TBLPROPERTIES varchar(2048); diff --git standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql index 06e758ccdb..a531fc5efd 100644 --- standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql +++ standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql @@ -357,6 +357,11 @@ INSERT INTO TXN_TO_WRITE_ID (T2W_DATABASE, T2W_TABLE, T2W_TXNID, T2W_WRITEID) UPDATE TXN_COMPONENTS SET TC_WRITEID = TC_TXNID; UPDATE COMPLETED_TXN_COMPONENTS SET CTC_WRITEID = CTC_TXNID; +-- HIVE-23211: Fix metastore schema differences between init scripts, and upgrade scripts +-- Not updating possible NULL values, since if NULLs existing in this table, the upgrade should fail +ALTER TABLE TXN_COMPONENTS ALTER COLUMN TC_TXNID SET NOT NULL; +ALTER TABLE COMPLETED_TXN_COMPONENTS ALTER COLUMN CTC_TXNID SET NOT NULL; + -- These lines need to be last. Insert any changes above. UPDATE "VERSION" SET "SCHEMA_VERSION"='3.0.0', "VERSION_COMMENT"='Hive release version 3.0.0' where "VER_ID"=1; SELECT 'Finished upgrading MetaStore schema from 2.3.0 to 3.0.0';