简体   繁体   中英

pg_restore - ignore specific error

I've been handed a project from a coworker with zero knowledge of Postgres. I'm trying to integrate a pg_restore into a Jenkins Pipeline job and it returns one error that I have been told is fine to overlook. However, this error obviously causes the Jenkins job to fail, which is unideal.

Is there a way to mitigate or stifle the output of this one error, without stopping any other (more serious) errors from being recorded?

The command I am running (with all personal data stripped) is

PGPASSWORD="password" pg_restore -h path -U user -d database filename -F c -c

and it returns this error (but executes successfully)

pg_restore: [archiver (db)] Error while PROCESSING TOC:
pg_restore: [archiver (db)] Error from TOC entry 8290; 0 0 COMMENT EXTENSION plpgsql 
pg_restore: [archiver (db)] could not execute query: ERROR:  must be owner of extension plpgsql
    Command was: COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';

Again, I have less than zero Postgres experience. Is there an easy way to ignore this one error, or is this just something I need to live with?

If you run pg_restore as the user who owns the extension in the source database, that would fix the problem for real.

For just suppressing the issue: with old-style script steps, adding #!/bin/sh -x as the first line would prevent it from aborting on a non-zero return code (Jenkins normally runs shells with the -e option as well). It's worth a shot with a pipeline build but I don't know for sure if it'll work the same way. If it does, do be aware that the script will continue after other bad return codes as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM