Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: introduce pg_extension schema #48754

Merged
merged 1 commit into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/sql/delegate/show_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func (d *delegator) delegateShowTables(n *tree.ShowTables) (tree.Statement, erro
}
schemaClause = fmt.Sprintf("AND ns.nspname = %s", schema)
} else {
schemaClause = "AND ns.nspname NOT IN ('information_schema', 'pg_catalog', 'crdb_internal')"
// These must be custom defined until the sql <-> sql/delegate cyclic dependency
// is resolved. When we have that, we should read the names off "virtualSchemas" instead.
schemaClause = "AND ns.nspname NOT IN ('information_schema', 'pg_catalog', 'crdb_internal', 'pg_extension')"
}

var query string
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/logictest/testdata/logic_test/create_as
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ query III colnames
SELECT * FROM bar
----
a b c
1 2 4
1 2 5
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change?

Copy link
Contributor Author

@otan otan May 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foo is CREATE TABLE foo (x, y, z) AS SELECT catalog_name, schema_name, sql_path FROM information_schema.schemata, and we added a new schema.

bar.c relies on count(*) from foo.


statement ok
CREATE TABLE baz (a, b, c) AS SELECT 1, 2, count(*) FROM foo
Expand All @@ -141,7 +141,7 @@ query III colnames
SELECT * FROM baz
----
a b c
1 2 4
1 2 5

# Check that CREATE TABLE AS allows users to specify primary key (#20940)
statement ok
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/logictest/testdata/logic_test/database
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ schema_name
crdb_internal
information_schema
pg_catalog
pg_extension
public

statement ok
Expand Down
19 changes: 13 additions & 6 deletions pkg/sql/logictest/testdata/logic_test/geospatial
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ INSERT INTO parse_test (geom, geog) VALUES
(ST_GeomFromGeoJSON('{"type":"Feature","geometry":{"type":"Point","coordinates":[1,2]},"properties":null}'::jsonb), ST_GeogFromGeoJSON('{"type":"Feature","geometry":{"type":"Point","coordinates":[1,2]},"properties":null}'::jsonb)),
(ST_GeomFromWKB(decode('0101000000000000000000F03F000000000000F03F', 'hex')), ST_GeogFromWKB(decode('0101000000000000000000F03F000000000000F03F', 'hex'))),
(ST_GeomFromWKB(decode('0101000000000000000000F03F000000000000F03F', 'hex'), 3857), ST_GeogFromWKB(decode('0101000000000000000000F03F000000000000F03F', 'hex'), 3857)),
(ST_GeomFromEWKB(decode('0101000000000000000000F03F000000000000F03F', 'hex')), ST_GeogFromEWKB(decode('0101000000000000000000F03F000000000000F03F', 'hex')))
(ST_GeomFromEWKB(decode('0101000000000000000000F03F000000000000F03F', 'hex')), ST_GeogFromEWKB(decode('0101000000000000000000F03F000000000000F03F', 'hex'))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these changes part of adding pg_extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah but it was an annoying rebase so i just moved this up from below.

(st_geomfromgeojson('null':::jsonb), st_geogfromgeojson('null':::jsonb))

query TTTTTTTT
SELECT
Expand Down Expand Up @@ -141,6 +142,7 @@ POINT (1 1) SRID=3857;POINT (1 1)
<Point><coordinates>1,1</coordinates></Point> {"type":"Feature","geometry":{"type":"Point","coordinates":[1,1]},"properties":null}
POINT (1 1) POINT (1 1) [1 1 0 0 0 0 0 0 0 0 0 240 63 0 0 0 0 0 0 240 63] [1 1 0 0 0 0 0 0 0 0 0 240 63 0 0 0 0 0 0 240 63] 0101000000000000000000F03F000000000000F03F 0101000000000000000000F03F000000000000F03F <?xml version="1.0" encoding="UTF-8"?>
<Point><coordinates>1,1</coordinates></Point> {"type":"Feature","geometry":{"type":"Point","coordinates":[1,1]},"properties":null}
NULL NULL NULL NULL NULL NULL NULL NULL

query TTTTTTTT
SELECT
Expand Down Expand Up @@ -178,6 +180,7 @@ POINT (1 1) SRID=3857;POINT (1 1)
<Point><coordinates>1,1</coordinates></Point> {"type":"Feature","geometry":{"type":"Point","coordinates":[1,1]},"properties":null}
POINT (1 1) SRID=4326;POINT (1 1) [1 1 0 0 0 0 0 0 0 0 0 240 63 0 0 0 0 0 0 240 63] [1 1 0 0 32 230 16 0 0 0 0 0 0 0 0 240 63 0 0 0 0 0 0 240 63] 0101000000000000000000F03F000000000000F03F 0101000020E6100000000000000000F03F000000000000F03F <?xml version="1.0" encoding="UTF-8"?>
<Point><coordinates>1,1</coordinates></Point> {"type":"Feature","geometry":{"type":"Point","coordinates":[1,1]},"properties":null}
NULL NULL NULL NULL NULL NULL NULL NULL

query TTTTTTTT
SELECT
Expand Down Expand Up @@ -356,9 +359,13 @@ Square overlapping left and right square Square (left)
Square overlapping left and right square Square (right) true false true false false true false false false
Square overlapping left and right square Square overlapping left and right square true true true false true true false false true

subtest regression_48093
subtest pg_extension

query TT
SELECT st_geogfromgeojson('null':::jsonb), st_geomfromgeojson('null':::jsonb)
----
NULL NULL
statement error not yet implemented
SELECT * FROM pg_extension.geography_columns

statement error not yet implemented
SELECT * FROM pg_extension.geometry_columns

statement error not yet implemented
SELECT * FROM pg_extension.spatial_ref_sys ORDER BY srid ASC
55 changes: 55 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/grant_database
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ a information_schema admin ALL
a information_schema root ALL
a pg_catalog admin ALL
a pg_catalog root ALL
a pg_extension admin ALL
a pg_extension root ALL
a public admin ALL
a public root ALL

Expand Down Expand Up @@ -55,6 +57,10 @@ a pg_catalog admin ALL
a pg_catalog readwrite ALL
a pg_catalog root ALL
a pg_catalog test-user ALL
a pg_extension admin ALL
a pg_extension readwrite ALL
a pg_extension root ALL
a pg_extension test-user ALL
a public admin ALL
a public readwrite ALL
a public root ALL
Expand Down Expand Up @@ -82,6 +88,8 @@ a information_schema readwrite ALL
a information_schema test-user ALL
a pg_catalog readwrite ALL
a pg_catalog test-user ALL
a pg_extension readwrite ALL
a pg_extension test-user ALL
a public readwrite ALL
a public test-user ALL

Expand Down Expand Up @@ -133,6 +141,20 @@ a pg_catalog test-user DROP
a pg_catalog test-user GRANT
a pg_catalog test-user SELECT
a pg_catalog test-user ZONECONFIG
a pg_extension admin ALL
a pg_extension readwrite CREATE
a pg_extension readwrite DELETE
a pg_extension readwrite DROP
a pg_extension readwrite GRANT
a pg_extension readwrite SELECT
a pg_extension readwrite ZONECONFIG
a pg_extension root ALL
a pg_extension test-user CREATE
a pg_extension test-user DELETE
a pg_extension test-user DROP
a pg_extension test-user GRANT
a pg_extension test-user SELECT
a pg_extension test-user ZONECONFIG
a public admin ALL
a public readwrite CREATE
a public readwrite DELETE
Expand Down Expand Up @@ -187,6 +209,18 @@ a pg_catalog test-user DROP
a pg_catalog test-user GRANT
a pg_catalog test-user SELECT
a pg_catalog test-user ZONECONFIG
a pg_extension readwrite CREATE
a pg_extension readwrite DELETE
a pg_extension readwrite DROP
a pg_extension readwrite GRANT
a pg_extension readwrite SELECT
a pg_extension readwrite ZONECONFIG
a pg_extension test-user CREATE
a pg_extension test-user DELETE
a pg_extension test-user DROP
a pg_extension test-user GRANT
a pg_extension test-user SELECT
a pg_extension test-user ZONECONFIG
a public readwrite CREATE
a public readwrite DELETE
a public readwrite DROP
Expand Down Expand Up @@ -245,6 +279,19 @@ a pg_catalog test-user DELETE
a pg_catalog test-user DROP
a pg_catalog test-user GRANT
a pg_catalog test-user ZONECONFIG
a pg_extension admin ALL
a pg_extension readwrite CREATE
a pg_extension readwrite DELETE
a pg_extension readwrite DROP
a pg_extension readwrite GRANT
a pg_extension readwrite SELECT
a pg_extension readwrite ZONECONFIG
a pg_extension root ALL
a pg_extension test-user CREATE
a pg_extension test-user DELETE
a pg_extension test-user DROP
a pg_extension test-user GRANT
a pg_extension test-user ZONECONFIG
a public admin ALL
a public readwrite CREATE
a public readwrite DELETE
Expand Down Expand Up @@ -283,6 +330,12 @@ a pg_catalog readwrite DROP
a pg_catalog readwrite GRANT
a pg_catalog readwrite SELECT
a pg_catalog readwrite ZONECONFIG
a pg_extension readwrite CREATE
a pg_extension readwrite DELETE
a pg_extension readwrite DROP
a pg_extension readwrite GRANT
a pg_extension readwrite SELECT
a pg_extension readwrite ZONECONFIG
a public readwrite CREATE
a public readwrite DELETE
a public readwrite DROP
Expand All @@ -302,6 +355,8 @@ a information_schema admin ALL
a information_schema root ALL
a pg_catalog admin ALL
a pg_catalog root ALL
a pg_extension admin ALL
a pg_extension root ALL
a public admin ALL
a public root ALL

Expand Down
Loading