Skip to content

[CBRD-26072] specification of PL/CSQL Package#701

Open
hyunikn wants to merge 14 commits intoCUBRID:developfrom
hyunikn:cbrd-26072-plcsql-package
Open

[CBRD-26072] specification of PL/CSQL Package#701
hyunikn wants to merge 14 commits intoCUBRID:developfrom
hyunikn:cbrd-26072-plcsql-package

Conversation

@hyunikn
Copy link
Contributor

@hyunikn hyunikn commented Dec 2, 2025

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

현재 스펙 설계를 진행하고 있는 PL/CSQL 패키지에 대한 초안입니다.

  • PL/CSQL 패키지 섹션을 추가하고 기존의 시스템 패키지 섹션을 그 아래로 이동하였습니다.
  • 일단, 예제 없이 스펙 부분만 작성했습니다. 예제는 별도 PR 로 작성하는 것이 좋을 것 같습니다.
  • 엔진 구현이 완료될 때까지 본 PR 을 develop 브랜치에 머지하지 않겠습니다. 점진적으로 추가되는 변경 내용에 대한 리뷰 용으로 사용하려고 합니다.
  • 영문 버전은 develop 브랜치에 merge 시점에 한번에 작성하겠습니다.

해당 지라 이슈에 렌더링된 문서 링크를 두었습니다.

검토 부탁드립니다.

. moved System Package section into the newly added PL/CSQL Package section
. corrected syntax for seq_of_... syntaxtic elements
. distinguish declaration and definition and correct improper usages
| <cursor_decl>
| <inner_procedure_decl>
| <inner_function_decl>
| <cursor_def>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

패키지가 도입되면서 declaration(선언)과 definition(정의)의 구별이 명확해질 필요가 있어서
기존 문서에서도 교정을 했습니다.
보통, 선언은 이름과 타입 정보 선언을 나타내고 정의는 구현 (body) 를 제공하는 것을 나타냅니다.

<cursor_def> ::=
CURSOR <identifier> [ ( <seq_of_cursor_parameters> ) ] IS <select_statement> ;

<seq_of_cursor_parameters> ::= <cursor_parameter> [, <cursor_parameter>, ...]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

기존 문법 기술에서 큐브리드 문법 기술 방식에서 벗어난 부분이 있어서
이번 기회에 함께 수정했습니다.
이번 PR 의 주된 변경 내용과는 관계 없는 변경입니다.

@@ -1,151 +0,0 @@
-----------------------------
Copy link
Contributor Author

Choose a reason for hiding this comment

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

이 내용은 새로 생긴 PL/CSQL 패키지 섹션의 서브섹션으로 이동했습니다.

@mhoh3963
Copy link
Contributor

mhoh3963 commented Dec 2, 2025

@hyunikn
리뷰가 완료되어서, develop에 머지하지 말아주세요.
11.4 branch를 develop 기준으로 다시 만들 예정입니다.
또한 PM팀에서 develop의 매뉴얼 구조가 변경 중입니다. 구조 변경 후에 맞추어서 변경해주세요.

@hyunikn
Copy link
Contributor Author

hyunikn commented Dec 3, 2025

@hyunikn 리뷰가 완료되어서, develop에 머지하지 말아주세요. 11.4 branch를 develop 기준으로 다시 만들 예정입니다. 또한 PM팀에서 develop의 매뉴얼 구조가 변경 중입니다. 구조 변경 후에 맞추어서 변경해주세요.

네. 알겠습니다. 구조는 변경되는 대로 반영하겠습니다.
일단 내용을 봐주시기 바랍니다.

@hyunikn
Copy link
Contributor Author

hyunikn commented Dec 18, 2025

변경된 develop 브랜치를 merge 하였습니다.

본 PR 의 변경 내용은 PL/CSQL Package 관련해서 사용자 관점 스펙이라고 할 수 있습니다.
추가 내용이 있을 수 있겠으나 guava 대상 구현 scope 에 대한 제 나름대로의 초안입니다.

한참 구현이 진행되었을 때 스펙이 변경되면 혼란과 시간 낭비가 생길 수 있습니다.
스펙에 틀린 부분이나 빠진 부분이 없는지 검토해 주시기 바랍니다.

<create_procedure> ::=
CREATE [ OR REPLACE ] PROCEDURE [schema_name.]<identifier> [ ( <seq_of_parameters> ) ]
{ IS | AS } [ LANGUAGE PLCSQL ] [ <seq_of_declare_specs> ] <body> ;
[ <procedure_properties> ] { IS | AS } [ LANGUAGE PLCSQL ] [ <seq_of_declare_specs> ] <body> ;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

본 이슈 (package) 와 관계 없는 교정 입니다.

<create_function> ::=
CREATE [ OR REPLACE ] FUNCTION [schema_name.]<identifier> [ ( <seq_of_parameters> ) ] RETURN <type_spec>
{ IS | AS } [ LANGUAGE PLCSQL ] [ <seq_of_declare_specs> ] <body> ;
[ <function_properties> ] { IS | AS } [ LANGUAGE PLCSQL ] [ <seq_of_declare_specs> ] <body> ;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

본 이슈 (package) 와 관계 없는 교정 입니다.

위 문법에서 저장 프로시저/함수의 *body*\는 PL/CSQL 실행문들을 포함하고
그 앞의 선언부 *seq_of_declare_specs*\는 실행문들 안에서 사용될 변수, 상수, Exception 등을 선언한다.
이들 문법 요소에 대한 자세한 내용은 :doc:`선언문 <plcsql_decl>`\과 :doc:`실행문 <plcsql_stmt>` 절을 참고한다.
이들 문법 요소에 대한 자세한 내용은 :ref:`CREATE PROCEDURE <create-procedure>`, :ref:`CREATE FUNCTION <create-function>`, :doc:`선언문 <plcsql_decl>`, :doc:`실행문 <plcsql_stmt>` 절을 참고한다.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

본 이슈 (package) 와 관계 없는 교정 입니다.

<mode> ::= IN | OUT | IN OUT | INOUT
<procedure_properties> ::=
<authid> = AUTHID {DEFINER | OWNER | CALLER | CURRENT_USER}
<procedure_properties> ::= <authid>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

본 이슈 (package) 와 관계 없는 교정 입니다.

<procedure_properties> ::= <authid> | <deterministic>
<authid> = AUTHID {DEFINER | OWNER | CALLER | CURRENT_USER}
<deterministic> = [NOT DETERMINISTIC | DETERMINISTIC]
<function_properties> ::= [<authid>] [<deterministic>]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

본 이슈 (package) 와 관계 없는 교정 입니다.


* **WITH GRANT OPTION** 을 이용하면 권한을 부여받은 사용자가 부여받은 권한을 다른 사용자에게 부여할 수 있다.
* 저장 프로시저와 저장 함수에 대한 **EXECUTE ON PROCEDURE** 권한은 **WITH GRANT OPTION** 을 지원하지 않는다.
* PL/CSQL 패키지에 대한 **EXECUTE ON PACKAGE** 권한은 **WITH GRANT OPTION** 을 지원하지 않는다.
Copy link
Contributor

@mhoh3963 mhoh3963 Dec 18, 2025

Choose a reason for hiding this comment

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

PL/CSQL을 붙이지 말고 그냥 패키지라고 표현하는 것은 어떨까요 ?

<type_spec> ::=
<builtin_type>
| <table>.<column>%TYPE
| <variable>%TYPE
Copy link
Contributor

@mhoh3963 mhoh3963 Dec 18, 2025

Choose a reason for hiding this comment

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

문의사항입니다. 아래에 설명이 없어서..

  1. %TYPE의 의미는 앞에 선언된 variable의 type을 표시하는 것인가 ?
  2. <record_type>의 의미 ? (PL/CSQL에서는 지원하지 않았던 type 인 것 같네요.)

Copy link
Contributor Author

@hyunikn hyunikn Dec 19, 2025

Choose a reason for hiding this comment

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

  1. 네. 그렇습니다. 기존의 PL/CSQL 에도 있는 feature 입니다.
  2. 여러 개의 필드를 가진 레코드의 타입을 나타냅니다. 순서쌍 (field name, field type)의 리스트라고 할 수 있고 필드별로 not null 여부와 디폴트 값을 지정할 수 있습니다. 기존의 %ROWTYPE 과 %ROWTYPE 과 비슷한 형태를 갖습니다. 문서 조금 아래쪽을 보시면 <record_type_def> 의 문법이 있습니다.
    레코드타입을 도입하면 %ROWTYPE 만으로 조금 아쉬운 부분을 처리할 수 있게 됩니다. 예를 들면,
    create or replace package pkg as
        type NameGender is record ( name varchar(40), gender char(1) );
    
        function getNameGender(c int) return NameGender as 
            r NameGender;
        begin
            select name, gender into r from athlete where code = c;
            return r;
        end;
    end;
    

    위 예제를 레코드타입 없이 구현하기 위해서는 SELECT 문에 해당하는 커서를 getNameGender 밖에 정의하고 그 커서의 %ROWTYPE을 사용하면 되겠지만 (아래) 사용하지 않을 커서를 정의하는 것보다 레코드 타입을 사용하는 것이 좀 더 나아 보입니다.

    create or replace package pkg as
        cursor cr is select name, gender from athlete;
    
        function getNameGender(c int) return cr%ROWTYPE as 
            r cr%ROWTYPE;
        begin
            select name, gender into r from athlete where code = c;
            return r;
        end;
    end;
    

    레코드타입을 도입하고 기존의 PL/CSQL에서도 쓸 수 있게 하면 좋을 것 같습니다.

Copy link
Contributor

@mhoh3963 mhoh3963 left a comment

Choose a reason for hiding this comment

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

패키지와 관련 없는 교정은 11.4 매뉴얼에도 수정 필요해 보이는데, 교정볼 내용과 패키지 내용을 분리해서 PR 하는 것은 어떨까요 ?

@hyunikn
Copy link
Contributor Author

hyunikn commented Dec 19, 2025

패키지와 관련 없는 교정은 11.4 매뉴얼에도 수정 필요해 보이는데, 교정볼 내용과 패키지 내용을 분리해서 PR 하는 것은 어떨까요 ?

네. 그렇게 하는 것이 좋겠습니다. 마지막 commit 은 제거하고 별도 pr 에서 처리하겠습니다.
이전 commit 에도 약간 그런 내용이 있는데 11.4 에 적용할 때 그 부분도 함께 적용하겠습니다.

@hyunikn hyunikn force-pushed the cbrd-26072-plcsql-package branch from 1aca820 to 0235306 Compare December 19, 2025 02:18
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.

9 participants