Skip to content

Commit

Permalink
pgbackup does not backup statistics for leaf partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
RekGRpth committed Sep 27, 2023
1 parent 9ce5974 commit 9617b42
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func DoBackup() {
}

gplog.Info("Gathering table state information")
metadataTables, dataTables := RetrieveAndProcessTables()
metadataTables, dataTables, allTables := RetrieveAndProcessTables()
dataTables, numExtOrForeignTables := GetBackupDataSet(dataTables)
if len(dataTables) == 0 && !backupReport.MetadataOnly {
gplog.Warn("No tables in backup set contain data. Performing metadata-only backup instead.")
Expand Down Expand Up @@ -191,7 +191,7 @@ func DoBackup() {

printDataBackupWarnings(numExtOrForeignTables)
if MustGetFlagBool(options.WITH_STATS) {
backupStatistics(metadataTables)
backupStatistics(allTables)
}

globalTOC.WriteToFileAndMakeReadOnly(globalFPInfo.GetTOCFilePath())
Expand Down
4 changes: 2 additions & 2 deletions backup/wrappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func createBackupDirectoriesOnAllHosts() {
* Metadata retrieval wrapper functions
*/

func RetrieveAndProcessTables() ([]Table, []Table) {
func RetrieveAndProcessTables() ([]Table, []Table, []Table) {
quotedIncludeRelations, err := options.QuoteTableNames(connectionPool, MustGetFlagStringArray(options.INCLUDE_RELATION))
gplog.FatalOnError(err)

Expand All @@ -220,7 +220,7 @@ func RetrieveAndProcessTables() ([]Table, []Table) {
metadataTables, dataTables := SplitTablesByPartitionType(tables, quotedIncludeRelations)
objectCounts["Tables"] = len(metadataTables)

return metadataTables, dataTables
return metadataTables, dataTables, tables
}

func retrieveFunctions(sortables *[]Sortable, metadataMap MetadataMap) ([]Function, map[uint32]FunctionInfo) {
Expand Down
20 changes: 10 additions & 10 deletions integration/wrappers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = Describe("Wrappers Integration", func() {
connectionPool.MustBegin(0)
defer connectionPool.MustCommit(0)

_, dataTables := backup.RetrieveAndProcessTables()
_, dataTables, _ := backup.RetrieveAndProcessTables()
Expect(len(dataTables)).To(Equal(2))
Expect(dataTables[0].Name).To(Equal("foo"))
Expect(dataTables[1].Name).To(Equal(`"BAR"`))
Expand All @@ -59,7 +59,7 @@ var _ = Describe("Wrappers Integration", func() {
rootCmd := &cobra.Command{}
backup.DoInit(rootCmd) // initialize the ObjectCount

_, dataTables := backup.RetrieveAndProcessTables()
_, dataTables, _ := backup.RetrieveAndProcessTables()
Expect(len(dataTables)).To(Equal(3))
Expect(dataTables[0].Name).To(Equal("thousands"))
Expect(dataTables[1].Name).To(Equal("ten"))
Expand All @@ -72,7 +72,7 @@ var _ = Describe("Wrappers Integration", func() {
backup.DoInit(rootCmd) // initialize the ObjectCount
rootCmd.Execute()

_, dataTables := backup.RetrieveAndProcessTables()
_, dataTables, _ := backup.RetrieveAndProcessTables()
Expect(len(dataTables)).To(Equal(2))
Expect(dataTables[0].Name).To(Equal("ten"))
Expect(dataTables[1].Name).To(Equal("empty"))
Expand All @@ -84,7 +84,7 @@ var _ = Describe("Wrappers Integration", func() {
backup.DoInit(rootCmd) // initialize the ObjectCount
rootCmd.Execute()

_, dataTables := backup.RetrieveAndProcessTables()
_, dataTables, _ := backup.RetrieveAndProcessTables()
Expect(len(dataTables)).To(Equal(2))
Expect(dataTables[0].Name).To(Equal("ten"))
Expect(dataTables[1].Name).To(Equal("empty"))
Expand Down Expand Up @@ -115,7 +115,7 @@ var _ = Describe("Wrappers Integration", func() {
backup.DoInit(rootCmd) // initialize the ObjectCount
rootCmd.Execute()

_, dataTables := backup.RetrieveAndProcessTables()
_, dataTables, _ := backup.RetrieveAndProcessTables()
Expect(len(dataTables)).To(Equal(2))
Expect(dataTables[0].Name).To(Equal("thousands"))
Expect(dataTables[1].Name).To(Equal("empty"))
Expand All @@ -127,7 +127,7 @@ var _ = Describe("Wrappers Integration", func() {
backup.DoInit(rootCmd) // initialize the ObjectCount
rootCmd.Execute()

_, dataTables := backup.RetrieveAndProcessTables()
_, dataTables, _ := backup.RetrieveAndProcessTables()
Expect(len(dataTables)).To(Equal(2))
Expect(dataTables[0].Name).To(Equal("thousands"))
Expect(dataTables[1].Name).To(Equal("empty"))
Expand Down Expand Up @@ -164,7 +164,7 @@ var _ = Describe("Wrappers Integration", func() {
err := opts.ExpandIncludesForPartitions(connectionPool, rootCmd.Flags())
Expect(err).ShouldNot(HaveOccurred())

_, dataTables := backup.RetrieveAndProcessTables()
_, dataTables, _ := backup.RetrieveAndProcessTables()
Expect(len(dataTables)).To(Equal(2))
Expect(dataTables[0].Name).To(Equal("partition_table"))
Expect(dataTables[1].Name).To(Equal("ten"))
Expand All @@ -180,7 +180,7 @@ var _ = Describe("Wrappers Integration", func() {
err := opts.ExpandIncludesForPartitions(connectionPool, rootCmd.Flags())
Expect(err).ShouldNot(HaveOccurred())

_, dataTables := backup.RetrieveAndProcessTables()
_, dataTables, _ := backup.RetrieveAndProcessTables()

Expect(len(dataTables)).To(Equal(3))
Expect(dataTables[0].Name).To(Equal("partition_table_1_prt_girls"))
Expand Down Expand Up @@ -211,7 +211,7 @@ var _ = Describe("Wrappers Integration", func() {
rootCmd := &cobra.Command{}
backup.DoInit(rootCmd) // initialize the ObjectCount

_, dataTables := backup.RetrieveAndProcessTables()
_, dataTables, _ := backup.RetrieveAndProcessTables()
Expect(len(dataTables)).To(Equal(3))

Expect(dataTables[0].Name).To(Equal("thousands"))
Expand All @@ -230,7 +230,7 @@ var _ = Describe("Wrappers Integration", func() {
rootCmd := &cobra.Command{}
backup.DoInit(rootCmd) // initialize the ObjectCount

_, dataTables := backup.RetrieveAndProcessTables()
_, dataTables, _ := backup.RetrieveAndProcessTables()
Expect(len(dataTables)).To(Equal(3))

Expect(dataTables[0].Name).To(Equal("thousands"))
Expand Down

0 comments on commit 9617b42

Please sign in to comment.