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-25658] Supports pseudo column in SP parameter default values #2022

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
===================================================
0

===================================================
0

===================================================
0

===================================================

null


1: 100
===================================================

null


0: ok
1: ok
2: ok
3: ok
4: ok
5: ok
6: ok
7: ok
8: ok
9: ok
10: ok
11: ok
12: ok
13: ok
===================================================

null


Formatted Date: ok
===================================================
sp_of pkg_name index_of is_system_generated arg_name data_type mode default_value is_optional comment
_db_stored_procedure null 0 0 p_id 1 1 100 1 null


===================================================
sp_of pkg_name index_of is_system_generated arg_name data_type mode default_value is_optional comment
_db_stored_procedure null 0 0 p_date 12 1 SYS_DATE 1 null
_db_stored_procedure null 1 0 p_null_value 1 1 null 1 null
_db_stored_procedure null 2 0 p_null_string 4 1 NULL 1 null
_db_stored_procedure null 3 0 p_empty_string 4 1 null 1 null
_db_stored_procedure null 4 0 p_user 4 1 CURRENT_USER 1 null
_db_stored_procedure null 5 0 p_fuser 4 1 USER() 1 null
_db_stored_procedure null 6 0 p_cuser 4 1 CURRENT_USER 1 null
_db_stored_procedure null 7 0 p_unix_timestamp 1 1 UNIX_TIMESTAMP() 1 null
_db_stored_procedure null 8 0 p_sys_datetime 32 1 SYS_DATETIME 1 null
_db_stored_procedure null 9 0 p_curr_datetime 32 1 CURRENT_DATETIME 1 null
_db_stored_procedure null 10 0 p_curr_date 12 1 CURRENT_DATE 1 null
_db_stored_procedure null 11 0 p_sys_time 10 1 SYS_TIME 1 null
_db_stored_procedure null 12 0 p_curr_time 10 1 CURRENT_TIME 1 null
_db_stored_procedure null 13 0 p_var_number 4 1 +12345 1 null


===================================================
sp_of pkg_name index_of is_system_generated arg_name data_type mode default_value is_optional comment
_db_stored_procedure null 0 0 p_formatted_date 4 1 TO_CHAR(SYS_DATE, 'YYYY-MM-DD') 1 null


===================================================
0

===================================================
0

===================================================
0

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
--+ server-message on

-- Verifies : CBRD-25658
-- default : procedure default
-- If CUBRID string and NULL are bundled, NULL is output.
-- When expressed in Oracle style, set the system parameter in ".conf" to 'oracle_style_empty_string=yes' and run the database.

CREATE OR REPLACE PROCEDURE default_procedure_simple (
p_id INTEGER DEFAULT 100
) AS
BEGIN
DBMS_OUTPUT.PUT_LINE('1: ' || p_id);
END;
kiho-um marked this conversation as resolved.
Show resolved Hide resolved

CREATE OR REPLACE PROCEDURE default_procedure_with_pseudo (
p_date DATE DEFAULT SYSDATE,
Copy link
Contributor

@kwonhoil kwonhoil Jan 20, 2025

Choose a reason for hiding this comment

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

p_sys_timestamp TIMESTAMP DEFAULT SYS_TIMESTAMP,
p_current_timestamp TIMESTAMP DEFAULT SYS_TIMESTAMP,

추가하고, 아래 출력하는 부분에도 추가해 주세요.

p_null_value INTEGER DEFAULT NULL,
p_null_string VARCHAR DEFAULT 'NULL',
p_empty_string VARCHAR DEFAULT '',
p_user VARCHAR DEFAULT USER,
p_fuser VARCHAR DEFAULT USER(),
p_cuser VARCHAR DEFAULT CURRENT_USER,
p_unix_timestamp INTEGER DEFAULT UNIX_TIMESTAMP(),
p_sys_datetime DATETIME DEFAULT SYS_DATETIME,
p_curr_datetime DATETIME DEFAULT CURRENT_DATETIME,
Copy link
Contributor

Choose a reason for hiding this comment

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

SYS_DATE 추가해 주세요

p_curr_date DATE DEFAULT CURRENT_DATE,
p_sys_time TIME DEFAULT SYS_TIME,
p_curr_time TIME DEFAULT CURRENT_TIME,
Copy link
Contributor

@kwonhoil kwonhoil Jan 20, 2025

Choose a reason for hiding this comment

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

p_date_time VARCHAR TO_CHAR(sysdatetime, 'YYYY-MM-DD HH24:MI:SS'),
추가해 주세요.

p_var_number VARCHAR DEFAULT TO_CHAR(12345, 'S999999')
) AS
BEGIN
Copy link
Contributor

@kwonhoil kwonhoil Jan 20, 2025

Choose a reason for hiding this comment

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

sys_date, sys_time 등과 같이 값이 변경되는 경우에는 length로 확인하는게 좋겠습니다.
length의 길이가 변경되는 경우에는 최소의 숫자보다 큰지를 확인하는게 좋을것 같습니다.

그 외에 user는 DBA 값으로 확인하고,
UNIX_TIMESTAMP()은 0보다 큰지 확인하는게 좋겠습니다.

DBMS_OUTPUT.PUT_LINE(' 0: ' || CASE isnull(p_date) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
DBMS_OUTPUT.PUT_LINE(' 1: ' || CASE WHEN p_null_value IS NULL THEN 'ok' ELSE 'nok' END);
DBMS_OUTPUT.PUT_LINE(' 2: ' || CASE WHEN p_null_string = 'NULL' THEN 'ok' ELSE 'nok' END);
DBMS_OUTPUT.PUT_LINE(' 3: ' || CASE WHEN p_empty_string IS NULL THEN 'ok' ELSE 'nok' END);
Copy link
Contributor

Choose a reason for hiding this comment

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

p_empty_string 는 default로 ''로 설정했는데
비교는 NULL로 하고, 결과는 OK로 처리되고 있습니다.

즉, default로 설정한 ''가 NULL로 변경되었습니다.
버그로 보여지며, 개발팀에 확인해 주세요.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CUBRID/cubrid#5792
머지가 되고, 반영되었는지 확인 후 수정 반영 하도록 하겠습니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

empty 부분 CUBRID/cubrid#5792 머지가 완료되었음.

DBMS_OUTPUT.PUT_LINE(' 4: ' || CASE isnull(p_user) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
DBMS_OUTPUT.PUT_LINE(' 5: ' || CASE WHEN p_fuser = USER() THEN 'ok' ELSE 'nok' END);
DBMS_OUTPUT.PUT_LINE(' 6: ' || CASE isnull(p_cuser) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
DBMS_OUTPUT.PUT_LINE(' 7: ' || CASE isnull(p_unix_timestamp) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
DBMS_OUTPUT.PUT_LINE(' 8: ' || CASE isnull(p_sys_datetime) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
DBMS_OUTPUT.PUT_LINE(' 9: ' || CASE isnull(p_curr_datetime) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
DBMS_OUTPUT.PUT_LINE('10: ' || CASE isnull(p_curr_date) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
DBMS_OUTPUT.PUT_LINE('11: ' || CASE isnull(p_sys_time) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
DBMS_OUTPUT.PUT_LINE('12: ' || CASE isnull(p_curr_time) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
Copy link
Contributor

@kwonhoil kwonhoil Jan 20, 2025

Choose a reason for hiding this comment

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

DBMS_OUTPUT.PUT_LINE('13: ' || CASE length(p_date_time ) WHEN 19 THEN 'ok' ELSE 'nok' END);

추가해 주세요.

DBMS_OUTPUT.PUT_LINE('13: ' || CASE isnull(p_var_number) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
END;

CREATE OR REPLACE PROCEDURE default_proc_tochar (
p_formatted_date VARCHAR DEFAULT TO_CHAR(SYSDATE, 'YYYY-MM-DD')
) AS
BEGIN
DBMS_OUTPUT.PUT_LINE('Formatted Date: ' || CASE isnull(p_formatted_date) WHEN 0 THEN 'ok' WHEN 1 THEN 'nok' END);
Copy link
Contributor

Choose a reason for hiding this comment

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

to_char( sysdate, 'YYYY-MM-DD')의 정확한 결과를 확인하는 것은 length 함수가 더 좋을것 같습니다.

예시)
CASE length(p_formatted_date) WHEN 10 THEN 'ok' else 'nok' END

Copy link
Contributor Author

Choose a reason for hiding this comment

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

수정 반영 하겠습니다.

END;

call default_procedure_simple ();
call default_procedure_with_pseudo ();
call default_proc_tochar ();

select * from _db_stored_procedure_args where sp_of.sp_name = 'default_procedure_simple';
select * from _db_stored_procedure_args where sp_of.sp_name = 'default_procedure_with_pseudo' order by index_of;
select * from _db_stored_procedure_args where sp_of.sp_name = 'default_proc_tochar';

drop procedure default_procedure_simple;
drop procedure default_procedure_with_pseudo;
drop procedure default_proc_tochar;

--+ server-message off