Skip to content

Surgical port of core logic improvements: Date, DSQL, and Sort#8978

Open
laBobberto wants to merge 1 commit intoFirebirdSQL:masterfrom
laBobberto:fix_logic_surgical
Open

Surgical port of core logic improvements: Date, DSQL, and Sort#8978
laBobberto wants to merge 1 commit intoFirebirdSQL:masterfrom
laBobberto:fix_logic_surgical

Conversation

@laBobberto
Copy link
Copy Markdown

@laBobberto laBobberto commented Apr 2, 2026

This PR is part of the closed parent PR #8938, which has been split into smaller, more targeted merge requests.

The PR includes:

  • NoThrowTimeStamp.cpp: Implemented McCarthy's algorithm for accurate weekday date calculation according to the ISO 8601 standard.
  • sort.cpp: Optimized the mergeRuns loop and localized merge_pool to improve memory safety. Fixed block indentation and replaced NULL with nullptr in the relevant logic.

@laBobberto laBobberto force-pushed the fix_logic_surgical branch from 61e555a to 8cea0c0 Compare April 2, 2026 21:37
@hvlad
Copy link
Copy Markdown
Member

hvlad commented Apr 2, 2026

  • NoThrowTimeStamp.cpp: Implemented McCarthy's algorithm for accurate weekday date calculation according to the ISO 8601 standard.

Do you say that current algorithm is not accurate or doesn't comply with ISO 8601 standard ?
Examples ?

  • sort.cpp: Optimized the mergeRuns loop and localized merge_pool to improve memory safety.

What exactly it optimizes ?

Fixed block indentation and replaced NULL with nullptr in the relevant logic.

Why block indentation of lines 493-532 is wrong (at least on github view) ?
Why so many NULL's was not replaced ?

int yearNumber, weekNumber;

if ((dayOfYearNumber <= (8 - jan1Weekday)) && (jan1Weekday > 4))
if ((dayOfYear <= (8 - jan1Weekday)) & (jan1Weekday > 4))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changing logical && to bitwise & here is plain bug.

weekNumber = ((jan1Weekday == 5) || ((jan1Weekday == 6) &&
isLeapYear(yearNumber))) ? 53 : 52;
const int prevYearLeap = (!(y_1 % 4) && ((y_1 % 100) || !(y_1 % 400)));
const int is53 = (jan1Weekday == 5) | ((jan1Weekday == 6) & prevYearLeap);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you sure that operator | always returns 1 (assigned to int is53), not for example -1?

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