Skip to content

Commit

Permalink
Ignore catalog (DB) name in multi-db handling logic for temp tables
Browse files Browse the repository at this point in the history

The schema name is set to NULL for temp tables because schema name is silently ignored in SQL server. But we didn't set the catalog (DB) name to NULL when one is provided. This causes a crash when  we  use the schema name in a string comparison. This commit addresses this issue by also setting the catalog (DB) name to NULL for temp tables

Task: BABEL-2692 
Author: Huansong Fu <[email protected]>
Signed-off-by: Sharu Goel <[email protected]>
  • Loading branch information
thephantomthief authored and nasbyj committed Feb 2, 2022
1 parent a947ed5 commit 8d9455b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/backend/parser/gram.y
Original file line number Diff line number Diff line change
Expand Up @@ -15108,10 +15108,11 @@ qualified_name:
case 2:
$$->catalogname = downcaseIfTsqlAndCaseInsensitive($1);
$$->schemaname = downcaseIfTsqlAndCaseInsensitive(strVal(linitial($2)));
/* TSQL temp table names. Schema name is allowed but ignored for temp tables.*/
/* TSQL temp table names. Catalog and schema names allowed but ignored for temp tables.*/
if (strncmp(strVal(lsecond($2)), "#", 1) == 0 || strncmp(strVal(lsecond($2)), "##", 2) == 0)
{
$$->relpersistence = RELPERSISTENCE_TEMP;
$$->catalogname = NULL;
$$->schemaname = NULL;
}
$$->relname = downcaseIfTsqlAndCaseInsensitive(strVal(lsecond($2)));
Expand Down

0 comments on commit 8d9455b

Please sign in to comment.