postgresql error: 'schema "" does not exist' on temporary table

postgresql error: 'schema "" does not exist' on temporary table

我发现这个相当简单的 postgresql 9.6 函数

CREATE OR REPLACE FUNCTION public.trying_to_index_me()
RETURNS VOID  AS
$BODY$
    BEGIN
    CREATE TABLE public.table_to_index ( 
        id INTEGER NOT NULL,    
        this_id UUID NOT NULL,
        that_id smallint NOT NULL,
        CONSTRAINT idx_table_to_index_unique
            UNIQUE (id,this_id,that_id)     
    ); 
    CREATE INDEX idx_table_to_index_thisthat ON public.table_to_index(this_id,that_id);  
    DROP TABLE public.table_to_index;
END;
$BODY$ LANGUAGE plpgsql;

--SELECT public.trying_to_index_me();

导致 schema "" does not exist error。确切的错误是:

ERROR:  schema "" does not exist
SQL state: 3F000
Context: SQL statement "CREATE INDEX idx_table_to_index_thisthat 
ON public.table_to_index(this_id,that_id)" 
PL/pgSQL function trying_to_index_me() line 10 at SQL statement

并且在第二次和后续执行中可靠地发生。 Cut/Pasting 上面的 SQL 块重现了错误……对我来说。如果您不是这种情况,我会很感兴趣。我有以下线索:

非常感谢您的想法。

我觉得 that_id smallint NOT NULL

后面少了一个逗号
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;

这似乎是由 citus 数据扩展引起的。该错误是由超过 2M 的默认堆栈后发生的内存损坏引起的。它不会出现在日志中,也不会出现本应抛出的 "stack depth limit exceeded" 异常。

这都是投机性的指责。

卸载 citus 扩展解决了我的问题。