// buildDelete returns the generated SQL for the DELETE statement. Panics if it can't geerate a query
340268
func (db *Database) buildDelete() string {
	var query bytes.Buffer
	query.WriteString(db.buildCTE())
	query.WriteString("DELETE FROM ")

	// Model only
	if len(db.tables) != 1 {
		db.panicLog("Unable to infer table name for Delete. Use Delete(model) or Model(model)")
	}
	query.WriteString(db.tables[0])

	// Where (mandatory)
	if len(db.whereFields) == 0 {
		db.panicLog("Where statement is mandatory in Delete")
	}

	query.WriteString(db.buildWhere())
	query.WriteString(";")

	qs := query.String()
	db.printLog(qs)
	return qs
}
189887
func (m *Sqlbridge) parseSqlDelete() (*SqlDelete, error) {

	req := NewSqlDelete()
	m.Next() // Consume Delete

	// from
	//u.Debugf("token:  %v", m.Cur())
	if m.Cur().T != lex.TokenFrom {
		return nil, m.ErrMsg("expected FROM")
	} else {
		// table name
		m.Next()
		//u.Debugf("found table?  %v", m.Cur())
		switch m.Cur().T {
		case lex.TokenTable:
			req.Table = m.Cur().V
		default:
			return nil, m.ErrMsg("expected table name")
		}
	}

	m.Next()
	//u.Debugf("cur lex.Token: %s", m.Cur().T.String())
	if errreq := m.parseWhereDelete(req); errreq != nil {
		return nil, errreq
	}
	// we are good
	return req, nil
}
925686
func (tb *CreateTableBuilder) Build() string {
	return fmt.Sprintf("CREATE TABLE %s(\n    %s);\n", tb.name, tb.buildColumns())
}
83594
func (q *ModelQuery) Delete() error {
	if q.lastError != nil {
		return q.lastError
	}
	pk := q.model.pk()
	if len(pk) == 0 {
		return MissingPKError
	}
	_, err := q.builder.Delete(q.model.tableName, HashExp(pk)).WithContext(q.ctx).Execute()
	return err
}
1319568
func build(expr string) (q query, err error) {
	defer func() {
		if e := recover(); e != nil {
			switch x := e.(type) {
			case string:
				err = errors.New(x)
			case error:
				err = x
			default:
				err = errors.New("unknown panic")
			}
		}
	}()
	root := parse(expr)
	b := &builder{}
	return b.processNode(root)
}
710051
func buildDeletePlan(del *sqlparser.Delete, vschema ContextVSchema) (*engine.Delete, error) {
	edel := &engine.Delete{}
	pb := newPrimitiveBuilder(vschema, newJointab(sqlparser.GetBindvars(del)))
	ro, err := pb.processDMLTable(del.TableExprs)
	if err != nil {
		return nil, err
	}
	edel.Query = generateQuery(del)
	edel.Keyspace = ro.eroute.Keyspace
	if !edel.Keyspace.Sharded {
		// We only validate non-table subexpressions because the previous analysis has already validated them.
		if !pb.finalizeUnshardedDMLSubqueries(del.Targets, del.Where, del.OrderBy, del.Limit) {
			return nil, errors.New("unsupported: sharded subqueries in DML")
		}
		edel.Opcode = engine.DeleteUnsharded
		// Generate query after all the analysis. Otherwise table name substitutions for
		// routed tables won't happen.
		edel.Query = generateQuery(del)
		return edel, nil
	}
	if del.Targets != nil || ro.vschemaTable == nil {
		return nil, errors.New("unsupported: multi-table delete statement in sharded keyspace")
	}
	if hasSubquery(del) {
		return nil, errors.New("unsupported: subqueries in sharded DML")
	}
	edel.Table = ro.vschemaTable
	// Generate query after all the analysis. Otherwise table name substitutions for
	// routed tables won't happen.
	edel.Query = generateQuery(del)

	directives := sqlparser.ExtractCommentDirectives(del.Comments)
	if directives.IsSet(sqlparser.DirectiveMultiShardAutocommit) {
		edel.MultiShardAutocommit = true
	}

	edel.QueryTimeout = queryTimeout(directives)
	if ro.eroute.TargetDestination != nil {
		if ro.eroute.TargetTabletType != topodatapb.TabletType_MASTER {
			return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "unsupported: DELETE statement with a replica target")
		}
		edel.Opcode = engine.DeleteByDestination
		edel.TargetDestination = ro.eroute.TargetDestination
		return edel, nil
	}
	edel.Vindex, edel.Values, err = getDMLRouting(del.Where, edel.Table)
	// We couldn't generate a route for a single shard
	// Execute a delete sharded
	if err != nil {
		edel.Opcode = engine.DeleteScatter
	} else {
		edel.Opcode = engine.DeleteEqual
	}

	if edel.Opcode == engine.DeleteScatter {
		if len(edel.Table.Owned) != 0 {
			return edel, errors.New("unsupported: multi shard delete on a table with owned lookup vindexes")
		}
		if del.Limit != nil {
			return edel, errors.New("unsupported: multi shard delete with limit")
		}
	}

	edel.OwnedVindexQuery = generateDeleteSubquery(del, edel.Table)
	return edel, nil
}
314638
func (c *Client) buildDeletions(ctxt context.Context, typ, name string) ([]*dns.ResourceRecordSet, error) {
	// get current records
	//c.logf("retrieving records (type: %s, name: %s, token: %s)", typ, name, token)
	req := c.dnsService.ResourceRecordSets.List(
		c.projectID, c.managedZone,
	)

	var deletions []*dns.ResourceRecordSet
	if err := req.Pages(ctxt, func(page *dns.ResourceRecordSetsListResponse) error {
		for _, rrSet := range page.Rrsets {
			//log.Printf(">>>> name: %s, type: %s, rrdatas: %v", rrSet.Name, rrSet.Type, rrSet.Rrdatas)
			if rrSet.Name != name || rrSet.Type != allowedRecordType {
				continue
			}
			deletions = append(deletions, rrSet)
		}
		return nil

	}); err != nil {
		c.errf("could not retrieve records (type: %s, name: %s): %v", typ, name, err)
		return nil, err
	}
	return deletions, nil
}
1037850
func (db *Database) Delete(sid string, key string) (deleted bool) {
	return db.redis.Delete(makeKey(sid, key)) == nil
}
217301
func (builder *DeleteIndexCommandBuilder) Build() (Command, error) {
	if builder.protobuf == nil {
		panic("builder.protobuf must not be nil")
	}
	return &DeleteIndexCommand{protobuf: builder.protobuf}, nil
}
493444
func Delete(conds ...Cond) *Builder {
	builder := &Builder{cond: NewCond()}
	return builder.Delete(conds...)
}
209498
func (d *Datastore) Delete(key ds.Key) (err error) {
	return d.child.Delete(d.ConvertKey(key))
}
194657
func (db *Database) Delete(key []byte) error {
	db.lock.Lock()
	defer db.lock.Unlock()

	if db.db == nil {
		return errMemorydbClosed
	}
	delete(db.db, string(key))
	return nil
}
738140
func (d *OvsdbDriver) Delete() error {
	if d.ovs != nil {
		log.Infof("Deleting OVS bridge: %s", d.bridgeName)
		for i := 0; i < 3; i++ {
			err := d.createDeleteBridge(d.bridgeName, "", operDeleteBridge)
			if err != nil {
				log.Errorf("Error deleting the bridge %s. Err: %v", d.bridgeName, err)
				time.Sleep(300 * time.Millisecond)
			} else {
				break
			}
		}
		(*d.ovs).Disconnect()
	}

	return nil
}
246234
func (db *DB) delete(t *batch, key []byte) int64 {
	key = db.encodeKVKey(key)
	t.Delete(key)
	return 1
}
80247
func (query Query) Delete() error {
	return transformError(query.repo.adapter.Delete(query, query.repo.logger...))
}
128320
func (m *StaticDataSource) Delete(key driver.Value) (int, error) {
	item := m.bt.Delete(NewKey(makeId(key)))
	if item == nil {
		//u.Warnf("could not delete: %v", key)
		return 0, schema.ErrNotFound
	}
	return 1, nil
}
80602
func (q *BuildQueue) Remove(b Buildable) {
	uuid := b.GetUUID()
	q.mutex.Lock()
	if status, ok := q.buildStatus[uuid]; ok {
		// Only remove the builder UUID from the buildStatus if no
		// build is currently running. If a build is running, the
		// buildStatus continue to be in place until the build has
		// completed.
		if status.currentBuild == nil {
			delete(q.buildStatus, uuid)
		}

		if status.nextBuild != nil {
			num := status.nextBuild.cancelScheduled(q)
			defer status.builder.BuildsDequeued(num, true)
		}
	}
	q.mutex.Unlock()
}