Install postgres extension PGXN "fatal error: unistd.h: No such file or directory" - postgresql

I need to sync some postgres tables with elasticsearch and come to conclusion that the best solution for my case is the one described here. Unfortunately I'm still failing to install required postgres extension amqp.
I use docker so I start from image postgres:13-alpine.
Here is how my Dockerfile looks like so far:
FROM postgres:13-alpine
ENV POSTGRES_DB ''
ENV POSTGRES_USER ''
ENV POSTGRES_PASSWORD ''
RUN apk update \
&& apk add py-pip make gcc \
&& pip install pgxnclient
Then when you enter the container and try to run pgxn install pg_amqp you will get following error.
bash-5.1# pgxn install pg_amqp
INFO: best version: pg_amqp 0.3.0
INFO: saving /tmp/tmpgjtefhgh/pg_amqp-0.3.0.zip
INFO: unpacking: /tmp/tmpgjtefhgh/pg_amqp-0.3.0.zip
INFO: building extension
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -O2 -fPIC -I. -I./ -I/usr/local/include/postgresql/server -I/usr/local/include/postgresql/internal -D_GNU_SOURCE -I/usr/include/libxml2 -c -o src/pg_amqp.o src/pg_amqp.c
src/pg_amqp.c:36:10: fatal error: unistd.h: No such file or directory
36 | #include <unistd.h>
| ^~~~~~~~~~
compilation terminated.
make: *** [<builtin>: src/pg_amqp.o] Error 1
ERROR: command returned 2: make PG_CONFIG=/usr/local/bin/pg_config all
It seems that I am out of the ideas what to do with that. Any help?

You are missing the musl C library (libc) implementation: musl-dev
RUN apk update \
&& apk add py-pip make gcc musl-dev \
&& pip install pgxnclient

Related

Unable to setup pg_repack in ubuntu22.04.1 LTS

I want to perform pg_repack in remote postgres server. pg_repack is used to remove bloat from PostgreSQL.
I am following this for reference: https://reorg.github.io/pg_repack/#installation
After installing pgxn, we need to install pg_repack. It's done by
sudo pgxn install pg_repack
And it's resulting in this
INFO: best version: pg_repack 1.4.8
INFO: saving /tmp/tmp3dyb4e3e/pg_repack-1.4.8.zip
INFO: unpacking: /tmp/tmp3dyb4e3e/pg_repack-1.4.8.zip
INFO: building extension
gmake[1]: Entering directory '/tmp/tmp3dyb4e3e/pg_repack-1.4.8/bin'
gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Werror=vla -Wendif-labels -Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -Wno-format-truncation -Wno-stringop-truncation -g -g -O2 -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fno-omit-frame-pointer -I/usr/include/postgresql -DREPACK_VERSION=1.4.8 -I. -I./ -I/usr/include/postgresql/14/server -I/usr/include/postgresql/internal -Wdate-time -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -c -o pg_repack.o pg_repack.c
gmake[1]: gcc: No such file or directory
gmake[1]: *** [<builtin>: pg_repack.o] Error 127
gmake[1]: Leaving directory '/tmp/tmp3dyb4e3e/pg_repack-1.4.8/bin'
gmake: *** [Makefile:35: all] Error 2
ERROR: command returned 2: gmake PG_CONFIG=/usr/bin/pg_config all`
I tried to clone this repo and perform gmake on it directly
gmake PG_CONFIG=/pg_config all
but still I'm getting
gmake: *** No rule to make target 'all'. Stop.

Compiling psqlODBC on CENTOS 7 gives me errors in connection.c - undeclared identifiers

So i'm stuck again.
What I want to do: access a postgreSQL database via database link from Oracle (12.1 - yes, I know it's old ...).
Oracle is running on Centos 7.
Initially I did a
yum -y install postgresql-odbc
yum -y install unixODBC
and was able to access postgreSQL (running on another machine).
But it didn't work for UTF-8 data. Got a hint that this might be due to an old version of unixODBC so I decided to compile from source (as the centos package is rather old).
Compiling and installing unixODBC worked without a hassle:
wget http://www.unixodbc.org/unixODBC-2.3.11.tar.gz
tar xzf unixODBC-2.3.11.tar.gz
cd unixODBC-2.3.11/
./configure
make
make install
But compiling psqlODBC is where it's at:
yum install postgresql
yum install postgresql-devel
wget https://ftp.postgresql.org/pub/odbc/versions/src/psqlodbc-13.02.0000.tar.gz
cd psqlodbc-13.02.0000/
./configure
make
...
Make gives me the following output:
[root#tukanbox psqlodbc-13.02.0000]# make
make all-am
make[1]: Entering directory `/root/psqlodbc-13.02.0000'
/bin/sh ./libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I/usr/local/include -I/usr/include -I/usr/include/pgsql/internal -DUNICODE_SUPPORT -g -O2 -Wall -MT psqlodbcw_la-connection.lo -MD -MP -MF .deps/psqlodbcw_la-connection.Tpo -c -o psqlodbcw_la-connection.lo `test -f 'connection.c' || echo './'`connection.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I/usr/local/include -I/usr/include -I/usr/include/pgsql/internal -DUNICODE_SUPPORT -g -O2 -Wall -MT psqlodbcw_la-connection.lo -MD -MP -MF .deps/psqlodbcw_la-connection.Tpo -c connection.c -fPIC -DPIC -o .libs/psqlodbcw_la-connection.o
connection.c: In function 'handle_pgres_error':
connection.c:900:45: error: 'PG_DIAG_SCHEMA_NAME' undeclared (first use in this function)
errschemaname = PQresultErrorField(pgres, PG_DIAG_SCHEMA_NAME);
^
connection.c:900:45: note: each undeclared identifier is reported only once for each function it appears in
connection.c:901:44: error: 'PG_DIAG_TABLE_NAME' undeclared (first use in this function)
errtablename = PQresultErrorField(pgres, PG_DIAG_TABLE_NAME);
^
connection.c:902:45: error: 'PG_DIAG_COLUMN_NAME' undeclared (first use in this function)
errcolumnname = PQresultErrorField(pgres, PG_DIAG_COLUMN_NAME);
^
connection.c:903:47: error: 'PG_DIAG_DATATYPE_NAME' undeclared (first use in this function)
errdatatypename = PQresultErrorField(pgres, PG_DIAG_DATATYPE_NAME);
^
make[1]: *** [psqlodbcw_la-connection.lo] Fehler 1
make[1]: Leaving directory `/root/psqlodbc-13.02.0000'
make: *** [all] Fehler 2
Wondering where to declare these undeclared idenifiers. What does it want to know here? How to solve it?
No answer to the problem of not being able to compile - but an answer to the original problem that the original packages didn't work for UTF8:
https://www.postgresql.org/message-id/OFA166DBFD.19742AF7-ONC1257B6A.005692E6-C1257B6A.0056F890#lladro.net
This has to be done in the database as sysdba:
select fds_class_name from HS_FDS_CLASS;
select * from hs_class_caps where upper(CAP_DESCRIPTION) like '%NCHAR%' and FDS_CLASS_NAME ='ODBC12.1.0.1.0_0017';
exec DBMS_HS.ALTER_CLASS_CAPS('ODBC12.1.0.1.0_0017' , 564, 'ODBC12.1.0.1.0_0017', 564,131071, NULL, NULL);

MySQL Workbench for PostgreSQL - ./psqlodbc.h:41:10: fatal error: 'sql.h' file not found

I am trying to connect to a Postgres db trough MySQL Workbench.
Following the documentation we need to install a driver for psql in our machine.
I am running a MacOS Big Sur 11.2.3.
After run CFLAGS="-arch i386 -arch x86_64" make I'm getting the following error:
/Library/Developer/CommandLineTools/usr/bin/make all-am
source='info.c' object='info.lo' libtool=yes \
depfile='.deps/info.Plo' tmpdepfile='.deps/info.TPlo' \
depmode=gcc3 /bin/sh ./depcomp \
/bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c -o info.lo `test -f 'info.c' || echo './'`info.c
gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -c info.c -MT info.lo -MD -MP -MF .deps/info.TPlo -fno-common -DPIC -o info.lo
In file included from info.c:19:
./psqlodbc.h:41:10: fatal error: 'sql.h' file not found
#include <sql.h>
^~~~~~~
1 error generated.
make[1]: *** [info.lo] Error 1
make: *** [all] Error 2
It seems that the 'sql.h' file is not found.
How to solve this issue?

how to build pipeline_kafka extension

i'm currently trying to compile the pipeline_kafka extension from Github to add it to my pipelinedb instance but i'm running in a problem neither i nor google seems to be able to solve.
when i execute make command i get the following error
stc#vm:~/pipeline_kafka$ make gcc -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -g -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -I/usr/include/mit-krb5 -fPIC -pie -DLINUX_OOM_SCORE_ADJ=0 -fno-omit-frame-pointer -fpic -I. -I./ -I/usr/include/postgresql/9.4/server -I/usr/include/postgresql/internal -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/include/tcl8.6 -c -o pipeline_kafka.o pipeline_kafka.c pipeline_kafka.c:23:40: fatal error: catalog/pipeline_stream_fn.h: No such file or directory #include "catalog/pipeline_stream_fn.h" ^ compilation terminated. : recipe for target 'pipeline_kafka.o' failed make: *** [pipeline_kafka.o] Error 1
does anyone has an idea what to do? I'm running on debian 8.
Does anyone know why this extension is not part of pipelinedb anymore?
cheers and thanks in advance
the reason for the error is my entire approach towards using/installing pipelinedb and pipeline_kafka.
the following script worked for me on a standard Debian 8 installation. Maybe it helps.
Download and install PipelineDB
wget -O pipelinedb_install_package "https://www.pipelinedb.com/download/0.9.1/debian8"
sudo dpkg -i pipelinedb_install_package
mkdir ~/logs
pipeline-init -D ~/data/pipelinedb
pipeline-ctl -D ~/data/pipelinedb -l ~/logs/pipelinedb.log start
sleep 5.0
pipeline pipeline
Download and install pipeline_kafka extension
sudo apt-get install git gcc g++ zlib1g-dev
mkdir ~/git
git clone https://github.com/edenhill/librdkafka.git ~/git/librdkafka
git clone https://github.com/pipelinedb/pipeline_kafka.git >~/git/pipeline_kafka
cd ~/git/librdkafka
./configure --prefix=/usr
make
sudo make install
cd ~/git/pipeline_kafka
./configure
make
sudo make install
pipeline pipeline -c "CREATE EXTENSION pipeline_kafka;"
sed -i 's/#shared_preload_libraries/shared_preload_libraries/' ~/data/pipelinedb/pipelinedb.conf
sed -i "s/shared_preload_libraries = ''/shared_preload_libraries=pipeline_kafka/" ~/data/pipelinedb/pipelinedb.conf

bdw-gc install failed on lion with brew

i am install w3m with brew on lion. when i use the origin formula the installation is filed.
then i following the issues 7068 of homebrew update the bdw-gc.rb formula script
require 'formula'
class BdwGc < Formula
# url 'http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-7.1.tar.gz'
url 'http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-7.2alpha6.tar.gz'
homepage 'http://www.hpl.hp.com/personal/Hans_Boehm/gc/'
# 7.1
# md5 '2ff9924c7249ef7f736ecfe6f08f3f9b'
# 7.2alpha6
md5 '319d0b18cc4eb735c8038ece9df055e4'
fails_with_llvm "LLVM gives an unsupported inline asm error", :build => 2335
def install
# ucontext has been deprecated in 10.6
# use this flag to force the header to compile
# ENV.append 'CPPFLAGS', "-D_XOPEN_SOURCE" if MacOS.snow_leopard?
ENV.append 'CPPFLAGS', "-D_XOPEN_SOURCE"# if MacOS.snow_leopard?
system "./configure", "--disable-debug", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make install"
end
end
and reinstall it, but it's still failed. here is the install log
brew install bdw-gc
==> Downloading http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-7.2alp
File already downloaded in /Users/akira/Library/Caches/Homebrew
==> ./configure --disable-debug --prefix=/usr/local/Cellar/bdw-gc/6
==> make install
........
libtool: compile: /usr/bin/llvm-gcc -DHAVE_CONFIG_H -I./include -I./include -I./libatomic_ops/src -I./libatomic_ops/src -D_XOPEN_SOURCE -fexceptions -O3 -march=core2 -w -pipe -c obj_map.c -o obj_map.o >/dev/null 2>&1
/bin/sh ./libtool --tag=CC --mode=compile /usr/bin/llvm-gcc -DHAVE_CONFIG_H -I./include -I./include -I./libatomic_ops/src -I./libatomic_ops/src -D_XOPEN_SOURCE -fexceptions -O3 -march=core2 -w -pipe -c -o pcr_interface.lo pcr_interface.c
./libatomic_ops/src/atomic_ops/sysdeps/gcc/x86_64.h: In function 'AO_test_and_set_full':
./libatomic_ops/src/ato==> Exit Status: 2
http://github.com/mxcl/homebrew/blob/master/Library/Formula/bdw-gc.rb#L22
==> Environment
HOMEBREW_VERSION: 0.8
HEAD: bc90bd554da6bd1199bdec92a830edbca24fa34e
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: quad-core 64-bit sandybridge
OS X: 10.7.2
Kernel Architecture: x86_64
Ruby: 1.8.7-249
/usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Xcode: 4.2
GCC-4.0: N/A
GCC-4.2: build 5666
LLVM: build 2336
MacPorts or Fink? false
X11 installed? true
==> Build Flags
CC: /usr/bin/llvm-gcc => /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2
CXX: /usr/bin/llvm-g++ => /usr/llvm-gcc-4.2/bin/llvm-g++-4.2
LD: /usr/bin/llvm-gcc => /usr/llvm-gcc-4.2/bin/llvm-gcc-4.2
CFLAGS: -O3 -march=core2 -w -pipe
CXXFLAGS: -O3 -march=core2 -w -pipe
CPPFLAGS: -D_XOPEN_SOURCE
MAKEFLAGS: -j4
Error: Failed executing: make install
These existing issues may help you:
https://github.com/mxcl/homebrew/issues/7068
Otherwise, please report the bug:
https://github.com/mxcl/homebrew/wiki/checklist-before-filing-a-new-issue
any suggestion?
this problem was fixed by Jack Nagel at Nov 15, 2011.
see the detail
bdw-gc: add 7.2alpha6 as the '--devel' version
but this batch still got a problem. the "make check" step does not works,so you can just skip this step and "make install".