diff --git a/contrib/babelfishpg_tsql/runtime/functions.c b/contrib/babelfishpg_tsql/runtime/functions.c index 61b087f4f1..18426ec9ab 100644 --- a/contrib/babelfishpg_tsql/runtime/functions.c +++ b/contrib/babelfishpg_tsql/runtime/functions.c @@ -243,7 +243,6 @@ extern bool inited_ht_tsql_cast_info; extern bool inited_ht_tsql_datatype_precedence_info; extern PLtsql_execstate *get_outermost_tsql_estate(int *nestlevel); extern char *replace_special_chars_fts_impl(char *input_str); -extern void get_xml_data_and_namespace_data(int document_id, xmltype **xml_data, xmltype **ns_data); #ifdef USE_LIBXML HTAB *ht_xmlNode2Id = NULL; @@ -5183,7 +5182,7 @@ get_bbf_pivot_tuplestore(const char *sourcetext, * The count of extracted namespaces is stored in ns_count. If no namespaces are found, * ns_names and ns_uris are set to NULL and ns_count to 0. */ -static void +void extract_namespaces_from_xml(xmltype *ns_data, char ***ns_names, char ***ns_uris, int *ns_count) { xmlDocPtr doc; diff --git a/contrib/babelfishpg_tsql/sql/sys_function_helpers.sql b/contrib/babelfishpg_tsql/sql/sys_function_helpers.sql index c5c739d0d6..b10411e748 100644 --- a/contrib/babelfishpg_tsql/sql/sys_function_helpers.sql +++ b/contrib/babelfishpg_tsql/sql/sys_function_helpers.sql @@ -3022,32 +3022,6 @@ $BODY$ LANGUAGE plpgsql STABLE; -CREATE OR REPLACE FUNCTION sys.babelfish_openxml(IN DocHandle BIGINT) - RETURNS TABLE (XmlData XML) -AS -$BODY$ -DECLARE - XmlDocument$data XML; -BEGIN - - SELECT t.XmlData - INTO STRICT XmlDocument$data - FROM sys$openxml t - WHERE t.DocID = DocHandle; - - RETURN QUERY SELECT XmlDocument$data; - - EXCEPTION - WHEN SQLSTATE '42P01' OR SQLSTATE 'P0002' THEN - RAISE EXCEPTION '%','Could not find prepared statement with handle '||CASE - WHEN DocHandle IS NULL THEN 'null' - ELSE DocHandle::TEXT - END; -END; -$BODY$ -LANGUAGE plpgsql -STABLE; - CREATE OR REPLACE FUNCTION sys.babelfish_parse_to_date(IN p_datestring TEXT, IN p_culture TEXT DEFAULT '') RETURNS DATE diff --git a/contrib/babelfishpg_tsql/sql/sys_functions.sql b/contrib/babelfishpg_tsql/sql/sys_functions.sql index e434cc2a99..e7909cb7f6 100644 --- a/contrib/babelfishpg_tsql/sql/sys_functions.sql +++ b/contrib/babelfishpg_tsql/sql/sys_functions.sql @@ -4152,6 +4152,18 @@ CREATE OR REPLACE FUNCTION sys.openjson_with(json_string text, path text, VARIAD RETURNS SETOF RECORD AS 'babelfishpg_tsql', 'tsql_openjson_with' LANGUAGE C STRICT IMMUTABLE PARALLEL SAFE; +/* Function to retrieve XML doc from temp table using doc_id (for openxml) */ +CREATE OR REPLACE FUNCTION sys.tsql_openxml_get_xmldoc(int) +RETURNS xml +AS 'babelfishpg_tsql', 'tsql_openxml_get_xmldoc' +LANGUAGE C STRICT; + +/* This function generates XPath expressions for OPENXML columns */ +CREATE OR REPLACE FUNCTION sys.tsql_openxml_get_colpattern(text,int) +RETURNS sys.nvarchar +AS 'babelfishpg_tsql', 'tsql_openxml_get_colpattern' +LANGUAGE C STRICT; + CREATE OR REPLACE FUNCTION sys.sp_datatype_info_helper( IN odbcVer smallint, IN is_100 bool, diff --git a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--5.3.0--5.4.0.sql b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--5.3.0--5.4.0.sql index dfbbe99a99..d2009c166e 100644 --- a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--5.3.0--5.4.0.sql +++ b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--5.3.0--5.4.0.sql @@ -223,6 +223,16 @@ GRANT EXECUTE ON PROCEDURE sys.sp_xml_removedocument( IN INTEGER ) TO PUBLIC; +CREATE OR REPLACE FUNCTION sys.tsql_openxml_get_xmldoc(int) +RETURNS xml +AS 'babelfishpg_tsql', 'tsql_openxml_get_xmldoc' +LANGUAGE C STRICT; + +CREATE OR REPLACE FUNCTION sys.tsql_openxml_get_colpattern(text,int) +RETURNS sys.nvarchar +AS 'babelfishpg_tsql', 'tsql_openxml_get_colpattern' +LANGUAGE C STRICT; + CREATE OR REPLACE FUNCTION sys.openxml_simple(document_id INT, rowpattern TEXT, flags INTEGER DEFAULT 0) @@ -283,6 +293,20 @@ BEGIN END; $$ LANGUAGE plpgsql IMMUTABLE STRICT PARALLEL SAFE; +DO $$ +DECLARE + exception_message text; +BEGIN + ALTER FUNCTION sys.babelfish_openxml RENAME TO babelfish_openxml_deprecated_in_5_4_0; +EXCEPTION WHEN OTHERS THEN + GET STACKED DIAGNOSTICS + exception_message = MESSAGE_TEXT; + RAISE WARNING '%', exception_message; +END; +$$; + +CALL sys.babelfish_drop_deprecated_object('function', 'sys', 'babelfish_openxml_deprecated_in_5_4_0'); + -- Drops the temporary procedure used by the upgrade script. -- Please have this be one of the last statements executed in this upgrade script. DROP PROCEDURE sys.babelfish_drop_deprecated_object(varchar, varchar, varchar); diff --git a/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-decl.y b/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-decl.y index bf57dc3830..73f90abb19 100644 --- a/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-decl.y +++ b/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-decl.y @@ -42,6 +42,8 @@ %type optional_path %type optional_asJson %type openxml_expr +%type openxml_column_list +%type openxml_column_el %type tsql_opt_arg_dflt %type tsql_opt_null_keyword @@ -137,6 +139,6 @@ * otherwise the parser cannot tell between 'WITH' and 'WITH (' and thus * lead to a shift/reduce conflict. */ -%token WITH_paren TSQL_HINT_START_BRACKET UPDATE_paren +%token WITH_paren TSQL_HINT_START_BRACKET UPDATE_paren WITH_table %left TSQL_CROSS TSQL_OUTER TSQL_UNPIVOT diff --git a/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-rule.y b/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-rule.y index 4ea0dffaea..7aa43f8cc8 100644 --- a/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-rule.y +++ b/contrib/babelfishpg_tsql/src/backend_parser/gram-tsql-rule.y @@ -1836,6 +1836,83 @@ openxml_expr: OPENXML '(' a_expr ',' a_expr ')' opt_alias_clause /* map to OPENXML_SIMPLE */ $$ = (Node*) n; } + | OPENXML '(' a_expr ',' a_expr ')' WITH_table TABLE qualified_name opt_alias_clause + { + RangeTableFunc *n = makeNode(RangeTableFunc); + n->docexpr = $3; + n->rowexpr = $5; + n->location = @1; + /* Default flag is 0 when not specified */ + n->namespaces = list_make1(makeIntConst(0, @1)); + n->columns = list_make1($9); + n->alias = $10; + $$ = (Node *) n; + } + | OPENXML '(' a_expr ',' a_expr ',' a_expr ')' WITH_table TABLE qualified_name opt_alias_clause + { + RangeTableFunc *n = makeNode(RangeTableFunc); + n->docexpr = $3; + n->rowexpr = $5; + n->location = @1; + n->namespaces = list_make1((Node *)$7); + n->columns = list_make1($11); + n->alias = $12; + $$ = (Node *) n; + } + | OPENXML '(' a_expr ',' a_expr ')' WITH_paren '(' openxml_column_list ')' opt_alias_clause + { + RangeTableFunc *n = makeNode(RangeTableFunc); + n->docexpr = $3; + n->rowexpr = $5; + n->location = @1; + n->columns = $9; + /* Default flag is 0 when not specified */ + n->namespaces = list_make1(makeIntConst(0, @1)); + n->alias = $11; + $$ = (Node *) n; + } + | OPENXML '(' a_expr ',' a_expr ',' a_expr ')' WITH_paren '(' openxml_column_list ')' opt_alias_clause + { + RangeTableFunc *n = makeNode(RangeTableFunc); + n->docexpr = $3; + n->rowexpr = $5; + n->columns = $11; + n->location = @1; + n->namespaces = list_make1((Node *)$7); + n->alias = $13; + $$ = (Node *) n; + } + ; + +openxml_column_list: openxml_column_el { $$ = list_make1($1); } + | openxml_column_list ',' openxml_column_el { $$ = lappend($1, $3); } + ; + +openxml_column_el: + ColId Typename + { + RangeTableFuncCol *fc = makeNode(RangeTableFuncCol); + + fc->colname = $1; + fc->typeName = $2; + fc->colexpr = NULL; + fc->coldefexpr = NULL; + fc->location = @1; + + $$ = (Node *) fc; + } + | ColId Typename Sconst + { + RangeTableFuncCol *fc = makeNode(RangeTableFuncCol); + + fc->colname = $1; + fc->typeName = $2; + fc->colexpr = (Node *) makeStringConst($3, @1); + fc->coldefexpr = NULL; + fc->location = @1; + + $$ = (Node *) fc; + } ; openjson_expr: OPENJSON '(' a_expr ')' opt_alias_clause diff --git a/contrib/babelfishpg_tsql/src/backend_parser/parser.c b/contrib/babelfishpg_tsql/src/backend_parser/parser.c index a25fca6f3a..4ae9d3ad2a 100644 --- a/contrib/babelfishpg_tsql/src/backend_parser/parser.c +++ b/contrib/babelfishpg_tsql/src/backend_parser/parser.c @@ -266,6 +266,8 @@ pgtsql_base_yylex(YYSTYPE *lvalp, YYLTYPE * llocp, core_yyscan_t yyscanner) case '(': cur_token = WITH_paren; break; + case TABLE: + cur_token = WITH_table; } break; case '(': diff --git a/contrib/babelfishpg_tsql/src/extendedproperty.c b/contrib/babelfishpg_tsql/src/extendedproperty.c index ad2719e1a8..2e1e22ffa0 100644 --- a/contrib/babelfishpg_tsql/src/extendedproperty.c +++ b/contrib/babelfishpg_tsql/src/extendedproperty.c @@ -71,7 +71,6 @@ static void init_scan_key(ScanKeyData *scanKey, static void sp_execextended_property(PG_FUNCTION_ARGS, ExtendedPropertyProc proc); static bool get_extended_property_from_tuple(Relation relation, HeapTuple tuple, Datum *values, bool *nulls, int len); -static char* get_value_by_name_from_array(ArrayType *array, const char *name); static void init_scan_key(ScanKeyData *scanKey, @@ -923,7 +922,7 @@ fn_listextendedproperty(PG_FUNCTION_ARGS) extern const char *ATTOPTION_BBF_ORIGINAL_TABLE_NAME; extern const char *ATTOPTION_BBF_ORIGINAL_NAME; -static char* +char* get_value_by_name_from_array(ArrayType *array, const char *name) { int i; diff --git a/contrib/babelfishpg_tsql/src/extendedproperty.h b/contrib/babelfishpg_tsql/src/extendedproperty.h index 99ccd7a4c4..b68e4188c5 100644 --- a/contrib/babelfishpg_tsql/src/extendedproperty.h +++ b/contrib/babelfishpg_tsql/src/extendedproperty.h @@ -16,6 +16,7 @@ typedef enum ExtendedPropertyType } ExtendedPropertyType; extern const char *const ExtendedPropertyTypeNames[]; +extern char *get_value_by_name_from_array(ArrayType *array, const char *name); extern void delete_extended_property(int16 db_id, const char *type, diff --git a/contrib/babelfishpg_tsql/src/hooks.c b/contrib/babelfishpg_tsql/src/hooks.c index 7a025e36b1..6b5f16e4d3 100644 --- a/contrib/babelfishpg_tsql/src/hooks.c +++ b/contrib/babelfishpg_tsql/src/hooks.c @@ -94,6 +94,14 @@ #include "tsql_analyze.h" #include "table_variable_mvcc.h" #include "bbf_parallel_query.h" +#include "extendedproperty.h" +#include "utils/xml.h" + +#ifdef USE_LIBXML +#include +#include +#include +#endif /* USE_LIBXML */ #define TDS_NUMERIC_MAX_PRECISION 38 @@ -118,6 +126,7 @@ typedef enum PltsqlInitPrivsOptions ERROR_INIT_PRIVS } PltsqlInitPrivsOptions; + /***************************************** * General Hooks *****************************************/ @@ -261,6 +270,10 @@ static char* pltsql_get_object_identity_event_trigger(ObjectAddress *addr); static const char *remove_db_name_in_schema(const char *schema_name, const char *object_type); static int32 pltsql_exprTypmod(Plan *plan, Node *expr); static Oid get_domain_typmodin(Type typ); +static void pre_transform_openxml_columns(ParseState *pstate, RangeTableFunc *rtf); +#ifdef USE_LIBXML +static void openxml_set_namespaces(xmlXPathContext *xpathctx, PgXmlErrorContext *xmlerrcxt, char *doc_id_str); +#endif /*************************************************** * Temp Table Related Declarations + Hooks @@ -327,6 +340,7 @@ static match_pltsql_func_call_hook_type prev_match_pltsql_func_call_hook = NULL; static insert_pltsql_function_defaults_hook_type prev_insert_pltsql_function_defaults_hook = NULL; static replace_pltsql_function_defaults_hook_type prev_replace_pltsql_function_defaults_hook = NULL; static exprTypmod_hook_type prev_exprTypmod_hook = NULL; +static pre_transform_openxml_columns_hook_type prev_pre_transform_openxml_columns_hook = NULL; static print_pltsql_function_arguments_hook_type prev_print_pltsql_function_arguments_hook = NULL; static planner_hook_type prev_planner_hook = NULL; static transform_check_constraint_expr_hook_type prev_transform_check_constraint_expr_hook = NULL; @@ -362,6 +376,9 @@ static validateCachedPlanSearchPath_hook_type prev_validateCachedPlanSearchPath_ static pre_QueryRewrite_hook_type prev_pre_QueryRewrite_hook = NULL; ExecInitParallelPlan_hook_type prev_ExecInitParallelPlan_hook = NULL; ParallelQueryMain_hook_type prev_ParallelQueryMain_hook = NULL; +#ifdef USE_LIBXML +static openxml_set_namespaces_hook_type prev_openxml_set_namespaces_hook = NULL; +#endif /***************************************** * Install / Uninstall @@ -491,6 +508,14 @@ InstallExtendedHooks(void) prev_exprTypmod_hook = exprTypmod_hook; exprTypmod_hook = pltsql_exprTypmod; + prev_pre_transform_openxml_columns_hook = pre_transform_openxml_columns_hook; + pre_transform_openxml_columns_hook = pre_transform_openxml_columns; + + #ifdef USE_LIBXML + prev_openxml_set_namespaces_hook = openxml_set_namespaces_hook; + openxml_set_namespaces_hook = openxml_set_namespaces; + #endif + prev_print_pltsql_function_arguments_hook = print_pltsql_function_arguments_hook; print_pltsql_function_arguments_hook = print_pltsql_function_arguments; @@ -663,6 +688,7 @@ UninstallExtendedHooks(void) insert_pltsql_function_defaults_hook = prev_insert_pltsql_function_defaults_hook; replace_pltsql_function_defaults_hook = prev_replace_pltsql_function_defaults_hook; exprTypmod_hook = prev_exprTypmod_hook; + pre_transform_openxml_columns_hook = prev_pre_transform_openxml_columns_hook; print_pltsql_function_arguments_hook = prev_print_pltsql_function_arguments_hook; planner_hook = prev_planner_hook; transform_check_constraint_expr_hook = prev_transform_check_constraint_expr_hook; @@ -697,6 +723,9 @@ UninstallExtendedHooks(void) bbf_check_member_has_direct_priv_to_grant_role_hook = prev_bbf_check_member_has_direct_priv_to_grant_role_hook; validateCachedPlanSearchPath_hook = prev_validateCachedPlanSearchPath_hook; pre_QueryRewrite_hook = prev_pre_QueryRewrite_hook; + #ifdef USE_LIBXML + openxml_set_namespaces_hook = prev_openxml_set_namespaces_hook; + #endif bbf_InitializeParallelDSM_hook = NULL; bbf_ParallelWorkerMain_hook = NULL; @@ -6927,6 +6956,242 @@ pltsql_exprTypmod(Plan *plan, Node *expr) return result_typmod; } +/* + * fetch_table_schema - Extract column metadata from a table for OPENXML processing + * + * This function retrieves column definitions from an existing table and transforms + * them into RangeTableFuncCol nodes with appropriate XPath expressions. It handles + * column name, type information, and creates expressions using tsql_openxml_get_colpattern function. + * + * Parameters: + * relation - The table to extract schema information from + * flag - The OPENXML flag parameter that controls XML mapping behavior + * + * Returns: + * List of RangeTableFuncCol nodes representing the table's columns + */ +static List * +fetch_table_schema(RangeVar *relation, Node *flag) +{ + List *columns = NIL; + + if (relation != NULL) + { + Relation rel; + ScanKeyData skey[1]; + SysScanDesc scan; + HeapTuple tuple; + Relation attrel; + + /* Open the relation to get its schema */ + rel = relation_openrv(relation, AccessShareLock); + + if (rel == NULL) + { + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_TABLE), + errmsg("table \"%s\" does not exist", + relation->relname))); + } + + /* Open pg_attribute catalog */ + attrel = table_open(AttributeRelationId, AccessShareLock); + + /* Set up scan key for this relation */ + ScanKeyInit(&skey[0], + Anum_pg_attribute_attrelid, + BTEqualStrategyNumber, F_OIDEQ, + ObjectIdGetDatum(RelationGetRelid(rel))); + + scan = systable_beginscan(attrel, AttributeRelidNumIndexId, true, + NULL, 1, skey); + + /* Process each column */ + while (HeapTupleIsValid(tuple = systable_getnext(scan))) + { + Form_pg_attribute att = (Form_pg_attribute) GETSTRUCT(tuple); + RangeTableFuncCol *fc; + char *colname; + ArrayType *attoptions; + Datum datum; + bool isnull; + + /* Skip dropped columns, system columns and identity columns */ + if (att->attisdropped || att->attnum <= 0 || att->attidentity) + continue; + + /* Get original column name from attoptions */ + datum = heap_getattr(tuple, Anum_pg_attribute_attoptions, + RelationGetDescr(attrel), &isnull); + + if (!isnull) + { + attoptions = DatumGetArrayTypeP(datum); + colname = get_value_by_name_from_array(attoptions, ATTOPTION_BBF_ORIGINAL_NAME); + } + else + { + colname = pstrdup(NameStr(att->attname)); + } + + /* Create a column definition */ + fc = makeNode(RangeTableFuncCol); + fc->colname = pstrdup(colname); + + /* Create a TypeName node for the column type */ + fc->typeName = makeTypeNameFromOid(att->atttypid, att->atttypmod); + + /* Set the column expression to the generated XPath */ + fc->colexpr = (Node *) makeFuncCall(list_make2(makeString("sys"), makeString("tsql_openxml_get_colpattern")), list_make2(makeStringConst(colname, -1), flag), COERCE_EXPLICIT_CALL, -1); + fc->coldefexpr = NULL; + fc->location = -1; + + columns = lappend(columns, fc); + } + + systable_endscan(scan); + table_close(attrel, AccessShareLock); + relation_close(rel, AccessShareLock); + } + + return columns; +} + +/* + * pre_transform_openxml_columns - Transform OPENXML syntax to XMLTABLE-compatible format + * + * This hook function converts TSQL OPENXML syntax into PostgreSQL XMLTABLE format + * by transforming the RangeTableFunc structure. It extracts the document handle + * and flag from the namespaces list, creates a document expression using + * tsql_openxml_get_xmldoc, and generates appropriate XPath column expressions + * using tsql_openxml_get_colpattern for TSQL compatibility. + */ +static void +pre_transform_openxml_columns(ParseState *pstate, RangeTableFunc *rtf) +{ + Node *tsql_docid_node; + Node *tsql_flag; + RangeVar *table_ref; + ResTarget *res = makeNode(ResTarget); + + if (sql_dialect != SQL_DIALECT_TSQL) + return; + + tsql_docid_node = rtf->docexpr; + tsql_flag = linitial(rtf->namespaces); + + rtf->namespaces = NIL; + rtf->docexpr = NULL; + + /* Storing doc_id in the rtf->namespaces field */ + res->name = pstrdup("openxml_doc_id"); + res->name_location = -1; + res->indirection = NIL; + res->val = tsql_docid_node; + res->location = -1; + rtf->namespaces = list_make1(res); + + /* + * Set the document expression to retrieve the XML document using the document handle. + * This creates a function call to tsql_openxml_get_xmldoc which retrieves the previously + * prepared XML document based on the document ID from sp_xml_preparedocument. + */ + rtf->docexpr = (Node *) makeFuncCall(list_make2(makeString("sys"), makeString("tsql_openxml_get_xmldoc")), list_make1(tsql_docid_node), COERCE_EXPLICIT_CALL, -1); + + if (rtf->columns != NIL) + { + Node *first_col = linitial(rtf->columns); + + /* Check if we have exactly one column and it's a table reference */ + if (list_length(rtf->columns) == 1 && IsA(first_col, RangeVar)) + { + table_ref = (RangeVar *) first_col; + /* Fetch the table schema and generate column definitions with appropriate XPath expressions */ + rtf->columns = fetch_table_schema(table_ref, tsql_flag); + } + else + { + ListCell *lc; + + foreach(lc, rtf->columns) + { + RangeTableFuncCol *fc = (RangeTableFuncCol *) lfirst(lc); + + /* If no column expression is provided, generate one based on the flag */ + if(fc->colexpr == NULL && tsql_flag != NULL) + { + /* + * To get original column name, utilize location of ColumnDef and query string. + * For colexpr, we need orignal name of columns (no downcase or uppercase) + */ + const char *column_name_start = pstate->p_sourcetext + fc->location; + char *original_name = extract_identifier(column_name_start, NULL); + + if (original_name == NULL) + original_name = fc->colname; + /* + * Create an XPath expression for the column using tsql_openxml_get_colpattern. + * This builds a function call to generate the appropriate XPath pattern + * based on the column name and the OPENXML flag parameter + */ + fc->colexpr = (Node *) makeFuncCall(list_make2(makeString("sys"), makeString("tsql_openxml_get_colpattern")), list_make2(makeStringConst(original_name, -1), tsql_flag), COERCE_EXPLICIT_CALL, -1); + } + } + } + } +} + +#ifdef USE_LIBXML +static void +openxml_set_namespaces(xmlXPathContext *xpathctx, PgXmlErrorContext *xmlerrcxt, char *doc_id_str) +{ + int doc_id; + xmltype *ns_data; + char **ns_names; + char **ns_uris; + int ns_count; + + /* + * We will reach here in only two cases, Either when using function XMLTable or OPENXML. + * And since XMLTable syntax is not supported by ANTLR, single dialect check is enough + * to identify that this is for OPENXML. + */ + if (sql_dialect != SQL_DIALECT_TSQL) + return; + + doc_id = pg_strtoint32(doc_id_str); + get_xml_data_and_namespace_data(doc_id, NULL, &ns_data); + if (ns_data == NULL) + return; + + extract_namespaces_from_xml(ns_data, &ns_names, &ns_uris, &ns_count); + + /* register namespaces, if any */ + if (ns_count > 0) + { + for (int i = 0; i < ns_count; i++) + { + char *ns_name; + char *ns_uri; + + if (ns_names[i] == NULL || ns_uris[i] == NULL) + ereport(ERROR, + (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), + errmsg("neither namespace name nor URI may be null"))); + + ns_name = ns_names[i]; + ns_uri = ns_uris[i]; + + if (xmlXPathRegisterNs(xpathctx, + pg_xmlCharStrndup_wrapper(ns_name, strlen(ns_name)), + pg_xmlCharStrndup_wrapper(ns_uri, strlen(ns_uri))) != 0) + xml_ereport(xmlerrcxt, ERROR, ERRCODE_DATA_EXCEPTION, + "could not set XML namespace"); + } + } +} +#endif + /* * pltsql_ExecUpdateResultTypeTL * diff --git a/contrib/babelfishpg_tsql/src/hooks.h b/contrib/babelfishpg_tsql/src/hooks.h index 27368d71fb..fa98f74e80 100644 --- a/contrib/babelfishpg_tsql/src/hooks.h +++ b/contrib/babelfishpg_tsql/src/hooks.h @@ -5,6 +5,7 @@ #include "parser/analyze.h" #include "tcop/cmdtag.h" #include "utils/pg_locale.h" +#include "utils/xml.h" extern IsExtendedCatalogHookType PrevIsExtendedCatalogHook; extern IsToastRelationHookType PrevIsToastRelationHook; @@ -41,5 +42,7 @@ extern char *update_delete_target_alias; extern bool sp_describe_first_result_set_inprogress; extern bool handle_bbf_view_binding_on_object_drop(const ObjectAddress *droppedObject, bool is_alter_view); extern bool check_view_binding_dependencies(Query *viewParse); +extern void get_xml_data_and_namespace_data(int document_id, xmltype **xml_data, xmltype **ns_data); +extern void extract_namespaces_from_xml(xmltype *ns_data, char ***ns_names, char ***ns_uris, int *ns_count); #endif diff --git a/contrib/babelfishpg_tsql/src/procedures.c b/contrib/babelfishpg_tsql/src/procedures.c index 474c5d39c8..b51d08c5ad 100644 --- a/contrib/babelfishpg_tsql/src/procedures.c +++ b/contrib/babelfishpg_tsql/src/procedures.c @@ -50,6 +50,7 @@ #include "tsearch/ts_locale.h" #include "utils/xml.h" #include "common/md5.h" +#include "utils/datum.h" #include "catalog.h" #include "catalog/toasting.h" @@ -84,6 +85,8 @@ PG_FUNCTION_INFO_V1(sp_reset_connection_internal); PG_FUNCTION_INFO_V1(sp_renamedb_internal); PG_FUNCTION_INFO_V1(sp_xml_preparedocument); PG_FUNCTION_INFO_V1(sp_xml_removedocument); +PG_FUNCTION_INFO_V1(tsql_openxml_get_colpattern); +PG_FUNCTION_INFO_V1(tsql_openxml_get_xmldoc); extern void delete_cached_batch(int handle); extern InlineCodeBlockArgs *create_args(int numargs); @@ -129,7 +132,6 @@ int get_next_xml_handle_counter(void); void create_xml_handle_temp_table(void); void delete_xml_handle_entry(int handle); int insert_xml_handle_entry(xmltype *xml_data,xmltype *ns_data, int xml_data_length, int ns_data_length); -void get_xml_data_and_namespace_data(int document_id, xmltype **xml_data, xmltype **ns_data); /* server options and their default values for babelfish_server_options catalog insert */ char * srvOptions_optname[BBF_SERVERS_DEF_NUM_COLS - 1] = {"query timeout", "connect timeout"}; @@ -5030,3 +5032,87 @@ get_xml_data_and_namespace_data(int document_id, xmltype **xml_data, xmltype **n relation_close(relation, AccessShareLock); } +/* + * Function to retrieve XML document using document ID + */ +Datum +tsql_openxml_get_xmldoc(PG_FUNCTION_ARGS) +{ + int32 document_id = PG_GETARG_INT32(0); + xmltype *xmldata = NULL; + + get_xml_data_and_namespace_data(document_id, &xmldata, NULL); + + /* If we found the document, return it */ + if (xmldata) + PG_RETURN_XML_P(xmldata); + + PG_RETURN_NULL(); +} + +/* + * tsql_openxml_get_colpattern - Generate XPath expressions for OPENXML columns + * + * This function generates the appropriate XPath expression for a column based on + * the OPENXML flag value. The flag determines whether to access XML data as + * attributes, elements, or either. + * flag - Controls the XPath pattern generation: + * 0,1: Use attribute access (@colname) + * 2: Use element access (colname) + * 3: Try both element and attribute (colname|@colname) + */ +Datum +tsql_openxml_get_colpattern(PG_FUNCTION_ARGS) +{ + char *xpath_expr; + int flag = PG_GETARG_INT32(1); + char *colname; + + /* Check if colname is NULL or empty */ + if (PG_ARGISNULL(0)) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("Column name cannot be NULL for OPENXML"))); + + colname = text_to_cstring(PG_GETARG_TEXT_PP(0)); + if (strlen(colname) == 0) + { + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("Column name cannot be empty for OPENXML"))); + } + + /* Check for negative flag values */ + if (flag < 0) + { + ereport(ERROR, + (errcode(ERRCODE_SYNTAX_ERROR), + errmsg("Invalid flag value %d for OPENXML", flag))); + } + + /* Normalize the flag value to 0-3 */ + flag = flag % 4; + + switch (flag) + { + case 0: + case 1: + /* For flags 0 and 1, use @colname */ + xpath_expr = psprintf("@%s", colname); + break; + case 2: + /* For flag 2, use colname */ + xpath_expr = pstrdup(colname); + break; + case 3: + /* For flag 3, use colname|@colname */ + xpath_expr = psprintf("%s|@%s", colname, colname); + break; + default: + /* Default to @colname for unknown flags */ + xpath_expr = psprintf("@%s", colname); + break; + } + + PG_RETURN_TEXT_P(cstring_to_text(xpath_expr)); +} \ No newline at end of file diff --git a/contrib/babelfishpg_tsql/src/tsqlIface.cpp b/contrib/babelfishpg_tsql/src/tsqlIface.cpp index f6dead3da9..cb81a75e85 100644 --- a/contrib/babelfishpg_tsql/src/tsqlIface.cpp +++ b/contrib/babelfishpg_tsql/src/tsqlIface.cpp @@ -1300,6 +1300,16 @@ class tsqlCommonMutator : public TSqlParserBaseListener } } + void exitOpen_xml(TSqlParser::Open_xmlContext *ctx) override + { + if(ctx->table_name()) + { + rewritten_query_fragment.emplace(std::make_pair(ctx->table_name()->start->getStartIndex(), + std::make_pair("", "TABLE "))); + + } + } + void exitOpen_query(TSqlParser::Open_queryContext *ctx) override { TSqlParser::IdContext *linked_srv = ctx->linked_server; diff --git a/contrib/babelfishpg_tsql/src/tsqlUnsupportedFeatureHandler.cpp b/contrib/babelfishpg_tsql/src/tsqlUnsupportedFeatureHandler.cpp index 1d4e29ef92..4c292e8827 100644 --- a/contrib/babelfishpg_tsql/src/tsqlUnsupportedFeatureHandler.cpp +++ b/contrib/babelfishpg_tsql/src/tsqlUnsupportedFeatureHandler.cpp @@ -182,7 +182,7 @@ class TsqlUnsupportedFeatureHandlerImpl : public TsqlUnsupportedFeatureHandler antlrcpp::Any visitFunction_call(TSqlParser::Function_callContext *ctx) override; antlrcpp::Any visitAggregate_windowed_function(TSqlParser::Aggregate_windowed_functionContext *ctx) override; antlrcpp::Any visitRowset_function(TSqlParser::Rowset_functionContext *ctx) override { - if (!ctx->open_json() && (!pltsql_enable_linked_servers || !ctx->open_query()) && ctx->open_xml()->WITH()) { + if (!ctx->open_json() && (!pltsql_enable_linked_servers || !ctx->open_query()) && !ctx->open_xml()) { handle(INSTR_UNSUPPORTED_TSQL_ROWSET_FUNCTION, "rowset function", getLineAndPos(ctx)); } return visitChildren(ctx); diff --git a/test/JDBC/expected/openxml_with_clause-before-17_7-vu-cleanup.out b/test/JDBC/expected/openxml_with_clause-before-17_7-vu-cleanup.out new file mode 100644 index 0000000000..e70e4ffb13 --- /dev/null +++ b/test/JDBC/expected/openxml_with_clause-before-17_7-vu-cleanup.out @@ -0,0 +1,37 @@ +DROP TABLE test_openxml_table; +GO + +DROP TABLE test_openxml_table_2; +GO + +DROP TABLE very_long_table_name_that_exceeds_sixty_four_characters_limit_test; +GO + +DROP TABLE test_long_columns; +GO + +DROP TABLE mixed_length_names; +GO + +DROP TABLE employee_defaults; +GO + +DROP TABLE person_table; +GO + +DROP TABLE regions; +GO + +DROP VIEW openxml_column_patterns +GO +~~ERROR (Code: 3701)~~ + +~~ERROR (Message: view "openxml_column_patterns" does not exist)~~ + + +DROP VIEW openxml_documents +GO +~~ERROR (Code: 3701)~~ + +~~ERROR (Message: view "openxml_documents" does not exist)~~ + diff --git a/test/JDBC/expected/openxml_with_clause-before-17_7-vu-prepare.out b/test/JDBC/expected/openxml_with_clause-before-17_7-vu-prepare.out new file mode 100644 index 0000000000..341142e60e --- /dev/null +++ b/test/JDBC/expected/openxml_with_clause-before-17_7-vu-prepare.out @@ -0,0 +1,64 @@ +CREATE TABLE test_openxml_table(oid char(5), date datetime, amount float); +GO + +CREATE TABLE test_openxml_table_2(oid char(5), Date datetime, amount float); +GO + +CREATE TABLE very_long_table_name_that_exceeds_sixty_four_characters_limit_test ( + id INT, + name VARCHAR(50), + value INT +); +GO + +CREATE TABLE test_long_columns ( + very_long_column_name_that_definitely_exceeds_sixty_four_characters_limit_test INT, + another_extremely_long_column_name_exceeding_standard_limits_for_testing VARCHAR(50), + short_col INT +); +GO + +CREATE TABLE mixed_length_names ( + id INT, + extremely_long_column_name_that_exceeds_the_standard_sixty_four_character_limit_for_identifiers VARCHAR(200), + short VARCHAR(50) +); +GO + +CREATE TABLE employee_defaults ( + id INT IDENTITY(1,1) PRIMARY KEY, + name VARCHAR(50) NOT NULL, + department VARCHAR(20) DEFAULT 'Unknown', + salary DECIMAL(10,2) DEFAULT 0.00, + hire_date DATETIME DEFAULT GETDATE(), + status VARCHAR(10) DEFAULT 'Active', + CHECK (salary >= 0) +); +GO + +CREATE TABLE person_table ( + id INT, + name VARCHAR(50), + age INT +); +GO + +CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); +GO + +-- View for col pattern generation and xml doc retrieval +CREATE VIEW openxml_column_patterns AS +SELECT 'id' as column_name, 0 as flag, sys.tsql_openxml_get_colpattern('id', 0) AS xpath_pattern +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: function sys.tsql_openxml_get_colpattern(unknown, integer) does not exist)~~ + + +CREATE VIEW openxml_documents AS +SELECT 1 as document_id, sys.tsql_openxml_get_xmldoc(1) AS xml_document; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: function sys.tsql_openxml_get_xmldoc(integer) does not exist)~~ + diff --git a/test/JDBC/expected/openxml_with_clause-before-17_7-vu-verify.out b/test/JDBC/expected/openxml_with_clause-before-17_7-vu-verify.out new file mode 100644 index 0000000000..4ed69c8efb --- /dev/null +++ b/test/JDBC/expected/openxml_with_clause-before-17_7-vu-verify.out @@ -0,0 +1,1644 @@ + +-- Test plan +-- When Colpattern is given for mapping +DECLARE @docHandle int; +DECLARE @xmlDocument nvarchar(1000); +SET @xmlDocument =N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument; +SELECT * +FROM OPENXML (@docHandle, '/ROOT/Customer/Order/OrderDetail/@ProductID') + WITH ( ProdID int '.', + Qty int '../@Quantity', + OID int '../../@OrderID'); +EXEC sp_xml_removedocument @docHandle; +GO +~~START~~ +int#!#int#!#int +11#!#12#!#10248 +42#!#10#!#10248 +72#!#3#!#10283 +~~END~~ + + + + +-- flag = 0 (default attribute centric) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',0) + WITH (CustomerID varchar(10) , + ContactName varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +VINET#!#Paul Henriot +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- flag = 1 (attribute centric) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',1) + WITH (CustomerID varchar(10) , + ContactName varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +VINET#!#Paul Henriot +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- flag = 2 (element centric) +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + LILAS + Carlos Gonzalez + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 2) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +VINET#!#Paul Henriot +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- flag = 3 (combines both) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + LILAS + Carlos Gonzalez + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',3) + WITH (customerid varchar(10), + contactname varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +VINET#!#Paul Henriot +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- flag = 8 +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer',8) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +#!# +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- default flag is 0 +DECLARE @idoc INT, @doc VARCHAR(1000); +SET @doc = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @idoc OUTPUT, @doc; +SELECT * +FROM OPENXML (@idoc, '/ROOT/Customer') + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @idoc; +GO +~~START~~ +varchar#!#varchar +#!# +LILAS#!#Carlos Gonzalez +~~END~~ + + + + + + +-- If tablename is given +DECLARE @docHandle int; +DECLARE @XmlDocument varchar(1000); +SET @xmlDocument = N' + + + Customer was very + satisfied + + + + Important + + + +'; +EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument; +SELECT * +FROM OPENXML (@docHandle, '/root/Customer/Order', 1) + WITH test_openxml_table; +EXEC sp_xml_removedocument @docHandle; +GO +~~START~~ +char#!#datetime#!#float +O1 #!#1996-01-20 00:00:00.0#!#3.5 +O2 #!#1997-04-30 00:00:00.0#!#13.4 +O3 #!#1999-07-14 00:00:00.0#!#100.0 +O4 #!#1996-01-20 00:00:00.0#!#10000.0 +~~END~~ + + + + +-- If flag value more than 3 +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 4) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +#!# +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 7) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +VINET#!#Paul Henriot +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- rowpattern is case sensitive (this gives null) +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/root/customer', 4) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +~~END~~ + + + + +-- colpattern is case sensitive +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',1) + WITH (customerid varchar(10) , + contactname varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +#!# +#!# +~~END~~ + + + + +-- negative flag value +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', -1) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Invalid flag value -1 for OPENXML)~~ + + + + +-- Mixed attributes +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + The Great Novel + + John + Author + 4.5 + + + Book House + 2023 + 29.99 + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/Library/Book', 2) +WITH ( + ISBN varchar(20), + Category varchar(50), + Title varchar(100) 'Title', + AuthorFirstName varchar(50) 'Author/FirstName', + AuthorLastName varchar(50) 'Author/LastName', + Rating decimal(3,1) 'Author/Rating', + Publisher varchar(50) 'Publication/Publisher', + PublishYear int 'Publication/Year', + Price decimal(10,2) 'Publication/Price', + Currency varchar(3) 'Publication/Price/@currency' +); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#numeric#!#varchar#!#int#!#numeric#!#varchar +#!##!#The Great Novel#!#John#!#Author#!#4.5#!#Book House#!#2023#!#29.99#!#USD +~~END~~ + + + + + + +-- Nested elements +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(2000); +SET @XmlDocument = N' + + + Acme Corp +
123 Business St
+
+ + + Laptop + 2 + 999.99 + 0.10 + + + Mouse + 5 + 24.99 + 0.05 + + +
+
'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/Invoices/Invoice', 2) +WITH ( + InvoiceID varchar(10), + InvoiceDate date '@Date', + CustomerID varchar(10) 'Customer/@ID', + CustomerName varchar(50) 'Customer/Name', + CustomerAddress varchar(100) 'Customer/Address' +); +SELECT * +FROM OPENXML (@DocHandle, '/Invoices/Invoice/Items/Item', 2) +WITH ( + InvoiceID varchar(10) '../../../@InvoiceID', + SKU varchar(10) '@SKU', + Description varchar(100) 'Description', + Quantity int 'Quantity', + UnitPrice decimal(10,2) 'UnitPrice', + Discount decimal(4,2) 'Discount' +); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#date#!#varchar#!#varchar#!#varchar +#!#2024-01-15#!#CUST001#!#Acme Corp#!#123 Business St +~~END~~ + +~~START~~ +varchar#!#varchar#!#varchar#!#int#!#numeric#!#numeric +#!#SKU001#!#Laptop#!#2#!#999.99#!#0.10 +#!#SKU002#!#Mouse#!#5#!#24.99#!#0.05 +~~END~~ + + + + + + + + + +-- Basic example which gives customer, order, product details +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer', 1) +WITH ( + CustomerID varchar(10), + ContactName varchar(50) +); +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer/Order', 1) +WITH ( + OrderID int, + OrderDate date, + CustomerID varchar(10) '../@CustomerID' +); +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer/Order/Product', 1) +WITH ( + OrderID int '../@OrderID', + ProductID varchar(10), + Quantity int, + Price decimal(10,2) +); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +C001#!#John Doe +C002#!#Jane Smith +~~END~~ + +~~START~~ +int#!#date#!#varchar +1001#!#2024-01-15#!#C001 +1002#!#2024-01-16#!#C002 +~~END~~ + +~~START~~ +int#!#varchar#!#int#!#numeric +1001#!#P1#!#5#!#100.00 +1001#!#P2#!#3#!#200.00 +1002#!#P3#!#2#!#150.00 +~~END~~ + + + + + + +-- When table name or colname > 64 bytes +-- Test Case 1: Long table name (> 64 bytes) +INSERT INTO very_long_table_name_that_exceeds_sixty_four_characters_limit_test +VALUES (1, 'Test', 100); +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, +''; +SELECT * FROM +OPENXML(@xml_doc, '/root/item') +WITH very_long_table_name_that_exceeds_sixty_four_characters_limit_test; +EXEC sp_xml_removedocument @xml_doc; +GO +~~ROW COUNT: 1~~ + +~~START~~ +int#!#varchar#!#int +1#!#John#!#200 +~~END~~ + + + + + + +-- Test Case 2: Long column names (> 64 bytes) +INSERT INTO test_long_columns VALUES (1, 'Test Value', 999); +DECLARE @xml_doc2 INT; +EXEC sp_xml_preparedocument @xml_doc2 OUTPUT, +' + +'; +SELECT * FROM +OPENXML(@xml_doc2, '/data/record') +WITH test_long_columns; +EXEC sp_xml_removedocument @xml_doc2; +GO +~~ROW COUNT: 1~~ + +~~START~~ +int#!#varchar#!#int +123#!#Long Value#!#456 +~~END~~ + + + + +-- Test Case 3: Explicit column definitions with long names +DECLARE @xml_doc3 INT; +EXEC sp_xml_preparedocument @xml_doc3 OUTPUT, +' + +'; +SELECT * FROM +OPENXML(@xml_doc3, '/items/item') WITH ( + very_long_column_name_that_definitely_exceeds_sixty_four_characters_limit_one VARCHAR(100), + another_extremely_long_column_name_that_exceeds_standard_database_limits_two VARCHAR(100) +); +EXEC sp_xml_removedocument @xml_doc3; +GO +~~START~~ +varchar#!#varchar +#!# +~~END~~ + + + + +-- Test Case 4: Mixed long and short names +DECLARE @xml_doc4 INT; +EXEC sp_xml_preparedocument @xml_doc4 OUTPUT, +' + +'; +SELECT * FROM +OPENXML(@xml_doc4, '/test/row') +WITH mixed_length_names; +EXEC sp_xml_removedocument @xml_doc4; +GO +~~START~~ +int#!#varchar#!#varchar +1#!#Long Value Test#!#Short +~~END~~ + + + + + +-- Openxml with table having default constraints +INSERT INTO employee_defaults (name, department, salary) +VALUES ('Test Employee', 'IT', 50000); +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, +' + + + +'; +SELECT * FROM +OPENXML(@xml_doc, '/employees/emp') WITH employee_defaults; +EXEC sp_xml_removedocument @xml_doc; +GO +~~ROW COUNT: 1~~ + +~~START~~ +varchar#!#varchar#!#numeric#!#datetime#!#varchar +John Smith#!#HR#!##!##!# +Jane Doe#!##!#75000.00#!##!# +Bob Wilson#!##!##!##!# +~~END~~ + + +-- Test with empty XML document +DECLARE @DocHandle int; +EXEC sp_xml_preparedocument @DocHandle OUTPUT; +SELECT * +FROM OPENXML (@DocHandle, '/', 1) +WITH ( + CustomerID varchar(10), + ContactName varchar(50) +); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +~~END~~ + + + + + +-- CROSS APPLY with openxml +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +int#!#varchar#!#int#!#date +1#!#John#!#1#!# +1#!#John#!#2#!# +2#!#Jane#!#1#!# +2#!#Jane#!#2#!# +~~END~~ + + + + + +-- cross apply for different row patterns +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, + concat('/Customers/Customer[@ID=', c.CustomerID, ']/Order'), + 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +int#!#varchar#!#int#!#date +1#!#John#!#1#!#2024-01-01 +1#!#John#!#2#!#2024-01-02 +2#!#Jane#!#3#!#2024-01-03 +~~END~~ + + +-- cross apply for different row patterns +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N''; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, + concat('/Customers/Customer[@ID=', c.CustomerID, ']/Order'), + 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +int#!#varchar#!#int#!#date +~~END~~ + + + + + +-- Basic CROSS APPLY with OPENXML using table reference +INSERT INTO person_table VALUES (1, 'John', 25), (2, 'Jane', 30); +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, ''; +SELECT * FROM +(SELECT 1 as id) t +CROSS APPLY OPENXML(@xml_doc, '/root/person') WITH person_table; +EXEC sp_xml_removedocument @xml_doc; +GO +~~ROW COUNT: 2~~ + +~~START~~ +int#!#int#!#varchar#!#int +1#!#1#!#John#!# +1#!#2#!#Jane#!# +~~END~~ + + + + +-- OUTER APPLY +DECLARE @xml_doc2 INT; +EXEC sp_xml_preparedocument @xml_doc2 OUTPUT, +' + + + + + +'; +SELECT + c.customer_id, + c.customer_name, + o.order_id, + o.amount +FROM + OPENXML(@xml_doc2, '/data/customer', 1) WITH ( + customer_id INT, + customer_name VARCHAR(50) + ) c +OUTER APPLY + OPENXML(@xml_doc2, '/data/order', 1) WITH ( + cust_id INT, + order_id INT, + amount DECIMAL(10,2) + ) o; +EXEC sp_xml_removedocument @xml_doc2; +GO +~~START~~ +int#!#varchar#!#int#!#numeric +#!##!#100#!#500.00 +#!##!#101#!#300.00 +#!##!#102#!#200.00 +#!##!#100#!#500.00 +#!##!#101#!#300.00 +#!##!#102#!#200.00 +~~END~~ + + + + + +-- Base table with outer apply openxml +INSERT INTO regions VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); +DECLARE @xml_doc3 INT; +EXEC sp_xml_preparedocument @xml_doc3 OUTPUT, +' + + + + + + + +'; +SELECT + r.region_id, + r.region_name, + s.amount, + s.product +FROM + regions r +OUTER APPLY + OPENXML(@xml_doc3, '/sales/region/sale', 2) WITH ( + region_id INT '../@id', + amount DECIMAL(10,2), + product VARCHAR(50) + ) s +WHERE s.region_id = r.region_id OR s.region_id IS NULL; +EXEC sp_xml_removedocument @xml_doc3; +GO +~~ROW COUNT: 4~~ + +~~START~~ +int#!#varchar#!#numeric#!#varchar +1#!#North#!##!# +1#!#North#!##!# +3#!#East#!##!# +~~END~~ + + +-- With namespaces +--test1 +DECLARE @xml nvarchar(1000) = +' + value1 + value2 +'; +DECLARE @namespace nvarchar(100) = ''; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/ns1:child', 3) WITH (child nvarchar(10) '.'); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +nvarchar +value1 +~~END~~ + + + +DECLARE @h int; +EXEC sp_xml_preparedocument @h OUTPUT, + N' + + TaU + + ', + ''; +SELECT * FROM openxml(@h, '/root/b:Elem', 3) + WITH (Col1 varchar(20) '.'); +EXEC sp_xml_removedocument @h; +GO +~~START~~ +varchar + TaU +~~END~~ + + + + + + +-- test2 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/hr:employee', 2) +WITH ( + name nvarchar(50) 'hr:name', + salary int 'fin:salary', + currency nvarchar(10) 'fin:salary/@currency' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +nvarchar#!#int#!#nvarchar +John Doe#!#50000#!#USD +Jane Smith#!#60000#!#USD +~~END~~ + + + + + + +--test3 +DECLARE @xml nvarchar(2000) = ' + + + + Laptop + 999.99 + + + Smartphone + 599.99 + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/catalog/cat:category/prod:product', 2) +WITH ( + category_name nvarchar(50) '../../@name', + product_name nvarchar(50) 'prod:name', + price decimal(10,2) 'prod:price' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +nvarchar#!#nvarchar#!#numeric +#!#Laptop#!#999.99 +#!#Smartphone#!#599.99 +~~END~~ + + + + + + +--test4 +DECLARE @xml nvarchar(2000) = ' + + + + Alice Johnson + alice@email.com + + + Widget A + Widget B + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/orders/ord:order/prod:items/prod:item', 2) +WITH ( + order_id int '../../../@id', + customer_name nvarchar(50) '../../../cust:customer/cust:name', + item_name nvarchar(50) '.', + quantity int '@qty' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +int#!#nvarchar#!#nvarchar#!#int +#!##!#Widget A#!#2 +#!##!#Widget B#!#1 +~~END~~ + + + + + + +--test5 +DECLARE @xml nvarchar(2000) = ' + + + New York + + 20 + 65 + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/weather/loc:city', 2) +WITH ( + city_id varchar(10) '@id', + city_name varchar(50) 'loc:name', + temperature int 'met:conditions/met:temperature', + temp_unit varchar(1) 'met:conditions/met:temperature/@unit', + humidity int 'met:conditions/met:humidity', + reading_date date 'met:conditions/@date' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#varchar#!#int#!#varchar#!#int#!#date +NYC#!#New York#!#20#!#C#!#65#!#2023-01-01 +~~END~~ + + + + + + +--test6 +DECLARE @xml nvarchar(2000) = ' + + + + John Smith + 45 + + + Dr. Brown + Cardiology + + + Hypertension + Lisinopril + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/medical/pat:record', 2) +WITH ( + record_id int '@id', + patient_name nvarchar(50) 'pat:info/pat:name', + patient_age int 'pat:info/pat:age', + doctor_name nvarchar(50) 'doc:physician/doc:name', + specialty nvarchar(50) 'doc:physician/doc:specialty', + diagnosis nvarchar(100) 'treat:treatment/treat:diagnosis', + medication nvarchar(100) 'treat:treatment/treat:medication' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +int#!#nvarchar#!#int#!#nvarchar#!#nvarchar#!#nvarchar#!#nvarchar +12345#!#John Smith#!#45#!#Dr. Brown#!#Cardiology#!#Hypertension#!#Lisinopril +~~END~~ + + + + + + + +--test7 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 1) +WITH ( + id int, + department varchar(20), + name varchar(50), + salary int +); +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 2) +WITH ( + id int, + department varchar(20), + name varchar(50), + salary int +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +int#!#varchar#!#varchar#!#int +1#!#IT#!##!# +2#!#HR#!##!# +~~END~~ + +~~START~~ +int#!#varchar#!#varchar#!#int +#!##!##!# +#!##!##!# +~~END~~ + + + + + + +--test8 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 3) +WITH ( + id int '@id', + department varchar(20) '@department', + name varchar(50) 'hr:name', + salary int 'hr:salary' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +int#!#varchar#!#varchar#!#int +1#!#IT#!#John Doe#!#50000 +2#!#HR#!#Jane Smith#!#60000 +~~END~~ + + + + + + +--test9 +DECLARE @xml nvarchar(2000) = ' + + + + + + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/cust:Customer', 1) +WITH ( + customerid varchar(10), + contactname varchar(50), + country varchar(20) +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#varchar#!#varchar +VINET#!#Paul Henriot#!#France +LILAS#!#Carlos Gonzalez#!#Spain +~~END~~ + + + + + + +--test10 +DECLARE @xml nvarchar(2000) = ' + + + 1001 + John + Doe + IT + + + 1002 + Jane + Smith + HR + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/emp:Employee', 2) +WITH ( + EmployeeId varchar(10), + FirstName varchar(50), + LastName varchar(50), + Department varchar(20) +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#varchar +#!##!##!# +#!##!##!# +~~END~~ + + + + + + +--test11 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 100.00 + + + Jane Smith + 200.00 + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/ord:Order', 3) +WITH ( + id varchar(10), + date datetime, + CustomerName varchar(50), + Total decimal(10,2) +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#datetime#!#varchar#!#numeric +1001#!#2023-01-01 00:00:00.0#!##!# +1002#!#2023-01-02 00:00:00.0#!##!# +~~END~~ + + + + + + +--test12 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + + 123 Main St + New York + + + + Jane Smith + + 456 Oak Ave + Los Angeles + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/cust:Customer', 3) +WITH ( + id varchar(10), + Name varchar(50), + Street varchar(100), + City varchar(50) +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#varchar +C001#!##!##!# +C002#!##!##!# +~~END~~ + + + + + + +--test13 +DECLARE @xml nvarchar(2000) = ' + + + + 1000.00 + 100.00 + 1100.00 + + + + + 2000.00 + 200.00 + 2200.00 + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/inv:Invoice', 3) +WITH ( + number varchar(10), + type varchar(20), + Amount decimal(10,2), + Tax decimal(10,2), + Total decimal(10,2) +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#varchar#!#numeric#!#numeric#!#numeric +INV001#!#Standard#!##!##!# +INV002#!#Express#!##!##!# +~~END~~ + + +-- Tests for tsql_openxml_get_colpattern and tsql_openxml_get_xmldoc +-- Test basic flag patterns +SELECT sys.tsql_openxml_get_colpattern('name', 0); +GO +~~START~~ +nvarchar +@name +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('name', 1); +GO +~~START~~ +nvarchar +@name +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('name', 2); +GO +~~START~~ +nvarchar +name +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('name', 3); +GO +~~START~~ +nvarchar +name|@name +~~END~~ + + +-- Test flag normalization (mod 4) +SELECT sys.tsql_openxml_get_colpattern('id', 4) +GO +~~START~~ +nvarchar +@id +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('id', 5); +GO +~~START~~ +nvarchar +@id +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('id', 6); +GO +~~START~~ +nvarchar +id +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('id', 7); +GO +~~START~~ +nvarchar +id|@id +~~END~~ + + +-- Test error and null cases +SELECT sys.tsql_openxml_get_colpattern(NULL, 1); +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('', 1); +GO +~~START~~ +nvarchar +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Column name cannot be empty for OPENXML)~~ + + +SELECT sys.tsql_openxml_get_colpattern('name', -1); +GO +~~START~~ +nvarchar +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Invalid flag value -1 for OPENXML)~~ + + +-- Test with valid document handle +DECLARE @doc_handle INT; +EXEC sp_xml_preparedocument @doc_handle OUTPUT, 'test'; +SELECT sys.tsql_openxml_get_xmldoc(@doc_handle); +EXEC sp_xml_removedocument @doc_handle; +GO +~~START~~ +xml +test +~~END~~ + + +-- Test with invalid or NULL handle +SELECT sys.tsql_openxml_get_xmldoc(999); +GO +~~START~~ +xml +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Could not find prepared statement with handle 999.)~~ + +SELECT sys.tsql_openxml_get_xmldoc(NULL); +GO +~~START~~ +xml + +~~END~~ + + +-- Tests for views for col pattern and xml doc generation +SELECT * FROM openxml_column_patterns WHERE flag = 3; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: relation "openxml_column_patterns" does not exist)~~ + + +SELECT document_id FROM openxml_documents; +GO +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: relation "openxml_documents" does not exist)~~ + diff --git a/test/JDBC/expected/openxml_with_clause-vu-cleanup.out b/test/JDBC/expected/openxml_with_clause-vu-cleanup.out new file mode 100644 index 0000000000..fd22e1cb4c --- /dev/null +++ b/test/JDBC/expected/openxml_with_clause-vu-cleanup.out @@ -0,0 +1,29 @@ +DROP TABLE test_openxml_table; +GO + +DROP TABLE test_openxml_table_2; +GO + +DROP TABLE very_long_table_name_that_exceeds_sixty_four_characters_limit_test; +GO + +DROP TABLE test_long_columns; +GO + +DROP TABLE mixed_length_names; +GO + +DROP TABLE employee_defaults; +GO + +DROP TABLE person_table; +GO + +DROP TABLE regions; +GO + +DROP VIEW openxml_column_patterns +GO + +DROP VIEW openxml_documents +GO diff --git a/test/JDBC/expected/openxml_with_clause-vu-prepare.out b/test/JDBC/expected/openxml_with_clause-vu-prepare.out new file mode 100644 index 0000000000..314a7add80 --- /dev/null +++ b/test/JDBC/expected/openxml_with_clause-vu-prepare.out @@ -0,0 +1,56 @@ +CREATE TABLE test_openxml_table(oid char(5), date datetime, amount float); +GO + +CREATE TABLE test_openxml_table_2(oid char(5), Date datetime, amount float); +GO + +CREATE TABLE very_long_table_name_that_exceeds_sixty_four_characters_limit_test ( + id INT, + name VARCHAR(50), + value INT +); +GO + +CREATE TABLE test_long_columns ( + very_long_column_name_that_definitely_exceeds_sixty_four_characters_limit_test INT, + another_extremely_long_column_name_exceeding_standard_limits_for_testing VARCHAR(50), + short_col INT +); +GO + +CREATE TABLE mixed_length_names ( + id INT, + extremely_long_column_name_that_exceeds_the_standard_sixty_four_character_limit_for_identifiers VARCHAR(200), + short VARCHAR(50) +); +GO + +CREATE TABLE employee_defaults ( + id INT IDENTITY(1,1) PRIMARY KEY, + name VARCHAR(50) NOT NULL, + department VARCHAR(20) DEFAULT 'Unknown', + salary DECIMAL(10,2) DEFAULT 0.00, + hire_date DATETIME DEFAULT GETDATE(), + status VARCHAR(10) DEFAULT 'Active', + CHECK (salary >= 0) +); +GO + +CREATE TABLE person_table ( + id INT, + name VARCHAR(50), + age INT +); +GO + +CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); +GO + +-- View for col pattern generation and xml doc retrieval +CREATE VIEW openxml_column_patterns AS +SELECT 'id' as column_name, 0 as flag, sys.tsql_openxml_get_colpattern('id', 0) AS xpath_pattern +GO + +CREATE VIEW openxml_documents AS +SELECT 1 as document_id, sys.tsql_openxml_get_xmldoc(1) AS xml_document; +GO diff --git a/test/JDBC/expected/openxml_with_clause-vu-verify.out b/test/JDBC/expected/openxml_with_clause-vu-verify.out new file mode 100644 index 0000000000..a48e0a4c6d --- /dev/null +++ b/test/JDBC/expected/openxml_with_clause-vu-verify.out @@ -0,0 +1,1646 @@ + +-- Test plan +-- When Colpattern is given for mapping +DECLARE @docHandle int; +DECLARE @xmlDocument nvarchar(1000); +SET @xmlDocument =N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument; +SELECT * +FROM OPENXML (@docHandle, '/ROOT/Customer/Order/OrderDetail/@ProductID') + WITH ( ProdID int '.', + Qty int '../@Quantity', + OID int '../../@OrderID'); +EXEC sp_xml_removedocument @docHandle; +GO +~~START~~ +int#!#int#!#int +11#!#12#!#10248 +42#!#10#!#10248 +72#!#3#!#10283 +~~END~~ + + + + +-- flag = 0 (default attribute centric) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',0) + WITH (CustomerID varchar(10) , + ContactName varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +VINET#!#Paul Henriot +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- flag = 1 (attribute centric) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',1) + WITH (CustomerID varchar(10) , + ContactName varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +VINET#!#Paul Henriot +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- flag = 2 (element centric) +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + LILAS + Carlos Gonzalez + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 2) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +VINET#!#Paul Henriot +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- flag = 3 (combines both) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + LILAS + Carlos Gonzalez + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',3) + WITH (customerid varchar(10), + contactname varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +VINET#!#Paul Henriot +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- flag = 8 +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer',8) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +#!# +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- default flag is 0 +DECLARE @idoc INT, @doc VARCHAR(1000); +SET @doc = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @idoc OUTPUT, @doc; +SELECT * +FROM OPENXML (@idoc, '/ROOT/Customer') + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @idoc; +GO +~~START~~ +varchar#!#varchar +#!# +LILAS#!#Carlos Gonzalez +~~END~~ + + + + + + +-- If tablename is given +DECLARE @docHandle int; +DECLARE @XmlDocument varchar(1000); +SET @xmlDocument = N' + + + Customer was very + satisfied + + + + Important + + + +'; +EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument; +SELECT * +FROM OPENXML (@docHandle, '/root/Customer/Order', 1) + WITH test_openxml_table; +EXEC sp_xml_removedocument @docHandle; +GO +~~START~~ +char#!#datetime#!#float +O1 #!#1996-01-20 00:00:00.0#!#3.5 +O2 #!#1997-04-30 00:00:00.0#!#13.4 +O3 #!#1999-07-14 00:00:00.0#!#100.0 +O4 #!#1996-01-20 00:00:00.0#!#10000.0 +~~END~~ + + + + +-- If flag value more than 3 +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 4) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +#!# +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 7) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +VINET#!#Paul Henriot +LILAS#!#Carlos Gonzalez +~~END~~ + + + + +-- rowpattern is case sensitive (this gives null) +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/root/customer', 4) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +~~END~~ + + + + +-- colpattern is case sensitive +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',1) + WITH (customerid varchar(10) , + contactname varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +#!# +#!# +~~END~~ + + + + +-- negative flag value +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', -1) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO +~~START~~ +varchar#!#varchar +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Invalid flag value -1 for OPENXML)~~ + + + + +-- Mixed attributes +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + The Great Novel + + John + Author + 4.5 + + + Book House + 2023 + 29.99 + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/Library/Book', 2) +WITH ( + ISBN varchar(20), + Category varchar(50), + Title varchar(100) 'Title', + AuthorFirstName varchar(50) 'Author/FirstName', + AuthorLastName varchar(50) 'Author/LastName', + Rating decimal(3,1) 'Author/Rating', + Publisher varchar(50) 'Publication/Publisher', + PublishYear int 'Publication/Year', + Price decimal(10,2) 'Publication/Price', + Currency varchar(3) 'Publication/Price/@currency' +); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#varchar#!#varchar#!#numeric#!#varchar#!#int#!#numeric#!#varchar +#!##!#The Great Novel#!#John#!#Author#!#4.5#!#Book House#!#2023#!#29.99#!#USD +~~END~~ + + + + + + +-- Nested elements +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(2000); +SET @XmlDocument = N' + + + Acme Corp +
123 Business St
+
+ + + Laptop + 2 + 999.99 + 0.10 + + + Mouse + 5 + 24.99 + 0.05 + + +
+
'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/Invoices/Invoice', 2) +WITH ( + InvoiceID varchar(10), + InvoiceDate date '@Date', + CustomerID varchar(10) 'Customer/@ID', + CustomerName varchar(50) 'Customer/Name', + CustomerAddress varchar(100) 'Customer/Address' +); +SELECT * +FROM OPENXML (@DocHandle, '/Invoices/Invoice/Items/Item', 2) +WITH ( + InvoiceID varchar(10) '../../../@InvoiceID', + SKU varchar(10) '@SKU', + Description varchar(100) 'Description', + Quantity int 'Quantity', + UnitPrice decimal(10,2) 'UnitPrice', + Discount decimal(4,2) 'Discount' +); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#date#!#varchar#!#varchar#!#varchar +#!#2024-01-15#!#CUST001#!#Acme Corp#!#123 Business St +~~END~~ + +~~START~~ +varchar#!#varchar#!#varchar#!#int#!#numeric#!#numeric +#!#SKU001#!#Laptop#!#2#!#999.99#!#0.10 +#!#SKU002#!#Mouse#!#5#!#24.99#!#0.05 +~~END~~ + + + + + + + + + +-- Basic example which gives customer, order, product details +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer', 1) +WITH ( + CustomerID varchar(10), + ContactName varchar(50) +); +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer/Order', 1) +WITH ( + OrderID int, + OrderDate date, + CustomerID varchar(10) '../@CustomerID' +); +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer/Order/Product', 1) +WITH ( + OrderID int '../@OrderID', + ProductID varchar(10), + Quantity int, + Price decimal(10,2) +); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +C001#!#John Doe +C002#!#Jane Smith +~~END~~ + +~~START~~ +int#!#date#!#varchar +1001#!#2024-01-15#!#C001 +1002#!#2024-01-16#!#C002 +~~END~~ + +~~START~~ +int#!#varchar#!#int#!#numeric +1001#!#P1#!#5#!#100.00 +1001#!#P2#!#3#!#200.00 +1002#!#P3#!#2#!#150.00 +~~END~~ + + + + + + +-- When table name or colname > 64 bytes +-- Test Case 1: Long table name (> 64 bytes) +INSERT INTO very_long_table_name_that_exceeds_sixty_four_characters_limit_test +VALUES (1, 'Test', 100); +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, +''; +SELECT * FROM +OPENXML(@xml_doc, '/root/item') +WITH very_long_table_name_that_exceeds_sixty_four_characters_limit_test; +EXEC sp_xml_removedocument @xml_doc; +GO +~~ROW COUNT: 1~~ + +~~START~~ +int#!#varchar#!#int +1#!#John#!#200 +~~END~~ + + + + + + +-- Test Case 2: Long column names (> 64 bytes) +INSERT INTO test_long_columns VALUES (1, 'Test Value', 999); +DECLARE @xml_doc2 INT; +EXEC sp_xml_preparedocument @xml_doc2 OUTPUT, +' + +'; +SELECT * FROM +OPENXML(@xml_doc2, '/data/record') +WITH test_long_columns; +EXEC sp_xml_removedocument @xml_doc2; +GO +~~ROW COUNT: 1~~ + +~~START~~ +int#!#varchar#!#int +123#!#Long Value#!#456 +~~END~~ + + + + +-- Test Case 3: Explicit column definitions with long names +DECLARE @xml_doc3 INT; +EXEC sp_xml_preparedocument @xml_doc3 OUTPUT, +' + +'; +SELECT * FROM +OPENXML(@xml_doc3, '/items/item') WITH ( + very_long_column_name_that_definitely_exceeds_sixty_four_characters_limit_one VARCHAR(100), + another_extremely_long_column_name_that_exceeds_standard_database_limits_two VARCHAR(100) +); +EXEC sp_xml_removedocument @xml_doc3; +GO +~~START~~ +varchar#!#varchar +#!# +~~END~~ + + + + +-- Test Case 4: Mixed long and short names +DECLARE @xml_doc4 INT; +EXEC sp_xml_preparedocument @xml_doc4 OUTPUT, +' + +'; +SELECT * FROM +OPENXML(@xml_doc4, '/test/row') +WITH mixed_length_names; +EXEC sp_xml_removedocument @xml_doc4; +GO +~~START~~ +int#!#varchar#!#varchar +1#!#Long Value Test#!#Short +~~END~~ + + + + + +-- Openxml with table having default constraints +INSERT INTO employee_defaults (name, department, salary) +VALUES ('Test Employee', 'IT', 50000); +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, +' + + + +'; +SELECT * FROM +OPENXML(@xml_doc, '/employees/emp') WITH employee_defaults; +EXEC sp_xml_removedocument @xml_doc; +GO +~~ROW COUNT: 1~~ + +~~START~~ +varchar#!#varchar#!#numeric#!#datetime#!#varchar +John Smith#!#HR#!##!##!# +Jane Doe#!##!#75000.00#!##!# +Bob Wilson#!##!##!##!# +~~END~~ + + +-- Test with empty XML document +DECLARE @DocHandle int; +EXEC sp_xml_preparedocument @DocHandle OUTPUT; +SELECT * +FROM OPENXML (@DocHandle, '/', 1) +WITH ( + CustomerID varchar(10), + ContactName varchar(50) +); +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +varchar#!#varchar +~~END~~ + + + + + +-- CROSS APPLY with openxml +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +int#!#varchar#!#int#!#date +1#!#John#!#1#!# +1#!#John#!#2#!# +2#!#Jane#!#1#!# +2#!#Jane#!#2#!# +~~END~~ + + + + + +-- cross apply for different row patterns +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + +'; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, + concat('/Customers/Customer[@ID=', c.CustomerID, ']/Order'), + 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +int#!#varchar#!#int#!#date +1#!#John#!#1#!#2024-01-01 +1#!#John#!#2#!#2024-01-02 +2#!#Jane#!#3#!#2024-01-03 +~~END~~ + + +-- cross apply for different row patterns +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N''; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, + concat('/Customers/Customer[@ID=', c.CustomerID, ']/Order'), + 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; +EXEC sp_xml_removedocument @DocHandle; +GO +~~START~~ +int#!#varchar#!#int#!#date +~~END~~ + + + + + +-- Basic CROSS APPLY with OPENXML using table reference +INSERT INTO person_table VALUES (1, 'John', 25), (2, 'Jane', 30); +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, ''; +SELECT * FROM +(SELECT 1 as id) t +CROSS APPLY OPENXML(@xml_doc, '/root/person') WITH person_table; +EXEC sp_xml_removedocument @xml_doc; +GO +~~ROW COUNT: 2~~ + +~~START~~ +int#!#int#!#varchar#!#int +1#!#1#!#John#!# +1#!#2#!#Jane#!# +~~END~~ + + + + +-- OUTER APPLY +DECLARE @xml_doc2 INT; +EXEC sp_xml_preparedocument @xml_doc2 OUTPUT, +' + + + + + +'; +SELECT + c.customer_id, + c.customer_name, + o.order_id, + o.amount +FROM + OPENXML(@xml_doc2, '/data/customer', 1) WITH ( + customer_id INT, + customer_name VARCHAR(50) + ) c +OUTER APPLY + OPENXML(@xml_doc2, '/data/order', 1) WITH ( + cust_id INT, + order_id INT, + amount DECIMAL(10,2) + ) o; +EXEC sp_xml_removedocument @xml_doc2; +GO +~~START~~ +int#!#varchar#!#int#!#numeric +#!##!#100#!#500.00 +#!##!#101#!#300.00 +#!##!#102#!#200.00 +#!##!#100#!#500.00 +#!##!#101#!#300.00 +#!##!#102#!#200.00 +~~END~~ + + + + + +-- Base table with outer apply openxml +INSERT INTO regions VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); +DECLARE @xml_doc3 INT; +EXEC sp_xml_preparedocument @xml_doc3 OUTPUT, +' + + + + + + + +'; +SELECT + r.region_id, + r.region_name, + s.amount, + s.product +FROM + regions r +OUTER APPLY + OPENXML(@xml_doc3, '/sales/region/sale', 2) WITH ( + region_id INT '../@id', + amount DECIMAL(10,2), + product VARCHAR(50) + ) s +WHERE s.region_id = r.region_id OR s.region_id IS NULL; +EXEC sp_xml_removedocument @xml_doc3; +GO +~~ROW COUNT: 4~~ + +~~START~~ +int#!#varchar#!#numeric#!#varchar +1#!#North#!##!# +1#!#North#!##!# +3#!#East#!##!# +~~END~~ + + +-- With namespaces +--test1 +DECLARE @xml nvarchar(1000) = +' + value1 + value2 +'; +DECLARE @namespace nvarchar(100) = ''; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/ns1:child', 3) WITH (child nvarchar(10) '.'); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +nvarchar +value1 +~~END~~ + + + +DECLARE @h int; +EXEC sp_xml_preparedocument @h OUTPUT, + N' + + TaU + + ', + ''; +SELECT * FROM openxml(@h, '/root/b:Elem', 3) + WITH (Col1 varchar(20) '.'); +EXEC sp_xml_removedocument @h; +GO +~~START~~ +varchar + TaU +~~END~~ + + + + + + +-- test2 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/hr:employee', 2) +WITH ( + name nvarchar(50) 'hr:name', + salary int 'fin:salary', + currency nvarchar(10) 'fin:salary/@currency' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +nvarchar#!#int#!#nvarchar +John Doe#!#50000#!#USD +Jane Smith#!#60000#!#USD +~~END~~ + + + + + + +--test3 +DECLARE @xml nvarchar(2000) = ' + + + + Laptop + 999.99 + + + Smartphone + 599.99 + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/catalog/cat:category/prod:product', 2) +WITH ( + category_name nvarchar(50) '../../@name', + product_name nvarchar(50) 'prod:name', + price decimal(10,2) 'prod:price' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +nvarchar#!#nvarchar#!#numeric +#!#Laptop#!#999.99 +#!#Smartphone#!#599.99 +~~END~~ + + + + + + +--test4 +DECLARE @xml nvarchar(2000) = ' + + + + Alice Johnson + alice@email.com + + + Widget A + Widget B + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/orders/ord:order/prod:items/prod:item', 2) +WITH ( + order_id int '../../../@id', + customer_name nvarchar(50) '../../../cust:customer/cust:name', + item_name nvarchar(50) '.', + quantity int '@qty' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +int#!#nvarchar#!#nvarchar#!#int +#!##!#Widget A#!#2 +#!##!#Widget B#!#1 +~~END~~ + + + + + + +--test5 +DECLARE @xml nvarchar(2000) = ' + + + New York + + 20 + 65 + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/weather/loc:city', 2) +WITH ( + city_id varchar(10) '@id', + city_name varchar(50) 'loc:name', + temperature int 'met:conditions/met:temperature', + temp_unit varchar(1) 'met:conditions/met:temperature/@unit', + humidity int 'met:conditions/met:humidity', + reading_date date 'met:conditions/@date' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#varchar#!#int#!#varchar#!#int#!#date +NYC#!#New York#!#20#!#C#!#65#!#2023-01-01 +~~END~~ + + + + + + +--test6 +DECLARE @xml nvarchar(2000) = ' + + + + John Smith + 45 + + + Dr. Brown + Cardiology + + + Hypertension + Lisinopril + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/medical/pat:record', 2) +WITH ( + record_id int '@id', + patient_name nvarchar(50) 'pat:info/pat:name', + patient_age int 'pat:info/pat:age', + doctor_name nvarchar(50) 'doc:physician/doc:name', + specialty nvarchar(50) 'doc:physician/doc:specialty', + diagnosis nvarchar(100) 'treat:treatment/treat:diagnosis', + medication nvarchar(100) 'treat:treatment/treat:medication' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +int#!#nvarchar#!#int#!#nvarchar#!#nvarchar#!#nvarchar#!#nvarchar +12345#!#John Smith#!#45#!#Dr. Brown#!#Cardiology#!#Hypertension#!#Lisinopril +~~END~~ + + + + + + + +--test7 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 1) +WITH ( + id int, + department varchar(20), + name varchar(50), + salary int +); +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 2) +WITH ( + id int, + department varchar(20), + name varchar(50), + salary int +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +int#!#varchar#!#varchar#!#int +1#!#IT#!##!# +2#!#HR#!##!# +~~END~~ + +~~START~~ +int#!#varchar#!#varchar#!#int +#!##!##!# +#!##!##!# +~~END~~ + + + + + + +--test8 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 3) +WITH ( + id int '@id', + department varchar(20) '@department', + name varchar(50) 'hr:name', + salary int 'hr:salary' +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +int#!#varchar#!#varchar#!#int +1#!#IT#!#John Doe#!#50000 +2#!#HR#!#Jane Smith#!#60000 +~~END~~ + + + + + + +--test9 +DECLARE @xml nvarchar(2000) = ' + + + + + + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/cust:Customer', 1) +WITH ( + customerid varchar(10), + contactname varchar(50), + country varchar(20) +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#varchar#!#varchar +VINET#!#Paul Henriot#!#France +LILAS#!#Carlos Gonzalez#!#Spain +~~END~~ + + + + + + +--test10 +DECLARE @xml nvarchar(2000) = ' + + + 1001 + John + Doe + IT + + + 1002 + Jane + Smith + HR + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/emp:Employee', 2) +WITH ( + EmployeeId varchar(10), + FirstName varchar(50), + LastName varchar(50), + Department varchar(20) +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#varchar +#!##!##!# +#!##!##!# +~~END~~ + + + + + + +--test11 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 100.00 + + + Jane Smith + 200.00 + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/ord:Order', 3) +WITH ( + id varchar(10), + date datetime, + CustomerName varchar(50), + Total decimal(10,2) +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#datetime#!#varchar#!#numeric +1001#!#2023-01-01 00:00:00.0#!##!# +1002#!#2023-01-02 00:00:00.0#!##!# +~~END~~ + + + + + + +--test12 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + + 123 Main St + New York + + + + Jane Smith + + 456 Oak Ave + Los Angeles + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/cust:Customer', 3) +WITH ( + id varchar(10), + Name varchar(50), + Street varchar(100), + City varchar(50) +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#varchar#!#varchar#!#varchar +C001#!##!##!# +C002#!##!##!# +~~END~~ + + + + + + +--test13 +DECLARE @xml nvarchar(2000) = ' + + + + 1000.00 + 100.00 + 1100.00 + + + + + 2000.00 + 200.00 + 2200.00 + + +'; +DECLARE @namespace nvarchar(200) = ' +'; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/inv:Invoice', 3) +WITH ( + number varchar(10), + type varchar(20), + Amount decimal(10,2), + Tax decimal(10,2), + Total decimal(10,2) +); +EXEC sp_xml_removedocument @handle; +GO +~~START~~ +varchar#!#varchar#!#numeric#!#numeric#!#numeric +INV001#!#Standard#!##!##!# +INV002#!#Express#!##!##!# +~~END~~ + + +-- Tests for tsql_openxml_get_colpattern and tsql_openxml_get_xmldoc +-- Test basic flag patterns +SELECT sys.tsql_openxml_get_colpattern('name', 0); +GO +~~START~~ +nvarchar +@name +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('name', 1); +GO +~~START~~ +nvarchar +@name +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('name', 2); +GO +~~START~~ +nvarchar +name +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('name', 3); +GO +~~START~~ +nvarchar +name|@name +~~END~~ + + +-- Test flag normalization (mod 4) +SELECT sys.tsql_openxml_get_colpattern('id', 4) +GO +~~START~~ +nvarchar +@id +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('id', 5); +GO +~~START~~ +nvarchar +@id +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('id', 6); +GO +~~START~~ +nvarchar +id +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('id', 7); +GO +~~START~~ +nvarchar +id|@id +~~END~~ + + +-- Test error and null cases +SELECT sys.tsql_openxml_get_colpattern(NULL, 1); +GO +~~START~~ +nvarchar + +~~END~~ + + +SELECT sys.tsql_openxml_get_colpattern('', 1); +GO +~~START~~ +nvarchar +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Column name cannot be empty for OPENXML)~~ + + +SELECT sys.tsql_openxml_get_colpattern('name', -1); +GO +~~START~~ +nvarchar +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Invalid flag value -1 for OPENXML)~~ + + +-- Test with valid document handle +DECLARE @doc_handle INT; +EXEC sp_xml_preparedocument @doc_handle OUTPUT, 'test'; +SELECT sys.tsql_openxml_get_xmldoc(@doc_handle); +EXEC sp_xml_removedocument @doc_handle; +GO +~~START~~ +xml +test +~~END~~ + + +-- Test with invalid or NULL handle +SELECT sys.tsql_openxml_get_xmldoc(999); +GO +~~START~~ +xml +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Could not find prepared statement with handle 999.)~~ + +SELECT sys.tsql_openxml_get_xmldoc(NULL); +GO +~~START~~ +xml + +~~END~~ + + +-- Tests for views for col pattern and xml doc generation +SELECT * FROM openxml_column_patterns WHERE flag = 3; +GO +~~START~~ +varchar#!#int#!#nvarchar +~~END~~ + + +SELECT document_id FROM openxml_documents; +GO +~~START~~ +int +~~ERROR (Code: 33557097)~~ + +~~ERROR (Message: Could not find prepared statement with handle 1.)~~ + diff --git a/test/JDBC/input/xml/openxml_with_clause-before-17_7-vu-cleanup.sql b/test/JDBC/input/xml/openxml_with_clause-before-17_7-vu-cleanup.sql new file mode 100644 index 0000000000..36765cdc33 --- /dev/null +++ b/test/JDBC/input/xml/openxml_with_clause-before-17_7-vu-cleanup.sql @@ -0,0 +1,29 @@ +DROP TABLE test_openxml_table; +GO + +DROP TABLE test_openxml_table_2; +GO + +DROP TABLE very_long_table_name_that_exceeds_sixty_four_characters_limit_test; +GO + +DROP TABLE test_long_columns; +GO + +DROP TABLE mixed_length_names; +GO + +DROP TABLE employee_defaults; +GO + +DROP TABLE person_table; +GO + +DROP TABLE regions; +GO + +DROP VIEW openxml_column_patterns +GO + +DROP VIEW openxml_documents +GO \ No newline at end of file diff --git a/test/JDBC/input/xml/openxml_with_clause-before-17_7-vu-prepare.sql b/test/JDBC/input/xml/openxml_with_clause-before-17_7-vu-prepare.sql new file mode 100644 index 0000000000..42c559250f --- /dev/null +++ b/test/JDBC/input/xml/openxml_with_clause-before-17_7-vu-prepare.sql @@ -0,0 +1,56 @@ +CREATE TABLE test_openxml_table(oid char(5), date datetime, amount float); +GO + +CREATE TABLE test_openxml_table_2(oid char(5), Date datetime, amount float); +GO + +CREATE TABLE very_long_table_name_that_exceeds_sixty_four_characters_limit_test ( + id INT, + name VARCHAR(50), + value INT +); +GO + +CREATE TABLE test_long_columns ( + very_long_column_name_that_definitely_exceeds_sixty_four_characters_limit_test INT, + another_extremely_long_column_name_exceeding_standard_limits_for_testing VARCHAR(50), + short_col INT +); +GO + +CREATE TABLE mixed_length_names ( + id INT, + extremely_long_column_name_that_exceeds_the_standard_sixty_four_character_limit_for_identifiers VARCHAR(200), + short VARCHAR(50) +); +GO + +CREATE TABLE employee_defaults ( + id INT IDENTITY(1,1) PRIMARY KEY, + name VARCHAR(50) NOT NULL, + department VARCHAR(20) DEFAULT 'Unknown', + salary DECIMAL(10,2) DEFAULT 0.00, + hire_date DATETIME DEFAULT GETDATE(), + status VARCHAR(10) DEFAULT 'Active', + CHECK (salary >= 0) +); +GO + +CREATE TABLE person_table ( + id INT, + name VARCHAR(50), + age INT +); +GO + +CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); +GO + +-- View for col pattern generation and xml doc retrieval +CREATE VIEW openxml_column_patterns AS +SELECT 'id' as column_name, 0 as flag, sys.tsql_openxml_get_colpattern('id', 0) AS xpath_pattern +GO + +CREATE VIEW openxml_documents AS +SELECT 1 as document_id, sys.tsql_openxml_get_xmldoc(1) AS xml_document; +GO \ No newline at end of file diff --git a/test/JDBC/input/xml/openxml_with_clause-before-17_7-vu-verify.sql b/test/JDBC/input/xml/openxml_with_clause-before-17_7-vu-verify.sql new file mode 100644 index 0000000000..0d83ce32f8 --- /dev/null +++ b/test/JDBC/input/xml/openxml_with_clause-before-17_7-vu-verify.sql @@ -0,0 +1,1280 @@ +-- Test plan + +-- When Colpattern is given for mapping +DECLARE @docHandle int; +DECLARE @xmlDocument nvarchar(1000); +SET @xmlDocument =N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument; +SELECT * +FROM OPENXML (@docHandle, '/ROOT/Customer/Order/OrderDetail/@ProductID') + WITH ( ProdID int '.', + Qty int '../@Quantity', + OID int '../../@OrderID'); +EXEC sp_xml_removedocument @docHandle; +GO + +-- flag = 0 (default attribute centric) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',0) + WITH (CustomerID varchar(10) , + ContactName varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- flag = 1 (attribute centric) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',1) + WITH (CustomerID varchar(10) , + ContactName varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- flag = 2 (element centric) +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + LILAS + Carlos Gonzalez + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 2) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +-- flag = 3 (combines both) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + LILAS + Carlos Gonzalez + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',3) + WITH (customerid varchar(10), + contactname varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- flag = 8 +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer',8) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +-- default flag is 0 +DECLARE @idoc INT, @doc VARCHAR(1000); +SET @doc = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @idoc OUTPUT, @doc; + +SELECT * +FROM OPENXML (@idoc, '/ROOT/Customer') + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @idoc; +GO + +-- If tablename is given +DECLARE @docHandle int; +DECLARE @XmlDocument varchar(1000); + +SET @xmlDocument = N' + + + Customer was very + satisfied + + + + Important + + + +'; + +EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument; + +SELECT * +FROM OPENXML (@docHandle, '/root/Customer/Order', 1) + WITH test_openxml_table; + +EXEC sp_xml_removedocument @docHandle; +GO + +-- If flag value more than 3 +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 4) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 7) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +-- rowpattern is case sensitive (this gives null) +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/root/customer', 4) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +-- colpattern is case sensitive +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',1) + WITH (customerid varchar(10) , + contactname varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- negative flag value +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', -1) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +-- Mixed attributes +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + The Great Novel + + John + Author + 4.5 + + + Book House + 2023 + 29.99 + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/Library/Book', 2) +WITH ( + ISBN varchar(20), + Category varchar(50), + Title varchar(100) 'Title', + AuthorFirstName varchar(50) 'Author/FirstName', + AuthorLastName varchar(50) 'Author/LastName', + Rating decimal(3,1) 'Author/Rating', + Publisher varchar(50) 'Publication/Publisher', + PublishYear int 'Publication/Year', + Price decimal(10,2) 'Publication/Price', + Currency varchar(3) 'Publication/Price/@currency' +); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- Nested elements +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(2000); +SET @XmlDocument = N' + + + Acme Corp +
123 Business St
+
+ + + Laptop + 2 + 999.99 + 0.10 + + + Mouse + 5 + 24.99 + 0.05 + + +
+
'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/Invoices/Invoice', 2) +WITH ( + InvoiceID varchar(10), + InvoiceDate date '@Date', + CustomerID varchar(10) 'Customer/@ID', + CustomerName varchar(50) 'Customer/Name', + CustomerAddress varchar(100) 'Customer/Address' +); + +SELECT * +FROM OPENXML (@DocHandle, '/Invoices/Invoice/Items/Item', 2) +WITH ( + InvoiceID varchar(10) '../../../@InvoiceID', + SKU varchar(10) '@SKU', + Description varchar(100) 'Description', + Quantity int 'Quantity', + UnitPrice decimal(10,2) 'UnitPrice', + Discount decimal(4,2) 'Discount' +); + +EXEC sp_xml_removedocument @DocHandle; +GO + +-- Basic example which gives customer, order, product details +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer', 1) +WITH ( + CustomerID varchar(10), + ContactName varchar(50) +); + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer/Order', 1) +WITH ( + OrderID int, + OrderDate date, + CustomerID varchar(10) '../@CustomerID' +); + + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer/Order/Product', 1) +WITH ( + OrderID int '../@OrderID', + ProductID varchar(10), + Quantity int, + Price decimal(10,2) +); + +EXEC sp_xml_removedocument @DocHandle; +GO + +-- When table name or colname > 64 bytes + +-- Test Case 1: Long table name (> 64 bytes) +INSERT INTO very_long_table_name_that_exceeds_sixty_four_characters_limit_test +VALUES (1, 'Test', 100); + +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, +''; + +SELECT * FROM +OPENXML(@xml_doc, '/root/item') +WITH very_long_table_name_that_exceeds_sixty_four_characters_limit_test; + +EXEC sp_xml_removedocument @xml_doc; +GO + +-- Test Case 2: Long column names (> 64 bytes) +INSERT INTO test_long_columns VALUES (1, 'Test Value', 999); + +DECLARE @xml_doc2 INT; +EXEC sp_xml_preparedocument @xml_doc2 OUTPUT, +' + +'; + + +SELECT * FROM +OPENXML(@xml_doc2, '/data/record') +WITH test_long_columns; + +EXEC sp_xml_removedocument @xml_doc2; +GO + +-- Test Case 3: Explicit column definitions with long names +DECLARE @xml_doc3 INT; +EXEC sp_xml_preparedocument @xml_doc3 OUTPUT, +' + +'; + +SELECT * FROM +OPENXML(@xml_doc3, '/items/item') WITH ( + very_long_column_name_that_definitely_exceeds_sixty_four_characters_limit_one VARCHAR(100), + another_extremely_long_column_name_that_exceeds_standard_database_limits_two VARCHAR(100) +); + +EXEC sp_xml_removedocument @xml_doc3; +GO + +-- Test Case 4: Mixed long and short names +DECLARE @xml_doc4 INT; +EXEC sp_xml_preparedocument @xml_doc4 OUTPUT, +' + +'; + +SELECT * FROM +OPENXML(@xml_doc4, '/test/row') +WITH mixed_length_names; + +EXEC sp_xml_removedocument @xml_doc4; +GO + +-- Openxml with table having default constraints +INSERT INTO employee_defaults (name, department, salary) +VALUES ('Test Employee', 'IT', 50000); + +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, +' + + + +'; + +SELECT * FROM +OPENXML(@xml_doc, '/employees/emp') WITH employee_defaults; + +EXEC sp_xml_removedocument @xml_doc; +GO + +-- Test with empty XML document +DECLARE @DocHandle int; +EXEC sp_xml_preparedocument @DocHandle OUTPUT; +SELECT * +FROM OPENXML (@DocHandle, '/', 1) +WITH ( + CustomerID varchar(10), + ContactName varchar(50) +); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- CROSS APPLY with openxml +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; + +EXEC sp_xml_removedocument @DocHandle; +GO + +-- cross apply for different row patterns +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, + concat('/Customers/Customer[@ID=', c.CustomerID, ']/Order'), + 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; + +EXEC sp_xml_removedocument @DocHandle; +GO + +-- cross apply for different row patterns +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N''; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, + concat('/Customers/Customer[@ID=', c.CustomerID, ']/Order'), + 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; +EXEC sp_xml_removedocument @DocHandle; +GO + +-- Basic CROSS APPLY with OPENXML using table reference +INSERT INTO person_table VALUES (1, 'John', 25), (2, 'Jane', 30); + +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, ''; + +SELECT * FROM +(SELECT 1 as id) t +CROSS APPLY OPENXML(@xml_doc, '/root/person') WITH person_table; + +EXEC sp_xml_removedocument @xml_doc; +GO + +-- OUTER APPLY +DECLARE @xml_doc2 INT; +EXEC sp_xml_preparedocument @xml_doc2 OUTPUT, +' + + + + + +'; + +SELECT + c.customer_id, + c.customer_name, + o.order_id, + o.amount +FROM + OPENXML(@xml_doc2, '/data/customer', 1) WITH ( + customer_id INT, + customer_name VARCHAR(50) + ) c +OUTER APPLY + OPENXML(@xml_doc2, '/data/order', 1) WITH ( + cust_id INT, + order_id INT, + amount DECIMAL(10,2) + ) o; + +EXEC sp_xml_removedocument @xml_doc2; +GO + +-- Base table with outer apply openxml +INSERT INTO regions VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); + +DECLARE @xml_doc3 INT; +EXEC sp_xml_preparedocument @xml_doc3 OUTPUT, +' + + + + + + + +'; + +SELECT + r.region_id, + r.region_name, + s.amount, + s.product +FROM + regions r +OUTER APPLY + OPENXML(@xml_doc3, '/sales/region/sale', 2) WITH ( + region_id INT '../@id', + amount DECIMAL(10,2), + product VARCHAR(50) + ) s +WHERE s.region_id = r.region_id OR s.region_id IS NULL; + +EXEC sp_xml_removedocument @xml_doc3; +GO + +-- With namespaces +--test1 +DECLARE @xml nvarchar(1000) = +' + value1 + value2 +'; +DECLARE @namespace nvarchar(100) = ''; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/ns1:child', 3) WITH (child nvarchar(10) '.'); +EXEC sp_xml_removedocument @handle; +GO + +DECLARE @h int; +EXEC sp_xml_preparedocument @h OUTPUT, + N' + + TaU + + ', + ''; + +SELECT * FROM openxml(@h, '/root/b:Elem', 3) + WITH (Col1 varchar(20) '.'); +EXEC sp_xml_removedocument @h; +GO + +-- test2 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/hr:employee', 2) +WITH ( + name nvarchar(50) 'hr:name', + salary int 'fin:salary', + currency nvarchar(10) 'fin:salary/@currency' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test3 +DECLARE @xml nvarchar(2000) = ' + + + + Laptop + 999.99 + + + Smartphone + 599.99 + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/catalog/cat:category/prod:product', 2) +WITH ( + category_name nvarchar(50) '../../@name', + product_name nvarchar(50) 'prod:name', + price decimal(10,2) 'prod:price' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test4 +DECLARE @xml nvarchar(2000) = ' + + + + Alice Johnson + alice@email.com + + + Widget A + Widget B + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/orders/ord:order/prod:items/prod:item', 2) +WITH ( + order_id int '../../../@id', + customer_name nvarchar(50) '../../../cust:customer/cust:name', + item_name nvarchar(50) '.', + quantity int '@qty' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test5 +DECLARE @xml nvarchar(2000) = ' + + + New York + + 20 + 65 + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/weather/loc:city', 2) +WITH ( + city_id varchar(10) '@id', + city_name varchar(50) 'loc:name', + temperature int 'met:conditions/met:temperature', + temp_unit varchar(1) 'met:conditions/met:temperature/@unit', + humidity int 'met:conditions/met:humidity', + reading_date date 'met:conditions/@date' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test6 +DECLARE @xml nvarchar(2000) = ' + + + + John Smith + 45 + + + Dr. Brown + Cardiology + + + Hypertension + Lisinopril + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/medical/pat:record', 2) +WITH ( + record_id int '@id', + patient_name nvarchar(50) 'pat:info/pat:name', + patient_age int 'pat:info/pat:age', + doctor_name nvarchar(50) 'doc:physician/doc:name', + specialty nvarchar(50) 'doc:physician/doc:specialty', + diagnosis nvarchar(100) 'treat:treatment/treat:diagnosis', + medication nvarchar(100) 'treat:treatment/treat:medication' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test7 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 1) +WITH ( + id int, + department varchar(20), + name varchar(50), + salary int +); + +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 2) +WITH ( + id int, + department varchar(20), + name varchar(50), + salary int +); + +EXEC sp_xml_removedocument @handle; +GO + +--test8 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 3) +WITH ( + id int '@id', + department varchar(20) '@department', + name varchar(50) 'hr:name', + salary int 'hr:salary' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test9 +DECLARE @xml nvarchar(2000) = ' + + + + + + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/cust:Customer', 1) +WITH ( + customerid varchar(10), + contactname varchar(50), + country varchar(20) +); + +EXEC sp_xml_removedocument @handle; +GO + +--test10 +DECLARE @xml nvarchar(2000) = ' + + + 1001 + John + Doe + IT + + + 1002 + Jane + Smith + HR + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/emp:Employee', 2) +WITH ( + EmployeeId varchar(10), + FirstName varchar(50), + LastName varchar(50), + Department varchar(20) +); + +EXEC sp_xml_removedocument @handle; +GO + +--test11 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 100.00 + + + Jane Smith + 200.00 + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/ord:Order', 3) +WITH ( + id varchar(10), + date datetime, + CustomerName varchar(50), + Total decimal(10,2) +); + +EXEC sp_xml_removedocument @handle; +GO + +--test12 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + + 123 Main St + New York + + + + Jane Smith + + 456 Oak Ave + Los Angeles + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/cust:Customer', 3) +WITH ( + id varchar(10), + Name varchar(50), + Street varchar(100), + City varchar(50) +); + +EXEC sp_xml_removedocument @handle; +GO + +--test13 +DECLARE @xml nvarchar(2000) = ' + + + + 1000.00 + 100.00 + 1100.00 + + + + + 2000.00 + 200.00 + 2200.00 + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/inv:Invoice', 3) +WITH ( + number varchar(10), + type varchar(20), + Amount decimal(10,2), + Tax decimal(10,2), + Total decimal(10,2) +); + +EXEC sp_xml_removedocument @handle; +GO + +-- Tests for tsql_openxml_get_colpattern and tsql_openxml_get_xmldoc +-- Test basic flag patterns +SELECT sys.tsql_openxml_get_colpattern('name', 0); +GO + +SELECT sys.tsql_openxml_get_colpattern('name', 1); +GO + +SELECT sys.tsql_openxml_get_colpattern('name', 2); +GO + +SELECT sys.tsql_openxml_get_colpattern('name', 3); +GO + +-- Test flag normalization (mod 4) +SELECT sys.tsql_openxml_get_colpattern('id', 4) +GO + +SELECT sys.tsql_openxml_get_colpattern('id', 5); +GO + +SELECT sys.tsql_openxml_get_colpattern('id', 6); +GO + +SELECT sys.tsql_openxml_get_colpattern('id', 7); +GO + +-- Test error and null cases +SELECT sys.tsql_openxml_get_colpattern(NULL, 1); +GO + +SELECT sys.tsql_openxml_get_colpattern('', 1); +GO + +SELECT sys.tsql_openxml_get_colpattern('name', -1); +GO + +-- Test with valid document handle +DECLARE @doc_handle INT; +EXEC sp_xml_preparedocument @doc_handle OUTPUT, 'test'; +SELECT sys.tsql_openxml_get_xmldoc(@doc_handle); +EXEC sp_xml_removedocument @doc_handle; +GO + +-- Test with invalid or NULL handle +SELECT sys.tsql_openxml_get_xmldoc(999); +GO +SELECT sys.tsql_openxml_get_xmldoc(NULL); +GO + +-- Tests for views for col pattern and xml doc generation +SELECT * FROM openxml_column_patterns WHERE flag = 3; +GO + +SELECT document_id FROM openxml_documents; +GO \ No newline at end of file diff --git a/test/JDBC/input/xml/openxml_with_clause-vu-cleanup.sql b/test/JDBC/input/xml/openxml_with_clause-vu-cleanup.sql new file mode 100644 index 0000000000..36765cdc33 --- /dev/null +++ b/test/JDBC/input/xml/openxml_with_clause-vu-cleanup.sql @@ -0,0 +1,29 @@ +DROP TABLE test_openxml_table; +GO + +DROP TABLE test_openxml_table_2; +GO + +DROP TABLE very_long_table_name_that_exceeds_sixty_four_characters_limit_test; +GO + +DROP TABLE test_long_columns; +GO + +DROP TABLE mixed_length_names; +GO + +DROP TABLE employee_defaults; +GO + +DROP TABLE person_table; +GO + +DROP TABLE regions; +GO + +DROP VIEW openxml_column_patterns +GO + +DROP VIEW openxml_documents +GO \ No newline at end of file diff --git a/test/JDBC/input/xml/openxml_with_clause-vu-prepare.sql b/test/JDBC/input/xml/openxml_with_clause-vu-prepare.sql new file mode 100644 index 0000000000..42c559250f --- /dev/null +++ b/test/JDBC/input/xml/openxml_with_clause-vu-prepare.sql @@ -0,0 +1,56 @@ +CREATE TABLE test_openxml_table(oid char(5), date datetime, amount float); +GO + +CREATE TABLE test_openxml_table_2(oid char(5), Date datetime, amount float); +GO + +CREATE TABLE very_long_table_name_that_exceeds_sixty_four_characters_limit_test ( + id INT, + name VARCHAR(50), + value INT +); +GO + +CREATE TABLE test_long_columns ( + very_long_column_name_that_definitely_exceeds_sixty_four_characters_limit_test INT, + another_extremely_long_column_name_exceeding_standard_limits_for_testing VARCHAR(50), + short_col INT +); +GO + +CREATE TABLE mixed_length_names ( + id INT, + extremely_long_column_name_that_exceeds_the_standard_sixty_four_character_limit_for_identifiers VARCHAR(200), + short VARCHAR(50) +); +GO + +CREATE TABLE employee_defaults ( + id INT IDENTITY(1,1) PRIMARY KEY, + name VARCHAR(50) NOT NULL, + department VARCHAR(20) DEFAULT 'Unknown', + salary DECIMAL(10,2) DEFAULT 0.00, + hire_date DATETIME DEFAULT GETDATE(), + status VARCHAR(10) DEFAULT 'Active', + CHECK (salary >= 0) +); +GO + +CREATE TABLE person_table ( + id INT, + name VARCHAR(50), + age INT +); +GO + +CREATE TABLE regions (region_id INT, region_name VARCHAR(50)); +GO + +-- View for col pattern generation and xml doc retrieval +CREATE VIEW openxml_column_patterns AS +SELECT 'id' as column_name, 0 as flag, sys.tsql_openxml_get_colpattern('id', 0) AS xpath_pattern +GO + +CREATE VIEW openxml_documents AS +SELECT 1 as document_id, sys.tsql_openxml_get_xmldoc(1) AS xml_document; +GO \ No newline at end of file diff --git a/test/JDBC/input/xml/openxml_with_clause-vu-verify.sql b/test/JDBC/input/xml/openxml_with_clause-vu-verify.sql new file mode 100644 index 0000000000..0d83ce32f8 --- /dev/null +++ b/test/JDBC/input/xml/openxml_with_clause-vu-verify.sql @@ -0,0 +1,1280 @@ +-- Test plan + +-- When Colpattern is given for mapping +DECLARE @docHandle int; +DECLARE @xmlDocument nvarchar(1000); +SET @xmlDocument =N' + + + + + + + + + + + +'; +EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument; +SELECT * +FROM OPENXML (@docHandle, '/ROOT/Customer/Order/OrderDetail/@ProductID') + WITH ( ProdID int '.', + Qty int '../@Quantity', + OID int '../../@OrderID'); +EXEC sp_xml_removedocument @docHandle; +GO + +-- flag = 0 (default attribute centric) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',0) + WITH (CustomerID varchar(10) , + ContactName varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- flag = 1 (attribute centric) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',1) + WITH (CustomerID varchar(10) , + ContactName varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- flag = 2 (element centric) +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + LILAS + Carlos Gonzalez + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 2) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +-- flag = 3 (combines both) +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + LILAS + Carlos Gonzalez + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',3) + WITH (customerid varchar(10), + contactname varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- flag = 8 +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer',8) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +-- default flag is 0 +DECLARE @idoc INT, @doc VARCHAR(1000); +SET @doc = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @idoc OUTPUT, @doc; + +SELECT * +FROM OPENXML (@idoc, '/ROOT/Customer') + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @idoc; +GO + +-- If tablename is given +DECLARE @docHandle int; +DECLARE @XmlDocument varchar(1000); + +SET @xmlDocument = N' + + + Customer was very + satisfied + + + + Important + + + +'; + +EXEC sp_xml_preparedocument @docHandle OUTPUT, @xmlDocument; + +SELECT * +FROM OPENXML (@docHandle, '/root/Customer/Order', 1) + WITH test_openxml_table; + +EXEC sp_xml_removedocument @docHandle; +GO + +-- If flag value more than 3 +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 4) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', 7) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +-- rowpattern is case sensitive (this gives null) +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/root/customer', 4) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +-- colpattern is case sensitive +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer',1) + WITH (customerid varchar(10) , + contactname varchar(20)); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- negative flag value +DECLARE @XmlDocumentHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + VINET + Paul Henriot + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @XmlDocumentHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@XmlDocumentHandle, '/ROOT/Customer', -1) + WITH (CustomerID varchar(10), + ContactName varchar(20)); +EXEC sp_xml_removedocument @XmlDocumentHandle; +GO + +-- Mixed attributes +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + The Great Novel + + John + Author + 4.5 + + + Book House + 2023 + 29.99 + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/Library/Book', 2) +WITH ( + ISBN varchar(20), + Category varchar(50), + Title varchar(100) 'Title', + AuthorFirstName varchar(50) 'Author/FirstName', + AuthorLastName varchar(50) 'Author/LastName', + Rating decimal(3,1) 'Author/Rating', + Publisher varchar(50) 'Publication/Publisher', + PublishYear int 'Publication/Year', + Price decimal(10,2) 'Publication/Price', + Currency varchar(3) 'Publication/Price/@currency' +); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- Nested elements +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(2000); +SET @XmlDocument = N' + + + Acme Corp +
123 Business St
+
+ + + Laptop + 2 + 999.99 + 0.10 + + + Mouse + 5 + 24.99 + 0.05 + + +
+
'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT * +FROM OPENXML (@DocHandle, '/Invoices/Invoice', 2) +WITH ( + InvoiceID varchar(10), + InvoiceDate date '@Date', + CustomerID varchar(10) 'Customer/@ID', + CustomerName varchar(50) 'Customer/Name', + CustomerAddress varchar(100) 'Customer/Address' +); + +SELECT * +FROM OPENXML (@DocHandle, '/Invoices/Invoice/Items/Item', 2) +WITH ( + InvoiceID varchar(10) '../../../@InvoiceID', + SKU varchar(10) '@SKU', + Description varchar(100) 'Description', + Quantity int 'Quantity', + UnitPrice decimal(10,2) 'UnitPrice', + Discount decimal(4,2) 'Discount' +); + +EXEC sp_xml_removedocument @DocHandle; +GO + +-- Basic example which gives customer, order, product details +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer', 1) +WITH ( + CustomerID varchar(10), + ContactName varchar(50) +); + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer/Order', 1) +WITH ( + OrderID int, + OrderDate date, + CustomerID varchar(10) '../@CustomerID' +); + + +SELECT * +FROM OPENXML (@DocHandle, '/ROOT/Customer/Order/Product', 1) +WITH ( + OrderID int '../@OrderID', + ProductID varchar(10), + Quantity int, + Price decimal(10,2) +); + +EXEC sp_xml_removedocument @DocHandle; +GO + +-- When table name or colname > 64 bytes + +-- Test Case 1: Long table name (> 64 bytes) +INSERT INTO very_long_table_name_that_exceeds_sixty_four_characters_limit_test +VALUES (1, 'Test', 100); + +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, +''; + +SELECT * FROM +OPENXML(@xml_doc, '/root/item') +WITH very_long_table_name_that_exceeds_sixty_four_characters_limit_test; + +EXEC sp_xml_removedocument @xml_doc; +GO + +-- Test Case 2: Long column names (> 64 bytes) +INSERT INTO test_long_columns VALUES (1, 'Test Value', 999); + +DECLARE @xml_doc2 INT; +EXEC sp_xml_preparedocument @xml_doc2 OUTPUT, +' + +'; + + +SELECT * FROM +OPENXML(@xml_doc2, '/data/record') +WITH test_long_columns; + +EXEC sp_xml_removedocument @xml_doc2; +GO + +-- Test Case 3: Explicit column definitions with long names +DECLARE @xml_doc3 INT; +EXEC sp_xml_preparedocument @xml_doc3 OUTPUT, +' + +'; + +SELECT * FROM +OPENXML(@xml_doc3, '/items/item') WITH ( + very_long_column_name_that_definitely_exceeds_sixty_four_characters_limit_one VARCHAR(100), + another_extremely_long_column_name_that_exceeds_standard_database_limits_two VARCHAR(100) +); + +EXEC sp_xml_removedocument @xml_doc3; +GO + +-- Test Case 4: Mixed long and short names +DECLARE @xml_doc4 INT; +EXEC sp_xml_preparedocument @xml_doc4 OUTPUT, +' + +'; + +SELECT * FROM +OPENXML(@xml_doc4, '/test/row') +WITH mixed_length_names; + +EXEC sp_xml_removedocument @xml_doc4; +GO + +-- Openxml with table having default constraints +INSERT INTO employee_defaults (name, department, salary) +VALUES ('Test Employee', 'IT', 50000); + +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, +' + + + +'; + +SELECT * FROM +OPENXML(@xml_doc, '/employees/emp') WITH employee_defaults; + +EXEC sp_xml_removedocument @xml_doc; +GO + +-- Test with empty XML document +DECLARE @DocHandle int; +EXEC sp_xml_preparedocument @DocHandle OUTPUT; +SELECT * +FROM OPENXML (@DocHandle, '/', 1) +WITH ( + CustomerID varchar(10), + ContactName varchar(50) +); +EXEC sp_xml_removedocument @DocHandle; +GO + +-- CROSS APPLY with openxml +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; + +EXEC sp_xml_removedocument @DocHandle; +GO + +-- cross apply for different row patterns +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N' + + + + + + + +'; + +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; + +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, + concat('/Customers/Customer[@ID=', c.CustomerID, ']/Order'), + 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; + +EXEC sp_xml_removedocument @DocHandle; +GO + +-- cross apply for different row patterns +DECLARE @DocHandle int; +DECLARE @XmlDocument nvarchar(1000); +SET @XmlDocument = N''; +EXEC sp_xml_preparedocument @DocHandle OUTPUT, @XmlDocument; +SELECT + c.CustomerID, + c.CustomerName, + o.OrderID, + o.OrderDate +FROM + OPENXML(@DocHandle, '/Customers/Customer', 2) + WITH ( + CustomerID int '@ID', + CustomerName varchar(50) '@Name' + ) c +CROSS APPLY + OPENXML(@DocHandle, + concat('/Customers/Customer[@ID=', c.CustomerID, ']/Order'), + 2) + WITH ( + OrderID int '@ID', + OrderDate date '@Date' + ) o; +EXEC sp_xml_removedocument @DocHandle; +GO + +-- Basic CROSS APPLY with OPENXML using table reference +INSERT INTO person_table VALUES (1, 'John', 25), (2, 'Jane', 30); + +DECLARE @xml_doc INT; +EXEC sp_xml_preparedocument @xml_doc OUTPUT, ''; + +SELECT * FROM +(SELECT 1 as id) t +CROSS APPLY OPENXML(@xml_doc, '/root/person') WITH person_table; + +EXEC sp_xml_removedocument @xml_doc; +GO + +-- OUTER APPLY +DECLARE @xml_doc2 INT; +EXEC sp_xml_preparedocument @xml_doc2 OUTPUT, +' + + + + + +'; + +SELECT + c.customer_id, + c.customer_name, + o.order_id, + o.amount +FROM + OPENXML(@xml_doc2, '/data/customer', 1) WITH ( + customer_id INT, + customer_name VARCHAR(50) + ) c +OUTER APPLY + OPENXML(@xml_doc2, '/data/order', 1) WITH ( + cust_id INT, + order_id INT, + amount DECIMAL(10,2) + ) o; + +EXEC sp_xml_removedocument @xml_doc2; +GO + +-- Base table with outer apply openxml +INSERT INTO regions VALUES (1, 'North'), (2, 'South'), (3, 'East'), (4, 'West'); + +DECLARE @xml_doc3 INT; +EXEC sp_xml_preparedocument @xml_doc3 OUTPUT, +' + + + + + + + +'; + +SELECT + r.region_id, + r.region_name, + s.amount, + s.product +FROM + regions r +OUTER APPLY + OPENXML(@xml_doc3, '/sales/region/sale', 2) WITH ( + region_id INT '../@id', + amount DECIMAL(10,2), + product VARCHAR(50) + ) s +WHERE s.region_id = r.region_id OR s.region_id IS NULL; + +EXEC sp_xml_removedocument @xml_doc3; +GO + +-- With namespaces +--test1 +DECLARE @xml nvarchar(1000) = +' + value1 + value2 +'; +DECLARE @namespace nvarchar(100) = ''; +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; +SELECT * FROM OPENXML(@handle, '/root/ns1:child', 3) WITH (child nvarchar(10) '.'); +EXEC sp_xml_removedocument @handle; +GO + +DECLARE @h int; +EXEC sp_xml_preparedocument @h OUTPUT, + N' + + TaU + + ', + ''; + +SELECT * FROM openxml(@h, '/root/b:Elem', 3) + WITH (Col1 varchar(20) '.'); +EXEC sp_xml_removedocument @h; +GO + +-- test2 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/hr:employee', 2) +WITH ( + name nvarchar(50) 'hr:name', + salary int 'fin:salary', + currency nvarchar(10) 'fin:salary/@currency' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test3 +DECLARE @xml nvarchar(2000) = ' + + + + Laptop + 999.99 + + + Smartphone + 599.99 + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/catalog/cat:category/prod:product', 2) +WITH ( + category_name nvarchar(50) '../../@name', + product_name nvarchar(50) 'prod:name', + price decimal(10,2) 'prod:price' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test4 +DECLARE @xml nvarchar(2000) = ' + + + + Alice Johnson + alice@email.com + + + Widget A + Widget B + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/orders/ord:order/prod:items/prod:item', 2) +WITH ( + order_id int '../../../@id', + customer_name nvarchar(50) '../../../cust:customer/cust:name', + item_name nvarchar(50) '.', + quantity int '@qty' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test5 +DECLARE @xml nvarchar(2000) = ' + + + New York + + 20 + 65 + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/weather/loc:city', 2) +WITH ( + city_id varchar(10) '@id', + city_name varchar(50) 'loc:name', + temperature int 'met:conditions/met:temperature', + temp_unit varchar(1) 'met:conditions/met:temperature/@unit', + humidity int 'met:conditions/met:humidity', + reading_date date 'met:conditions/@date' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test6 +DECLARE @xml nvarchar(2000) = ' + + + + John Smith + 45 + + + Dr. Brown + Cardiology + + + Hypertension + Lisinopril + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/medical/pat:record', 2) +WITH ( + record_id int '@id', + patient_name nvarchar(50) 'pat:info/pat:name', + patient_age int 'pat:info/pat:age', + doctor_name nvarchar(50) 'doc:physician/doc:name', + specialty nvarchar(50) 'doc:physician/doc:specialty', + diagnosis nvarchar(100) 'treat:treatment/treat:diagnosis', + medication nvarchar(100) 'treat:treatment/treat:medication' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test7 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 1) +WITH ( + id int, + department varchar(20), + name varchar(50), + salary int +); + +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 2) +WITH ( + id int, + department varchar(20), + name varchar(50), + salary int +); + +EXEC sp_xml_removedocument @handle; +GO + +--test8 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 50000 + + + Jane Smith + 60000 + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/employees/hr:employee', 3) +WITH ( + id int '@id', + department varchar(20) '@department', + name varchar(50) 'hr:name', + salary int 'hr:salary' +); + +EXEC sp_xml_removedocument @handle; +GO + +--test9 +DECLARE @xml nvarchar(2000) = ' + + + + + + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/cust:Customer', 1) +WITH ( + customerid varchar(10), + contactname varchar(50), + country varchar(20) +); + +EXEC sp_xml_removedocument @handle; +GO + +--test10 +DECLARE @xml nvarchar(2000) = ' + + + 1001 + John + Doe + IT + + + 1002 + Jane + Smith + HR + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/emp:Employee', 2) +WITH ( + EmployeeId varchar(10), + FirstName varchar(50), + LastName varchar(50), + Department varchar(20) +); + +EXEC sp_xml_removedocument @handle; +GO + +--test11 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + 100.00 + + + Jane Smith + 200.00 + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/ord:Order', 3) +WITH ( + id varchar(10), + date datetime, + CustomerName varchar(50), + Total decimal(10,2) +); + +EXEC sp_xml_removedocument @handle; +GO + +--test12 +DECLARE @xml nvarchar(2000) = ' + + + John Doe + + 123 Main St + New York + + + + Jane Smith + + 456 Oak Ave + Los Angeles + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/cust:Customer', 3) +WITH ( + id varchar(10), + Name varchar(50), + Street varchar(100), + City varchar(50) +); + +EXEC sp_xml_removedocument @handle; +GO + +--test13 +DECLARE @xml nvarchar(2000) = ' + + + + 1000.00 + 100.00 + 1100.00 + + + + + 2000.00 + 200.00 + 2200.00 + + +'; + +DECLARE @namespace nvarchar(200) = ' +'; + +DECLARE @handle INT; +EXEC sp_xml_preparedocument @handle OUTPUT, @xml, @namespace; + +SELECT * FROM OPENXML(@handle, '/root/inv:Invoice', 3) +WITH ( + number varchar(10), + type varchar(20), + Amount decimal(10,2), + Tax decimal(10,2), + Total decimal(10,2) +); + +EXEC sp_xml_removedocument @handle; +GO + +-- Tests for tsql_openxml_get_colpattern and tsql_openxml_get_xmldoc +-- Test basic flag patterns +SELECT sys.tsql_openxml_get_colpattern('name', 0); +GO + +SELECT sys.tsql_openxml_get_colpattern('name', 1); +GO + +SELECT sys.tsql_openxml_get_colpattern('name', 2); +GO + +SELECT sys.tsql_openxml_get_colpattern('name', 3); +GO + +-- Test flag normalization (mod 4) +SELECT sys.tsql_openxml_get_colpattern('id', 4) +GO + +SELECT sys.tsql_openxml_get_colpattern('id', 5); +GO + +SELECT sys.tsql_openxml_get_colpattern('id', 6); +GO + +SELECT sys.tsql_openxml_get_colpattern('id', 7); +GO + +-- Test error and null cases +SELECT sys.tsql_openxml_get_colpattern(NULL, 1); +GO + +SELECT sys.tsql_openxml_get_colpattern('', 1); +GO + +SELECT sys.tsql_openxml_get_colpattern('name', -1); +GO + +-- Test with valid document handle +DECLARE @doc_handle INT; +EXEC sp_xml_preparedocument @doc_handle OUTPUT, 'test'; +SELECT sys.tsql_openxml_get_xmldoc(@doc_handle); +EXEC sp_xml_removedocument @doc_handle; +GO + +-- Test with invalid or NULL handle +SELECT sys.tsql_openxml_get_xmldoc(999); +GO +SELECT sys.tsql_openxml_get_xmldoc(NULL); +GO + +-- Tests for views for col pattern and xml doc generation +SELECT * FROM openxml_column_patterns WHERE flag = 3; +GO + +SELECT document_id FROM openxml_documents; +GO \ No newline at end of file diff --git a/test/JDBC/jdbc_schedule b/test/JDBC/jdbc_schedule index 72be00186f..476f21e7f8 100644 --- a/test/JDBC/jdbc_schedule +++ b/test/JDBC/jdbc_schedule @@ -639,6 +639,9 @@ ignore#!#view_sec_setting_before_17_6-or-16_10-vu-cleanup ignore#!#mathematical_func-before_17_7-or-16_11-vu-prepare ignore#!#mathematical_func-before_17_7-or-16_11-vu-verify ignore#!#mathematical_func-before_17_7-or-16_11-vu-cleanup +ignore#!#openxml_with_clause-before-17_7-vu-prepare +ignore#!#openxml_with_clause-before-17_7-vu-verify +ignore#!#openxml_with_clause-before-17_7-vu-cleanup ignore#!#ascii_function_before-17_7-or-16_11-vu-prepare ignore#!#ascii_function_before-17_7-or-16_11-vu-verify ignore#!#ascii_function_before-17_7-or-16_11-vu-cleanup diff --git a/test/JDBC/upgrade/13_4/schedule b/test/JDBC/upgrade/13_4/schedule index e688a06eae..96d4c94e90 100644 --- a/test/JDBC/upgrade/13_4/schedule +++ b/test/JDBC/upgrade/13_4/schedule @@ -262,6 +262,7 @@ BABEL-5031 test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/13_5/schedule b/test/JDBC/upgrade/13_5/schedule index 605960cafd..374e464a5b 100644 --- a/test/JDBC/upgrade/13_5/schedule +++ b/test/JDBC/upgrade/13_5/schedule @@ -315,6 +315,7 @@ BABEL-5031 test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/13_6/schedule b/test/JDBC/upgrade/13_6/schedule index 17d311e269..5f0c3fbbc8 100644 --- a/test/JDBC/upgrade/13_6/schedule +++ b/test/JDBC/upgrade/13_6/schedule @@ -373,6 +373,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/13_7/schedule b/test/JDBC/upgrade/13_7/schedule index eff99360ce..53c1b54568 100644 --- a/test/JDBC/upgrade/13_7/schedule +++ b/test/JDBC/upgrade/13_7/schedule @@ -366,6 +366,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/13_8/schedule b/test/JDBC/upgrade/13_8/schedule index eff99360ce..53c1b54568 100644 --- a/test/JDBC/upgrade/13_8/schedule +++ b/test/JDBC/upgrade/13_8/schedule @@ -366,6 +366,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/13_9/schedule b/test/JDBC/upgrade/13_9/schedule index 4078bf11af..6c802de2e1 100644 --- a/test/JDBC/upgrade/13_9/schedule +++ b/test/JDBC/upgrade/13_9/schedule @@ -371,6 +371,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/14_10/schedule b/test/JDBC/upgrade/14_10/schedule index 00d7e3ab16..e9e94980ae 100644 --- a/test/JDBC/upgrade/14_10/schedule +++ b/test/JDBC/upgrade/14_10/schedule @@ -484,6 +484,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/14_11/schedule b/test/JDBC/upgrade/14_11/schedule index c5dcdcaae5..016c70619d 100644 --- a/test/JDBC/upgrade/14_11/schedule +++ b/test/JDBC/upgrade/14_11/schedule @@ -482,6 +482,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/14_12/schedule b/test/JDBC/upgrade/14_12/schedule index ea1c57f7a4..72ae46b7ee 100644 --- a/test/JDBC/upgrade/14_12/schedule +++ b/test/JDBC/upgrade/14_12/schedule @@ -483,6 +483,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/14_13/schedule b/test/JDBC/upgrade/14_13/schedule index f764521837..5b9a0e7279 100644 --- a/test/JDBC/upgrade/14_13/schedule +++ b/test/JDBC/upgrade/14_13/schedule @@ -483,6 +483,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/14_15/schedule b/test/JDBC/upgrade/14_15/schedule index 82f6f60f26..5b96d92141 100644 --- a/test/JDBC/upgrade/14_15/schedule +++ b/test/JDBC/upgrade/14_15/schedule @@ -479,6 +479,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/14_18/schedule b/test/JDBC/upgrade/14_18/schedule index 5ddc00792e..be36e06b59 100644 --- a/test/JDBC/upgrade/14_18/schedule +++ b/test/JDBC/upgrade/14_18/schedule @@ -479,6 +479,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/14_3/schedule b/test/JDBC/upgrade/14_3/schedule index 03cdde1cc3..601aaefbc6 100644 --- a/test/JDBC/upgrade/14_3/schedule +++ b/test/JDBC/upgrade/14_3/schedule @@ -402,6 +402,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/14_5/schedule b/test/JDBC/upgrade/14_5/schedule index fcaeaa070d..50b1125a50 100644 --- a/test/JDBC/upgrade/14_5/schedule +++ b/test/JDBC/upgrade/14_5/schedule @@ -414,6 +414,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/14_6/schedule b/test/JDBC/upgrade/14_6/schedule index 185ad47a93..58b0e94ced 100644 --- a/test/JDBC/upgrade/14_6/schedule +++ b/test/JDBC/upgrade/14_6/schedule @@ -452,6 +452,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/14_7/schedule b/test/JDBC/upgrade/14_7/schedule index 75a50f4b41..ff29755e12 100644 --- a/test/JDBC/upgrade/14_7/schedule +++ b/test/JDBC/upgrade/14_7/schedule @@ -474,6 +474,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/14_8/schedule b/test/JDBC/upgrade/14_8/schedule index 303f8d7370..13e1af747c 100644 --- a/test/JDBC/upgrade/14_8/schedule +++ b/test/JDBC/upgrade/14_8/schedule @@ -476,6 +476,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/14_9/schedule b/test/JDBC/upgrade/14_9/schedule index 4eb88527c1..4cfb2827ff 100644 --- a/test/JDBC/upgrade/14_9/schedule +++ b/test/JDBC/upgrade/14_9/schedule @@ -479,6 +479,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_1/schedule b/test/JDBC/upgrade/15_1/schedule index d8ceff97a1..ee08eb421e 100644 --- a/test/JDBC/upgrade/15_1/schedule +++ b/test/JDBC/upgrade/15_1/schedule @@ -452,6 +452,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_10/schedule b/test/JDBC/upgrade/15_10/schedule index a0b8d14ee2..09d7d835ef 100644 --- a/test/JDBC/upgrade/15_10/schedule +++ b/test/JDBC/upgrade/15_10/schedule @@ -570,6 +570,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_12/schedule b/test/JDBC/upgrade/15_12/schedule index 21f9e688a6..04eecf3c11 100644 --- a/test/JDBC/upgrade/15_12/schedule +++ b/test/JDBC/upgrade/15_12/schedule @@ -570,6 +570,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_13/schedule b/test/JDBC/upgrade/15_13/schedule index cf9009bfea..d83c3c6ddf 100644 --- a/test/JDBC/upgrade/15_13/schedule +++ b/test/JDBC/upgrade/15_13/schedule @@ -570,6 +570,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_14/schedule b/test/JDBC/upgrade/15_14/schedule index 5576197252..1c976c16a6 100644 --- a/test/JDBC/upgrade/15_14/schedule +++ b/test/JDBC/upgrade/15_14/schedule @@ -570,6 +570,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_15/schedule b/test/JDBC/upgrade/15_15/schedule index 4041f79380..61595f0e74 100644 --- a/test/JDBC/upgrade/15_15/schedule +++ b/test/JDBC/upgrade/15_15/schedule @@ -568,6 +568,7 @@ test_conv_string_to_time-before-17_4 BABEL-5031 BABEL-USER-GRANT test_conv_money_to_varchar +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_2/schedule b/test/JDBC/upgrade/15_2/schedule index 6824314f4c..d44375b1d2 100644 --- a/test/JDBC/upgrade/15_2/schedule +++ b/test/JDBC/upgrade/15_2/schedule @@ -488,6 +488,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_3/schedule b/test/JDBC/upgrade/15_3/schedule index 02622b36ed..71fe68b634 100644 --- a/test/JDBC/upgrade/15_3/schedule +++ b/test/JDBC/upgrade/15_3/schedule @@ -508,6 +508,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_4/schedule b/test/JDBC/upgrade/15_4/schedule index 97d941602d..8979cdacff 100644 --- a/test/JDBC/upgrade/15_4/schedule +++ b/test/JDBC/upgrade/15_4/schedule @@ -521,6 +521,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_5/schedule b/test/JDBC/upgrade/15_5/schedule index 072101d49e..43d801a420 100644 --- a/test/JDBC/upgrade/15_5/schedule +++ b/test/JDBC/upgrade/15_5/schedule @@ -555,6 +555,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/15_6/schedule b/test/JDBC/upgrade/15_6/schedule index e76a0e695b..a24cb9edc5 100644 --- a/test/JDBC/upgrade/15_6/schedule +++ b/test/JDBC/upgrade/15_6/schedule @@ -570,6 +570,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_7/schedule b/test/JDBC/upgrade/15_7/schedule index ec74010530..53249c1037 100644 --- a/test/JDBC/upgrade/15_7/schedule +++ b/test/JDBC/upgrade/15_7/schedule @@ -578,6 +578,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/15_8/schedule b/test/JDBC/upgrade/15_8/schedule index e706499eca..94f4be2f83 100644 --- a/test/JDBC/upgrade/15_8/schedule +++ b/test/JDBC/upgrade/15_8/schedule @@ -570,6 +570,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR BABEL-5467 diff --git a/test/JDBC/upgrade/16_1/schedule b/test/JDBC/upgrade/16_1/schedule index 8e34ae4a15..3c472be7b5 100644 --- a/test/JDBC/upgrade/16_1/schedule +++ b/test/JDBC/upgrade/16_1/schedule @@ -563,6 +563,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/16_10/schedule b/test/JDBC/upgrade/16_10/schedule index f350b57b0f..60ea360832 100644 --- a/test/JDBC/upgrade/16_10/schedule +++ b/test/JDBC/upgrade/16_10/schedule @@ -605,6 +605,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char diff --git a/test/JDBC/upgrade/16_11/schedule b/test/JDBC/upgrade/16_11/schedule index 334e25af65..d9fb6ba07e 100644 --- a/test/JDBC/upgrade/16_11/schedule +++ b/test/JDBC/upgrade/16_11/schedule @@ -605,6 +605,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char diff --git a/test/JDBC/upgrade/16_2/schedule b/test/JDBC/upgrade/16_2/schedule index 3025c38db1..4d0454992a 100644 --- a/test/JDBC/upgrade/16_2/schedule +++ b/test/JDBC/upgrade/16_2/schedule @@ -579,6 +579,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/16_3/schedule b/test/JDBC/upgrade/16_3/schedule index 2bf5335cbe..e687dee3f7 100644 --- a/test/JDBC/upgrade/16_3/schedule +++ b/test/JDBC/upgrade/16_3/schedule @@ -582,6 +582,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/16_4/schedule b/test/JDBC/upgrade/16_4/schedule index 7d1c55e423..8ce7b327d9 100644 --- a/test/JDBC/upgrade/16_4/schedule +++ b/test/JDBC/upgrade/16_4/schedule @@ -596,6 +596,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/16_6/schedule b/test/JDBC/upgrade/16_6/schedule index 5e7c12006a..f24fffbe8c 100644 --- a/test/JDBC/upgrade/16_6/schedule +++ b/test/JDBC/upgrade/16_6/schedule @@ -599,6 +599,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char_before_17_4 diff --git a/test/JDBC/upgrade/16_8/schedule b/test/JDBC/upgrade/16_8/schedule index 3aaf5a71e1..f623b7fda4 100644 --- a/test/JDBC/upgrade/16_8/schedule +++ b/test/JDBC/upgrade/16_8/schedule @@ -604,6 +604,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char diff --git a/test/JDBC/upgrade/16_9/schedule b/test/JDBC/upgrade/16_9/schedule index f25648d1f8..e4a7dc70d4 100644 --- a/test/JDBC/upgrade/16_9/schedule +++ b/test/JDBC/upgrade/16_9/schedule @@ -606,6 +606,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char diff --git a/test/JDBC/upgrade/17_4/schedule b/test/JDBC/upgrade/17_4/schedule index 87e00a3086..3ec0007442 100644 --- a/test/JDBC/upgrade/17_4/schedule +++ b/test/JDBC/upgrade/17_4/schedule @@ -601,6 +601,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char diff --git a/test/JDBC/upgrade/17_5/schedule b/test/JDBC/upgrade/17_5/schedule index 34fb723ff7..1918c95495 100644 --- a/test/JDBC/upgrade/17_5/schedule +++ b/test/JDBC/upgrade/17_5/schedule @@ -606,6 +606,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char diff --git a/test/JDBC/upgrade/17_6/schedule b/test/JDBC/upgrade/17_6/schedule index 29be468f10..57a3657a6c 100644 --- a/test/JDBC/upgrade/17_6/schedule +++ b/test/JDBC/upgrade/17_6/schedule @@ -610,6 +610,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause-before-17_7 fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char diff --git a/test/JDBC/upgrade/latest/schedule b/test/JDBC/upgrade/latest/schedule index a36901bd7d..0b372ed165 100644 --- a/test/JDBC/upgrade/latest/schedule +++ b/test/JDBC/upgrade/latest/schedule @@ -610,6 +610,7 @@ BABEL-USER-GRANT test_conv_money_to_varchar sp_xml_preparedocument sp_xml_removedocument +openxml_with_clause fixeddecimal_modulo BABEL-NUMERIC_EXPR test_conv_float_to_varchar_char diff --git a/test/python/expected/upgrade_validation/expected_dependency.out b/test/python/expected/upgrade_validation/expected_dependency.out index 785b414ca5..d650dba044 100644 --- a/test/python/expected/upgrade_validation/expected_dependency.out +++ b/test/python/expected/upgrade_validation/expected_dependency.out @@ -132,7 +132,6 @@ Function sys.babelfish_helpdb(character varying) Function sys.babelfish_is_ossp_present() Function sys.babelfish_is_spatial_present() Function sys.babelfish_istime(text) -Function sys.babelfish_openxml(bigint) Function sys.babelfish_parse_helper_to_date(text,boolean,text) Function sys.babelfish_parse_helper_to_datetime(text,boolean,text) Function sys.babelfish_parse_helper_to_time(text,boolean,text)