首页 文章

initdb:初始化pg_authid ... FATAL:索引表达式的数量错误

提问于
浏览
6

我是PostgreSql的新手 . 我正在尝试在我的系统中安装PostgreSql . 我的操作系统是Ubuntu,下面发布的是我的错误

将使用区域设置en_US.UTF-8初始化数据库群集 . 因此,默认数据库编码已设置为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"

帮帮我!!谢谢!

3 回答

  • 4

    用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:
    

    重新编译postgres后,通过使用-fno-aggressive-loop-optimizations禁用了该优化,问题就消失了 .

  • 3

    @Rhim似乎是正确的 - you've hit what was assumed to be a compiler bug . 您可能希望更新到最新的gcc包然后 make clean ,以 CFLAGS="-O1" 作为参数重新运行 configure ,然后重新编译 .

    顺便说一句,这表明您正在编译PostgreSQL 8.4或更早版本,因为 pg_sync_pg_database 没有出现在9.0或更新版本中 . 您还必须在较新的主机上进行编译 . 由于PostgreSQL 8.4很快就会终止并且不受支持,这可能不是一个好主意 .

    它还建议您编译自己的版本而不是使用包 . 你应该使用http://apt.postgresql.org/而不是自己编译,除非你有一个很好的具体原因 .

  • 3

    我为centos 7(3.10.0-229.el7.x86_64)构建了centos 5版本的postgresql(8.2)时遇到了同样的问题 .

    我无法使用CFLAGS =“ - O1”技巧使用gcc-4.8.3,但是因为编译器(CC = clang)对我起作用而切换到clang(3.4.2)(并且它有效)在默认的-O2优化级别 . )

相关问题