提交 edf3d1d9 authored 作者: Thomas Mueller's avatar Thomas Mueller

PgServer: non-admin users could not open a database.

上级 f67db592
...@@ -15,6 +15,7 @@ drop alias if exists pg_get_oid; ...@@ -15,6 +15,7 @@ drop alias if exists pg_get_oid;
create alias pg_get_oid deterministic for "org.h2.server.pg.PgServer.getOid"; create alias pg_get_oid deterministic for "org.h2.server.pg.PgServer.getOid";
create table pg_catalog.pg_version as select 2 as version, 2 as version_read; create table pg_catalog.pg_version as select 2 as version, 2 as version_read;
grant select on pg_catalog.pg_version to public;
create view pg_catalog.pg_roles -- (oid, rolname, rolcreaterole, rolcreatedb) create view pg_catalog.pg_roles -- (oid, rolname, rolcreaterole, rolcreatedb)
as as
...@@ -24,6 +25,7 @@ select ...@@ -24,6 +25,7 @@ select
case when admin then 't' else 'f' end as rolcreaterole, case when admin then 't' else 'f' end as rolcreaterole,
case when admin then 't' else 'f' end as rolcreatedb case when admin then 't' else 'f' end as rolcreatedb
from information_schema.users; from information_schema.users;
grant select on pg_catalog.pg_roles to public;
create view pg_catalog.pg_namespace -- (oid, nspname) create view pg_catalog.pg_namespace -- (oid, nspname)
as as
...@@ -31,6 +33,7 @@ select ...@@ -31,6 +33,7 @@ select
id oid, id oid,
cast(schema_name as varchar_ignorecase) nspname cast(schema_name as varchar_ignorecase) nspname
from information_schema.schemata; from information_schema.schemata;
grant select on pg_catalog.pg_namespace to public;
create table pg_catalog.pg_type( create table pg_catalog.pg_type(
oid int primary key, oid int primary key,
...@@ -40,6 +43,7 @@ create table pg_catalog.pg_type( ...@@ -40,6 +43,7 @@ create table pg_catalog.pg_type(
typtype varchar, typtype varchar,
typbasetype int, typbasetype int,
typtypmod int); typtypmod int);
grant select on pg_catalog.pg_type to public;
insert into pg_catalog.pg_type insert into pg_catalog.pg_type
select select
...@@ -107,6 +111,7 @@ select ...@@ -107,6 +111,7 @@ select
false relhasrules, false relhasrules,
false relhasoids false relhasoids
from information_schema.indexes; from information_schema.indexes;
grant select on pg_catalog.pg_class to public;
create table pg_catalog.pg_proc( create table pg_catalog.pg_proc(
oid int, oid int,
...@@ -114,6 +119,7 @@ create table pg_catalog.pg_proc( ...@@ -114,6 +119,7 @@ create table pg_catalog.pg_proc(
prorettype int, prorettype int,
pronamespace int pronamespace int
); );
grant select on pg_catalog.pg_proc to public;
create table pg_catalog.pg_trigger( create table pg_catalog.pg_trigger(
oid int, oid int,
...@@ -126,6 +132,7 @@ create table pg_catalog.pg_trigger( ...@@ -126,6 +132,7 @@ create table pg_catalog.pg_trigger(
tgconstrname varchar_ignorecase, tgconstrname varchar_ignorecase,
tgrelid int tgrelid int
); );
grant select on pg_catalog.pg_trigger to public;
create view pg_catalog.pg_attrdef -- (oid, adsrc, adrelid, adnum) create view pg_catalog.pg_attrdef -- (oid, adsrc, adrelid, adnum)
as as
...@@ -135,6 +142,7 @@ select ...@@ -135,6 +142,7 @@ select
0 adrelid, 0 adrelid,
0 adnum 0 adnum
from information_schema.tables where 1=0; from information_schema.tables where 1=0;
grant select on pg_catalog.pg_attrdef to public;
create view pg_catalog.pg_attribute -- (oid, attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, attisdropped, atthasdef) create view pg_catalog.pg_attribute -- (oid, attrelid, attname, atttypid, attlen, attnum, atttypmod, attnotnull, attisdropped, atthasdef)
as as
...@@ -169,6 +177,7 @@ where t.table_name = i.table_name ...@@ -169,6 +177,7 @@ where t.table_name = i.table_name
and t.table_schema = i.table_schema and t.table_schema = i.table_schema
and t.table_name = c.table_name and t.table_name = c.table_name
and t.table_schema = c.table_schema; and t.table_schema = c.table_schema;
grant select on pg_catalog.pg_attribute to public;
create view pg_catalog.pg_index -- (oid, indexrelid, indrelid, indisclustered, indisunique, indisprimary, indexprs, indkey) create view pg_catalog.pg_index -- (oid, indexrelid, indrelid, indisclustered, indisunique, indisprimary, indexprs, indkey)
as as
...@@ -187,6 +196,7 @@ and i.table_name = t.table_name ...@@ -187,6 +196,7 @@ and i.table_name = t.table_name
and i.ordinal_position = 1 and i.ordinal_position = 1
-- workaround for MS Access problem opening tables with primary key -- workaround for MS Access problem opening tables with primary key
and 1=0; and 1=0;
grant select on pg_catalog.pg_index to public;
drop alias if exists pg_get_indexdef; drop alias if exists pg_get_indexdef;
create alias pg_get_indexdef for "org.h2.server.pg.PgServer.getIndexColumn"; create alias pg_get_indexdef for "org.h2.server.pg.PgServer.getIndexColumn";
...@@ -226,6 +236,7 @@ create table pg_catalog.pg_database( ...@@ -226,6 +236,7 @@ create table pg_catalog.pg_database(
datdba int, datdba int,
dattablespace int dattablespace int
); );
grant select on pg_catalog.pg_database to public;
insert into pg_catalog.pg_database values( insert into pg_catalog.pg_database values(
0, -- oid 0, -- oid
...@@ -246,6 +257,7 @@ create table pg_catalog.pg_tablespace( ...@@ -246,6 +257,7 @@ create table pg_catalog.pg_tablespace(
spcowner int, spcowner int,
spcacl array -- aclitem[] spcacl array -- aclitem[]
); );
grant select on pg_catalog.pg_tablespace to public;
insert into pg_catalog.pg_tablespace values( insert into pg_catalog.pg_tablespace values(
0, 0,
...@@ -260,6 +272,7 @@ create table pg_catalog.pg_settings( ...@@ -260,6 +272,7 @@ create table pg_catalog.pg_settings(
name varchar_ignorecase, name varchar_ignorecase,
setting varchar_ignorecase setting varchar_ignorecase
); );
grant select on pg_catalog.pg_settings to public;
insert into pg_catalog.pg_settings values insert into pg_catalog.pg_settings values
(0, 'autovacuum', 'on'), (0, 'autovacuum', 'on'),
...@@ -274,6 +287,7 @@ select ...@@ -274,6 +287,7 @@ select
true usecreatedb, true usecreatedb,
true usesuper true usesuper
from information_schema.users; from information_schema.users;
grant select on pg_catalog.pg_user to public;
create table pg_catalog.pg_authid( create table pg_catalog.pg_authid(
oid int, oid int,
...@@ -289,8 +303,10 @@ create table pg_catalog.pg_authid( ...@@ -289,8 +303,10 @@ create table pg_catalog.pg_authid(
rolvaliduntil timestamp, -- timestamptz rolvaliduntil timestamp, -- timestamptz
rolconfig array -- text[] rolconfig array -- text[]
); );
grant select on pg_catalog.pg_authid to public;
create table pg_catalog.pg_am(oid int, amname varchar_ignorecase); create table pg_catalog.pg_am(oid int, amname varchar_ignorecase);
grant select on pg_catalog.pg_am to public;
insert into pg_catalog.pg_am values(0, 'btree'); insert into pg_catalog.pg_am values(0, 'btree');
insert into pg_catalog.pg_am values(1, 'hash'); insert into pg_catalog.pg_am values(1, 'hash');
...@@ -302,6 +318,7 @@ select ...@@ -302,6 +318,7 @@ select
-1 classoid, -1 classoid,
cast(datname as varchar_ignorecase) description cast(datname as varchar_ignorecase) description
from pg_catalog.pg_database; from pg_catalog.pg_database;
grant select on pg_catalog.pg_description to public;
create table pg_catalog.pg_group -- oid, groname create table pg_catalog.pg_group -- oid, groname
as as
...@@ -309,4 +326,4 @@ select ...@@ -309,4 +326,4 @@ select
0 oid, 0 oid,
cast('' as varchar_ignorecase) groname cast('' as varchar_ignorecase) groname
from pg_catalog.pg_database where 1=0; from pg_catalog.pg_database where 1=0;
grant select on pg_catalog.pg_group to public;
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论