On Mon, Jun 28, 2010 at 11:42 AM, Mike Rylander <mrylander(at)gmail(dot)com> wrote:
> You could do something like this (untested):
>
> CREATE OR REPLACE FUNCTION my_xml_is_valid ( x TEXT ) RETURNS BOOL AS $$
> BEGIN
> PERFORM XMLPARSE( DOCUMENT x::XML );
> RETURN TRUE;
> EXCEPTION WHEN OTHERS THEN
> RETURN FALSE;
> END;
> $$ LANGUAGE PLPGSQL;
This might perform significantly worse, though: exception handling ain't cheap.
It's not a bad workaround, but I think the OP has a point.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company