Thread: How to handle "could not find function xml_is_well_formed" when restoring database in Version 17
How to handle "could not find function xml_is_well_formed" when restoring database in Version 17
Good afternoon,
I am testing upgrading from Version 13 to Version 17. I am getting the following error when trying to restore a database in Version 17 (the database was backed up from Version 13 using the Version 17 pg_dump):
pg_Restore: error: could not execute query: ERROR: could not find function "xml_is_well_formed" in file "C:/Program Files/PostgreSQL/17/lib/pgxml.dll"
Command was: CREATE FUNCTION public.xml_is_well_formed(text) RETURNS boolean
LANGUAGE c IMMUTABLE STRICT
AS '$libdir/pgxml', 'xml_is_well_formed';
The only reference I can find to xml_is_well_formed in the Release Notes (Version 15) is:
Remove xml2's
xml_is_well_formed()
function (Tom Lane) This function has been implemented in the core backend since Postgres 9.1
How do I address this in restoring the backup to 17?
Thanks,
George
Re: How to handle "could not find function xml_is_well_formed" when restoring database in Version 17
## George Weaver (gweaver@shaw.ca): > I am testing upgrading from Version 13 to Version 17. I am getting > the following error when trying to restore a database in Version 17 > (the database was backed up from Version 13 using the Version 17 > pg_dump): > > pg_Restore: error: could not execute query: ERROR: could not find > function "xml_is_well_formed" in file "C:/Program > Files/PostgreSQL/17/lib/pgxml.dll" > Command was: CREATE FUNCTION public.xml_is_well_formed(text) RETURNS > boolean > LANGUAGE c IMMUTABLE STRICT > AS '$libdir/pgxml', 'xml_is_well_formed'; > > The only reference I can find to xml_is_well_formed in the Release > Notes (Version 15) is: That's it. Your best option is to get rid of that module in the "old" (PostgreSQL 13) database - maybe cou can just drop the extension outright (because it's not really used anyways), maybe you need to fix you code to use the new API. The minimalist workaround would be to exclude function public.xml_is_well_formed() from the backup (either at backup or at restore time) and point your code to pg_catalog.xml_is_well_formed(). The fact that you are seeing that CREATE FUNCTION and not only a CREATE EXTENSION would indicate that the function was created manually and not as part of the extension (but pgxml.so would match the extension) - or this is a left-over from pre-extension days (CREATE EXTENSION was added in 9.1, so...) I'd strongly advise to clean up the old database (if required migrate away from the xml2 extension/functions and drop the extensions and any manually created function referencing it), it will safe you a lot of headache later on. Regards, Christoph -- Spare Space
Re: How to handle "could not find function xml_is_well_formed" when restoring database in Version 17
George Weaver <gweaver@shaw.ca> writes: > I am testing upgrading from Version 13 to Version 17. I am getting the > following error when trying to restore a database in Version 17 (the > database was backed up from Version 13 using the Version 17 pg_dump): > pg_Restore: error: could not execute query: ERROR: could not find > function "xml_is_well_formed" in file "C:/Program > Files/PostgreSQL/17/lib/pgxml.dll" > Command was: CREATE FUNCTION public.xml_is_well_formed(text) RETURNS > boolean > LANGUAGE c IMMUTABLE STRICT > AS '$libdir/pgxml', 'xml_is_well_formed'; What you appear to have here is a pre-9.1 version of the xml2 extension. That is so old that you're going to have difficulty modernizing it. We used to provide scripts for converting those loose objects into extensions, but we got rid of them in v13, figuring that after ten years their usefulness had passed. I think what you will have to do is manually drop all the xml2 functions (look for pg_proc entries with '$libdir/pgxml' in probin) from the v13 database, then upgrade, then install the xml2 extension if you still want it. Fortunately that module only provided functions not datatypes, so this shouldn't be too painful. (Another way could be to manually remove those CREATE FUNCTION commands from the dump script.) I'm betting that this database has a lot of other deferred maintenance that you ought to think about while you're at it. If there are any other old-style extensions in there, better fix them up. regards, tom lane
Re: How to handle "could not find function xml_is_well_formed" when restoring database in Version 17
Thanks Tom and Christoph,
Got it!
The function xml_valid is also gone. Does xml_is_well_formed accomplish the same objective?
Thanks,
George
George Weaver <gweaver@shaw.ca> writes:I am testing upgrading from Version 13 to Version 17. I am getting the following error when trying to restore a database in Version 17 (the database was backed up from Version 13 using the Version 17 pg_dump):pg_Restore: error: could not execute query: ERROR: could not find function "xml_is_well_formed" in file "C:/Program Files/PostgreSQL/17/lib/pgxml.dll" Command was: CREATE FUNCTION public.xml_is_well_formed(text) RETURNS boolean LANGUAGE c IMMUTABLE STRICT AS '$libdir/pgxml', 'xml_is_well_formed';What you appear to have here is a pre-9.1 version of the xml2 extension. That is so old that you're going to have difficulty modernizing it. We used to provide scripts for converting those loose objects into extensions, but we got rid of them in v13, figuring that after ten years their usefulness had passed. I think what you will have to do is manually drop all the xml2 functions (look for pg_proc entries with '$libdir/pgxml' in probin) from the v13 database, then upgrade, then install the xml2 extension if you still want it. Fortunately that module only provided functions not datatypes, so this shouldn't be too painful. (Another way could be to manually remove those CREATE FUNCTION commands from the dump script.) I'm betting that this database has a lot of other deferred maintenance that you ought to think about while you're at it. If there are any other old-style extensions in there, better fix them up. regards, tom lane
Re: How to handle "could not find function xml_is_well_formed" when restoring database in Version 17
On 10/3/24 08:20, George Weaver wrote: > Thanks Tom and Christoph, > > Got it! > > The function xml_valid is also gone. Does xml_is_well_formed accomplish > the same objective? Gone from where? https://www.postgresql.org/docs/17/xml2.html xml_valid ( document text ) → boolean Parses the given document and returns true if the document is well-formed XML. (Note: this is an alias for the standard PostgreSQL function xml_is_well_formed(). The name xml_valid() is technically incorrect since validity and well-formedness have different meanings in XML.) > > Thanks, > > George -- Adrian Klaver adrian.klaver@aklaver.com