Skip to content
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

Merged

Conversation

jongmin-won
Copy link
Contributor

@jongmin-won jongmin-won commented Dec 2, 2024

http://jira.cubrid.org/browse/CBRD-25707

Purpose

11.2v 이전 버전([user_schema]가 없는 버전)에서, View 테이블 내에 SP가 포함된 언로드 파일을 --no-user-specified-name 옵션과 함께 로드할 때 loaddb가 실패하는 문제를 수정했습니다.

Repro

  1. 9.3v unload schema 파일
call [find_user]('PUBLIC') on class [db_user] to [g_public];

CREATE FUNCTION [hello] () RETURN character varying AS LANGUAGE JAVA NAME 'SpCubrid.HelloCubrid() return java.lang.String';
call [change_sp_owner]('hello', 'PUBLIC') on class [db_root];
CREATE VCLASS [v1];

ALTER VCLASS [v1] ADD ATTRIBUTE
       [col1] character varying(1073741823) COLLATE iso88591_bin;

call [change_owner]('v1', 'PUBLIC') on class [db_root];

ALTER VCLASS [v1] ADD QUERY select NA from [db_class] [db_class] ; 
ALTER VCLASS [v1] CHANGE QUERY 1 select [hello]() from [db_class] [db_class] ;

COMMIT WORK;
  1. loaddb 수행
cubrid loaddb --no-user-specified-name -S -u dba -s test_schema testdb -v

Expected

  • loaddb 수행 이후, view 테이블 결과
show create view public.v1;

  VIEW                  CREATE VIEW         
============================================
  'public.v1'           'select  cast([public.hello]() as varchar) from [db_class] [db_class]'

Implementation

N/A

Remarks

  1. name_resolution의 case PT_FUNCTION: 에서 SP를 확인하는 함수 변경
  • AS-IS : jsp_is_exist_stored_procedure()
  • TO-BE : jsp_find_stored_procedure()
  1. 변경 이유
  • node->info.function.generic_name 값을 변경함으로써, 아래 예시와 같이 query_spec(View에서 사용자가 입력한 쿼리)에 작성된 sp_name의 소유자가 변경됩니다.
  1. 예시
  • hello 소유자 확인
select unique_name, sp_name, owner.name from _db_stored_procedure where sp_name ='hello';

  unique_name           sp_name               owner.name          
==================================================================
  'public.hello'        'hello'               'PUBLIC'   
  • AS-IS : jsp_is_exist_stored_procedure()
show create view public.v1;

  VIEW                  CREATE VIEW         
============================================
  'public.v1'           'select  cast([dba.hello]() as varchar) from [db_class] [db_class]'
  • TO-BE : jsp_find_stored_procedure()
show create view public.v1;

  VIEW                  CREATE VIEW         
============================================
  'public.v1'           'select  cast([public.hello]() as varchar) from [db_class] [db_class]'
  1. 분석 내용
  • jsp_is_exist_stored_procedure() 함수의 경우 SP의 존재 여부만 확인 가능합니다.
  • 따라서, jsp_find_stored_procedure() 함수에서 MOP를 return 받아 unique_name을 확인하여 node->info.function.generic_name 값을 변경할 수 있습니다.

…e option of the loaddb utility has been fixed to function correctly, even when SPs are included in unload files from the past.
@jongmin-won jongmin-won self-assigned this Dec 2, 2024
@jongmin-won jongmin-won marked this pull request as ready for review December 4, 2024 03:42
src/sp/jsp_cl.cpp Outdated Show resolved Hide resolved
src/sp/jsp_cl.cpp Outdated Show resolved Hide resolved
jongmin-won added 2 commits December 9, 2024 12:51
…reated the jsp_find_sp_of_another_owner() function to make the logic for locating of the SP unique_name more readable.
@jongmin-won
Copy link
Contributor Author

f611049의 commit 수정 내용은 jsp_cl.cpp 파일에서 jsp_* 관련 함수 순서 정렬 및 주석 내용을 정리했습니다.

@jongmin-won jongmin-won merged commit e36c8ef into CUBRID:feature/plcsql-p1n Dec 10, 2024
8 of 10 checks passed
@jongmin-won jongmin-won deleted the plcsql-p1n-CBRD-25707 branch December 10, 2024 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants