From c7440554de7f6a64ff350f6994ae56505c1ea713 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Thu, 25 Oct 2007 14:31:17 +0000 Subject: [PATCH] Fixed CORE-1528 - Functions DATEDIFF, ABS(integer const) does not work in dialect 1 --- src/dsql/dsql.cpp | 2 +- src/dsql/utld.cpp | 5 +++++ src/dsql/utld_proto.h | 1 + src/jrd/DataTypeUtil.cpp | 5 ++++- src/jrd/DataTypeUtil.h | 2 ++ src/jrd/SysFunction.cpp | 5 ++++- 6 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/dsql/dsql.cpp b/src/dsql/dsql.cpp index c91a310aab..b33f8bb35a 100644 --- a/src/dsql/dsql.cpp +++ b/src/dsql/dsql.cpp @@ -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 * diff --git a/src/dsql/utld.cpp b/src/dsql/utld.cpp index dd1cda0886..8124edd410 100644 --- a/src/dsql/utld.cpp +++ b/src/dsql/utld.cpp @@ -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 diff --git a/src/dsql/utld_proto.h b/src/dsql/utld_proto.h index a78c7bc170..3ce6ebccfa 100644 --- a/src/dsql/utld_proto.h +++ b/src/dsql/utld_proto.h @@ -56,6 +56,7 @@ public: public: virtual UCHAR maxBytesPerChar(UCHAR charSet); + virtual USHORT getDialect(); private: dsql_req* request; diff --git a/src/jrd/DataTypeUtil.cpp b/src/jrd/DataTypeUtil.cpp index d02855ecc1..395255c6bf 100644 --- a/src/jrd/DataTypeUtil.cpp +++ b/src/jrd/DataTypeUtil.cpp @@ -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 diff --git a/src/jrd/DataTypeUtil.h b/src/jrd/DataTypeUtil.h index ae42fbefc6..7419d3cd63 100644 --- a/src/jrd/DataTypeUtil.h +++ b/src/jrd/DataTypeUtil.h @@ -50,6 +50,7 @@ public: public: virtual UCHAR maxBytesPerChar(UCHAR charSet) = 0; + virtual USHORT getDialect() = 0; }; @@ -67,6 +68,7 @@ public: public: virtual UCHAR maxBytesPerChar(UCHAR charSet); + virtual USHORT getDialect(); // returns client dialect in DSQL and database dialect in JRD private: thread_db* tdbb; diff --git a/src/jrd/SysFunction.cpp b/src/jrd/SysFunction.cpp index 7fa103872f..dc47c1d807 100644 --- a/src/jrd/SysFunction.cpp +++ b/src/jrd/SysFunction.cpp @@ -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))