fix(influx_inspect): multiple retention policies bug in influx_inspect export (#23197)

pull/21125/head
Shiwen Cheng 2022-04-15 01:59:06 +08:00 committed by GitHub
parent 753f503424
commit 476111c40f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -200,10 +200,23 @@ func (cmd *Command) walkWALFiles() error {
func (cmd *Command) writeDDL(mw io.Writer, w io.Writer) error {
// Write out all the DDL
fmt.Fprintln(mw, "# DDL")
manifest := make(map[string][]string)
for key := range cmd.manifest {
keys := strings.Split(key, string(os.PathSeparator))
db, rp := influxql.QuoteIdent(keys[0]), influxql.QuoteIdent(keys[1])
fmt.Fprintf(w, "CREATE DATABASE %s WITH NAME %s\n", db, rp)
manifest[db] = append(manifest[db], rp)
}
for db, rps := range manifest {
if len(rps) > 1 {
fmt.Fprintf(w, "CREATE DATABASE %s WITH NAME autogen\n", db)
for _, rp := range rps {
if rp != "autogen" {
fmt.Fprintf(w, "CREATE RETENTION POLICY %s ON %s DURATION 0s REPLICATION 1\n", rp, db)
}
}
} else {
fmt.Fprintf(w, "CREATE DATABASE %s WITH NAME %s\n", db, rps[0])
}
}
return nil