GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Resolve parsing error for CHARACTER SET and COLLATE in MySQL ALTER TABLE (issue 2027) by minleejae · Pull Request #2045 · JSQLParser/JSqlParser

Conversation

@minleejae

@minleejae minleejae commented Jul 22, 2024

Copy link
Copy Markdown
Contributor

Problem

When attempting to parse ALTER TABLE statements in MySQL that include CHARACTER SET and COLLATE specifications for column types such as text, tinytext, mediumtext, and longtext, a ParseException is thrown. This issue is currently present in JSqlParser version 5.0.
#2027

Solution

This PR introduces updates to the parsing rules within JSqlParser, allowing for correct handling of CHARACTER SET and COLLATE clauses in MySQL ALTER TABLE statements. The changes involve modifying the token recognition patterns and parser rules to ensure that these keywords are properly interpreted when following the mentioned text data types.

Tests

The following test cases have been added to verify the correct parsing of modified statements:

  • Simple ALTER TABLE with text
  • ALTER TABLE with text, including CHARACTER SET and COLLATE
  • The same checks for tinytext, mediumtext, and longtext.

These tests ensure that the parser remains stable and performs as expected across these common use cases in MySQL.

I look forward to feedback and further suggestions!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
mj-db added 2 commits July 23, 2024 02:15
@mj-db
fix: parsing alter text character set
df8ad57
@mj-db
style: remove unnecessary comment
4652299
@manticore-projects manticore-projects added MySQL MySQL specific issue DDL DDL statement related labels Jul 23, 2024
@manticore-projects

manticore-projects commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

fixes #2027

minleejae reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects manticore-projects linked an issue Jul 23, 2024 that may be closed by this pull request
[BUG] 5.0 : MySQL : Parsing ALTER TABLE statement with CHARACTER SET fails #2027
Closed
@minleejae

minleejae commented Jul 23, 2024

Copy link
Copy Markdown
Contributor Author

Hi, @manticore-projects
In my development environment, the NestedBracketsPerformanceTest passes successfully, but I'm not sure why the Gradle build is failing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects

manticore-projects commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

Hi, @manticore-projects In my development environment, the NestedBracketsPerformanceTest passes successfully, but I'm not sure why the Gradle build is failing.

Greetings!

Likely because the GitHub build environment is slower (cpu clock/speed wise) than your local environment -- meaning that your change still slows the parser down, which is not a welcome development.

minleejae reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@minleejae

minleejae commented Jul 23, 2024

Copy link
Copy Markdown
Contributor Author

@manticore-projects
I understood the cause of the problem.
I don't think I've changed the code much enough to have a big impact on the overall performance, but what should I do to fix this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects

manticore-projects commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

I don't think I've changed the code much enough to have a big impact on the overall performance, but what should I do to fix this?

Any change in the Grammar can have potentially big impact.
Also, the impact does not need to be big, likely just something like the "straw that broke the camel's back".

I would still merge it (and fix this performance exception manually by adding timeout). However, please address my concern on the TEXT token first -- I need it as a data type token.

minleejae reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mj-db
fix: TEXT as a data type token
d8fc0d8
@minleejae

minleejae commented Jul 23, 2024

Copy link
Copy Markdown
Contributor Author

@manticore-projects
I understand the potential impact of changes to the grammar and will consider ways to further enhance performance. Additionally, I have updated the code to include "TEXT" as a data type token as requested. d8fc0d8

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects

manticore-projects commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

Something is wrong. In the Github Maven task I see:

Error:  COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
Error:  /home/runner/work/JSqlParser/JSqlParser/target/generated-sources/javacc/net/sf/jsqlparser/parser/CCJSqlParser.java:[22081,7] unreachable statement

However, when pulling your PR and compile locally everything seems to work. This confuses the hell out me right now.

minleejae reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects
manticore-projects merged commit 93c8210 into JSQLParser:master Jul 23, 2024
@manticore-projects

manticore-projects commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

I have merged it and will test/fix whatever problem directly.
Thank you for your contribution. Cheers!

minleejae reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects

manticore-projects commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

Your changes cause real breakage:

    case K_TEXT_LITERAL:{
      tk = jj_consume_token(K_TEXT_LITERAL);
type = tk.image;
            return new ColDataType(type, precision, scale);
      break;
      }

Although I don't understand why gradle check works but Maven does not.

minleejae reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@minleejae

minleejae commented Jul 23, 2024

Copy link
Copy Markdown
Contributor Author

@manticore-projects
I apologize for not catching this issue in my environment. It seems like it has been resolved in the main branch, so thank you for fixing it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@manticore-projects

manticore-projects commented Jul 23, 2024

Copy link
Copy Markdown
Contributor

@manticore-projects I apologize for not catching this issue in my environment. It seems like it has been resolved in the main branch, so thank you for fixing it.

No problem at all, that's what team work is for. Thank you again for your help and contribution!
Looking forward seeing more MySQL related improvements from you. Cheers!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@minleejae
minleejae deleted the fix/text branch November 14, 2024 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

DDL DDL statement related MySQL MySQL specific issue

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[BUG] 5.0 : MySQL : Parsing ALTER TABLE statement with CHARACTER SET fails

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@minleejae @manticore-projects @mj-db
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.