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 1iNeAd-0006nZ-OT for pgsql-general@arkaria.postgresql.org; Thu, 24 Oct 2019 14:32:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iNeAc-0003Y5-Fy for pgsql-general@arkaria.postgresql.org; Thu, 24 Oct 2019 14:32:58 +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 1iNeAc-0003Xy-6n for pgsql-general@lists.postgresql.org; Thu, 24 Oct 2019 14:32:58 +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 1iNeAZ-0001dm-Co for pgsql-general@postgresql.org; Thu, 24 Oct 2019 14:32:57 +0000 Received: from panix2.panix.com (panix2.panix.com [166.84.1.2]) by mailbackend.panix.com (Postfix) with ESMTP id 46zV8P3RG9z1BwF; Thu, 24 Oct 2019 10:32:53 -0400 (EDT) Received: by panix2.panix.com (Postfix, from userid 17622) id 46zV8P2TDPz1ZVn; Thu, 24 Oct 2019 10:32:53 -0400 (EDT) Date: Thu, 24 Oct 2019 10:32:53 -0400 From: stan To: Adrian Klaver Cc: pgsql-general@postgresql.org Subject: Re: A very puzzling backup/restore problem Message-ID: <20191024143253.GA16590@panix.com> References: <20191024105227.GA13265@panix.com> <4fc52554-6dad-b833-c800-7f91172c7cf1@aklaver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <4fc52554-6dad-b833-c800-7f91172c7cf1@aklaver.com> 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 On Thu, Oct 24, 2019 at 07:04:11AM -0700, Adrian Klaver wrote: > On 10/24/19 3:52 AM, stan wrote: > >=20 > >=20 > > I have a very confusing isse. I am trying to backup and restre a signle > > table . > >=20 > > first I dump the table. >=20 > Actually you are just dumping the table data. >=20 > More below. > >=20 > >=20 > > Script started on 2019-10-24 06:29:12-0400 > > =1B]0;stan@smokey: ~=07stan@smokey:~$ pg_dump -a --table task_instance = > task_instance.dump > >=20 > > Then I connect to the db, and verify that things are as expected. > >=20 > > =1B]0;stan@smokey: ~=07stan@smokey:~$ psql > > psql (11.5 (Ubuntu 11.5-3.pgdg18.04+1)) > > Type "help" for help. > >=20 > > =1B[1m[local] stan@stan=3D=1B[0m> \dt > > List of relations > > Schema | Name | Type | Owner > > --------+--------------------------+-------+------- > > 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) > >=20 > > =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 > > ---------------+--------------------------+-----------+----------+-----= --------- =08--------------------------------- > > task_instance | integer | | not null | nex= tval('task =08_instance_key_serial'::regclass) > > project_key | integer | | not null | > > employee_key | integer | | not null | > > work_type_key | integer | | not null | > > hours | numeric(5,2) | | not null | > > work_start | timestamp with time zone | | not null | > > work_end | timestamp with time zone | | not null | > > modtime | timestamp with time zone | | not null | CUR= RENT_TIMES =08TAMP > > lock | boolean | | | true > > descrip | character varying | | | > > Indexes: > > "task_instance_pkey" PRIMARY KEY, btree (task_instance) > > "task_constraint" UNIQUE CONSTRAINT, btree (employee_key, work_typ= e_key, pro =08ject_key, work_start, work_end) > > Foreign-key constraints: > > "task_instance_employee_key_fkey" FOREIGN KEY (employee_key) REFER= ENCES 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 "pu= blic.permitted_work" > > Column | Type | Collation | Nullable | = Default =08 > > ---------------+--------------------------+-----------+----------+-----= --------- =08----- > > employee_key | integer | | not null | > > work_type_key | integer | | not null | > > permit | boolean | | not null | fal= se > > modtime | timestamp with time zone | | not null | CUR= RENT_TIMES =08TAMP > > Indexes: > > "permit_constraint" UNIQUE CONSTRAINT, btree (employee_key, work_t= ype_key) > > Foreign-key constraints: > > "permitted_work_employee_key_fkey" FOREIGN KEY (employee_key) REFE= RENCES emp =08loyee(employee_key) ON DELETE RESTRICT > > "permitted_work_work_type_key_fkey" FOREIGN KEY (work_type_key) RE= FERENCES w =08ork_type(work_type_key) ON DELETE RESTRICT > >=20 > > Then I delete the rows from the table. > >=20 > > =1B[7m(END)=1B[27m=1B[K=1B[K=1B[?1l=1B>=1B[?1049l=1B[23;0;0t=1B[1m[loca= l] stan@stan=3D=1B[0m> delete from task_instance ; > > DELETE 31 > >=20 > > Then I try to restore from the dump file. > >=20 > > =1B[1m[local] stan@stan=3D=1B[0m> \i task_instance.dump > > SET > > SET > > SET > > SET > > SET > > set_config > > ------------ > > (1 row) > >=20 > > SET > > SET > > SET > > SET > > psql:task_instance.dump:55: ERROR: relation "permitted_work" does not = exist > > LINE 3: permitted_work > > ^ >=20 > In your \d task_instance above I do not see a trigger that calls > public.check_permission(). Does one exist or was it cut off the output you > pasted? It exists. Perhaps I am using a different /dt format? I am not accustomed to seeing the triggers when I do it. >=20 > Also look in the dump file. Given that you are using 11.5 I'm going to > assume it is resetting the search_path and that the unqualified schema n= ame > of permitted_work below is your issue. That makes sense. If I delete all the SET lines things do work. Is this a known bug on version 11.5? Or am I doing something incorrectly? BTW 11.5 is the latest package for Ubuntu, I believe. Should I start always specifying the schema? Seems to add confusion to me. Thanks for the education here. >=20 > > 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 sta= tement > > COPY task_instance, line 1: "1 1 1 8 17.50 2019-02-01 00:00:00-05 2019-= 02-08 00:00:00-05 2019-10-24 06:28:44.502699-04 t Drawings..." > >=20 > > After that error, U cannot see any objects in the table > >=20 > > =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 > >=20 > > Script done on 2019-10-24 06:30:48-0400 > >=20 > > quiting psql and reconecting shows that the obkects ARE there, with the > > taks)instance table empty. > >=20 > > What am I doing wrong? > >=20 >=20 >=20 > --=20 > Adrian Klaver > adrian.klaver@aklaver.com --=20 "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin