Skip to content

Instantly share code, notes, and snippets.

@activeshadow
Last active October 19, 2017 16:43
Show Gist options
  • Save activeshadow/2e14bf889d9d216713b6 to your computer and use it in GitHub Desktop.
Save activeshadow/2e14bf889d9d216713b6 to your computer and use it in GitHub Desktop.
PostgreSQL Errors
CREATE TABLE network_info (
network CIDR NOT NULL,
some_info TEXT NULL,
PRIMARY KEY (network)
);
CREATE TABLE ipaddr_info (
ipaddr INET NOT NULL,
some_info INT NULL,
PRIMARY KEY (ipaddr, some_info)
);
CREATE TABLE ipaddrs (
addr INET NOT NULL,
);
CREATE VIEW ipaddr_summary AS
SELECT DISTINCT
i.addr AS ip_address,
a.some_info AS network_info,
COUNT(b.ipaddr) AS ip_info_count
FROM ipaddrs AS i
LEFT JOIN network_info AS a
ON (i.addr << a.network)
LEFT JOIN ipaddr_info AS b
ON (i.addr = b.ipaddr)
GROUP BY i.addr, a.some_info
;
test_tbl=# CREATE INDEX idx_network_info_network_gist
test_tbl-# ON network_info USING gist(network);
ERROR: data type cidr has no default operator class for access method "gist"
HINT: You must specify an operator class for the index or define a default operator class for the data type.
test_tbl=# CREATE INDEX idx_ipaddr_info_ipaddr_gist
test_tbl-# ON ipaddr_info USING gist(ipaddr);
ERROR: data type inet has no default operator class for access method "gist"
HINT: You must specify an operator class for the index or define a default operator class for the data type.
@KES777
Copy link

KES777 commented Oct 19, 2017

inet_ops did it. Thank you

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