From HeinemannM@imsweb.com Wed Apr 1 13:49:03 2020 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 1jJdk8-0002mW-P8 for pgsql-sql@arkaria.postgresql.org; Wed, 01 Apr 2020 13:49:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jJdk7-00078D-Dd for pgsql-sql@arkaria.postgresql.org; Wed, 01 Apr 2020 13:49:19 +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 1jJdk7-000786-7B for pgsql-sql@lists.postgresql.org; Wed, 01 Apr 2020 13:49:19 +0000 Received: from util-st-02.imsweb.com ([204.132.58.65]) by magus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jJdju-0007zg-Kv for pgsql-sql@lists.postgresql.org; Wed, 01 Apr 2020 13:49:18 +0000 Received: from NAIAD.omni.imsweb.com (haproxy-st-01 [204.132.58.75]) by util-st-02.imsweb.com (Postfix) with ESMTP id D910CE41F5 for ; Wed, 1 Apr 2020 09:49:03 -0400 (EDT) Received: from NAIAD.omni.imsweb.com (172.22.64.103) by NAIAD.omni.imsweb.com (172.22.64.103) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 1 Apr 2020 09:49:03 -0400 Received: from NAIAD.omni.imsweb.com ([172.22.64.103]) by NAIAD.omni.imsweb.com ([172.22.64.103]) with mapi id 15.00.1497.006; Wed, 1 Apr 2020 09:49:03 -0400 From: "Heinemann, Manfred (IMS)" To: "pgsql-sql@lists.postgresql.org" Subject: FK constraint question Thread-Topic: FK constraint question Thread-Index: AdYIK+fDrLfdeUAlT1qY34n4HgKNcg== Date: Wed, 1 Apr 2020 13:49:03 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [204.132.58.75] Content-Type: multipart/alternative; boundary="_000_e5f1fa241b2a4f67816c3f1915f49ff2NAIADomniimswebcom_" MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_e5f1fa241b2a4f67816c3f1915f49ff2NAIADomniimswebcom_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Can something explain why something like the following could happen? INSERT INTO task_history (task_id, user_id, task_date) SELECT task_id, user_id, task_date FROM task WHERE task_id IN (1, 2, 3); ERROR: insert or update on table "task_history" violates foreign key constr= aint "fk_task_history_task_id" Detail: Key (task_id)=3D(1) is not present in table "task". Thanks, Manfred ________________________________ Information in this e-mail may be confidential. It is intended only for the= addressee(s) identified above. If you are not the addressee(s), or an empl= oyee or agent of the addressee(s), please note that any dissemination, dist= ribution, or copying of this communication is strictly prohibited. If you h= ave received this e-mail in error, please notify the sender of the error. --_000_e5f1fa241b2a4f67816c3f1915f49ff2NAIADomniimswebcom_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Can something explain why something like the followi= ng could happen?

 

INSERT INTO task_history (task_id, user_id, task_dat= e)

SELECT task_id, user_id, task_date

FROM task

WHERE task_id IN (1, 2, 3);

 

ERROR: insert or update on table "task_history&= quot; violates foreign key constraint "fk_task_history_task_id"

  Detail: Key (task_id)=3D(1) is not present in= table "task".

 

Thanks,

Manfred




Information in this e-mail may be confidential. It is intended only for the= addressee(s) identified above. If you are not the addressee(s), or an empl= oyee or agent of the addressee(s), please note that any dissemination, dist= ribution, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please = notify the sender of the error.
--_000_e5f1fa241b2a4f67816c3f1915f49ff2NAIADomniimswebcom_-- From science@misuse.org Wed Apr 1 15:29:44 2020 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 1jJfJn-00040P-Gk for pgsql-sql@arkaria.postgresql.org; Wed, 01 Apr 2020 15:30:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jJfJl-0001Ml-Jw for pgsql-sql@arkaria.postgresql.org; Wed, 01 Apr 2020 15:30:13 +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 1jJfJl-0001Kl-D8 for pgsql-sql@lists.postgresql.org; Wed, 01 Apr 2020 15:30:13 +0000 Received: from sanddollar.geekisp.com ([216.168.135.167]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.92) (envelope-from ) id 1jJfJd-0000JK-7z for pgsql-sql@lists.postgresql.org; Wed, 01 Apr 2020 15:30:12 +0000 Received: (qmail 26597 invoked by uid 1003); 1 Apr 2020 15:30:04 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=misuse.org; b=A47WP8GTudSLbgsdrWFafjFVhpeiBb/DzRllGgQdegxpefMkumXw6/EKNlV2dg/paadiSDVMT8OCS0TwEitUDXTELvA81gwsByDWXDZrIK8xWbmla0MF1WZNkpxDE9m2 ; Received: from unknown (HELO mail-lj1-f173.google.com) (steve@misuse.org@209.85.208.173) by mail.geekisp.com with (ECDHE-RSA-AES128-GCM-SHA256 encrypted) SMTP; 1 Apr 2020 15:30:04 -0000 Received: by mail-lj1-f173.google.com with SMTP id i20so26202995ljn.6 for ; Wed, 01 Apr 2020 08:29:58 -0700 (PDT) X-Gm-Message-State: AGi0PubzoEgTEIwjoZpiIeBmJJjsMULYAWNUIKuUpM8lwNp6zdhmtmcb dbTA9sdECt4c8lCk+GQ4KCqAWoxjOpB6oK5ehh8= X-Google-Smtp-Source: APiQypJ9SkPpOlIB4uULBx09su/ucZM9m5dKJWnsQv54A9dTmifqyL6HtmnB4TqiT+U4STiks5VgEOSaueT2llTs8yw= X-Received: by 2002:a2e:9194:: with SMTP id f20mr13929221ljg.33.1585754996308; Wed, 01 Apr 2020 08:29:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Steve Midgley Date: Wed, 1 Apr 2020 08:29:44 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: FK constraint question To: "Heinemann, Manfred (IMS)" Cc: "pgsql-sql@lists.postgresql.org" Content-Type: multipart/alternative; boundary="00000000000041807c05a23c5ba6" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --00000000000041807c05a23c5ba6 Content-Type: text/plain; charset="UTF-8" On Wed, Apr 1, 2020 at 6:49 AM Heinemann, Manfred (IMS) < HeinemannM@imsweb.com> wrote: > Can something explain why something like the following could happen? > > > > INSERT INTO task_history (task_id, user_id, task_date) > > SELECT task_id, user_id, task_date > > FROM task > > WHERE task_id IN (1, 2, 3); > > > > ERROR: insert or update on table "task_history" violates foreign key > constraint "fk_task_history_task_id" > > Detail: Key (task_id)=(1) is not present in table "task". > > > Would you share the DDL create table and create FK statements? Seems weird for sure, but it would help to have the DDL to diagnose. Also, if you can provide sample data that generates this error, that will help everyone interested to reproduce your issue. --00000000000041807c05a23c5ba6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Apr 1, 2020 at 6:49 AM Heinemann, Manfred (IMS) <HeinemannM@imsweb.com> wrote:
<= /div>

Can something explain why something like the followi= ng could happen?

=C2=A0

INSERT INTO task_history (task_id, user_id, task_dat= e)

SELECT task_id, user_id, task_date

FROM task

WHERE task_id IN (1, 2, 3);

=C2=A0

ERROR: insert or update on table "task_history&= quot; violates foreign key constraint "fk_task_history_task_id"

=C2=A0 Detail: Key (task_id)=3D(1) is not present in= table "task".

=C2=A0

Would you sh= are the DDL create table and=20 create=20 FK statements? Seems weird for sure, but it would help to have the DDL to d= iagnose. Also, if you can provide sample data that generates this error, th= at will help everyone interested to reproduce your issue.
--00000000000041807c05a23c5ba6-- From samed@reddoc.net Wed Apr 22 15:50:40 2020 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 1jRHeF-0007FU-Kc for pgsql-sql@arkaria.postgresql.org; Wed, 22 Apr 2020 15:50:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jRHeE-0007kX-IN for pgsql-sql@arkaria.postgresql.org; Wed, 22 Apr 2020 15:50:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jRHeE-0007kQ-AQ for pgsql-sql@lists.postgresql.org; Wed, 22 Apr 2020 15:50:50 +0000 Received: from forward501o.mail.yandex.net ([2a02:6b8:0:1a2d::611]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jRHeA-0000xq-OV for pgsql-sql@lists.postgresql.org; Wed, 22 Apr 2020 15:50:49 +0000 Received: from mxback30j.mail.yandex.net (mxback30j.mail.yandex.net [IPv6:2a02:6b8:0:1619::230]) by forward501o.mail.yandex.net (Yandex) with ESMTP id 4B6DA1E80AD2; Wed, 22 Apr 2020 18:50:42 +0300 (MSK) Received: from localhost (localhost [::1]) by mxback30j.mail.yandex.net (mxback/Yandex) with ESMTP id dourEILe0G-oeVmQOSH; Wed, 22 Apr 2020 18:50:41 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=reddoc.net; s=mail; t=1587570641; bh=lQtpENC3ioluzL06T0Zd9mDGGfd5bJs/lyFdSFzB3+w=; h=References:Date:Message-Id:Subject:In-Reply-To:To:From; b=Onj0Ne6uo4P+acOW13QPnZTeIz1oVyTqrgUsqAaoWe9l1N3nSWhNmArGec63er3cK 7nYE7M7S2wmTCkulvgfdojBcNNUmg1U26pSPCTz+88PJdyWYWQZI6g/x/ekTlriWvZ Li7ENKgVKjLL5OGw0V9xU1diXxouRtZUYtAPrXjs= Authentication-Results: mxback30j.mail.yandex.net; dkim=pass header.i=@reddoc.net Received: by iva3-67f911cb3a01.qloud-c.yandex.net with HTTP; Wed, 22 Apr 2020 18:50:40 +0300 From: Samed YILDIRIM To: "Heinemann, Manfred (IMS)" , "pgsql-sql@lists.postgresql.org" In-Reply-To: References: Subject: Re: FK constraint question MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Wed, 22 Apr 2020 18:50:40 +0300 Message-Id: <580931587570375@mail.yandex.com.tr> Content-Transfer-Encoding: base64 Content-Type: text/html; charset=utf-8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk PGRpdj5IZWxsbyBNYW5mcmVkLDwvZGl2PjxkaXY+wqA8L2Rpdj48ZGl2PkRpZCB0aGUgdGFibGUg bmFtZWQgPGVtPnRhc2s8L2VtPiBoYXZlIGNoaWxkIHRhYmxlcz8gVGhlIHJlY29yZHMgd2hvc2Ug dGFza19pZCB3YXMgMSB3ZXJlIGluIGNoaWxkIHRhYmxlcyByYXRoZXIgdGhhbiA8ZW0+dGFzaz88 L2VtPjwvZGl2PjxkaXY+wqA8L2Rpdj48ZGl2PkNvdWxkIHlvdSBwbGVhc2UgdHJ5IGZvbGxvd2lu ZyBxdWVyeT88L2Rpdj48ZGl2PsKgPC9kaXY+PGRpdj48cCBzdHlsZT0iZm9udC1mYW1pbHk6J2Nh bGlicmknICwgc2Fucy1zZXJpZjtmb250LXNpemU6MTFwdDttYXJnaW46MGluIDBpbiAwLj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GFueSBkaXNzZW1pbmF0aW9uLCBkaXN0cmlidXRpb24sIG9yIGNvcHlpbmcgb2Yg dGhpcyBjb21tdW5pY2F0aW9uIGlzIHN0cmljdGx5IHByb2hpYml0ZWQuIElmIHlvdSBoYXZlIHJl Y2VpdmVkIHRoaXMgZS1tYWlsIGluIGVycm9yLCBwbGVhc2Ugbm90aWZ5IHRoZSBzZW5kZXIgb2Yg dGhlIGVycm9yLjwvZm9udD48L2Rpdj48L2Jsb2NrcXVvdGU+ From ashu.coek88@gmail.com Wed Apr 22 16:31:08 2020 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 1jRIHJ-0000K9-PN for pgsql-sql@arkaria.postgresql.org; Wed, 22 Apr 2020 16:31:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jRIHI-0004Pg-ED for pgsql-sql@arkaria.postgresql.org; Wed, 22 Apr 2020 16:31:12 +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 1jRIHI-0004OI-7T for pgsql-sql@lists.postgresql.org; Wed, 22 Apr 2020 16:31:12 +0000 Received: from mail-yb1-xb33.google.com ([2607:f8b0:4864:20::b33]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jRIHG-00022C-8r for pgsql-sql@lists.postgresql.org; Wed, 22 Apr 2020 16:31:11 +0000 Received: by mail-yb1-xb33.google.com with SMTP id l5so1495703ybf.5 for ; Wed, 22 Apr 2020 09:31:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=kS5Xavd0eDY8s/Zl+rebxuAEwLS1D/10U9OnOgCpP6M=; b=FLN7dcxXODFXmq904kUqUJFUjuDcUDHSNM0O1XG28LLo95q1G5/buS5rfQE7cZ7rlt lf3oM3fBSAoL8oc/We3BDE/ghS4jHQcxUxrTB4QKzF7orAyHDdLz50PrZRmdyBxKliDv 4cUmFx7G7DfFqsaUkp2qoziedV1fw+EwxzKazF1JexVc+tLOrZ5iZzY0czCBUFMvbBwa 9OKeA7nFqoWxJ/uBBiE6eaYtKE9frYgypYh9WwxzHoSv7rdlaZE+wY1L+2rdc1bEQabk x+4Rf7s2DJfkaWT34PA5SW1ZJNcYqGtXjQdFt/pdUSDR8v9R5FBY839Zh1ojQXlTSjT4 UNrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=kS5Xavd0eDY8s/Zl+rebxuAEwLS1D/10U9OnOgCpP6M=; b=IIaAT08nEc0k7uAU0pzpxDED5tuyVF2cdmbrzbHjrICzUdUrWmR4QLVugH3u/0zeBJ pk6OMCLq+yNVsodgLkA/hy3uqpEqGeyb/4sem5x5jDvK6P23JAb+dV+WPTe/IFaWyka5 Aa7aNakh3apDWNg5AoATo3dlvSi/gYdYKJw+k/gDLj/Ff0ziFHDmxhSkJnWfK9vexdhy eOrsFkjuTnjneEJB9s7zPT1D0pJ/GT6sk1JPiNfnm+mYsczAulbavmfoY+Fj/vBiQDai jNrRz09m8UI/ZPPj7bs+srzBSRvdAdUVJFMjascEQpPpZEVfcCJR7OLhC3rrfBX9pYS9 Xuog== X-Gm-Message-State: AGi0PuZvAjpPXsD6MAyThdAR4S2L2Wpqi5YxvL6wesJXoFlnwC/asTyM fV8kOw3jDAYlpHkmcmOQbiDHHauVUfW6Lam0115DNQ== X-Google-Smtp-Source: APiQypL2e57uTydEK90Ppgh/kayugNghHWDauC/ErhLVOQKqCn2cp3oRHLmJ0W1M9nc0DBGLU7bCLfZYyyD2gxup0FA= X-Received: by 2002:a25:e658:: with SMTP id d85mr3267662ybh.481.1587573068549; Wed, 22 Apr 2020 09:31:08 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:ab48:0:0:0:0:0 with HTTP; Wed, 22 Apr 2020 09:31:08 -0700 (PDT) In-Reply-To: References: From: Ashutosh Sharma Date: Wed, 22 Apr 2020 22:01:08 +0530 Message-ID: Subject: Re: FK constraint question To: "Heinemann, Manfred (IMS)" Cc: "pgsql-sql@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000ce529b05a3e3a8a5" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --000000000000ce529b05a3e3a8a5 Content-Type: text/plain; charset="UTF-8" Hi, Do you have multiple task table created in your database? Can you share the output of \d+ task_history? On Wednesday, April 1, 2020, Heinemann, Manfred (IMS) wrote: > Can something explain why something like the following could happen? > > > > INSERT INTO task_history (task_id, user_id, task_date) > > SELECT task_id, user_id, task_date > > FROM task > > WHERE task_id IN (1, 2, 3); > > > > ERROR: insert or update on table "task_history" violates foreign key > constraint "fk_task_history_task_id" > > Detail: Key (task_id)=(1) is not present in table "task". > > > > Thanks, > > Manfred > > ------------------------------ > > Information in this e-mail may be confidential. It is intended only for > the addressee(s) identified above. If you are not the addressee(s), or an > employee or agent of the addressee(s), please note that any dissemination, > distribution, or copying of this communication is strictly prohibited. If > you have received this e-mail in error, please notify the sender of the > error. > --000000000000ce529b05a3e3a8a5 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi,

Do you have multiple task table created in your data= base?=C2=A0

Can you share the output of \d+ task_h= istory?

On Wednesday, April 1, 2020, Heinemann, Manfred (IMS) <HeinemannM@imsweb.com> wrote:=

Can something explain why something like the followi= ng could happen?

=C2=A0

INSERT INTO task_history (task_id, user_id, task_dat= e)

SELECT task_id, user_id, task_date

FROM task

WHERE task_id IN (1, 2, 3);

=C2=A0

ERROR: insert or update on table "task_history&= quot; violates foreign key constraint "fk_task_history_task_id"

=C2=A0 Detail: Key (task_id)=3D(1) is not present in= table "task".

=C2=A0

Thanks,

Manfred




Information in this e-mail may be confidential. It is intended only for the= addressee(s) identified above. If you are not the addressee(s), or an empl= oyee or agent of the addressee(s), please note that any dissemination, dist= ribution, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please = notify the sender of the error.
--000000000000ce529b05a3e3a8a5--