@@ -344,7 +344,7 @@ xml_out_internal(xmltype *x, pg_enc target_encoding)
344344 }
345345
346346 ereport (WARNING ,
347- errcode (ERRCODE_INTERNAL_ERROR ),
347+ errcode (ERRCODE_DATA_CORRUPTED ),
348348 errmsg_internal ("could not parse XML declaration in stored value" ),
349349 errdetail_for_xml_code (res_code ));
350350#endif
@@ -742,7 +742,7 @@ xmltotext_with_options(xmltype *data, XmlOptionType xmloption_arg, bool indent)
742742 {
743743 /* If it's a document, saving is easy. */
744744 if (xmlSaveDoc (ctxt , doc ) == -1 || xmlerrcxt -> err_occurred )
745- xml_ereport (xmlerrcxt , ERROR , ERRCODE_INTERNAL_ERROR ,
745+ xml_ereport (xmlerrcxt , ERROR , ERRCODE_OUT_OF_MEMORY ,
746746 "could not save document to xmlBuffer" );
747747 }
748748 else if (content_nodes != NULL )
@@ -785,15 +785,15 @@ xmltotext_with_options(xmltype *data, XmlOptionType xmloption_arg, bool indent)
785785 if (xmlSaveTree (ctxt , newline ) == -1 || xmlerrcxt -> err_occurred )
786786 {
787787 xmlFreeNode (newline );
788- xml_ereport (xmlerrcxt , ERROR , ERRCODE_INTERNAL_ERROR ,
788+ xml_ereport (xmlerrcxt , ERROR , ERRCODE_OUT_OF_MEMORY ,
789789 "could not save newline to xmlBuffer" );
790790 }
791791 }
792792
793793 if (xmlSaveTree (ctxt , node ) == -1 || xmlerrcxt -> err_occurred )
794794 {
795795 xmlFreeNode (newline );
796- xml_ereport (xmlerrcxt , ERROR , ERRCODE_INTERNAL_ERROR ,
796+ xml_ereport (xmlerrcxt , ERROR , ERRCODE_OUT_OF_MEMORY ,
797797 "could not save content to xmlBuffer" );
798798 }
799799 }
@@ -1004,7 +1004,7 @@ xmlpi(const char *target, text *arg, bool arg_is_null, bool *result_is_null)
10041004
10051005 if (pg_strcasecmp (target , "xml" ) == 0 )
10061006 ereport (ERROR ,
1007- (errcode (ERRCODE_SYNTAX_ERROR ), /* really */
1007+ (errcode (ERRCODE_INVALID_XML_PROCESSING_INSTRUCTION ),
10081008 errmsg ("invalid XML processing instruction" ),
10091009 errdetail ("XML processing instruction target name cannot be \"%s\"." , target )));
10101010
@@ -4383,7 +4383,7 @@ xpath_internal(text *xpath_expr_text, xmltype *data, ArrayType *namespaces,
43834383 xpath_len = VARSIZE_ANY_EXHDR (xpath_expr_text );
43844384 if (xpath_len == 0 )
43854385 ereport (ERROR ,
4386- (errcode (ERRCODE_DATA_EXCEPTION ),
4386+ (errcode (ERRCODE_INVALID_ARGUMENT_FOR_XQUERY ),
43874387 errmsg ("empty XPath expression" )));
43884388
43894389 string = pg_xmlCharStrndup (datastr , len );
@@ -4456,7 +4456,7 @@ xpath_internal(text *xpath_expr_text, xmltype *data, ArrayType *namespaces,
44564456 */
44574457 xpathcomp = xmlXPathCtxtCompile (xpathctx , xpath_expr );
44584458 if (xpathcomp == NULL || xmlerrcxt -> err_occurred )
4459- xml_ereport (xmlerrcxt , ERROR , ERRCODE_INTERNAL_ERROR ,
4459+ xml_ereport (xmlerrcxt , ERROR , ERRCODE_INVALID_ARGUMENT_FOR_XQUERY ,
44604460 "invalid XPath expression" );
44614461
44624462 /*
@@ -4468,7 +4468,7 @@ xpath_internal(text *xpath_expr_text, xmltype *data, ArrayType *namespaces,
44684468 */
44694469 xpathobj = xmlXPathCompiledEval (xpathcomp , xpathctx );
44704470 if (xpathobj == NULL || xmlerrcxt -> err_occurred )
4471- xml_ereport (xmlerrcxt , ERROR , ERRCODE_INTERNAL_ERROR ,
4471+ xml_ereport (xmlerrcxt , ERROR , ERRCODE_INVALID_ARGUMENT_FOR_XQUERY ,
44724472 "could not create XPath object" );
44734473
44744474 /*
@@ -4798,7 +4798,7 @@ XmlTableSetNamespace(TableFuncScanState *state, const char *name, const char *ur
47984798 if (xmlXPathRegisterNs (xtCxt -> xpathcxt ,
47994799 pg_xmlCharStrndup (name , strlen (name )),
48004800 pg_xmlCharStrndup (uri , strlen (uri ))))
4801- xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_DATA_EXCEPTION ,
4801+ xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_INVALID_ARGUMENT_FOR_XQUERY ,
48024802 "could not set XML namespace" );
48034803#else
48044804 NO_XML_SUPPORT ();
@@ -4820,7 +4820,7 @@ XmlTableSetRowFilter(TableFuncScanState *state, const char *path)
48204820
48214821 if (* path == '\0' )
48224822 ereport (ERROR ,
4823- (errcode (ERRCODE_DATA_EXCEPTION ),
4823+ (errcode (ERRCODE_INVALID_ARGUMENT_FOR_XQUERY ),
48244824 errmsg ("row path filter must not be empty string" )));
48254825
48264826 xstr = pg_xmlCharStrndup (path , strlen (path ));
@@ -4830,7 +4830,7 @@ XmlTableSetRowFilter(TableFuncScanState *state, const char *path)
48304830
48314831 xtCxt -> xpathcomp = xmlXPathCtxtCompile (xtCxt -> xpathcxt , xstr );
48324832 if (xtCxt -> xpathcomp == NULL || xtCxt -> xmlerrcxt -> err_occurred )
4833- xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_SYNTAX_ERROR ,
4833+ xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_INVALID_ARGUMENT_FOR_XQUERY ,
48344834 "invalid XPath expression" );
48354835#else
48364836 NO_XML_SUPPORT ();
@@ -4854,7 +4854,7 @@ XmlTableSetColumnFilter(TableFuncScanState *state, const char *path, int colnum)
48544854
48554855 if (* path == '\0' )
48564856 ereport (ERROR ,
4857- (errcode (ERRCODE_DATA_EXCEPTION ),
4857+ (errcode (ERRCODE_INVALID_ARGUMENT_FOR_XQUERY ),
48584858 errmsg ("column path filter must not be empty string" )));
48594859
48604860 xstr = pg_xmlCharStrndup (path , strlen (path ));
@@ -4864,7 +4864,7 @@ XmlTableSetColumnFilter(TableFuncScanState *state, const char *path, int colnum)
48644864
48654865 xtCxt -> xpathscomp [colnum ] = xmlXPathCtxtCompile (xtCxt -> xpathcxt , xstr );
48664866 if (xtCxt -> xpathscomp [colnum ] == NULL || xtCxt -> xmlerrcxt -> err_occurred )
4867- xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_DATA_EXCEPTION ,
4867+ xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_INVALID_ARGUMENT_FOR_XQUERY ,
48684868 "invalid XPath expression" );
48694869#else
48704870 NO_XML_SUPPORT ();
@@ -4891,7 +4891,7 @@ XmlTableFetchRow(TableFuncScanState *state)
48914891 {
48924892 xtCxt -> xpathobj = xmlXPathCompiledEval (xtCxt -> xpathcomp , xtCxt -> xpathcxt );
48934893 if (xtCxt -> xpathobj == NULL || xtCxt -> xmlerrcxt -> err_occurred )
4894- xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_INTERNAL_ERROR ,
4894+ xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_INVALID_ARGUMENT_FOR_XQUERY ,
48954895 "could not create XPath object" );
48964896
48974897 xtCxt -> row_count = 0 ;
@@ -4955,7 +4955,7 @@ XmlTableGetValue(TableFuncScanState *state, int colnum,
49554955 /* Evaluate column path */
49564956 xpathobj = xmlXPathCompiledEval (xtCxt -> xpathscomp [colnum ], xtCxt -> xpathcxt );
49574957 if (xpathobj == NULL || xtCxt -> xmlerrcxt -> err_occurred )
4958- xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_INTERNAL_ERROR ,
4958+ xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_INVALID_ARGUMENT_FOR_XQUERY ,
49594959 "could not create XPath object" );
49604960
49614961 /*
0 commit comments