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: SHOW TABLES marks a dropped table with a " (dropped)" suffix #10063

Merged
merged 2 commits into from
Oct 27, 2016

Conversation

vivekmenezes
Copy link
Contributor

@vivekmenezes vivekmenezes commented Oct 18, 2016

fixes #9318

Added another commit that renames table deleted to table dropped for #9493


This change is Reviewable

@dt
Copy link
Member

dt commented Oct 18, 2016

hm, how do we feel about show tables and the introspection meta tables (pg_* and information_schema) being different?

@dt
Copy link
Member

dt commented Oct 18, 2016

I wonder if we should just change desc.Name in-place when we flip the Deleted bit, so all the paths read the same thing

@vivekmenezes
Copy link
Contributor Author

I'm not familiar with what you're talking about. What's broken here?

@dt
Copy link
Member

dt commented Oct 18, 2016

in addition to SHOW TABLES, we support reflecting on tables using the metatables in information_schema or pg_catalog. Having show tables show one name while they show something else is potentially confusing (plus there's a goal to unify their implementation, potentially replacing the SHOW commands with queries into the meta tables). While this isn't broken yet, it just introduces inconsistency when it's only implemented here.

@knz
Copy link
Contributor

knz commented Oct 18, 2016

I'd recommend linking this with #9966.

@andreimatei
Copy link
Contributor

LGTM

this looks to me like a quick fix for something that has come up many times. Whether or not the table should appear in information schema is a valid question; I'd say leave it alone there, since we probably shouldn't be massaging names like we're doing in the SHOW output.
Once we back the implementation of SHOW TABLES with queries in info schema, we can still continue doing this massaging, I think that's fair.


// Check that SHOW TABLES marks a deleted table with the " (deleted)"
// suffix.
rows, err := t.db.Query(`SHOW TABLES FROM test`)
Copy link
Contributor

Choose a reason for hiding this comment

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

defer rows.Close()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -401,7 +401,8 @@ func TestLeaseManagerPublishVersionChanged(testingT *testing.T) {
t.expectLeases(descID, "/3/1")
}

// Test that we fail to lease a table that was marked for deletion.
// Test that we fail to lease a table that was marked for deletion. This also
// tests that SHOW TABLES marks a deleted table with the " (deleted)" suffix.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it'd be more natural for this to be a test on SHOW TABLES

Copy link
Contributor Author

@vivekmenezes vivekmenezes Oct 21, 2016

Choose a reason for hiding this comment

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

Done. Moved to drop_test.go as way for us to test a variety of operations while a table is being dropped.

@vivekmenezes vivekmenezes force-pushed the showtables branch 4 times, most recently from 131deae to 973b2f8 Compare October 21, 2016 19:50
@vivekmenezes vivekmenezes changed the title sql: SHOW TABLES marks a deleted table with a " (deleted)" suffix sql: SHOW TABLES marks a dropped table with a " (dropped)" suffix Oct 21, 2016
@vivekmenezes vivekmenezes force-pushed the showtables branch 2 times, most recently from 0094377 to 8651da9 Compare October 21, 2016 21:37
Change the error message when a DROP TABLE tried to drop a
table that has already been dropped. Added tests for error
messages observed with CREATE and DROP commands while a
 table is being dropped.

fixes cockroachdb#9318
@vivekmenezes
Copy link
Contributor Author

Any thoughts on this PR?

@andreimatei
Copy link
Contributor

Still LGTM as far as I'm concerned.
Was there a particular point to r3? If not, there is a cost to churn...


Review status: 0 of 9 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful.


pkg/sql/drop_test.go, line 502 at r2 (raw file):

      t.Fatal("table invisible through SHOW TABLES")
  }
  var val []byte

can't this be a string?


Comments from Reviewable

@vivekmenezes
Copy link
Contributor Author

The dropped versus deleted incompatibility was driving me crazy!


Review status: 0 of 9 files reviewed at latest revision, 3 unresolved discussions, some commit checks pending.


pkg/sql/drop_test.go, line 502 at r2 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

can't this be a string?

Yes it can. I was under the impression that a string was immutable: https://golang.org/ref/spec#String_types

I'm puzzled by what they mean by immutable


Comments from Reviewable

@andreimatei
Copy link
Contributor

Review status: 0 of 9 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful.


pkg/sql/drop_test.go, line 502 at r2 (raw file):

Previously, vivekmenezes wrote…

Yes it can. I was under the impression that a string was immutable: https://golang.org/ref/spec#String_types

I'm puzzled by what they mean by immutable

the mean that you can't change the contents of a string instance. Here you're passing a pointer to a string to `Scan`, and the instance being pointed to will be overwritten by a completely new instance.

Comments from Reviewable

@vivekmenezes vivekmenezes merged commit e96b448 into cockroachdb:master Oct 27, 2016
@vivekmenezes vivekmenezes deleted the showtables branch October 27, 2016 19:57
@tamird
Copy link
Contributor

tamird commented Oct 27, 2016

Reviewed 9 of 9 files at r3.
Review status: all files reviewed at latest revision, 5 unresolved discussions, all commit checks successful.


pkg/sql/drop_test.go, line 470 at r3 (raw file):

  params.Knobs = base.TestingKnobs{
      SQLSchemaChanger: &sql.SchemaChangerTestingKnobs{
          SyncFilter: func(tscc sql.TestingSchemaChangerCollection) {

FYI: this can be written as SyncFilter: (*sql.TestingSchemaChangerCollection).ClearSchemaChangers. Just sharing.


pkg/sql/show.go, line 668 at r3 (raw file):

              tableName := name.Table()
              // Check to see if the table has been dropped.
              if _, err := p.mustGetTableOrViewDesc(&name); err != nil {

NYC but a function called mustGet... returns an error? What has the world come to?


Comments from Reviewable

@jseldess jseldess removed the docs-todo label Nov 3, 2016
pav-kv pushed a commit to pav-kv/cockroach that referenced this pull request Mar 5, 2024
…nation

raft: fix correctness bug in CommittedEntries pagination
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: DROP does not properly mark tables as deleted
6 participants