Skip to content

[*] fix error hint in timetable.cron_split_to_arrays - #863

Open
pashagolub wants to merge 1 commit into
masterfrom
fix/cron-split-hint
Open

pashagolub wants to merge 1 commit into
masterfrom
fix/cron-split-hint

Conversation

@pashagolub

Copy link
Copy Markdown
Collaborator

Summary

timetable.cron_split_to_arrays joined its RAISE EXCEPTION hint with + instead of ||. PostgreSQL has no unique text + text operator, so an unrecognised cron field raised the wrong error.

 RAISE EXCEPTION 'Value ("%") not recognized', a_element[i_index]
-    USING HINT = 'fields separated by space or tab.'+
-       'Values allowed: numbers (value list with ","), '+
+    USING HINT = 'fields separated by space or tab. ' ||
+        'Values allowed: numbers (value list with ","), ' ||
         'any value with "*", range of value with "-" and step values with "/"!';
 internal/pgengine/
 ├── sql/cron.sql                # fresh installs
+├── sql/migrations/00850.sql    # existing installs, CREATE OR REPLACE FUNCTION
 ├── sql/init.sql                # records 00850 in timetable.migration
 └── migration.go                # registers 00850
 cmd/pg_timetable/main.go        # dbapi 00820 → 00850

Found by the pgcov SQL tests in #850, which is stacked on this PR.

Evidence

assertCronSplitRejectsValue runs SELECT timetable.cron_split_to_arrays('foo * * * *'). Two tests call it: TestCronSplitToArraysUnknownValue on a fresh install, and TestMigrations after migrating from 00000.sql.

  • Before: --- FAIL: TestCronSplitToArraysUnknownValue
    Error: Not equal: expected: "P0001"
    Error: Not equal: expected: "Value (\"foo\") not recognized"
    Error: "Could not choose a best candidate operator. You might need to add explicit type casts."
           does not contain "fields separated by space or tab. Values allowed"
    
    After: both tests pass.

Merge Danger

Door: one-way

Migration 00850 runs on existing installs and is recorded in timetable.migration. It only replaces one function body, so a later migration can change it again.

Blast Radius: small

Only the error path for an unrecognised cron field changes, and that path already failed with the wrong error. Valid cron strings take the same code path as before.

The hint was built with `+` instead of `||`, so an unrecognized cron
value raised 42725 (operator is not unique) instead of the intended
'Value ("...") not recognized' error.

Migration 00850 replaces the function on existing installs, and dbapi
is bumped to 00850. TestMigrations checks the migrated function and
TestCronSplitToArraysUnknownValue checks a fresh install.
@pashagolub
pashagolub added this pull request to stack #864 October 9, 2026 17:48
@pashagolub pashagolub self-assigned this Oct 9, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 37968493685

Coverage decreased (-0.07%) to 87.49%

Details

  • Coverage decreased (-0.07%) from the base build.
  • Patch coverage: 2 of 2 lines across 1 file are fully covered (100%).
  • 8 coverage regressions across 3 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

8 previously-covered lines in 3 files lost coverage.

File Lines Losing Coverage Coverage
internal/pgengine/log_hook.go 4 78.89%
cmd/pg_timetable/service_windows.go 2 74.88%
internal/otel/otel.go 2 90.98%

Coverage Stats

Coverage Status
Relevant Lines: 2446
Covered Lines: 2140
Line Coverage: 87.49%
Coverage Strength: 0.89 hits per line

💛 - Coveralls

@postgresql007 postgresql007 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good

This branch has not been deployed

No deployments
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