I want to check the capability of XML in PostgreSQL before moving large data into the Database.
I have a simple test to check the XML Capability in PostgreSQL. It works with 3000000 XML formed data but not with 4000000.
✅
select xml_is_well_formed('<test>' || repeat('월', 3000000) || '</test>');
❌
select xml_is_well_formed('<test>' || repeat('월', 4000000) || '</test>');
This is what my XML Capability test looks like: XML_Test.sh
#### XML capabilities
sql1="select xml_is_well_formed('<test>' || repeat('월', 3000000) || '</test>');"
sql2="select xml_is_well_formed('<test>' || repeat('월', 4000000) || '</test>');"
status="OK:"
ret=$(echo "$sql1" | psql -At -U $user -h $host $db)
if [ "$ret" != "t" ]
then
status="FAILED:"
fi
echo " $status XML capability (test 1/libxml): "
status="OK:"
ret=$(echo "$sql2" | psql -At -U $user -h $host $db)
if [ "$ret" != "t" ]
then
status="FAILED:"
fi
echo " $status XML capability (test 2/libxml): "
I'm using Amazon Linux AMI and my PostgreSQL version is: 9.2.24 and using the default PostgreSQL configuration.
Edit: My total system memory is 32 GB.
Running the below command is only indicating whether the test is passing or not:
$ echo "select xml_is_well_formed('<test>' || repeat('월', 4000000) || '</test>')" | psql -At -U USER -h localhost DB
f
$ echo "select xml_is_well_formed('<test>' || repeat('월', 3000000) || '</test>')" | psql -At -U USER -h localhost DB
t
Thank you!
xml_is_well_formedisn't used in querying and doesn't have to work with such amounts anyway. It's the loader's job to ensure the input is valid - and a single XML element with 1GB of text isn't a valid choice. It's a BLOB and should be treated as one. The query doesn't test loading, insertion, indexing or querying.