Missing option to convert `INET` IP to CIDR network without string conversion
- Dominant language
- C++
- Stars
- 13
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
Description
The `INET` type supports storing IP addresses and networks as well. However, there’s no straightforward way to convert an IP address into a network with a specified prefix length without relying on string-based workarounds.
```sql
D WITH
q AS (SELECT '192.168.53.16'::INET AS cidr)
SELECT network((cidr::STRING || '/24')::INET) FROM q;
┌─────────────────────────────────────────────────────────┐
│ network(CAST((CAST(cidr AS VARCHAR) || '/24') AS INET)) │
│ inet │
├─────────────────────────────────────────────────────────┤
│ 192.168.53.0/24 │
└─────────────────────────────────────────────────────────┘
```
Intuitively it should be possible by doing something like `cidr / 24` or `to_network(cidr, 24)`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the SQL example in the issue and inspect the INET extension's existing conversion and network operations. The change is done when an IP address can be converted to a network with a specified prefix length without string conversion, using a clearly chosen function or operator and covered by a reproducible SQL case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100