0001-Parse-the-format-option-for-pg_restore-with-pg_strcasecmp.patch
application/octet-stream
Filename: 0001-Parse-the-format-option-for-pg_restore-with-pg_strcasecmp.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch 0001
Subject: Parse the --format option for pg_restore with pg_strcasecmp instead of first char of the formatName.
| File | + | − |
|---|---|---|
| src/bin/pg_dump/pg_restore.c | 14 | 20 |
From eb632649b49b8c48593294875d823c0077d06d78 Mon Sep 17 00:00:00 2001
From: Srinath Reddy Sadipiralla <srinath2133@gmail.com>
Date: Sat, 25 Jan 2025 17:52:50 +0530
Subject: [PATCH 1/1] Parse the --format option for pg_restore with
pg_strcasecmp instead of first char of the formatName.
---
src/bin/pg_dump/pg_restore.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/src/bin/pg_dump/pg_restore.c b/src/bin/pg_dump/pg_restore.c
index 88ae39d938..79f046163c 100644
--- a/src/bin/pg_dump/pg_restore.c
+++ b/src/bin/pg_dump/pg_restore.c
@@ -383,27 +383,21 @@ main(int argc, char **argv)
if (opts->formatName)
{
- switch (opts->formatName[0])
- {
- case 'c':
- case 'C':
- opts->format = archCustom;
- break;
-
- case 'd':
- case 'D':
- opts->format = archDirectory;
- break;
-
- case 't':
- case 'T':
- opts->format = archTar;
- break;
-
- default:
- pg_fatal("unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"",
+ if (pg_strcasecmp(opts->formatName, "c") == 0)
+ opts->format = archCustom;
+ else if (pg_strcasecmp(opts->formatName, "custom") == 0)
+ opts->format = archCustom;
+ else if (pg_strcasecmp(opts->formatName, "d") == 0)
+ opts->format = archDirectory;
+ else if (pg_strcasecmp(opts->formatName, "directory") == 0)
+ opts->format = archDirectory;
+ else if (pg_strcasecmp(opts->formatName, "t") == 0)
+ opts->format = archTar;
+ else if (pg_strcasecmp(opts->formatName, "tar") == 0)
+ opts->format = archTar;
+ else
+ pg_fatal("unrecognized archive format \"%s\"; please specify \"c\", \"d\", or \"t\"",
opts->formatName);
- }
}
AH = OpenArchive(inputFileSpec, opts->format);
--
2.43.0