Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iNajL-0006LQ-6c for pgsql-general@arkaria.postgresql.org; Thu, 24 Oct 2019 10:52:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iNajK-0000WV-19 for pgsql-general@arkaria.postgresql.org; Thu, 24 Oct 2019 10:52:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iNajJ-0000WN-Ns for pgsql-general@lists.postgresql.org; Thu, 24 Oct 2019 10:52:33 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iNajG-0007YD-Uv for pgsql-general@lists.postgresql.org; Thu, 24 Oct 2019 10:52:33 +0000 Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id 46zPG42J6Fztxn for ; Thu, 24 Oct 2019 06:52:28 -0400 (EDT) Received: by panix2.panix.com (Postfix, from userid 17622) id 46zPG40v7lz1ZVn; Thu, 24 Oct 2019 06:52:28 -0400 (EDT) Date: Thu, 24 Oct 2019 06:52:27 -0400 From: stan To: pgsql-general@lists.postgresql.org Subject: A very puzzling backup/restore problem Message-ID: <20191024105227.GA13265@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-Editor: gVim User-Agent: Mutt/1.12.1 (2019-06-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I have a very confusing isse. I am trying to backup and restre a signle table . first I dump the table. Script started on 2019-10-24 06:29:12-0400 =1B]0;stan@smokey: ~=07stan@smokey:~$ pg_dump -a --table task_instance > t= ask_instance.dump Then I connect to the db, and verify that things are as expected. =1B]0;stan@smokey: ~=07stan@smokey:~$ psql psql (11.5 (Ubuntu 11.5-3.pgdg18.04+1)) Type "help" for help. =1B[1m[local] stan@stan=3D=1B[0m> \dt List of relations Schema | Name | Type | Owner=20 --------+--------------------------+-------+------- public | biz_constants | table | stan public | bom_item | table | stan public | costing_unit | table | stan public | customer | table | stan public | earthquake | table | stan public | employee | table | stan public | expense_report_instance | table | stan public | gl_code | table | stan public | mfg | table | stan public | mfg_part | table | stan public | mfg_vendor_relationship | table | stan public | permitted_work | table | stan public | phone_number_test | table | stan public | project | table | stan public | project_budget_component | table | stan public | project_cost_category | table | stan public | rate | table | stan public | salary | table | stan public | task_instance | table | stan public | vendor | table | stan public | work_type | table | stan (21 rows) =1B[1m[local] stan@stan=3D=1B[0m> \d task_instance =1B[?1049h=1B[22;0;0t=1B[?1h=1B=3D = Table "public.task_instance" Column | Type | Collation | Nullable | = =08 Default =20 ---------------+--------------------------+-----------+----------+---------= ----- =08--------------------------------- task_instance | integer | | not null | nextval(= 'task =08_instance_key_serial'::regclass) project_key | integer | | not null |=20 employee_key | integer | | not null |=20 work_type_key | integer | | not null |=20 hours | numeric(5,2) | | not null |=20 work_start | timestamp with time zone | | not null |=20 work_end | timestamp with time zone | | not null |=20 modtime | timestamp with time zone | | not null | CURRENT_= TIMES =08TAMP lock | boolean | | | true descrip | character varying | | |=20 Indexes: "task_instance_pkey" PRIMARY KEY, btree (task_instance) "task_constraint" UNIQUE CONSTRAINT, btree (employee_key, work_type_key= , pro =08ject_key, work_start, work_end) Foreign-key constraints: "task_instance_employee_key_fkey" FOREIGN KEY (employee_key) REFERENCES= empl =08:=1B[K=1B[K=1B[?1l=1B>=1B[?1049l=1B[23;0;0t=1B[1m[local] stan@stan= =3D=1B[0m> \d permitted_work =1B[?1049h=1B[22;0;0t=1B[?1h=1B=3D Table "public= =2Epermitted_work" Column | Type | Collation | Nullable | Def= ault =08 =20 ---------------+--------------------------+-----------+----------+---------= ----- =08----- employee_key | integer | | not null |=20 work_type_key | integer | | not null |=20 permit | boolean | | not null | false modtime | timestamp with time zone | | not null | CURRENT_= TIMES =08TAMP Indexes: "permit_constraint" UNIQUE CONSTRAINT, btree (employee_key, work_type_k= ey) Foreign-key constraints: "permitted_work_employee_key_fkey" FOREIGN KEY (employee_key) REFERENCE= S emp =08loyee(employee_key) ON DELETE RESTRICT "permitted_work_work_type_key_fkey" FOREIGN KEY (work_type_key) REFEREN= CES w =08ork_type(work_type_key) ON DELETE RESTRICT Then I delete the rows from the table. =1B[7m(END)=1B[27m=1B[K=1B[K=1B[?1l=1B>=1B[?1049l=1B[23;0;0t=1B[1m[local] s= tan@stan=3D=1B[0m> delete from task_instance ; DELETE 31 Then I try to restore from the dump file. =1B[1m[local] stan@stan=3D=1B[0m> \i task_instance.dump SET SET SET SET SET set_config=20 ------------ =20 (1 row) SET SET SET SET psql:task_instance.dump:55: ERROR: relation "permitted_work" does not exist LINE 3: permitted_work ^ QUERY: SELECT permit FROM permitted_work WHERE NEW.employee_key =3D permitted_work.employee_key AND NEW.work_type_key =3D permitted_work.work_type_key CONTEXT: PL/pgSQL function public.check_permission() line 4 at SQL stateme= nt COPY task_instance, line 1: "1 1 1 8 17.50 2019-02-01 00:00:00-05 2019-02-0= 8 00:00:00-05 2019-10-24 06:28:44.502699-04 t Drawings..." After that error, U cannot see any objects in the table =1B[1m[local] stan@stan=3D=1B[0m> \dt Did not find any relations. =1B[1m[local] stan@stan=3D=1B[0m> \q =1B]0;stan@smokey: ~=07stan@smokey:~$ exit Script done on 2019-10-24 06:30:48-0400 quiting psql and reconecting shows that the obkects ARE there, with the taks)instance table empty. What am I doing wrong? --=20 "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin