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 1ncE5t-0004ow-8l for pgsql-general@arkaria.postgresql.org; Wed, 06 Apr 2022 22:25:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ncE5s-00047E-5J for pgsql-general@arkaria.postgresql.org; Wed, 06 Apr 2022 22:25:40 +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 1ncE5r-000475-Cl for pgsql-general@lists.postgresql.org; Wed, 06 Apr 2022 22:25:39 +0000 Received: from eastern.birch.relay.mailchannels.net ([23.83.209.55]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ncE5o-0008Bo-Lx for pgsql-general@lists.postgresql.org; Wed, 06 Apr 2022 22:25:38 +0000 X-Sender-Id: a2hosting|x-authuser|pedz+easesoftware.com@mi3-ss4.a2hosting.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B37E9120ADA for ; Wed, 6 Apr 2022 22:25:34 +0000 (UTC) Received: from mi3-ss4.a2hosting.com (unknown [127.0.0.6]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id 1B8B9120B15 for ; Wed, 6 Apr 2022 22:25:26 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1649283926; a=rsa-sha256; cv=none; b=XaTj+MAWVEh8jZdzmOYhcj+lbMV0gSMf6jOJobaLXItVnP1WhMyoy5+WChUPxPPsaVM7qw mOCJ4Iy6U5YORXlwablYOMhaF4RPm4bxmruoIV7gY1l2WkJMzrCgw2ya2J7aJyNzIUiRqs Pg9ARQZhd9PaqRaUKLBxYA6TyiJnOWncfStYrWrPejdhBNPh3ucrHmLECXSyQmzpG2RfsY k1iiRBQ6JOtSENuMgKDxgQqoKpf9gWbhlSNF+EAqjraY/Fg/0ulkrFQqYB0qMd5h9v0zpZ i48VhJTcd3O/A9WpuNOJYD8NTlsSqop9fGWlRPoLMjGyoDe5a61BCczM6LX1Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1649283926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: dkim-signature; bh=B4WmGHx5J/7IsU65iyhmGE1QUbVGxNlfMqCnImkRFu8=; b=SWKKJ6EE3uPH0JzrNQoQFTpyAPnhkxoFJ7IzdT0UYmrjAfkBcRkjGMlsmZM6wbefKmXHzk ziPD9ihZ1Q/LxC4cZUcRgMSWdHiwi6m8WrJWtb8hpZNpND7oGCt8yp5BWwg4xZRhUVYxeh kDU6CgzgrHZHrpLoQaedeJxrB21f6Cz3ozPbgMIRXLVe741oP29r2rYWioljDRqvO9ZvPr RXNLzVnMoEf2g72anThH3FSu5iSgfLvw+6qNzUKRxSdnJw0KLAvfF0Y4WkEGSavPRGzC1N 3Yn4LhqUFoWzjTrzoICjr5WphvMDlDGnU57EjkDI1ewX69n2k+SOnGp8TRSErQ== ARC-Authentication-Results: i=1; rspamd-786f77c8d-bb6kw; auth=pass smtp.auth=a2hosting smtp.mailfrom=pedz@easesoftware.com X-Sender-Id: a2hosting|x-authuser|pedz+easesoftware.com@mi3-ss4.a2hosting.com Received: from mi3-ss4.a2hosting.com (mi3-ss4.a2hosting.com [68.66.200.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.112.55.239 (trex/6.7.1); Wed, 06 Apr 2022 22:25:34 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|pedz+easesoftware.com@mi3-ss4.a2hosting.com X-MailChannels-Auth-Id: a2hosting X-Callous-Macabre: 052586721717585c_1649283934489_1674712439 X-MC-Loop-Signature: 1649283934489:154947530 X-MC-Ingress-Time: 1649283934489 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=easesoftware.com; s=default; h=To:Date:Message-Id:Subject:Mime-Version: Content-Type:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=B4WmGHx5J/7IsU65iyhmGE1QUbVGxNlfMqCnImkRFu8=; b=RtYuySe2jqCrtz4bYVYhf0BJPL 0VL4dU239TxcG7ggsW8LI9gjeQdNR63WBqnLouMK0uETriNp+0KMB0b1vg6Ywcz61zlGYsnGrkPlg lD4wro5JzvyKdzGOwvq+cjY+7XXGLTa9qZWmeYabGntjY+97/35+9tTfr7UpiedcM2/hkxAUTeAJh RBPodL0L1qybqxNqAOCesdBJSqGFL7d9r9lcZOsAA4N1OpFdo2FVpq3p90BcczM+f+9Zj6sZrJpCk GwL56/OAH8+GCzwjfU5zKK3qHdHx4IzvvFcE7Ssjt0gxpuGRHxIW+u2dmox4JmtkP4vh8Qi42tk+3 iv+lLhYw==; Received: from cpe-70-94-128-193.satx.res.rr.com ([70.94.128.193]:51068 helo=smtpclient.apple) by mi3-ss4.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ncE5d-0002yb-5l for pgsql-general@lists.postgresql.org; Wed, 06 Apr 2022 18:25:25 -0400 From: Perry Smith Content-Type: multipart/signed; boundary="Apple-Mail=_121D18A9-F50A-43DF-91DD-888A86D0D39D"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Subject: What have I done!?!?!? :-) Message-Id: Date: Wed, 6 Apr 2022 17:25:24 -0500 To: pgsql-general@lists.postgresql.org X-Mailer: Apple Mail (2.3696.80.82.1.1) X-AuthUser: pedz+easesoftware.com@mi3-ss4.a2hosting.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_121D18A9-F50A-43DF-91DD-888A86D0D39D Content-Type: multipart/alternative; boundary="Apple-Mail=_A1512E58-1B63-4D37-8456-DD17A64EE885" --Apple-Mail=_A1512E58-1B63-4D37-8456-DD17A64EE885 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Rather than explain how I got here, I=E2=80=99ll just explain the state = I=E2=80=99m in. =46rom psql: files_development=3D# \d files Table "public.files" Column | Type | Collation | Nullable | = Default = ------------+--------------------------------+-----------+----------+-----= ------------------------------ id | bigint | | not null | = nextval('files_id_seq'::regclass) basename | character varying | | not null | parent_id | bigint | | not null | dev | bigint | | not null | ftype | character varying | | not null | uid | bigint | | not null | gid | bigint | | not null | ino | bigint | | not null | mode | bigint | | not null | mtime | time without time zone | | not null | nlink | bigint | | not null | size | bigint | | not null | created_at | timestamp(6) without time zone | | not null | updated_at | timestamp(6) without time zone | | not null | Indexes: "files_pkey" PRIMARY KEY, btree (id) "index_files_on_parent_id" btree (parent_id) Foreign-key constraints: "fk_rails_15605042e6" FOREIGN KEY (parent_id) REFERENCES files(id) Referenced by: TABLE "files" CONSTRAINT "fk_rails_15605042e6" FOREIGN KEY = (parent_id) REFERENCES files(id) Notice that parent_id is suppose to refer to an id in the same table =E2=80= =94 at least, that is what I=E2=80=99m trying to do. I=E2=80=99m trying = to create a =E2=80=9Croot=E2=80=9D entry whose parent points to = themselves and I botched the code first time around and now I have this: files_development=3D# select * from files; id | basename | parent_id | dev | ftype | uid | gid | ino | = mode | mtime | nlink | size | created_at | = updated_at = ----+----------+-----------+-----------+-----------+------+------+-----+--= -----+----------------+-------+------+----------------------------+-------= --------------------- 11 | pedz | 1234 | 687931150 | directory | 1000 | 1002 | 2 | = 16877 | 18:43:29.65271 | 31 | 34 | 2022-04-06 21:58:43.570539 | = 2022-04-06 21:58:43.570539 12 | pedz | 12 | 687931150 | directory | 1000 | 1002 | 2 | = 16877 | 18:43:29.65271 | 31 | 34 | 2022-04-06 22:00:29.087417 | = 2022-04-06 22:00:29.115021 (2 rows) The record with id 11 has a parent id of 1234 which doesn=E2=80=99t = exist. My question isn=E2=80=99t how do I fix it, my question is why didn=E2=80=99= t Postgres back out the botched record? Why isn=E2=80=99t it = complaining? I=E2=80=99m using Active Record with the psql adapter. It has a = disable_referential_integrity which takes a block of code. When the = block of code exists, the constraints are put back. At least, that is = what I thought. I=E2=80=99m wondering if the disabled constraints are still disabled = somehow. If so, how would I check for that and how would I turn them = back on? Or am I way off in the weeds? Thank you for your time Perry Smith --Apple-Mail=_A1512E58-1B63-4D37-8456-DD17A64EE885 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Rather than explain how I got here, I=E2=80=99ll just explain = the state I=E2=80=99m in.

=46rom psql:

files_development=3D# \d = files
              =                     =         Table "public.files"
  =  Column   |             =  Type              | Collation | = Nullable |              Default  =             
------------+--------------------------------+-----------+-----= -----+-----------------------------------
 id   =       | bigint             =             |         =   | not null | nextval('files_id_seq'::regclass)
 basename   | character varying     =          |           | = not null | 
 parent_id  | bigint   =                     =   |           | not null | 
 dev        | bigint     =                     | =           | not null | 
 ftype      | character varying   =            |         =   | not null | 
 uid       =  | bigint                 =         |           | not = null | 
 gid        | bigint =                     =     |           | not null | 
 ino        | bigint     =                     | =           | not null | 
 mode       | bigint       =                   |   =         | not null | 
 mtime =      | time without time zone         = |           | not null | 
 nlink      | bigint       =                   |   =         | not null | 
 size =       | bigint             =             |         =   | not null | 
 created_at | timestamp(6) = without time zone |           | not null = | 
 updated_at | timestamp(6) without time zone = |           | not null | 
Indexes:
    "files_pkey" PRIMARY = KEY, btree (id)
    "index_files_on_parent_id" = btree (parent_id)
Foreign-key constraints:
    "fk_rails_15605042e6" FOREIGN KEY (parent_id) = REFERENCES files(id)
Referenced by:
  =   TABLE "files" CONSTRAINT "fk_rails_15605042e6" FOREIGN KEY = (parent_id) REFERENCES files(id)

Notice that parent_id is suppose to refer to an id in the = same table =E2=80=94 at least, that is what I=E2=80=99m trying to do. =  I=E2=80=99m trying to create a =E2=80=9Croot=E2=80=9D entry whose = parent points to themselves and I botched the code first time around and = now I have this:

files_development=3D# select * = from files;
 id | basename | parent_id |   =  dev    |   ftype   | uid  | gid  | = ino | mode  |     mtime      | nlink | = size |         created_at       =   |         updated_at      =    
----+----------+-----------+-----------+-----------+------+----= --+-----+-------+----------------+-------+------+-------------------------= ---+----------------------------
 11 | pedz   =   |      1234 | 687931150 | = directory | 1000 | 1002 |   2 | 16877 | 18:43:29.65271 |   =  31 |   34 | 2022-04-06 21:58:43.570539 | 2022-04-06 = 21:58:43.570539
 12 | pedz     |   =      12 | 687931150 | directory | 1000 | 1002 |   2 = | 16877 | 18:43:29.65271 |    31 |   34 | 2022-04-06 = 22:00:29.087417 | 2022-04-06 22:00:29.115021
(2 rows)


The record with id 11 has a parent id = of 1234 which doesn=E2=80=99t exist.

My question isn=E2=80=99t how do I fix = it, my question is why didn=E2=80=99t Postgres back out the botched = record?  Why isn=E2=80=99t it complaining?

I=E2=80=99m using Active Record with = the psql adapter.  It has a disable_referential_integrity which takes a = block of code.  When the block of code exists, the constraints are = put back.  At least, that is what I thought.
I=E2=80=99m wondering if the disabled = constraints are still disabled somehow.  If so, how would I check = for that and how would I turn them back on?  Or am I way off in the = weeds?

Thank = you for your time
Perry Smith

= --Apple-Mail=_A1512E58-1B63-4D37-8456-DD17A64EE885-- --Apple-Mail=_121D18A9-F50A-43DF-91DD-888A86D0D39D Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEE5yOa/gCtQpb3oCpljxzk9yzE+MAFAmJOE1QACgkQjxzk9yzE +MCzdQ//Xusm6GPC2Ifb2sEA/Bm/VbUkkMfZGJkXdoPtRxjV7zZ99GOXTRWaQBFL MegF4XpmhpvOyIU0jRLE4OOUnV+3fk+2f2PSteV4JrungRFXuI3X+aN93kU22CGV qpkz/WIVIlBdHayR91HRK17b+QaAx3wqubYvDR1xzwRnBlaTXkWrrYXPsHrJitNg mnr582MrnbCdwXeU27zetWPlNZXWO/urzqL286V6fQbhujWbN9YAvfvQazZgjoWm mGSza0vWqRqUx91WkTldthc1o0xQyecMsVDR3SHCJ/qDvuxbv09cWVbZA7w9BIDC co6rm0kIRrmzT2C06cowbsIZ9Js1+VG6Nuw3elCjuwPEO2U6Wvn7Lh/xEM0MSQEW vNHlHYPr2tgpFvTGkXoxtuWytXAzKsml9qsR8PsG0UxBGpBVPjVVcEC3nkwC1pj+ 6bAMv3CuNweGAUR5S3oya3CC7TooMBjdAjsPBg1zvyUt22pHB8phEApxd4FCHwEL e0nswnawIJUR0b9sPNT6hhTxV8gs0hyuQdGMd7vtkuRlb4o+DVu6LnpUct3kSz48 Ig1AEgltMpOYZg78Rm27PT/sn6MQj/TwFYmq1D0ldasQfvtQE1EfBOCbBjsDBhPS bG/Tmtgm+YXQk4fH3coVnb+9LdW1Qtsm2JIj/JOQ2B/7Ey8hqQo= =GVj5 -----END PGP SIGNATURE----- --Apple-Mail=_121D18A9-F50A-43DF-91DD-888A86D0D39D--