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

Open
wants to merge 2 commits into
base: feature/plcsql-p1n
Choose a base branch
from

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
}

goto end;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 에러가 발생할 경우는 없나요?

/* unique_name must not be null. */
ASSERT_ERROR_AND_SET (error);
goto end;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (DB_IS_NULL) 로 하는 게 읽기 편할 것 같습니다.

{
other_class_name[0] = '\0';

err = do_find_stored_procedure_by_query (name, other_class_name, DB_MAX_IDENTIFIER_LENGTH);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err 처리는 안해도 되나요?


current_schema_name = sc_current_schema_name ();

sp_name = sm_remove_qualifier_name (name);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sp_name이 NULL일 경우는 체크할 필요가 없을까요?

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.

3 participants