Skip to content

Commit

Permalink
[CBRD-25352] When adding a user schema to a stored procedure, the way…
Browse files Browse the repository at this point in the history
… a built-in PL/SQL is called is changed, and the test tools need to be temporarily modified. (#681)

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.
  • Loading branch information
jongmin-won authored Aug 7, 2024
1 parent 4e3d639 commit e3219b9
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 45 deletions.
147 changes: 116 additions & 31 deletions CTP/sql/src/com/navercorp/cubridqa/cqt/console/bo/ConsoleBO.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
21 changes: 19 additions & 2 deletions CTP/sql/src/com/navercorp/cubridqa/cqt/console/dao/ConsoleDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ private String getServerOutputMessage(Connection conn) {
ArrayList<SqlParam> params = new ArrayList<SqlParam>();
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) {
Expand All @@ -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<SqlParam> 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();
Expand Down
46 changes: 34 additions & 12 deletions CTP/sql_by_cci/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit e3219b9

Please sign in to comment.