Skip to content

Conversation

@ctshim
Copy link
Contributor

@ctshim ctshim commented Dec 22, 2025

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

Purpose

  • Fixed an issue where adddate() and subdate() results would be inaccurate when a leap year was included

Implementation

N/A

Remarks

N/A

…ld be inaccurate when a leap year was included
@ctshim ctshim added this to the guava milestone Dec 22, 2025
@ctshim ctshim self-assigned this Dec 22, 2025
@ctshim ctshim added the bug label Dec 22, 2025
@ctshim
Copy link
Contributor Author

ctshim commented Dec 22, 2025

/run all

{
_d = 1;
_y--;
_m = (_m == 1) ? 12 : (_m - 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

_d가 0인 경우는 /* days within a year */ 루프 전부터 _d = 0인 경우밖에 없을 것 같습니다.

해당 경우엔 항상 _y--; _m = 12; 일 것 같습니다.

{
_d += days[i];
}
_m = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

이슈와 별개로 해당 부분을 삭제할 수 있을 거 같습니다.

Suggested change
_m = 1;

Copy link
Contributor

@hyunikn hyunikn Dec 23, 2025

Choose a reason for hiding this comment

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

19693 라인의 goto 문에서 19722 라인을 거쳐 19730 라인에서 _m 을 사용하기 때문에 삭제할 수 없을 것 같습니다.
19693 라인에서 언제나 _m 이 1 이라고 볼 수 없을 것 같습니다.
단, 18700 라인의 for 문에서 _m = 1 은 지울 수 있을 것 같습니다.

Copy link
Contributor

Choose a reason for hiding this comment

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

19693라인의 goto 문을 통했을 때, 19730 라인을 갈 수 있나요?

Copy link
Contributor

Choose a reason for hiding this comment

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

컴파일러가 최적화 과정에서 for 문의 _m = 1 을 삭제할 수는 있겠지만,
readability 를 위해서 생략하지 않는 것이 좋겠습니다.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kangmin5505 갈 수 있지요.

Copy link
Contributor Author

@ctshim ctshim Dec 24, 2025

Choose a reason for hiding this comment

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

_m = 1; goto set_and_return; 앞으로 옮기도록 하겠습니다.
이렇게 되면 가독성 문제도 해결 되고, 기존과 동일한 결과도 기대할 수 있겠네요

그런데 이 경우에는 어차피 에러를 리턴하고 _m은 사용되지 않는군요

Copy link
Contributor

Choose a reason for hiding this comment

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

goto 직전 검사하는 조건을 볼 때 19730 라인을 갈 수 없다는 것을 알게 되었습니다.
혼란을 드려 죄송합니다.

@beyondykk9
Copy link
Contributor

본 이슈를 리뷰하면서 발견한 오류가 있습니다. add date 기능이지만 argument로 음수가 넘어왔을 때 처리가 제대로 안 되고 있습니다.
예를 들면 month가 -1인 경우

@hyunikn
Copy link
Contributor

hyunikn commented Dec 23, 2025

본 이슈를 리뷰하면서 발견한 오류가 있습니다. add date 기능이지만 argument로 음수가 넘어왔을 때 처리가 제대로 안 되고 있습니다. 예를 들면 month가 -1인 경우

m 이 음수인 경우는 sub_and_normalize_date_time() 를 타고 실행되는 것 같습니다.
오동작 하는 예가 있을까요.

@beyondykk9
Copy link
Contributor

beyondykk9 commented Dec 23, 2025

본 이슈를 리뷰하면서 발견한 오류가 있습니다. add date 기능이지만 argument로 음수가 넘어왔을 때 처리가 제대로 안 되고 있습니다. 예를 들면 month가 -1인 경우

m 이 음수인 경우는 sub_and_normalize_date_time() 를 타고 실행되는 것 같습니다. 오동작 하는 예가 있을까요.

select adddate('2025-01-15:10:00:00', interval '-1'year_month);

=== <Result of SELECT Command in Line 1> ===

   date_add('2025-01-15:10:00:00', INTERVAL '-1' YEAR_MONTH)
======================
  '10:00:00.000 AM 02/15/2025'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants