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 1tL5Lx-00Ce20-43 for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Dec 2024 18:53:01 +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 1tL5Lu-008Jq5-Ew for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Dec 2024 18:52:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tL5Lt-008Jpw-Tc for pgsql-hackers@lists.postgresql.org; Tue, 10 Dec 2024 18:52:59 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tL5Ls-0027wC-2b for pgsql-hackers@lists.postgresql.org; Tue, 10 Dec 2024 18:52:57 +0000 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-728e729562fso692778b3a.0 for ; Tue, 10 Dec 2024 10:52:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20230601.gappssmtp.com; s=20230601; t=1733856775; x=1734461575; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=X97jUyh5CpdXjF/s6z6O+vvTRhR8HZppgZz71L1+sHc=; b=WNJkrKd604fKfRzlNo9GhIq9hNn3hb5ZyIBwHySTzUQR1xAaerZOk+KHGp5zhYEQir Unf+s6bBilnVVx1cqVCrc8GIwdlOACgmJdFXIYQwW3xD52efyDZTml+gEDGMwxDeMDIG vBdBl1VjQRdrPk+kZmBaTNXJfesoOBaPb7mEoKgkhhEyyDSk1fzlfHSvsaUL7KC6Tjp9 EKIFxo3raBSnZ7SAawybmz0a0CAS987S7dksElMS6DhEH/loKKbjmbTjKsFDbuVtqcp6 dU1y1jitlkXAFcOYQhvb/A4dw0zvqLTZnilFag/orQmtPz6ZVObRelFC0vQHrZiu4tdv o6TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733856775; x=1734461575; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=X97jUyh5CpdXjF/s6z6O+vvTRhR8HZppgZz71L1+sHc=; b=AJsiSS90+ZPNKBWF4UZSJz1xfA2jZCBxwQbWQ73hVwDzGyE/N02q+4E+EHi8XTcBQB NqdJ8uzMDAagd3EWQsKho0f3oCVBnW6JNc0e9V4eFiXNgpvxtxIYcOQHsomxp9nEL8rf IsKIANWSw8lO4J42aZsTfTnRco4aM+HknKgMyk4bw1vqJYLsBcEbdEmOogH2y7sQm+zQ sb0SfwjBztMMFd6Onda8+LB5i4ijDHNG88xlwg+jGT/fn5rVuTVEzaLTBjEdGM6jBIqd B7eoVM6rDRApP4BS/na3oNjXy5dhZzae4Q4fcc6h5EhX+ZTyEWOLylEmk/C8gO53cAZ0 ddGA== X-Forwarded-Encrypted: i=1; AJvYcCUxOhKinFUZ2vopAtY3TjVPSJylA6Q8EuxlYbxDEBdp+dg+GBD7592WzSEGwnN18Rs1XCjGdmNVu3Oulo8z@lists.postgresql.org X-Gm-Message-State: AOJu0YxPCnEnoUbW2L5Gdscu5K2wcXGMyEUraJ+o4fX+tiuL7nWboZP3 uDp3jzc357cb+dkjwkELAnqzAtjpGRMyJJB9XuWRZygq4UrtmLDlzI0XmOyiMQ== X-Gm-Gg: ASbGnctmptmGihn3W7Rn7ZREQpycoZ2qORg5gn4ZIW7FSgzprJwqPxZbIY7NLlJHJad /r1a48tF04240ktuXpuJfQDb4ABZ/KuhKdgQBQWRiBVdSzTV3gvcAXFmNzbC41kkHu/sJmatqHM /bVE61H+SC2iOtH+X7rEnlRz9wPZ8CoFiuvl5NyVaphZN3Ex/OxgGZ7yKws1xTnDSYLx1HOcn8N eLsAuLQaQS3Yd60534PIK7kG3GWSDuhyivHxiNkCaN6BVqceCSYHWThrQtHfP4n16C0XxpZBmh8 yhrvaCo3R0coMdzddM0g X-Google-Smtp-Source: AGHT+IG5PFx5TI9NBaQsgp/GA6Chd0aDmRuGi0qRAskDZTsladCc+Ewc0XqmAghfDXXjT/xAsBUqFA== X-Received: by 2002:a05:6a20:8420:b0:1db:915b:ab11 with SMTP id adf61e73a8af0-1e1c12fb10emr631254637.24.1733856775072; Tue, 10 Dec 2024 10:52:55 -0800 (PST) Received: from jeff-laptop.lan (c-76-102-242-158.hsd1.ca.comcast.net. [76.102.242.158]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725d7cdb38fsm6096735b3a.110.2024.12.10.10.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2024 10:52:54 -0800 (PST) Message-ID: <5fbbebb78a9e5ecea8adbbc1ba720dd0ca6d5205.camel@j-davis.com> Subject: Re: Document NULL From: Jeff Davis To: "David G. Johnston" Cc: Yugo NAGATA , Tom Lane , Peter Eisentraut , David Rowley , PostgreSQL Hackers Date: Tue, 10 Dec 2024 10:52:53 -0800 In-Reply-To: References: <2074118.1714625223@sss.pgh.pa.us> <6c11f5a2-478c-42af-9208-e82bb710e78a@eisentraut.org> <2674591.1714751043@sss.pgh.pa.us> <20240619123412.7bd1f5fd827120192a24674a@sraoss.co.jp> <20240619141520.9fefb69d051fb112f41bf1d1@sraoss.co.jp> <54757.1718775943@sss.pgh.pa.us> <20240627121425.e0b6fa51b8f3682da11b3a6c@sranhm.sraoss.co.jp> <505f9dfcc6e84a442c6fbdf600ab1df1e5030603.camel@j-davis.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2024-12-09 at 15:27 -0700, David G. Johnston wrote: > I have not done this.=C2=A0 This is already a large patch and this kind o= f > example doesn't seem like our norm.=C2=A0 I'm not opposed to more content > like this but for now would leave considering it as something an > interested party can propose once this goes in. Fair enough Though I think it's a great example and I'd like to find some place to put it. >=20 > =C2=A0 =C2=A0 > =C2=A0 =C2=A0 The presence of null values in the system results in three-= valued > logic. > =C2=A0 =C2=A0 In conventional two-valued (binary) logic every outcome is = either > true or false. > =C2=A0 =C2=A0 In three-valued logic the concept of unknown, represented u= sing > the null value, is > =C2=A0 =C2=A0 also an outcome.=C2=A0 This results in falsifying the commo= n-sense > notion > =C2=A0 =C2=A0 that "p OR NOT p" is always true. > =C2=A0 =C2=A0 Thank you. I might reword the final sentence as more of an example, like: "Unknown values can lead to surprising behavior, for instance "NULL OR NOT NULL" evaluates to the null value." >=20 > When executing an aggregate or window function the state tracking > component > =C2=A0 =C2=A0(which may be initialized to a non-null value, e.g., 0 for t= he > count function) > =C2=A0 =C2=A0will remain unchanged even if the underlying processing > =C2=A0 =C2=A0function returns a null value, whether from being defined st= rict > =C2=A0 =C2=A0or it simply returns a null value upon execution. Thank you. > Since count doesn't have an input function to check the only way to > see zero such rows is if the underlying thing being counted is empty. While true for COUNT(*), technically that's incorrect for COUNT(x), which counts the rows for which x is non-null. That doesn't invalidate your point, though: the initial state is unchanged either way. Regards, Jeff Davis