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 1jQShy-0006KA-7t for pgsql-admin@arkaria.postgresql.org; Mon, 20 Apr 2020 09:27:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQShx-0006e1-2x for pgsql-admin@arkaria.postgresql.org; Mon, 20 Apr 2020 09:27:17 +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 1jQShw-0006dt-6w for pgsql-admin@lists.postgresql.org; Mon, 20 Apr 2020 09:27:16 +0000 Received: from mail-eopbgr30048.outbound.protection.outlook.com ([40.107.3.48] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQShr-0007DO-SC for pgsql-admin@postgresql.org; Mon, 20 Apr 2020 09:27:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=luHo/cnWGagWc2iN4RGBr+uUiYAQD3T3yIKQ0MegJ0zYGtA9xacLOKr5y7h9oQWd6EJxRuqIDvI2eCPx8qGFad7kQJ+bCx7VubSWzJyq3FQO6xqqhzdWt+b3JYGjjrThNPhhoMqAzcYbJ6V0wB2HfIUuQr/fwaHJ7UgnZZAy6doaumpT2YNvw6MMN32YAmLSa0KLqbH1+Zlt7CgjKye2m8bd9DYta1kq2tsVFA6Rg8LjQeCrGv7tA9Q58fi4zSSbVVDvY1eB6KplwifBlTiuybZSlDz9iyOuWaZ41AaBbmqPuzBagUyt9tpOVJUwAzaQgaxE4oSirHiXMNo9Vqc2rA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lT2A5fbq0xkV10sf/HLkWNiwZ1BiQrYJwVO1ymZy8i4=; b=SLWszTCb4ih4FvUDybf0BXaxlqpUk1sysnHp5DcfeOPpTYX6qNV7yfPMdJgcGr/YqANsDpfu3E2soVILpOKzJ1HAPbQsBsSQ3JP2CIlpqPRBXy7H48OnSDMhd7wtdq2WL6DZez/eEVEIMr6rSO/NVInSx/rFPiiby+jOTP7ESC/pmnXZDBL4YEp53qk2qJIXh8C4Ttvb7yI7v8CDGPX8ooGr3h5gIthSgZoB09UKUWQg/7VKxkyBQeKXI0lc6sxIBZs7ilAO7pRMrT2enl5bPkGKCTvV7+7UdnR17thqkPBu5mDs1BUxl9fz3C1b02kIASuofr72haDLYTC6C9E1kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ucll.be; dmarc=pass action=none header.from=ucll.be; dkim=pass header.d=ucll.be; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucll.be; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lT2A5fbq0xkV10sf/HLkWNiwZ1BiQrYJwVO1ymZy8i4=; b=ZsgGB56Gxm8EJ1a3MgriySUGLdBILHqCiwkc1wKKMf83hiib3l3E25jHlhNibzGDdv2qeype43CkKUdsbkuesv02O9hj8Q60d+XwuFZkTjRwoK4kJwrt920rwQ7fZ+EjWe2+wBxETl1v7ekD7qwWg7pw8N2bonlO6JU/RjKu16M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=wim.bertels@ucll.be; Received: from AM0P195MB0324.EURP195.PROD.OUTLOOK.COM (2603:10a6:208:b3::30) by AM0P195MB0692.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:16d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.25; Mon, 20 Apr 2020 09:27:09 +0000 Received: from AM0P195MB0324.EURP195.PROD.OUTLOOK.COM ([fe80::8928:605c:2250:ccb6]) by AM0P195MB0324.EURP195.PROD.OUTLOOK.COM ([fe80::8928:605c:2250:ccb6%7]) with mapi id 15.20.2921.027; Mon, 20 Apr 2020 09:27:08 +0000 Message-ID: <904691b6c7df23ffb4439572ed2b8ba99185877f.camel@ucll.be> Subject: Re: View pervious versions of row From: Wim Bertels Reply-To: wim.bertels@ucll.be To: Arnav , pgsql-admin Date: Mon, 20 Apr 2020 11:25:37 +0200 In-Reply-To: References: Organization: UC Leuven-Limburg Content-Type: multipart/alternative; boundary="=-w9K4oN6/4krAEL7DIeIL" User-Agent: Evolution 3.30.5-1.1 X-ClientProxiedBy: AM6P191CA0008.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8b::21) To AM0P195MB0324.EURP195.PROD.OUTLOOK.COM (2603:10a6:208:b3::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from blauwbok (94.225.42.148) by AM6P191CA0008.EURP191.PROD.OUTLOOK.COM (2603:10a6:209:8b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.25 via Frontend Transport; Mon, 20 Apr 2020 09:27:08 +0000 X-Originating-IP: [94.225.42.148] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05d42e7f-4df3-4eb7-96f1-08d7e50cff53 X-MS-TrafficTypeDiagnostic: AM0P195MB0692: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:144; X-Forefront-PRVS: 03793408BA X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0P195MB0324.EURP195.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFTY:;SFS:(10009020)(4636009)(366004)(376002)(39850400004)(396003)(346002)(136003)(52116002)(36756003)(6496006)(36916002)(16526019)(478600001)(6486002)(186003)(86362001)(5660300002)(3450700001)(8936002)(6666004)(2906002)(66556008)(66946007)(81156014)(8676002)(956004)(2616005)(26005)(44832011)(316002)(786003)(110136005)(66476007)(33964004);DIR:OUT;SFP:1101; Received-SPF: None (protection.outlook.com: ucll.be does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J+4FHRMN3Is9rznAnISE1psk3VCAQaC5t64pMF16wjo+NOn0y+IELPox8xo3q6fgK+az5Gl/8JRCJ0FtZkV6j/MVqHlOV4NnMIu44vLkmtlLR61E0e24g0cU+gUv/oSIKXwHjeAwTOEY2/6qk7Eq0UsMyhrBnF7vPZCq7g2gOLLd7y+DHhL2mLZvYrlyDmZh4gxjEoUYlUs8jg8tTo7fE8cmVbQl9HYHRSs8QF8l1YmiUJ50M6EDjPVc5/4ZICMpyinPx9szJS9Jf4ozguo5qY8Ty16pPMdFXvswTf4vSJveWRPdyxSOhEjlTIYMshgcdYZIPvXJ8T0IlX6b+hdjPldWO9QyFS8XsUvuhD7UQQOnGL1OHpyXExY0qey+Bx/TmMBNq/3QhIcA4GsVCRGR6qEoVp+WJTIZQ4gAXbUKlhsimfbndgeK2T3PFv/9OVC+ X-MS-Exchange-AntiSpam-MessageData: d1GbbDRl/GWieRpcyKpFa1KXcyJk42Y6jSKBukWULJrj1cPn/HUBZdBtfbbJ0Xmo02CanXD42jz6YH7uTg3wqvFRdXL5jag89uQVG7nPNJuzVoIH3sDsb9ONr8KJuUkk1R0mUOkbjx4AJF305iWk6w== X-OriginatorOrg: ucll.be X-MS-Exchange-CrossTenant-Network-Message-Id: 05d42e7f-4df3-4eb7-96f1-08d7e50cff53 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Apr 2020 09:27:08.5315 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e638861b-15d9-4de6-a65d-b48789ae1f08 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4vObImVdhXjRmJcJPQ+V85ZaMHhtZNsyfehvXi71RiZbLLq01S+oSZ9tzzcm64c92Kv+/7Urf9XuaNKei6wUvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0P195MB0692 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=-w9K4oN6/4krAEL7DIeIL Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit a few queries with some info: # \d test Table "public.test" Column | Type | Collation | Nullable | Default --------+---------+-----------+--------- -+--------- a | integer | | | b | text | | | wim=# table test; a | b ---+--- 3 | 3 | 5 | 4 | t 5 | b(5 rows) # SELECT * FROM heap_page_items(get_raw_page('test', 0)); lp | lp_off | lp_flags | lp_len | t_xmin | t_xmax | t_field3 | t_ctid | t_infomask2 | t_infomask | t_hoff | t_bits | t_oid | t_data - ---+--------+----------+--------+--------+--------+----------+------ --+-------------+------------+--------+--------+-------+--------------- - 1 | 8160 | 1 | 28 | 938 | 0 | 0 | (0,1) | 1 | 2304 | 24 | | | \x03000000 2 | 8128 | 1 | 28 | 939 | 0 | 0 | (0,2) | 1 | 2304 | 24 | | | \x03000000 3 | 8096 | 1 | 28 | 941 | 942 | 0 | (0,3) | 8193 | 256 | 24 | | | \x04000000 4 | 8064 | 1 | 28 | 941 | 0 | 0 | (0,4) | 1 | 2304 | 24 | | | \x05000000 5 | 8032 | 1 | 30 | 944 | 0 | 0 | (0,5) | 2 | 2050 | 24 | | | \x040000000574 6 | 8000 | 1 | 30 | 944 | 0 | 0 | (0,6) | 2 | 2050 | 24 | | | \x050000000562 so in this example 941 | 942 (t_xmin t_xmax) is the dead row, the data is in the last row more info about t_data:# SELECT tuple_data_split('test'::regclass, t_data, t_infomask, t_infomask2, t_bits),t_xmin,t_xmax FROM heap_page_items(get_raw_page('test', 0)); tuple_data_split | t_xmin | t_xmax ---------------------------+--------+------ -- {"\\x03000000",NULL} | 938 | 0 {"\\x03000000",NULL} | 939 | 0 {"\\x04000000",NULL} | 941 | 942 {"\\x05000000",NULL} | 941 | 0 {"\\x04000000","\\x0574"} | 944 | 0 {"\\x05000000","\\x0562"} | 944 | 0 # update test set b = 'r' where a=5 and b is null; # SELECT tuple_data_split('test'::regclass, t_data, t_infomask, t_infomask2, t_bits),* FROM heap_page_items(get_raw_page('test', 0)); tuple_data_split | lp | lp_off | lp_flags | lp_len | t_xmin | t_xmax | t_field3 | t_ctid | t_infomask2 | t_infomask | t_hoff | t_bits | t_oid | t_data ---------------------------+----+-- ------+----------+--------+--------+--------+----------+--------+---- ---------+------------+--------+--------+-------+-------------- -- {"\\x03000000",NULL} | 1 | 8160 | 1 | 28 | 938 | 0 | 0 | (0,1) | 1 | 2304 | 24 | | | \x03000000 {"\\x03000000",NULL} | 2 | 8128 | 1 | 28 | 939 | 0 | 0 | (0,2) | 1 | 2304 | 24 | | | \x03000000 {"\\x04000000",NULL} | 3 | 8096 | 1 | 28 | 941 | 942 | 0 | (0,3) | 8193 | 1280 | 24 | | | \x04000000 {"\\x05000000",NULL} | 4 | 8064 | 1 | 28 | 941 | 945 | 0 | (0,7) | 16385 | 256 | 24 | | | \x05000000 {"\\x04000000","\\x0574"} | 5 | 8032 | 1 | 30 | 944 | 0 | 0 | (0,5) | 2 | 2306 | 24 | | | \x040000000574 {"\\x05000000","\\x0562"} | 6 | 8000 | 1 | 30 | 944 | 0 | 0 | (0,6) | 2 | 2306 | 24 | | | \x050000000562 {"\\x05000000","\\x0572"} | 7 | 7968 | 1 | 30 | 945 | 0 | 0 | (0,7) | 32770 | 10242 | 24 | | | \x050000000572 maybe you forget the extension?# create extension pageinspect ; hth,Wim Arnav schreef op vr 17-04-2020 om 17:57 [+0530]: > hi Pgsql-Admin > > What is the command to view the previous version of rows (deleted or > updated) > > I searched and found some functions like : . But none of them are > working > SELECT * FROM page_header(get_raw_page('school',0)); > SELECT * FROM heap_page_items(get_raw_page('school',0)); > ^ > Sorry if the question sounds stupid > -- > Regards > Ankush > > > > > Regards > Arnav -- mvg, Wim Bertels -- Lector UC Leuven-Limburg -- All I know is what the words know, and dead things, and that makes a handsome little sum, with a beginning and a middle and an end, as in the well-built phrase and the long sonata of the dead. -- Samuel Beckett --=-w9K4oN6/4krAEL7DIeIL Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
a few quer= ies with some info:

# \d test
 &nbs= p;            &= nbsp; Table "public.test"
 Column | &nbs= p;Type   | Collation | Nullable | Default 
--= ------+---------+-----------+----------+---------
 a      | integer |   &n= bsp;       |    &nbs= p;     | 
 b   =    | text    |    &n= bsp;      |     &nbs= p;    | 

wim=3D# table te= st;
 a | b 
---+---
 3 |&n= bsp;
 3 | 
 5 | 
 4 = | t
 5 | b
(5 rows)

# SEL= ECT * FROM heap_page_items(get_raw_page('test', 0));

 lp | lp_off | lp_flags | lp_len | t_xmin | t_xmax | t_field3 | t_c= tid | t_infomask2 | t_infomask | t_hoff | t_bits | t_oid |   = ;  t_data     
----+------= --+----------+--------+--------+--------+----------+= ;--------+-------------+------------+--------+--------+= -------+----------------
  1 |   8160 |&n= bsp;       1 |    &n= bsp;28 |    938 |      0 = |        0 | (0,1)  |&nbs= p;          1 | &nbs= p;     2304 |     24 |&nb= sp;       |     = ;  | \x03000000
  2 |   8128 | = ;       1 |     = ;28 |    939 |      0 |&n= bsp;       0 | (0,2)  | &= nbsp;         1 |  &= nbsp;    2304 |     24 | =        |     &n= bsp; | \x03000000
  3 |   8096 | &n= bsp;      1 |     28= |    941 |    942 |  &nb= sp;     0 | (0,3)  |   &n= bsp;    8193 |       = ; 256 |     24 |     = ;   |       | \x04000000<= /div>
  4 |   8064 |     &= nbsp;  1 |     28 |   &nb= sp;941 |      0 |    &nbs= p;   0 | (0,4)  |     &nb= sp;     1 |      &nb= sp;2304 |     24 |     &n= bsp;  |       | \x05000000
  5 |   8032 |     &nbs= p;  1 |     30 |    = 944 |      0 |     &= nbsp;  0 | (0,5)  |      =      2 |       = 2050 |     24 |      = ;  |       | \x040000000574
  6 |   8000 |     &nb= sp;  1 |     30 |    = ;944 |      0 |     =    0 | (0,6)  |      = ;     2 |       = ;2050 |     24 |     &nbs= p;  |       | \x050000000562

so in this example 941 |   &nbs= p;942 (t_xmin t_xmax) is the dead row, the data is in the last row

more info about t_data:
# SELECT tuple_data_spl= it('test'::regclass, t_data, t_infomask, t_infomask2, t_bits),t_xmin,t_xmax= FROM heap_page_items(get_raw_page('test', 0));
   = ;  tuple_data_split      | t_xmin |= t_xmax 
---------------------------+--------+------= --
 {"\\x03000000",NULL}    &n= bsp; |    938 |      = ;0
 {"\\x03000000",NULL}    &n= bsp; |    939 |      = ;0
 {"\\x04000000",NULL}    &n= bsp; |    941 |    942
 {"\\x05000000",NULL}      = |    941 |      0
 {"\\x04000000","\\x0574"} |   &= nbsp;944 |      0
 {"\\x0= 5000000","\\x0562"} |    944 | &nbs= p;    0

# update te= st set b =3D 'r' where a=3D5 and b is null;

# SELE= CT tuple_data_split('test'::regclass, t_data, t_infomask, t_infomask2, t_bi= ts),* FROM heap_page_items(get_raw_page('test', 0));
  =    tuple_data_split      | lp = | lp_off | lp_flags | lp_len | t_xmin | t_xmax | t_field3 | t_ctid | t_info= mask2 | t_infomask | t_hoff | t_bits | t_oid |     = ;t_data     
---------------------------= +----+--------+----------+--------+--------+-------= -+----------+--------+-------------+------------+------= --+--------+-------+----------------
 {"\\x= 03000000",NULL}      |  1 |&nb= sp;  8160 |        1 |&nb= sp;    28 |    938 |  &nb= sp;   0 |        0 |= (0,1)  |         &n= bsp; 1 |       2304 |  &n= bsp;  24 |        | =       | \x03000000
 {"\\x= 03000000",NULL}      |  2 |&nb= sp;  8128 |        1 |&nb= sp;    28 |    939 |  &nb= sp;   0 |        0 |= (0,2)  |         &n= bsp; 1 |       2304 |  &n= bsp;  24 |        | =       | \x03000000
 {"\\x= 04000000",NULL}      |  3 |&nb= sp;  8096 |        1 |&nb= sp;    28 |    941 |  &nb= sp; 942 |        0 | (0,3)&nbs= p; |        8193 |  =      1280 |     24 | = ;       |     &= nbsp; | \x04000000
 {"\\x05000000",NULL} = ;     |  4 |   8064 |&nbs= p;       1 |    &nbs= p;28 |    941 |    945 |  = ;      0 | (0,7)  |  &nbs= p;    16385 |       =  256 |     24 |     =    |       | \x05000000
 {"\\x04000000","\\x0574"} |  5= |   8032 |        1= |     30 |    944 | &nbs= p;    0 |       &nbs= p;0 | (0,5)  |        &nb= sp;  2 |       2306 | &nb= sp;   24 |        |&= nbsp;      | \x040000000574
 {= "\\x05000000","\\x0562"} |  6 |  &n= bsp;8000 |        1 |  &n= bsp;  30 |    944 |    &n= bsp; 0 |        0 | (0,6) = ; |           2= |       2306 |    &= nbsp;24 |        |   = ;    | \x050000000562
 {"\\x0500000= 0","\\x0572"} |  7 |   7968 | =        1 |     = 30 |    945 |      0 |&nb= sp;       0 | (0,7)  | &n= bsp;     32770 |     &nbs= p;10242 |     24 |     &n= bsp;  |       | \x050000000572=

maybe you forget the extension?
# creat= e extension pageinspect ;

hth,
Wim
=

Arnav schreef op vr 17-04-2020 om 17:57 [+0530]:
hi Pgsql-Admin

=
What is the command to view the previous version of rows (deleted or u= pdated)

I searched and found some functions like := . But none of them are working
 SELECT * FROM page_header(g= et_raw_page('school',0));
SELECT * FROM heap_page_items(get_raw_p= age('school',0));
             = ;                     ^
Sorry if the question sounds stupid
-- 
R= egards
Ankush



<= div>
Regards
Arnav
-- 
mvg, Wim Bertels -- Lector UC Leuven-Limburg -- All I know is what the words know, and dead things, and that makes a handsome little sum, with a beginning and a middle and an end, as in the well-built phrase and the long sonata of the dead. -- Samuel Beckett
--=-w9K4oN6/4krAEL7DIeIL--