RedBeardLab / rediSQL

Redis module that provides a completely functional SQL database
https://redisql.com
Other
1.55k stars 150 forks source link

redisql.copy command delete the source db? #59

Closed xiao321 closed 5 years ago

xiao321 commented 5 years ago

redisql version 0.7.1

redisql.copy test_a test_b OK redisql.exec test_a "select name from sqlite_master where type='table'" (nil) (10.05s) redisql.exec test_b "select name from sqlite_master where type='table'" 1) 1) "RediSQLMetadata" 2) 1) "a"

siscia commented 5 years ago

Indeed there was this bug up to version 0.9.0 reported here: https://github.com/RedBeardLab/rediSQL/issues/38

It was fixed on version 0.9.1

Do you mind to try with a newer version and let me know if the bug persist?

xiao321 commented 5 years ago

Indeed there was this bug up to version 0.9.0 reported here:

38

It was fixed on version 0.9.1

Do you mind to try with a newer version and let me know if the bug persist?

i will. another problem : my AOF file can not record the "redisql.exec db insert ..." command . so when my redis broken,i can not recover. i do not know why?

siscia commented 5 years ago

What version are you talking about?

AOF was a PRO features in RediSQL < 1.0.0

You should have a RDB file thought!

xiao321 commented 5 years ago

What version are you talking about?

AOF was a PRO features in RediSQL < 1.0.0

You should have a RDB file thought!

redisql 0.7.1. i will try the new version.

siscia commented 5 years ago

I am about to release the version 1.0.1 tomorrow morning (China time) or this evening (Europe time).

It does introduce few small enhancement, nothing big, but you may be interested.

siscia commented 5 years ago

Hi @xiao321

I just released the version 1.0.1

As always you can find it on the release part, on payhip and on docker

Let me know if this works for you :)

Feel free to close the issue if it works for you!

Cheers, Simone

xiao321 commented 5 years ago

Hi @xiao321

I just released the version 1.0.1

As always you can find it on the release part, on payhip and on docker

Let me know if this works for you :)

Feel free to close the issue if it works for you!

Cheers, Simone

the version 1.0.1 works! i can run the redisql.copy successfully. but i meet another problems. 1、 when i restart the redis with the rdb file. i get a warning "Warning trying to load from RDB: Couldn't find the path of the database in the metadata table." the redis is ok, can I ignore it?

2、the math function "round" can not work 127.0.0.1:6379> redisql.exec test "select number from test" 1) 1) "10.300000000000001" 2) 1) "9" 127.0.0.1:6379> redisql.exec test "select round(number,2) from test" 1) 1) "10.300000000000001" 2) 1) "9" 127.0.0.1:6379>

siscia commented 5 years ago

Hi!

Great I am glad!

For what concerns 1. you should be able to just ignore that error. Please, just to stay on the safe side, make sure that the database is actually there and working. If it was a database backed by a file, like one created with: REDISQL.CREATE_DB foo "/home/user/foo.sqlite" is possible that now the database is not backed by a file anymore, but is a in-memory database. The solution is to just REDISQL.COPY the database into another database backed by file.

For what concern 2. I am afraid there is no much we can do. SQLite returns a float and we send a float to redis, redis use a text protocol and encode the float in the way you see and it returns that number. The solution would be to multiply by 100, then cast to integer, and finally obtain the original number by dividing by 100 in client code. I understand is sub-optimal, but there is really nothing I can do...
The code that returns a float is here: https://github.com/RedBeardLab/rediSQL/blob/master/redisql_lib/src/redis.rs#L321 While here is the documentation from the RedisModule part: https://redis-module-redoc.readthedocs.io/en/latest/API/#rm_replywithdouble

Cheers, Simone

xiao321 commented 5 years ago

Hi!

Great I am glad!

For what concerns 1. you should be able to just ignore that error. Please, just to stay on the safe side, make sure that the database is actually there and working. If it was a database backed by a file, like one created with: REDISQL.CREATE_DB foo "/home/user/foo.sqlite" is possible that now the database is not backed by a file anymore, but is a in-memory database. The solution is to just REDISQL.COPY the database into another database backed by file.

For what concern 2. I am afraid there is no much we can do. SQLite returns a float and we send a float to redis, redis use a text protocol and encode the float in the way you see and it returns that number. The solution would be to multiply by 100, then cast to integer, and finally obtain the original number by dividing by 100 in client code. I understand is sub-optimal, but there is really nothing I can do... The code that returns a float is here: https://github.com/RedBeardLab/rediSQL/blob/master/redisql_lib/src/redis.rs#L321 While here is the documentation from the RedisModule part: https://redis-module-redoc.readthedocs.io/en/latest/API/#rm_replywithdouble

Cheers, Simone

OK,thanks for your help ! Y(^_^)Y