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

varchar2 support #3387

Open
yitsushi opened this issue May 16, 2024 · 1 comment
Open

varchar2 support #3387

yitsushi opened this issue May 16, 2024 · 1 comment
Labels
enhancement New feature or request triage New issues that hasn't been reviewed

Comments

@yitsushi
Copy link

yitsushi commented May 16, 2024

What do you want to change?

Oracle has a varchar2 datatype, and it's the same as varchar (at least for now), but it can change in the future. Because of some scanning tools, like SonarCube yells at us to use varchar2 with the following reason:

Currently, VARCHAR and VARCHAR2 are identical data types. But to prevent future changes in behavior, Oracle recommends the use of VARCHAR2.

  • varchar is ANSI, varchar2 is Oracle.
  • With MariaDB: "In Oracle mode from MariaDB 10.3, VARCHAR2 is a synonym."
  • I think the generated code shouldn't change much, I think it can be handled the same way as varchar to generate code. People can still use varchar.

Right now if I try to use varchar2 it fails with syntax error):

❯ sqlc generate
# package database
db/migrations/20240510112356_init.sql:3:16: syntax error near "varchar2(36) not null primary key,"

References:

What database engines need to be changed?

MySQL

What programming language backends need to be changed?

Go

@yitsushi yitsushi added enhancement New feature or request triage New issues that hasn't been reviewed labels May 16, 2024
@yitsushi
Copy link
Author

I check what I can do, but it seems to me it's a pingcap/tidb issue as this hits error in internal/engine/dolphin/parse.go:

	stmtNodes, _, err := p.pingcap.Parse(string(blob), "", "")
	if err != nil {
		return nil, normalizeErr(err)
	}

If I understand that parser correctly, it doesn't know anything about varchar2 based on this file: https://github.com/pingcap/tidb/blob/master/pkg/parser/parser.y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage New issues that hasn't been reviewed
Projects
None yet
Development

No branches or pull requests

1 participant