Closed jefft closed 7 years ago
Hi, Thanks for the report, however I could not reproduce the seg fault. Please share your complete test case.
Also Can you please try this test case on your set up:
CREATE EXTENSION mysql_fdw;
CREATE SERVER mysql_server FOREIGN DATA WRAPPER mysql_fdw OPTIONS (host '127.0.0.1', port '3306');
CREATE USER MAPPING FOR abbasbutt SERVER mysql_server OPTIONS (username 'root', password 'what_ever');
CREATE FOREIGN TABLE foreign_test_tab(a int, b text) SERVER mysql_server OPTIONS (dbname 'msql_test_db', table_name 'test_tab');
select count(*) from foreign_test_tab;
prepare stmt(int) as select b from foreign_test_tab where a=$1;
execute stmt(1); execute stmt(2); execute stmt(3); execute stmt(4); execute stmt(5); execute stmt(6); execute stmt(7);
The test case works fine for me.
Thanks for checking! After further testing, I found the problem was due to a stale 'mysql_fdw.so' file. I was using make USE_PGXS=1 install
to rebuild from git. I needed to use make USE_PGXS=1 clean install
.
Because it would be a shame to let a test case go to waste, here is the full set of command for a clean Ubuntu system:
apt update
apt install -y postgresql-9.5 postgresql-server-dev-9.5 \
mariadb-server-10.0 libmysqlclient-dev \
make gcc
git clone https://github.com/EnterpriseDB/mysql_fdw.git
cd mysql_fdw
make USE_PGXS=1 clean install
cd ..
cat > mysql.sql <<EOF
create database msql_test_db;
use msql_test_db;
create table test_tab(a integer, b text);
insert into test_tab values (1, 'hello');
grant all on msql_test_db to 'root'@'localhost' identified by 'secret';
EOF
mysql < mysql.sql
sudo su - postgres
cat > postgres.sql <<EOF
CREATE DATABASE testdb;
\connect testdb;
CREATE EXTENSION mysql_fdw;
CREATE SERVER mysql_server FOREIGN DATA WRAPPER mysql_fdw OPTIONS (host '127.0.0.1', port '3306');
CREATE USER MAPPING FOR postgres SERVER mysql_server OPTIONS (username 'root', password 'secret');
CREATE FOREIGN TABLE foreign_test_tab(a int, b text) SERVER mysql_server OPTIONS (dbname 'msql_test_db', table_name 'test_tab');
EOF
psql < postgres.sql
psql testdb -tAc 'select * from foreign_test_tab;'
It appears mysql_fdw in git is segfaulting on all operations, at least in Postgres 9.5 on Ubuntu 16.04. Here I've installed it from git and ran a query on a previously established psql->mysql table:
The postgres log shows the segfault:
Reverting to the last official release gets it working again: