decimal: add decimal.c
This commit is contained in:
parent
1273d1a816
commit
e63a0e277c
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _TD_DECIMAL_H_
|
||||||
|
#define _TD_DECIMAL_H_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "tdef.h"
|
||||||
|
typedef struct SDataType SDataType;
|
||||||
|
|
||||||
|
int32_t decimalCalcTypeMod(const SDataType* pType);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /*_TD_DECIMAL_H_*/
|
|
@ -0,0 +1,16 @@
|
||||||
|
aux_source_directory(src DECIMAL_SRC)
|
||||||
|
|
||||||
|
add_library(decimal STATIC ${DECIMAL_SRC})
|
||||||
|
|
||||||
|
target_include_directories(
|
||||||
|
decimal
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/libs/decimal"
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
decimal
|
||||||
|
PRIVATE os util common qcom nodes
|
||||||
|
)
|
||||||
|
|
||||||
|
if(${BUILD_TEST})
|
||||||
|
ADD_SUBDIRECTORY(test)
|
||||||
|
endif(${BUILD_TEST})
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "decimal.h"
|
||||||
|
#include "querynodes.h"
|
||||||
|
|
||||||
|
int32_t decimalCalcTypeMod(const SDataType* pType) {
|
||||||
|
if (IS_DECIMAL_TYPE(pType->type)) {
|
||||||
|
return (pType->precision << 8) + pType->scale;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue