From 35fe29b7ad1335a21f857c9a6fc3bc210e25a406 Mon Sep 17 00:00:00 2001
From: Roman Tsisyk <roman@tsisyk.com>
Date: Fri, 11 Apr 2014 19:03:23 +0400
Subject: [PATCH] Remove dependency on catalog/pg_type.h for module/pg

---
 cmake/FindPostgreSQL.cmake | 21 +++------------------
 debian/control             |  3 +--
 src/module/pg/pg.cc        |  9 ++++++++-
 3 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/cmake/FindPostgreSQL.cmake b/cmake/FindPostgreSQL.cmake
index 33702cd67e..73800fb074 100644
--- a/cmake/FindPostgreSQL.cmake
+++ b/cmake/FindPostgreSQL.cmake
@@ -101,21 +101,6 @@ find_path(PostgreSQL_INCLUDE_DIR
   DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
 )
 
-find_path(PostgreSQL_TYPE_INCLUDE_DIR
-  NAMES catalog/pg_type.h
-  PATHS
-   # Look in other places.
-   ${PostgreSQL_ROOT_DIRECTORIES}
-  PATH_SUFFIXES
-    server
-    postgresql
-    pgsql/server
-    postgresql/server
-    include/server
-  # Help the user find it if we cannot.
-  DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
-)
-
 # The PostgreSQL library.
 set (PostgreSQL_LIBRARY_TO_FIND pq)
 # Setting some more prefixes for the library
@@ -146,14 +131,14 @@ endif()
 # Did we find anything?
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(PostgreSQL
-                                  REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR
+                                  REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR
                                   VERSION_VAR PostgreSQL_VERSION_STRING)
 set( PostgreSQL_FOUND  ${POSTGRESQL_FOUND})
 
 # Now try to get the include and library path.
 if(PostgreSQL_FOUND)
 
-  set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} )
+  set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} )
   set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
   set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND})
 
@@ -162,4 +147,4 @@ if(PostgreSQL_FOUND)
   #message("Final PostgreSQL libraries:   ${PostgreSQL_LIBRARIES}")
 endif()
 
-mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY )
+mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_LIBRARY )
diff --git a/debian/control b/debian/control
index 484295e58b..ad10860a0f 100644
--- a/debian/control
+++ b/debian/control
@@ -9,8 +9,7 @@ Build-Depends: cdbs, debhelper (>= 8),
  libncurses5-dev,
  libiberty-dev | binutils-dev,
  libmysqlclient-dev,
- libpq-dev,
- postgresql-server-dev-all
+ libpq-dev
 Section: database
 Standards-Version: 3.9.5
 Homepage: http://tarantool.org/
diff --git a/src/module/pg/pg.cc b/src/module/pg/pg.cc
index 27f71bbd9f..438d236767 100644
--- a/src/module/pg/pg.cc
+++ b/src/module/pg/pg.cc
@@ -30,10 +30,17 @@
 extern "C" {
 	#include <postgres.h>
 	#include <libpq-fe.h>
-	#include <catalog/pg_type.h>
 	#undef PACKAGE_VERSION
 }
 
+/* PostgreSQL types (see catalog/pg_type.h) */
+#define INT2OID 21
+#define INT4OID 23
+#define INT8OID 20
+#define NUMERICOID 1700
+#define BOOLOID 16
+#define TEXTOID 25
+
 #include <stddef.h>
 
 extern "C" {
-- 
GitLab