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

About ParseTableName #30

Open
cassiaman7 opened this issue Nov 1, 2024 · 0 comments
Open

About ParseTableName #30

cassiaman7 opened this issue Nov 1, 2024 · 0 comments

Comments

@cassiaman7
Copy link

what does function ParseTableName mean?

// in file: pkg/sql/parser/parser.go:253
func ParseTableName(sql string) (*tree.UnresolvedObjectName, error) {
	// We wrap the name we want to parse into a dummy statement since our parser
	// can only parse full statements.
	stmt, err := ParseOne(fmt.Sprintf("ALTER TABLE %s RENAME TO x", sql))
	if err != nil {
		return nil, err
	}
	rename, ok := stmt.AST.(*tree.RenameTable)
	if !ok {
		return nil, errors.AssertionFailedf("expected an ALTER TABLE statement, but found %T", stmt)
	}
	return rename.Name, nil
}

I think this function maybe parser tableName From a sql.
But when put sql into ALTER TABLE %s RENAME TO x, It mustn't be parsed ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant