Initdb: initializing pg_authid ... FATAL: incorrect number of index expressions

I am new to PostgreSql.I'm trying to install PostgreSql on my system. My operating system is Ubuntu, my error is posted below

The database cluster will be initialized with locale en_US.UTF-8. By default, the encoding of the database is 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" 

Help me! Thanks!

+6
source share
3 answers

I ran into the same problem after compiling postgresql 8.1.4 with gcc 4.9.3.

The problem is that postgres uses to represent variable-length arrays:

 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 */ 

In some cases, for loops referring to "values", GCC assumes that they will do one iteration at most. Loops like the following (extracted from postgres source code):

 ii->ii_NumIndexAttrs = numKeys; for (i = 0; i < numKeys; i++) ii->ii_KeyAttrNumbers[i] = indexStruct->indkey.values[i]; 

can be reduced to something like:

 ii->ii_NumIndexAttrs = numKeys; if (numKeys) ii->ii_KeyAttrNumbers[0] = indexStruct->indkey.values[0]; 

as shown in the assembler generated for it:

 .L161: testl %r12d, %r12d movl %r12d, 4(%rbx) jle .L162 movzwl 40(%r13), %eax movw %ax, 8(%rbx) .L162: 

The problem disappeared after recompiling postgres with optimization disabled using -fno-aggressive optimization loops.

+4
source

@Rhim seems right - you are in what was considered a compiler error . You might want to upgrade to the latest gcc packages, then make clean , run configure with CFLAGS="-O1" as an argument, and then recompile.

By the way, this means that you are compiling PostgreSQL 8.4 or later, since pg_sync_pg_database does not appear in 9.0 or later. You must also compile the new host. Since PostgreSQL 8.4 will be near the end of its life and is not supported, this is probably not a good idea.

It also suggests that you compile your own version, rather than using packages. You should use http://apt.postgresql.org/ rather than compiling your own unless you have a special reason.

+3
source

I ran into the same problem when creating the centos 5 postgresql (8.2) version for centos 7 (3.10.0-229.el7.x86_64.)

I was not able to get it to work with gcc-4.8.3 using CFLAGS = "- O1", but switching to clang (3.4.2), since the compiler (CC = clang) really worked for me (and it worked at the optimization level by default is O2.)

+3
source

Source: https://habr.com/ru/post/974586/


All Articles