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 1kcnfE-0000WK-H8 for pgsql-general@arkaria.postgresql.org; Wed, 11 Nov 2020 10:47:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kcnfD-0001kD-Dm for pgsql-general@arkaria.postgresql.org; Wed, 11 Nov 2020 10:47:43 +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 1kcnfD-0001jS-1l for pgsql-general@lists.postgresql.org; Wed, 11 Nov 2020 10:47:43 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kcnf8-0000JV-Ey for pgsql-general@lists.postgresql.org; Wed, 11 Nov 2020 10:47:42 +0000 Received: by mail-wr1-x444.google.com with SMTP id b6so2070998wrt.4 for ; Wed, 11 Nov 2020 02:47:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=D/E45fJx8jxgB2R4e5bI8ubOhCteNvwIY9tU+5r1SqY=; b=UTEqBCCazyT0giLKMZv5WFNq0uz/mkL3qbSwLUxyq1c1n6M3duCE4MIBfk2IjmUhiP Psz/DZtoF1suETGcozdHET31kGHNOZPlXOdlySOyQb2RWq+mfisrES9UwsH/nahsXjw7 T1WKpB9+Rru6CZcQdbiV3iXaXW1m2CGBzGpSzGtn+WWKqT6Vsu6TC/GedDmZZna3RTky Xt/Pg3bWhRwnLW1Q+MCSc5L+kOnPJ6CW9N0CkcKygTF4ZufBWQNbv3cha/7OZIRpFuQB BvP0u67EImHqCkbpKhKUuHDpgBrljjgwns5fW4DXwx7P7CMk+Xk84ahC1fUB2PecnGU7 ETDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=D/E45fJx8jxgB2R4e5bI8ubOhCteNvwIY9tU+5r1SqY=; b=ApnLyWFDdPUdmJPvqPD0YruXjeNzP9F1rPcA5p2wX2NAUwSoygBFA/23yY75ics5lC sniqz4L1A6p4pdAvBLzPfGYMdUxhRspLqBMItxO0RlujxhSmLVCxM4jZ0RY+swqqWhQA UC2T3wm3M3KAWP5cNu1q8tEfwBJgilc8JPcpHu2rPhPfkWcE21b83URReXGnNGJxQlSV ALA5UFgeGAAUbTVKuvD4Zqi4rNmxhq9/hPk0NkyGGv3fVpuSbO3Bf/5eTNKA4YCRXufd 6bRNwvk4Y31HXmNSCT8TR+OVfOJDtgvIWxSC+CV/CcbxPk7f9MXaubsIu4kXu+Dhn/Ay XBdA== X-Gm-Message-State: AOAM531f7bFdPxnox051gKHoOcfqOorojbZAMQWqD6BaI78Yl11BvSnR KyLiqVbAdc6uzfVL5+j3a+MtTGgleAriSPTLs0gMSJod6O1F4YP0XDumqwXh3n0XKR7baVFab3D Wnecm6wgsfBrv//UaW75SdJQxp7rzwieCe6fkij4ALilLASXOQNzWMw53DgFS6VZILVzAix87JC FO2xLYurT/mqmaP2Aj59v7z4nRWJBCa0HbQX8ihiGgBKDHK+UHLNuY1S/xuCyjQwG8Tr5APplQx LFGUsx12C7L1sTKO7zmwyVFFuV1+NUX0HcMK+eG2gU4E3/Fj6OyHj9q X-Google-Smtp-Source: ABdhPJxmBBToa8M+MGIMnJ86hmm9CFbtWOxeKrIToGEfZSygH6HFzTHTWy3uWC618Q4ShX2nADBPBw== X-Received: by 2002:adf:fd03:: with SMTP id e3mr23316212wrr.303.1605091656707; Wed, 11 Nov 2020 02:47:36 -0800 (PST) Received: from [10.137.0.4] (ip-86-49-245-76.net.upcbroadband.cz. [86.49.245.76]) by smtp.gmail.com with ESMTPSA id v9sm2011805wrp.11.2020.11.11.02.47.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 11 Nov 2020 02:47:36 -0800 (PST) Subject: Re: Check constraints do not seem to be working!!! To: Jitendra Loyal , Nikolay Samokhvalov Cc: pgsql-general@lists.postgresql.org References: From: Tomas Vondra Message-ID: <698d0c84-ff8a-4197-51d4-0a9772b998dd@enterprisedb.com> Date: Wed, 11 Nov 2020 11:47:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/11/20 10:06 AM, Jitendra Loyal wrote: > Thanks Nikolay > > I read that but is there a way to meet the above requirement. And I will > like to add that IS NULL and IS NOT NULL should evaluate to true/false. > These operators are made for this and should not be returning NULL. > This has nothing to do with IS [NOT] NULL, it's the first part of the expression (b = TRUE) causing trouble. Essentially, the constraint (b = true) and (c is not null) is evaluated in two steps. First we evaluate the two parts individually, and for (null, true) the results would look like this: (b = true) => null (c is not null) => true and then we combine those results using 'AND' null AND true => null which is considered as if the constraint matches. If you want to handle NULL for the first expression, you may do this, for example: (b it not null and b = true) and (c is not null) Or something like that. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company