Hubert 'depesz' Lubaczewski: Don’t do these things in PostgreSQL

栏目: IT技术 · 发布时间: 6年前

内容简介:In 2018Since then there have been 30 changes, done by nine more people.Based on some conversation onirc I figured I can write a tool to automatically check these rules. Or at least – most of them.

In 2018 Lluad created wiki page with couple of rules about what not to do .

Since then there have been 30 changes, done by nine more people.

Based on some conversation onirc I figured I can write a tool to automatically check these rules. Or at least – most of them.

Currently wiki lists contains 18 rules:

Not all of them can be checked from within database, using SQL queries (for example, Don't use psql -W or –password ). But most can.

So pgWikiDont project was born. To run it, you generally need only to download it, cd to its directory, and run

=$ psql -f pgWikiDont.sql

Output can look like this:

pgWikiDont version 0.2 
 
Your database violates 2 rule(s):
=================================
 
Rule: Don't use money
  details: https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_money
  You have 1 column(s) that use money datatype:
      - public.z.x
 
Rule: Don't use trust authentication over TCP/IP (host, hostssl)
  details: https://wiki.postgresql.org/wiki/Don't_Do_This#Don.27t_use_trust_authentication_over_TCP.2FIP_.28host.2C_hostssl.29
  You have 4 rule(s) in pg_hba.conf that use TRUST over TCP/IP:
      - host    replication all         127.0.0.1/32          trust
      - host    replication all         ::1/128               trust
      - host    all         all         127.0.0.1/32          trust
      - host    all         all         ::1/128               trust
 
 
 WARNINGS: 
===========
- You don't seem to have pg_stat_statements enabled, so queries can't be checked.

or like this:

pgWikiDont version 0.2 
 
Looks that your database is clean. Congratulations.
===================================================
 
 
 WARNINGS: 
===========
- You don't seem to have pg_stat_statements enabled, so queries can't be checked.
- Can't check for TRUST authentication because your hba file (/etc/postgresql/11/main/pg_hba.conf) is outside of data_directory (/var/lib/postgresql/11/main).

or, hopefully, simply:

pgWikiDont version 0.2 
 
Looks that your database is clean. Congratulations.
===================================================

It doesn't require any special programs or tools – just psql and installed pl/PgSQL language.

I tried hard to make it work on all supported PostgreSQL versions, but bugs can happen. If anything bad would happen, please create issue , or simply reach me onirc.

Hope you'll find it useful.


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

人人都是产品经理

人人都是产品经理

苏杰 / 电子工业出版社 / 2014-9-1 / CNY 55.00

《人人都是产品经理(纪念版)》为经典畅销书《人人都是产品经理》的内容升级版本。对于大量成长起来的优秀互联网产品经理,为数不少想投身产品工作的其他岗位从业者,以及更多有志从事这一职业的学生而言,这本书曾是他们记忆深刻的启蒙读物、思想基石和行动手册。作者以分享经历与体会为出发点,以“朋友间聊聊如何做产品”的语气,将自己数年产品工作过程中学到的思维方法与做事方式,及其它们对自己的帮助,系统性地梳理为用户......一起来看看 《人人都是产品经理》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具