我已经尝试在postgresql.conf中将'log_min_error_statement'设置为debug5,但是在控制台和postgresql日志中,我仍然收到标准的“ PostgreSQL说:“ AS”或附近的语法错误“错误消息。
如果PostgreSQL知道错误是什么,至少在大多数情况下,它会告诉您。
如果它仅显示“语法错误……或附近...”,则说明您的意思是不正确的,并且无法猜测出什么地方出了问题。这是一个解析错误。它可能会提供(很长的)建议列表,但这会使错误消息变得非常荒谬,例如:
postgres=# SELECT AS fred ORDER BY 1;
ERROR: syntax error at or near "AS"
LINE 1: SELECT AS fred ORDER BY 1;
是的,这是语法错误,因为它在任何级别上都没有意义。它出什么问题了?您如何简洁地描述这一点?解析器如何分辨出什么问题?
postgres=# SELECT AS fred ORDER BY 1;
ERROR: syntax error at or near "AS"
LINE 1: SELECT AS fred ORDER BY 1;
HINT: typo?
HINT: Did you use a reserved keyword as an identifier without "quoting" it? Like "AS"?
HINT: Did you leave out the value before the AS keyword?
HINT: ... endless possibilities ...
有时,解析器可以猜测出您可能做错了什么。PostgreSQL的解析器试图告诉您什么时候可以,例如
psql -c "SELECT 'openquote";
ERROR: unterminated quoted string at or near "'openquote"
LINE 1: SELECT 'openquote
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句