Re: [PATCH] minor bug fix for pg_dump --clean

From: Виктория Шепард <we(dot)viktory(at)gmail(dot)com>
To: Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] minor bug fix for pg_dump --clean
Date: 2022-10-24 00:12:46
Message-ID: CAAB=fdO2zpwqyHOxUQzwi7G6Dh7RJCydqj3nHpZ0OkGdaM0fQQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Good catch! Here are several points for improvement:
1. pg_dump.c:17380
Maybe better to write simpler

appendPQExpBuffer(delcmd, "CREATE SCHEMA IF NOT EXISTS %s;\n",
tbinfo->dobj.namespace->dobj.name);

because there is a schema name inside the `tbinfo->dobj.namespace->dobj.name
`

2. pg_backup_archiver.c:588
Here are no necessary spaces before and after braces, and no spaces around
the '+' sign.

( strncmp(dropStmt, "CREATE SCHEMA IF NOT EXISTS", 27) == 0 &&
strstr(dropStmt+29, "CREATE OR REPLACE VIEW") ))

Best regards,
Viktoria Shepard

чт, 1 сент. 2022 г. в 12:13, Frédéric Yhuel <frederic(dot)yhuel(at)dalibo(dot)com>:

> Hello,
>
> When using pg_dump (or pg_restore) with option "--clean", there is some
> SQL code to drop every objects at the beginning.
>
> The DROP statement for a view involving circular dependencies is :
>
> CREATE OR REPLACE VIEW [...]
>
> (see commit message of d8c05aff for a much better explanation)
>
> If the view is not in the "public" schema, and the target database is
> empty, this statement fails, because the schema hasn't been created yet.
>
> The attached patches are a TAP test which can be used to reproduce the
> bug, and a proposed fix. They apply to the master branch.
>
> Best regards,
> Frédéric

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-10-24 01:01:40 Re: [PATCH] minor bug fix for pg_dump --clean
Previous Message Andres Freund 2022-10-24 00:05:02 Re: Use simplehash.h instead of dynahash in SMgr