{"action":"opened","issue":{"url":"https://api.github.com/repos/tds-fdw/tds_fdw/issues/74","repository_url":"https://api.github.com/repos/tds-fdw/tds_fdw","labels_url":"https://api.github.com/repos/tds-fdw/tds_fdw/issues/74/labels{/name}","comments_url":"https://api.github.com/repos/tds-fdw/tds_fdw/issues/74/comments","events_url":"https://api.github.com/repos/tds-fdw/tds_fdw/issues/74/events","html_url":"https://github.com/tds-fdw/tds_fdw/issues/74","id":151402658,"number":74,"title":"PG 9.5.2, freetds + tds_fdw => server crash\t","user":{"login":"danielwestermann","id":13865881,"avatar_url":"https://avatars.githubusercontent.com/u/13865881?v=3","gravatar_id":"","url":"https://api.github.com/users/danielwestermann","html_url":"https://github.com/danielwestermann","followers_url":"https://api.github.com/users/danielwestermann/followers","following_url":"https://api.github.com/users/danielwestermann/following{/other_user}","gists_url":"https://api.github.com/users/danielwestermann/gists{/gist_id}","starred_url":"https://api.github.com/users/danielwestermann/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielwestermann/subscriptions","organizations_url":"https://api.github.com/users/danielwestermann/orgs","repos_url":"https://api.github.com/users/danielwestermann/repos","events_url":"https://api.github.com/users/danielwestermann/events{/privacy}","received_events_url":"https://api.github.com/users/danielwestermann/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-27T14:38:47Z","updated_at":"2016-04-27T14:38:47Z","closed_at":null,"body":"Hi,\r\n\r\nI have installed freetds and can connect to the remote mssql server:\r\n\r\npostgres@pgreporting:/home/postgres/ [PGREP] tsql -S mssql -U ds2user -P xxxxxxx -D ds2 -o v\r\nlocale is \"LC_CTYPE=en_US.UTF-8;LC_NUMERIC=de_CH.UTF-8;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=de_CH.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=de_CH.UTF-8;LC_NAME=de_CH.UTF-8;LC_ADDRESS=de_CH.UTF-8;LC_TELEPHONE=de_CH.UTF-8;LC_MEASUREMENT=de_CH.UTF-8;LC_IDENTIFICATION=de_CH.UTF-8\"\r\nlocale charset is \"UTF-8\"\r\nusing default charset \"UTF-8\"\r\nSetting ds2 as default database in login packet\r\n1> select count(*) from sys.databases;\r\n2> go\r\n\r\n5\r\n(1 row affected)\r\nusing TDS version 7.3\r\n\r\nPostgreSQL version is 9.5.2:\r\n\r\npostgres=# select version();\r\n                                                          version                                                           \r\n----------------------------------------------------------------------------------------------------------------------------\r\n PostgreSQL 9.5.2 dbi services build on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4), 64-bit\r\n(1 row)\r\n\r\n\r\nCreated the fdw stuff like this:\r\n\r\n\r\npostgres=# \\dx\r\n                                            List of installed extensions\r\n  Name   | Version |   Schema   |                                    Description                                    \r\n---------+---------+------------+-----------------------------------------------------------------------------------\r\n plpgsql | 1.0     | pg_catalog | PL/pgSQL procedural language\r\n tds_fdw | 1.0.7   | public     | Foreign data wrapper for querying a TDS database (Sybase or Microsoft SQL Server)\r\n(2 rows)\r\n\r\npostgres=# create server mssql_svr foreign data wrapper tds_fdw options ( servername '192.168.22.102', port '1433',  database 'ds2', tds_version '7.3', msg_handler 'notice' );\r\nCREATE SERVER\r\npostgres=# CREATE USER MAPPING FOR postgres SERVER mssql_svr  OPTIONS (username 'ds2user', password 'xxxxxx');\r\nCREATE USER MAPPING\r\npostgres=# create foreign table ds2_mssql.customers (CUSTOMERID            int\r\n,FIRSTNAME             varchar(50)\r\n,LASTNAME              varchar(50)\r\n,ADDRESS1              varchar(50)\r\n,ADDRESS2              varchar(50)\r\n,CITY                  varchar(50)\r\n,STATE                 varchar(50)\r\n,ZIP                   int\r\n,COUNTRY               varchar(50)\r\n,REGION                int\r\n,EMAIL                 varchar(50)\r\n,PHONE                 varchar(50)\r\n,CREDITCARDTYPE        int\r\n,CREDITCARD            varchar(50)\r\n,CREDITCARDEXPIRATION  varchar(50)\r\n,USERNAME              varchar(50)\r\n,PASSWORD              varchar(50)\r\n,AGE                   int\r\n,GENDER                varchar(50))\r\nSERVER mssql_svr\r\n    OPTIONS (query 'select * from dbo.customers', row_estimate_method 'showplan_all');\r\nCREATE FOREIGN TABLE\r\n\r\nOnce I do a select from the foreign table the server just crashes:\r\n\r\npostgres=# select count(*) from ds2_mssql.customers;\r\nserver closed the connection unexpectedly\r\n    This probably means the server terminated abnormally\r\n    before or while processing the request.\r\nThe connection to the server was lost. Attempting reset: Failed.\r\n!> \r\n\r\nThis is from the log:\r\n\r\n2016-04-24 14:34:31.896 CEST - 16 - 23252 -  - @ LOG:  server process (PID 23796) was terminated by signal 11: Segmentation fault\r\n2016-04-24 14:34:31.896 CEST - 17 - 23252 -  - @ DETAIL:  Failed process was running: select count(*) from ds2_mssql.customers;\r\n2016-04-24 14:34:31.896 CEST - 18 - 23252 -  - @ LOG:  terminating any other active server processes\r\n2016-04-24 14:34:31.898 CEST - 2 - 23454 -  - @ WARNING:  terminating connection because of crash of another server process\r\n2016-04-24 14:34:31.898 CEST - 3 - 23454 -  - @ DETAIL:  The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory.\r\n2016-04-24 14:34:31.898 CEST - 4 - 23454 -  - @ HINT:  In a moment you should be able to reconnect to the database and repeat your command.\r\n2016-04-24 14:34:31.901 CEST - 19 - 23252 -  - @ LOG:  archiver process (PID 23455) exited with exit code 1\r\n2016-04-24 14:34:31.901 CEST - 1 - 23797 - [local] - postgres@postgres FATAL:  the database system is in recovery mode\r\n2016-04-24 14:34:31.902 CEST - 20 - 23252 -  - @ LOG:  all server processes terminated; reinitializing\r\n2016-04-24 14:34:31.931 CEST - 1 - 23798 -  - @ LOG:  database system was interrupted; last known up at 2016-04-24 14:33:15 CEST\r\n2016-04-24 14:34:32.262 CEST - 2 - 23798 -  - @ LOG:  database system was not properly shut down; automatic recovery in progress\r\n2016-04-24 14:34:32.264 CEST - 3 - 23798 -  - @ LOG:  redo starts at 0/7074278\r\n2016-04-24 14:34:32.264 CEST - 4 - 23798 -  - @ LOG:  invalid record length at 0/7077270\r\n2016-04-24 14:34:32.264 CEST - 5 - 23798 -  - @ LOG:  redo done at 0/7076100\r\n2016-04-24 14:34:32.266 CEST - 6 - 23798 -  - @ LOG:  checkpoint starting: end-of-recovery immediate\r\n2016-04-24 14:34:32.270 CEST - 7 - 23798 -  - @ LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 transaction log file(s) added, 0 removed, 0 recycled; write=0.000 s, sync=0.001 s, total=0.005 s; sync files=1, longest=0.001 s, average=0.001 s; distance=12 kB, estimate=12 kB\r\n2016-04-24 14:34:32.272 CEST - 8 - 23798 -  - @ LOG:  MultiXact member wraparound protections are now enabled\r\n2016-04-24 14:34:32.274 CEST - 21 - 23252 -  - @ LOG:  database system is ready to accept connections\r\n2016-04-24 14:34:32.274 CEST - 1 - 23802 -  - @ LOG:  autovacuum launcher started\r\n\r\nIf I increase the log level:\r\n\r\npostgres=# alter system set log_min_messages='INFO';\r\nALTER SYSTEM\r\n\r\n... I additionally get this:\r\n\r\n2016-04-24 14:43:56.265 CEST - 1 - 24539 - [local] - postgres@postgres NOTICE:  DB-Library notice: Msg #: 5701, Msg state: 2, Msg: Changed database context to 'ds2'., Server: WSCORE\\SQL2014, Process: , Line: 1, Level: 0\r\n2016-04-24 14:43:56.265 CEST - 2 - 24539 - [local] - postgres@postgres NOTICE:  DB-Library notice: Msg #: 5703, Msg state: 1, Msg: Changed language setting to us_english., Server: WSCORE\\SQL2014, Process: , Line: 1, Level: 0\r\n2016-04-24 14:43:56.268 CEST - 3 - 24539 - [local] - postgres@postgres NOTICE:  DB-Library notice: Msg #: 5701, Msg state: 2, Msg: Changed database context to 'ds2'., Server: WSCORE\\SQL2014, Process: , Line: 1, Level: 0\r\n2016-04-24 14:43:56.268 CEST - 4 - 24539 - [local] - postgres@postgres NOTICE:  DB-Library notice: Msg #: 5703, Msg state: 1, Msg: Changed language setting to us_english., Server: WSCORE\\SQL2014, Process: , Line: 1, Level: 0\r\n\r\n\r\nThe OS is (64bit):\r\n\r\npostgres@pgreporting:/home/postgres/ [PGREP] cat /etc/centos-release\r\nCentOS Linux release 7.2.1511 (Core) \r\n\r\nAny ideas?\r\n\r\nThanks in advance\r\nDaniel"}}