Skip to content

Add expected errors for postgres 18#1298

Merged
mrigger merged 7 commits intosqlancer:mainfrom
albertZhangTJ:main
Mar 24, 2026
Merged

Add expected errors for postgres 18#1298
mrigger merged 7 commits intosqlancer:mainfrom
albertZhangTJ:main

Conversation

@albertZhangTJ
Copy link
Copy Markdown
Collaborator

Add expected errors related to SQL_ASCII encoding in PG18; Add error message related to WAL enforcement on partitioned table

@albertZhangTJ albertZhangTJ requested a review from mrigger March 3, 2026 01:41
public static List<String> getCommonExpressionErrors() {
ArrayList<String> errors = new ArrayList<>();

errors.add("for encoding \"SQL_ASCII\" does not exist");
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.

Hmm, why does this happen? Is this something that we should avoid generating instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I err towards adding this as expected error.

The root cause is if the database was created without specifying UTF8 encoding, then specifying COLLATE later will be invalid. e.g.

CREATE DATABASE database7  TEMPLATE template0;
CREATE UNLOGGED TABLE t3(c0 TEXT COLLATE "pg_c_utf8"  UNIQUE) INHERITS(t2, t1);

The other fix option would be enforcing UTF8 encoding in PostgresProvider instead of making it randomized, but I feel like it will lead to less diverse behaviors.

@albertZhangTJ
Copy link
Copy Markdown
Collaborator Author

Added 1 further expected errors:

  • Cannot drop inherited constraint for inherited columns: avoiding this at the generator level would require adding additional attribute to PostgresColumn and corresponding schema query

Disabled SET_LOGGED_UNLOGGED action of ALTER TABLE for partitioned table. Additional attribute was added to PostgresTable class. The old constructor was kept as an adapter for other DBMS implementations that depends on the Postgres one.

Fixed NullPonterException for PostgresBinaryComparisonOperation, which returned a Java null instead of a SQL NULL when either side of the operator has a NULL expected error. This would later cause an NPE when accessed without null checks.

Copy link
Copy Markdown
Contributor

@mrigger mrigger left a comment

Choose a reason for hiding this comment

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

Regarding the PostgresBinaryComparisonOperation, I have a minor comment/request. Could you please take a look at this?

It seems that that the linter check is currently failing. You'll need to execute the code formatter: mvn formatter:format.

After that, we can merge the change.

Thanks!

PostgresConstant rightExpectedValue = getRight().getExpectedValue();
if (leftExpectedValue == null || rightExpectedValue == null) {
return null;
return PostgresConstant.createNullConstant();
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.

Hmm, I think this should probably throw an IgnoreMeException. This logic is part of PQS. I think null is only returned if some functionality is not fully implemented.

this.statistics = statistics;
this.isInsertable = isInsertable;
this.tableType = tableType;
//TODO: simple adapter for other implementations
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.

Hmm, I don't understand what that comment means, but I guess it's fine.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The PostgresTable class can be instantiated at the fromConnection function below, as a result of a schema query, in the generator by the PostgresTableGenerator, as well as by other DBMS implementations that depends on the Postgres one.
The new constructor signature with an additional isPartitioned argument is not easily applicable to all of those. Hence I left this original constructor in place with the isPartitioned flag set to false by default as an adapter.

Copy link
Copy Markdown
Contributor

@mrigger mrigger left a comment

Choose a reason for hiding this comment

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

LGTM!

@mrigger mrigger merged commit 9fdd0a1 into sqlancer:main Mar 24, 2026
16 of 26 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