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 1sp8EV-00GrD0-B0 for pgsql-docs@arkaria.postgresql.org; Fri, 13 Sep 2024 15:29:16 +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 1sp8EU-005OhR-Ok for pgsql-docs@arkaria.postgresql.org; Fri, 13 Sep 2024 15:29:14 +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 1sp8EU-005OhJ-GE for pgsql-docs@lists.postgresql.org; Fri, 13 Sep 2024 15:29:14 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sp8EQ-0010fM-Td for pgsql-docs@lists.postgresql.org; Fri, 13 Sep 2024 15:29:13 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42cb60aff1eso22082515e9.0 for ; Fri, 13 Sep 2024 08:29:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726241351; x=1726846151; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=s7P1SdxU+6+k4ZlxBN3ZqcAWAkWQWS0LwjBF5g1l5Ws=; b=DE52Wq6xlHjhpdNH6bVK2TpjD8rLNlzhOGV1Z86mN2RosbT8gOEYaxFPv28IOl2BPS Km1wKI+ANhEj+tA36fach02gcLUlhYtSzoZynl4/hv4bmXD5PwpCjHk6gFwG4DGAWEG7 KFeMDcUOrfPRYKLJD/FnpXuR2qm6i2/hA7r5jmzjgSlJSgj2zEX2neArxFjfkVU0ucy3 5Rr9XcBwz5QPJOysg8v6ajrcpIjx5q70ML5CCYraQtP/NdCfoESr9Jp8/HTC9Szz+QLp NtPMg0OsZ5fYOwnkfptrD/poc+95236DcDgblC945VSadsrk4qreUUc9CMynGB0wxx+9 Bx6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726241351; x=1726846151; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s7P1SdxU+6+k4ZlxBN3ZqcAWAkWQWS0LwjBF5g1l5Ws=; b=WDZuiyjijs0+FiSNaygjY0I92+GDIod4oSjhzL6+9TlHHA/r6PKf/4OUimUESApHKd HUxBJki3Mk5keb/1718elUVDBvPUGhsV/FJ37pmd/eHoGXATAgDIxNfWbTmIoKMTGz/d HbrgRBA4UkgtNCdCIh9ihzcP+XAsEXU4UcNsKNsCW7a/5IOuiSVulLxrgfhL3sxkzDMN stXAsf17NWcmAaQUaWGv6ccePvuZEYskLJ0uKGg29cRdllcYIHQtw7kYroUoFRd0h5Cd S7laJWR4QTNDx2jDdkDRYyE5y1J12U8uzPnXWQ46OkbuplghBnj3mRtsb4aKS1UtyI0T Oqbw== X-Gm-Message-State: AOJu0YxJ98hhwG28XDnSNh+oFbQBVR09AjluSY1sYRg5xVwkAEdIrVcF WsaY8Yb37O3QkksBd+EdklsAKGkmTYdfV+9jesIM6shw/f+8x0QnwSlMFQ== X-Google-Smtp-Source: AGHT+IE/aJkmuwVTab/zBicREDQ9tJspjrR4HPMAC8gJUaFvK4pMX4nqC/sQPqxyl0JihJsCZ0x2Rg== X-Received: by 2002:a05:600c:45ce:b0:428:18d9:9963 with SMTP id 5b1f17b1804b1-42cdb586d9fmr58015265e9.22.1726241350478; Fri, 13 Sep 2024 08:29:10 -0700 (PDT) Received: from smtpclient.apple ([2a02:121f:3ed6:0:79ca:63e4:4277:9a41]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42d9b05c984sm30028355e9.11.2024.09.13.08.29.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Sep 2024 08:29:09 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Subject: Re: Undocumented optionality of handler_statements From: Philipp Salvisberg In-Reply-To: Date: Fri, 13 Sep 2024 17:28:58 +0200 Cc: pgsql-docs@lists.postgresql.org Content-Transfer-Encoding: 7bit Message-Id: References: <172165655256.710.2097726158572647813@wrigleys.postgresql.org> To: Michael Paquier X-Mailer: Apple Mail (2.3776.700.51) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk >> Therefore, I suggest to change this example by adding a NULL >> statement as in other examples. This change would make the >> documentation consistent and handle the optionality of >> handler_statements as an implementation detail. I created a patch >> for plpgsql.sgml based on the master branch, adding a NULL statement >> in empty exception handlers (see attached file >> doc_patch_using_null_stmt_instead_of_empty_exception_handler_v1.diff). > > These examples have been around for 20 years with, and I think that it > is helpful to show this pattern as well. So if I were to do something > about that, I would suggest the attached. I agree. Expressing the optionality in the synopsis/EBNF is the better way. Therefore I suggest adding the optionality also for the "statements" in this section (43.6.8. Trapping Errors). And of course, the optionality should be added for all related "statements" in other sections such as - 43.2. Structure of PL/pgSQL - 43.6.4.1. IF-THEN - 43.6.4.2. IF-THEN-ELSE - 43.6.4.3. IF-THEN-ELSIF - 43.6.4.4. Simple CASE - 43.6.4.5. Searched CASE - 43.6.5.1. LOOP - 43.6.5.4. WHILE - 43.6.5.5. FOR (Integer Variant) - 43.6.6. Looping through Query Results - 43.6.7. Looping through Arrays - 43.7.4. Looping through a Cursor's Result The PL/pgSQL implementation allows empty branches.