Skip to content

Commit

Permalink
Fixed CORE-1528 - Functions DATEDIFF, ABS(integer const) does not wor…
Browse files Browse the repository at this point in the history
…k in dialect 1
  • Loading branch information
asfernandes committed Oct 25, 2007
1 parent b71d62c commit c744055
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dsql/dsql.cpp
Expand Up @@ -672,7 +672,7 @@ static ISC_STATUS dsql8_execute_immediate_common(ISC_STATUS* user_status,
* be a way to send the parser version to DSQL so that the parser can compare the keyword
* version to the parser version. To accomplish this, the parser version is combined with
* the client dialect and sent across that way. In dsql8_execute_immediate, the parser version
* and client dialect are separated and passed on to their final desintations. The information
* and client dialect are separated and passed on to their final destinations. The information
* is combined as follows:
* Dialect * 10 + parser_version
*
Expand Down
5 changes: 5 additions & 0 deletions src/dsql/utld.cpp
Expand Up @@ -1056,4 +1056,9 @@ UCHAR DSqlDataTypeUtil::maxBytesPerChar(UCHAR charSet)
return METD_get_charset_bpc(request, charSet);
}

USHORT DSqlDataTypeUtil::getDialect()
{
return request->req_client_dialect;
}

#endif
1 change: 1 addition & 0 deletions src/dsql/utld_proto.h
Expand Up @@ -56,6 +56,7 @@ class DSqlDataTypeUtil : public DataTypeUtilBase

public:
virtual UCHAR maxBytesPerChar(UCHAR charSet);
virtual USHORT getDialect();

private:
dsql_req* request;
Expand Down
5 changes: 4 additions & 1 deletion src/jrd/DataTypeUtil.cpp
Expand Up @@ -535,11 +535,14 @@ void DataTypeUtilBase::makeSysFunction(dsc* result, const char* name, int argsCo

namespace Jrd {


UCHAR DataTypeUtil::maxBytesPerChar(UCHAR charSet)
{
return INTL_charset_lookup(tdbb, charSet)->maxBytesPerChar();
}

USHORT DataTypeUtil::getDialect()
{
return (tdbb->tdbb_database->dbb_flags & DBB_DB_SQL_dialect_3) ? 3 : 1;
}

} // namespace Jrd
2 changes: 2 additions & 0 deletions src/jrd/DataTypeUtil.h
Expand Up @@ -50,6 +50,7 @@ class DataTypeUtilBase

public:
virtual UCHAR maxBytesPerChar(UCHAR charSet) = 0;
virtual USHORT getDialect() = 0;
};


Expand All @@ -67,6 +68,7 @@ class DataTypeUtil : public DataTypeUtilBase

public:
virtual UCHAR maxBytesPerChar(UCHAR charSet);
virtual USHORT getDialect(); // returns client dialect in DSQL and database dialect in JRD

private:
thread_db* tdbb;
Expand Down
5 changes: 4 additions & 1 deletion src/jrd/SysFunction.cpp
Expand Up @@ -351,7 +351,10 @@ static void makeFromListResult(DataTypeUtilBase* dataTypeUtil, const SysFunction

static void makeInt64Result(DataTypeUtilBase* dataTypeUtil, const SysFunction* function, dsc* result, int argsCount, const dsc** args)
{
result->makeInt64(0);
if (dataTypeUtil->getDialect() == 1)
result->makeDouble();
else
result->makeInt64(0);

bool isNullable;
if (initResult(result, argsCount, args, &isNullable))
Expand Down

0 comments on commit c744055

Please sign in to comment.