BUG #14408: Schema not found error when 2 or more indices declared on temporary table

From: vcolborn(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14408: Schema not found error when 2 or more indices declared on temporary table
Date: 2016-11-01 19:26:55
Message-ID: 20161101192655.15987.25903@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14408
Logged by: Victor Colborn
Email address: vcolborn(at)gmail(dot)com
PostgreSQL version: 9.6.1
Operating system: (Red Hat 4.4.7-16), 64-bit
Description:

I'm finding that this rather simple postgresql 9.6.1 function

CREATE OR REPLACE FUNCTION trying_to_index_me()
RETURNS VOID AS
$BODY$
BEGIN
CREATE Temporary TABLE temp_data_to_index (
id INTEGER NOT NULL,
this_id UUID NOT NULL,
that_id smallint NOT NULL,
CONSTRAINT idx_temp_data_to_index_unique
UNIQUE (id,this_id,that_id)
);
CREATE INDEX idx_temp_data_to_index_thisthat ON
temp_data_to_index(this_id,that_id);
DROP TABLE temp_data_to_index;
END;
$BODY$ LANGUAGE plpgsql VOLATILE COST 100;
--SELECT trying_to_index_me();

is resulting in a schema "" does not exist error. The exact error is:

ERROR: schema "" does not exist
CONTEXT: SQL statement "CREATE INDEX idx_temp_data_to_index_thisthat ON
temp_data_to_index(this_id,that_id)"
PL/pgSQL function trying_to_index_me() line 10 at SQL statement
********** Error **********
ERROR: schema "" does not exist
SQL state: 3F000
Context: SQL statement "CREATE INDEX idx_temp_data_to_index_thisthat ON
temp_data_to_index(this_id,that_id)"
PL/pgSQL function trying_to_index_me() line 10 at SQL statement

and occurs reliably on the second and subsequent executions. Cut/Pasting the
above SQL chunk reproduces the error...for me. Quite interested if that's
not the case elsewhere. I have the following clues:

It will error consistently once its in.
It always indicates the 'CREATE INDEX' line as the culprit of error.
Declaring the pg_temp temporary schema as '... ON pg_temp.temp_data_to_index
...' has no effect.
I find that if I drop the function and recreate it, I'll get one execution
and then the errored state will occur again.
Inserting records also had no effect on the error state.
I find that removing either idx_temp_data_to_index_thisthat or
idx_temp_data_to_index_unique resolves the issue.
It indicates the name of the not found schema to be "" or "0MA{Start of
Text}" or some similar variant with non-visible character values.
Truly appreciate your thoughts.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jamie Koceniak 2016-11-01 19:43:51 Re: BUG #14399: Order by id DESC causing bad query plan
Previous Message Tom Lane 2016-11-01 13:34:03 Re: BUG #14407: pg_attribute shows old column names for indexes