turgs / sql_firewall

SQL Firewall Extension for PostgreSQL
http://pgsnaga.blogspot.jp/2015/08/postgresql-sql-firewall.html
Other
4 stars 3 forks source link

Compilation errors in Postgres 10 #1

Open turgs opened 6 years ago

turgs commented 6 years ago

On DigitalOcean, I have an Ubuntu 16.04 droplet, where Postgres is installed via apt-get.

This extension compiled and installed correctly on Postgres 9.6, however it's now failing with Postgres 10. Everything else is the same. I'm installing the same way, on Ubuntu 16.04. From a quick googling myself, it sounds like some API changes may have occurred in Postgres 10.

Compiling the extension via ‘sudo sh ./build.sh’ shows these errors:

sql_firewall.c: In function ‘_PG_init’:
sql_firewall.c:420:19: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
  ExecutorRun_hook = pgss_ExecutorRun;
                   ^
sql_firewall.c:426:22: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
  ProcessUtility_hook = pgss_ProcessUtility;
                      ^
sql_firewall.c: In function ‘pgss_ExecutorRun’:
sql_firewall.c:979:4: error: too few arguments to function ‘prev_ExecutorRun’
    prev_ExecutorRun(queryDesc, direction, count);
    ^
sql_firewall.c:981:4: error: too few arguments to function ‘standard_ExecutorRun’
    standard_ExecutorRun(queryDesc, direction, count);
    ^
In file included from /usr/include/postgresql/10/server/funcapi.h:22:0,
                 from sql_firewall.c:76:
/usr/include/postgresql/10/server/executor/executor.h:172:13: note: declared here
 extern void standard_ExecutorRun(QueryDesc *queryDesc,
             ^
sql_firewall.c: In function ‘pgss_ProcessUtility’:
sql_firewall.c:1086:25: warning: passing argument 1 of ‘prev_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
     prev_ProcessUtility(parsetree, queryString,
                         ^
sql_firewall.c:1086:25: note: expected ‘PlannedStmt * {aka struct PlannedStmt *}’ but argument is of type ‘Node * {aka struct Node *}’
sql_firewall.c:1088:10: warning: passing argument 5 of ‘prev_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
          dest, completionTag);
          ^
sql_firewall.c:1088:10: note: expected ‘QueryEnvironment * {aka struct QueryEnvironment *}’ but argument is of type ‘DestReceiver * {aka struct _DestReceiver *}’
sql_firewall.c:1088:16: warning: passing argument 6 of ‘prev_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
          dest, completionTag);
                ^
sql_firewall.c:1088:16: note: expected ‘DestReceiver * {aka struct _DestReceiver *}’ but argument is of type ‘char *’
sql_firewall.c:1086:5: error: too few arguments to function ‘prev_ProcessUtility’
     prev_ProcessUtility(parsetree, queryString,
     ^
sql_firewall.c:1090:29: warning: passing argument 1 of ‘standard_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
     standard_ProcessUtility(parsetree, queryString,
                             ^
In file included from sql_firewall.c:86:0:
/usr/include/postgresql/10/server/tcop/utility.h:38:13: note: expected ‘PlannedStmt * {aka struct PlannedStmt *}’ but argument is of type ‘Node * {aka struct Node *}’
 extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
             ^
sql_firewall.c:1092:11: warning: passing argument 5 of ‘standard_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
           dest, completionTag);
           ^
In file included from sql_firewall.c:86:0:
/usr/include/postgresql/10/server/tcop/utility.h:38:13: note: expected ‘QueryEnvironment * {aka struct QueryEnvironment *}’ but argument is of type ‘DestReceiver * {aka struct _DestReceiver *}’
 extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
             ^
sql_firewall.c:1092:17: warning: passing argument 6 of ‘standard_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
           dest, completionTag);
                 ^
In file included from sql_firewall.c:86:0:
/usr/include/postgresql/10/server/tcop/utility.h:38:13: note: expected ‘DestReceiver * {aka struct _DestReceiver *}’ but argument is of type ‘char *’
 extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
             ^
sql_firewall.c:1090:5: error: too few arguments to function ‘standard_ProcessUtility’
     standard_ProcessUtility(parsetree, queryString,
     ^
In file included from sql_firewall.c:86:0:
/usr/include/postgresql/10/server/tcop/utility.h:38:13: note: declared here
 extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
             ^
sql_firewall.c:1157:24: warning: passing argument 1 of ‘prev_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
    prev_ProcessUtility(parsetree, queryString,
                        ^
sql_firewall.c:1157:24: note: expected ‘PlannedStmt * {aka struct PlannedStmt *}’ but argument is of type ‘Node * {aka struct Node *}’
sql_firewall.c:1159:9: warning: passing argument 5 of ‘prev_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
         dest, completionTag);
         ^
sql_firewall.c:1159:9: note: expected ‘QueryEnvironment * {aka struct QueryEnvironment *}’ but argument is of type ‘DestReceiver * {aka struct _DestReceiver *}’
sql_firewall.c:1159:15: warning: passing argument 6 of ‘prev_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
         dest, completionTag);
               ^
sql_firewall.c:1159:15: note: expected ‘DestReceiver * {aka struct _DestReceiver *}’ but argument is of type ‘char *’
sql_firewall.c:1157:4: error: too few arguments to function ‘prev_ProcessUtility’
    prev_ProcessUtility(parsetree, queryString,
    ^
sql_firewall.c:1161:28: warning: passing argument 1 of ‘standard_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
    standard_ProcessUtility(parsetree, queryString,
                            ^
In file included from sql_firewall.c:86:0:
/usr/include/postgresql/10/server/tcop/utility.h:38:13: note: expected ‘PlannedStmt * {aka struct PlannedStmt *}’ but argument is of type ‘Node * {aka struct Node *}’
 extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
             ^
sql_firewall.c:1163:10: warning: passing argument 5 of ‘standard_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
          dest, completionTag);
          ^
In file included from sql_firewall.c:86:0:
/usr/include/postgresql/10/server/tcop/utility.h:38:13: note: expected ‘QueryEnvironment * {aka struct QueryEnvironment *}’ but argument is of type ‘DestReceiver * {aka struct _DestReceiver *}’
 extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
             ^
sql_firewall.c:1163:16: warning: passing argument 6 of ‘standard_ProcessUtility’ from incompatible pointer type [-Wincompatible-pointer-types]
          dest, completionTag);
                ^
In file included from sql_firewall.c:86:0:
/usr/include/postgresql/10/server/tcop/utility.h:38:13: note: expected ‘DestReceiver * {aka struct _DestReceiver *}’ but argument is of type ‘char *’
 extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
             ^
sql_firewall.c:1161:4: error: too few arguments to function ‘standard_ProcessUtility’
    standard_ProcessUtility(parsetree, queryString,
    ^
In file included from sql_firewall.c:86:0:
/usr/include/postgresql/10/server/tcop/utility.h:38:13: note: declared here
 extern void standard_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
             ^
<builtin>: recipe for target 'sql_firewall.o' failed
make: *** [sql_firewall.o] Error 1
turgs commented 6 years ago

Here are the exact steps I run on Ubuntu 16.04 as a bash file to install and configure postgres, and install the extension:

# INSTALL POSTGRES 10
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get -y update
sudo apt-get -y install postgresql-10 postgresql-contrib-10 postgresql-server-dev-10 gcc
sudo /etc/init.d/postgresql restart

# install sql_firewall
mkdir /home/deploy/sql_firewall
cd /home/deploy/sql_firewall
curl -sL https://github.com/turgs/sql_firewall/archive/develop.tar.gz | tar xz
cd sql_firewall-*
sudo sh ./build.sh ##### this line currently fails due to compilation errors
sudo sh ./build.sh install
cd
rm -rf /home/deploy/sql_firewall

sudo /etc/init.d/postgresql restart

# create my database and user
sudo -u postgres psql --command "CREATE USER myUser1 WITH PASSWORD 'password';"
sudo -u postgres psql --command 'CREATE DATABASE MyDatabase;'
sudo -u postgres psql --command 'GRANT ALL PRIVILEGES ON DATABASE MyDatabase to myUser1;'

# add extension
sudo -u postgres psql MyDatabase --command 'CREATE EXTENSION sql_firewall;'

sudo /etc/init.d/postgresql restart