jerryshao opened a new issue, #13035:
URL: https://github.com/apache/gravitino/issues/13035

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   `GroupRoleRelBaseSQLProvider.batchInsertGroupRoleRelOnDuplicateKeyUpdate` 
emits MySQL-only syntax 
([GroupRoleRelBaseSQLProvider.java#L50-L75](https://github.com/apache/gravitino/blob/main/core/src/main/java/org/apache/gravitino/storage/relational/mapper/provider/base/GroupRoleRelBaseSQLProvider.java#L50-L75)):
   
   ```sql
   ON DUPLICATE KEY UPDATE
     ... = VALUES(...)
   ```
   
   Both `ON DUPLICATE KEY UPDATE` and the `VALUES(col)` reference are syntax 
errors on PostgreSQL (`42601`), and `GroupRoleRelPostgreSQLProvider` does not 
override the method — it overrides only the four `softDelete*` methods and 
`deleteGroupRoleRelMetasByLegacyTimeline`.
   
   The identical method on the user side **is** overridden: 
`UserRoleRelPostgreSQLProvider#batchInsertUserRoleRelOnDuplicateKeyUpdate` 
rewrites it as `ON CONFLICT (user_id, role_id, deleted_at) DO UPDATE SET ...`. 
The group side appears to have been missed when that override was added.
   
   This is **latent, not a live failure**: no service calls 
`batchInsertGroupRoleRelOnDuplicateKeyUpdate` — the only references in the 
repository are the mapper declaration, the SQL provider factory dispatch, and 
the base provider itself. So the broken SQL is unreachable today, and would 
surface the moment anything wires the method up.
   
   ### Error message and/or stacktrace
   
   Found by static inspection while auditing PostgreSQL backend coverage; the 
method is unreachable, so there is no runtime trace to attach and I would 
rather not fabricate one. If invoked against PostgreSQL, MyBatis would surface 
a `PSQLException` with SQLState `42601` (`syntax error at or near "DUPLICATE"`).
   
   ### How to reproduce
   
   Static, not runtime — the defect is reachable only by code path, not through 
any public API today:
   
   1. `core/.../provider/base/GroupRoleRelBaseSQLProvider.java` — the base SQL 
uses `ON DUPLICATE KEY UPDATE`.
   2. `core/.../provider/postgresql/GroupRoleRelPostgreSQLProvider.java` — no 
override for that method.
   3. Compare with 
`core/.../provider/postgresql/UserRoleRelPostgreSQLProvider.java`, which does 
override it with `ON CONFLICT`.
   
   ### Additional context
   
   The fix is mechanical: the required conflict target already exists as 
`UNIQUE (group_id, role_id, deleted_at)` on `group_role_rel`, so the 
`UserRoleRel` override can be mirrored almost verbatim.
   
   An alternative worth considering: since neither the group nor the user 
variant has any caller, both upsert methods may be dead code, in which case 
removing them (mapper + factory + providers) would be cleaner than adding an 
override that will never execute.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to