Skip to content

Initial inet data type implementation - #111

Open
mkgrgis wants to merge 4 commits into
pgspider:masterfrom
mkgrgis:inet
Open

Initial inet data type implementation#111
mkgrgis wants to merge 4 commits into
pgspider:masterfrom
mkgrgis:inet

Conversation

@mkgrgis

Copy link
Copy Markdown
Contributor

Based on storage conventions, discussed on SQLite forum thread.
Default affinity of IPv4 - integer. Default affinity of IPv6 - blob, because other compact forms are impossible.
Storage convention for blob affinity:

 m - mask as number of bits
a - bytes of IP address
IP v4 + cidr
┏━━━┳━━━┳━━━┳━━━┳━━━┓
┃ a ┃ a ┃ a ┃ a ┃ m ┃
┗━━━┻━━━┻━━━┻━━━┻━━━┛
0 1 2 3 4 - byte index
IP v6 + cidr
┏━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┓
┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ m ┃
┗━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┛
0 1 2 3 4 5 5 7 8 9 10 11 12 13 14 15 16 17 - byte index
IP v4
┏━━━┳━━━┳━━━┳━━━┓
┃ a ┃ a ┃ a ┃ a ┃
┗━━━┻━━━┻━━━┻━━━┛
0 1 2 3 - byte index
IP v6
┏━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┳━━━┓
┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃ a ┃
┗━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┻━━━┛
0 1 2 3 4 5 5 7 8 9 10 11 12 13 14 15 16 - byte index

@mkgrgismkgrgis mentioned this pull request Apr 5, 2025
Merged
@mkgrgis

Copy link
Copy Markdown
ContributorAuthor

@t-hiroshige , please assign a reviewer for this PR. This not easy and not hard PR mainly similar to some previous PR about MAC addresses support.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@mkgrgis