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

Weird behaviour of function IPv4CIDRToRange/IPv6CIDRToRange #11245

Closed
nvartolomei opened this issue May 28, 2020 · 3 comments
Closed

Weird behaviour of function IPv4CIDRToRange/IPv6CIDRToRange #11245

nvartolomei opened this issue May 28, 2020 · 3 comments
Labels
bug Confirmed user-visible misbehaviour in official release easy task Good for first contributors st-accepted The issue is in our backlog, ready to take st-fixed

Comments

@nvartolomei
Copy link
Contributor

nvartolomei commented May 28, 2020

How to reproduce

  • Which ClickHouse server version to use: version 20.4.4
DROP TABLE IF EXISTS test;
CREATE TABLE test Engine = Memory
AS SELECT '1.1.1.1/24' as address;
WITH '1.1.1.1' AS addr
SELECT
    address,
    splitByChar('/', address) AS prefix,
    prefix[1] AS base,
    toUInt8(prefix[2]) AS mask
FROM test
WHERE (IPv4CIDRToRange(toIPv4(addr), mask).1) = toIPv4(base)

Received exception from server (version 20.4.4):
Code: 44. DB::Exception: Received from localhost:9000. DB::Exception: Illegal column Const(UInt32) of argument of function IPv4CIDRToRange.

Expected behaviour is this (here mask is hard coded to 24.

WITH '1.1.1.1' AS addr
SELECT
    address,
    splitByChar('/', address) AS prefix,
    prefix[1] AS base,
    toUInt8(prefix[2]) AS mask
FROM test
WHERE (IPv4CIDRToRange(toIPv4(addr), 24).1) = toIPv4(base)

┌─address────┬─prefix───────────┬─base────┬─mask─┐
│ 1.1.1.0/24 │ ['1.1.1.0','24'] │ 1.1.1.024 │
└────────────┴──────────────────┴─────────┴──────┘

1 rows in set. Elapsed: 0.005 sec.

cc @lspgn

@nvartolomei nvartolomei added the bug Confirmed user-visible misbehaviour in official release label May 28, 2020
@qoega
Copy link
Member

qoega commented May 29, 2020

Can reproduce on master as well.

@alexey-milovidov
Copy link
Member

Reproduced on

master
20.4
20.3
20.1
19.14

On 19.1 there is no such function.

@alexey-milovidov
Copy link
Member

The bug was introduced here: #5095

@alexey-milovidov alexey-milovidov added easy task Good for first contributors st-accepted The issue is in our backlog, ready to take labels Jun 17, 2020
@alexey-milovidov alexey-milovidov changed the title Weird behaviour of function IPv4CIDRToRange/IPv6CIDRToRange which seems to be triggered by some query pipeline optimizations Weird behaviour of function IPv4CIDRToRange/IPv6CIDRToRange Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed user-visible misbehaviour in official release easy task Good for first contributors st-accepted The issue is in our backlog, ready to take st-fixed
Projects
None yet
Development

No branches or pull requests

4 participants