Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1a38-0006GL-1v for pgsql-general@arkaria.postgresql.org; Thu, 08 Jul 2021 19:51:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m1a36-0002TE-SP for pgsql-general@arkaria.postgresql.org; Thu, 08 Jul 2021 19:51:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1a36-0002Sw-DE for pgsql-general@lists.postgresql.org; Thu, 08 Jul 2021 19:51:04 +0000 Received: from mail-il1-x12c.google.com ([2607:f8b0:4864:20::12c]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m1a32-00011d-Pz for pgsql-general@lists.postgresql.org; Thu, 08 Jul 2021 19:51:03 +0000 Received: by mail-il1-x12c.google.com with SMTP id j12so7825194ils.5 for ; Thu, 08 Jul 2021 12:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:mime-version:message-id:date:from:to:subject; bh=uPP01N6O0dClclO/cGiJ9/vHKoMX5SvELf0sJJVbXFA=; b=bM9lVoeKAIgEc8+wLj5YkcGNuaugIu3x2sdlNW7PS8SrpI+J38gZDbJHA+zw5sKWE2 UbKhwzz9HUi61398V/JhqgYeZ1iecKvAFnupZdGFXC9V99AXNI+yMFvVk1c8xTSxtRDC EuxedziekDIFAgtWo/ElnnFHfsqhdfsWEkaANLY1/ouz8/JTUqfuTXSWAgt/dq6feCRW YDylqzYkDhfMa+VQsNfKJ3E69nY1UJSNW/XdrazFpQ3lBTbe12L00rk4f7zY9sHGHUXy 9bn1tVk6ZKrRpdLApXe+TUT/GX2A+Z0qN5AJsT/gIVJdvgX0yezNc9n68ztbwU215p1V PV6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:mime-version:message-id:date:from:to :subject; bh=uPP01N6O0dClclO/cGiJ9/vHKoMX5SvELf0sJJVbXFA=; b=U+5psKMmislkcLtdBS7BLeDuARfcuqOWAgsT5Y3aog1cnaTxKmTatYZA7OMqTl82Ti SO5gdFJE/Igss+gQUQJ4/GtR2zK0MZlI0Hvbkgu5zca0+f2BbvJuLwwFsXbNql6X86I7 HoWDCNtl3eiTmcOcEsbT9/8wBYLfGmQrn+kTF2PYvXPHYqReorZq+RSbYZUmtiQ7UMHa qnTb8Cs7uajh5nlBrsEBgiHwUyuo5VuQRoDBLC4iZzYL3/rk7eD6rpGPzQ3HdK9cOpWI EJ+Zs4jktD03eordqSmUDmPbmxNtFywQVUg+6Tpt9IOP/jsD07l+MuYCxZ3Y6oMVvkGN /SBg== X-Gm-Message-State: AOAM5310A5hK9ZUs0CB/UcHTYqpMaZ24SjaO/mDU2h6I9XO7nV8bBCwK QmUWyndEkJRgfszeFfiFZAKEnvmKp1c= X-Google-Smtp-Source: ABdhPJzkeyOn0upuDqMWhEhg8QQiiy4s7OauOrHsVw/M4oXeeFd6y+mcweefvNn3q/sYibwlduWx3A== X-Received: by 2002:a92:c10d:: with SMTP id p13mr1060422ile.83.1625773859188; Thu, 08 Jul 2021 12:50:59 -0700 (PDT) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id m184sm1735957ioa.17.2021.07.08.12.50.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jul 2021 12:50:58 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id 179DB27C0054 for ; Thu, 8 Jul 2021 15:50:57 -0400 (EDT) Received: from imap42 ([10.202.2.92]) by compute4.internal (MEProxy); Thu, 08 Jul 2021 15:50:58 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrtdeggddufeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfffhffvufgtsehttdertd erreejnecuhfhrohhmpedfvehhrhhishhtohhphhgvrhcuvegruhhsvghrfdcuoegthhih rdgtrghushgvrhesghhmrghilhdrtghomheqnecuggftrfgrthhtvghrnhepueeuveffvd eufeelgfduleejveejfffffeegleefveekgedthfegudfhgefggeejnecuffhomhgrihhn pehsthgrtghkohhvvghrfhhlohifrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomheptghhhigtodhmvghsmhhtphgruhhthhhpvghrshho nhgrlhhithihqdeiheektddvkedtkedqudeijeekvddukeegqdgthhihrdgtrghushgvrh eppehgmhgrihhlrdgtohhmsehpohgsohigrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4450B2180062; Thu, 8 Jul 2021 15:50:57 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-531-g1160beca77-fm-20210705.001-g1160beca Mime-Version: 1.0 Message-Id: <8a602a2a-e0b8-42ef-8468-21fa2eb25bd9@www.fastmail.com> Date: Thu, 08 Jul 2021 20:50:36 +0100 From: "Christopher Causer" To: pgsql-general@lists.postgresql.org Subject: =?UTF-8?Q?pg=5Fdump's_restore_gives_"operator_does_not_exist:_public.ipr?= =?UTF-8?Q?ange_=3D_public.iprange"_but_copy_paste_works?= Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, I originally posted this as a StackOverflow question[1], but one of the responses there suggested I may get further help here on pgsql-general. The question is perhaps a little more fleshed out than what follows, but I hope this email is self-contained. I have a large database whose schema I have recently changed. Since then I cannot restore its dump using the normal `psql -1 -f ...` route. Running `psql -1 -f ...` gives the error shown in the subject, yet pasting the failing view in the terminal afterwards is successful. To cut a long story short, I pruned the schema to ~100 lines but something that can reproduce the error shown in the subject. The testcase is appended to this email for completeness[2]. No lines have been changed; I have only deleted lines to whittle the production dump down to something that is copy-paste friendly. One helpful person there was able to find the line created by pg_dump which causes the error ``` SELECT pg_catalog.set_config('search_path', '', false); ``` However, I do not know the knock-on effects of removing this line, and it doesn't help that I will have to edit the dumps every time I wish to restore them. Is there something I can do to pg_dump which can suppress this error in the general case? Is this a bug or have I done something wrong myself? The relevant details of the Debian stretch host: ii postgresql-9.6-ip4r 2.4-1.pgdg80+1 ii postgresql-client-9.6 9.6.22-0+deb9u1 ii postgresql-contrib-9.6 9.6.22-0+deb9u1 Many thanks for your time on this Christopher --------------------------------------------------------------------- [1] https://stackoverflow.com/questions/68282538/pg-dumps-restore-gives-operator-does-not-exist-public-iprange-public-iprang?noredirect=1#comment120721406_68282538 [2] ``` SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; SET xmloption = content; SET client_min_messages = warning; SET row_security = off; CREATE SCHEMA archive; CREATE SCHEMA auth; CREATE SCHEMA data; CREATE SCHEMA minion; CREATE SCHEMA user_views; CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; CREATE EXTENSION IF NOT EXISTS ip4r WITH SCHEMA public; CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public; CREATE TABLE data.subnet_dhcp_options_updates_log ( subnet_range public.iprange NOT NULL, txid bigint NOT NULL, last_update timestamp without time zone NOT NULL ); CREATE FUNCTION public.subnet_dhcp_option_last_update(arg_subnet_range public.iprange) RETURNS timestamp without time zone LANGUAGE sql STABLE AS $$ select last_update from data.subnet_dhcp_options_updates_log where subnet_range = arg_subnet_range; $$; CREATE TABLE data.subnets ( id uuid DEFAULT public.uuid_generate_v4() NOT NULL, subnet_range public.iprange NOT NULL, comment text DEFAULT ''::text NOT NULL, created_in_transaction bigint DEFAULT txid_current() NOT NULL, deleted_in_transaction bigint, subnet_name text DEFAULT ''::text NOT NULL, is_visible boolean DEFAULT true NOT NULL ); CREATE VIEW archive.subnets AS SELECT subnets.id, subnets.subnet_range, subnets.comment, subnets.created_in_transaction, subnets.deleted_in_transaction, subnets.subnet_name, subnets.is_visible, public.family(subnets.subnet_range) AS ip_version FROM data.subnets; CREATE TABLE data.subnet_dhcp_options ( id uuid NOT NULL, kea_subnet_id integer NOT NULL, subnet_range public.iprange NOT NULL, subnet_pools public.iprange[] DEFAULT '{}'::public.iprange[] NOT NULL, dhcp_options jsonb DEFAULT '{}'::jsonb NOT NULL, unknown_client_leases boolean NOT NULL, comment text DEFAULT ''::text NOT NULL, created_in_transaction bigint DEFAULT txid_current() NOT NULL, deleted_in_transaction bigint ); CREATE VIEW public.subnets AS SELECT subnets.id, subnets.subnet_range, subnets.comment, subnets.created_in_transaction, subnets.deleted_in_transaction, subnets.subnet_name, subnets.is_visible, subnets.ip_version FROM archive.subnets WHERE (subnets.deleted_in_transaction IS NULL); CREATE VIEW archive.subnet_dhcp_options AS SELECT sdo.id, sdo.subnet_range, (sdo.subnet_pools)::text[] AS subnet_pools, sdo.dhcp_options, sdo.unknown_client_leases, sdo.kea_subnet_id, public.family(sdo.subnet_range) AS ip_version, sdo.comment, sdo.created_in_transaction, sdo.deleted_in_transaction, array_to_string((sdo.subnet_pools)::text[], ' '::text) AS subnet_pools_as_string, public.subnet_dhcp_option_last_update(sdo.subnet_range) AS last_update, s.id AS subnet_id FROM (data.subnet_dhcp_options sdo JOIN public.subnets s USING (subnet_range)); ```