Odd messages on reloading DB table

Поиск
Список
Период
Сортировка
Искать

Odd messages on reloading DB table

От:
Steve Wampler <swampler@nso.edu>
Дата:

With PostgreSQL 9.5.15, I ran:

    pg_dump -t targets -d atst.experimentdb >nT.db

then I ran:

    psql -h langley atst.experimentdb 

Re: Odd messages on reloading DB table

От:
Steve Wampler <swampler@nso.edu>
Дата:
On 2/7/19 9:28 AM, Steve Wampler wrote:
> With PostgreSQL 9.5.15, I ran:
> 
>     pg_dump -t targets -d atst.experimentdb >nT.db
> 
> then I ran:
> 
>     psql -h langley atst.experimentdb  
> and got:
...
>     ERROR:  relation "targets" already exists
>     ALTER TABLE
>     ERROR:  relation "targets" does not exist
>     LINE 1: UPDATE targets SET             time_stamp=new.time_stamp,   ...
>                 ^
>     QUERY:  UPDATE targets SET             time_stamp=new.time_stamp,            modified=new.modified, 
> id=new.id,            targets=new.targets     WHERE (id=new.id)
>     CONTEXT:  PL/pgSQL function public.targets_insert_or_update() line 1 at SQL statement
>     COPY targets, line 1: "2017-10-31 09:37:28.798152    t    az_el_target 
> {"name":"AZ_EL_Targets","priority":10,"tags":["{\\"Tag.tag..."
>     ERROR:  relation "id_id_targets" already exists
>     ERROR:  relation "time_stamp_id_targets" already exists
>     ERROR:  trigger "targets_trigger_insert" for relation "targets" already exists
> ERROR:  trigger "targets_trigger_update" for relation "targets" already exists
> REVOKE
> REVOKE
> GRANT
> GRANT
> 
> Eh?  It looks like it worked (maybe), but why:
> 
>     (1) the table already exist and the immediately doesn't exist?
>     (2) report ERROR on UPDATE when there are no UPDATES in the input file?

I take it back.  The content of the table was not restored to the values in nT.db afterall.
-- 
Steve Wampler -- swampler@nso.edu
The gods that smiled on your birth are now laughing out loud.

Re: Odd messages on reloading DB table

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Thursday, February 7, 2019, Steve Wampler <swampler@nso.edu> wrote:
   (1) the table already exist and the immediately doesn't exist?
   (2) report ERROR on UPDATE when there are no UPDATES in the input file
 

Most likely the first attempt was schema qualified and so found the existing targets table while the second attempt was not schema qualified and targets is not in the search path.

One guess I have is that triggers are involved here and those triggers need to be more resiliant in face of the recent search_path security update.

David J.

Re: Odd messages on reloading DB table

От:
Steve Wampler <swampler@nso.edu>
Дата:
On 2/7/19 3:24 PM, David G. Johnston wrote:
> On Thursday, February 7, 2019, Steve Wampler > wrote:
> 
>         (1) the table already exist and the immediately doesn't exist?
>         (2) report ERROR on UPDATE when there are no UPDATES in the input file
> 
> 
> 
> Most likely the first attempt was schema qualified and so found the existing targets table while the second attempt was 
> not schema qualified and targets is not in the search path.
> 
> One guess I have is that triggers are involved here and those triggers need to be more resiliant in face of the recent 
> search_path security update.

Thanks - but I thought the search_path update was a PG 10 change and so shouldn't reflect on 9.5.15 behavior.  Did it
get back-ported?

In any event I'm surprised that pg_dump for 9.5.15 can produce a dump that can't be restored by either pg_restore
(when -Fc is used on both ends) or with psql (without -Fc used on pg_dump).  I would have expected some message
from pg_dump if it ran into issues preventing this.


-- 
Steve Wampler -- swampler@nso.edu
The gods that smiled on your birth are now laughing out loud.

Re: Odd messages on reloading DB table

От:
"David G. Johnston" <david.g.johnston@gmail.com>
Дата:
On Mon, Feb 11, 2019 at 12:29 PM Steve Wampler  wrote:
> Thanks - but I thought the search_path update was a PG 10 change and so shouldn't reflect on 9.5.15 behavior.  Did it
> get back-ported?

Yes, it was deemed a security vulnerability and thus back-patched.
Release notes will indicate when that happened.

> In any event I'm surprised that pg_dump for 9.5.15 can produce a dump that can't be restored by either pg_restore
> (when -Fc is used on both ends) or with psql (without -Fc used on pg_dump).  I would have expected some message
> from pg_dump if it ran into issues preventing this.

pg_dump doesn't look into function bodies to make determinations - to
it those are just strings.  There are number of susceptible areas that
cannot be reliably detected during backup.  That is why it is
imperative that backups are restored before being considered valid (at
the least those backups that occur subsequent to a schema change).

David J.

FAQ