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

Add show table $table_name next_row_id syntax #14567

Closed
crazycs520 opened this issue Jan 22, 2020 · 2 comments · Fixed by #14697
Closed

Add show table $table_name next_row_id syntax #14567

crazycs520 opened this issue Jan 22, 2020 · 2 comments · Fixed by #14697
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. sig/sql-infra SIG: SQL Infra type/usability

Comments

@crazycs520
Copy link
Contributor

crazycs520 commented Jan 22, 2020

Feature Request

Add show table $table_name next_row_id to get the next global table row id.

Is your feature request related to a problem? Please describe:

Currently, TiDB has admin show $table_name next_row_id to get the next global table row id.

But admin show syntax needs the super privilege. Getting the next_row_id no need to use super privilege, only use SELECT privilege will be ok. We can add show $table_name next_row_id syntax to get next_row_id.

Describe the feature you'd like:

test> show table test.t next_row_id;
+---------+------------+-------------+--------------------+
| DB_NAME | TABLE_NAME | COLUMN_NAME | NEXT_GLOBAL_ROW_ID |
+---------+------------+-------------+--------------------+
| test    | t          | _tidb_rowid | 30001              |
+---------+------------+-------------+--------------------+

Teachability, Documentation, Adoption, Migration Strategy:

For compatibility, we can't remove admin show $table_name next_row_id soon.

@crazycs520 crazycs520 added type/usability help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Jan 22, 2020
@zz-jason zz-jason added difficulty/easy good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels Jan 22, 2020
@zhang555
Copy link
Contributor

zhang555 commented Feb 6, 2020

I want solve this issue , but I have a problem .

For add show $table_name next_row_id syntax , I edit parser.y file .

before my edit :

ShowStmt:
	"SHOW" ShowTargetFilterable ShowLikeOrWhereOpt
	{
		stmt := $2.(*ast.ShowStmt)
		if $3 != nil {
			if x, ok := $3.(*ast.PatternLikeExpr); ok && x.Expr == nil {
				stmt.Pattern = x
			} else {
				stmt.Where = $3.(ast.ExprNode)
			}
		}
		$$ = stmt
	}
|	"SHOW" "CREATE" "TABLE" TableName
	{
		$$ = &ast.ShowStmt{
			Tp:    ast.ShowCreateTable,
			Table: $4.(*ast.TableName),
		}
	}

after my edit :

ShowStmt:
	"SHOW" ShowTargetFilterable ShowLikeOrWhereOpt
	{
		stmt := $2.(*ast.ShowStmt)
		if $3 != nil {
			if x, ok := $3.(*ast.PatternLikeExpr); ok && x.Expr == nil {
				stmt.Pattern = x
			} else {
				stmt.Where = $3.(ast.ExprNode)
			}
		}
		$$ = stmt
	}
|	"SHOW" TableName "NEXT_ROW_ID"
	{
		$$ = &ast.ShowStmt{
			Tp:     ast.ShowTableNextRowId,
			Tables: []*ast.TableName{$2.(*ast.TableName)},
		}
	}
|	"SHOW" "CREATE" "TABLE" TableName
	{
		$$ = &ast.ShowStmt{
			Tp:    ast.ShowCreateTable,
			Table: $4.(*ast.TableName),
		}
	}

but when I make it , I get a error :

gofmt (simplify)
bin/goyacc -o parser.go -p yy -t Parser parser.y
conflicts: 1 reduce/reduce
conflicts: 7 shift/reduce
Please check y.output for more information
make: *** [parser.go] Error 1

what went wrong with parser.y file ?

@crazycs520
Copy link
Contributor Author

@zhang555 , Thanks for your contribution.
After consideration, since SHOW syntax has many syntaxes,
SHOW TALBLE $table_name NEXT_ROW_ID maybe a better syntax.

zhang555 added a commit to zhang555/tidb that referenced this issue Feb 8, 2020
Signed-off-by: zhang555 <4598181@qq.com>

planner: add `show table $table_name next_row_id` syntax (pingcap#14567)

Signed-off-by: zhang555 <4598181@qq.com>
zhang555 added a commit to zhang555/tidb that referenced this issue Feb 8, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Feb 9, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Feb 9, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Feb 9, 2020
@crazycs520 crazycs520 changed the title Add show $table_name next_row_id syntax Add show table $table_name next_row_id syntax Feb 17, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 1, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 1, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 1, 2020
Signed-off-by: zhang555 <4598181@qq.com>

planner: add `show table $table_name next_row_id` syntax (pingcap#14567)

Signed-off-by: zhang555 <4598181@qq.com>
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 1, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 1, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 1, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 1, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 1, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 1, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 3, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 3, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 5, 2020
zhang555 added a commit to zhang555/tidb that referenced this issue Mar 14, 2020
@zz-jason zz-jason added the sig/sql-infra SIG: SQL Infra label Mar 14, 2020
sthagen added a commit to sthagen/pingcap-tidb that referenced this issue Mar 14, 2020
planner: add `show table $table_name next_row_id` syntax (pingcap#14567) (#1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. sig/sql-infra SIG: SQL Infra type/usability
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants