我正在尝试编译并在我的系统中安装PostgreSQL。我的操作系统是Debian 9 gcc-4.9下面发布的是我的错误
The database cluster will be initialized with locale en_US.UTF-8. The default database encoding has accordingly been set to UTF8. creating directory p01/pgsql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers/max_fsm_pages ... 24MB/153600 creating configuration files ... ok creating template1 database in p01/pgsql/data/base/1 ... ok initializing pg_authid ... FATAL: wrong number of index expressions STATEMENT: CREATE TRIGGER pg_sync_pg_database AFTER INSERT OR UPDATE OR DELETE ON pg_database FOR EACH STATEMENT EXECUTE PROCEDURE flatfile_update_trigger(); child process exited with exit code 1 initdb: removing data directory "p01/pgsql/data"
在另一篇文章中,用户建议禁用“fno-aggressive-loop-optimizations”。但是如何禁用它?编译字体时,它是./configure中的参数。请参阅以下建议:
使用gcc 4.9.3编译postgresql 8.1.4后遇到了同样的问题。 问题似乎是postgres用来表示可变长度数组的方式:
typedef struct { int32 size; /* these fields must match ArrayType! */ int ndim; int flags; Oid elemtype; int dim1; int lbound1; int2 values[1]; /* VARIABLE LENGTH ARRAY */ } int2vector; /* VARIABLE LENGTH STRUCT */
在某些情况下,对于访问“值”的循环,GCC假定它们最多只进行一次迭代。下面的循环(从postgres的源代码中提取):
ii->ii_NumIndexAttrs = numKeys; for (i = 0; i < numKeys; i++) ii->ii_KeyAttrNumbers[i] = indexStruct->indkey.values[i];
可能最终被缩减为:
ii->ii_NumIndexAttrs = numKeys; if (numKeys) ii->ii_KeyAttrNumbers[0] = indexStruct->indkey.values[0];
通过查看为其生成的汇编程序推断:
.L161: testl %r12d, %r12d movl %r12d, 4(%rbx) jle .L162 movzwl 40(%r13), %eax movw %ax, 8(%rbx) .L162:
使用-fno-aggressive-loop-optimizations重新编译postgres后,问题就消失了。
答案 0 :(得分:1)
感谢您提示......我能够解决问题。
如果有人遇到这个问题,可以采取解决方案。
要使用GCC-4.9编译PostgreSQL 9.0.1源代码,我在postgresql源代码中使用了以下指令:
./configure -prefix=/opt/postgres9.0 CFLAGS="-Wno-aggressive-loop-optimizations"
Wno-aggressive-looop-optiimizations禁用积极的GCC优化,避免在先前的消息和讨论中报告的错误-List pgsql-general - &gt; https://www.postgresql.org/message-id/CAOD%3DoQ-kq3Eg5SOvRYOVxDuqibVWC8R0wEivPsMGcyzZY-nfzA%40mail.gmail.com
我希望删除&#34; GCC积极的循环优化&#34;不会导致DBMS中出现任何类型的错误。