Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PostgreSQL connector truncates long identifiers silently #12882

Closed
ebyhr opened this issue Jun 17, 2022 · 3 comments · Fixed by #13742
Closed

PostgreSQL connector truncates long identifiers silently #12882

ebyhr opened this issue Jun 17, 2022 · 3 comments · Fixed by #13742
Assignees
Labels
bug Something isn't working correctness

Comments

@ebyhr
Copy link
Member

ebyhr commented Jun 17, 2022

# schema name
trino> CREATE SCHEMA postgresql.a123456789012345678901234567890123456789012345678901234567890123;
trino> SHOW SCHEMAS IN postgresql;
                             Schema
-----------------------------------------------------------------
 a12345678901234567890123456789012345678901234567890123456789012

# table name
trino> CREATE TABLE postgresql.tpch.a123456789012345678901234567890123456789012345678901234567890123 (c1 int);
trino> SHOW TABLES IN postgresql.tpch;
                              Table
-----------------------------------------------------------------
 a12345678901234567890123456789012345678901234567890123456789012

# column name
trino> CREATE TABLE postgresql.tpch.test (a123456789012345678901234567890123456789012345678901234567890123 int);
trino> DESC postgresql.tpch.test;
                             Column                              |  Type   | Extra | Comment
-----------------------------------------------------------------+---------+-------+---------
 a12345678901234567890123456789012345678901234567890123456789012 | integer |       |

https://www.postgresql.org/docs/current/limits.html

identifier length | 63 bytes | can be increased by recompiling PostgreSQL

I think we should block such identifiers using:

  • DatabaseMetaData#getMaxCatalogNameLength
  • DatabaseMetaData#getMaxSchemaNameLength
  • DatabaseMetaData#getMaxTableNameLength
  • DatabaseMetaData#getMaxColumnNameLength
@findepi
Copy link
Member

findepi commented Jun 20, 2022

Do you know why PostgreSQL chose to silently truncate identifiers in CREATE SCHEMA / CREATE TABLE?
is there any related PostgreSQL issue about this?

@ebyhr
Copy link
Member Author

ebyhr commented Jun 21, 2022

@findepi JDBC driver reports the truncation via Statement#getWarnings, so it's not "silent" actually. I couldn't find relevant issues.

@findepi
Copy link
Member

findepi commented Jun 21, 2022

well.. warning is too late, as the object is already created. It's created with a different name, so we cannot clean it up, even if we understood the warning and wanted to clean up.

I couldn't find relevant issues.

worth filing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness
Development

Successfully merging a pull request may close this issue.

2 participants