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

Primary key column not found #38935

Closed
ChenPeng2013 opened this issue Nov 7, 2022 · 5 comments
Closed

Primary key column not found #38935

ChenPeng2013 opened this issue Nov 7, 2022 · 5 comments
Assignees
Labels
affects-6.4 affects-6.5 may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 severity/major sig/planner SIG: Planner type/bug This issue is a bug.

Comments

@ChenPeng2013
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

use test; 
drop table if exists t2;
CREATE TABLE `t2` (
  `pk` varchar(255) NOT NULL,
  `c_i` int(11) DEFAULT NULL,
  `c_ui` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`pk`) /*T![clustered_index] CLUSTERED */,
  UNIQUE KEY `uniq_c_ui` (`c_ui`),
  KEY `idx_c_i` (`c_i`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
INSERT INTO `t2` VALUES ('3d81248c-cc8b-45e1-98ca-d5e9c2917d56',-992760534,'5fc0d15e-7b15-494c-80c2-54daf3443b74'),('5719acb4-3de6-4c98-a096-3306d1ca0233',-1261265135,'a932b7ce-d568-4813-ba6c-72a0f447aba7'),('571d43ca-ca38-493c-8508-0df8ad0931cd',-1088540202,'121050d2-1bcd-4632-adf8-6188755519b8'),('72e46cf8-f552-4030-93f0-8a454ebbc682',1086248921,'b8951863-40a9-4be2-a772-d0188b23eae3'),('a3fe795e-09ef-484d-a8a6-d194b084526a',-81222597,'f7b4b988-4a3e-46f0-8849-d4fa9288f748'),('a5e1a888-3df6-441c-8d4d-ed843f6c8533',-1549645063,'0ceaee09-f017-4095-b24e-8d9fcf05afc2'),('d9a25671-06b4-47be-a906-8ccf2daef6db',2133220521,'0ad4da8f-eed2-4b6e-852e-6dd459c9daeb'),('e2d25fe7-e088-411c-af4a-7b0aaec74f52',1072287519,'804c035a-88d3-409a-90e3-84409afa98ff'),('f18b943e-ae67-44d6-8914-591b8b5d0c54',444588401,'95ef041f-c981-4a9b-81ee-6df96ba47420'),('ff177750-d09d-42b3-845c-ca5f673c1c90',1625870362,'18ffc5ad-5ad6-453d-a99d-af67997bb680');
set tidb_enable_fast_analyze=on;
set tidb_analyze_version=1;
analyze table t2;

2. What did you expect to see? (Required)

3. What did you see instead (Required)

MySQL [test]> analyze table t2;
ERROR 1105 (HY000): Primary key column not found

4. What is your TiDB version? (Required)

Release Version: v6.4.0-alpha-246-g00b99ec17
Edition: Community
Git Commit Hash: 00b99ec17ec4345db07849327cc16295e75235e4
Git Branch: release-6.4
UTC Build Time: 2022-11-07 03:49:58
GoVersion: go1.19.1
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore
@ChenPeng2013 ChenPeng2013 added type/bug This issue is a bug. sig/planner SIG: Planner severity/major labels Nov 7, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 labels Nov 7, 2022
@wxbty
Copy link
Contributor

wxbty commented Nov 8, 2022

/assign

@wxbty
Copy link
Contributor

wxbty commented Nov 8, 2022

The steps to reproduce this problem can be simplified as follows:

use test;
drop table if exists t2;
CREATE TABLE t2 (pk varchar(15) NOT NULL,PRIMARY KEY (pk)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
INSERT INTO t2 VALUES ('1892')
set tidb_enable_fast_analyze=on;
set tidb_analyze_version=1;
analyze table t2;

If the primary key is a string type, an error will be reported.
If replace it with the following,will show successful result:

CREATE TABLE t2 (pk int(15) NOT NULL,PRIMARY KEY (pk)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
INSERT INTO t2 VALUES (1892)

@wxbty
Copy link
Contributor

wxbty commented Nov 11, 2022

hi, @ChenPeng2013
You may need to verify the scope of influence and mark it with effects_x

@ChenPeng2013
Copy link
Contributor Author

fast analyze will be deprecated, close this issue ? @chrysan

@chrysan
Copy link
Contributor

chrysan commented Dec 14, 2022

Fast analyze will be deprecated, close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.4 affects-6.5 may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 severity/major sig/planner SIG: Planner type/bug This issue is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants