postgresql - 为什么只有 super 用户可以 CREATE EXTENSION hstore,而不能在 Heroku 上创建?

标签 postgresql heroku hstore

当我尝试在我的数据库上启用 hstore 时:

=> CREATE EXTENSION IF NOT EXISTS hstore;
ERROR:  permission denied to create extension "hstore"
HINT:  Must be superuser to create this extension.

我的用户不是 super 用户,但数据库的所有者。

根据 the CREATE EXTENSION docs :

Loading an extension requires the same privileges that would be required to create its component objects. For most extensions this means superuser or database owner privileges are needed. The user who runs CREATE EXTENSION becomes the owner of the extension for purposes of later privilege checks, as well as the owner of any objects created by the extension's script.

hstore 做什么需要 super 用户权限?它会影响我将其添加到的数据库之外的部分集群吗?


进一步的混淆:

The DB user Heroku Postgres provides is not a superuser :

Heroku Postgres users are granted all non-superuser permissions on their database. These include SELECT, INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER, CREATE, CONNECT, TEMPORARY, EXECUTE, and USAGE.

然而,that user is able to CREATE EXTENSION hstore :

To create any supported extension, open a session with heroku pg:psql and run the appropriate command:

$ heroku pg:psql
Pager usage is off.
psql (9.2.4)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.

ad27m1eao6kqb1=> CREATE EXTENSION hstore;
CREATE EXTENSION
ad27m1eao6kqb1=>

(对于上下文,我正在尝试设置一个 Dokku 部署,因此与 Heroku 的比较尤为重要。)

最佳答案

hstore 扩展创建从外部动态对象调用代码的函数,这需要 super 用户权限。这就是创建 hstore 扩展需要 super 用户权限的原因。

至于 Heroku,我的理解是他们运行着一个特殊的扩展白名单模块,允许用户创建某些扩展,即使他们不是 super 用户。我相信它基于以下代码:https://github.com/dimitri/pgextwlist .如果您想在数据库中使用相同的功能,您可以尝试自己安装该代码。

关于postgresql - 为什么只有 super 用户可以 CREATE EXTENSION hstore,而不能在 Heroku 上创建?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20723100/

相关文章:

python - 添加 hstore 字段后如何创建迁移? (django-hstore 与南方)

node.js - 在 Heroku 上的 NodeJS 中创建两个 Redis To Go 客户端时出错

arrays - 将 HSTORE 数组值转换为 JSONB 中的列

python - psycopg2 无法插入特定列

PostgreSQL: block 中的页眉无效

ruby-on-rails - 我是否正确地在 Heroku + Unicorn 中预加载了应用程序?

node.js - 推送被拒绝,无法编译 Node.js 应用程序

postgresql - 这是 hstore 的正确用法吗?

java - JPA - 在 Postgresql 上保留 LOB 属性

sql - 如何根据另一列的值查找一列的值?