Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uWXQP-00FKIm-9G for pgsql-admin@arkaria.postgresql.org; Tue, 01 Jul 2025 09:37:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uWXQN-004tZC-Bq for pgsql-admin@arkaria.postgresql.org; Tue, 01 Jul 2025 09:37:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uWXQM-004tZ1-Vh for pgsql-admin@lists.postgresql.org; Tue, 01 Jul 2025 09:37:11 +0000 Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uWXQK-0054M8-2p for pgsql-admin@lists.postgresql.org; Tue, 01 Jul 2025 09:37:11 +0000 Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-60c6fea6742so10331047a12.1 for ; Tue, 01 Jul 2025 02:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1751362628; x=1751967428; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=8UDYrcCkMCu7DNBxk2APC6RyoqQwLShpjn6SPQIV9sA=; b=eNOwJZvdmxZOw4SthRhNAljCKVXrHzJDLTZXEi//xi2nVWt2D8G9MyWIFmTZG67B2l RznwMOPezZo1jHeJoBQZfMJyb5uO9m9SPLIULDmFNyE0HEpnFEyQ3QgWXa6lypDpzH4V N7Xbpn8mlWJ/GpwnlwQInn/sE2wX2ZlArAkLiDha/zBKdTRflnM5xh9ls8D3lsZWWiDp WNUWG6FYOExjQ6Qj0WIzTAi1C8EAaDdzvZcFz8TR1BxBy9GJwBIaxW/VbreB9SG+l1BQ ZnUOJ2QQqy6M5tNUSNV6qG8syTz+zxdV3Sd/6mR+DOUWrdlWqFqjBmFOAZhgcc8/N2hB GJ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751362628; x=1751967428; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=8UDYrcCkMCu7DNBxk2APC6RyoqQwLShpjn6SPQIV9sA=; b=vffiKhxmpdTe32ApM83+36jP5BV2uX6mIsxEewVOnNxCyzoY7VWnNhw30bmNU1OLez QHbS9HXx//eiE9/sjTBJZkpyRe/2Ph3OgeUlh07bIgN0OJ7Xauyeqfm8QelakgeGM13G luA2nBQwrfbakq5tC0RbpiGtpToDhJeeqJiKv5KbxIGgJVZQVp16ORqz1LEX5kN9K0C9 UgLvD8n1lhHE8XWf4IrCE237bOaZACtMqClXdyArxJQpLw4DWL2ssFmw9f5T5dFcKfO3 Ima4/kVnYHlOcQ3KUEmep8chaMzFUAmuSm32zjYCitVkaXfSG0uZaTK5WK9YByoHweNY eoaw== X-Forwarded-Encrypted: i=1; AJvYcCUyrlTFSjXM0Oz+sLS4DqJ+BmkSLvdB7KAX+okgJRaRscofOT847QUjM+sNGHeFhO1xDmE2AG341wUZjg==@lists.postgresql.org X-Gm-Message-State: AOJu0YyKM8gfj7O3VFTLLxvRqBf3wPfYVfCxQ7Nh8hWH3/BwT1EYCmEO lLDZ/acRmgWHW4qbrKGX6asykHUYwMxutXOTC5SZnVuwEO7kYjbyqYP+HeBpJzSbyK3uQIXSUer 33Zhi X-Gm-Gg: ASbGncusDf8W2FZzCACrDhXiWaGGl3gYsHxmQycDMHmhULwea5P0u/sF96o1JE07rTL H49BjV1qTY2EwtNdHPk68kd/YMfWiYV+f1RLsZVcHIZwm3oWxgdBiYMhB/t+lbKRQVp2mkLQL7m ZwAoHOb7J4szN+jtQUl+O3Maauc6rjXg5Ciqqa9iRyBd6237XEulAT4XWo2q180KbN3dQdsuM2W 0pPYwmBpP0gz32tRvxmzsltbJm6nUcxVAfBXrDOa6NzfnMvY//TYcY3yNKHbhnRxghxgbHluzjY DquwQ1bj+Wj+iLoBi0zxgKHC/AO7EnYXpSORAkl0VNNq2k+g3z+aKH3qXhFlv40Sh1ZBM3MHgae ivaneub9GTIbfvp0v X-Google-Smtp-Source: AGHT+IH/mbxaseILVEJFTlB9N38EgBDizOE+q1R3Tmh/I5Yat8+CxQKjJF+ToVPqjD54heKPOjb/IQ== X-Received: by 2002:a17:907:f507:b0:ae0:68a8:bd6a with SMTP id a640c23a62f3a-ae34fd9a82bmr1494932266b.15.1751362627693; Tue, 01 Jul 2025 02:37:07 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:260:cf0d:694c:a36b:6bd2:90d5]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ae35363b1b9sm843282766b.12.2025.07.01.02.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Jul 2025 02:37:07 -0700 (PDT) Message-ID: <396f2fb636248f329c152c6eca189f4348fec726.camel@cybertec.at> Subject: Re: pg_upgrade failure due to dependencies From: Laurenz Albe To: Nikhil Shetty , Pgsql-admin Date: Tue, 01 Jul 2025 11:37:06 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-1.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2025-07-01 at 11:23 +0530, Nikhil Shetty wrote: > I was trying an upgrade from=C2=A0PostgreSQL 13 and PostGIS 3.1.2 TO Post= greSQL 15 and PostGIS 3.4.2 and got below error >=20 > pg_restore: creating TABLE "table1" > pg_restore: while PROCESSING TOC: > pg_restore: from TOC entry 551; 1259 39789310 TABLE table1 db1 > pg_restore: error: could not execute query: ERROR: relation "public.spat= ial_ref_sys" does not exist > LINE 1: ...LECT proj4text, auth_name, auth_srid, srtext FROM public.spa..= . > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0^ > QUERY: SELECT proj4text, auth_name, auth_srid, srtext FROM public.spatia= l_ref_sys WHERE srid =3D 3857 LIMIT 1 > Command was: >=20 >=20 > Table Structure=20 >=20 > CREATE TABLE table1 ( > =C2=A0=C2=A0=C2=A0=C2=A0"id1" numeric NOT NULL, > =C2=A0=C2=A0=C2=A0=C2=A0"geom" "public"."geometry"(Geometry,4326), > =C2=A0=C2=A0=C2=A0=C2=A0"geom_3857" "public"."geometry"(Geometry,3857) GE= NERATED ALWAYS AS ("public"."st_transform"("public"."st_intersection"("geom= ", "public"."st_transform"("public"."st_tileenvelope"(0, 0, 0), 4326)), 385= 7)) STORED > ); >=20 > The st_transform function used in above table definition uses=C2=A0public= .spatial_ref_sys to check the SRID > but since public.spatial_ref_sys is not restored yet, the table creation = for table1 fails >=20 > I checked with the PostGIS community and they suggested this needs to be = fixed in pg_upgrade because > it is not checking the dependencies in this particular case. Even if it r= estores public.spatial_ref_sys > first, another problem here is that it is checking for a record in the 'p= ublic.spatial_ref_sys' table > which does not exist and would be populated during the upgrade link. >=20 > I am adding this in the community to check if there is a way to fix this = kind of problem during upgrade? The PostGIS people must be misinformed. The fault is clearly theirs for marking the function st_transform(geometry,= text, integer) as IMMUTABLE: \sf st_transform(geometry, text, integer) CREATE OR REPLACE FUNCTION public.st_transform(geom geometry, from_proj t= ext, to_srid integer) RETURNS geometry LANGUAGE sql IMMUTABLE PARALLEL SAFE STRICT COST 5000 AS $function$SELECT public.postgis_transform_geometry($1, $2, proj4text, = $3) FROM public.spatial_ref_sys WHERE srid=3D$3;$function$ Anything that selects from a table may not be marked IMMUTABLE, since the c= ontents of the table can change. In your case, the table did not even exist. Moreover, PostgreSQL cannot check dependencies, since the function was defi= ned using the "old" style for SQL functions, where the function body is just a string. If they= had used the standard conforming new style, PostgreSQL would try to trach dependencies. Not sure= if that would have been enough to avoid the problem, but clearly better. Did you open a bug report on https://trac.osgeo.org/postgis ? Yours, Laurenz Albe