Skip to content

Commit

Permalink
Fixed CORE-4061 - isql does not insert boolean values correctly, alwa…
Browse files Browse the repository at this point in the history
…ys shown as False.
  • Loading branch information
asfernandes committed Mar 13, 2013
1 parent 37a7f1c commit b1644df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/dsql/make.cpp
Expand Up @@ -92,7 +92,7 @@ LiteralNode* MAKE_const_slong(SLONG value)
@param numeric_flag
**/
ValueExprNode* MAKE_constant(const string& str, dsql_constant_type numeric_flag)
ValueExprNode* MAKE_constant(const char* str, dsql_constant_type numeric_flag)
{
thread_db* tdbb = JRD_get_thread_data();

Expand All @@ -109,10 +109,10 @@ ValueExprNode* MAKE_constant(const string& str, dsql_constant_type numeric_flag)

literal->litDesc.dsc_dtype = dtype_double;
// Scale has no use for double
literal->litDesc.dsc_scale = static_cast<signed char>(str.length());
literal->litDesc.dsc_scale = static_cast<signed char>(strlen(str));
literal->litDesc.dsc_sub_type = 0;
literal->litDesc.dsc_length = sizeof(double);
literal->litDesc.dsc_address = (UCHAR*) str.c_str();
literal->litDesc.dsc_address = (UCHAR*) str;
literal->litDesc.dsc_ttype() = ttype_ascii;
break;

Expand Down Expand Up @@ -140,14 +140,14 @@ ValueExprNode* MAKE_constant(const string& str, dsql_constant_type numeric_flag)
// And, they will fit in a SINT64 without overflow.

SINT64 value = 0;
const UCHAR* p = reinterpret_cast<const UCHAR*>(str.c_str());
const UCHAR* p = reinterpret_cast<const UCHAR*>(str);

if (*p == 'X')
{
// oh no, a hex string!
++p; // skip the 'X' part.
UCHAR byte = 0;
bool nibble = ((str.length() - 1) & 1);
bool nibble = ((strlen(str) - 1) & 1);
SSHORT c;

// hex string is already upper-cased
Expand Down Expand Up @@ -239,8 +239,8 @@ ValueExprNode* MAKE_constant(const string& str, dsql_constant_type numeric_flag)
tmp.dsc_scale = 0;
tmp.dsc_flags = 0;
tmp.dsc_ttype() = ttype_ascii;
tmp.dsc_length = static_cast<USHORT>(str.length());
tmp.dsc_address = (UCHAR*) str.c_str();
tmp.dsc_length = static_cast<USHORT>(strlen(str));
tmp.dsc_address = (UCHAR*) str;

// Now invoke the string_to_date/time/timestamp routines

Expand All @@ -249,7 +249,7 @@ ValueExprNode* MAKE_constant(const string& str, dsql_constant_type numeric_flag)
}

case CONSTANT_BOOLEAN:
literal->litDesc.makeBoolean((UCHAR*) str.c_str());
literal->litDesc.makeBoolean((UCHAR*) str);
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion src/dsql/make_proto.h
Expand Up @@ -56,7 +56,7 @@ namespace Jrd {


Jrd::LiteralNode* MAKE_const_slong(SLONG);
Jrd::ValueExprNode* MAKE_constant(const Firebird::string&, Jrd::dsql_constant_type);
Jrd::ValueExprNode* MAKE_constant(const char*, Jrd::dsql_constant_type);
Jrd::LiteralNode* MAKE_str_constant(const Jrd::IntlString*, SSHORT);
void MAKE_desc(Jrd::DsqlCompilerScratch*, dsc*, Jrd::ValueExprNode*);
void MAKE_desc_from_field(dsc*, const Jrd::dsql_fld*);
Expand Down
16 changes: 8 additions & 8 deletions src/dsql/parse.y
Expand Up @@ -1523,9 +1523,9 @@ sequence_value
: signed_long_integer
{ $$ = MAKE_const_slong($1); }
| NUMBER64BIT
{ $$ = MAKE_constant(*$1, CONSTANT_SINT64); }
{ $$ = MAKE_constant($1->c_str(), CONSTANT_SINT64); }
| '-' NUMBER64BIT
{ $$ = newNode<NegateNode>(MAKE_constant(*$2, CONSTANT_SINT64)); }
{ $$ = newNode<NegateNode>(MAKE_constant($2->c_str(), CONSTANT_SINT64)); }
;


Expand Down Expand Up @@ -5959,9 +5959,9 @@ constant
%type <valueExprNode> u_numeric_constant
u_numeric_constant
: NUMBER { $$ = MAKE_const_slong($1); }
| FLOAT_NUMBER { $$ = MAKE_constant(*$1, CONSTANT_DOUBLE); }
| NUMBER64BIT { $$ = MAKE_constant(*$1, CONSTANT_SINT64); }
| SCALEDINT { $$ = MAKE_constant(*$1, CONSTANT_SINT64); }
| FLOAT_NUMBER { $$ = MAKE_constant($1->c_str(), CONSTANT_DOUBLE); }
| NUMBER64BIT { $$ = MAKE_constant($1->c_str(), CONSTANT_SINT64); }
| SCALEDINT { $$ = MAKE_constant($1->c_str(), CONSTANT_SINT64); }
;

%type <valueExprNode> u_constant
Expand All @@ -5983,7 +5983,7 @@ u_constant
Arg::Gds(isc_sql_db_dialect_dtype_unsupport) << Arg::Num(db_dialect) <<
Arg::Str("DATE"));
}
$$ = MAKE_constant($2->getString(), CONSTANT_DATE);
$$ = MAKE_constant($2->getString().c_str(), CONSTANT_DATE);
}
| TIME STRING
{
Expand All @@ -5999,10 +5999,10 @@ u_constant
Arg::Gds(isc_sql_db_dialect_dtype_unsupport) << Arg::Num(db_dialect) <<
Arg::Str("TIME"));
}
$$ = MAKE_constant($2->getString(), CONSTANT_TIME);
$$ = MAKE_constant($2->getString().c_str(), CONSTANT_TIME);
}
| TIMESTAMP STRING
{ $$ = MAKE_constant($2->getString(), CONSTANT_TIMESTAMP); }
{ $$ = MAKE_constant($2->getString().c_str(), CONSTANT_TIMESTAMP); }
;

%type <valueExprNode> boolean_literal
Expand Down

0 comments on commit b1644df

Please sign in to comment.