Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#13441 closed (fixed)

maximum name length not specified for PostgreSQL

Reported by: aball Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Neither the postgresql nor postgresql_psycopg2 database backends implement the DatabaseOperations.max_name_length() method. Issue #13434 contains changeset ([13040]) that implements the corresponding method for the MySQL database backend, thus preventing the BaseDatabaseCreation class's sql_indices_for_field() method from trying to make indices in MySQL with names that are too long. The same fix should work for PostgreSQL, given a suitable max_name_length() implementation.

Generally, the maximum identifier length in PostgreSQL is 63, but it may be changed by recompiling PostgreSQL with the NAMEDATALEN macro in src/include/pg_config_manual.h changed. Note that the maximum identifier length is always one less than the value of that macro.

I've made a patch that just returns 63 in both PostgreSQL backends, with a docstring explaining about the possibility of recompiling PostgreSQL and suggesting that someone who has recompiled PostgreSQL and wants a different maximum name length could make their own database backend by inheriting almost everything from one of the existing backends and overridding the max_name_length() method in the database operations class.

Attachments (1)

postgresql_max_name_length.diff (1.1 KB) - added by aball 4 years ago.
patch to specify the maximum name length for PostgreSQL

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by aball

patch to specify the maximum name length for PostgreSQL

comment:1 Changed 4 years ago by aball

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I have run the unit tests with the postgresql_psycopg2 on revision r13042 of the trunk with my patch applied. All tests passed.

comment:2 Changed 4 years ago by russellm

  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

Given the changes in r13040 for #12977, this should also be bumped to 1.2.

comment:3 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [13044]) Fixed #13441 -- Enforced a maximum identifier length of 63 for PostgreSQL. Thanks to aball for the report and patch.

comment:4 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.