Skip to content

Commit

Permalink
Backport fix for CORE-1126 - UNION vs UTF8 literals : arithmetic exce…
Browse files Browse the repository at this point in the history
…ption is thrown
  • Loading branch information
asfernandes committed Feb 15, 2007
1 parent d7a755e commit bb68ec8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/jrd/cmp.cpp
Expand Up @@ -80,6 +80,7 @@
#include "../jrd/mov_proto.h"
#include "../jrd/dsc_proto.h"
#include "../jrd/dbg_proto.h" // DBG_supervisor
#include "../jrd/intl_proto.h"
#include "../jrd/execute_statement.h"

/* Pick up relation ids */
Expand Down Expand Up @@ -1689,6 +1690,33 @@ void CMP_get_desc(thread_db* tdbb, CompilerScratch* csb, jrd_nod* node, DSC * de

case nod_literal:
*desc = ((Literal*) node)->lit_desc;

// ASF: I expect only dtype_text could occur here.
// But I'll treat all string types for sure.
if (DTYPE_IS_TEXT(desc->dsc_dtype))
{
const UCHAR* p;
USHORT adjust = 0;

if (desc->dsc_dtype == dtype_varying)
{
p = desc->dsc_address + sizeof(USHORT);
adjust = 2;
}
else
{
p = desc->dsc_address;

if (desc->dsc_dtype == dtype_cstring)
adjust = 1;
}

// Do the same thing which DSQL does.
// Increase descriptor size to evaluate dependent expressions correctly.
CharSet* cs = INTL_charset_lookup(tdbb, INTL_GET_CHARSET(desc));
desc->dsc_length = (cs->length(tdbb, desc->dsc_length - adjust, p, true) *
cs->maxBytesPerChar()) + adjust;
}
return;

case nod_cast:
Expand Down

0 comments on commit bb68ec8

Please sign in to comment.