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 1pWNtT-0007oq-V3 for pgsql-general@arkaria.postgresql.org; Sun, 26 Feb 2023 20:45:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pWNtS-0007WQ-5w for pgsql-general@arkaria.postgresql.org; Sun, 26 Feb 2023 20:45:14 +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 1pWNtR-0007WG-Nm for pgsql-general@lists.postgresql.org; Sun, 26 Feb 2023 20:45:13 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pWNtK-0007o3-Iq for pgsql-general@lists.postgresql.org; Sun, 26 Feb 2023 20:45:13 +0000 Received: by mail-wm1-x32f.google.com with SMTP id l7-20020a05600c4f0700b003e79fa98ce1so2690921wmq.2 for ; Sun, 26 Feb 2023 12:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=oyB0YkjPHTYwluQ16uK1z7QxzBXW7ydpogSFMo0Q5cU=; b=cgNsZYaJ/mxkST287wnplV+S/Al7FL6Gf81jYrVLaQAAlVlr1Eno4097UwaGa6kVp4 TAuOKzenPnhlBky0hNltrh6sEHf9MbiJxJwx/oL4mRRyDFzOQLNUmVxpJrsspwKGKRg5 +Sl+8YZ0pcO6GOPxPl7Zj3VjfLU04MYWBmedYUb2rUCOE7gsB8gXzAivS1zXH08M3L7K Nl9+3eUv94HFTkfL6EFTr9PkxE6JTjJVVsP7WUr+UjgsrKGp81DxTaVKOlAAq+bjmJdB OzlLLCdjc4ChOzZ/fYS501nG64vHFqyVZlQR1cYyeYwZuET7OM8y60aSzrlFT500KliC pW1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=oyB0YkjPHTYwluQ16uK1z7QxzBXW7ydpogSFMo0Q5cU=; b=tA7j/twHDAqr99e2piGC17WF5eHiAvtO+Gtp7J9ATIawJxxRYSs+ktyrU+TYvFtp8l ltXUpqnvamNImsQRG5hV2DC3uABm58oANOtyl87YLXmnvwk4pQAmIevg6Z6oOv5qxCrU pXrWUXxrkyRev5AUG348bEvMqyBJMzHD1SJoeL5tmEU/9QpuE8EqokiNESxNmageD+IZ s0k+i+YhM+xTyoA8Nm1UwsJ5APfD4iZafBtikgIqTBqJqZnKkhqskvN7KNV+iua/mya2 XpKJNmcJgwv0vxyCODg9a8gBBZzdHcYpdpkvJjauhhGVgtYQZEjOSszl2xSszP3frmsB Oy3g== X-Gm-Message-State: AO0yUKXC+O6Tki1UrtxJ2mvCSkD9SW2fNs0XoHm4P0O5iFpfUdUfeJxr XUmWwmzYB6B6YrMMjqHRmkt26+2uBhdUEMUa X-Google-Smtp-Source: AK7set+4cFTWYYTWyv727KvQReCwzN9itifgJqRdqha7TURp3QKpw5Y02CPEr5D+6DhBy4jZA0MY7Q== X-Received: by 2002:a05:600c:1608:b0:3eb:42fc:fb30 with SMTP id m8-20020a05600c160800b003eb42fcfb30mr1021777wmn.32.1677444305178; Sun, 26 Feb 2023 12:45:05 -0800 (PST) Received: from localhost.localdomain (62-46-251-98.adsl.highway.telekom.at. [62.46.251.98]) by smtp.gmail.com with ESMTPSA id v7-20020a05600c470700b003eb3933ef10sm5163893wmo.46.2023.02.26.12.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 12:45:04 -0800 (PST) Message-ID: <46c39c565e94aed56d678d6fce0ca06c0e081f9e.camel@cybertec.at> Subject: Re: Give me details of some attributes!! From: Laurenz Albe To: "jacktby@gmail.com" , pgsql-general Date: Sun, 26 Feb 2023 21:45:03 +0100 In-Reply-To: <2023022622292523172412@gmail.com> References: <2023022622292523172412@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 2023-02-26 at 22:29 +0800, jacktby@gmail.com wrote: >=20 > here are the source codes from src/include/access/htup_details.h. > /* > =C2=A0* information stored in t_infomask: > =C2=A0*/ > #define HEAP_HASNULL 0x0001 /* has null attribute(s) */ > #define HEAP_HASVARWIDTH 0x0002 /* has variable-width attribute(s) */ > #define HEAP_HASEXTERNAL 0x0004 /* has external stored attribute(s) */ > #define HEAP_HASOID_OLD 0x0008 /* has an object-id field */ > #define HEAP_XMAX_KEYSHR_LOCK 0x0010 /* xmax is a key-shared locker */ > #define HEAP_COMBOCID 0x0020 /* t_cid is a combo CID */ > #define HEAP_XMAX_EXCL_LOCK 0x0040 /* xmax is exclusive locker */ > #define HEAP_XMAX_LOCK_ONLY 0x0080 /* xmax, if valid, is only a locker *= / >=20 > And I can't understand these attrs: > 1.=C2=A0external stored attribute(s), what is this?=C2=A0 can you give a = create statement to show me? Those are columns stored out of line. See https://www.postgresql.org/docs/current/storage-toast.html > 2.=C2=A0xmax is a key-shared locker/exclusive locker/only a locker, so ho= w you use this? can you give me a=C2=A0=C2=A0scenario? https://www.cybertec-postgresql.com/en/whats-in-an-xmax/ > let me try to explain it: > =C2=A0if there is a txn is trying to read this heaptuple, the=C2=A0HEAP_X= MAX_KEYSHR_LOCK bit will be set to 1. No, reading a row won't lock it. It's SELECT ... FOR KEY SHARE that does that. > =C2=A0if=C2=A0there is a txn is trying to delete/update this heaptuple, t= he=C2=A0HEAP_XMAX_EXCL_LOCK=C2=A0bit will be set to 1. Correct. > =C2=A0but for=C2=A0HEAP_XMAX_LOCK_ONLY, I can't understand. See the comment a few source lines below: /* * A tuple is only locked (i.e. not updated by its Xmax) if the * HEAP_XMAX_LOCK_ONLY bit is set; or, for pg_upgrade's sake, if the Xmax i= s * not a multi and the EXCL_LOCK bit is set. Essentially, it is set after SELECT ... FOR UPDATE. > And another thought is that these three bit can have only one to be set 1= at most. If a tuple is only locked FOR KEY SHARE, bit not updated or deleted, both a= re set. > 3.=C2=A0t_cid is a combo CID? what's a CID? give me an example please. The command ID of the command in the transaction. Yours, Laurenz Albe