예제 #1
0
파일: select.go 프로젝트: nangong92t/go_src
func analyzeFrom(tableExprs sqlparser.TableExprs) (tablename string, hasHints bool) {
	if len(tableExprs) > 1 {
		return "", false
	}
	node, ok := tableExprs[0].(*sqlparser.AliasedTableExpr)
	if !ok {
		return "", false
	}
	return sqlparser.GetTableName(node.Expr), node.Hints != nil
}
예제 #2
0
func analyzeDelete(del *sqlparser.Delete, args []string, user *client.Client) (plan *ExecPlan, err error) {
	// Default plan
	plan = &ExecPlan{
		PlanId:    PLAN_PASS_DML,
		FullQuery: GenerateFullQuery(del),
	}

	tableName := sqlparser.GetTableName(del.Table)
	if tableName == "" {
		plan.Reason = REASON_TABLE
		return plan, nil
	}

	plan.Core = NewDeleteDML(del, tableName, args, user)

	return plan, nil
}
예제 #3
0
파일: insert.go 프로젝트: nangong92t/go_src
func analyzeInsert(ins *sqlparser.Insert, args []string, user *client.Client) (plan *ExecPlan, err error) {

	plan = &ExecPlan{
		PlanId:    PLAN_PASS_DML,
		FullQuery: GenerateFullQuery(ins),
	}
	tableName := sqlparser.GetTableName(ins.Table)

	if tableName == "" {
		plan.Reason = REASON_TABLE
		return plan, nil
	}

	plan.Core = NewInsertDML(ins, tableName, args, user)

	return plan, nil
}
예제 #4
0
func analyzeUpdate(upd *sqlparser.Update, args []string, user *client.Client) (plan *ExecPlan, err error) {
	// Default plan
	plan = &ExecPlan{
		PlanId:    PLAN_PASS_DML,
		FullQuery: GenerateFullQuery(upd),
	}

	tableName := sqlparser.GetTableName(upd.Table)
	if tableName == "" {
		plan.Reason = REASON_TABLE
		return plan, nil
	}

	plan.Core = NewUpdateDML(upd, tableName, args, user)

	/*
		conditions := analyzeWhere(upd.Where)
		if conditions == nil {
			plan.Reason = REASON_WHERE
			return plan, nil
		}*/

	return plan, nil
}