Conversation
Comment on lines
+154
to
+196
| # Check if it's a single-line statement (ends with semicolon) | ||
| if( /;$/ ) { | ||
| # Process immediately | ||
|
|
||
| # Check if this is ADD INDEX or ADD UNIQUE | ||
| if( /ADD INDEX|add index|ADD UNIQUE|add unique/ ) { | ||
| isAddIndex = 1 | ||
|
|
||
| # Extract table name | ||
| if( match( $0, /`[^`]+/ ) ){ | ||
| alterTableName = substr( $0, RSTART+1, RLENGTH-1 ) | ||
| } | ||
|
|
||
| # Extract index name | ||
| if( match( $0, /(ADD INDEX|add index|ADD UNIQUE|add unique) `[^`]+/ ) ){ | ||
| indexMatch = substr( $0, RSTART, RLENGTH ) | ||
| if( match( indexMatch, /`[^`]+$/ ) ){ | ||
| alterIndexName = substr( indexMatch, RSTART+1, RLENGTH-1 ) | ||
| } | ||
| } | ||
|
|
||
| # Extract column list | ||
| if( isAddIndex && alterTableName != "" && alterIndexName != "" ) { | ||
| if( match( alterStatement, /\([^)]+\)/ ) ){ | ||
| columnList = substr( alterStatement, RSTART+1, RLENGTH-2 ) | ||
| gsub( /[ \t\n\r]+/, " ", columnList ) | ||
| gsub( /^ +| +$/, "", columnList ) | ||
| gsub( /`/, "\"", columnList ) | ||
|
|
||
| # Check if UNIQUE | ||
| uniquePrefix = "" | ||
| if( alterStatement ~ /ADD UNIQUE|add unique/ ) { | ||
| uniquePrefix = "UNIQUE " | ||
| } | ||
|
|
||
| print "CREATE " uniquePrefix "INDEX \"idx_" alterTableName "_" alterIndexName "\" ON \"" alterTableName "\" (" columnList ");" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # Reset | ||
| inAlterTable = 0 | ||
| } |
Member
There was a problem hiding this comment.
I don't really understand why all these lines need to be added: seems that unique indexes are handled a bit lower in this file.
Author
There was a problem hiding this comment.
unfortunately, can't say too much about this, but as I see according to the search over the previous version - ADD UNIQUE / UNIQUE does not appear anywhere in a file and current include. I tested several times and no error occurs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolve issue when ADD UNIQUE skipped