Skip to content

Commit 6c45a53

Browse files
author
anju15bharti
committed
Revert: ENR temp table creation for long table names
Reverts commits 6368e37 and 0ebb3e6. The approach of storing full name directly in ENR is replaced by a new design using a separate orig_name field.
1 parent 6368e37 commit 6c45a53

1 file changed

Lines changed: 1 addition & 31 deletions

File tree

src/backend/commands/tablecmds.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -797,26 +797,13 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
797797
LOCKMODE parentLockmode;
798798
Oid accessMethodId = InvalidOid;
799799
ObjectAddress tsql_tabletype_address;
800-
const char *enr_relname;
801800

802801
/*
803802
* Truncate relname to appropriate length (probably a waste of time, as
804803
* parser should have done this already).
805804
*/
806805
strlcpy(relname, stmt->relation->relname, NAMEDATALEN);
807806

808-
/*
809-
* For T-SQL #temp tables, ENR stores names in heap-allocated memory
810-
* without NAMEDATALEN limit. Use the full original name so that
811-
* subsequent lookups via the scanner match the registered ENR entry.
812-
*/
813-
if (sql_dialect == SQL_DIALECT_TSQL &&
814-
stmt->relation->relpersistence == RELPERSISTENCE_TEMP &&
815-
stmt->relation->relname[0] == '#')
816-
enr_relname = stmt->relation->relname;
817-
else
818-
enr_relname = relname;
819-
820807
/*
821808
* Check consistency of arguments
822809
*/
@@ -1091,7 +1078,7 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
10911078
* passed in for immediate handling --- since they don't need parsing,
10921079
* they can be stored immediately.
10931080
*/
1094-
relationId = heap_create_with_catalog(enr_relname,
1081+
relationId = heap_create_with_catalog(relname,
10951082
namespaceId,
10961083
tablespaceId,
10971084
InvalidOid,
@@ -5834,23 +5821,6 @@ ATParseTransformCmd(List **wqueue, AlteredTableInfo *tab, Relation rel,
58345821
makeRangeVar(get_namespace_name(RelationGetNamespace(rel)),
58355822
pstrdup(RelationGetRelationName(rel)),
58365823
-1);
5837-
5838-
/*
5839-
* For T-SQL #temp tables with long names (>= NAMEDATALEN), the relation
5840-
* descriptor stores the name clipped to NAMEDATALEN-1 (63 chars) due to the
5841-
* Name type limitation. However, ENR stores the full untruncated name which
5842-
* is what subsequent lookups via RangeVarGetRelidExtended need to match.
5843-
* Replace the clipped relname with the full name from ENR.
5844-
*/
5845-
if (sql_dialect == SQL_DIALECT_TSQL &&
5846-
RelationGetRelationName(rel)[0] == '#')
5847-
{
5848-
EphemeralNamedRelation enr = get_ENR_withoid(currentQueryEnv,
5849-
RelationGetRelid(rel),
5850-
ENR_TSQL_TEMP, true);
5851-
if (enr)
5852-
atstmt->relation->relname = pstrdup(enr->md.name);
5853-
}
58545824
atstmt->relation->inh = recurse;
58555825
atstmt->cmds = list_make1(cmd);
58565826
atstmt->objtype = OBJECT_TABLE; /* needn't be picky here */

0 commit comments

Comments
 (0)