BUG #15729: Error 'invalid memory alloc request size' during updating a big xml field - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15729: Error 'invalid memory alloc request size' during updating a big xml field
Date
Msg-id 15729-bb65cf975dd7c6ca@postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15729
Logged by:          Kent
Email address:      varuzam@gmail.com
PostgreSQL version: 11.2
Operating system:   Centos 7 64bit
Description:

Hello
I have a table with big records
```
test=# \d xrecords 
                 Table "public.xrecords"
 Column |     Type      | Collation | Nullable | Default 
--------+---------------+-----------+----------+---------
 recid  | character(19) |           | not null | 
 detail | xml           |           |          | 
 data   | oid           |           |          | 
Indexes:
    "recidkey" PRIMARY KEY, btree (recid)
    "delete_ix" btree (text((xpath('/detail/delete_date/text()'::text,
detail))[1]))
Triggers:
    delete_all_trigger BEFORE TRUNCATE ON xrecords FOR EACH STATEMENT
EXECUTE PROCEDURE clean_all_data()
    delete_trigger BEFORE DELETE ON xrecords FOR EACH ROW EXECUTE PROCEDURE
clean_data()
    insert_or_update_trigger BEFORE INSERT ON xrecords FOR EACH ROW EXECUTE
PROCEDURE insert_or_update()
    update_trigger BEFORE UPDATE ON xrecords FOR EACH ROW EXECUTE PROCEDURE
clean_data()


test=# select length(detail::text) from xrecords WHERE
recid='GU20190309070000020' ;
  length   
-----------
 493514189
```

The error occurs during this query
```
test=# UPDATE xrecords SET detail = XMLPARSE (DOCUMENT
replace(text(detail),'<update_date>','<delete_date>2019-04-01
10:04:05</delete_date><update_date>')) WHERE recid='GU20190309070000020' AND
text((xpath('/detail/delete_date/text()', detail))[1]) IS NULL;

ERROR:  invalid memory alloc request size 1974056760
```

is it a bug?


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #15727: PANIC: cannot abort transaction 295144144, it was already committed
Next
From: Andres Freund
Date:
Subject: Re: BUG #15727: PANIC: cannot abort transaction 295144144, it wasalready committed