chaisql / chai

Modern embedded SQL database
MIT License
1.56k stars 95 forks source link

CLI: restore from dump.sql to new db fails depending on the data in the dump.sql it seems. #430

Closed gedw99 closed 2 years ago

gedw99 commented 3 years ago

What version of Genji are you using?

tip

Does this issue reproduce with the latest release?

yes

What did you do?

repro:

print:

dep:
    git clone https://github.com/genjidb/genji

build:
    # puts CLI to gopath
    cd genji/cmd/genji && go build -o $(GOPATH)/bin/genji .
run:
    genji -h

DB_PATH=$(PWD)/data/my.db
DUMB_PATH=$(PWD)/data/my.sql
RESTORE_DB_PATH=$(PWD)/data/my_restore.db
DB_ENGINE=badger
#DB_ENGINE=bolt

data-delete:
    rm -rf ./data
    rm -rf *.db
    rm -rf data_*

run-json-insert: data-delete
    # insert
    genji insert -a -e $(DB_ENGINE) --db $(DB_PATH) '{"a": 1}' '{"a": 2}'

    # dump
    # to std out
    genji dump -e $(DB_ENGINE) $(DB_PATH)
    # to file
    genji dump -e $(DB_ENGINE) -f $(DUMB_PATH) $(DB_PATH)

    # restore
    genji restore -e $(DB_ENGINE) $(DUMB_PATH) $(RESTORE_DB_PATH)

run-curl-insert: data-delete

    # insert
    curl https://api.github.com/repos/genjidb/genji/issues | genji insert -a -e $(DB_ENGINE) --db $(DB_PATH)

    # dump
    # to std out
    genji dump -e $(DB_ENGINE) $(DB_PATH)
    # to file
    genji dump -e $(DB_ENGINE) -f $(DUMB_PATH) $(DB_PATH)

    # restore
    genji restore -e $(DB_ENGINE) $(DUMB_PATH) $(RESTORE_DB_PATH)

run-std-insert: data-delete

    # insert
    echo '[{"a": 1},{"a": 2}]' | genji insert -a -e $(DB_ENGINE) --db $(DB_PATH)

    # to std out
    genji dump -e $(DB_ENGINE) $(DB_PATH)
    # to file
    genji dump -e $(DB_ENGINE) -f $(DUMB_PATH) $(DB_PATH) 

    genji restore -e $(DB_ENGINE) $(DUMB_PATH) $(RESTORE_DB_PATH) 

What did you expect to see?

restore from dump.sql to new db should work.

What did you see instead?

make run-std-insert works fine make make run-curl-insert fails with

error: found \r, expected } at line 1, char 2441

What Go version and environment are you using?

go version go1.16.6 darwin/amd64

go env Output
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/apple/Library/Caches/go-build"
GOENV="/Users/apple/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/apple/workspace/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/apple/workspace/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/opt/go/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/apple/workspace/go/src/github.com/gedw99/notes/db/genji/genjidb__genji/genji/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wp/ff6sz9qs6g71jnm12nj2kbyw0000gp/T/go-build1815681598=/tmp/go-build -gno-record-gcc-switches -fno-common"

asdine commented 2 years ago

Fixed by #439