Skip to content
Draft
Changes from all 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
21 changes: 14 additions & 7 deletions src/query/string_opfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19682,15 +19682,17 @@ add_and_normalize_date_time (int *year, int *month, int *day, int *hour, int *mi
_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 라인을 갈 수 없다는 것을 알게 되었습니다.
혼란을 드려 죄송합니다.


/* days for years */
while (_d >= 366)

int maxdays = (days[2] == 29) ? 366 : 365;
while (_d >= maxdays)
{
days[2] = LEAP (_y) ? 29 : 28;
_d -= (days[2] == 29) ? 366 : 365;
_d -= maxdays;
_y++;
if (_y > 9999)
{
goto set_and_return;
}
maxdays = LEAP (_y) ? 366 : 365;
}

/* days within a year */
Expand All @@ -19707,11 +19709,14 @@ add_and_normalize_date_time (int *year, int *month, int *day, int *hour, int *mi

if (_m == 0)
{
assert (false);
_m = 1;
}
if (_d == 0)
{
_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[_m];
}

set_and_return:
Expand Down Expand Up @@ -19875,8 +19880,8 @@ sub_and_normalize_date_time (int *year, int *month, int *day, int *hour, int *mi
{
goto set_and_return;
}
days[2] = LEAP (_y) ? 29 : 28;
_d += (days[2] == 29) ? 366 : 365;

_d += (LEAP (_y) ? 366 : 365);
}

/* days within a year */
Expand All @@ -19897,7 +19902,9 @@ sub_and_normalize_date_time (int *year, int *month, int *day, int *hour, int *mi
}
if (_d == 0)
{
_d = 1;
_y--;
_m = (_m == 1) ? 12 : (_m - 1);
_d = days[_m];
}

set_and_return:
Expand Down
Loading