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

Added whitespaces where necessary in regex checks #312

Merged
merged 2 commits into from
Sep 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions yb-voyager/cmd/analyzeSchema.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,33 +97,33 @@ var (
alterOfRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* OF `)
alterSchemaRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* SET SCHEMA `)
createSchemaRegex = regexp.MustCompile(`(?i)CREATE SCHEMA .* CREATE TABLE`)
alterNotOfRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* NOT OF`)
alterNotOfRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* NOT OF `)
alterColumnStatsRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* ALTER COLUMN ([a-zA-Z0-9_."]+).* SET STATISTICS`)
alterColumnStorageRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* ALTER COLUMN ([a-zA-Z0-9_."]+).* SET STORAGE`)
alterColumnSetAttributesRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* ALTER COLUMN ([a-zA-Z0-9_."]+).* SET \(`)
alterColumnResetAttributesRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* ALTER COLUMN ([a-zA-Z0-9_."]+).* RESET`)
alterColumnResetAttributesRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* ALTER COLUMN ([a-zA-Z0-9_."]+).* RESET `)
alterConstrRegex = regexp.MustCompile(`(?i)ALTER ([a-zA-Z_]+ )?(IF EXISTS )?TABLE ([a-zA-Z0-9_."]+).* ALTER CONSTRAINT`)
setOidsRegex = regexp.MustCompile(`(?i)ALTER ([a-zA-Z_]+ )?TABLE (IF EXISTS )?([a-zA-Z0-9_."]+).* SET WITH OIDS`)
clusterRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* CLUSTER`)
withoutClusterRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* SET WITHOUT CLUSTER`)
clusterRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* CLUSTER `)
withoutClusterRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+).* SET WITHOUT CLUSTER `)
alterSetRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+) SET `)
alterIdxRegex = regexp.MustCompile(`(?i)ALTER INDEX ([a-zA-Z0-9_."]+) SET `)
alterResetRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+) RESET `)
alterOptionsRegex = regexp.MustCompile(`(?i)ALTER ([a-zA-Z_]+ )?TABLE (IF EXISTS )?([a-zA-Z0-9_."]+) OPTIONS`)
alterInhRegex = regexp.MustCompile(`(?i)ALTER ([a-zA-Z_]+ )?TABLE (IF EXISTS )?([a-zA-Z0-9_."]+) INHERIT`)
alterOptionsRegex = regexp.MustCompile(`(?i)ALTER ([a-zA-Z_]+ )?TABLE (IF EXISTS )?([a-zA-Z0-9_."]+) OPTIONS `)
alterInhRegex = regexp.MustCompile(`(?i)ALTER ([a-zA-Z_]+ )?TABLE (IF EXISTS )?([a-zA-Z0-9_."]+) INHERIT `)
valConstrRegex = regexp.MustCompile(`(?i)ALTER ([a-zA-Z_]+ )?TABLE (IF EXISTS )?([a-zA-Z0-9_."]+) VALIDATE CONSTRAINT`)
deferRegex = regexp.MustCompile(`(?i)ALTER ([a-zA-Z_]+ )?TABLE (IF EXISTS )?([a-zA-Z0-9_."]+).* unique .*deferrable`)
alterViewRegex = regexp.MustCompile(`(?i)ALTER VIEW ([a-zA-Z0-9_."]+)`)

dropAttrRegex = regexp.MustCompile(`(?i)ALTER TYPE ([a-zA-Z0-9_."]+) DROP ATTRIBUTE`)
alterTypeRegex = regexp.MustCompile(`(?i)ALTER TYPE ([a-zA-Z0-9_."]+)`)
alterTblSpcRegex = regexp.MustCompile(`(?i)ALTER TABLESPACE ([a-zA-Z0-9_."]+) SET`)
alterTblSpcRegex = regexp.MustCompile(`(?i)ALTER TABLESPACE ([a-zA-Z0-9_."]+) SET `)

// table partition. partitioned table is the key in tblParts map
tblPartitionRegex = regexp.MustCompile(`(?i)CREATE TABLE (IF NOT EXISTS )?([a-zA-Z0-9_."]+) .*PARTITION OF ([a-zA-Z0-9_."]+)`)
addPrimaryRegex = regexp.MustCompile(`(?i)ALTER TABLE (ONLY )?(IF EXISTS )?([a-zA-Z0-9_."]+) .*ADD PRIMARY KEY`)
primRegex = regexp.MustCompile(`(?i)CREATE FOREIGN TABLE ([a-zA-Z0-9_."]+).*PRIMARY KEY`)
foreignKeyRegex = regexp.MustCompile(`(?i)CREATE FOREIGN TABLE ([a-zA-Z0-9_."]+).*REFERENCES`)
foreignKeyRegex = regexp.MustCompile(`(?i)CREATE FOREIGN TABLE ([a-zA-Z0-9_."]+).*REFERENCES `)

// unsupported SQLs exported by ora2pg
compoundTrigRegex = regexp.MustCompile(`(?i)CREATE[\s\n]+(OR REPLACE[\s\n]*)?TRIGGER[\s\n]+([a-zA-Z0-9_."]+)[\s\n]+.*[\s\n]+COMPOUND.*`)
Expand Down