From e3219b9b67d4745ae480c7f2c686fa32c713ea6f Mon Sep 17 00:00:00 2001 From: jongmin-won <55681111+jongmin-won@users.noreply.github.com> Date: Wed, 7 Aug 2024 10:37:32 +0900 Subject: [PATCH] [CBRD-25352] When adding a user schema to a stored procedure, the way a built-in PL/SQL is called is changed, and the test tools need to be temporarily modified. (#681) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://jira.cubrid.org/browse/CBRD-25352 When calling Built-in PL/CSQL in phase-1, “dbms_output.” must be added for normal execution. When that PR is merged, it will affect the develop branch where the existing phase-0 was merged. Therefore, we modified it to perform the built-in PL/CSQL once more by temporarily removing the 'DBMS_OUTPUT." inside the catch statement until Phase-1 is merged. We plan to remove it again when the phase-1 feature branch is merged in the future. --- .../cubridqa/cqt/console/bo/ConsoleBO.java | 147 ++++++++++++++---- .../cubridqa/cqt/console/dao/ConsoleDAO.java | 21 ++- CTP/sql_by_cci/execute.c | 46 ++++-- 3 files changed, 169 insertions(+), 45 deletions(-) diff --git a/CTP/sql/src/com/navercorp/cubridqa/cqt/console/bo/ConsoleBO.java b/CTP/sql/src/com/navercorp/cubridqa/cqt/console/bo/ConsoleBO.java index 08a50676..1a28c9ab 100644 --- a/CTP/sql/src/com/navercorp/cubridqa/cqt/console/bo/ConsoleBO.java +++ b/CTP/sql/src/com/navercorp/cubridqa/cqt/console/bo/ConsoleBO.java @@ -1127,42 +1127,127 @@ private String executeSqlFile(Test test, CaseResult caseResult) { this.onMessage(message); } } else if (isServerMessageOn) { + /*temporary*/ + boolean phase_1_flag = false; + + Statement temp_stmt; + conn.setAutoCommit(true); + temp_stmt = conn.createStatement(); try { - String message = - "@" - + test.getConnId() - + ": server message " - + isServerMessageOn; - this.onMessage(message); - test.setServerMessage("on"); - // TODO: DBMS_OUTPUT.enable () - Sql enableSql = - new Sql(connId, "CALL enable(50000)", null, true); // TODO: set - // size of - // enable - dao.execute(conn, enableSql, false); - } catch (Exception e) { - String message = - "Exception: the current version can't support DBMS_OUTPUT!"; - this.onMessage(message); + temp_stmt.executeQuery("call DBMS_OUTPUT.put_line('Temporary !!');"); + + phase_1_flag = true; + } catch (SQLException s) { + phase_1_flag = false; + } + temp_stmt.close(); + + if (phase_1_flag) { + /* if phase-1 */ + try { + String message = + "@" + + test.getConnId() + + ": server message " + + isServerMessageOn; + this.onMessage(message); + test.setServerMessage("on"); + // TODO: DBMS_OUTPUT.enable () + Sql enableSql = + new Sql( + connId, + "CALL DBMS_OUTPUT.enable(50000)", + null, + true); // TODO: set + // size of + // enable + dao.execute(conn, enableSql, false); + } catch (Exception e) { + String message = + "Exception: the current version can't support DBMS_OUTPUT!"; + this.onMessage(message); + } + } else { + /* if phase-0 */ + try { + String message = + "@" + + test.getConnId() + + ": server message " + + isServerMessageOn; + this.onMessage(message); + test.setServerMessage("on"); + // TODO: DBMS_OUTPUT.enable () + Sql enableSql = + new Sql( + connId, + "CALL enable(50000)", + null, + true); // TODO: set + // size of + // enable + dao.execute(conn, enableSql, false); + } catch (Exception e) { + String message = + "Exception: the current version can't support DBMS_OUTPUT!"; + this.onMessage(message); + } } } else if (isServerMessageOff) { + /*temporary*/ + boolean phase_1_flag = false; + + Statement temp_stmt; + conn.setAutoCommit(true); + temp_stmt = conn.createStatement(); try { - String message = - "@" - + test.getConnId() - + ": server message " - + isServerMessageOff; - this.onMessage(message); + temp_stmt.executeQuery("call DBMS_OUTPUT.put_line('Temporary !!');"); - test.setServerMessage("off"); - // TODO: DBMS_OUTPUT.disable() - Sql disableSql = new Sql(connId, "CALL disable()", null, true); - dao.execute(conn, disableSql, false); - } catch (Exception e) { - String message = - "Exception: the current version can't support DBMS_OUTPUT!"; - this.onMessage(message); + phase_1_flag = true; + } catch (SQLException s) { + phase_1_flag = false; + } + temp_stmt.close(); + + if (phase_1_flag) { + /* if phase-1 */ + try { + String message = + "@" + + test.getConnId() + + ": server message " + + isServerMessageOff; + this.onMessage(message); + + test.setServerMessage("off"); + // TODO: DBMS_OUTPUT.disable() + Sql disableSql = + new Sql(connId, "CALL DBMS_OUTPUT.disable()", null, true); + dao.execute(conn, disableSql, false); + } catch (Exception e) { + String message = + "Exception: the current version can't support DBMS_OUTPUT!"; + this.onMessage(message); + } + } else { + /* if phase-0 */ + try { + String message = + "@" + + test.getConnId() + + ": server message " + + isServerMessageOff; + this.onMessage(message); + + test.setServerMessage("off"); + // TODO: DBMS_OUTPUT.disable() + Sql disableSql = new Sql(connId, "CALL disable()", null, true); + dao.execute(conn, disableSql, false); + } catch (Exception e) { + String message = + "Exception: the current version can't support DBMS_OUTPUT!"; + this.onMessage(message); + } } } else { String message = diff --git a/CTP/sql/src/com/navercorp/cubridqa/cqt/console/dao/ConsoleDAO.java b/CTP/sql/src/com/navercorp/cubridqa/cqt/console/dao/ConsoleDAO.java index a45cb8e0..a0e30e3d 100644 --- a/CTP/sql/src/com/navercorp/cubridqa/cqt/console/dao/ConsoleDAO.java +++ b/CTP/sql/src/com/navercorp/cubridqa/cqt/console/dao/ConsoleDAO.java @@ -716,7 +716,7 @@ private String getServerOutputMessage(Connection conn) { ArrayList params = new ArrayList(); params.add(new SqlParam("OUT", 1, null, Types.VARCHAR)); params.add(new SqlParam("OUT", 2, null, Types.INTEGER)); - Sql getLine = new Sql(test.getConnId(), "CALL GET_LINE (?, ?);", params, true); + Sql getLine = new Sql(test.getConnId(), "CALL DBMS_OUTPUT.get_line (?, ?);", params, true); try { while (true) { @@ -732,7 +732,24 @@ private String getServerOutputMessage(Connection conn) { } } } catch (Exception e) { - // error? + getLine = new Sql(test.getConnId(), "CALL get_line (?, ?);", params, true); + + try { + while (true) { + executeCall(conn, getLine); + List paramList = getLine.getParamList(); + if (((Integer) paramList.get(1).getValue()) == 0) { + /* status */ + message.append( + ((String) paramList.get(0).getValue()) + + System.getProperty("line.separator")); /* message */ + } else { + break; + } + } + } catch (Exception e2) { + // error? + } } return message.toString(); diff --git a/CTP/sql_by_cci/execute.c b/CTP/sql_by_cci/execute.c index b8c1d91a..0c8f38a6 100644 --- a/CTP/sql_by_cci/execute.c +++ b/CTP/sql_by_cci/execute.c @@ -1446,23 +1446,37 @@ set_server_message (FILE * fp, char conn, bool on) char sql[20]; int req, res = 0; T_CCI_ERROR error; - + + /* if phase-1 */ if (on) { - sprintf (sql, "call enable(%d)", DBMS_OUTPUT_BUFFER_SIZE); + sprintf (sql, "call DBMS_OUTPUT.enable(%d)", DBMS_OUTPUT_BUFFER_SIZE); } else { - sprintf (sql, "call disable()"); + sprintf (sql, "call DBMS_OUTPUT.disable()"); } req = cci_prepare (conn, sql, CCI_PREPARE_CALL, &error); if (req < 0) { - fprintf (stdout, "Set Server-Message Error:%d\n", error.err_code); - fprintf (fp, "Set Server-Message Error:%d\n", error.err_code); - res = -1; - goto _END; + /* if phase-0 */ + if (on) + { + sprintf (sql, "call enable(%d)", DBMS_OUTPUT_BUFFER_SIZE); + } + else + { + sprintf (sql, "call disable()"); + } + req = cci_prepare (conn, sql, CCI_PREPARE_CALL, &error); + if (req < 0) + { + fprintf (stdout, "Set Server-Message Error:%d\n", error.err_code); + fprintf (fp, "Set Server-Message Error:%d\n", error.err_code); + res = -1; + goto _END; + } } res = cci_execute (req, 0, 0, &error); @@ -1488,17 +1502,25 @@ get_server_output (FILE * fp, char conn) { int req = 0, res = 0; T_CCI_ERROR error; - static const char *sql = "call get_line(?, ?)"; + static const char *sql = "call DBMS_OUTPUT.get_line(?, ?)"; static char buff[DBMS_OUTPUT_BUFFER_SIZE]; char *ret = NULL, *p, *str; int status, ind; - + + /* if phase-1 */ req = cci_prepare (conn, sql, CCI_PREPARE_CALL, &error); if (req < 0) { - fprintf (stdout, "Get Server-Output Error:%d\n", error.err_code); - fprintf (fp, "Get Server-Output Error:%d\n", error.err_code); - goto _END; + /* if phase-0 */ + sql = "CALL GET_LINE (?, ?);" + + req = cci_prepare (conn, sql, CCI_PREPARE_CALL, &error); + if (req < 0) + { + fprintf (stdout, "Get Server-Output Error:%d\n", error.err_code); + fprintf (fp, "Get Server-Output Error:%d\n", error.err_code); + goto _END; + } } res = cci_register_out_param (req, 1);