-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CBRD-25707] With the addition of [user_schema] to SP, the --no-user-specified-name option of the loaddb utility has been fixed to function correctly, even when SPs are included in unload files from the past. #5659
base: feature/plcsql-p1n
Are you sure you want to change the base?
Changes from all commits
2973990
4a703d4
aa801fb
d35442d
f611049
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20250,6 +20250,98 @@ do_find_synonym_by_query (const char *name, char *buf, int buf_size) | |
#undef QUERY_BUF_SIZE | ||
} | ||
|
||
int | ||
do_find_stored_procedure_by_query (const char *name, char *buf, int buf_size) | ||
{ | ||
#define QUERY_BUF_SIZE 2048 | ||
jongmin-won marked this conversation as resolved.
Show resolved
Hide resolved
|
||
DB_QUERY_RESULT *query_result = NULL; | ||
DB_QUERY_ERROR query_error; | ||
DB_VALUE value; | ||
const char *query = NULL; | ||
char query_buf[QUERY_BUF_SIZE] = { '\0' }; | ||
const char *current_schema_name = NULL; | ||
const char *sp_name = NULL; | ||
int error = NO_ERROR; | ||
|
||
db_make_null (&value); | ||
query_error.err_lineno = 0; | ||
query_error.err_posno = 0; | ||
|
||
if (name == NULL || name[0] == '\0') | ||
{ | ||
ERROR_SET_WARNING (error, ER_OBJ_INVALID_ARGUMENTS); | ||
return error; | ||
} | ||
|
||
assert (buf != NULL); | ||
|
||
current_schema_name = sc_current_schema_name (); | ||
|
||
sp_name = sm_remove_qualifier_name (name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sp_name이 NULL일 경우는 체크할 필요가 없을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sp_name이 NULL인 경우, WHERE 조건에서 [sp_name] = NULL로 조회하게 됩니다. |
||
query = "SELECT [unique_name] FROM [%s] WHERE [sp_name] = '%s' AND [owner].[name] != UPPER ('%s')"; | ||
assert (QUERY_BUF_SIZE > snprintf (NULL, 0, query, CT_STORED_PROC_NAME, sp_name, current_schema_name)); | ||
snprintf (query_buf, QUERY_BUF_SIZE, query, CT_STORED_PROC_NAME, sp_name, current_schema_name); | ||
assert (query_buf[0] != '\0'); | ||
|
||
error = db_compile_and_execute_local (query_buf, &query_result, &query_error); | ||
if (error < NO_ERROR) | ||
{ | ||
ASSERT_ERROR (); | ||
goto end; | ||
} | ||
|
||
error = db_query_first_tuple (query_result); | ||
if (error != DB_CURSOR_SUCCESS) | ||
{ | ||
if (error == DB_CURSOR_END) | ||
{ | ||
ERROR_SET_WARNING_1ARG (error, ER_SP_NOT_EXIST, name); | ||
} | ||
else | ||
{ | ||
ASSERT_ERROR (); | ||
} | ||
|
||
goto end; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 다른 에러가 발생할 경우는 없나요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네, DB_CURSOR_SUCCESS와 DB_CURSOR_END를 제외한 모든 경우는 ASSERT_ERROR()로 처리됩니다.
|
||
|
||
error = db_query_get_tuple_value (query_result, 0, &value); | ||
if (error != NO_ERROR) | ||
{ | ||
ASSERT_ERROR (); | ||
goto end; | ||
} | ||
|
||
if (!DB_IS_NULL (&value)) | ||
{ | ||
assert (strlen (db_get_string (&value)) < buf_size); | ||
strcpy (buf, db_get_string (&value)); | ||
} | ||
else | ||
{ | ||
/* unique_name must not be null. */ | ||
ASSERT_ERROR_AND_SET (error); | ||
goto end; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if (DB_IS_NULL) 로 하는 게 읽기 편할 것 같습니다. |
||
|
||
error = db_query_next_tuple (query_result); | ||
if (error != DB_CURSOR_END) | ||
{ | ||
/* No result can be returned because unique_name is not unique. */ | ||
buf[0] = '\0'; | ||
} | ||
|
||
end: | ||
if (query_result) | ||
{ | ||
db_query_end (query_result); | ||
query_result = NULL; | ||
} | ||
|
||
return error; | ||
#undef QUERY_BUF_SIZE | ||
} | ||
|
||
/* | ||
* do_set_trace_to_query_flag() - | ||
* return: void | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿼리 내용을 보니 이름은 갖고 소유자는 현재 스키마와 다른 경우를 찾는 것 같습니다.
함수 이름에 이런 사정이 잘 드러나지 않는 듯 합니다.
함수 이름으로 do_find_sp_of_another_owner 정도가 어떨까요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. 기존에 동일한 기능을 수행하는 함수들과의 일관성을 유지하기 위해 do_find_stored_procedure_by_query() 함수의 이름은 변경하지 않았습니다.
2. 코드의 가독성을 높이기 위해 제안해 주신 함수 이름을 참고하여 jsp_find_sp_of_another_owner 함수를 추가하였으며, 해당 함수에서 다른 소유자의 SP를 찾을 수 있도록 수정했습니다.
AS-IS
TO-BE