forked from greenplum-db/gpdb-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpr_tree_generator.cc
63 lines (59 loc) · 1.87 KB
/
expr_tree_generator.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//---------------------------------------------------------------------------
// Greenplum Database
// Copyright (C) 2016 Pivotal Software, Inc.
//
// @filename:
// expr_tree_generator.cc
//
// @doc:
// Base class for expression tree to generate code
//
//---------------------------------------------------------------------------
#include <cassert>
#include <memory>
#include "codegen/const_expr_tree_generator.h"
#include "codegen/expr_tree_generator.h"
#include "codegen/op_expr_tree_generator.h"
#include "codegen/var_expr_tree_generator.h"
extern "C" {
#include "postgres.h" // NOLINT(build/include)
#include "nodes/execnodes.h"
#include "utils/elog.h"
#include "nodes/nodes.h"
}
using gpcodegen::ExprTreeGenerator;
bool ExprTreeGenerator::VerifyAndCreateExprTree(
const ExprState* expr_state,
ExprTreeGeneratorInfo* gen_info,
std::unique_ptr<ExprTreeGenerator>* expr_tree) {
assert(nullptr != expr_state &&
nullptr != expr_state->expr &&
nullptr != expr_tree);
expr_tree->reset(nullptr);
bool supported_expr_tree = false;
switch (nodeTag(expr_state->expr)) {
case T_OpExpr: {
supported_expr_tree = OpExprTreeGenerator::VerifyAndCreateExprTree(
expr_state, gen_info, expr_tree);
break;
}
case T_Var: {
supported_expr_tree = VarExprTreeGenerator::VerifyAndCreateExprTree(
expr_state, gen_info, expr_tree);
break;
}
case T_Const: {
supported_expr_tree = ConstExprTreeGenerator::VerifyAndCreateExprTree(
expr_state, gen_info, expr_tree);
break;
}
default : {
supported_expr_tree = false;
elog(DEBUG1, "Unsupported expression tree %d found",
nodeTag(expr_state->expr));
}
}
assert((!supported_expr_tree && nullptr == expr_tree->get()) ||
(supported_expr_tree && nullptr != expr_tree->get()));
return supported_expr_tree;
}