// Dump writes a snapshot of the database in SQL text format. The consistency
// of the snapshot is READ_COMMITTED relative to any other connections
// currently open to this database.
14395
func (c *Conn) Dump(w io.Writer) error {
	if _, err := w.Write([]byte("PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\n")); err != nil {
		return err
	}

	// Get the schema.
	query := `SELECT "name", "type", "sql" FROM "sqlite_master"
              WHERE "sql" NOT NULL AND "type" == 'table' ORDER BY "name"`
	rows, err := c.Query([]string{query}, false, false)
	if err != nil {
		return err
	}
	row := rows[0]
	for _, v := range row.Values {
		table := v[0].(string)
		var stmt string

		if table == "sqlite_sequence" {
			stmt = `DELETE FROM "sqlite_sequence";`
		} else if table == "sqlite_stat1" {
			stmt = `ANALYZE "sqlite_master";`
		} else if strings.HasPrefix(table, "sqlite_") {
			continue
		} else {
			stmt = v[2].(string)
		}

		if _, err := w.Write([]byte(fmt.Sprintf("%s;\n", stmt))); err != nil {
			return err
		}

		tableIndent := strings.Replace(table, `"`, `""`, -1)
		query = fmt.Sprintf(`PRAGMA table_info("%s")`, tableIndent)
		r, err := c.Query([]string{query}, false, false)
		if err != nil {
			return err
		}
		var columnNames []string
		for _, w := range r[0].Values {
			columnNames = append(columnNames, fmt.Sprintf(`'||quote("%s")||'`, w[1].(string)))
		}

		query = fmt.Sprintf(`SELECT 'INSERT INTO "%s" VALUES(%s)' FROM "%s";`,
			tableIndent,
			strings.Join(columnNames, ","),
			tableIndent)
		r, err = c.Query([]string{query}, false, false)
		if err != nil {
			return err
		}
		for _, x := range r[0].Values {
			y := fmt.Sprintf("%s;\n", x[0].(string))
			if _, err := w.Write([]byte(y)); err != nil {
				return err
			}
		}
	}

	// Do indexes, triggers, and views.
	query = `SELECT "name", "type", "sql" FROM "sqlite_master"
			  WHERE "sql" NOT NULL AND "type" IN ('index', 'trigger', 'view')`
	rows, err = c.Query([]string{query}, false, false)
	if err != nil {
		return err
	}
	row = rows[0]
	for _, v := range row.Values {
		if _, err := w.Write([]byte(fmt.Sprintf("%s;\n", v[2]))); err != nil {
			return err
		}
	}

	if _, err := w.Write([]byte("COMMIT;\n")); err != nil {
		return err
	}

	return nil
}
1177334
func (commit *Commit) Dump(wr io.Writer) error {
	funcMap := template.FuncMap{
		"indent": func(content string) (string, error) {
			var out bytes.Buffer
			scanner := bufio.NewScanner(strings.NewReader(content))
			for scanner.Scan() {
				if _, err := fmt.Fprintln(&out, "    ", scanner.Text()); err != nil {
					return "", err
				}
			}
			if err := scanner.Err(); err != nil {
				return "", err
			}
			return out.String(), nil
		},
	}

	tpl := template.Must(template.New("commit").Funcs(funcMap).Parse(commitTemplate))
	return tpl.Execute(wr, commit)
}
42676
func Save(db DB, table string, src interface{}) error {
	return Default.Save(db, table, src)
}
794082
func (sc *SigChain) Dump(w io.Writer) {
	fmt.Fprintf(w, "sigchain dump\n")
	for i, l := range sc.chainLinks {
		fmt.Fprintf(w, "link %d: %+v\n", i, l)
	}
	fmt.Fprintf(w, "last known seqno: %d\n", sc.GetLastKnownSeqno())
	fmt.Fprintf(w, "last known id: %s\n", sc.GetLastKnownID())
}
876272
func (e *Env) Dump() {
	e.RLock()
	fmt.Printf("Name: %v\n", e.name)
	fmt.Printf("Has parent: %v\n", e.parent != nil)
	for k, v := range e.env {
		fmt.Printf("%v = %#v\n", k, v)
	}
	e.RUnlock()
}
1004661
func Dump(data []byte) (
	h *Header,
	tocs []*Toc,
	metrics map[uint64]Metric,
	values map[uint64]*Value,
	instances map[uint64]Instance,
	indoms map[uint64]*InstanceDomain,
	strings map[uint64]*String,
	err error,
) {
	h, err = readHeader(data)
	if err != nil {
		return nil, nil, nil, nil, nil, nil, nil, err
	}

	tocs, err = readTocs(data, h.Toc)
	if err != nil {
		return nil, nil, nil, nil, nil, nil, nil, err
	}

	var ierr, inerr, merr, verr, serr error

	metrics, values, instances, indoms, strings, ierr, inerr, merr, verr, serr = readComponents(data, tocs, h.Version)

	switch {
	case ierr != nil:
		return nil, nil, nil, nil, nil, nil, nil, ierr
	case inerr != nil:
		return nil, nil, nil, nil, nil, nil, nil, inerr
	case merr != nil:
		return nil, nil, nil, nil, nil, nil, nil, merr
	case verr != nil:
		return nil, nil, nil, nil, nil, nil, nil, verr
	case serr != nil:
		return nil, nil, nil, nil, nil, nil, nil, serr
	}

	return
}
969051
func (m *MemLogger) Dump(w io.Writer) (n int, err error) {
	amt := 0
	for i, msg := range m.Messages() {
		if i == 0 {
			amt, err = fmt.Fprintf(w, "\nDUMP LOG:\n")
			n += amt
			if err != nil {
				return
			}
		}
		if msg.Data == nil {
			amt, err = fmt.Fprintf(w, "  %s: %s\n", msg.Level, msg.Msg)
			n += amt
			if err != nil {
				return
			}
		} else {
			amt, err = fmt.Fprintf(w, "  %s: %s: %s\n", msg.Level, msg.Msg, logging.Fields(msg.Data))
			n += amt
			if err != nil {
				return
			}
		}
	}
	return
}
903929
func (db *DB) LDump(key []byte) ([]byte, error) {
	v, err := db.LRange(key, 0, -1)
	if err != nil {
		return nil, err
	} else if len(v) == 0 {
		return nil, err
	}

	return rdb.Dump(rdb.List(v))
}
591677
func (tl *TestLogger) Dump(t *testing.T) {
	t.Log("== Dumping Test Logs ==")
	for _, msg := range tl.Messages {
		t.Logf("lvl: %s, msg: %s", msg.Level, msg.Body)
	}
}
338523
func (m *Position) Dump() {
	switch m.State.MoveMode {
	case MoveModeNone:
		fmt.Printf("Null move\n")
	case MoveModeRapid:
		fmt.Printf("Rapid move\n")
	case MoveModeLinear:
		fmt.Printf("Linear move\n")
	case MoveModeCWArc:
		fmt.Printf("Clockwise arc\n")
	case MoveModeCCWArc:
		fmt.Printf("Counterclockwise arc\n")
	}
	fmt.Printf("   Tool: %d, Tool length: %d, Next tool: %d\n", m.State.ToolIndex, m.State.ToolLengthIndex, m.State.NextToolIndex)
	fmt.Printf("   Feedrate: %g\n", m.State.Feedrate)
	fmt.Printf("   Spindle: %t, clockwise: %t, speed: %g\n", m.State.SpindleEnabled, m.State.SpindleClockwise, m.State.SpindleSpeed)
	fmt.Printf("   Mist coolant: %t, flood coolant: %t\n", m.State.MistCoolant, m.State.FloodCoolant)
	fmt.Printf("   X: %f, Y: %f, Z: %f\n", m.X, m.Y, m.Z)
}
1341834
func Dump(c *cli.Context) {
	hostsfile := AlwaysLoadHostFile(c)
	jsonbytes, err := hostsfile.Hosts.Dump()
	if err != nil {
		MaybeError(c, err.Error())
	}
	fmt.Println(fmt.Sprintf("%s", jsonbytes))
}
740673
func _dump_fixture(filename string, buf []byte) {
	fmt.Printf("writing fixture %s...\n", filename)
	if err := ioutil.WriteFile("./fixtures/"+filename, buf, 0644); err != nil {
		panic(err)
	}
}
91899
func (p *PreFilter) Dump(to []string) ([]string, int64) {
	p.mutex.RLock()
	defer p.mutex.RUnlock()
	for i := prefixesV4Dyn; i < mapCount; i++ {
		to = p.dumpOneMap(i, to)
	}
	return to, p.revision
}
840020
func (b *Buffer) DumpTo(w io.Writer) (written int, err error) {
	var n int
	for _, buf := range b.bufs {
		if err == nil {
			n, err = w.Write(buf)
			written += n
		}
		putBuf(buf)
	}

	if err == nil {
		n, err = w.Write(b.Buf)
		written += n
	}
	putBuf(b.toPool)

	b.bufs = nil
	b.Buf = nil
	b.toPool = nil

	return
}
1318026
func (engine *Engine) DumpAll(w io.Writer) error {
	return engine.dumpAll(w, engine.dialect.DBType())
}
1304818
func (rwt *RWTree) Dump() string {
	tree := treeprint.New()
	AddTreePrintTree("ReadTree", tree, rwt)
	AddTreePrintTree("WriteTree", tree, rwt.tree)
	return tree.String()
}
265936
func (db *memDB) Snapshot() View {
	return &memdbView{
		txn: db.store.Txn(false),
	}
}