Skip to content

Termination with comments in query and .query method #54

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

Open
ks-s-a opened this issue Feb 11, 2020 · 1 comment
Open

Termination with comments in query and .query method #54

ks-s-a opened this issue Feb 11, 2020 · 1 comment
Labels

Comments

@ks-s-a
Copy link

ks-s-a commented Feb 11, 2020

Run such snippet:

const ClickHouse = require('@apla/clickhouse');

const c = new ClickHouse({
  host,
  port,
  auth
});

const q = 'select count() from table
-- ololololoolololololoolololololol
'
const stream = c.query(q);

stream.on('metadata', function (metadata) {
  console.log('metadata', metadata);
});

stream.on('data', function (data) {
  console.log('data!', data);
});

stream.on('error', err => {
  console.log('error', err);
});

stream.on('end', () => {
  console.log('end');
});

stream.on('end', () => {
  console.log('end');
});

And receive nothing. Stream was closed and the script terminated. There were no fired events. However, if I remove comments from the query it will work properly.

I looked at tcpdump and saw that the request was sent to the server. After sending we got 'close' event from http.response inside the client's code then 'response' event and 'close' again.

Tried to send the request with http://ui.tabix.io/ - everything is fine. And it is the reason why I texted here. It looks like client bug, which not related to server settings.

@ks-s-a ks-s-a changed the title Termination with long queries and .query method Termination with comments in query and .query method Feb 11, 2020
@ks-s-a
Copy link
Author

ks-s-a commented Feb 13, 2020

Ok. Swiched clickhouse server to debug mode and got:

2020.02.13 11:53:32.442129 <Debug> executeQuery: (from ${IP}:46934, user: username) select count() from default.events -- FORMAT JSONCompact

Looks like client adds FORMAT statement to the end of the query and it becomes part of comment. Is it expected behavior?

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

No branches or pull requests

2 participants