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: Define more columns in pg_catalog.pg_statistic_ext #93274

Merged
merged 1 commit into from
Dec 20, 2022

Conversation

e-mbrown
Copy link
Contributor

@e-mbrown e-mbrown commented Dec 8, 2022

Epic: CRDB-23454
Fixes: #88108
Fixes: #93430

This commit makes sure the stxnamespace, stxkind and stxstattarget columns are defined in pg_statistics_ext.

Release note: The stxnamespace, stxkind and
stxstattarget columns are now defined in
pg_statistics_ext. Also pg_statistics_ext
no longer crashes when stxname is null.

@e-mbrown e-mbrown requested review from knz and a team December 8, 2022 19:56
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

pls also take a review from @rafiss

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @e-mbrown)


-- commits line 7 at r1:
looks to me like a bug fix worthy of a release note.


pkg/sql/pg_catalog.go line 3465 at r1 (raw file):

		for _, row := range rows {
			tableID := tree.MustBeDInt(row[0])
			name := tree.MustBeDString(row[1])

Using MustBeDString for the name forces a heap allocation when you convert it back to a Datum below.
You could simply refer to row[1] in the addRow call below instead.


pkg/sql/pg_catalog.go line 3488 at r1 (raw file):

				schemaOid(statSchema),        // stxnamespace
				tree.DNull,                   // stxowner
				tree.NewDInt(-1),             // stxstattarget

You can allocate this DInt just once out of the loop.

@e-mbrown e-mbrown requested a review from rafiss December 8, 2022 20:11
@e-mbrown e-mbrown force-pushed the eb/statext branch 2 times, most recently from 6058fc2 to 0ad6ab3 Compare December 8, 2022 21:11
Copy link
Contributor Author

@e-mbrown e-mbrown left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @knz and @rafiss)


-- commits line 7 at r1:

Previously, knz (Raphael 'kena' Poss) wrote…

looks to me like a bug fix worthy of a release note.

Done.


pkg/sql/pg_catalog.go line 3465 at r1 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

Using MustBeDString for the name forces a heap allocation when you convert it back to a Datum below.
You could simply refer to row[1] in the addRow call below instead.

Done.


pkg/sql/pg_catalog.go line 3488 at r1 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

You can allocate this DInt just once out of the loop.

Done.

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

lgtm, with one nit!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @e-mbrown and @knz)


pkg/sql/pg_catalog.go line 3453 at r2 (raw file):

	schema: vtable.PgCatalogStatisticExt,
	populate: func(ctx context.Context, p *planner, db catalog.DatabaseDescriptor, addRow func(...tree.Datum) error) error {
		query := `SELECT "tableID", name, "columnIDs", "statisticID", '{d}'::CHAR[] FROM system.table_statistics;`

nit: the {d} value should be cast to "char"[]

also, can you add a comment explaining what d means here (based on the PG docs)

@jordanlewis
Copy link
Member

Hey @e-mbrown, coincidentally (unrelated to this PR!) I noticed this issue: #93430. Would you mind adding a fix for it while you're editing pg_statistic_ext?

Thanks!

`pg_catalog.pg_statistic_ext` is now
populated with more data.

Release note (bug fix): The `stxnamespace`, `stxkind` and
`stxstattarget` columns are now defined in
`pg_statistics_ext`.
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

nice fix! i'm adding a backport label as well

Reviewed 1 of 2 files at r3, 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @e-mbrown and @knz)

@e-mbrown
Copy link
Contributor Author

bors r=rafiss

@craig
Copy link
Contributor

craig bot commented Dec 20, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Dec 20, 2022

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Dec 20, 2022

Build succeeded:

@craig craig bot merged commit 56d249d into cockroachdb:master Dec 20, 2022
@blathers-crl
Copy link

blathers-crl bot commented Dec 20, 2022

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from 5fb4c60 to blathers/backport-release-22.1-93274: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.1.x failed. See errors above.


error creating merge commit from 5fb4c60 to blathers/backport-release-22.2-93274: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 22.2.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

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