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 1mgTDJ-0000dj-F0 for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Oct 2021 14:50:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mgTDH-0007OF-7N for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Oct 2021 14:50:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mgTDG-0007O5-Ta for pgsql-hackers@lists.postgresql.org; Fri, 29 Oct 2021 14:50:34 +0000 Received: from mail.tuxteam.de ([5.199.139.25]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.92) (envelope-from ) id 1mgTDD-0003xM-UT for pgsql-hackers@postgresql.org; Fri, 29 Oct 2021 14:50:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=hifYdgeFBeRtaOpWFWpKA+yO2eHfP7aQ6m9pWdWIFVI=; b=slrbQ7FHPyXLg64lg3moh5KMkEHXGDh10guyTtj2pzjbYT7Zb3DGkDotLHA9lR7RBlJIzpCurb9gyFJ4Yw8T8yUiH0Nt4tTtfHolHGFDgwjYNHN4ERGCTQiGr4JaEsOk9m7UtTUqpxkV38DweyfS2rTwvQwN8gOO2R5zEhTSF3XIrlhAp7Xwsjg3LVIiukqbqdFwGKxqrBj/5yobE3fGFCbolgAlEg2nM0oHKa2053Y+OEniorNQoWDZa/wVi1itAMqSZfaF3Zy8hndeODkdR+aJmmAQ44GdNOAzOjkmfHLN4rHPiM4m2aQNIkCoGXhYniLAUHQqIjBw9IyqZ8E1ng==; Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1mgTDC-0003dD-G8; Fri, 29 Oct 2021 16:50:30 +0200 Date: Fri, 29 Oct 2021 16:50:30 +0200 From: tomas@tuxteam.de To: Tom Lane Cc: pgsql-hackers@postgresql.org Subject: Re: plpgsql: can I use a variable in a DECLARE later whithin the DECLARE? Message-ID: <20211029145030.GA13799@tuxteam.de> References: <20211029121435.GA5414@tuxteam.de> <626327.1635516271@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="a8Wt8u1KmwUX3Y2C" Content-Disposition: inline In-Reply-To: <626327.1635516271@sss.pgh.pa.us> User-Agent: Mutt/1.5.21 (2010-09-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --a8Wt8u1KmwUX3Y2C Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 29, 2021 at 10:04:31AM -0400, Tom Lane wrote: > writes: > > In plpgsql, i'm trying to use a variable initialised in a DECLARE in > > a later initialisation expression whithin the same DECLARE: >=20 > > DECLARE > > x int :=3D 23; > > y int :=3D x + 4 > > BEGIN > > ... >=20 > > Experiments suggest that it works, but the docs are silent about that. > > Is this a good idea, or should I be more careful and do it in a nested > > block? >=20 > I don't see any reason to foresee that it would break. Thanks :) > However, I notice that we don't actually have any regression tests > checking this. scope_test() in plpgsql.sql checks an adjacent > question, but not exactly this one. I'm a bit inclined now to go > add such a test. Even more thanks. After a long hiatus I have the luck to play again with PostgreSQL. Let me say: you folks rock, seriously. Cheers - t --a8Wt8u1KmwUX3Y2C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAmF8CjYACgkQBcgs9XrR2kZ5bgCcC3Xb6JtPdgEFGyzWAZzJyibt 0qcAnjXUQ4tsKEKcItv+15ILenMexCfy =N3Ra -----END PGP SIGNATURE----- --a8Wt8u1KmwUX3Y2C--