1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +03:00

Fix another bit of unlogged-table-induced breakage.

Per bug #6205, reported by Abel Abraham Camarillo Ojeda.  This isn't a
particularly elegant fix, but I'm trying to minimize the chances of
causing yet another round of breakage.

Adjust regression tests to exercise this case.
This commit is contained in:
Robert Haas
2011-09-21 10:47:47 -04:00
parent c47e629498
commit c67bba9925
3 changed files with 36 additions and 22 deletions

View File

@@ -221,7 +221,6 @@ Datum pg_is_other_temp_schema(PG_FUNCTION_ARGS);
Oid
RangeVarGetRelid(const RangeVar *relation, bool failOK)
{
Oid namespaceId;
Oid relId;
/*
@@ -247,17 +246,27 @@ RangeVarGetRelid(const RangeVar *relation, bool failOK)
*/
if (relation->relpersistence == RELPERSISTENCE_TEMP)
{
if (relation->schemaname)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("temporary tables cannot specify a schema name")));
if (OidIsValid(myTempNamespace))
if (!OidIsValid(myTempNamespace))
relId = InvalidOid; /* this probably can't happen? */
else
{
if (relation->schemaname)
{
Oid namespaceId;
namespaceId = LookupExplicitNamespace(relation->schemaname);
if (namespaceId != myTempNamespace)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("temporary tables cannot specify a schema name")));
}
relId = get_relname_relid(relation->relname, myTempNamespace);
else /* this probably can't happen? */
relId = InvalidOid;
}
}
else if (relation->schemaname)
{
Oid namespaceId;
/* use exact schema given */
namespaceId = LookupExplicitNamespace(relation->schemaname);
relId = get_relname_relid(relation->relname, namespaceId);