Installation from Source Code

Install Go Language

Go to the website https://golang.org/ and install the Go language.

Windows Hack

For Microsoft Windows, a small hack is needed.

By default, on Windows, Go does not allow deletion of open files, as is the case in Linux.

Rsql relies on this behaviour. So, ONLY IN WINDOWS, we must make a small change in the Go standard library, as described in the following issue:

code review 8203043: syscall: Use FILE_SHARE_DELETE flag when opening files … (issue 8203043)
https://groups.google.com/forum/#!topic/golang-dev/dS2GnwizSkk

In the file C:\Go\src\syscall\syscall_windows.go, in the function Open(path string, mode int, perm uint32), the line declaring the variable sharemode

func Open(path string, mode int, perm uint32) (fd Handle, err error) {
    ...

    sharemode := uint32(FILE_SHARE_READ | FILE_SHARE_WRITE) <--- add flag FILE_SHARE_DELETE to this line

    ...

must be changed to

func Open(path string, mode int, perm uint32) (fd Handle, err error) {
    ...

    sharemode := uint32(FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE)

    ...

Then, recompile the standard library packages:

go install -a -v std

After having downloaded the rsql source code, you should use the -a option the first time you will compile rsql_server, rcli and rsqlctl.
This -a option forces the recompilation of all packages they import, and which may depend on the modified syscall package.

go install -a rsql/rsql_server
go install -a rsql/rcli
go install -a rsql/rsqlctl

Subsequent compilations will not need the -a option.

Download the source code

Installation of the tool tool_tblfile_reader

If you want to compile tool_tblfile_reader, which is a tool that displays on the terminal the B-tree content of a table or index file:

The argument must be the path of a table file or index file. You can find it by typing, for the tables in mytest database:

$ rcli -Q='use mytest; show id t'

2017/03/14 17:43:38 --- executing batch <query string>:1 ---
TABLE                                               FILEPATH
--------------------------------------------------  --------------------
mytest.dbo.country                                  data/d102/s0/t7000001
mytest.dbo.customer                                 data/d102/s0/t7000003
       idx_name                                            index/d102/s0/i7000004
       idx_name_birthdate                                  index/d102/s0/i7000005
mytest.dbo.items                                    data/d102/s0/t7000009
mytest.dbo.orders                                   data/d102/s0/t7000006
       idx_custid                                          index/d102/s0/i7000007
       idx_order_date                                      index/d102/s0/i7000008
mytest.dbo.product                                  data/d102/s0/t7000002

element count: 5

2017/03/14 17:43:38 return code: 0

To display the content of the data file for the country table:

$ tool_tblfile_reader /var/opt/rsql1/data//d102/s0/t7000001

type: TD_TYPE_BASE_TABLE, dbid.schema.(gtblid)tblid: 102.0.(7000001)7000001
highest allocated page no, excepted allocator pages, is page_no=2
PAGE_SIZE=16384
PZONE_NUMBER_OF_PAGES_IN_ZONE=65536

---------- PAGE_INFO: 1 ---------
pinf_column_array_capacity          : 1024
pinf_nk_array_capacity              : 12
pinf_nk_array_coll_capacity         : 360
|
pinf_column_count                   : 3
pinf_column_base_seqno              : 0,1,2
pinf_column_datatypes               : 0:BIGINT, 1:INT, 2:VARCHAR
pinf_nk_count                       : 1
pinf_nk_base_seqno                  : 1
pinf_nk_collations                  : []
|
pinf_next_rowid                     : 10
pinf_next_identity                  : -9223372036854775807
|
pinf_root_page_no                   : 2
|
pinf_total_leaf_tuples_count        : 10
pinf_total_leaf_pages _count        : 1
|
pinf_zone_bitmaps_count             : 1
pinf_zone_bitmap_array_size         : 8192
|
pinf_zone_rootbitmap_array_size     : 2048

---------- LEAF: 2 ---- 176/16134 16310-----
pg_tuple_count: 10, pg_prev_no: BOT, pg_next_no: EOT
|                   0|          0|USA       |
|                   1|          1|France    |
|                   2|          2|Italy     |
|                   3|          3|Germany   |
|                   4|          4|Russia    |
|                   5|          5|Japan     |
|                   6|          6|China     |
|                   7|          7|Sweden    |
|                   8|          8|New Zeala~|
|                   9|          9|UK        |

Total number of tuples read in leaf pages: 10