PostgreSQL 协议数据样例

本文详细分析了PostgreSQL数据库在启动时遇到的常见问题,包括缺失用户名、数据库、不存在的用户或密码错误等。此外,还展示了查询请求过程中的异常,如预期密码响应错误。最后,讨论了预编译语句的关闭和执行问题。这些问题对于理解和解决数据库连接故障至关重要。

Startup Message

Startup Message 缺少用户名

响应数据

0000   45 00 00 00 79 53 46 41 54 41 4c 00 56 46 41 54   E...ySFATAL.VFAT
0010   41 4c 00 43 32 38 30 30 30 00 4d 6e 6f 20 50 6f   AL.C28000.Mno Po
0020   73 74 67 72 65 53 51 4c 20 75 73 65 72 20 6e 61   stgreSQL user na
0030   6d 65 20 73 70 65 63 69 66 69 65 64 20 69 6e 20   me specified in 
0040   73 74 61 72 74 75 70 20 70 61 63 6b 65 74 00 46   startup packet.F
0050   70 6f 73 74 6d 61 73 74 65 72 2e 63 00 4c 32 32   postmaster.c.L22
0060   31 37 00 52 50 72 6f 63 65 73 73 53 74 61 72 74   17.RProcessStart
0070   75 70 50 61 63 6b 65 74 00 00                     upPacket..

响应数据

PostgreSQL
    Type: Error
    Length: 121
    Severity: FATAL
    Text: FATAL
    Code: 28000
    Message: no PostgreSQL user name specified in startup packet
    File: postmaster.c
    Line: 2217
    Routine: ProcessStartupPacket

Startup Message 缺少 Database

startupPacket 删除了 database 的 key-value,没有返回错误信息,继续进行认证。

请求数据:

0000   2a ca 99 b3 a5 ce ce 19 d8 bd 2a f8 08 00 45 00   *.........*...E.
0010   00 76 2c a3 40 00 40 06 3e 12 c0 a8 03 e9 0a f0   .v,.@.@.>.......
0020   00 4c 9f ea 15 38 b2 d7 bb e5 88 d3 54 bc 80 18   .L...8......T...
0030   02 00 d0 35 00 00 01 01 08 0a 43 67 be 76 0f a3   ...5......Cg.v..
0040   ca bf 00 00 00 42 00 03 00 00 75 73 65 72 00 70   .....B....user.p
0050   6f 73 74 67 72 65 73 00 61 70 70 6c 69 63 61 74   ostgres.applicat
0060   69 6f 6e 5f 6e 61 6d 65 00 70 73 71 6c 00 63 6c   ion_name.psql.cl
0070   69 65 6e 74 5f 65 6e 63 6f 64 69 6e 67 00 55 54   ient_encoding.UT
0080   46 38 00 00                                       F8..

Startup Message 指定不存在的数据库

响应数据

0000   45 00 00 00 5d 53 46 41 54 41 4c 00 56 46 41 54   E...]SFATAL.VFAT
0010   41 4c 00 43 33 44 30 30 30 00 4d 64 61 74 61 62   AL.C3D000.Mdatab
0020   61 73 65 20 22 68 65 6c 6c 6f 5f 73 73 22 20 64   ase "hello_ss" d
0030   6f 65 73 20 6e 6f 74 20 65 78 69 73 74 00 46 70   oes not exist.Fp
0040   6f 73 74 69 6e 69 74 2e 63 00 4c 38 39 30 00 52   ostinit.c.L890.R
0050   49 6e 69 74 50 6f 73 74 67 72 65 73 00 00         InitPostgres..

响应数据

PostgreSQL
    Type: Error
    Length: 93
    Severity: FATAL
    Text: FATAL
    Code: 3D000
    Message: database "hello_ss" does not exist
    File: postinit.c
    Line: 890
    Routine: InitPostgres

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wuweijie@apache.org

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值