Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate OIDs on Postgres ≥14 #25

Open
lacanoid opened this issue Apr 30, 2023 · 2 comments
Open

Duplicate OIDs on Postgres ≥14 #25

lacanoid opened this issue Apr 30, 2023 · 2 comments
Labels

Comments

@lacanoid
Copy link
Owner

Regression tests fail on PG 15. It seems that same OIDs are used for several distinct catalog objects, causing ddlx to dump a wrong object.

Investigate further and report to pgsql-hackers if necessary.

@lacanoid lacanoid changed the title Duplicate OIDs on Postgres ≥15 Duplicate OIDs on Postgres ≥14 May 15, 2023
@lacanoid
Copy link
Owner Author

lacanoid commented May 15, 2023

create or replace function crossoidcount(oid,oid) returns bigint language plpgsql as 
$$
declare s text; n bigint;
begin 
 s := format('select count(*) from %I a join %I b using (oid)',$1::regclass,$2::regclass);
 execute s into n; 
 return n;
end
$$;

with a as (
select attrelid::regclass as oid
  from pg_catalog.pg_attribute a 
  join pg_class c on (c.oid=attrelid)
 where c.relkind='r' and attname='oid' and atttypid='oid'::regtype
 order by attrelid
)
select *,crossoidcount(a1.oid,a2.oid) from a a1
  join a a2 on (a1.oid<a2.oid)
 where crossoidcount(a1.oid,a2.oid)>0
 order by 1,2;

@lacanoid lacanoid added the bug label May 15, 2023
@lacanoid
Copy link
Owner Author

lacanoid commented Sep 16, 2023

Postgres 13 and earlier

 oid | oid | crossoidcount 
-----+-----+---------------
(0 rows)

Postgres 14

    oid    |    oid     | crossoidcount 
-----------+------------+---------------
 pg_amop   | pg_amproc  |           697
 pg_amop   | pg_cast    |           230
 pg_amop   | pg_opclass |           164
 pg_amproc | pg_cast    |           230
 pg_amproc | pg_opclass |           164
 pg_cast   | pg_opclass |           164
(6 rows)

Postgres 15

      oid      |      oid      | crossoidcount 
---------------+---------------+---------------
 pg_type       | pg_amop       |           115
 pg_type       | pg_amproc     |           115
 pg_type       | pg_cast       |           115
 pg_type       | pg_opclass    |           115
 pg_amop       | pg_amproc     |           697
 pg_amop       | pg_cast       |           229
 pg_amop       | pg_constraint |           109
 pg_amop       | pg_opclass    |           164
 pg_amproc     | pg_cast       |           229
 pg_amproc     | pg_constraint |           109
 pg_amproc     | pg_opclass    |           164
 pg_cast       | pg_constraint |           109
 pg_cast       | pg_opclass    |           164
 pg_constraint | pg_opclass    |            49
(14 rows)

Postgres 16

       oid       |      oid      | crossoidcount 
-----------------+---------------+---------------
 pg_type         | pg_amop       |           115
 pg_type         | pg_amproc     |           115
 pg_type         | pg_cast       |           115
 pg_type         | pg_opclass    |           115
 pg_auth_members | pg_amop       |             3
 pg_auth_members | pg_amproc     |             3
 pg_auth_members | pg_cast       |             3
 pg_amop         | pg_amproc     |           697
 pg_amop         | pg_cast       |           229
 pg_amop         | pg_constraint |           110
 pg_amop         | pg_opclass    |           164
 pg_amproc       | pg_cast       |           229
 pg_amproc       | pg_constraint |           110
 pg_amproc       | pg_opclass    |           164
 pg_cast         | pg_constraint |           110
 pg_cast         | pg_opclass    |           164
 pg_constraint   | pg_opclass    |            49
(17 rows)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant