MCPcopy Create free account
hub / github.com/araddon/qlbridge / evalSetExpression

Function evalSetExpression

exec/command.go:90–124  ·  view source on GitHub ↗
(col *rel.CommandColumn, ctx expr.ContextReadWriter, arg expr.Node)

Source from the content-addressed store, hash-verified

88}
89
90func evalSetExpression(col *rel.CommandColumn, ctx expr.ContextReadWriter, arg expr.Node) error {
91
92 switch bn := arg.(type) {
93 case *expr.BinaryNode:
94 _, ok := bn.Args[0].(*expr.IdentityNode)
95 if !ok {
96 u.Warnf("expected identity but got %T in %s", bn.Args[0], arg.String())
97 return fmt.Errorf("Expected identity but got %T", bn.Args[0])
98 }
99 rhv, ok := vm.Eval(ctx, bn.Args[1])
100 if !ok {
101 u.Warnf("expected right side value but got %T in %s", bn.Args[1], arg.String())
102 return fmt.Errorf("Expected value but got %T", bn.Args[1])
103 }
104 //u.Infof(`writeContext.Put("%v",%v)`, col.Key(), rhv.Value())
105 ctx.Put(col, ctx, rhv)
106 case nil:
107 // Special statements
108 name := strings.ToLower(col.Name)
109 switch {
110 case strings.HasPrefix(name, "names ") || strings.HasPrefix(name, "character set"):
111 // http://dev.mysql.com/doc/refman/5.7/en/charset-connection.html
112 // hm, no idea what to do
113 /*
114 SET character_set_client = charset_name;
115 SET character_set_results = charset_name;
116 SET character_set_connection = charset_name;
117 */
118 }
119 default:
120 u.Errorf("SET command only accepts binary nodes but got type: %#v", arg)
121 return fmt.Errorf("Un recognized command %T", arg)
122 }
123 return nil
124}

Callers 1

runSetMethod · 0.85

Calls 4

EvalFunction · 0.92
ErrorfMethod · 0.80
StringMethod · 0.65
PutMethod · 0.65

Tested by

no test coverage detected