diff --git a/src/bin/pg_dump/pg_restore.cpp b/src/bin/pg_dump/pg_restore.cpp index 490f73d53..3c65954a0 100644 --- a/src/bin/pg_dump/pg_restore.cpp +++ b/src/bin/pg_dump/pg_restore.cpp @@ -224,6 +224,15 @@ int main(int argc, char** argv) exit_nicely(1); } + /* Make sure the input file exists */ + FILE* fd = fopen(inputFileSpec, PG_BINARY_R); + if (NULL == fd) { + fprintf(stderr, "%s: %s\n", inputFileSpec, strerror(errno)); + exit_nicely(1); + } + fclose(fd); + fd = NULL; + /* validate the restore options before start the actual operation */ validate_restore_options(argv, opts); decryptfile = checkDecryptArchive(&inputFileSpec, (ArchiveFormat)opts->format, decrypt_key); diff --git a/src/test/regress/input/gs_dump.source b/src/test/regress/input/gs_dump.source index a148fe413..c0faa397d 100644 --- a/src/test/regress/input/gs_dump.source +++ b/src/test/regress/input/gs_dump.source @@ -339,7 +339,7 @@ export PGUSER=zcl ================================================================================================================================================================ ---f @abs_srcdir@/t test \! @abs_bindir@/gs_dump -p @portstring@ postgres --file='@abs_srcdir@/tb1_zcl_shcema' -f @abs_srcdir@/t -n zcl --inserts -\! @abs_bindir@/gs_restore -d postgres -p @portstring@ -U zcl -W TestPwd@123 -f @abs_srcdir@/t '@abs_srcdir@/tb1_zcl_shcema' -c +\! @abs_bindir@/gs_restore -d postgres -p @portstring@ -U zcl -W TestPwd@123 -f @abs_srcdir@/t -c \! @abs_bindir@/gs_dump -p @portstring@ postgres -f '@abs_srcdir@/tb1_zcl_shcema1' -f @abs_srcdir@/t -n zcl --inserts --Export all information in a schema and insert statements in SQL format in insert mode. \! @abs_bindir@/gs_dump -p @portstring@ postgres -f '@abs_srcdir@/tb1_zcl_shcema2' -f @abs_srcdir@/t -n zcl --disable-dollar-quoting diff --git a/src/test/regress/input/gs_restore.source b/src/test/regress/input/gs_restore.source index 57b355e7b..1e9de4929 100644 --- a/src/test/regress/input/gs_restore.source +++ b/src/test/regress/input/gs_restore.source @@ -262,7 +262,7 @@ gsql \! @abs_bindir@/gsql -d postgres -p @portstring@ -c "ALTER DATABASE music OWNER TO jim;" \! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create tablespace tbs_user_default LOCATION '@abs_srcdir@/data/tbs_user_default_01';" \! @abs_bindir@/gs_restore -d music -p @portstring@ -L musicmultischema.sql -F d musicmultischema -j 1 -\! @abs_bindir@/gs_restore -d music -p @portstring@ -L musicmultischema.sql -F d musicmultischema -j 3 -c --±¨´í +\! @abs_bindir@/gs_restore -d music -p @portstring@ -L musicmultischema.sql -F d musicmultischema -j 3 -c --报错 \! @abs_bindir@/gsql -d postgres -p @portstring@ -c "set current_schema to zcl;" \! @abs_bindir@/gsql -d postgres -p @portstring@ -c "\dt" \! @abs_bindir@/gsql -d postgres -p @portstring@ -c "\df" diff --git a/src/test/regress/output/gs_dump.source b/src/test/regress/output/gs_dump.source index c42ca927e..9d3a01367 100644 --- a/src/test/regress/output/gs_dump.source +++ b/src/test/regress/output/gs_dump.source @@ -2955,9 +2955,8 @@ connection to database "postgres" failed: FATAL: Invalid username/password,logi --?gs_dump[port='@portstring@'][postgres][.*]: [100.00%] 421 objects have been dumped. --?gs_dump[port='@portstring@'][postgres][.*]: dump database postgres successfully --?gs_dump[port='@portstring@'][postgres][.*]: total time: .* ms -\! @abs_bindir@/gs_restore -d postgres -p @portstring@ -U zcl -W TestPwd@123 -f @abs_srcdir@/t '@abs_srcdir@/tb1_zcl_shcema' -c -gs_restore: options -d/--dbname and -f/--file cannot be used together -Try "gs_restore --help" for more information. +\! @abs_bindir@/gs_restore -d postgres -p @portstring@ -U zcl -W TestPwd@123 -f @abs_srcdir@/t -c +Mandatory to specify dump filename/path for gs_restore \! @abs_bindir@/gs_dump -p @portstring@ postgres -f '@abs_srcdir@/tb1_zcl_shcema1' -f @abs_srcdir@/t -n zcl --inserts --?gs_dump[port='@portstring@'][postgres][.*]: The total objects number is 421. --?gs_dump[port='@portstring@'][postgres][.*]: [100.00%] 421 objects have been dumped. diff --git a/src/test/regress/output/gs_restore.source b/src/test/regress/output/gs_restore.source index cc0c3fd6c..dd08d4430 100644 --- a/src/test/regress/output/gs_restore.source +++ b/src/test/regress/output/gs_restore.source @@ -827,8 +827,8 @@ ALTER DATABASE ERROR: tablespace "tbs_user_default" already exists \! @abs_bindir@/gs_restore -d music -p @portstring@ -L musicmultischema.sql -F d musicmultischema -j 1 changing permissions for file "@abs_srcdir@/musicmultischema/toc.dat" failed with: Not a directory -\! @abs_bindir@/gs_restore -d music -p @portstring@ -L musicmultischema.sql -F d musicmultischema -j 3 -c --±¨´í -@abs_bindir@/gs_restore: unrecognized option '--±¨´í' +\! @abs_bindir@/gs_restore -d music -p @portstring@ -L musicmultischema.sql -F d musicmultischema -j 3 -c --报错 +@abs_bindir@/gs_restore: unrecognized option '--报错' Try "gs_restore --help" for more information. \! @abs_bindir@/gsql -d postgres -p @portstring@ -c "set current_schema to zcl;" SET @@ -1064,24 +1064,24 @@ ERROR at pg_backup_tar.cpp : 1214 : The destination buffer or format is a NULL p --role=ROLENAME/--rolepassword=ROLEPASSWORD -------------------------------------------------------------------------------------------------------------------- \! @abs_bindir@/gs_restore -d postgres -p @portstring@ -F t tb1_zcl_shcema2 -v -e -could not find header for file "toc.dat" in tar archive +@abs_srcdir@/tb1_zcl_shcema2: No such file or directory \! @abs_bindir@/gs_restore -d postgres -p @portstring@ -F t tb1_zcl_shcema2 --no-tablespaces -v -could not find header for file "toc.dat" in tar archive +@abs_srcdir@/tb1_zcl_shcema2: No such file or directory \! @abs_bindir@/gs_restore -d postgres -p @portstring@ -F t tb1_zcl_shcema2 -a -v -could not find header for file "toc.dat" in tar archive +@abs_srcdir@/tb1_zcl_shcema2: No such file or directory \! @abs_bindir@/gs_restore -d postgres -p @portstring@ -F t tb1_zcl_shcema2 -a -could not find header for file "toc.dat" in tar archive +@abs_srcdir@/tb1_zcl_shcema2: No such file or directory \! @abs_bindir@/gs_restore -d postgres -p @portstring@ -F t tb1_zcl_shcema2 -a -e -could not find header for file "toc.dat" in tar archive +@abs_srcdir@/tb1_zcl_shcema2: No such file or directory \! @abs_bindir@/gs_restore -d postgres -p @portstring@ -F t tb1_zcl_shcema2 -a -c -gs_restore: options -c/--clean and -a/--data-only cannot be used together +@abs_srcdir@/tb1_zcl_shcema2: No such file or directory gsql \! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create user createdatabase PASSWORD 'data_123';" CREATE ROLE \! @abs_bindir@/gsql -d postgres -p @portstring@ -c "create database createdatabase owner createdatabase;" CREATE DATABASE \! @abs_bindir@/gs_restore -d postgres -p @portstring@ -F t tb1_zcl_shcema2 -C -could not find header for file "toc.dat" in tar archive +@abs_srcdir@/tb1_zcl_shcema2: No such file or directory gsql \! @abs_bindir@/gsql -d postgres -p @portstring@ -c "createdatabase=# set current_schema to zcl;" ERROR: syntax error at or near "createdatabase"