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

sql: populate the pg_enum catalog table #49213

Merged
merged 1 commit into from
May 20, 2020
Merged

Conversation

rohany
Copy link
Contributor

@rohany rohany commented May 18, 2020

Fixes #48359.

Release note (sql change): Populate the catalog table
pg_catalog.pg_enum.

@rohany rohany requested review from jordanlewis and otan May 18, 2020 19:20
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rohany
Copy link
Contributor Author

rohany commented May 18, 2020

Look at the second commit please!

I did the oid generation with hashing -- I think it's fine for this table. A reasonable index would be on enumtypoid not oid, so hashing doesn't affect that.

// internally using floats for ordering like Postgres, so just pick a
// float entry for the rows.
typ := types.MakeEnum(uint32(typDesc.ID))
if err := typDesc.HydrateTypeInfo(typ); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stay hydrated!
(why didn't we call this InitTypeInfo? hah.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK, someone said Hydrate once and then I couldn't get it out of my head

typOID := tree.NewDOid(tree.DInt(typ.Oid()))
for i := range enumData.LogicalRepresentations {
if err := addRow(
h.EnumEntryOid(typOID, enumData.PhysicalRepresentations[i]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this change every time the ENUM changes? if so that seems bad.
can we use some sort of other unique identifier? typDesc.ID seems better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the physical representations are static. Either way, IDT we could do typDesc.ID because each row here needs a new OID.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right, i totally missed that this is happening on each logical repr.

Copy link
Contributor

@otan otan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if physical repr stay the same, LGTM!

Fixes cockroachdb#48359.

Release note (sql change): Populate the catalog table
`pg_catalog.pg_enum`.
@rohany
Copy link
Contributor Author

rohany commented May 20, 2020

TFTR

bors r+

@craig
Copy link
Contributor

craig bot commented May 20, 2020

Build succeeded

@craig craig bot merged commit 1bd13e7 into cockroachdb:master May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: populate the pg_enum table
3 participants