!91 pgdb compatibility support

Merge pull request !91 from 吴岳川/master
This commit is contained in:
opengauss-bot
2020-08-10 10:01:53 +08:00
committed by Gitee
36 changed files with 219 additions and 153 deletions

View File

@ -452,8 +452,9 @@ llvm::Function* substr_codegen()
* in case of a db compatible format we have to prepare a flag to indicate whether
* result string is NULL, so we add one more parameter.
*/
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT)
if (DB_IS_CMPT(DB_CMPT_A)) {
fn_prototype.addArgument(GsCodeGen::NamedVariable("isNull", int8PtrType));
}
llvm::Function* jitted_substr = fn_prototype.generatePrototype(&builder, &llvmargs[0]);
@ -461,8 +462,9 @@ llvm::Function* substr_codegen()
start = llvmargs[1];
len = llvmargs[2];
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT)
if (DB_IS_CMPT(DB_CMPT_A)) {
isNull = llvmargs[3];
}
/*
* Convert the first arg to {i32, i8*} type to get the length and the real value.
@ -499,7 +501,7 @@ llvm::Function* substr_codegen()
*in case of ORC, we should set isNull to True if res_len == 0;
*otherwise, just return the result.
*/
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT) {
if (DB_IS_CMPT(DB_CMPT_A)) {
DEFINE_BLOCK(be_null, jitted_substr);
DEFINE_BLOCK(bnot_null, jitted_substr);
DEFINE_BLOCK(ret_bb, jitted_substr);
@ -570,14 +572,16 @@ llvm::Function* rtrim1_codegen()
* in case of a db compatible format we have to prepare a flag to indicate whether
* result string is NULL, so we add one more parameter.
*/
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT)
if (DB_IS_CMPT(DB_CMPT_A)) {
fn_prototype.addArgument(GsCodeGen::NamedVariable("isNull", int8PtrType));
}
llvm::Function* jitted_rtrim1 = fn_prototype.generatePrototype(&builder, &llvmargs[0]);
argval = llvmargs[0];
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT)
if (DB_IS_CMPT(DB_CMPT_A)) {
isNull = llvmargs[1];
}
/* load rtrim1 ir function from module */
llvm::Function* func_rtrim1_cc = llvmCodeGen->module()->getFunction("LLVMIRrtrim1");
@ -601,7 +605,7 @@ llvm::Function* rtrim1_codegen()
*in case of ORC, we should set isNull to True if res_len == 0;
*otherwise, just return the result.
*/
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT) {
if (DB_IS_CMPT(DB_CMPT_A)) {
DEFINE_BLOCK(be_null, jitted_rtrim1);
DEFINE_BLOCK(bnot_null, jitted_rtrim1);
DEFINE_BLOCK(ret_bb, jitted_rtrim1);
@ -673,12 +677,13 @@ llvm::Function* btrim1_codegen()
* in case of a compatible format we have to prepare a flag to indicate whether
* result string is NULL, so we add one more parameter.
*/
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT)
if (DB_IS_CMPT(DB_CMPT_A)) {
fn_prototype.addArgument(GsCodeGen::NamedVariable("isNull", int8PtrType));
}
llvm::Function* jitted_btrim1 = fn_prototype.generatePrototype(&builder, &llvmargs[0]);
argval = llvmargs[0];
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT)
if (DB_IS_CMPT(DB_CMPT_A))
isNull = llvmargs[1];
/* load rtrim1 ir function from IR file*/
@ -703,7 +708,7 @@ llvm::Function* btrim1_codegen()
*in case of ORC, we should set isNull to True if res_len == 0;
*otherwise, just return the result.
*/
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT) {
if (DB_IS_CMPT(DB_CMPT_A)) {
DEFINE_BLOCK(be_null, jitted_btrim1);
DEFINE_BLOCK(bnot_null, jitted_btrim1);
DEFINE_BLOCK(ret_bb, jitted_btrim1);

View File

@ -2869,7 +2869,7 @@ llvm::Value* VecExprCodeGen::FuncCodeGen(ExprCodeGenArgs* args)
* then we have to set 'isNull' flag to True,
* and then jump to the be_null block.
*/
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT) {
if (DB_IS_CMPT(DB_CMPT_A)) {
res1 = inner_builder.CreateCall(func_substr, {inargs[0], inargs[1], inargs[2], isNull});
llvm::Value* res_flag = inner_builder.CreateAlignedLoad(isNull, 1, "resflag");
llvm::Value* cmp = inner_builder.CreateICmpEQ(res_flag, null_true, "check");
@ -2892,7 +2892,7 @@ llvm::Value* VecExprCodeGen::FuncCodeGen(ExprCodeGenArgs* args)
* then we have to set 'isNull' flag to True,
* and then jump to the be_null block.
*/
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT) {
if (DB_IS_CMPT(DB_CMPT_A)) {
res1 = inner_builder.CreateCall(func_rtrim1, {inargs[0], isNull});
llvm::Value* res_flag = inner_builder.CreateAlignedLoad(isNull, 1, "resflag");
llvm::Value* cmp = inner_builder.CreateICmpEQ(res_flag, null_true, "check");
@ -2914,7 +2914,7 @@ llvm::Value* VecExprCodeGen::FuncCodeGen(ExprCodeGenArgs* args)
* then we have to set 'isNull' flag to True,
* and then jump to the be_null block.
*/
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT) {
if (DB_IS_CMPT(DB_CMPT_A)) {
res1 = inner_builder.CreateCall(func_btrim1, {inargs[0], isNull});
llvm::Value* res_flag = inner_builder.CreateAlignedLoad(isNull, 1, "resflag");
llvm::Value* cmp = inner_builder.CreateICmpEQ(res_flag, null_true, "check");

View File

@ -453,7 +453,7 @@ void OpFusion::updatePreAllocParamter(StringInfo input_message)
/* add null value process for date type */
if ((VARCHAROID == ptype || TIMESTAMPOID == ptype || TIMESTAMPTZOID == ptype || TIMEOID == ptype ||
TIMETZOID == ptype || INTERVALOID == ptype || SMALLDATETIMEOID == ptype) &&
plength == 0 && u_sess->attr.attr_sql.sql_compatibility == A_FORMAT) {
plength == 0 && DB_IS_CMPT(DB_CMPT_A)) {
isNull = true;
}

View File

@ -321,7 +321,7 @@ inline static Datum
null_return(bool *is_null)
{
text *result = NULL;
if(u_sess->attr.attr_sql.sql_compatibility == A_FORMAT)
if(DB_IS_CMPT(DB_CMPT_A))
{
*is_null = true;
return (Datum)0;