Commit 2fd6663f authored by craig[bot]'s avatar craig[bot]

Merge #48624 #48744 #48753

48624: sql: fix bug where show create could show partitions of dropped indexes r=rohany a=rohany

Release note (bug fix): Fix a bug where the `SHOW CREATE` statement
would sometimes show a partitioning step for an index that has been
dropped.

48744: sql: allow global access for pg_database table r=rafiss a=rafiss

In Postgres, this table is world-readable, so we should match.

fixes #48726

Release note (sql change): The pg_database table in pg_catalog
no longer require privileges on any database in order for the
data to be visible.

48753: interactive_tests: skip test_missing_log_output.tcl r=otan a=otan

Touches https://github.com/cockroachdb/cockroach/issues/48413 - this has flaked quite a few times for me in master / on bors.

Release note: None
Co-authored-by: default avatarRohan Yadav <[email protected]>
Co-authored-by: default avatarRafi Shamim <[email protected]>
Co-authored-by: default avatarOliver Tan <[email protected]>
#! /usr/bin/env expect -f
# disabled until #48413 is resolved.
source [file join [file dirname $argv0] common.tcl]
spawn /bin/bash
......
......@@ -2452,12 +2452,12 @@ CREATE TABLE crdb_internal.zones (
}
for i, s := range subzones {
index, err := table.FindIndexByID(sqlbase.IndexID(s.IndexID))
if err != nil {
if errors.Is(err, sqlbase.ErrIndexGCMutationsList) {
continue
}
return err
index := table.FindActiveIndexByID(sqlbase.IndexID(s.IndexID))
if index == nil {
// If we can't find an active index that corresponds to this index
// ID then continue, as the index is being dropped, or is already
// dropped and in the GC queue.
continue
}
if zoneSpecifier != nil {
zs := zs
......
......@@ -256,6 +256,19 @@ oid datname datconnlimit datlastsysoid datfrozenxid datminmxid datta
52 test -1 0 NULL NULL 0 NULL
54 constraint_db -1 0 NULL NULL 0 NULL
user testuser
# Should be globally visible
query OTIOIIOT colnames
SELECT oid, datname, datconnlimit, datlastsysoid, datfrozenxid, datminmxid, dattablespace, datacl
FROM pg_catalog.pg_database
ORDER BY oid LIMIT 1
----
oid datname datconnlimit datlastsysoid datfrozenxid datminmxid dattablespace datacl
1 system -1 0 NULL NULL 0 NULL
user root
## pg_catalog.pg_tables
statement ok
......
......@@ -1180,7 +1180,7 @@ CREATE TABLE pg_catalog.pg_database (
datacl STRING[]
)`,
populate: func(ctx context.Context, p *planner, _ *DatabaseDescriptor, addRow func(...tree.Datum) error) error {
return forEachDatabaseDesc(ctx, p, nil /*all databases*/, true, /* requiresPrivileges */
return forEachDatabaseDesc(ctx, p, nil /*all databases*/, false, /* requiresPrivileges */
func(db *sqlbase.DatabaseDescriptor) error {
return addRow(
dbOid(db.ID), // oid
......
......@@ -2933,6 +2933,21 @@ func (desc *TableDescriptor) FindIndexByID(id IndexID) (*IndexDescriptor, error)
return nil, fmt.Errorf("index-id \"%d\" does not exist", id)
}
// FindActiveIndexByID returns the index with the specified ID, or nil if it
// does not exist. It only searches active indexes.
func (desc *TableDescriptor) FindActiveIndexByID(id IndexID) *IndexDescriptor {
if desc.PrimaryIndex.ID == id {
return &desc.PrimaryIndex
}
for i := range desc.Indexes {
idx := &desc.Indexes[i]
if idx.ID == id {
return idx
}
}
return nil
}
// FindIndexByIndexIdx returns an active index with the specified
// index's index which has a domain of [0, # of secondary indexes] and whether
// the index is a secondary index.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment