-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
PostgreSQL divergence: pg_class entries do not always have equivalent representation in pg_type #66576
Comments
Hello, I am Blathers. I am here to help you get the issue triaged. Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here. I have CC'd a few people who may be able to assist you:
If we have not gotten back to your issue within a few business days, you can try the following:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
Thanks @benjie -- we'll look into it and see what we can do here. Out of curiosity, how does Graphile use the pg_type info for table names? I'm curious if we could get away with a limited subset of info. |
We use the type in general to refer to the composite type since that's what referenced from function arguments and similar situations. I think we generally just use it for the name of the type for casting purposes, determining array variants, etc. The most intense usage of Note we alias the various pg_type columns; you can see that in our introspection query here: I think the most important columns for us are:
|
@otan could you pick this one up? here's a few details that might make this a little tricky:
|
This also means that casts to Currently, |
i guess it can be 10000+descriptor_id, like we do for user defined types |
Out of curiosity, what happens if we make |
well oids are basically meaningless anyway, since a pg_type oid and a pg_class oid may represent completely different things :\ so with that grim analysis, the least we can do is make pg_type.oid unique, i.e. 10000 + descriptor_id. typrelid should point to the descriptor id (since it is pg_class). however, the array type id is a problem as it can collide as we only allocate 1 id for a table, but we need to allocate 2 ids for a type to include the allocated array type :\ |
We can also kick the can down the road for pg_class array types by not giving them an array type. But I'm not sure how many ORMs rely on every type having an array type... The docs seem to suggest it is possible to not have an array type:
|
@benjie i'm trying to understand why the pg_class in pg_type is helpful to you here. Unfortunately there's no really clean way of representing pg_class as pg_type as we did not reserve enough OIDs. Can you determine when this data is useful? In particular, i'm trying to gauge whether the array variant is required for you. e.g. if I create a table |
Postgres generally refers to the type e.g. for function args, function return types, column types, domains, etc, so we use it quite heavily. I think we only need the array variant if an array variant is represented in the database somewhere. Mostly we just read what "types" things are from Postgres (e.g. function arguments) and then we look up those types in the introspection results. If you don't have user defined functions and none of your built in functions can either accept or return an array of a composite type then I think we're okay for the list type? |
Describe the problem
From the Postgres docs:
These automatically created types are not represented in Cockroach.
To Reproduce
Create the following table (in the
public
schema):Then run the following:
Notice that there's no pg_type entry for this pg_class.
Expected behavior
Postgres automatically creates the type:
Environment:
psql
(Postgres v13)The text was updated successfully, but these errors were encountered: