AWS Aurora PostgreSQL 集群用户名长度限制

问题描述:

AWS  Aurora PostgreSQL引擎,在控制台创建,以及创建完成库之后的用户名长度限制?

分析过程 及 测试结果:

通过AWS RDS服务控制台上的主用户的说明,Aurora MySQL和PG是有区别的:

Aurora MySQL:1 to 32 alphanumeric characters. First character must be a letter.

Aurora PG: 1 to 16 alphanumeric characters. First character must be a letter.

而登录的Aurora PG之后,创建的用户名,其实是受identifier length 63 bytes这个限制的[1]。

我在测试中,从Aurora Postgres数据库中测试创建超过63bytes的Role,可以看到,输入指令以后,PG返回一个:NOTICE: identifier "xxxxx" - 即将超过63 byte的字符进行了截断。

在Aurora PostgreSQL内创建用户名的限制测试:

1. 当创建该用户名的时候,如果不加双引号,那么该用户名会在Postgres中以小写来创建。此时如果再用用户名来登录,便无法识别:

postgres=> create role qERTY97j_d login password 'xxx';
CREATE ROLE
postgres=> grant all privileges on database postgres to qERTY97j_d;
GRANT

[ec2-user@ip-19 ~]$ psql -UqERTY97j_d -p5432 -hjiangaupg.cluster-cpa1onesgnhw.rds.cn-north-1.amazonaws.com.cn  postgres.
Password for user qERTY97j_d:
psql: error: connection to server at "jiangaupg.cluster-cpa1onesgnhw.rds.cn-north-1.amazonaws.com.cn " (52.80.0.224), port 5432 failed: FATAL:  password authentication failed for user "qERTY97j_d"
connection to server at "jiangaupg.cluster-cpa1onesgnhw.rds.cn-north-1.amazonaws.com.cn " (52.80.0.224), port 5432 failed: FATAL:  password authentication failed for user "qERTY97j_d"

[ec2-user@ip-19 ~]$ psql -Uqerty97j_d -p5432 -hjiangaupg.cluster-cpa1onesgnhw.rds.cn-north-1.amazonaws.com.cn   postgres
Password for user qerty97j_d:
psql (14.3, server 13.7)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES128-GCM-SHA256, bits: 128, compression: off)
Type "help" for help.

postgres=> 

2. 创建用户的时候,可以通过双引号来让用户名的大小写在Postgres中识别,而在测试中,此用户名也进行了成功登录:

postgres=> create role "qERTY97j_deva_data_ro" login password 'xxx';
CREATE ROLE
postgres=> grant all privileges on database postgres to "qERTY97j_deva_data_ro";
GRANT
postgres=> ^C

[ec2-user@ip-192-168-0-87 ~]$ psql -UqERTY97j_deva_data_ro -p5432 -hjiangaupg.cluster-cpa1onesgnhw.rds.cn-north-1.amazonaws.com.cn   postgres
Password for user qERTY97j_deva_data_ro:
psql (14.3, server 13.7)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES128-GCM-SHA256, bits: 128, compression: off)
Type "help" for help.

postgres=>

3. 我从PostgreSQL官网中找到了双引号对于Case Sensitivity的相关说明[2], 粘贴英文原文如下:

Quoting an identifier also makes it case-sensitive, whereas unquoted names are always folded to lower case. For example, the identifiers FOO, foo, and "foo" are considered the same by PostgreSQL, but "Foo" and "FOO" are different from these three and each other. (The folding of unquoted names to lower case in PostgreSQL is incompatible with the SQL standard, which says that unquoted names should be folded to upper case. 

参考文档:
[1] PostgreSQL Limits: https://www.postgresql.org/docs/current/limits.html
[2] https://www.postgresql.org/docs/8.0/sql-syntax.html 
 

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值