顯示具有 Database 標籤的文章。 顯示所有文章
顯示具有 Database 標籤的文章。 顯示所有文章

2025-02-04

Valkey database

在更新 thiredis 之後,需要測試 thiredis 的關係,所以需要一個 Redis 協定相容的資料庫,openSUSE 目前採用的是 Valkey,所以筆記一下他的安裝部份。


Valkey is an open-source in-memory storage, used as a distributed, in-memory key–value database, cache and message broker, with optional durability.

在 openSUSE 安裝的指令:

sudo zypper in valkey

而下面是 README.SUSE 的簡要內容。需要使用 root 的權限進行設定。

  1. cp -a /etc/valkey/default.conf.example /etc/valkey/instancename.conf

    使用 -a 是因為要保留檔案的 permissions 設定,如果沒有使用,也可以使用下列的指令設定:
    chown root:valkey /etc/valkey/sentinel-instancename.conf
    chmod u=rw,g=rw,o= /etc/valkey/sentinel-instancename.conf

  2. change at least pidfile, logfile and dir setting

    pidfile /run/valkey/instancename.pid
    logfile /var/log/valkey/instancename.log
    dir /var/lib/valkey/instancename/

  3. create the database dir:
    install -d -o valkey -g valkey -m 0750 /var/lib/valkey/instancename/

  4. systemctl start valkey@instancename
  5. systemctl enable valkey@instancename
    (optional: 設定開機會啟動 valkey)

  6. To stop/restart all instances at the same time use:
    systemctl restart valkey.target
    systemctl stop valkey.target

如果要查看目前的狀態,使用:

sudo systemctl status valkey@instancename

相關連結

2024-05-17

The race to replace Redis

The race to replace Redis
redis (Tcler's Wiki)


雖然有點晚了(在三月發生的事情),不過事件持續中。Redis 資料庫更改授權,從 7.4 開始就不是 Open Source 軟體。Redeis 目前使用雙授權,其中 Server Side Public License (SSPL) 與 MongoDB 所使用的相同,不是 OSI 所認證的自由軟體授權(Redis 另外一個授權也不是!)。也因此有好幾個  Forks 出現,而各個 Linux distribution 需要找出可用的選項。

所以如果有人寫文章列出 Open Source Database,結果有 MongoDB(接下來 Redis 也是如此),你就知道這個文章的作者真的只是搜尋網路然後列出個名單,而他並不用心。

2023-11-30

tcl-monetdbe v0.2.0

 tcl-monetdbe


Tcl extension and TDBC driver for MonetDB Embedded.

MonetDB Embedded (MonetDB/e) 已經出現了一段時間,是 MonetDB 的 embedded solution。因為 MonetDB 我只是用來測試一些想法,所以之前一直沒有使用 MonetDB/e 的場合。

不過因為電腦上有裝 MonetDB 而且我也有安裝 MonetDB embedded library,所以考慮了一下,最近嘗試寫一個 Tcl extension 測試看看使用的情況。

2023-11-23

tdbc::mysql

最近我在整理自己的作業環境,這才發現 libmariadb-devel 對於 tdbc::mysql 而言是非必要的(以前因為 so suffixes 的關係需要裝,但是其實 tdbc::mysql 已經修正了,只是我沒注意到)。下面就是目前的 code:

static const char *const mysqlStubLibNames[] = {
    /* @LIBNAMES@: DO NOT EDIT THESE NAMES */
    "mariadbclient", "mariadb", "mysqlclient_r", "mysqlclient", "mysql", NULL
    /* @END@ */
};

/* ABI Version numbers of the MySQL API that we can cope with */

static const char mysqlSuffixes[][4] = {
    "", ".3", ".21", ".20", ".19", ".18", ".17", ".16", ".15"
};

如果說 MariaDB 是為了防止 Oracle 更改 MySQL 的授權而成立的,可是那為什麼 Michael Widenius 除了基金會,還又成立了一家企業?嘴上說我不是要用 MySQL 或者是 MariaDB 賺錢,實際上的行為卻完全相反,這是一個與說法衝突的行為(還可以參考 Uproar: MariaDB Corp. veers away from open source)。如果採用 MySQL 是被騙第一次,那 MariaDB 被騙第二次的人就應該要自我檢討了。我是說如果你擔心 Oracle 會對 MySQL 做出什麼損壞開放原始碼的事情,那麼 Michael Widenius 也可以重施故技,又賣掉 MariaDB 企業或者是上市賺取利益。

也就是說,我不認為應該要採用 MySQL 或者是 MariaDB。當然不是所有人都可以直接切換到其它的資料庫,這個時候可以考慮採用 MySQL protocol 並且高度相容的其它資料庫,在這個情況下,client 端的 source code 的變動理論上要很少,而 server 端則是換掉 MySQL 或者是 MariaDB,採用其它相容方案的資料庫。

在這個情況下,MySQL/MariaDB client API 是很重要的,而又剛好 MySQL/MariaDB client API 極大多數是 LGPL 或者是較為寬鬆的條款,只要採用動態連結的使用方式就可以在商業環境下使用,所以保留 MySQL/MariaDB client library,然後從MySQL 或者是 MariaDB 遷移出去。 

不過如果是因為學習 LAMP 架構而需要安裝一個資料庫,或者是撰寫開放原始碼的軟體,那麼 MySQL 與 MariaDB 我想可以考慮 MariaDB;理由也很簡單,因為大多數的 Linux distribution 都有內建的套件可以安裝(只是版本可能會比較舊不是最新的)。然後要小心資料庫專屬的功能,小心的避掉廠商鎖定的風險。

2023-11-15

DuckDB and ODBC

 DuckDB 是一套 in-process SQL OLAP database management system,所以是使用 DuckDB 在單機分析數據,也可以內嵌到應用程式。

因為有提供 ODBC interface,所以我使用 TDBC-ODBC 測試一下是否可以連線。

下載後解開壓縮檔,將二個檔案放在某個目錄(我是放在家目錄下的 Programs)。

首先在 Linux 執行需要有安裝 unixODBC。雖然 DuckDB 有提供 unixodbc_setup.sh 可以建立設定檔,不過需要python 以及相關的函式庫有安裝,所以我在執行時發生錯誤。不過只是要建立 ODBC 設定,DuckDB 在文件上也有提供相關的內容,所以自行在家目錄下建立以下二個檔案即可。

.odbc.ini

[DuckDB]
Driver = DuckDB Driver
Database=:memory:

.odbcinst.ini

[ODBC]
Trace = yes
TraceFile = /tmp/odbctrace

[DuckDB Driver]
Driver = /home/danilo/Programs/libduckdb_odbc.so

接下來就寫一個簡單的 script 測試。

package require tdbc::odbc

set connStr "DSN=DuckDB;"
if {[catch {tdbc::odbc::connection create db $connStr}]} {
   puts "Connection failed."
   exit
}

set statement [db prepare {SELECT VERSION() as version}]

puts "DuckDB version:"
$statement foreach row {
    puts [dict get $row version]
}

$statement close
db close

如果有印出 DuckDB 的版本,就表示可以透過 ODBC 來使用 DuckDB 了。

2023-11-14

tclcubrid v0.9.6

Source code
tclcubrid


附帶一提,要注意的是,CUBRID 使用 NCURSES 5 API,所以在 openSUSE 上使用,如果 NCRUSES 版本已升級到 6, 那麼需要安裝 NCURSES 6 所提供的與 5 ABI 相容的函式庫:

sudo zypper in libncurses5

我看了一下 tclcubrid 在 CUBRID 11.3 的執行情況,發現會有問題,所以更新了 CCI header files 嘗試解決問題;以及 CUBRID 10.2 有加入 JSON type,我在 v0.9.6 也嘗試加入 JSON type 的支援。

2021-07-25

tcl-gremlin

tcl-gremlin: Gremlin Server driver for Tcl


上一篇文章的延續,整合成為一個套件。只有簡單的測試過,目前已經可以使用 Websocket 連線 Gremlin server,送出 query string 然後取得結果。

2018-12-08

Apache Rivet and DIO

Apache Rivet 提供了 DIO 套件存取資料庫。而 DIO::Postgresql 是以 Pgtcl 作為底層的套件。

我先在 PostgreSQL 建立一個表格 Notes 作為測試:
create table if not exists Notes (id uuid DEFAULT md5(random()::text || clock_timestamp()::text)::uuid, 
title varchar(255), body text, created timestamp, PRIMARY KEY (id));


接下來撰寫一個簡單的程式測試 Apache Rivet。

建立檔案 tdbcnoteservices.tcl,將資料庫的實作部份放在這裡(使用 tdbc::postgres):
package require tdbc::postgres

proc getAllNotes {} {
    set rows {}

    tdbc::postgres::connection create db -user danilo -password danilo -port 5432
    set stmt [db prepare {select * from Notes order by created}]
    $stmt execute
    set rows [$stmt allrows -as lists]

    $stmt close
    db close

    return $rows
}

proc getNote {id} {
    set myparams [dict create id $id]

    tdbc::postgres::connection create db -user danilo -password danilo -port 5432
    set stmt [db prepare {select * from Notes where id = :id}]
    $stmt execute $myparams
    set rows [$stmt allrows -as lists]
   
    $stmt close
    db close

    return $rows    
}

proc addNote {title body} {
    set myparams [dict create title $title body $body]
    tdbc::postgres::connection create db -user danilo -password danilo -port 5432
    set stmt [db prepare {INSERT INTO Notes (Title, Body, Created) values (:title, :body, now())}]
    set resultset [$stmt execute $myparams]
    set rowcount [$resultset rowcount]

    $resultset close
    $stmt close
    db close

    return $rowcount
}

proc updateNote {id title body} {
    set myparams [dict create id $id title $title body $body]
    tdbc::postgres::connection create db -user danilo -password danilo -port 5432
    set stmt [db prepare {UPDATE Notes SET Title = :title, Body = :body where Id = :id}]
    set resultset [$stmt execute $myparams]
    set rowcount [$resultset rowcount]

    $resultset close
    $stmt close
    db close

    return $rowcount
}

proc deleteNote {id} {
    set myparams [dict create id $id]
    tdbc::postgres::connection create db -user danilo -password danilo -port 5432
    set stmt [db prepare {DELETE FROM Notes where Id = :id}]
    set resultset [$stmt execute $myparams]
    set rowcount [$resultset rowcount]

    $resultset close
    $stmt close
    db close

    return $rowcount
}


再來就是測試我比較不熟悉的 DIO 套件,建立 dionoteservices.tcl 檔案,然後實作同樣的功能:
package require DIO

proc getAllNotes {} {
    set rows {}
    set db [::DIO::handle Postgresql -host localhost -port 5432 -user danilo -pass danilo -db danilo]

    set rows [list]
    $db forall {select id, title, body, created from Notes order by created} row {
        set myrow [list $row(id) $row(title) $row(body) $row(created)]    
        lappend rows $myrow
    }

    $db destroy
    return $rows
}

proc getNote {id} {
    set rows {}    
    set db [::DIO::handle Postgresql -host localhost -port 5432 -user danilo -pass danilo -db danilo]

    set query "select id, title, body, created from Notes where id = '$id'"
    set rows [list]
    $db forall $query row {
        set myrow [list $row(id) $row(title) $row(body) $row(created)]
        lappend rows $myrow
    }

    $db destroy
    return $rows    
}

proc addNote {title body} {
    set db [::DIO::handle Postgresql -host localhost -port 5432 -user danilo -pass danilo -db danilo]

    set arrayVar(Title) $title
    set arrayVar(Body) $body
    set arrayVar(Created) "now()"
    set rowcount [$db insert Notes arrayVar]

    $db destroy
    return $rowcount
}

proc updateNote {id title body} {
    set db [::DIO::handle Postgresql -host localhost -port 5432 -user danilo -pass danilo -db danilo]

    set arrayVar(Id) $id
    set arrayVar(Title) $title
    set arrayVar(Body) $body
    set rowcount [$db update arrayVar -table Notes -keyfield Id]

    $db destroy
    return $rowcount
}

proc deleteNote {id} {
    set db [::DIO::handle Postgresql -host localhost -port 5432 -user danilo -pass danilo -db danilo]

    set rowcount [$db delete $id -table Notes -keyfield Id]

    $db destroy    
    return $rowcount
}


這樣只要 source 的檔案不同,就可以測試不同的資料庫實作部份。

2018-09-05

MonetDB and SHA224_Update

在 openSUSE 升版到 LEAP 15.0 以後,我發現編譯 MonetDB Mar2018 SP1 成功,但是 MonetDB mapi library 在 load library 使用時載入失敗。一開始出現的是 SHA224_Update undefined,這是 openSSL 的 function,所以我嘗試在 configure 刪除 SHA224_Update 的部份。(更新:按照 MonetDB 的更新記錄,Mar2018 SP1 和 Aug2018 都會有這問題)

然後就出現更奇怪的結果,結果會發生 mnstr_settimeout undefined 的問題。但是這是 MonetDB stream library 的 function,所以有可能 MonetDB 在 mapi library 連結時的設定有問題。

目前還沒有解法。所以 tclmonetdb 會載入 mapi library 失敗,導致無法使用。

使用 nm 檢查 libmapi.so 的情況:
nm -D libmapi.so.10.1.0
                 U block_stream
0000000000213329 B __bss_start
                 U calloc
                 U close
                 U closedir
                 U close_stream
                 U connect
                 U __ctype_b_loc
                 w __cxa_finalize
0000000000213329 D _edata
0000000000213360 B _end
                 U __errno_location
                 U exit
                 U fclose
                 U fflush
                 U fgets
000000000000f5ac T _fini
                 U fopen
                 U __fprintf_chk
                 U fputc
                 U fputs
                 U free
                 U freeaddrinfo
                 U fwrite
                 U gai_strerror
                 U getaddrinfo
                 U gettimeofday
                 U getuid
                 w __gmon_start__
00000000000030e8 T _init
                 U isa_block_stream
                 w _ITM_deregisterTMCloneTable
                 w _ITM_registerTMCloneTable
                 w _Jv_RegisterClasses
                 U malloc
0000000000007f10 T mapi_bind
00000000000080a0 T mapi_bind_numeric
0000000000007fc0 T mapi_bind_var
000000000000a8a0 T mapi_cache_freeup
0000000000008ea0 T mapi_cache_limit
000000000000a7a0 T mapi_cache_shuffle
0000000000008110 T mapi_clear_bindings
00000000000083e0 T mapi_clear_params
00000000000074b0 T mapi_close_handle
000000000000a6a0 T mapi_connect
0000000000007780 T mapi_destroy
0000000000007740 T mapi_disconnect
0000000000006d30 T mapi_error
0000000000006d40 T mapi_error_str
000000000000bf00 T mapi_execute
0000000000006d60 T mapi_explain
0000000000006e20 T mapi_explain_query
0000000000006f00 T mapi_explain_result
000000000000c420 T mapi_fetch_all_rows
000000000000c610 T mapi_fetch_field
000000000000c740 T mapi_fetch_field_len
000000000000ab20 T mapi_fetch_line
000000000000a840 T mapi_fetch_reset
000000000000c390 T mapi_fetch_row
000000000000ad00 T mapi_finish
000000000000d1a0 T mapi_get_active
00000000000070f0 T mapi_get_autocommit
000000000000d090 T mapi_get_dbname
000000000000cc80 T mapi_get_digits
000000000000c870 T mapi_get_field_count
0000000000007060 T mapi_get_from
000000000000d0b0 T mapi_get_host
000000000000d0d0 T mapi_get_lang
000000000000c990 T mapi_get_last_id
000000000000cbe0 T mapi_get_len
000000000000cfd0 T mapi_get_maloptimizertime
000000000000d0f0 T mapi_get_mapi_version
000000000000d100 T mapi_get_monet_version
000000000000d150 T mapi_get_motd
000000000000c9f0 T mapi_get_name
000000000000cdc0 T mapi_get_query
000000000000cf70 T mapi_get_querytime
000000000000ce10 T mapi_get_querytype
000000000000c930 T mapi_get_row_count
000000000000cd20 T mapi_get_scale
000000000000d030 T mapi_get_sqloptimizertime
000000000000cb40 T mapi_get_table
000000000000ce90 T mapi_get_tableid
0000000000007020 T mapi_get_to
00000000000070a0 T mapi_get_trace
000000000000ca90 T mapi_get_type
000000000000d0e0 T mapi_get_uri
000000000000d0c0 T mapi_get_user
000000000000d190 T mapi_is_connected
0000000000007140 T mapi_log
0000000000007d70 T mapi_mapi
00000000000079d0 T mapi_mapiuri
00000000000072e0 T mapi_more_results
00000000000072d0 T mapi_needmore
00000000000073c0 T mapi_new_handle
0000000000007230 T mapi_next_result
0000000000006d50 T mapi_noexplain
0000000000008360 T mapi_param
0000000000008370 T mapi_param_numeric
0000000000008280 T mapi_param_string
0000000000008180 T mapi_param_type
000000000000c010 T mapi_ping
0000000000008570 T mapi_prepare
00000000000084e0 T mapi_prepare_handle
000000000000bf60 T mapi_query
0000000000008d90 T mapi_query_done
000000000000c1d0 T mapi_query_handle
0000000000008b80 T mapi_query_part
0000000000008a90 T mapi_query_prep
000000000000ad70 T mapi_quote
0000000000008a80 T mapi_read_response
0000000000009010 T mapi_reconnect
00000000000086b0 T mapi_release_id
000000000000a6d0 T mapi_resolve
00000000000071e0 T mapi_result_error
0000000000007200 T mapi_result_errorcode
000000000000cf10 T mapi_rows_affected
000000000000a950 T mapi_seek_row
000000000000c130 T mapi_send
00000000000085e0 T mapi_setAutocommit
0000000000008650 T mapi_set_size_header
000000000000c360 T mapi_split_line
000000000000c290 T mapi_store_field
000000000000c090 T mapi_stream_query
0000000000008450 T mapi_timeout
0000000000008750 T mapi_trace
000000000000ad40 T mapi_unquote
0000000000008770 T mapi_virtual_result
000000000000ee20 T mcrypt_BackendSum
000000000000dd30 T mcrypt_getHashAlgorithms
000000000000ee30 T mcrypt_hashPassword
000000000000dd40 T mcrypt_MD5Sum
000000000000ec70 T mcrypt_RIPEMD160Sum
000000000000deb0 T mcrypt_SHA1Sum
000000000000e060 T mcrypt_SHA224Sum
000000000000e280 T mcrypt_SHA256Sum
000000000000e4e0 T mcrypt_SHA384Sum
000000000000e830 T mcrypt_SHA512Sum
                 U MD5_Final
                 U MD5_Init
                 U MD5_Update
                 U memmove
                 U memset
                 U mnstr_destroy
                 U mnstr_errnr
                 U mnstr_error
                 U mnstr_flush
                 U mnstr_init
                 U mnstr_printf
                 U mnstr_read
                 U mnstr_read_block
                 U mnstr_set_byteorder
                 U mnstr_settimeout
                 U mnstr_write
000000000000dbd0 T mo_add_option
000000000000d1b0 T mo_builtin_settings
000000000000d730 T mo_find_option
000000000000dcb0 T mo_free_options
000000000000d5f0 T mo_print_options
000000000000db30 T mo_system_config
                 U opendir
                 U open_wastream
                 U __printf_chk
                 U puts
                 U readdir
                 U realloc
                 U RIPEMD160_Final
                 U RIPEMD160_Init
                 U RIPEMD160_Update
                 U sendmsg
                 U SHA1_Final
                 U SHA1_Init
                 U SHA1_Update
                 U SHA224_Final
                 U SHA224_Init
                 U SHA224_Update
                 U SHA256_Final
                 U SHA256_Init
                 U SHA256_Update
                 U SHA384_Final
                 U SHA384_Init
                 U SHA384_Update
                 U SHA512_Final
                 U SHA512_Init
                 U SHA512_Update
                 U __snprintf_chk
                 U socket
                 U socket_rastream
                 U socket_wastream
                 U __sprintf_chk
                 U sscanf
                 U __stack_chk_fail
                 U stderr
                 U stdout
                 U strcat
                 U strchr
                 U strcmp
                 U strcpy
                 U __strdup
                 U strerror
                 U strlen
                 U strncmp
                 U strncpy
                 U strrchr
                 U strstr
                 U strtod
                 U strtof
                 U strtol
                 U strtoll
                 U strtoul
                 U strtoull
                 U __xstat


修正方法如下:
sed -i 's/WIN32?//g' clients/mapilib/Makefile.ag
sed -i 's/@WIN32_TRUE@//g' clients/mapilib/Makefile.in
sed -i 's/WIN32?//g' common/stream/Makefile.ag
sed -i 's/@WIN32_TRUE@//g' common/stream/Makefile.in
然後需要重新編譯一次就可以產生正確的檔案。


這是因為 MonetDB team 想要避免多次連結的解法而產生的問題。MonetDB team 沒有考慮到,如果有使用者使用 Load Library 的方式載入 MAPI library 使用,就會產生 undefined function 的問題而無法正確載入。

2018-07-23

TDBC and MariaDB (use MySQL driver)

下面是一個測試程式:
#!/usr/bin/env tclsh

package require tdbc::mysql
tdbc::mysql::connection create db -user root -passwd admin -host 127.0.0.1 -port 3306 -database test

set statement [db prepare {
    SELECT VERSION() as version
}]


$statement foreach row {
    puts [dict get $row version]
}

$statement close

db close


在 openSUSE Leap 15.0 上測試,需要安裝 libmariadb-devel 才能夠正確執行。我的 libmariadb-devel 來源是 http://download.opensuse.org/repositories/server:/database/openSUSE_Leap_15.0/,因為我之前需要安裝跟資料庫有關的軟體,所以有使用這個 repository。

2018-06-21

Google Sites tclmonetdb is gone

簡單的說,就是 tclmonetdb  進行 Google 新的協作平台轉換以後版面直接炸掉,在試著調整了一下以後,我發現調整好是個有點麻煩的任務,我本來想說放棄新的保留舊的,但是 Google 顯然沒考慮有人會想這麼做,所以變成一個 zombie 的狀態。

經過思考,我直接刪除新的,然後在 tclmonetdb 舊的 Google Sites 網頁 留下訊息,這個站已經移往 Github 了,將在 2018/06/22 刪除。

所以事情就是這樣了,Google Sites tclmonetdb is gone. 如果 Google 服務繼續這樣,那他們會有麻煩,問題不在技術高低,問題在於使用的過程。

所以 Source code 你可以在 Github 找到:
tclmonetdb

如果是 openSUSE,你可以找到 OBS 上的檔案:
tclmonetdb @ OBS

至於 Windows 平台,其實我今天本來是要放新的檔案,但是因為炸掉了所以也直接被我刪除,就…… 跳過這件事吧。


更新:
我也刪除了這個部落格關於 tclmonetdb 文章(因為都會指向錯誤的連結)。

2018-06-03

TDBC-ODBC: Get Data Sources list

TDBC-ODBC 有提供取得目前 data sources 名單的函式 ::tdbc::odbc::datasources。下面的 code 就是取得目前的名單以後,將資料增加到 tablelist 的片段。
# Get data sources list and list
tablelist::tablelist .t -columns {0 "DSN" 0 "Driver"} -stretch all \
    -background white -font {Helvetica -14}
pack .t -fill both -expand 1 -side top
set sources [::tdbc::odbc::datasources]
foreach {dsn driver} $sources {
   .t insert end [list $dsn $driver]
}

這樣就可以取得目前的 ODBC data sources。


其它部份:
unixODBC 可以在 /etc/unixODBC 目錄中設定 odbc.ini 與 odbcinst.ini,或者是在家目錄下設定 .odbc.ini。

::tdbc::odbc::datasources 如果沒有特別設定,會取得 system 和 user 的名單。TDBC-ODBC 可以使用選項 -system 或者是 -user 來取得個別的名單。

2017-08-21

tcl-rocksdb v0.1.1

tcl-rocksdb


RocksDB 更改了授權,從原本的 BSD+PATENTS 變成 BSD+PATENTS/GPL v2 (dual license) 然後又變成 Apache 2.0/GPL v2 (dual license)。

而會修改授權,是因為 Apache 基金會接到 Apache Cassandra Team 的請求,希望能夠釐清使用 RocksDB 是否會有版權上的疑慮以後,公佈了結果,Facebook BSD+PATENTS license 被列為 category-x,同時提出了下列的建議:
  • No new project, sub-project or codebase, which has not used Facebook BSD+patents licensed jars (or similar), are allowed to use them. In other words, if you haven't been using them, you aren't allowed to start. It is Cat-X.
  • If you have been using it, and have done so in a *release*, you have a temporary exclusion from the Cat-X classification thru August 31, 2017. At that point in time, ANY and ALL usage of these Facebook BSD+patents licensed artifacts are DISALLOWED. You must either find a suitably licensed replacement, or do without. There will be NO exceptions.
  • Any situation not covered by the above is an implicit DISALLOWAL of usage.

所以如果 RocksDB 沒有修改授權,那麼 Apache Cassandra 就無法使用 RocksDB,已經使用的 Apache Flink, Apache Samza 等各個專案也需要開始尋找替代品。而 RocksDB team 在 Apache 基金會公佈結果以後,很快就修改了授權,變成 Apache 2.0/GPL v2 (dual license)。

既然授權的疑慮清除(PATENTS 是很複雜的議題,如果可以,我會儘量避開),所以我實作了 tcl-rocksdb (prototype),實作一些最基本的操作,同時也寫了簡易的 test case 測試。因為其它的部份我不知道怎麼實作成 Tcl extension 比較好,所以目前的 v0.1.1 就是我實作上比較知道怎麼做的部份了。


2017/08/22
加入幾個新的 command,更新版本為 v0.2。

另外,我發現 LevelDB 和 RocksDB 的基本操作長的很像,所以按照目前的資料,也寫了一個 tcl-leveldb

2017-05-19

Tcl extension and TDBC driver for CrateDB database : cratedb-tcl 0.1

Source code:
cratedb-tcl


如果需要知道 CrateDB 的一些資料:
CrateDB


因為 CrateDB REST API 支援 Parameter Substitution,所以實際上可以用來模擬 prepare/execute 的行為,這個套件為了驗證這個想法而寫的。

也就是實際上是使用 TclCurl 發出 POST request,然後取得結果。而為了模擬,所以我們將步驟分為幾個部份:
  • prepare: 取得 SQL code,只是放在某個變數中
  • param: 使用者設定參數的型別 (TYPE) 與值 (VALUE)
  • 當使用者呼叫 execute,我們將前面二者的資料結合並且設定好 Parameter Substitution 以後,發出 POST request 然後取得結果
而因為模擬了 prepare/execute,所以我們就可以使用 TDBC 中的 ::tdbc::tokenize 分析 SQL 並且進行參數代換的工作,這部份完成以後,就有一個基本可用的 TDBC driver。

但是需要注意的是因為是用模擬的,跟一般資料庫的行為還是有一些差距,當設定  PARAM 時如果沒有為某個欄位指定 TYPE/VALUE,一般會設為 NULL,雖然 TDBC 的部份我有做一些處理,但是還是沒辦法跟一般的資料庫行為完全一樣。

讓我驚嚇的部份是 CrateDB 欄位部份會自動按照變數 欄位的字母大小排序,也就是在 insert 時不指定欄位順序的話,就會出現插入資料到錯誤的欄位。我反覆測試的時候發現的,目前不知道是 CrateDB 的設計還是 bug。

2017-05-12

tclcubrid v0.9.5

Source code

tclcubrid

About


CUBRID is an open source SQL-based relational database management system with object extensions developed by Naver Corporation for web applications.

tclcubrid is a Tcl extension by using CUBRID CCI (CCI Client Interface) driver to connect CUBRID. I write this extension to research CUBRID and CCI (CCI Client Interface) driver.

Main changelog

  1. Improve set/multiset/sequence type handle for fetch_row_list/fetch_row_dict method.
    Now tclcubrid will return a Tcl list for set/multiset/sequence type.
    It is an INCOMPATIBILITY change! User maybe need update source code.
  2. Add blob/clob write size check

改進對於 set/multiset/sequence type 的處理。同時加入更多 blob/clob size 的檢查。


更新:
CUBRID 網站怪怪的,我本來想指向正確的文件位址,結果位址一直變動。最後我覺得煩了,我把位址暫時清掉,然後也重置了  tclcubrid 的 git repository。

更新:
早上起來發現網站又回復為原來的樣子,所以我把連結加回去了,希望接下來不會又出現連結失效的問題。

2017-01-20

BaseXClient-Tcl

Source code:
BaseXClient-Tcl


Tcl client for BaseX database.

BaseX 是一個 XML 資料庫,我只是用來做某些簡單的測試。大部份的功能跟官方的 client 都有點像,不過還是有做一些簡化假設,但是整體上功能應該是差不多的(應該啦)。

2016-12-08

tclcubrid v0.9.4

Source code

tclcubrid

About


CUBRID is an open source SQL-based relational database management system with object extensions developed by Naver Corporation for web applications.

tclcubrid is a Tcl extension by using CUBRID CCI (CCI Client Interface) driver to connect CUBRID. I write this extension to research CUBRID and CCI (CCI Client Interface) driver.

Main changelog

  1. Add Date/Time types with timezone support

這個版本增加 Date/Time types with timezone 的支援。

2016-11-14

tclcubrid v0.9.3

Source code

tclcubrid

About


CUBRID is an open source SQL-based relational database management system with object extensions developed by Naver Corporation for web applications.

tclcubrid is a Tcl extension by using CUBRID CCI (CCI Client Interface) driver to connect CUBRID. I write this extension to research CUBRID and CCI (CCI Client Interface) driver.

Main changelog

  1. Free memory when connect fail

 這是一個小更新的版本。

2016-11-11

MonetDB ODBC (Linux/openSUSE) test

MonetDB ODBC driver 的部份,首先必須要先安裝 unixODBC,然後編譯的時候需要有編譯 ODBC driver。 unixODBC 需要設定二個檔案。/etc/unixODBC/odbc.ini 與 /etc/unixODBC/odbcinst.ini。


首先是 odbcinst.ini 的內容:
[MonetDB]
Description     = ODBC driver for MonetDB server
Driver          = /usr/local/lib64/libMonetODBC.so
Setup           = /usr/local/lib64/libMonetODBCs.so
FileUsage       = 1

再來是 odbc.ini,
[MonetDB]
Description     = MonetDB
Driver          = MonetDB
Trace           = No
TraceFile       =
Database        = demo
Host            = localhost
UserName        = monetdb
Password        = monetdb
Port            = 50000
ConfigFile      =

我們使用 TDBCODBC 進行驗證:
package require tdbc::odbc

set connStr "DSN=MonetDB; UID=monetdb; PWD=monetdb;"
tdbc::odbc::connection create db $connStr

set statement [db prepare {create table person (id integer, name varchar(40))}]
$statement execute
$statement close

set statement [db prepare {insert into person values(1, 'leo')}]
$statement execute
$statement close

set statement [db prepare {insert into person values(2, 'yui')}]
$statement execute
$statement close

set statement [db prepare {SELECT * FROM person}]

$statement foreach row {
    puts [dict get $row id]
    puts [dict get $row name]
}

$statement close

set statement [db prepare {drop table person}]
$statement execute
$statement close

2016-11-06

tclcubrid v0.9.2

Source code

tclcubrid

About


CUBRID is an open source SQL-based relational database management system with object extensions developed by Naver Corporation for web applications.

tclcubrid is a Tcl extension by using CUBRID CCI (CCI Client Interface) driver to connect CUBRID. I write this extension to research CUBRID and CCI (CCI Client Interface) driver.

Main changelog

  1. Update Thread_Exit method

 這是一個小更新的版本。