Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to send multiple parameterised queries through the thrift interface? #70

Open
ashwinswy opened this issue Oct 24, 2018 · 9 comments

Comments

@ashwinswy
Copy link
Contributor

ashwinswy commented Oct 24, 2018

I couldn't find this anywhere in the documentation. I've tried the following:

client.exec_single_param('user_1', 'type', query_1 + query_2, [], [bindings_1, bindings_2])
client.exec_sql_param('actor type(user_1)' + query_1 + query_2, [bindings_1, bindings_2])

In both cases, I'm getting InvalidRequestException(info='not an error', code=6).

First off, is this even possible? If not, how can I execute multiple queries within a transaction?

@SergejJurecko
Copy link
Contributor

You can not with parameterized queries unfortunately. You can if it’s all in the sql statement.

@ashwinswy
Copy link
Contributor Author

I'd like to try and add this functionality here. Can you point me in the right direction so that I can setup a development environment? Do you have some kind of wiki/documentation which will give me a top level view of all the components involved and how they are working together?

@SergejJurecko
Copy link
Contributor

By writing the thrift spec: https://github.com/biokoda/actordb/blob/master/adbt.thrift
You need an additional level of lists, so bindingvals type must be: list<list<list>>
List of statements, list of rows and list of columns.

Implementing the call to actordb: https://github.com/biokoda/actordb_thrift/blob/master/src/adbt.erl

The adbt.erl file wraps parameters in a list with a single parameter (prepare/1 function) because it assumes only one statement. It sends bindingvals as a list three layers deep, but first layer is always single element. This is what you need to expand.

@ashwinswy
Copy link
Contributor Author

How can I setup a development environment? I can see that you have a bash script startdev.sh, but it is not working for me probably because of some missing dependencies. Are these dependencies documented? Am I even looking at the correct file?

Further to that, can you please tell me how to build actordb?

I tried doing make but got the following error

cat: /etc/redhat-release: No such file or directory
Makefile:168: warning: overriding recipe for target `ballclean'
Makefile:65: warning: ignoring old recipe for target `ballclean'
./rebar get-deps

=ERROR REPORT==== 30-Oct-2018::11:35:46 ===
beam/beam_load.c(1365): Error loading module rebar:
  use of opcode 153; this emulator supports only up to 152


=ERROR REPORT==== 30-Oct-2018::11:35:46 ===
Loading of /home/ftpcmbin/workspace/actordb/actordb/rebar/rebar/ebin/rebar.beam failed: badfile
escript: exception error: undefined function rebar:main/1
  in function  escript:run/2
  in call from escript:start/1
  in call from init:start_it/1
  in call from init:start_em/1
make: *** [deps] Error 127

@SergejJurecko
Copy link
Contributor

  1. Install erlang 21
  2. Checkout actordb
  3. ./rebar get-deps
  4. ./rebar co
  5. If you are working on a dependency such as actordb_thrift, I simply go to deps folder and manage it directly. Rebar annoyingly checks out in a detached state, so make sure you are on master or whatever branch you want.
  6. ./startdev.sh will start actor. Anything you change in deps will automaticaly be compiled and running as you work on it.

@ashwinswy
Copy link
Contributor Author

ashwinswy commented Nov 6, 2018

I've extended the thrift interface to support one more level of nesting for BindingVals0. Now the problem is that, when I'm executing multiple queries it is only returning the result of the very last query in Result(rdRes, wrRes).

I'm assuming I need to modify the Result struct so that it returns a list of ReadResult & WriteResult structs in response. If so, how do you suggest I go about that?

@ashwinsadeep
Copy link

I've raised pull requests for this feature in the following repos: actordb, actordb_thrift, and adbt

Please review these when you get a chance. Further to that, can you please let me know how to build actordb for production on CentOS?

@SergejJurecko
Copy link
Contributor

Thank you. Building a package is basically as simple as make package

Requirements:

  • erlang 21
  • readline, ncurses
  • at least gcc 4.9

@SergejJurecko
Copy link
Contributor

Keep in mind it will checkout according to tags and branches set for the various subprojects in rebar.config. Main actordb references actordb_core, which then references the other projects that were updated. If you have a fork of everything, you have to commit your own rebar.configs pointing to your forks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants