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:
parent
2562dcea81
commit
4893552e21
|
@ -225,7 +225,6 @@ RangeVarGetRelid(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok,
|
||||||
bool nowait)
|
bool nowait)
|
||||||
{
|
{
|
||||||
uint64 inval_count;
|
uint64 inval_count;
|
||||||
Oid namespaceId;
|
|
||||||
Oid relId;
|
Oid relId;
|
||||||
Oid oldRelId = InvalidOid;
|
Oid oldRelId = InvalidOid;
|
||||||
bool retry = false;
|
bool retry = false;
|
||||||
|
@ -278,17 +277,27 @@ RangeVarGetRelid(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok,
|
||||||
*/
|
*/
|
||||||
if (relation->relpersistence == RELPERSISTENCE_TEMP)
|
if (relation->relpersistence == RELPERSISTENCE_TEMP)
|
||||||
{
|
{
|
||||||
if (relation->schemaname)
|
if (!OidIsValid(myTempNamespace))
|
||||||
ereport(ERROR,
|
relId = InvalidOid; /* this probably can't happen? */
|
||||||
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
|
else
|
||||||
errmsg("temporary tables cannot specify a schema name")));
|
{
|
||||||
if (OidIsValid(myTempNamespace))
|
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);
|
relId = get_relname_relid(relation->relname, myTempNamespace);
|
||||||
else /* this probably can't happen? */
|
}
|
||||||
relId = InvalidOid;
|
|
||||||
}
|
}
|
||||||
else if (relation->schemaname)
|
else if (relation->schemaname)
|
||||||
{
|
{
|
||||||
|
Oid namespaceId;
|
||||||
|
|
||||||
/* use exact schema given */
|
/* use exact schema given */
|
||||||
namespaceId = LookupExplicitNamespace(relation->schemaname);
|
namespaceId = LookupExplicitNamespace(relation->schemaname);
|
||||||
relId = get_relname_relid(relation->relname, namespaceId);
|
relId = get_relname_relid(relation->relname, namespaceId);
|
||||||
|
|
|
@ -204,14 +204,19 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
|
||||||
t text
|
t text
|
||||||
);
|
);
|
||||||
NOTICE: relation "test_tsvector" already exists, skipping
|
NOTICE: relation "test_tsvector" already exists, skipping
|
||||||
CREATE UNLOGGED TABLE unlogged1 (a int); -- OK
|
CREATE UNLOGGED TABLE unlogged1 (a int primary key); -- OK
|
||||||
|
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "unlogged1_pkey" for table "unlogged1"
|
||||||
INSERT INTO unlogged1 VALUES (42);
|
INSERT INTO unlogged1 VALUES (42);
|
||||||
CREATE UNLOGGED TABLE public.unlogged2 (a int); -- also OK
|
CREATE UNLOGGED TABLE public.unlogged2 (a int primary key); -- also OK
|
||||||
CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int); -- not OK
|
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "unlogged2_pkey" for table "unlogged2"
|
||||||
|
CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key); -- not OK
|
||||||
ERROR: only temporary relations may be created in temporary schemas
|
ERROR: only temporary relations may be created in temporary schemas
|
||||||
CREATE TABLE pg_temp.implicity_temp (a int); -- OK
|
CREATE TABLE pg_temp.implicitly_temp (a int primary key); -- OK
|
||||||
CREATE TEMP TABLE explicitly_temp (a int); -- also OK
|
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "implicitly_temp_pkey" for table "implicitly_temp"
|
||||||
CREATE TEMP TABLE pg_temp.doubly_temp (a int); -- also OK
|
CREATE TEMP TABLE explicitly_temp (a int primary key); -- also OK
|
||||||
CREATE TEMP TABLE public.temp_to_perm (a int); -- not OK
|
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "explicitly_temp_pkey" for table "explicitly_temp"
|
||||||
|
CREATE TEMP TABLE pg_temp.doubly_temp (a int primary key); -- also OK
|
||||||
|
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "doubly_temp_pkey" for table "doubly_temp"
|
||||||
|
CREATE TEMP TABLE public.temp_to_perm (a int primary key); -- not OK
|
||||||
ERROR: cannot create temporary relation in non-temporary schema
|
ERROR: cannot create temporary relation in non-temporary schema
|
||||||
DROP TABLE unlogged1, public.unlogged2;
|
DROP TABLE unlogged1, public.unlogged2;
|
||||||
|
|
|
@ -241,12 +241,12 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
|
||||||
t text
|
t text
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE UNLOGGED TABLE unlogged1 (a int); -- OK
|
CREATE UNLOGGED TABLE unlogged1 (a int primary key); -- OK
|
||||||
INSERT INTO unlogged1 VALUES (42);
|
INSERT INTO unlogged1 VALUES (42);
|
||||||
CREATE UNLOGGED TABLE public.unlogged2 (a int); -- also OK
|
CREATE UNLOGGED TABLE public.unlogged2 (a int primary key); -- also OK
|
||||||
CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int); -- not OK
|
CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key); -- not OK
|
||||||
CREATE TABLE pg_temp.implicity_temp (a int); -- OK
|
CREATE TABLE pg_temp.implicitly_temp (a int primary key); -- OK
|
||||||
CREATE TEMP TABLE explicitly_temp (a int); -- also OK
|
CREATE TEMP TABLE explicitly_temp (a int primary key); -- also OK
|
||||||
CREATE TEMP TABLE pg_temp.doubly_temp (a int); -- also OK
|
CREATE TEMP TABLE pg_temp.doubly_temp (a int primary key); -- also OK
|
||||||
CREATE TEMP TABLE public.temp_to_perm (a int); -- not OK
|
CREATE TEMP TABLE public.temp_to_perm (a int primary key); -- not OK
|
||||||
DROP TABLE unlogged1, public.unlogged2;
|
DROP TABLE unlogged1, public.unlogged2;
|
||||||
|
|
Loading…
Reference in New Issue