From fd40942fd8f99dd46da1dcb49fae58f607aea179 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Sat, 10 Feb 2001 05:50:29 +0000
Subject: [PATCH] Properly exit ODBC with 'X', allow linking on BSD/OS.

---
 src/interfaces/odbc/GNUmakefile    | 9 +++++++--
 src/interfaces/odbc/bind.c         | 1 -
 src/interfaces/odbc/columninfo.c   | 1 -
 src/interfaces/odbc/connection.c   | 1 -
 src/interfaces/odbc/convert.c      | 1 -
 src/interfaces/odbc/dlg_specific.c | 1 -
 src/interfaces/odbc/drvconn.c      | 1 -
 src/interfaces/odbc/environ.c      | 1 -
 src/interfaces/odbc/execute.c      | 1 -
 src/interfaces/odbc/info.c         | 1 -
 src/interfaces/odbc/lobj.c         | 1 -
 src/interfaces/odbc/misc.c         | 1 -
 src/interfaces/odbc/options.c      | 1 -
 src/interfaces/odbc/parse.c        | 1 -
 src/interfaces/odbc/pgtypes.c      | 1 -
 src/interfaces/odbc/psqlodbc.c     | 1 -
 src/interfaces/odbc/qresult.c      | 1 -
 src/interfaces/odbc/results.c      | 1 -
 src/interfaces/odbc/setup.c        | 1 -
 src/interfaces/odbc/socket.c       | 5 ++++-
 src/interfaces/odbc/statement.c    | 1 -
 src/interfaces/odbc/tuple.c        | 1 -
 src/interfaces/odbc/tuplelist.c    | 1 -
 23 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/src/interfaces/odbc/GNUmakefile b/src/interfaces/odbc/GNUmakefile
index 7a1542f3d41..7265512a9f1 100644
--- a/src/interfaces/odbc/GNUmakefile
+++ b/src/interfaces/odbc/GNUmakefile
@@ -2,7 +2,7 @@
 #
 # GNUMakefile for psqlodbc (Postgres ODBC driver)
 #
-# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.8 2000/12/16 18:14:25 petere Exp $
+# $Header: /cvsroot/pgsql/src/interfaces/odbc/Attic/GNUmakefile,v 1.9 2001/02/10 05:50:27 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -24,7 +24,6 @@ OBJS = info.o bind.o columninfo.o connection.o convert.o drvconn.o \
         gpps.o tuple.o tuplelist.o dlg_specific.o $(OBJX)
 
 SHLIB_LINK = $(filter -lm, $(LIBS))
-
 all: all-lib
 
 # Shared library stuff
@@ -33,7 +32,13 @@ include $(top_srcdir)/src/Makefile.shlib
 # Symbols must be resolved to the version in the shared library because
 # the driver manager (e.g., iodbc) provides some symbols with the same
 # names and we don't want those.  (This issue is probably ELF specific.)
+#
+# BSD/OS fails with libc and crt1.o undefined symbols without this.
+# bjm 2001-02-09
+#
+ifneq ($(PORTNAME), bsdi)
 LINK.shared += $(shlib_symbolic)
+endif
 
 odbc_headers = isql.h isqlext.h iodbc.h
 odbc_includedir = $(includedir)/iodbc
diff --git a/src/interfaces/odbc/bind.c b/src/interfaces/odbc/bind.c
index 6ec25f80d63..ce25c4a1c3a 100644
--- a/src/interfaces/odbc/bind.c
+++ b/src/interfaces/odbc/bind.c
@@ -1,4 +1,3 @@
-
 /* Module:          bind.c
  *
  * Description:     This module contains routines related to binding 
diff --git a/src/interfaces/odbc/columninfo.c b/src/interfaces/odbc/columninfo.c
index 9e5223b83b3..75fdd9f4f68 100644
--- a/src/interfaces/odbc/columninfo.c
+++ b/src/interfaces/odbc/columninfo.c
@@ -1,4 +1,3 @@
-
 /* Module:          columninfo.c
  *
  * Description:     This module contains routines related to 
diff --git a/src/interfaces/odbc/connection.c b/src/interfaces/odbc/connection.c
index b528a69ea03..7d20e4cb4f1 100644
--- a/src/interfaces/odbc/connection.c
+++ b/src/interfaces/odbc/connection.c
@@ -1,4 +1,3 @@
-
 /* Module:          connection.c
  *
  * Description:     This module contains routines related to 
diff --git a/src/interfaces/odbc/convert.c b/src/interfaces/odbc/convert.c
index 95ac701247b..f033ce4b3ff 100644
--- a/src/interfaces/odbc/convert.c
+++ b/src/interfaces/odbc/convert.c
@@ -1,4 +1,3 @@
-
 /* Module:         convert.c
  *
  * Description:	   This module contains routines related to 
diff --git a/src/interfaces/odbc/dlg_specific.c b/src/interfaces/odbc/dlg_specific.c
index 13e8b44e618..9be8b3cdd5f 100644
--- a/src/interfaces/odbc/dlg_specific.c
+++ b/src/interfaces/odbc/dlg_specific.c
@@ -1,4 +1,3 @@
-
 /* Module:          dlg_specific.c
  *
  * Description:     This module contains any specific code for handling
diff --git a/src/interfaces/odbc/drvconn.c b/src/interfaces/odbc/drvconn.c
index 2cbe6e6a87a..cbc25467266 100644
--- a/src/interfaces/odbc/drvconn.c
+++ b/src/interfaces/odbc/drvconn.c
@@ -1,4 +1,3 @@
-
 /* Module:          drvconn.c
  *
  * Description:     This module contains only routines related to 
diff --git a/src/interfaces/odbc/environ.c b/src/interfaces/odbc/environ.c
index 080a8026d5e..637b5fc160b 100644
--- a/src/interfaces/odbc/environ.c
+++ b/src/interfaces/odbc/environ.c
@@ -1,4 +1,3 @@
-
 /* Module:          environ.c
  *
  * Description:     This module contains routines related to 
diff --git a/src/interfaces/odbc/execute.c b/src/interfaces/odbc/execute.c
index ac5d0b19c38..57199f73966 100644
--- a/src/interfaces/odbc/execute.c
+++ b/src/interfaces/odbc/execute.c
@@ -1,4 +1,3 @@
-
 /* Module:          execute.c
  *
  * Description:     This module contains routines related to 
diff --git a/src/interfaces/odbc/info.c b/src/interfaces/odbc/info.c
index bf43d6522b5..9ee92c0687f 100644
--- a/src/interfaces/odbc/info.c
+++ b/src/interfaces/odbc/info.c
@@ -1,4 +1,3 @@
-
 /* Module:          info.c
  *
  * Description:     This module contains routines related to
diff --git a/src/interfaces/odbc/lobj.c b/src/interfaces/odbc/lobj.c
index 8d98ee33e4f..c31591a65bb 100644
--- a/src/interfaces/odbc/lobj.c
+++ b/src/interfaces/odbc/lobj.c
@@ -1,4 +1,3 @@
-
 /* Module:          lobj.c
  *
  * Description:     This module contains routines related to manipulating
diff --git a/src/interfaces/odbc/misc.c b/src/interfaces/odbc/misc.c
index 5d0a19c375e..b35c5c3d5b6 100644
--- a/src/interfaces/odbc/misc.c
+++ b/src/interfaces/odbc/misc.c
@@ -1,4 +1,3 @@
-
 /* Module:          misc.c
  *
  * Description:     This module contains miscellaneous routines
diff --git a/src/interfaces/odbc/options.c b/src/interfaces/odbc/options.c
index ccc419299dd..67c973ec0ac 100644
--- a/src/interfaces/odbc/options.c
+++ b/src/interfaces/odbc/options.c
@@ -1,4 +1,3 @@
-
 /* Module:          options.c
  *
  * Description:     This module contains routines for getting/setting
diff --git a/src/interfaces/odbc/parse.c b/src/interfaces/odbc/parse.c
index 690a902ec4b..dd85e66dceb 100644
--- a/src/interfaces/odbc/parse.c
+++ b/src/interfaces/odbc/parse.c
@@ -1,4 +1,3 @@
-
 /* Module:          parse.c
  *
  * Description:     This module contains routines related to parsing SQL statements.
diff --git a/src/interfaces/odbc/pgtypes.c b/src/interfaces/odbc/pgtypes.c
index ebee8ab262f..91a1b3d37ff 100644
--- a/src/interfaces/odbc/pgtypes.c
+++ b/src/interfaces/odbc/pgtypes.c
@@ -1,4 +1,3 @@
-
 /* Module:          pgtypes.c
  *
  * Description:     This module contains routines for getting information
diff --git a/src/interfaces/odbc/psqlodbc.c b/src/interfaces/odbc/psqlodbc.c
index dbf4029a4ac..c5770f9d33c 100644
--- a/src/interfaces/odbc/psqlodbc.c
+++ b/src/interfaces/odbc/psqlodbc.c
@@ -1,4 +1,3 @@
-
 /* Module:          psqlodbc.c
  *
  * Description:     This module contains the main entry point (DllMain) for the library.
diff --git a/src/interfaces/odbc/qresult.c b/src/interfaces/odbc/qresult.c
index de52884ff3c..eaffef5b793 100644
--- a/src/interfaces/odbc/qresult.c
+++ b/src/interfaces/odbc/qresult.c
@@ -1,4 +1,3 @@
-
 /* Module:          qresult.c
  *
  * Description:     This module contains functions related to 
diff --git a/src/interfaces/odbc/results.c b/src/interfaces/odbc/results.c
index 8ef3936a8a6..3ef098a91b7 100644
--- a/src/interfaces/odbc/results.c
+++ b/src/interfaces/odbc/results.c
@@ -1,4 +1,3 @@
-
 /* Module:          results.c
  *
  * Description:     This module contains functions related to 
diff --git a/src/interfaces/odbc/setup.c b/src/interfaces/odbc/setup.c
index 8c3ba4d02ae..4c31afed49e 100644
--- a/src/interfaces/odbc/setup.c
+++ b/src/interfaces/odbc/setup.c
@@ -1,4 +1,3 @@
-
 /* Module:          setup.c
  *
  * Description:     This module contains the setup functions for 
diff --git a/src/interfaces/odbc/socket.c b/src/interfaces/odbc/socket.c
index 30fb56f9042..917951f49d4 100644
--- a/src/interfaces/odbc/socket.c
+++ b/src/interfaces/odbc/socket.c
@@ -1,4 +1,3 @@
-
 /* Module:          socket.c
  *
  * Description:     This module contains functions for low level socket
@@ -78,7 +77,11 @@ SOCK_Destructor(SocketClass *self)
 {
 	if (self->socket != -1) {
 		if ( ! shutdown(self->socket, 2)) /* no sends or receives */
+		{
+			SOCK_put_char(self, 'X');
+			SOCK_flush_output(self);
 			closesocket(self->socket);
+		}
 	}
 
 	if (self->buffer_in)
diff --git a/src/interfaces/odbc/statement.c b/src/interfaces/odbc/statement.c
index 06d97f7457e..b0ea3a9f59c 100644
--- a/src/interfaces/odbc/statement.c
+++ b/src/interfaces/odbc/statement.c
@@ -1,4 +1,3 @@
-
 /* Module:          statement.c
  *
  * Description:     This module contains functions related to creating
diff --git a/src/interfaces/odbc/tuple.c b/src/interfaces/odbc/tuple.c
index 303476fef28..968f098a80c 100644
--- a/src/interfaces/odbc/tuple.c
+++ b/src/interfaces/odbc/tuple.c
@@ -1,4 +1,3 @@
-
 /* Module:          tuple.c
  *
  * Description:     This module contains functions for setting the data for individual
diff --git a/src/interfaces/odbc/tuplelist.c b/src/interfaces/odbc/tuplelist.c
index 31acb9c9c90..75110896a72 100644
--- a/src/interfaces/odbc/tuplelist.c
+++ b/src/interfaces/odbc/tuplelist.c
@@ -1,4 +1,3 @@
-
 /* Module:          tuplelist.c
  *
  * Description:     This module contains functions for creating a manual result set
-- 
GitLab