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

Postgres check for valid identifiers does not check for length #5834

Open
jqnatividad opened this issue Jan 18, 2021 · 0 comments
Open

Postgres check for valid identifiers does not check for length #5834

jqnatividad opened this issue Jan 18, 2021 · 0 comments

Comments

@jqnatividad
Copy link
Contributor

CKAN version
2.9.1

Describe the bug
The postgres backend has several functions/helpers that check for valid postgres identifiers - for valid table, column, index and view (alias) names - that's used by the different datastore API actions.

However, it doesn't detect when an identifier is greater than postgres' maximum identifier length (63 by default - NAMEDATALEN-1 - unless postgres is compiled with a different NAMEDATALEN setting).

https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

This results in truncated identifiers when database objects are created with overly long identifiers, sometimes resulting in errors.

Steps to reproduce

  1. Create a resource
  2. Create an alias that's longer than 63 characters with datastore_create
  3. Check _table_metadata and the alias is truncated at 63 characters

or

  1. Prepare a CSV file with several column names longer than 63 characters
  2. Upload it to CKAN
  3. Datapusher error because datastore_create fails

Expected behavior
The datastore API should not fail silently and pass the long identifiers to postgres which blindly truncates at 63 characters. It should explicitly return an "identifier too long" error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants