// Insert stores the CertificateRelease in the database. It does no
// checking to determine if the CertificateRelease is already in the
// database, and will fail if it's already present in the database
// (due to UNIQUE constraints).
542596
func (cr *CertificateRelease) Insert(tx *sql.Tx) error {
	query := fmt.Sprintf("INSERT INTO %ss (ski, serial, release) VALUES (?, ?, ?)", cr.Release.table())
	_, err := tx.Exec(query, cr.Certificate.SKI, cr.Certificate.Serial, cr.Release.Version)
	return err
}
263086
func (rev *Revocation) Insert(tx *sql.Tx) error {
	_, err := tx.Exec(`INSERT INTO revocations (ski, revoked_at, mechanism, reason) VALUES (?, ?, ?, ?)`, rev.SKI, rev.RevokedAt, rev.Mechanism, rev.Reason)
	return err
}
1338474
func (n *Node) insert(comparator Comparator, key *Key) *Key {
	var overwrittenKey *Key
	i := n.search(comparator, key.Value)
	if i == len(n.ChildValues) {
		n.ChildValues = append(n.ChildValues, key.Value)
	} else {
		if n.ChildValues[i] == key.Value {
			overwrittenKey = n.ChildKeys[i]
			n.ChildKeys[i] = key
			return overwrittenKey
		} else {
			n.ChildValues = append(n.ChildValues, 0)
			copy(n.ChildValues[i+1:], n.ChildValues[i:])
			n.ChildValues[i] = key.Value
		}
	}

	if n.IsLeaf && i == len(n.ChildKeys) {
		n.ChildKeys = append(n.ChildKeys, key)
	} else {
		n.ChildKeys = append(n.ChildKeys, nil)
		copy(n.ChildKeys[i+1:], n.ChildKeys[i:])
		n.ChildKeys[i] = key
	}

	return overwrittenKey
}
588830
func (ag *AuthGroup) Insert(db XODB) error {
	var err error

	// if already exist, bail
	if ag._exists {
		return errors.New("insert failed: already exists")
	}

	// sql query
	const sqlstr = `INSERT INTO django.auth_group (` +
		`name` +
		`) VALUES (` +
		`:1` +
		`) RETURNING id /*lastInsertId*/ INTO :pk`

	// run query
	XOLog(sqlstr, ag.Name, nil)
	res, err := db.Exec(sqlstr, ag.Name, nil)
	if err != nil {
		return err
	}

	// retrieve id
	id, err := res.LastInsertId()
	if err != nil {
		return err
	}

	// set primary key and existence
	ag.ID = float64(id)
	ag._exists = true

	return nil
}
1301639
func (session *Session) Insert(beans ...interface{}) (int64, error) {
	var affected int64
	var err error

	if session.IsAutoClose {
		defer session.Close()
	}

	for _, bean := range beans {
		sliceValue := reflect.Indirect(reflect.ValueOf(bean))
		if sliceValue.Kind() == reflect.Slice {
			size := sliceValue.Len()
			if size > 0 {
				if session.Engine.SupportInsertMany() {
					cnt, err := session.innerInsertMulti(bean)
					session.resetStatement()
					if err != nil {
						return affected, err
					}
					affected += cnt
				} else {
					for i := 0; i < size; i++ {
						cnt, err := session.innerInsert(sliceValue.Index(i).Interface())
						session.resetStatement()
						if err != nil {
							return affected, err
						}
						affected += cnt
					}
				}
			}
		} else {
			cnt, err := session.innerInsert(bean)
			session.resetStatement()
			if err != nil {
				return affected, err
			}
			affected += cnt
		}
	}

	return affected, err
}
481666
func (r *Relation) Insert(t *Tuple) error {
	// Maybe do somthing like lock read/write here
	// Maybe index
	r.rows = append(r.rows, t)
	return nil
}
907225
func (q *Query) Insert(values ...interface{}) (Result, error) {
	if q.stickyErr != nil {
		return nil, q.stickyErr
	}

	model, err := q.newModel(values...)
	if err != nil {
		return nil, err
	}

	if q.model != nil && q.model.Table().HasFlag(BeforeInsertHookFlag) {
		err = q.model.BeforeInsert(q.ctx, q.db)
		if err != nil {
			return nil, err
		}
	}

	query := newInsertQuery(q)
	res, err := q.returningQuery(model, query)
	if err != nil {
		return nil, err
	}

	if q.model != nil {
		err = q.model.AfterInsert(q.ctx, q.db)
		if err != nil {
			return nil, err
		}
	}

	return res, nil
}
565889
func (r *RemoteProofLinks) Insert(link RemoteProofChainLink, err ProofError) {
	key := link.TableKey()
	if len(key) == 0 {
		return
	}
	r.links[key] = append(r.links[key], ProofLinkWithState{link: link, state: ProofErrorToState(err)})
}
114384
func (aug *AuthUserGroup) Insert(db XODB) error {
	var err error

	// if already exist, bail
	if aug._exists {
		return errors.New("insert failed: already exists")
	}

	// sql query
	const sqlstr = `INSERT INTO django.auth_user_groups (` +
		`user_id, group_id` +
		`) VALUES (` +
		`:1, :2` +
		`) RETURNING id /*lastInsertId*/ INTO :pk`

	// run query
	XOLog(sqlstr, aug.UserID, aug.GroupID, nil)
	res, err := db.Exec(sqlstr, aug.UserID, aug.GroupID, nil)
	if err != nil {
		return err
	}

	// retrieve id
	id, err := res.LastInsertId()
	if err != nil {
		return err
	}

	// set primary key and existence
	aug.ID = float64(id)
	aug._exists = true

	return nil
}
903616
func (ipt *IPTables) Insert(table, chain string, pos int, rulespec ...string) error {
	cmd := append([]string{"-t", table, "-I", chain, strconv.Itoa(pos)}, rulespec...)
	return ipt.run(cmd...)
}
69852
func Insert(topic *db.Topic) string {
	return db.Conn.Insert(db.TopicCollection, topic)
}
1039873
func (t *Trie) Insert(key string) {
	curNode := t.root
	for _, v := range key {
		if curNode.child[v] == nil {
			curNode.child[v] = newNode()
		}
		curNode = curNode.child[v]
	}

	if !curNode.exists {
		// increment when new rune child is added.
		t.size++
		curNode.exists = true
	}
	// value is stored for retrieval in future.
	curNode.value = key
}
665618
func (b *Bucket) Insert(key string, value interface{}, expiry uint32) (Cas, error) {
	cas, _, err := b.insert(key, value, expiry)
	return cas, err
}
17295
func (au *AuthUser) Insert(db XODB) error {
	var err error

	// if already exist, bail
	if au._exists {
		return errors.New("insert failed: already exists")
	}

	// sql insert query, primary key provided by autoincrement
	const sqlstr = `INSERT INTO auth_user (` +
		`password, last_login, is_superuser, first_name, last_name, email, is_staff, is_active, date_joined, username` +
		`) VALUES (` +
		`?, ?, ?, ?, ?, ?, ?, ?, ?, ?` +
		`)`

	// run query
	XOLog(sqlstr, au.Password, au.LastLogin, au.IsSuperuser, au.FirstName, au.LastName, au.Email, au.IsStaff, au.IsActive, au.DateJoined, au.Username)
	res, err := db.Exec(sqlstr, au.Password, au.LastLogin, au.IsSuperuser, au.FirstName, au.LastName, au.Email, au.IsStaff, au.IsActive, au.DateJoined, au.Username)
	if err != nil {
		return err
	}

	// retrieve id
	id, err := res.LastInsertId()
	if err != nil {
		return err
	}

	// set primary key and existence
	au.ID = int(id)
	au._exists = true

	return nil
}
145545
func (pm *peersManager) Insert(infoHash string, peer *Peer) {
	pm.Lock()
	if _, ok := pm.table.Get(infoHash); !ok {
		pm.table.Set(infoHash, newKeyedDeque())
	}
	pm.Unlock()

	v, _ := pm.table.Get(infoHash)
	queue := v.(*keyedDeque)

	queue.Push(peer.CompactIPPortInfo(), peer)
	if queue.Len() > pm.dht.K {
		queue.Remove(queue.Front())
	}
}
478989
func Insert(collectionName string, doc interface{}) error {
	connection := shared.Connection()
	if connection == nil {
		log.Println("MongoConn", connection)
		return errors.New("No connection to database server")
	}
	collection := connection.DB(variables.DBName).C(collectionName)
	err := collection.Insert(doc)
	if err != nil {
		return err
	}

	return nil
}
441252
func (ap *AuthPermission) Insert(db XODB) error {
	var err error

	// if already exist, bail
	if ap._exists {
		return errors.New("insert failed: already exists")
	}

	// sql insert query, primary key provided by sequence
	const sqlstr = `INSERT INTO public.auth_permission (` +
		`name, content_type_id, codename` +
		`) VALUES (` +
		`$1, $2, $3` +
		`) RETURNING id`

	// run query
	XOLog(sqlstr, ap.Name, ap.ContentTypeID, ap.Codename)
	err = db.QueryRow(sqlstr, ap.Name, ap.ContentTypeID, ap.Codename).Scan(&ap.ID)
	if err != nil {
		return err
	}

	// set existence
	ap._exists = true

	return nil
}