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

We can't execute update ... where colName ... when the column is WriteOnly state #15567

Closed
zimulala opened this issue Mar 23, 2020 · 11 comments · Fixed by #22307
Closed

We can't execute update ... where colName ... when the column is WriteOnly state #15567

zimulala opened this issue Mar 23, 2020 · 11 comments · Fixed by #22307
Assignees
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.

Comments

@zimulala
Copy link
Contributor

zimulala commented Mar 23, 2020

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. What did you do?

create table t (a int, b int)
insert into t values(1,1);

Do the following:

time connection1 connection2
t1 drop column b
t2 column state (write only) update t set a=5 where b=1;

2. What did you expect to see?

Retrun an error like [planner:1054]Unknown column 'b' in 'field list'.

3. What did you see instead?

Statement executed successfully

4. What version of TiDB are you using? (tidb-server -V or run select tidb_version(); on TiDB)

Release Version: v4.0.0-beta.2-46-gfd0235d03
Git Commit Hash: fd0235d
Git Branch: master

@zimulala zimulala added the type/bug The issue is confirmed as a bug. label Mar 23, 2020
@zimulala zimulala changed the title We can't when the column is We can't execute update ... where colName ... when the column is WriteOnly state Mar 23, 2020
@qw4990
Copy link
Contributor

qw4990 commented Mar 24, 2020

@zimulala Since #15539 has been merged, is this issue fixed and can we close it?

@zimulala
Copy link
Contributor Author

@qw4990
No. #15539 fix the issue of #15386.

@zz-jason zz-jason added the sig/sql-infra SIG: SQL Infra label Mar 24, 2020
@killua525
Copy link

expect execute successful
#15539 why return error?

@zimulala
Copy link
Contributor Author

zimulala commented May 6, 2020

@jzdxeb
Do you mean why update t set a =2 ,b=2 return an error when b's state is write-only?
Because clients only see the column when the column's state is public. So we can't update the value of b explicitly.

@killua525
Copy link

thx a lot

@killua525

This comment has been minimized.

@killua525
Copy link

in branch release 3.0

mysql> update t set b=5 where a=1;
ERROR 1054 (42S22): Unknown column 'b' in 'field list'
mysql> update t set a=5 where b=1;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

is expect ?

@zimulala
Copy link
Contributor Author

Column B in this scene is not public, is it? If column b is not public, it is the problem described by this issue. update t set a=5 where b=1; also needs to return an error.

@killua525
Copy link

branch master
commit f139821

update t set a=5 where b=1 return successfully

timeline

time connection1 connection2
t1 drop b
t2 update t set a=5 where b=1
t3 update t set b=5 where a=1
t4 drop b done
diff --git a/Makefile b/Makefile
index 793d44b7c..3af1e8137 100644
--- a/Makefile
+++ b/Makefile
@@ -214,9 +214,9 @@ endif

 server:
 ifeq ($(TARGET), "")
-       CGO_ENABLED=1 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server tidb-server/main.go
+       CGO_ENABLED=0 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o bin/tidb-server tidb-server/main.go
 else
-       CGO_ENABLED=1 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' tidb-server/main.go
+       CGO_ENABLED=0 $(GOBUILD) $(RACE_FLAG) -ldflags '$(LDFLAGS) $(CHECK_FLAG)' -o '$(TARGET)' tidb-server/main.go
 endif

 server_check:
diff --git a/ddl/column.go b/ddl/column.go
index a38c3afab..5e0cf9214 100644
--- a/ddl/column.go
+++ b/ddl/column.go
@@ -515,6 +515,7 @@ func onDropColumn(t *meta.Meta, job *model.Job) (ver int64, _ error) {
                }
                ver, err = updateVersionAndTableInfoWithCheck(t, job, tblInfo, originalState != colInfo.State)
        case model.StateWriteOnly:
+               time.Sleep(time.Second * 20)
                // write only -> delete only
                job.SchemaState = model.StateDeleteOnly
                colInfo.State = model.StateDeleteOnly

image

@wjhuang2016 wjhuang2016 added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Sep 8, 2020
@xiongjiwei
Copy link
Contributor

/assign

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. severity/moderate sig/sql-infra SIG: SQL Infra type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants