Skip to content

Expect the to_char error for RN combined with other formats - #1353

Merged
mrigger merged 1 commit into
sqlancer:mainfrom
splf-jojo:fix/postgres-to-char-incompatible-format
Jul 31, 2026
Merged

Expect the to_char error for RN combined with other formats#1353
mrigger merged 1 commit into
sqlancer:mainfrom
splf-jojo:fix/postgres-to-char-incompatible-format

Conversation

@splf-jojo

Copy link
Copy Markdown
Contributor

Summary

During a run against postgres:18, a randomly generated to_char call was reported as a bug, although PostgreSQL rejected it correctly:

postgres=# SELECT to_char(1.5, 'RN0');
ERROR:  "RN" is incompatible with other formats
DETAIL:  "RN" may only be used together with "FM".

The message was not registered as an expected error, so SQLancer stopped testing that database. This patch adds it to getToCharFunctionErrors(), without the pattern name, so that the entry does not depend on which pattern raises it.

Validating the format in the generator would mean reproducing the format parser of PostgreSQL, since the argument is built from concatenated expressions.

Testing

mvn package passes. A 40 second --oracle NOREC run against postgres:18 executed 2814 queries with no thread shutting down.

PostgreSQL rejects a numeric format string that combines RN with any
other pattern, for example to_char(1.5, 'RN0'), with the error
"RN" is incompatible with other formats. The expression generator can
produce such format strings, so this error reached the caller as an
unexpected one and aborted the test run.

@mrigger mrigger 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.

LGTM, thanks!

@mrigger
mrigger merged commit fc442ec into sqlancer:main Jul 31, 2026
22 of 25 checks passed
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.

2 participants