[HACKERS] Index created in BEFORE trigger not updated during INSERT

Поиск
Список
Период
Сортировка
От Albe Laurenz
Тема [HACKERS] Index created in BEFORE trigger not updated during INSERT
Дата
Msg-id A737B7A37273E048B164557ADEF4A58B53A4DC9A@ntex2010i.host.magwien.gv.at
обсуждение исходный текст
Ответы Re: [HACKERS] Index created in BEFORE trigger not updated during INSERT  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Not that it is a useful use case, but I believe that this is
a bug that causes index corruption:

CREATE TABLE mytable(  id integer PRIMARY KEY,  id2 integer NOT NULL
);

CREATE FUNCTION makeindex() RETURNS trigger  LANGUAGE plpgsql AS
$$BEGIN  CREATE INDEX ON mytable(id2);  RETURN NEW;
END;$$;

CREATE TRIGGER makeindex BEFORE INSERT ON mytable FOR EACH ROW  EXECUTE PROCEDURE makeindex();

INSERT INTO mytable VALUES (1, 42);

SELECT * FROM mytable;
┌────┬─────┐
│ id │ id2 │
├────┼─────┤
│  1 │  42 │
└────┴─────┘
(1 row)

But 42 is not present in the index:

SET enable_seqscan = off;

SELECT * FROM mytable WHERE id2 = 42;
┌────┬─────┐
│ id │ id2 │
├────┼─────┤
└────┴─────┘
(0 rows)

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Kuntal Ghosh
Дата:
Сообщение: Re: [HACKERS] "create publication..all tables" ignore 'partition notsupported' error
Следующее
От: Kuntal Ghosh
Дата:
Сообщение: Re: [HACKERS] pg_dump ignoring information_schema tables which usedin Create Publication.