diff --git a/beeline/src/java/org/apache/hive/beeline/BeeLine.java b/beeline/src/java/org/apache/hive/beeline/BeeLine.java index 4eda8e3..29ec2de 100644 --- a/beeline/src/java/org/apache/hive/beeline/BeeLine.java +++ b/beeline/src/java/org/apache/hive/beeline/BeeLine.java @@ -1026,12 +1026,15 @@ public void updateOptsForCli() { getOpts().setNullEmptyString(true); } + public int begin(String[] args, InputStream inputStream) throws IOException { + return begin(args, inputStream, true); + } /** * Start accepting input from stdin, and dispatch it * to the appropriate {@link CommandHandler} until the * global variable exit is true. */ - public int begin(String[] args, InputStream inputStream) throws IOException { + public int begin(String[] args, InputStream inputStream, boolean keepHistory) throws IOException { try { // load the options first, so we can override on the command line getOpts().load(); @@ -1039,7 +1042,9 @@ public int begin(String[] args, InputStream inputStream) throws IOException { // nothing } - setupHistory(); + if (keepHistory) { + setupHistory(); + } //add shutdown hook to cleanup the beeline for smooth exit addBeelineShutdownHook(); @@ -1341,7 +1346,11 @@ public ConsoleReader initializeConsoleReader(InputStream inputStream) throws IOE try { // now set the output for the history - consoleReader.setHistory(this.history); + if (this.history != null) { + consoleReader.setHistory(this.history); + } else { + consoleReader.setHistoryEnabled(false); + } } catch (Exception e) { handleException(e); } diff --git a/beeline/src/java/org/apache/hive/beeline/schematool/HiveSchemaTool.java b/beeline/src/java/org/apache/hive/beeline/schematool/HiveSchemaTool.java index 69514e5..c723476 100644 --- a/beeline/src/java/org/apache/hive/beeline/schematool/HiveSchemaTool.java +++ b/beeline/src/java/org/apache/hive/beeline/schematool/HiveSchemaTool.java @@ -100,7 +100,7 @@ protected void execSql(String sqlScriptFile) throws IOException { // we always add a line separator at the end while calling dbCommandParser.buildCommand. beeLine.getOpts().setEntireLineAsCommand(true); LOG.debug("Going to run command <" + builder.buildToLog() + ">"); - int status = beeLine.begin(builder.buildToRun(), null); + int status = beeLine.begin(builder.buildToRun(), null, false); if (status != 0) { throw new IOException("Schema script failed, errorcode " + status); }