From bb0bd8acc5d6899ed514159e344928e6453faa63 Mon Sep 17 00:00:00 2001 From: Aravindraja Thinakaran Date: Sat, 1 Apr 2017 02:57:48 -0400 Subject: [PATCH] Properly handle truncated table names (> NAMEDATALEN). Fixes #2277 --- .../servers/databases/schemas/tables/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py index 1fed25d4c..179d4a873 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/__init__.py @@ -1446,6 +1446,12 @@ class TableView(PGChildNodeView, DataTypeReader, VacuumSettings): if not status: return internal_server_error(errormsg=res) + # PostgreSQL truncates the table name to 63 characters. + # Have to truncate the name as like PostgreSQL to get the proper schema id + CONST_MAX_CHAR_COUNT = 63 + if len(data['name']) > CONST_MAX_CHAR_COUNT: + data['name'] = data['name'][0:CONST_MAX_CHAR_COUNT] + # Get updated schema oid SQL = render_template("/".join([self.template_path, 'get_schema_oid.sql']), tname=data['name'])