-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
Hey folks!
I make regular use of this extension and have made a function expand_cidr() that takes in an IP address (network or bare) and returns the expanded IPs from the CIDR in a list/array. Handles IPv4 & v6.
I'm curious if (a) y'all accept PRs and (b) if so, what should I do to ensure the least amount of work on your end?
A short example:
🦆>SELECT UNNEST(expand_cidr('192.168.1.0/32'::INET)) ip;
┌─────────────┐
│ ip │
│ inet │
├─────────────┤
│ 192.168.1.0 │
└─────────────┘
🦆>SELECT UNNEST(expand_cidr('192.168.1.0/30'::INET)) ip;
┌─────────────┐
│ ip │
│ inet │
├─────────────┤
│ 192.168.1.0 │
│ 192.168.1.1 │
│ 192.168.1.2 │
│ 192.168.1.3 │
└─────────────┘
🦆>FROM (SELECT UNNEST(expand_cidr('192.168.1.0/16'::INET)) ip) SELECT COUNT(ip);
┌───────────┐
│ count(ip) │
│ int64 │
├───────────┤
│ 65536 │
└───────────┘
🦆>
Please ignore this PR: #3
This is the correct PR: #5
Metadata
Metadata
Assignees
Labels
No labels