Skip to content

[#8109] improvement(core): correct PostgreSQL ON CONFLICT syntax using EXCLUDED instead of VALUES#8125

Merged
justinmclean merged 1 commit intoapache:mainfrom
keepConcentration:8109
Aug 17, 2025
Merged

[#8109] improvement(core): correct PostgreSQL ON CONFLICT syntax using EXCLUDED instead of VALUES#8125
justinmclean merged 1 commit intoapache:mainfrom
keepConcentration:8109

Conversation

@keepConcentration
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This PR fixes the incorrect SQL syntax in UserRoleRelPostgreSQLProvider.java by replacing VALUES() function calls with EXCLUDED references in the ON CONFLICT ... DO UPDATE clause. The change ensures proper PostgreSQL compatibility for upsert operations.\

Why are the changes needed?

The current implementation uses MySQL-specific VALUES() function syntax in PostgreSQL provider, which is incorrect according to PostgreSQL documentation. PostgreSQL's INSERT ... ON CONFLICT ... DO UPDATE requires using EXCLUDED table alias to reference the values that would have been inserted, not the VALUES() function.

Fix: #8109

Does this PR introduce any user-facing change?

No user-facing changes. This is a bug fix that ensures the existing functionality works correctly on PostgreSQL databases.

How was this patch tested?

Tested with existing tests.

Copy link
Copy Markdown
Member

@justinmclean justinmclean left a comment

Choose a reason for hiding this comment

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

Thanks, that looks good to me.

@justinmclean justinmclean merged commit bcbfdc6 into apache:main Aug 17, 2025
30 of 31 checks passed
diqiu50 pushed a commit to diqiu50/gravitino that referenced this pull request Sep 15, 2025
…x using EXCLUDED instead of VALUES (apache#8125)

### What changes were proposed in this pull request?

This PR fixes the incorrect SQL syntax in
`UserRoleRelPostgreSQLProvider.java` by replacing `VALUES()` function
calls with `EXCLUDED` references in the `ON CONFLICT ... DO UPDATE`
clause. The change ensures proper PostgreSQL compatibility for upsert
operations.\

### Why are the changes needed?

The current implementation uses MySQL-specific `VALUES()` function
syntax in PostgreSQL provider, which is incorrect according to
PostgreSQL documentation. PostgreSQL's `INSERT ... ON CONFLICT ... DO
UPDATE` requires using `EXCLUDED` table alias to reference the values
that would have been inserted, not the `VALUES()` function.

Fix: apache#8109

### Does this PR introduce _any_ user-facing change?

No user-facing changes. This is a bug fix that ensures the existing
functionality works correctly on PostgreSQL databases.

### How was this patch tested?

Tested with existing tests.
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.

[Improvement] Incorrect SQL syntax for Postgres with insert on conflict

2 participants