Ejemplo n.º 1
0
func (node *Node) execAnalyzeUpdateExpressions(pkIndex *schema.Index) (updateColumns []Pair, status updateStatus) {
	updateColumns = make([]Pair, node.Len())
	for i := 0; i < node.Len(); i++ {
		columnName := string(node.At(i).At(0).Value)
		index := pkIndex.FindColumn(columnName)
		if index != -1 {
			// update pkvalues not supported
			return nil, updatePkValue
		}
		value := node.At(i).At(1).execAnalyzeValue()
		if value == nil {
			log.Warn("unsupported update expression", node.At(i).At(0))
			return nil, updateUnsupport
		}
		log.Info(string(value.Value))
		updateColumns[i] = Pair{columnName, string(value.Value)}
	}
	return updateColumns, updateOk
}
Ejemplo n.º 2
0
func (node *Node) execAnalyzeUpdateExpressions(pkIndex *schema.Index) (pkValues []interface{}, ok bool) {
	for i := 0; i < node.Len(); i++ {
		columnName := string(node.At(i).At(0).Value)
		index := pkIndex.FindColumn(columnName)
		if index == -1 {
			continue
		}
		value := node.At(i).At(1).execAnalyzeValue()
		if value == nil {
			log.Warn("expression is too complex %v", node.At(i).At(0))
			return nil, false
		}
		if pkValues == nil {
			pkValues = make([]interface{}, len(pkIndex.Columns))
		}
		pkValues[index] = asInterface(value)
	}
	return pkValues, true
}