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

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   A PostgreSQL table whose name is not entirely lower case can be listed and 
loaded but cannot be altered (add/rename/retype/delete column). The ALTER 
statement is emitted without quoting the table identifier, so PostgreSQL folds 
it to lower case and the statement targets a relation that does not exist.
   
   ### Error message and/or stacktrace
   
   ```
   404  NoSuchTableException
   Failed to operate table(s) [MixedCaseTbl] operation [ALTER] under schema 
[public],
   reason [ERROR: relation "mixedcasetbl" does not exist]
   ```
   
   ### How to reproduce
   
   ```sql
   CREATE TABLE "MixedCaseTbl" ("Id" INT);
   ```
   
   1. Load works, column case preserved: `GET 
.../catalogs/pg_demo/schemas/public/tables/MixedCaseTbl` -> 200
   2. Alter fails: `PUT 
.../catalogs/pg_demo/schemas/public/tables/MixedCaseTbl` with 
`{"updates":[{"@type":"addColumn","fieldName":["extra"],"type":"varchar(20)","nullable":true}]}`
 -> 404 as above
   3. The same alter on an all-lower-case table in the same schema succeeds.
   
   ### Additional context
   
   In 
`catalogs/catalog-jdbc-postgresql/src/main/java/org/apache/gravitino/catalog/postgresql/operation/PostgreSqlTableOperations.java`,
 most ALTER-statement builders wrap the table name in double quotes 
(`PG_QUOTE`), but four do not: `addColumnFieldDefinition`, 
`updateColumnDefaultValueFieldDefinition`, `updateColumnTypeFieldDefinition`, 
`renameColumnFieldDefinition`. Fix: quote the table identifier in these four 
builders, consistent with the rest of the class.
   


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