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.96) (envelope-from ) id 1vd7AY-00E9Ag-2v for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Jan 2026 13:32:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vd7AX-007ybA-2d for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Jan 2026 13:32:18 +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.96) (envelope-from ) id 1vd7AX-007yb1-1Q for pgsql-hackers@lists.postgresql.org; Tue, 06 Jan 2026 13:32:18 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vd7AW-004WFU-1m for pgsql-hackers@lists.postgresql.org; Tue, 06 Jan 2026 13:32:17 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-42fbc3056afso474391f8f.2 for ; Tue, 06 Jan 2026 05:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1767706335; x=1768311135; darn=lists.postgresql.org; h=content-transfer-encoding:mime-version:user-agent:reply-to :references:in-reply-to:message-id:date:cc:subject:to:from:from:to :cc:subject:date:message-id:reply-to; bh=gnjeGRCWxzDlY/Py64GEg4dJQ2nROWaQxTmvzQb3Oe0=; b=EnAaqs5PeupMkLmRhYFFmeoGZb9737JUM3gJv7BdWLnR02JgLY6QHyC5sHvHCNjLNl SbcRVanQaWwFdkpMalU2ybpz9z9DkpX6PDhELyxPokK6SwSyceEPyPN5sqAcUuoYsX8R VchPwD0ye9t1NjawdugA402y/7f5uTcr1vv5PHYe5hjwbHdd5Qy90RTeFzSkKoifK4A3 mVuHWcM6F0Sy2T1LQ+32ydWwiIyqs68BrxLe+5U4xFCx77IBQkkVHpMmwyvTqS/0Cuq1 tdrMPqZHsNSe8tPh6XQSGYtbZ+jf3m1kZGEj+Tz1NmW1K5PeXBJQ6I1CtQv8yfB3fSQQ CkFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767706335; x=1768311135; h=content-transfer-encoding:mime-version:user-agent:reply-to :references:in-reply-to:message-id:date:cc:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gnjeGRCWxzDlY/Py64GEg4dJQ2nROWaQxTmvzQb3Oe0=; b=VTXbWdh6BHBpxubQIdBrM/Y35MLcVjFrW6KmI2hbGRWgq7jpzUL/l+KPJOO32UGoa/ VhFB+KrVGfBOCGEm/jlCeigAzdNqom5naE9JEVC7HPUuffFDzZOjvDRABu/aerrBA+lb AuEuEj9z71ZcYJ5bTqO8Ln9cHyH3rVr5w27L0utBogfFmiVD95OBwpdiEK9XQ6KY/RdU arKXkUvzwRH/mElMm8Y+2u9QfC5aAENwkjjdcOpnidpx7HLzmfyfKkjOEXX3WIQ0VRh/ tcDUeUC7JYL1VTRhIimlrvfo0Ey/uheKRtFiboJmzHHGjx6QbVsXGg7sTJLX6qhSCzBC FIvw== X-Gm-Message-State: AOJu0YxBbSVsk2wXYxsNVGOR5N3gueu8bQkIf8vDeOuqcrPz8h/PLw0v NFvv9DvWA/Pxr3VtpfLXsStugrcZzKnhrfOfnlIcwXwPWTcbd9ykktZ6Ql3LgU2PJ6I= X-Gm-Gg: AY/fxX7CfiItqbZICZimgOeXUMs/jAG05IBAsxNctyvd/3QyXoV3M/Q0PACTC2Oh3Fh zYpNXFv1lxTktFUeO2phAYcu75rTtgW/UofHwJsAVJQ8UY0fti26atI33CD/bVaPENTJXeI8ZeM agzLonmsV9KN9C5NvjBigEzx9JZdle2ArSyx8C+6evtXGc3pA9Z1NlincUVNVW9H0q4rM2RWoCI FcdmNdMhwcFtbWtUBPebfpq44GWVu7tslfjWyBFvE7tKsNiZ4f6+8V2RqZadJX3fFkq921sCZSx ssUA+pyjT5M+FzCATz2e6yQQ31roRKPnpYJVwh8IzVFPqOzC6Wu62m4oD02D9+AHebnZkZMsvzu jrqfB6iazG5a5ioqhuhRRUyWS/zx6AlOVSsQJOWFYsSCTWkg7T2jYZCAHjgWFOB9FKe6Zub6F/c rkWOAzZMk7GePislMHm6CZD8WZ4KQ3Oxrv1an+T0wCCdZ1Gaouxw== X-Google-Smtp-Source: AGHT+IEulPJsCyxyMzHSJp571QEmGShABRQuPohoshvVes6L3GOrpYDScP07JQpA6+uEqZhS6FgaZQ== X-Received: by 2002:a05:6000:2c0c:b0:42f:8816:a509 with SMTP id ffacd0b85a97d-432bca04279mr3812967f8f.62.1767706334270; Tue, 06 Jan 2026 05:32:14 -0800 (PST) Received: from ?IPv6:::ffff:192.168.0.101? ([62.197.243.85]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd0e199bsm4550011f8f.16.2026.01.06.05.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 05:32:14 -0800 (PST) From: "Pavlo Golub" To: assam258@gmail.com Subject: Re[2]: [PATCH] Add pg_current_vxact_id() function to expose virtual transaction IDs Cc: pgsql-hackers@lists.postgresql.org Date: Tue, 06 Jan 2026 13:32:16 +0000 Message-Id: In-Reply-To: References: Reply-To: "Pavlo Golub" User-Agent: eM_Client/10.4.4195.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello. Thanks for the review. > >Only pg_locks has it. And you can already get your VXID from there: > > SELECT virtualtransaction FROM pg_locks > WHERE pid =3D pg_backend_pid() LIMIT 1; While it is true that pg_locks contains the virtual transaction=20 information, I believe there are strong technical reasons to expose this=20 directly via a function. First of all, querying pg_locks is expensive. By contrast,=20 pg_current_vxact_id() is a practically free O(1) read from MyProc. The %v log placeholder is the specific identifier for individual=20 transaction executions (including read-only ones where no permanent XID=20 is assigned). PIDs (%p) are session-scoped and too coarse for helping=20 debug specific transactions in connection-pooled environments. This=20 function allows applications to easily obtain the ID needed to correlate=20 with server logs. We already provide fast accessors for other identifiers like=20 pg_backend_pid() and pg_current_xact_id(). Additionally, PostgreSQL=20 often provides utility functions that overlap with other commands or=20 views to improve developer experience (e.g., pg_notify() vs NOTIFY,=20 pg_sleep() vs pg_sleep_for() vs pg_sleep_until()). It feels consistent=20 to offer a simple accessor rather than requiring a complex query against=20 a system view. Best regards, Pavlo Golub