# LogicTest: local

# SRID of the geometry column is unspecified, so default index bounds are used.
statement ok
CREATE TABLE geo_table(
  k int primary key,
  geom geometry,
  INVERTED INDEX geom_index(geom)
)

# Test that only the permitted opclasses are usable to make an inverted index.
statement error operator class \"blah_ops\" does not exist
CREATE INVERTED INDEX ON geo_table(geom blah_ops)

# Test that only the permitted opclasses are usable to make an inverted index.
statement error operator class \"blah_ops\" does not exist
CREATE INDEX ON geo_table USING GIST(geom blah_ops)

# Shapes with SRID 26918. We've taken small X, Y values and added 400,000 to the X coordinate
# and 4,000,000 to the Y coordinate to place them inside the bounds of SRID 26918.
statement ok
INSERT INTO geo_table VALUES
  (1, 'SRID=26918;POINT(400001 4000001)'),
  (2, 'SRID=26918;LINESTRING(400001 4000001, 400002 4000002)'),
  (3, 'SRID=26918;POINT(400003 4000003)'),
  (4, 'SRID=26918;LINESTRING(400004 4000004, 400005 4000005)'),
  (5, 'SRID=26918;LINESTRING(400040 4000040, 400041 4000041)'),
  (6, 'SRID=26918;POLYGON((400001 4000001, 400005 4000001, 400005 4000005, 400001 4000005, 400001 4000001))')

query I
SELECT k FROM geo_table WHERE ST_Intersects('SRID=26918;POINT(400003 4000003)'::geometry, geom) ORDER BY k
----
3
6

statement ok
DROP TABLE geo_table

# SRID of the geometry column is specified, so SRID specific bounds are used.
statement ok
CREATE TABLE geo_table(
  k int primary key,
  geom geometry(geometry, 26918),
  INVERTED INDEX geom_index(geom)
)

# Same shapes.
statement ok
INSERT INTO geo_table VALUES
  (1, 'SRID=26918;POINT(400001 4000001)'),
  (2, 'SRID=26918;LINESTRING(400001 4000001, 400002 4000002)'),
  (3, 'SRID=26918;POINT(400003 4000003)'),
  (4, 'SRID=26918;LINESTRING(400004 4000004, 400005 4000005)'),
  (5, 'SRID=26918;LINESTRING(400040 4000040, 400041 4000041)'),
  (6, 'SRID=26918;POLYGON((400001 4000001, 400005 4000001, 400005 4000005, 400001 4000005, 400001 4000001))')

# Same result.
query I
SELECT k FROM geo_table WHERE ST_Intersects('SRID=26918;POINT(400003 4000003)'::geometry, geom) ORDER BY k
----
3
6
