bloomberg/comdb2

`cdb2_open` seems to ignore its third parameter

sarahmonod opened this issue · 1 comments

Describe the bug

The cdb2_open function seems to completely ignore its third argument (type) and works regardless of whether it is a valid utf-8 string or not.

To Reproduce
Steps to reproduce the behavior:

  1. execute int rc = cdb2_open(&hndl, "DB_NAME", "不好意思", 0);
  2. rc is equal to CDB2_OK and the connection is working

Expected behavior

  1. rc should be equal to CDB2ERR_CONNECT_ERROR
  2. cdb2_errstr(hndl) should return "cdb2_hndl_get_dbhosts: comdb2db has no entry of db DB_NAME of cluster type 不好意思."

Environment (please complete the following information):

  • Operating System and Version: Ubuntu 20.04 on Github Actions

Additional context

Note that this required us to turn off tests as seen here: bloomberg/python-comdb2@36da55c

cdb2api ignores the type argument by design (I'm not going to argue it's good design...), if you have an explicit definition of what hosts constitute your cluster. If you don't you'll get the expected error. There's no requirement that database names or tiers (types) are utf8 - I understand that that'd cause a problem for Python.

# tier wharrrgharrrbl doesnt't exist, no local config
$ ./q mikedb wharrrgharrrbl
open: -1 cdb2_hndl_get_dbhosts: comdb2db has no entry of db mikedb of cluster type wharrrgharrrbl.
# mikedb tier dev exists, we'll connect to dev
$ ./q mikedb dev
ok
# create a config with ```mikedb localhost```, run a local db
# ANY value will now connect you to localhost - it overrides the argument
$ ./q mikedb wharrrgharrrbl
ok
$