Skip to content
This repository was archived by the owner on Oct 2, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion backup/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func CopyTableOut(connectionPool *dbconn.DBConn, table Table, destinationToWrite
checkPipeExistsCommand := ""
customPipeThroughCommand := utils.GetPipeThroughProgram().OutputCommand
sendToDestinationCommand := ">"
copyCommand := ""
if MustGetFlagBool(options.SINGLE_DATA_FILE) {
/*
* The segment TOC files are always written to the segment data directory for
Expand All @@ -70,9 +71,13 @@ func CopyTableOut(connectionPool *dbconn.DBConn, table Table, destinationToWrite
customPipeThroughCommand = "cat -"
} else if MustGetFlagString(options.PLUGIN_CONFIG) != "" {
sendToDestinationCommand = fmt.Sprintf("| %s backup_data %s", pluginConfig.ExecutablePath, pluginConfig.ConfigPath)
} else if customPipeThroughCommand == "cat -" {
copyCommand = fmt.Sprintf("'%s'", destinationToWrite)
}

copyCommand := fmt.Sprintf("PROGRAM '%s%s %s %s'", checkPipeExistsCommand, customPipeThroughCommand, sendToDestinationCommand, destinationToWrite)
if copyCommand == "" {
copyCommand = fmt.Sprintf("PROGRAM '%s%s %s %s'", checkPipeExistsCommand, customPipeThroughCommand, sendToDestinationCommand, destinationToWrite)
}

query := fmt.Sprintf("COPY %s TO %s WITH CSV DELIMITER '%s' ON SEGMENT IGNORE EXTERNAL PARTITIONS;", table.FQN(), copyCommand, tableDelim)
gplog.Verbose("Worker %d: %s", connNum, query)
Expand Down
2 changes: 1 addition & 1 deletion backup/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ var _ = Describe("backup/data tests", func() {
})
It("will back up a table to its own file without compression", func() {
utils.SetPipeThroughProgram(utils.PipeThroughProgram{Name: "cat", OutputCommand: "cat -", InputCommand: "cat -", Extension: ""})
execStr := regexp.QuoteMeta("COPY public.foo TO PROGRAM 'cat - > <SEG_DATA_DIR>/backups/20170101/20170101010101/gpbackup_<SEGID>_20170101010101_3456' WITH CSV DELIMITER ',' ON SEGMENT IGNORE EXTERNAL PARTITIONS;")
execStr := regexp.QuoteMeta("COPY public.foo TO '<SEG_DATA_DIR>/backups/20170101/20170101010101/gpbackup_<SEGID>_20170101010101_3456' WITH CSV DELIMITER ',' ON SEGMENT IGNORE EXTERNAL PARTITIONS;")
mock.ExpectExec(execStr).WillReturnResult(sqlmock.NewResult(10, 0))
filename := "<SEG_DATA_DIR>/backups/20170101/20170101010101/gpbackup_<SEGID>_20170101010101_3456"

Expand Down