Ai
1 Star 0 Fork 0

github_repo/pg_query_go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
makefuncs.go 5.55 KB
一键复制 编辑 原始数据 按行查看 历史
package pg_query
func MakeStrNode(str string) *Node {
return &Node{Node: &Node_String_{String_: &String{Str: str}}}
}
func MakeAConstStrNode(str string, location int32) *Node {
return &Node{
Node: &Node_AConst{
AConst: &A_Const{
Val: MakeStrNode(str),
Location: location,
},
},
}
}
func MakeIntNode(ival int64) *Node {
return &Node{Node: &Node_Integer{Integer: &Integer{Ival: int32(ival)}}}
}
func MakeAConstIntNode(ival int64, location int32) *Node {
return &Node{
Node: &Node_AConst{
AConst: &A_Const{
Val: MakeIntNode(ival),
Location: location,
},
},
}
}
func MakeListNode(items []*Node) *Node {
return &Node{Node: &Node_List{List: &List{Items: items}}}
}
func MakeResTargetNodeWithName(name string, location int32) *Node {
return &Node{Node: &Node_ResTarget{ResTarget: &ResTarget{Name: name, Location: location}}}
}
func MakeResTargetNodeWithVal(val *Node, location int32) *Node {
return &Node{Node: &Node_ResTarget{ResTarget: &ResTarget{Val: val, Location: location}}}
}
func MakeResTargetNodeWithNameAndVal(name string, val *Node, location int32) *Node {
return &Node{Node: &Node_ResTarget{ResTarget: &ResTarget{Name: name, Val: val, Location: location}}}
}
func MakeSimpleRangeVar(relname string, location int32) *RangeVar {
return &RangeVar{
Relname: relname,
Inh: true,
Relpersistence: "p",
Location: location,
}
}
func MakeSimpleRangeVarNode(relname string, location int32) *Node {
return &Node{
Node: &Node_RangeVar{
RangeVar: MakeSimpleRangeVar(relname, location),
},
}
}
func MakeFullRangeVar(schemaname string, relname string, alias string, location int32) *RangeVar {
return &RangeVar{
Schemaname: schemaname,
Relname: relname,
Inh: true,
Relpersistence: "p",
Alias: &Alias{
Aliasname: alias,
},
Location: location,
}
}
func MakeFullRangeVarNode(schemaname string, relname string, alias string, location int32) *Node {
return &Node{
Node: &Node_RangeVar{
RangeVar: MakeFullRangeVar(schemaname, relname, alias, location),
},
}
}
func MakeParamRefNode(number int32, location int32) *Node {
return &Node{
Node: &Node_ParamRef{
ParamRef: &ParamRef{Number: number, Location: location},
},
}
}
func MakeColumnRefNode(fields []*Node, location int32) *Node {
return &Node{
Node: &Node_ColumnRef{
ColumnRef: &ColumnRef{Fields: fields, Location: location},
},
}
}
func MakeAStarNode() *Node {
return &Node{
Node: &Node_AStar{
AStar: &A_Star{},
},
}
}
func MakeCaseExprNode(arg *Node, args []*Node, location int32) *Node {
return &Node{
Node: &Node_CaseExpr{
CaseExpr: &CaseExpr{
Arg: arg,
Args: args,
Location: location,
},
},
}
}
func MakeCaseWhenNode(expr *Node, result *Node, location int32) *Node {
return &Node{
Node: &Node_CaseWhen{
CaseWhen: &CaseWhen{
Expr: expr,
Result: result,
Location: location,
},
},
}
}
func MakeFuncCallNode(funcname []*Node, args []*Node, location int32) *Node {
return &Node{
Node: &Node_FuncCall{
FuncCall: &FuncCall{
Funcname: funcname,
Args: args,
Location: location,
},
},
}
}
func MakeJoinExprNode(jointype JoinType, larg *Node, rarg *Node, quals *Node) *Node {
return &Node{
Node: &Node_JoinExpr{
JoinExpr: &JoinExpr{
Jointype: jointype,
Larg: larg,
Rarg: rarg,
Quals: quals,
},
},
}
}
func MakeAExprNode(kind A_Expr_Kind, name []*Node, lexpr *Node, rexpr *Node, location int32) *Node {
return &Node{
Node: &Node_AExpr{
AExpr: &A_Expr{
Kind: kind,
Name: name,
Lexpr: lexpr,
Rexpr: rexpr,
Location: location,
},
},
}
}
func MakeBoolExprNode(boolop BoolExprType, args []*Node, location int32) *Node {
return &Node{
Node: &Node_BoolExpr{
BoolExpr: &BoolExpr{
Boolop: boolop,
Args: args,
Location: location,
},
},
}
}
func MakeSortByNode(node *Node, sortbyDir SortByDir, sortbyNulls SortByNulls, location int32) *Node {
return &Node{
Node: &Node_SortBy{
SortBy: &SortBy{
Node: node,
SortbyDir: sortbyDir,
SortbyNulls: sortbyNulls,
Location: location,
},
},
}
}
func MakeSimpleDefElemNode(defname string, arg *Node, location int32) *Node {
return &Node{
Node: &Node_DefElem{
DefElem: &DefElem{
Defname: defname,
Arg: arg,
Defaction: DefElemAction_DEFELEM_UNSPEC,
Location: location,
},
},
}
}
func MakeSimpleColumnDefNode(colname string, typeName *TypeName, constraints []*Node, location int32) *Node {
return &Node{
Node: &Node_ColumnDef{
ColumnDef: &ColumnDef{
Colname: colname,
TypeName: typeName,
Constraints: constraints,
IsLocal: true,
Location: location,
},
},
}
}
func MakePrimaryKeyConstraintNode(location int32) *Node {
return &Node{
Node: &Node_Constraint{
Constraint: &Constraint{
Contype: ConstrType_CONSTR_PRIMARY,
Location: location,
},
},
}
}
func MakeNotNullConstraintNode(location int32) *Node {
return &Node{
Node: &Node_Constraint{
Constraint: &Constraint{
Contype: ConstrType_CONSTR_NOTNULL,
Location: location,
},
},
}
}
func MakeDefaultConstraintNode(rawExpr *Node, location int32) *Node {
return &Node{
Node: &Node_Constraint{
Constraint: &Constraint{
Contype: ConstrType_CONSTR_DEFAULT,
RawExpr: rawExpr,
Location: location,
},
},
}
}
func MakeSimpleRangeFunctionNode(functions []*Node) *Node {
return &Node{
Node: &Node_RangeFunction{
RangeFunction: &RangeFunction{
Functions: functions,
},
},
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/github_repo/pg_query_go.git
git@gitee.com:github_repo/pg_query_go.git
github_repo
pg_query_go
pg_query_go
lfittl-patch-1

搜索帮助