Skip to content

Commit

Permalink
changed the case for REINDEX CONCURRENTLY to REINDEX anything as any …
Browse files Browse the repository at this point in the history
…REINDEX is not supported (yugabyte/yugabyte-db#10267)
  • Loading branch information
priyanshi-yb committed Feb 3, 2023
1 parent c7f9e7b commit 34667e9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ DROP INDEX CONCURRENTLY sales_quantity_index;
--index access method not supported
CREATE ACCESS METHOD heptree TYPE INDEX HANDLER heptree_handler;


--alter index case
ALTER INDEX abc set TABLESPACE new_tbl;
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ CREATE CONVERSION myconv FOR 'UTF8' TO 'LATIN1' FROM myfunc;
ALTER CONVERSION myconv for 'UTF8' TO 'LATIN1' FROM myfunc1;

--Reindexing not supported
REINDEX TABLE CONCURRENTLY my_table;
REINDEX TABLE my_table;

--Generated stored
CREATE TABLE newtable (
Expand Down
6 changes: 3 additions & 3 deletions migtests/tests/analyze-schema/expected_issues.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@
{
"objectType": "TABLE",
"objectName": "my_table",
"reason": "REINDEX CONCURRENTLY is not supported.",
"sqlStatement": "REINDEX TABLE CONCURRENTLY my_table;",
"reason": "REINDEX is not supported.",
"sqlStatement": "REINDEX TABLE my_table;",
"suggestion": "",
"GH": "https://github.com/yugabyte/yugabyte-db/issues/10694"
"GH": "https://github.com/yugabyte/yugabyte-db/issues/10267"
},
{
"objectType": "TABLE",
Expand Down
69 changes: 35 additions & 34 deletions yb-voyager/cmd/analyzeSchema.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,31 +90,31 @@ var (
multiRegex = regexp.MustCompile(`([a-zA-Z0-9_\.]+[,|;])`)
dollarQuoteRegex = regexp.MustCompile(`(\$.*\$)`)
//TODO: optional but replace every possible space or new line char with [\s\n]+ in all regexs
createConvRegex = re("CREATE", opt("DEFAULT"), "CONVERSION", capture(ident))
alterConvRegex = re("ALTER", "CONVERSION", capture(ident))
gistRegex = re("CREATE", "INDEX", ifNotExists, capture(ident), "ON", capture(ident), anything, "USING GIST")
brinRegex = re("CREATE", "INDEX", ifNotExists, capture(ident), "ON", capture(ident), anything, "USING brin")
spgistRegex = re("CREATE", "INDEX", ifNotExists, capture(ident), "ON", capture(ident), anything, "USING spgist")
rtreeRegex = re("CREATE", "INDEX", ifNotExists, capture(ident), "ON", capture(ident), anything, "USING rtree")
ginRegex = re("CREATE", "INDEX", ifNotExists, capture(ident), "ON", capture(ident), anything, "USING GIN", capture(commaSeperatedStrings))
viewWithCheckRegex = re("VIEW", capture(ident), anything, "WITH", "CHECK", "OPTION")
rangeRegex = re("PRECEDING", "and", anything, ":float")
fetchRegex = re("FETCH", anything, "FROM")
fetchRelativeRegex = re("FETCH", "RELATIVE")
backwardRegex = re("MOVE", "BACKWARD")
fetchAbsRegex = re("FETCH", "ABSOLUTE")
alterAggRegex = re("ALTER", "AGGREGATE", capture(ident))
dropCollRegex = re("DROP", "COLLATION", ifExists, capture(commaSeperatedStringsMoreThan1))
dropIdxRegex = re("DROP", "INDEX", ifExists, capture(commaSeperatedStringsMoreThan1))
dropViewRegex = re("DROP", "VIEW", ifExists, capture(commaSeperatedStringsMoreThan1))
dropSeqRegex = re("DROP", "SEQUENCE", ifExists, capture(commaSeperatedStringsMoreThan1))
dropForeignRegex = re("DROP", "FOREIGN", "TABLE", ifExists, capture(commaSeperatedStringsMoreThan1))
createConvRegex = re("CREATE", opt("DEFAULT"), "CONVERSION", capture(ident))
alterConvRegex = re("ALTER", "CONVERSION", capture(ident))
gistRegex = re("CREATE", "INDEX", ifNotExists, capture(ident), "ON", capture(ident), anything, "USING GIST")
brinRegex = re("CREATE", "INDEX", ifNotExists, capture(ident), "ON", capture(ident), anything, "USING brin")
spgistRegex = re("CREATE", "INDEX", ifNotExists, capture(ident), "ON", capture(ident), anything, "USING spgist")
rtreeRegex = re("CREATE", "INDEX", ifNotExists, capture(ident), "ON", capture(ident), anything, "USING rtree")
ginRegex = re("CREATE", "INDEX", ifNotExists, capture(ident), "ON", capture(ident), anything, "USING GIN", capture(commaSeperatedStrings))
viewWithCheckRegex = re("VIEW", capture(ident), anything, "WITH", "CHECK", "OPTION")
rangeRegex = re("PRECEDING", "and", anything, ":float")
fetchRegex = re("FETCH", anything, "FROM")
fetchRelativeRegex = re("FETCH", "RELATIVE")
backwardRegex = re("MOVE", "BACKWARD")
fetchAbsRegex = re("FETCH", "ABSOLUTE")
alterAggRegex = re("ALTER", "AGGREGATE", capture(ident))
dropCollRegex = re("DROP", "COLLATION", ifExists, capture(commaSeperatedStringsMoreThan1))
dropIdxRegex = re("DROP", "INDEX", ifExists, capture(commaSeperatedStringsMoreThan1))
dropViewRegex = re("DROP", "VIEW", ifExists, capture(commaSeperatedStringsMoreThan1))
dropSeqRegex = re("DROP", "SEQUENCE", ifExists, capture(commaSeperatedStringsMoreThan1))
dropForeignRegex = re("DROP", "FOREIGN", "TABLE", ifExists, capture(commaSeperatedStringsMoreThan1))
dropIdxConcurRegex = re("DROP", "INDEX", "CONCURRENTLY", ifExists, capture(ident))
trigRefRegex = re("CREATE", "TRIGGER", capture(ident), anything, "REFERENCING")
constrTrgRegex = re("CREATE", "CONSTRAINT", "TRIGGER", capture(ident))
currentOfRegex = re("WHERE", "CURRENT", "OF")
currentOfRegex = re("WHERE", "CURRENT", "OF")
amRegex = re("CREATE", "ACCESS", "METHOD", capture(ident))
idxConcRegex = re("REINDEX", anything, "CONCURRENTLY", capture(ident))
idxConcRegex = re("REINDEX ", anything, " ", capture(ident))
storedRegex = re(capture(normalIdent), capture(normalIdent), "GENERATED", "ALWAYS", anything, "STORED")
partitionColumnsRegex = re("CREATE", "TABLE", ifNotExists, capture(ident), `\(`+capture(commaSeperatedStrings)+`\) PARTITION BY`, capture("[A-Za-z]+"), `\(`, capture(commaSeperatedStrings), `\)`)
likeAllRegex = re("CREATE", "TABLE", ifNotExists, capture(ident), anything, "LIKE", anything, "INCLUDING ALL")
Expand All @@ -125,9 +125,9 @@ var (
//super user role required, language c is errored as unsafe
cLangRegex = re("CREATE", opt("OR REPLACE"), "FUNCTION", capture(ident), anything, "language c")

alterOfRegex = re("ALTER", "TABLE", opt("ONLY"), ifExists, capture(ident), anything, "OF")
alterSchemaRegex = re("ALTER", "TABLE", opt("ONLY"), ifExists, capture(ident), anything, "SET SCHEMA")
createSchemaRegex = re("CREATE", "SCHEMA", anything, "CREATE", "TABLE")
alterOfRegex = re("ALTER", "TABLE", opt("ONLY"), ifExists, capture(ident), anything, "OF")
alterSchemaRegex = re("ALTER", "TABLE", opt("ONLY"), ifExists, capture(ident), anything, "SET SCHEMA")
createSchemaRegex = re("CREATE", "SCHEMA", anything, "CREATE", "TABLE")
alterNotOfRegex = re("ALTER", "TABLE", opt("ONLY"), ifExists, capture(ident), anything, "NOT OF")
alterColumnStatsRegex = re("ALTER", "TABLE", opt("ONLY"), ifExists, capture(ident), anything, "ALTER", "COLUMN", capture(ident), anything, "SET STATISTICS")
alterColumnStorageRegex = re("ALTER", "TABLE", opt("ONLY"), ifExists, capture(ident), anything, "ALTER", "COLUMN", capture(ident), anything, "SET STORAGE")
Expand All @@ -140,14 +140,14 @@ var (
alterSetRegex = re("ALTER", "TABLE", opt("ONLY"), ifExists, capture(ident), "SET")
alterIdxRegex = re("ALTER", "INDEX", capture(ident), "SET")
alterResetRegex = re("ALTER", "TABLE", opt("ONLY"), ifExists, capture(ident), "RESET")
alterOptionsRegex = re("ALTER", opt(capture(normalIdent)), "TABLE", ifExists, capture(ident), "OPTIONS")
alterInhRegex = re("ALTER", opt(capture(normalIdent)), "TABLE", ifExists, capture(ident), "INHERIT")
valConstrRegex = re("ALTER", opt(capture(normalIdent)), "TABLE", ifExists, capture(ident), "VALIDATE CONSTRAINT")
deferRegex = re("ALTER", opt(capture(normalIdent)), "TABLE", ifExists, capture(ident), anything, "UNIQUE", anything, "deferrable")
alterViewRegex = re("ALTER", "VIEW", capture(ident))
dropAttrRegex = re("ALTER", "TYPE", capture(ident), "DROP ATTRIBUTE")
alterTypeRegex = re("ALTER", "TYPE", capture(ident))
alterTblSpcRegex = re("ALTER", "TABLESPACE", capture(ident), "SET")
alterOptionsRegex = re("ALTER", opt(capture(normalIdent)), "TABLE", ifExists, capture(ident), "OPTIONS")
alterInhRegex = re("ALTER", opt(capture(normalIdent)), "TABLE", ifExists, capture(ident), "INHERIT")
valConstrRegex = re("ALTER", opt(capture(normalIdent)), "TABLE", ifExists, capture(ident), "VALIDATE CONSTRAINT")
deferRegex = re("ALTER", opt(capture(normalIdent)), "TABLE", ifExists, capture(ident), anything, "UNIQUE", anything, "deferrable")
alterViewRegex = re("ALTER", "VIEW", capture(ident))
dropAttrRegex = re("ALTER", "TYPE", capture(ident), "DROP ATTRIBUTE")
alterTypeRegex = re("ALTER", "TYPE", capture(ident))
alterTblSpcRegex = re("ALTER", "TABLESPACE", capture(ident), "SET")

// table partition. partitioned table is the key in tblParts map
tblPartitionRegex = re("CREATE", "TABLE", ifNotExists, capture(ident), anything, "PARTITION", "OF", capture(ident))
Expand Down Expand Up @@ -367,8 +367,9 @@ func checkDDL(sqlInfoArr []sqlInfo, fpath string) {
reportCase(fpath, "CREATE ACCESS METHOD is not supported.",
"https://github.com/yugabyte/yugabyte-db/issues/10693", "", "ACCESS METHOD", am[1], sqlInfo.formattedStmt)
} else if tbl := idxConcRegex.FindStringSubmatch(sqlInfo.stmt); tbl != nil {
reportCase(fpath, "REINDEX CONCURRENTLY is not supported.",
"https://github.com/yugabyte/yugabyte-db/issues/10694", "", "TABLE", tbl[1], sqlInfo.formattedStmt)
fmt.Println(idxConcRegex, sqlInfo.stmt, len(tbl), tbl[1])
reportCase(fpath, "REINDEX is not supported.",
"https://github.com/yugabyte/yugabyte-db/issues/10267", "", "TABLE", tbl[1], sqlInfo.formattedStmt)
} else if col := storedRegex.FindStringSubmatch(sqlInfo.stmt); col != nil {
reportCase(fpath, "Stored generated column is not supported. Column is: "+col[1],
"https://github.com/yugabyte/yugabyte-db/issues/10695", "", "TABLE", "", sqlInfo.formattedStmt)
Expand Down

0 comments on commit 34667e9

Please sign in to comment.