Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Consider a scenario where beeline is used to connect to a mysql server. The commands executed via beeline can include stored procedures. For e.g. the following command used to create a stored procedure is a valid command :
CREATE PROCEDURE RM_TLBS_LINKID() BEGIN IF EXISTS (SELECT * FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_NAME` = 'TBLS' AND `COLUMN_NAME` = 'LINK_TARGET_ID') THEN ALTER TABLE `TBLS` DROP FOREIGN KEY `TBLS_FK3` ; ALTER TABLE `TBLS` DROP KEY `TBLS_N51` ; ALTER TABLE `TBLS` DROP COLUMN `LINK_TARGET_ID` ; END IF; END
MySQL stored procedures have semi-colon ( ; ) as the statement terminator. Since this coincides with beeline's only available command terminator, semi-colon, beeline will not able to execute the above command successfully . i.e, beeline tries to execute the below partial command instead of the complete command shown above.
CREATE PROCEDURE RM_TLBS_LINKID() BEGIN IF EXISTS (SELECT * FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_NAME` = 'TBLS' AND `COLUMN_NAME` = 'LINK_TARGET_ID') THEN ALTER TABLE `TBLS` DROP FOREIGN KEY `TBLS_FK3` ;
The above situation can actually happen within Hive when Hive SchemaTool is used to upgrade a mysql metastore db and the scripts used for the upgrade process contain stored procedures(as the one introduced initially by HIVE-7018). As of now, we cannot have any stored procedure as part of MySQL metastore db upgrade scripts because schemaTool uses beeline to connect to MySQL. As of now, beeline fails to execute any "create procedure" command or similar command containing ; . This is a serious limitation; it needs to be fixed by allowing the end user to provide an option to beeline to not use semi-colon as the command delimiter and instead use new line character as the command delimiter.
Attachments
Attachments
Issue Links
- blocks
-
HIVE-7018 Table and Partition tables have column LINK_TARGET_ID in Mysql scripts but not others
- Closed
- is broken by
-
HIVE-9877 Beeline cannot run multiple statements in the same row
- Closed
- is related to
-
HIVE-10614 schemaTool upgrade from 0.14.0 to 1.3.0 causes failure
- Closed
-
HIVE-10865 Beeline needs to support DELIMITER command
- Closed
- links to