vibhorkum / pg_background

pg_background
GNU General Public License v3.0
136 stars 35 forks source link

Error when make with Postgresql 11 #9

Closed denoley closed 4 years ago

denoley commented 5 years ago

I had errors when I make pg_background with Popstgresql 11:

bash-4.2$ make
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -I. -I./ -I/usr/pgsql-11/include/server -I/usr/pgsql-11/include/internal  -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include  -c -o pg_background.o pg_background.c
pg_background.c: In function ‘pg_background_result’:
pg_background.c:333:57: error: invalid type argument of ‘->’ (have ‘FormData_pg_attribute’)
     getTypeBinaryInputInfo(funcctx->tuple_desc->attrs[i]->atttypid,
                                                         ^
pg_background.c:440:89: error: invalid type argument of ‘->’ (have ‘FormData_pg_attribute’)
                                                         if (type_id != tupdesc->attrs[i]->atttypid)
                                                                                         ^
pg_background.c:446:74: error: invalid type argument of ‘->’ (have ‘FormData_pg_attribute’)
                                                 else if(tupdesc->attrs[i]->atttypid != TEXTOID)
                                                                          ^
pg_background.c:510:47: error: invalid type argument of ‘->’ (have ‘FormData_pg_attribute’)
   if (tupdesc->natts != 1 || tupdesc->attrs[0]->atttypid != TEXTOID)
                                               ^
pg_background.c: In function ‘form_result_tuple’:
pg_background.c:569:29: error: invalid type argument of ‘->’ (have ‘FormData_pg_attribute’)
            tupdesc->attrs[i]->atttypmod);
                             ^
pg_background.c:579:29: error: invalid type argument of ‘->’ (have ‘FormData_pg_attribute’)
            tupdesc->attrs[i]->atttypmod);
                             ^
pg_background.c: In function ‘pg_background_worker_main’:
pg_background.c:762:38: error: macro "AllocSetContextCreate" passed 5 arguments, but takes just 3
              ALLOCSET_DEFAULT_MAXSIZE);
                                      ^
pg_background.c:758:25: error: ‘AllocSetContextCreate’ undeclared (first use in this function)
  CurrentMemoryContext = AllocSetContextCreate(TopMemoryContext,
                         ^
pg_background.c:758:25: note: each undeclared identifier is reported only once for each function it appears in
pg_background.c:808:82: error: too few arguments to function ‘BackgroundWorkerInitializeConnection’
                                                                                  NameStr(fdata->authenticated_user));
                                                                                  ^
In file included from /usr/pgsql-11/include/server/storage/shm_mq.h:16:0,
                 from /usr/pgsql-11/include/server/libpq/pqmq.h:17,
                 from pg_background.c:27:
/usr/pgsql-11/include/server/postmaster/bgworker.h:143:13: note: declared here
 extern void BackgroundWorkerInitializeConnection(const char *dbname, const char *username, uint32 flags);
             ^
pg_background.c: In function ‘execute_sql_string’:
pg_background.c:896:36: error: macro "AllocSetContextCreate" passed 5 arguments, but takes just 3
            ALLOCSET_DEFAULT_MAXSIZE);
                                    ^
pg_background.c:892:17: error: ‘AllocSetContextCreate’ undeclared (first use in this function)
  parsecontext = AllocSetContextCreate(TopMemoryContext,
                 ^
make: *** [pg_background.o] Error 1
bash-4.2$
denoley commented 5 years ago

Severall errors i've fixed via:

For the code like this:

Form_pg_attribute att = tupdesc->attrs[i];

i've change it to like this:

Form_pg_attribute att = TupleDescAttr(tupdesc, i);

But one error still present:

bash-4.2$ make
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC -I. -I./ -I/usr/pgsql-11/include/server -I/usr/pgsql-11/include/internal  -D_GNU_SOURCE -I/usr/include/libxml2  -I/usr/include  -c -o pg_background.o pg_background.c
pg_background.c: In function ‘pg_background_worker_main’:
pg_background.c:825:82: error: too few arguments to function ‘BackgroundWorkerInitializeConnection’
                                                                                  NameStr(fdata->authenticated_user));
                                                                                  ^
In file included from /usr/pgsql-11/include/server/storage/shm_mq.h:16:0,
                 from /usr/pgsql-11/include/server/libpq/pqmq.h:17,
                 from pg_background.c:27:
/usr/pgsql-11/include/server/postmaster/bgworker.h:143:13: note: declared here
 extern void BackgroundWorkerInitializeConnection(const char *dbname, const char *username, uint32 flags);
             ^
make: *** [pg_background.o] Error 1
denoley commented 5 years ago

Last error has gone when i have modifed code

BackgroundWorkerInitializeConnection(NameStr(fdata->database),
                            NameStr(fdata->authenticated_user));

with

BackgroundWorkerInitializeConnection(NameStr(fdata->database),
                            NameStr(fdata->authenticated_user),
                            BGWORKER_BYPASS_ALLOWCONN);

because of [> Allow background workers to bypass datallowconn

THis adds a "flags" field to the BackgroundWorkerInitializeConnection() and BackgroundWorkerInitializeConnectionByOid(). For now only one flag, BGWORKER_BYPASS_ALLOWCONN, is defined, which allows the worker to ignore datallowconn. ](https://postgrespro.ru/list/thread-id/2381342)

vibhorkum commented 4 years ago

Fixed. Closing this.