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

Define all system variables in go type. #11269

Closed
SunRunAway opened this issue Jul 16, 2019 · 3 comments
Closed

Define all system variables in go type. #11269

SunRunAway opened this issue Jul 16, 2019 · 3 comments
Labels
duplicate Issues or pull requests already exists. 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. type/enhancement The issue or PR belongs to an enhancement.

Comments

@SunRunAway
Copy link
Contributor

SunRunAway commented Jul 16, 2019

Feature Request

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

For now, all system variables are defined in a map with type string.

	// systems variables, don't modify it directly, use GetSystemVar/SetSystemVar method.
	systems map[string]string

If we need a system variable in which the real type is an integer, for example, we must do string conversation. It's hard to code and bad to performance.

	valStr, _ := ctx.GetSessionVars().GetSystemVar(variable.MaxAllowedPacket)
	maxAllowedPacket, err := strconv.ParseUint(valStr, 10, 64)
	if err != nil {
		return nil, err
	}

Describe the feature you'd like:

We need to define all system variables with their real type in go code. So that all of them can be called directly without performance loss.

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

All the system variables defined in MySQL are located in https://github.com/mysql/mysql-server/blob/8.0/sql/system_variables.h#L174

@SunRunAway SunRunAway added the type/enhancement The issue or PR belongs to an enhancement. label Jul 16, 2019
@ngaut ngaut added 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. labels Jul 23, 2019
@kilgaloon
Copy link

kilgaloon commented Dec 7, 2019

I guess this can be mapped to interface{} then type asserted later for usage?

@ngaut
Copy link
Member

ngaut commented Dec 7, 2019

It's not a good idea, we should set system variables explicitly.

@ghost
Copy link

ghost commented Aug 3, 2020

This is required for fixing compatibility issues. i.e. When you run SHOW VARIABLES LIKE 'x' in MySQL you should get a string type, but SELECT @@x should return the actual type. I am tracking a request for typed variables in #15131 , so I am going to close this issue to reduce duplication. Thanks!

@ghost ghost added the duplicate Issues or pull requests already exists. label Aug 3, 2020
@ghost ghost closed this as completed Aug 3, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate Issues or pull requests already exists. 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. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

3 participants