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 1sAGjP-008c4X-0i for pgsql-admin@arkaria.postgresql.org; Thu, 23 May 2024 22:16: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 1sAGjO-00Gw8O-AW for pgsql-admin@arkaria.postgresql.org; Thu, 23 May 2024 22:16:14 +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 1sAGjN-00Gw8F-Tv for pgsql-admin@lists.postgresql.org; Thu, 23 May 2024 22:16:13 +0000 Received: from qs51p00im-qukt01071502.me.com ([17.57.155.5]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sAGjG-001gUD-Pg for pgsql-admin@lists.postgresql.org; Thu, 23 May 2024 22:16:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1716502563; bh=OAoNKAisiP4S1Mfgn6P3jgshMWdLV3vhj6yWlNsQmjQ=; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:To; b=FEnv4rw9fNbax6DhqzAJODCvah0W06QSLp0SmglZk8Y4JfDRvjIF+oIllTm9XV3C2 mgbQl7RdYJ+sjhkFr/bc6VO3Wf0r+vUq+ukQ3GnAw22g7oT0sa4I578vWH5tbsBIUc SptCCVhkd/5SaIhvUViYvKYlWE+MdIylHsnW/p/6HDWEDB1j2Da8Hc9HcqxJhM+x5V VPr8uFHNBfJM7OtzXCRAQsdlUwfec4JZ9d4JBIaBSfIhQ6//AwjG9QF4izjVGRS6WE /JDQ2T5qZAxFB3X59/pAWy5u7rTQrqxE+DlLsuAgUM3ta08VeR1Fhojic48fA5tCN6 Qm4vjj23zIETg== Received: from smtpclient.apple (qs51p00im-dlb-asmtp-mailmevip.me.com [17.57.155.28]) by qs51p00im-qukt01071502.me.com (Postfix) with ESMTPSA id CA97A66800B1; Thu, 23 May 2024 22:16:02 +0000 (UTC) From: Rui DeSousa Message-Id: <93EDD0BC-830E-4EE6-95FD-D41F689DD7EF@icloud.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_AA08B42F-0FE0-4B96-A611-0D5935F3A748" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.8\)) Subject: Re: AFTER INSERT trigger INSERT into another table-B are ignoring Table-B constraints Date: Thu, 23 May 2024 18:15:59 -0400 In-Reply-To: Cc: "David G. Johnston" , "wolters.k@web.de" , "pgsql-admin@lists.postgresql.org" To: M Sarwar References: <1E8736C1-ACF4-4250-9B0B-789A6D927958@icloud.com> X-Mailer: Apple Mail (2.3696.120.41.1.8) X-Proofpoint-ORIG-GUID: KZodiIeau9Vbai3rMG8t7J9CqfV2rPlU X-Proofpoint-GUID: KZodiIeau9Vbai3rMG8t7J9CqfV2rPlU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-23_13,2024-05-23_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 mlxscore=0 spamscore=0 phishscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2405230154 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_AA08B42F-0FE0-4B96-A611-0D5935F3A748 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On May 23, 2024, at 4:30 PM, M Sarwar wrote: >=20 > Constraints are working as expected when I am working the table-2 = directly.=20 > In my case, Table-2 needs to get INSERTed only when table-1 has = INSERTs. Table-1 is working fine. Table-2 is also working fine when I am = directly working in table-2. > But when I Table-2 needs to have INSERTs based on the trigger = invocation of Table-1, Table-2 is applying constraints which is causing = issues. CONSTRAINT cons_unique_for_concatenated_view UNIQUE (start_time_numeric, = stop_time_numeric, test_action, part_type, fixture_id, run_id, = auxid1_build_id, auxid2_asic_id, serial_number, part_pf) So the constraint above is not being honored? What are the duplicate = records? Is this a view that you=E2=80=99re seeing the duplicate records = in or a table? I was under the impression that NULLs where in play here. Is that not = the case?= --Apple-Mail=_AA08B42F-0FE0-4B96-A611-0D5935F3A748 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On = May 23, 2024, at 4:30 PM, M Sarwar <sarwarmd02@outlook.com> wrote:

Constraints are working as = expected when I am working the table-2 directly. 
In = my case, Table-2 needs to get INSERTed only when table-1 has INSERTs. = Table-1 is working fine. Table-2 is also working fine when I am directly = working in table-2.
But when I Table-2 = needs to have INSERTs based on the trigger invocation of Table-1, = Table-2 is applying constraints which is causing = issues.

CONSTRAINT = cons_unique_for_concatenated_view UNIQUE (start_time_numeric, = stop_time_numeric, test_action, part_type, fixture_id, run_id, = auxid1_build_id, auxid2_asic_id, serial_number, = part_pf)

So the constraint above is not being = honored? What are the duplicate records? Is this a view that you=E2=80=99r= e seeing the duplicate records in or a table?

I was under the impression that NULLs where in = play here.  Is that not the case?
= --Apple-Mail=_AA08B42F-0FE0-4B96-A611-0D5935F3A748--