From 529e0bc59388dae09510b03e548c98eae4d97bd7 Mon Sep 17 00:00:00 2001 From: dimitr Date: Wed, 14 Dec 2011 16:08:05 +0000 Subject: [PATCH] Fixed (methinks) CORE-3697: String truncation error when selecting from a VIEW with UNION inside. It doesn't look like a good idea to modify dsc_length in place, as it can be used afterwards (e.g. MAKE_desc(field) after GEN_expr(rse), see define_view() in ddl.cpp). We only need to ensure that the generated BLR has the real byte length and it can be achieved with a temporary descriptor copy. Other solutions are also possible but this one seems better at the first glance. --- src/dsql/gen.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/dsql/gen.cpp b/src/dsql/gen.cpp index a2537d1078..cb1021165c 100644 --- a/src/dsql/gen.cpp +++ b/src/dsql/gen.cpp @@ -1653,10 +1653,12 @@ static void gen_constant( CompiledStatement* statement, const dsc* desc, bool ne **/ static void gen_constant( CompiledStatement* statement, dsql_nod* node, bool negate_value) { - if (node->nod_desc.dsc_dtype == dtype_text) - node->nod_desc.dsc_length = ((dsql_str*) node->nod_arg[0])->str_length; + dsc desc = node->nod_desc; - gen_constant(statement, &node->nod_desc, negate_value); + if (desc.dsc_dtype == dtype_text) + desc.dsc_length = ((dsql_str*) node->nod_arg[0])->str_length; + + gen_constant(statement, &desc, negate_value); } @@ -3098,7 +3100,7 @@ static void gen_union( CompiledStatement* statement, const dsql_nod* union_node) dsql_nod* map_item = items->nod_arg[0]; // AB: First item could be a virtual field generated by derived table. if (map_item->nod_type == nod_derived_field) { - map_item = map_item->nod_arg[e_alias_value]; + map_item = map_item->nod_arg[e_derived_field_value]; } dsql_ctx* union_context = (dsql_ctx*) map_item->nod_arg[e_map_context]; stuff_context(statement, union_context);