1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-02 09:02:37 +03:00

Fix DROP OPERATOR to reset oprcom/oprnegate links to the dropped operator.

This avoids leaving dangling links in pg_operator; which while fairly
harmless are also unsightly.

While we're at it, simplify OperatorUpd, which went through
heap_modify_tuple for no very good reason considering it had already made
a tuple copy it could just scribble on.

Roma Sokolov, reviewed by Tomas Vondra, additional hacking by Robert Haas
and myself.
This commit is contained in:
Tom Lane
2016-03-25 12:33:16 -04:00
parent d543170f2f
commit c94959d411
7 changed files with 237 additions and 99 deletions

View File

@ -0,0 +1,61 @@
CREATE OPERATOR === (
PROCEDURE = int8eq,
LEFTARG = bigint,
RIGHTARG = bigint,
COMMUTATOR = ===
);
CREATE OPERATOR !== (
PROCEDURE = int8ne,
LEFTARG = bigint,
RIGHTARG = bigint,
NEGATOR = ===,
COMMUTATOR = !==
);
DROP OPERATOR !==(bigint, bigint);
SELECT ctid, oprcom
FROM pg_catalog.pg_operator fk
WHERE oprcom != 0 AND
NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprcom);
ctid | oprcom
------+--------
(0 rows)
SELECT ctid, oprnegate
FROM pg_catalog.pg_operator fk
WHERE oprnegate != 0 AND
NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprnegate);
ctid | oprnegate
------+-----------
(0 rows)
DROP OPERATOR ===(bigint, bigint);
CREATE OPERATOR <| (
PROCEDURE = int8lt,
LEFTARG = bigint,
RIGHTARG = bigint
);
CREATE OPERATOR |> (
PROCEDURE = int8gt,
LEFTARG = bigint,
RIGHTARG = bigint,
NEGATOR = <|,
COMMUTATOR = <|
);
DROP OPERATOR |>(bigint, bigint);
SELECT ctid, oprcom
FROM pg_catalog.pg_operator fk
WHERE oprcom != 0 AND
NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprcom);
ctid | oprcom
------+--------
(0 rows)
SELECT ctid, oprnegate
FROM pg_catalog.pg_operator fk
WHERE oprnegate != 0 AND
NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprnegate);
ctid | oprnegate
------+-----------
(0 rows)
DROP OPERATOR <|(bigint, bigint);

View File

@ -84,7 +84,7 @@ test: select_into select_distinct select_distinct_on select_implicit select_havi
# ----------
# Another group of parallel tests
# ----------
test: brin gin gist spgist privileges security_label collate matview lock replica_identity rowsecurity object_address tablesample groupingsets
test: brin gin gist spgist privileges security_label collate matview lock replica_identity rowsecurity object_address tablesample groupingsets drop_operator
# ----------
# Another group of parallel tests

View File

@ -89,7 +89,6 @@ test: union
test: case
test: join
test: aggregates
test: groupingsets
test: transactions
ignore: random
test: random
@ -114,6 +113,8 @@ test: replica_identity
test: rowsecurity
test: object_address
test: tablesample
test: groupingsets
test: drop_operator
test: alter_generic
test: alter_operator
test: misc

View File

@ -0,0 +1,56 @@
CREATE OPERATOR === (
PROCEDURE = int8eq,
LEFTARG = bigint,
RIGHTARG = bigint,
COMMUTATOR = ===
);
CREATE OPERATOR !== (
PROCEDURE = int8ne,
LEFTARG = bigint,
RIGHTARG = bigint,
NEGATOR = ===,
COMMUTATOR = !==
);
DROP OPERATOR !==(bigint, bigint);
SELECT ctid, oprcom
FROM pg_catalog.pg_operator fk
WHERE oprcom != 0 AND
NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprcom);
SELECT ctid, oprnegate
FROM pg_catalog.pg_operator fk
WHERE oprnegate != 0 AND
NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprnegate);
DROP OPERATOR ===(bigint, bigint);
CREATE OPERATOR <| (
PROCEDURE = int8lt,
LEFTARG = bigint,
RIGHTARG = bigint
);
CREATE OPERATOR |> (
PROCEDURE = int8gt,
LEFTARG = bigint,
RIGHTARG = bigint,
NEGATOR = <|,
COMMUTATOR = <|
);
DROP OPERATOR |>(bigint, bigint);
SELECT ctid, oprcom
FROM pg_catalog.pg_operator fk
WHERE oprcom != 0 AND
NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprcom);
SELECT ctid, oprnegate
FROM pg_catalog.pg_operator fk
WHERE oprnegate != 0 AND
NOT EXISTS(SELECT 1 FROM pg_catalog.pg_operator pk WHERE pk.oid = fk.oprnegate);
DROP OPERATOR <|(bigint, bigint);