aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclick <none@none>2010-05-06 09:53:09 +0200
committerclick <none@none>2010-05-06 09:53:09 +0200
commitcb84d3e617975d172ec1be043810554bac09cb83 (patch)
tree4e2ed1445865704d8ac6959f240847942a7659f0
parent38061a6fa6dc661125175e82ff98104761acb70a (diff)
Cleanup : Remove postgreSQL-support (not used and has also been broken for a long time)
--HG-- branch : trunk
-rw-r--r--CMakeLists.txt9
-rw-r--r--INSTALL.linux1
-rw-r--r--cmake/FindPostgreSql.cmake55
-rw-r--r--contrib/mysql_to_pgsql/CMakeLists.txt21
-rw-r--r--contrib/mysql_to_pgsql/README14
-rw-r--r--contrib/mysql_to_pgsql/cmake/FindMySQL.cmake74
-rw-r--r--contrib/mysql_to_pgsql/cmake/FindPostgreSQL.cmake82
-rw-r--r--contrib/mysql_to_pgsql/src/defines.h184
-rw-r--r--contrib/mysql_to_pgsql/src/main.cpp339
-rw-r--r--dep/include/postgre/libpq-fe.h526
-rw-r--r--dep/include/postgre/pg_type.h74
-rw-r--r--dep/include/postgre/postgres_ext.h60
-rw-r--r--src/shared/Database/CMakeLists.txt5
-rw-r--r--src/shared/Database/DatabaseEnv.h11
-rw-r--r--src/shared/Database/DatabaseMysql.cpp3
-rw-r--r--src/shared/Database/DatabaseMysql.h3
-rw-r--r--src/shared/Database/DatabasePostgre.cpp384
-rw-r--r--src/shared/Database/DatabasePostgre.h77
-rw-r--r--src/shared/Database/PGSQLDelayThread.h33
-rw-r--r--src/shared/Database/QueryResultMysql.cpp3
-rw-r--r--src/shared/Database/QueryResultMysql.h3
-rw-r--r--src/shared/Database/QueryResultPostgre.cpp139
-rw-r--r--src/shared/Database/QueryResultPostgre.h52
-rw-r--r--src/shared/Database/SQLStorage.cpp4
-rw-r--r--src/shared/Database/SqlDelayThread.cpp4
-rw-r--r--src/trinitycore/CMakeLists.txt5
-rw-r--r--src/trinitycore/trinitycore.conf.dist6
-rw-r--r--src/trinityrealm/CMakeLists.txt5
-rw-r--r--src/trinityrealm/trinityrealm.conf.dist6
29 files changed, 0 insertions, 2182 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0c335711b9..e2e579ca508 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -5,7 +5,6 @@ cmake_policy(SET CMP0005 OLD)
include(CheckIncludeFiles)
include(cmake/FindAce.cmake)
include(cmake/FindMySql.cmake)
-include(cmake/FindPostgreSql.cmake)
include(cmake/FindReadline.cmake)
include(cmake/FindTermcap.cmake)
CONFIGURE_FILE(
@@ -15,7 +14,6 @@ CONFIGURE_FILE(
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
OPTION(DO_MYSQL "With MySQL support" 1)
-OPTION(DO_POSTGRESQL "With PostgreSQL support" 0) # not complete yet, may not link properly.
OPTION(DO_SCRIPTS "With trinityscripts" 1)
OPTION(DO_CLI "With CLI" 1)
OPTION(DO_RA "With RA" 0)
@@ -76,13 +74,6 @@ message("* Libs install dir at: ${LIBSDIR}")
FIND_LIBRARY(SSLLIB NAMES ssl DOC "SSL library")
FIND_LIBRARY(ZLIB z "Zlib library")
-IF(DO_POSTGRESQL)
- SET(DO_MYSQL 0)
- MESSAGE("* With PostgreSQL")
- FIND_PostgreSQL()
- ADD_DEFINITIONS(-DDO_POSTGRESQL)
-ENDIF(DO_POSTGRESQL)
-
IF(DO_MYSQL)
MESSAGE("* With MySQL")
FIND_MYSQL()
diff --git a/INSTALL.linux b/INSTALL.linux
index 6f4ceff66f8..a0bd7e07715 100644
--- a/INSTALL.linux
+++ b/INSTALL.linux
@@ -39,7 +39,6 @@ the directory and cmake and make. E.G. you created a dir named build ad want to
Thats just about all thats needed. You can however tweak more settings than where to install using flags built into our cmake files. Just open up CMakeLists.txt in the main folder and take a look at some of the flags like
DO_MYSQL --mysql database support (enabled or disabled by a 1 or 0, enabled by default)
- DO_POSTGRESQL --postgresql database support (enabled or disabled by a 1 or 0)
DO_SCRIPTS --enable or disable trinity script (enabled or disabled by a 1 or 0, enabled by default)
DO_RA --remote administration (enabled or disabled by a 1 or 0)
DO_DEBUG --enable debugging (enabled or disabled by a 1 or 0)
diff --git a/cmake/FindPostgreSql.cmake b/cmake/FindPostgreSql.cmake
deleted file mode 100644
index 3d06ad87f97..00000000000
--- a/cmake/FindPostgreSql.cmake
+++ /dev/null
@@ -1,55 +0,0 @@
-# - Find PostgreSQL
-# Find the PostgreSQL includes and client library
-# This module defines
-# POSTGRESQL_INCLUDE_DIR, where to find POSTGRESQL.h
-# POSTGRESQL_LIBRARIES, the libraries needed to use POSTGRESQL.
-# POSTGRESQL_FOUND, If false, do not try to use PostgreSQL.
-#
-# Copyright (c) 2006, Jaroslaw Staniek, <js@iidea.pl>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-# Add the postgresql and mysql include paths here
-
-MACRO(FIND_PostgreSQL)
-
-# find_path(POSTGRESQL_INCLUDE_DIR libpq-fe.h
-
- FIND_PATH(POSTGRESQL_INCLUDE_DIR libpq-fe.h
- /usr/include/server
- /usr/include/postgresql
- /usr/include/pgsql/server
- /usr/local/include/pgsql/server
- /usr/include/postgresql/server
- /usr/include/postgresql/*/server
- /usr/local/include/postgresql/server
- /usr/local/include/postgresql/*/server
- $ENV{ProgramFiles}/PostgreSQL/*/include/server
- $ENV{SystemDrive}/PostgreSQL/*/include/server
- )
-
- find_library(POSTGRESQL_LIBRARIES NAMES pq libpq
- PATHS
- /usr/lib
- /usr/local/lib
- /usr/lib/postgresql
- /usr/lib64
- /usr/local/lib64
- /usr/lib64/postgresql
- $ENV{ProgramFiles}/PostgreSQL/*/lib/ms
- $ENV{SystemDrive}/PostgreSQL/*/lib/ms
- )
-
- if(POSTGRESQL_INCLUDE_DIR AND POSTGRESQL_LIBRARIES)
- set(POSTGRESQL_FOUND TRUE)
- message(STATUS "Found PostgreSQL: ${POSTGRESQL_INCLUDE_DIR}, ${POSTGRESQL_LIBRARIES}")
- INCLUDE_DIRECTORIES(${POSTGRESQL_INCLUDE_DIR})
- else(POSTGRESQL_INCLUDE_DIR AND POSTGRESQL_LIBRARIES)
- set(POSTGRESQL_FOUND FALSE)
- message(STATUS "PostgreSQL not found.")
- endif(POSTGRESQL_INCLUDE_DIR AND POSTGRESQL_LIBRARIES)
-
- mark_as_advanced(POSTGRESQL_INCLUDE_DIR POSTGRESQL_LIBRARIES)
-
-ENDMACRO(FIND_PostgreSQL) \ No newline at end of file
diff --git a/contrib/mysql_to_pgsql/CMakeLists.txt b/contrib/mysql_to_pgsql/CMakeLists.txt
deleted file mode 100644
index 490a023e4ec..00000000000
--- a/contrib/mysql_to_pgsql/CMakeLists.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-SET(CMAKE_VERBOSE_MAKEFILE ON)
-cmake_minimum_required (VERSION 2.6)
-
-INCLUDE(cmake/FindMySQL.cmake)
-INCLUDE(cmake/FindPostgreSQL.cmake)
-
-MESSAGE("-- Check PostgreSQL")
-FIND_PGSQL()
-ADD_DEFINITIONS(-DDO_POSTGRESQL)
-
-MESSAGE("-- Check MySQL")
-FIND_MYSQL()
-ADD_DEFINITIONS(-DDO_MYSQL)
-
-INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIR})
-INCLUDE_DIRECTORIES(${PGSQL_INCLUDE_DIR})
-
-ADD_EXECUTABLE (mysql2pgsql src/main.cpp)
-
-TARGET_LINK_LIBRARIES(mysql2pgsql ${PGSQL_LIBRARIES})
-TARGET_LINK_LIBRARIES(mysql2pgsql ${MYSQL_LIBRARIES})
diff --git a/contrib/mysql_to_pgsql/README b/contrib/mysql_to_pgsql/README
deleted file mode 100644
index bf7083fb663..00000000000
--- a/contrib/mysql_to_pgsql/README
+++ /dev/null
@@ -1,14 +0,0 @@
-Using cmake on a Windows
-------------------
- 1. install cmake (http://www.cmake.org/cmake/resources/software.html)
- 2. cmake -i
- 3. Project.sln
- 4. {Debug/Release}/mysql2pgsql.exe
-
-Using cmake on a Unix/Linux
-------------------
- 1. install cmake
- 2. cmake -i
- 3. make
- 4. ./mysql2pgsql
-
diff --git a/contrib/mysql_to_pgsql/cmake/FindMySQL.cmake b/contrib/mysql_to_pgsql/cmake/FindMySQL.cmake
deleted file mode 100644
index 3d13c6f4d2a..00000000000
--- a/contrib/mysql_to_pgsql/cmake/FindMySQL.cmake
+++ /dev/null
@@ -1,74 +0,0 @@
-# - Find mysqlclient
-# Find the native MySQL includes and library
-#
-# MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
-# MYSQL_LIBRARIES - List of libraries when using MySQL.
-# MYSQL_FOUND - True if MySQL found.
-MACRO(FIND_MYSQL)
-
-IF (MYSQL_INCLUDE_DIR)
- # Already in cache, be silent
- SET(MySQL_FIND_QUIETLY TRUE)
-ENDIF (MYSQL_INCLUDE_DIR)
-
-FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 6.0;Location]/include"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/include"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.0;Location]/include"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 4.1;Location]/include"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 4.0;Location]/include"
- /usr/local/mysql/include
- /usr/local/include/mysql
- /usr/local/include
- /usr/include/mysql
- /usr/include
- /usr/mysql/include
-)
-
-IF(MSVC)
- SET(MYSQL_NAMES libmysql)
-ELSE(MSVC)
- SET(MYSQL_NAMES mysqlclient mysqlclient_r)
-ENDIF(MSVC)
-SET(MYSQL_SEARCH_LIB_PATHS
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 6.0;Location]/lib/opt"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/lib/opt"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.0;Location]/lib/opt"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 4.1;Location]/lib/opt"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 4.0;Location]/lib/opt"
- /usr/local/mysql/lib
- /usr/local/lib/mysql
- /usr/local/lib
- /usr/lib/mysql
- /usr/lib
-)
-FIND_LIBRARY(MYSQL_LIBRARY
- NAMES ${MYSQL_NAMES}
- PATHS ${MYSQL_SEARCH_LIB_PATHS}
-)
-
-IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
- SET(MYSQL_FOUND TRUE)
- SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
-ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
- SET(MYSQL_FOUND FALSE)
- SET( MYSQL_LIBRARIES )
-ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
-
-IF (MYSQL_FOUND)
- IF (NOT MySQL_FIND_QUIETLY)
- MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
- ENDIF (NOT MySQL_FIND_QUIETLY)
-ELSE (MYSQL_FOUND)
- IF (MySQL_FIND_REQUIRED)
- MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
- MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
- ENDIF (MySQL_FIND_REQUIRED)
-ENDIF (MYSQL_FOUND)
-
-MARK_AS_ADVANCED(
- MYSQL_LIBRARY
- MYSQL_INCLUDE_DIR
-)
-
-ENDMACRO(FIND_MYSQL)
diff --git a/contrib/mysql_to_pgsql/cmake/FindPostgreSQL.cmake b/contrib/mysql_to_pgsql/cmake/FindPostgreSQL.cmake
deleted file mode 100644
index 6cfabd2a2ff..00000000000
--- a/contrib/mysql_to_pgsql/cmake/FindPostgreSQL.cmake
+++ /dev/null
@@ -1,82 +0,0 @@
-# - Find libpq
-# Find the native PostgreSQL includes and library
-#
-# PGSQL_INCLUDE_DIR - where to find libpq-fe.h, etc.
-# PGSQL_LIBRARIES - List of libraries when using PGSQL.
-# PGSQL_FOUND - True if PGSQL found.
-
-MACRO(FIND_PGSQL)
-IF (PGSQL_INCLUDE_DIR)
- # Already in cache, be silent
- SET(PostgreSQL_FIND_QUIETLY TRUE)
-ENDIF (PGSQL_INCLUDE_DIR)
-
-# the registry settings checked are in order:
-# - for pgInstaller 8.2.x postgresql version
-# - for pgInstaller 8.3.x postgresql version
-SET(PGSQL_WIN_BASE
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{B823632F-3B72-4514-8861-B961CE263224};Base Directory]"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{1F701DBD-1660-4108-B10A-FB435EA63BF0};Base Directory]")
-
-IF(PGSQL_WIN_BASE)
- IF(MSVC)
- SET(PGSQL_SEARCH_LIB_PATHS "${PGSQL_WIN_BASE}/lib/ms")
- ELSE(MSVC)
- SET(PGSQL_SEARCH_LIB_PATHS "${PGSQL_WIN_BASE}/lib")
- ENDIF(MSVC)
-ENDIF(PGSQL_WIN_BASE)
-
-FIND_PATH(PGSQL_INCLUDE_DIR libpq-fe.h
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{1F701DBD-1660-4108-B10A-FB435EA63BF0};Base Directory]/include"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{B823632F-3B72-4514-8861-B961CE263224};Base Directory]/include"
- /usr/local/pgsql/include
- /usr/local/postgresql/include
- /usr/local/include/pgsql
- /usr/local/include/postgresql
- /usr/local/include
- /usr/include/pgsql
- /usr/include/postgresql
- /usr/include
- /usr/pgsql/include
- /usr/postgresql/include
-)
-
-SET(PGSQL_NAMES pq libpq)
-SET(PGSQL_SEARCH_LIB_PATHS
- ${PGSQL_SEARCH_LIB_PATHS}
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{1F701DBD-1660-4108-B10A-FB435EA63BF0};Base Directory]/lib"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\PostgreSQL\\Installations\\{B823632F-3B72-4514-8861-B961CE263224};Base Directory]/lib"
- /usr/local/pgsql/lib
- /usr/local/lib
- /usr/lib
-)
-FIND_LIBRARY(PGSQL_LIBRARY
- NAMES ${PGSQL_NAMES}
- PATHS ${PGSQL_SEARCH_LIB_PATHS}
-)
-
-IF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
- SET(PGSQL_FOUND TRUE)
- SET( PGSQL_LIBRARIES ${PGSQL_LIBRARY} )
-ELSE (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
- SET(PGSQL_FOUND FALSE)
- SET( PGSQL_LIBRARIES )
-ENDIF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
-
-IF (PGSQL_FOUND)
- IF (NOT PostgreSQL_FIND_QUIETLY)
- MESSAGE(STATUS "Found PostgreSQL: ${PGSQL_LIBRARY}")
- ENDIF (NOT PostgreSQL_FIND_QUIETLY)
-ELSE (PGSQL_FOUND)
- IF (PostgreSQL_FIND_REQUIRED)
- MESSAGE(STATUS "Looked for PostgreSQL libraries named ${PGSQL_NAMES}.")
- MESSAGE(FATAL_ERROR "Could NOT find PostgreSQL library")
- ENDIF (PostgreSQL_FIND_REQUIRED)
-ENDIF (PGSQL_FOUND)
-
-MARK_AS_ADVANCED(
- PGSQL_LIBRARY
- PGSQL_INCLUDE_DIR
-)
-ENDMACRO(FIND_PGSQL)
-
diff --git a/contrib/mysql_to_pgsql/src/defines.h b/contrib/mysql_to_pgsql/src/defines.h
deleted file mode 100644
index 3ffaf9923e0..00000000000
--- a/contrib/mysql_to_pgsql/src/defines.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _DEFINES_
-#define _DEFINES_
-
-#ifdef WIN32
-#include <winsock2.h>
-#pragma warning(disable:4996)
-#endif
-
-#include <libpq-fe.h>
-#include <mysql.h>
-#include <string>
-#include <vector>
-#include <map>
-#include <iostream>
-#include <sstream>
-#include <cstdlib>
-#include <string.h>
-using namespace std;
-
-
-#ifdef WIN32
-typedef unsigned __int64 uint64;
-typedef unsigned int uint32;
-#else
-#include <stdint.h>
-#ifndef uint64_t
-#include <linux/types.h>
-#endif
-typedef uint64_t uint64;
-typedef unsigned int uint32;
-#endif
-
-struct sField
-{
- string name; // field name
- string def; // field default data
- string type; // field type
- uint32 flags; // filed flags, see field flags;
-};
-typedef vector<sField> T_Table;
-typedef vector<string> T_TableList;
-typedef map< string, T_Table > TDataBase;
-
-static
-void pg_notice(void *arg, const char *message)
-{
- /// Do nothing
- //printf("%s\n", message);
-}
-
-inline
-string ConvertNativeType(enum_field_types mysqlType, uint32 length)
-{
-
- switch (mysqlType)
- {
- case FIELD_TYPE_TIMESTAMP:
- return "timestamp";
- case FIELD_TYPE_BIT:
- return "bit(1)";
- case FIELD_TYPE_DATETIME:
- return "date";
- case FIELD_TYPE_YEAR:
- case FIELD_TYPE_BLOB:
- case FIELD_TYPE_SET:
- case FIELD_TYPE_NULL:
- case FIELD_TYPE_ENUM:
- return "text";
- case FIELD_TYPE_TINY:
- case FIELD_TYPE_SHORT:
- case FIELD_TYPE_INT24:
- return "integer";
- case FIELD_TYPE_LONGLONG:
- case FIELD_TYPE_LONG:
- {
- string temp;
- char str[10];
- temp = "numeric";
- if (length)
- {
- temp.append("(");
- sprintf(str,"%d",length);
- temp.append(str);
- temp.append(")");
- }
- return temp;
- }
- case FIELD_TYPE_DECIMAL:
- case FIELD_TYPE_FLOAT:
- case FIELD_TYPE_DOUBLE:
- return "float";
- case FIELD_TYPE_STRING:
- {
- string temp;
- char str[10];
- temp = "char";
- if (length)
- {
- temp.append("(");
- sprintf(str,"%d",length);
- temp.append(str);
- temp.append(")");
- }
- return temp;
- }
- case FIELD_TYPE_VAR_STRING:
- {
- string temp;
- char str[10];
- temp = "varchar";
- if (length)
- {
- temp.append("(");
- sprintf(str,"%d",length);
- temp.append(str);
- temp.append(")");
- }
- return temp;
- }
- default:
- return "text";
- }
- return "text";
-}
-
-inline
-bool IsNeeedEscapeString(enum_field_types mysqlType)
-{
- switch(mysqlType)
- {
- case FIELD_TYPE_VAR_STRING:
- case FIELD_TYPE_STRING:
- case FIELD_TYPE_TINY_BLOB:
- case FIELD_TYPE_MEDIUM_BLOB:
- case FIELD_TYPE_LONG_BLOB:
- case FIELD_TYPE_BLOB:
- return true;
- default:
- return false;
- }
- return false;
-}
-
-inline
-void PG_Exec_str(string sql, PGconn *mPGconn)
-{
- PGresult *res = PQexec (mPGconn, sql.c_str());
- if (PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- printf( "SQL: %s", sql.c_str() );
- printf( "SQL %s", PQerrorMessage(mPGconn) );
- }
-}
-
-void PG_Escape_Str(string& str)
-{
- if(str.empty())
- return;
- char* buf = new char[str.size()*2+1];
- PQescapeString(buf,str.c_str(),str.size());
- str = buf;
- delete[] buf;
-}
-
-#endif
-
diff --git a/contrib/mysql_to_pgsql/src/main.cpp b/contrib/mysql_to_pgsql/src/main.cpp
deleted file mode 100644
index 8ca6772de20..00000000000
--- a/contrib/mysql_to_pgsql/src/main.cpp
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "defines.h"
-
-int main(int argc, char* argv[])
-{
- char sPGhost[26], sPGport[26], sPGdb[26], sPGuser[26], sPGpass[26];
- printf("Postgres connection settings\n Host>");
- scanf("%s",sPGhost);
- printf(" Port>");
- scanf("%s",sPGport);
- printf(" Base>");
- scanf("%s",sPGdb);
- printf(" User>");
- scanf("%s",sPGuser);
- printf(" Pass>");
- scanf("%s",sPGpass);
-
- ///////////////////////////////
- ///////PGSQL Connect///////////
- ///////////////////////////////
- PGconn *mPGconn=NULL;
- mPGconn = PQsetdbLogin(sPGhost,sPGport, NULL, NULL, sPGdb, sPGuser, sPGpass);
-
- if (PQstatus(mPGconn) != CONNECTION_OK)
- {
- printf("Could not connect to Postgre database at [%s]: \n %s\n",sPGhost, PQerrorMessage(mPGconn));
- PQfinish(mPGconn);
- return 1;
- }
- else
- {
- printf("Connected to Postgre database at [%s]\n", sPGhost);
- printf(" PostgreSQL server ver: [%d]\n\n",PQserverVersion(mPGconn));
- }
-
- /// Set dummy notice processor
- PQsetNoticeProcessor(mPGconn, pg_notice, mPGconn);
-
- ///////////////////////////////
- ///////MySQL Connect///////////
- ///////////////////////////////
- MYSQL *mysqlInit;
- mysqlInit = mysql_init(NULL);
- if (!mysqlInit)
- {
- printf( "Could not initialize Mysql connection\n" );
- return 1;
- }
-
- char sMYhost[26], sMYdb[26], sMYuser[26], sMYpass[26];
- int iMYport;
- printf("Mysql connection settings \n Host>");
- scanf("%s",sMYhost);
- printf(" Port>");
- scanf("%d",&iMYport);
- printf(" Base>");
- scanf("%s",sMYdb);
- printf(" User>");
- scanf("%s",sMYuser);
- printf(" Pass>");
- scanf("%s",sMYpass);
-
- mysql_options(mysqlInit,MYSQL_SET_CHARSET_NAME,"utf8");
-
- MYSQL *mMysql;
- mMysql = mysql_real_connect(mysqlInit, sMYhost, sMYuser, sMYpass, sMYdb, iMYport, NULL, 0);
-
- if (mMysql)
- {
- printf( "Connected to MySQL database at [%s] \n", sMYhost);
- printf( " MySQL client library: [%s] \n", mysql_get_client_info());
- printf( " MySQL server ver: [%s] \n\n", mysql_get_server_info( mMysql));
- }
- else
- {
- printf("Could not connect to MySQL database at [%s]:\n %s\n", sMYhost ,mysql_error(mysqlInit));
- mysql_close(mysqlInit);
- return 1;
- }
-
- //////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////
- MYSQL_RES *result = NULL;
- MYSQL_ROW row;
- MYSQL_FIELD *fields = NULL;
- uint64 rowCount = 0;
- uint32 fieldCount =0;
- result = mysql_list_tables( mMysql , NULL );
- rowCount = mysql_num_rows(result);
-
- /***********************/
- /* get list of tables */
- /***********************/
- T_TableList mTableList;
- mTableList.reserve((size_t)rowCount);
- while( (row = mysql_fetch_row(result)) !=NULL )
- {
- for (uint32 i = 0;i<mysql_num_fields(result);i++)
- {
- mTableList.push_back(row[i]);
- }
- }
- mysql_free_result(result);
-
- /****************************************/
- /* convert filed type and default type */
- /****************************************/
- T_Table m_Table;
- TDataBase m_DataBase_Map;
- m_DataBase_Map.clear();
- for (uint32 j=0; j<mTableList.size();++j)
- {
- result = mysql_list_fields(mMysql, mTableList[j].c_str(), NULL);
- fieldCount = mysql_num_fields(result);
- fields = mysql_fetch_fields(result);
-
- for (uint32 i=0; i<fieldCount;++i)
- {
- sField mfield;
- mfield.name = fields[i].name;
- if (!fields[i].def)
- {
- mfield.def = "NULL";
- }
- else if (!strcmp(fields[i].def,"0000-00-00 00:00:00"))
- {
- /// Convert MySQL Default timestamp to PGSQL Default timestamp
- mfield.def.append("'1970-01-01 00:00:00'");
- }
- else
- {
- /// Append '
- mfield.def.append("'");
- mfield.def.append(fields[i].def);;
- mfield.def.append("'");
- }
- mfield.type = ConvertNativeType(fields[i].type,fields[i].length);
- mfield.flags = fields[i].flags;
- m_Table.push_back(mfield);
- }
- m_DataBase_Map[mTableList[j]] = m_Table;
- m_Table.clear();
- mysql_free_result(result);
- }
-
- /******************************************/
- /* Conversion of the layout of the tables */
- /******************************************/
-
- uint32 count = 0;
- TDataBase::const_iterator citr;
- for (citr = m_DataBase_Map.begin(); citr != m_DataBase_Map.end(); ++citr)
- {
- ostringstream sql_str;
- sql_str<<"DROP TABLE IF EXISTS "<<(*citr).first.c_str()<<";\n";
- sql_str<<"CREATE TABLE "<<(*citr).first.c_str()<<"(\n";
-
- T_Table::const_iterator v_iter;
- ostringstream prim_key_str;
- ostringstream index_str;
- for (v_iter = (*citr).second.begin();
- v_iter != (*citr).second.end();
- ++v_iter)
- {
- sql_str<<" "<<(*v_iter).name;
- if (((*v_iter).flags & AUTO_INCREMENT_FLAG)!=0)
- {
- /// AUTO_INCREMENT fields not have "default" data
- sql_str<<" bigserial";
- }
- else
- {
- sql_str<<" "<<(*v_iter).type;
- sql_str<<" default "<<(*v_iter).def;
- }
- /// IF column have PRIMARY KEY flag then use column in PRIMARY KEY
- if (IS_PRI_KEY( (*v_iter).flags )!=0)
- {
- if( prim_key_str.str().size())
- prim_key_str << ", ";
- else
- {
- prim_key_str << "ALTER TABLE ";
- prim_key_str << (*citr).first.c_str();
- prim_key_str << " ADD CONSTRAINT pk_";
- prim_key_str << (*citr).first.c_str();
- prim_key_str << "_";
- prim_key_str << (*v_iter).name;
- prim_key_str << " PRIMARY KEY (";
- }
- prim_key_str<<(*v_iter).name;
- }
- else if (((*v_iter).flags & MULTIPLE_KEY_FLAG)!=0)
- {
- /// IF column have INDEX flag then create INDEX
- index_str << "CREATE INDEX idx_";
- index_str << (*citr).first.c_str();
- index_str << "_";
- index_str << (*v_iter).name;
- index_str << " ON ";
- index_str << (*citr).first.c_str();
- index_str << " USING btree (";
- index_str << (*v_iter).name;
- index_str << ");\n";
- }
- else if (((*v_iter).flags & UNIQUE_KEY_FLAG)!=0)
- {
- /// IF column have UNIQUE INDEX flag then create INDEX
- index_str << "CREATE UNIQUE INDEX uidx_";
- index_str << (*citr).first.c_str();
- index_str << "_";
- index_str << (*v_iter).name;
- index_str << " ON ";
- index_str << (*citr).first.c_str();
- index_str << " USING btree (";
- index_str << (*v_iter).name;
- index_str << ");\n";
- }
- /// don't output "," for last column
- if(v_iter + 1 != (*citr).second.end())
- sql_str<< ",\n";
- else
- sql_str<< "\n";
- }
- sql_str<< ")\n";
-
- /// Out Table structure
- PG_Exec_str(sql_str.str(),mPGconn);
-
- /// out PRIMARY KEY
- if(prim_key_str.str().size())
- {
- prim_key_str<<")";
- PG_Exec_str(prim_key_str.str(),mPGconn);
- }
-
- /// out INDEX's
- if (index_str.str().size())
- PG_Exec_str(index_str.str(),mPGconn);
-
- ++count;
- printf("Convert [%d] tables...\r",count);
- }
- printf("Completed the conversion of [%d] tables!\n", count);
-
- /****************/
- /* Copying data */
- /****************/
-
- count = 0;
- for (uint32 j=0; j<mTableList.size();++j)
- {
- ostringstream sql_str;
- sql_str << "SELECT * FROM ";
- sql_str << mTableList[j].c_str();
-
- if (mysql_query(mysqlInit,sql_str.str().c_str()) )
- continue;
- if (!(result = mysql_store_result(mysqlInit)))
- continue;
-
- while ((row = mysql_fetch_row(result))!=NULL)
- {
- ostringstream insert_str;
- insert_str << "INSERT INTO ";
- insert_str << mTableList[j].c_str();
- insert_str << " VALUES (";
-
- fieldCount = mysql_num_fields(result);
- fields = mysql_fetch_fields(result);
- for (uint32 i = 0 ; i < fieldCount ; ++i)
- {
- if (!row[i])
- insert_str << "NULL";
- else
- {
- if (IsNeeedEscapeString(fields[i].type))
- {
- string field_str = row[i];
- PG_Escape_Str(field_str);
- insert_str << "E'";
- insert_str << field_str.c_str();
- insert_str << "'";
- }
- else if (!strcmp(row[i],"0000-00-00 00:00:00"))
- {
- /// Convert MySQL timestamp to PGSQL timestamp
- insert_str << "'1970-01-01 00:00:00'";
- }
- else
- {
- insert_str << "'";
- insert_str << row[i];
- insert_str << "'";
- }
- }
-
- /// don't output "," for last column
- if(i + 1 != fieldCount )
- insert_str<< ",";
- else
- insert_str<< ")\n";
- }
- PG_Exec_str(insert_str.str(), mPGconn);
- }
- mysql_free_result(result);
- ++count;
- printf("Copied data from [%d] tables...\r",count);
- }
- printf("Finished copying the data from [%d] tables!\n",count);
- mTableList.clear();
- m_DataBase_Map.clear();
-
- /// Close connections
- mysql_close(mMysql);
- PQfinish(mPGconn);
-
- printf("end\n");
- return 0;
-
-}
-
diff --git a/dep/include/postgre/libpq-fe.h b/dep/include/postgre/libpq-fe.h
deleted file mode 100644
index e38d47f2bd7..00000000000
--- a/dep/include/postgre/libpq-fe.h
+++ /dev/null
@@ -1,526 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * libpq-fe.h
- * This file contains definitions for structures and
- * externs for functions used by frontend postgres applications.
- *
- * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.141 2008/01/01 19:46:00 momjian Exp $
- *
- *-------------------------------------------------------------------------
- */
-
-#ifndef LIBPQ_FE_H
-#define LIBPQ_FE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include <stdio.h>
-
-/*
- * postgres_ext.h defines the backend's externally visible types,
- * such as Oid.
- */
-#include "postgres_ext.h"
-
-/* Application-visible enum types */
-
-typedef enum
-{
- /*
- * Although it is okay to add to this list, values which become unused
- * should never be removed, nor should constants be redefined - that would
- * break compatibility with existing code.
- */
- CONNECTION_OK,
- CONNECTION_BAD,
- /* Non-blocking mode only below here */
-
- /*
- * The existence of these should never be relied upon - they should only
- * be used for user feedback or similar purposes.
- */
- CONNECTION_STARTED, /* Waiting for connection to be made. */
- CONNECTION_MADE, /* Connection OK; waiting to send. */
- CONNECTION_AWAITING_RESPONSE, /* Waiting for a response from the
- * postmaster. */
- CONNECTION_AUTH_OK, /* Received authentication; waiting for
- * backend startup. */
- CONNECTION_SETENV, /* Negotiating environment. */
- CONNECTION_SSL_STARTUP, /* Negotiating SSL. */
- CONNECTION_NEEDED /* Internal state: connect() needed */
-} ConnStatusType;
-
-typedef enum
-{
- PGRES_POLLING_FAILED = 0,
- PGRES_POLLING_READING, /* These two indicate that one may */
- PGRES_POLLING_WRITING, /* use select before polling again. */
- PGRES_POLLING_OK,
- PGRES_POLLING_ACTIVE /* unused; keep for awhile for backwards
- * compatibility */
-} PostgresPollingStatusType;
-
-typedef enum
-{
- PGRES_EMPTY_QUERY = 0, /* empty query string was executed */
- PGRES_COMMAND_OK, /* a query command that doesn't return
- * anything was executed properly by the
- * backend */
- PGRES_TUPLES_OK, /* a query command that returns tuples was
- * executed properly by the backend, PGresult
- * contains the result tuples */
- PGRES_COPY_OUT, /* Copy Out data transfer in progress */
- PGRES_COPY_IN, /* Copy In data transfer in progress */
- PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from the
- * backend */
- PGRES_NONFATAL_ERROR, /* notice or warning message */
- PGRES_FATAL_ERROR /* query failed */
-} ExecStatusType;
-
-typedef enum
-{
- PQTRANS_IDLE, /* connection idle */
- PQTRANS_ACTIVE, /* command in progress */
- PQTRANS_INTRANS, /* idle, within transaction block */
- PQTRANS_INERROR, /* idle, within failed transaction */
- PQTRANS_UNKNOWN /* cannot determine status */
-} PGTransactionStatusType;
-
-typedef enum
-{
- PQERRORS_TERSE, /* single-line error messages */
- PQERRORS_DEFAULT, /* recommended style */
- PQERRORS_VERBOSE /* all the facts, ma'am */
-} PGVerbosity;
-
-/* PGconn encapsulates a connection to the backend.
- * The contents of this struct are not supposed to be known to applications.
- */
-typedef struct pg_conn PGconn;
-
-/* PGresult encapsulates the result of a query (or more precisely, of a single
- * SQL command --- a query string given to PQsendQuery can contain multiple
- * commands and thus return multiple PGresult objects).
- * The contents of this struct are not supposed to be known to applications.
- */
-typedef struct pg_result PGresult;
-
-/* PGcancel encapsulates the information needed to cancel a running
- * query on an existing connection.
- * The contents of this struct are not supposed to be known to applications.
- */
-typedef struct pg_cancel PGcancel;
-
-/* PGnotify represents the occurrence of a NOTIFY message.
- * Ideally this would be an opaque typedef, but it's so simple that it's
- * unlikely to change.
- * NOTE: in Postgres 6.4 and later, the be_pid is the notifying backend's,
- * whereas in earlier versions it was always your own backend's PID.
- */
-typedef struct pgNotify
-{
- char *relname; /* notification condition name */
- int be_pid; /* process ID of notifying server process */
- char *extra; /* notification parameter */
- /* Fields below here are private to libpq; apps should not use 'em */
- struct pgNotify *next; /* list link */
-} PGnotify;
-
-/* Function types for notice-handling callbacks */
-typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);
-typedef void (*PQnoticeProcessor) (void *arg, const char *message);
-
-/* Print options for PQprint() */
-typedef char pqbool;
-
-typedef struct _PQprintOpt
-{
- pqbool header; /* print output field headings and row count */
- pqbool align; /* fill align the fields */
- pqbool standard; /* old brain dead format */
- pqbool html3; /* output html tables */
- pqbool expanded; /* expand tables */
- pqbool pager; /* use pager for output if needed */
- char *fieldSep; /* field separator */
- char *tableOpt; /* insert to HTML <table ...> */
- char *caption; /* HTML <caption> */
- char **fieldName; /* null terminated array of replacement field
- * names */
-} PQprintOpt;
-
-/* ----------------
- * Structure for the conninfo parameter definitions returned by PQconndefaults
- *
- * All fields except "val" point at static strings which must not be altered.
- * "val" is either NULL or a malloc'd current-value string. PQconninfoFree()
- * will release both the val strings and the PQconninfoOption array itself.
- * ----------------
- */
-typedef struct _PQconninfoOption
-{
- char *keyword; /* The keyword of the option */
- char *envvar; /* Fallback environment variable name */
- char *compiled; /* Fallback compiled in default value */
- char *val; /* Option's current value, or NULL */
- char *label; /* Label for field in connect dialog */
- char *dispchar; /* Character to display for this field in a
- * connect dialog. Values are: "" Display
- * entered value as is "*" Password field -
- * hide value "D" Debug option - don't show
- * by default */
- int dispsize; /* Field size in characters for dialog */
-} PQconninfoOption;
-
-/* ----------------
- * PQArgBlock -- structure for PQfn() arguments
- * ----------------
- */
-typedef struct
-{
- int len;
- int isint;
- union
- {
- int *ptr; /* can't use void (dec compiler barfs) */
- int integer;
- } u;
-} PQArgBlock;
-
-/* ----------------
- * Exported functions of libpq
- * ----------------
- */
-
-/* === in fe-connect.c === */
-
-/* make a new client connection to the backend */
-/* Asynchronous (non-blocking) */
-extern PGconn *PQconnectStart(const char *conninfo);
-extern PostgresPollingStatusType PQconnectPoll(PGconn *conn);
-
-/* Synchronous (blocking) */
-extern PGconn *PQconnectdb(const char *conninfo);
-extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
- const char *pgoptions, const char *pgtty,
- const char *dbName,
- const char *login, const char *pwd);
-
-#define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \
- PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
-
-/* close the current connection and free the PGconn data structure */
-extern void PQfinish(PGconn *conn);
-
-/* get info about connection options known to PQconnectdb */
-extern PQconninfoOption *PQconndefaults(void);
-
-/* free the data structure returned by PQconndefaults() */
-extern void PQconninfoFree(PQconninfoOption *connOptions);
-
-/*
- * close the current connection and restablish a new one with the same
- * parameters
- */
-/* Asynchronous (non-blocking) */
-extern int PQresetStart(PGconn *conn);
-extern PostgresPollingStatusType PQresetPoll(PGconn *conn);
-
-/* Synchronous (blocking) */
-extern void PQreset(PGconn *conn);
-
-/* request a cancel structure */
-extern PGcancel *PQgetCancel(PGconn *conn);
-
-/* free a cancel structure */
-extern void PQfreeCancel(PGcancel *cancel);
-
-/* issue a cancel request */
-extern int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);
-
-/* backwards compatible version of PQcancel; not thread-safe */
-extern int PQrequestCancel(PGconn *conn);
-
-/* Accessor functions for PGconn objects */
-extern char *PQdb(const PGconn *conn);
-extern char *PQuser(const PGconn *conn);
-extern char *PQpass(const PGconn *conn);
-extern char *PQhost(const PGconn *conn);
-extern char *PQport(const PGconn *conn);
-extern char *PQtty(const PGconn *conn);
-extern char *PQoptions(const PGconn *conn);
-extern ConnStatusType PQstatus(const PGconn *conn);
-extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn);
-extern const char *PQparameterStatus(const PGconn *conn,
- const char *paramName);
-extern int PQprotocolVersion(const PGconn *conn);
-extern int PQserverVersion(const PGconn *conn);
-extern char *PQerrorMessage(const PGconn *conn);
-extern int PQsocket(const PGconn *conn);
-extern int PQbackendPID(const PGconn *conn);
-extern int PQconnectionNeedsPassword(const PGconn *conn);
-extern int PQconnectionUsedPassword(const PGconn *conn);
-extern int PQclientEncoding(const PGconn *conn);
-extern int PQsetClientEncoding(PGconn *conn, const char *encoding);
-
-/* Get the OpenSSL structure associated with a connection. Returns NULL for
- * unencrypted connections or if any other TLS library is in use. */
-extern void *PQgetssl(PGconn *conn);
-
-/* Tell libpq whether it needs to initialize OpenSSL */
-extern void PQinitSSL(int do_init);
-
-/* Set verbosity for PQerrorMessage and PQresultErrorMessage */
-extern PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
-
-/* Enable/disable tracing */
-extern void PQtrace(PGconn *conn, FILE *debug_port);
-extern void PQuntrace(PGconn *conn);
-
-/* Override default notice handling routines */
-extern PQnoticeReceiver PQsetNoticeReceiver(PGconn *conn,
- PQnoticeReceiver proc,
- void *arg);
-extern PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn,
- PQnoticeProcessor proc,
- void *arg);
-
-/*
- * Used to set callback that prevents concurrent access to
- * non-thread safe functions that libpq needs.
- * The default implementation uses a libpq internal mutex.
- * Only required for multithreaded apps that use kerberos
- * both within their app and for postgresql connections.
- */
-typedef void (*pgthreadlock_t) (int acquire);
-
-extern pgthreadlock_t PQregisterThreadLock(pgthreadlock_t newhandler);
-
-/* === in fe-exec.c === */
-
-/* Simple synchronous query */
-extern PGresult *PQexec(PGconn *conn, const char *query);
-extern PGresult *PQexecParams(PGconn *conn,
- const char *command,
- int nParams,
- const Oid *paramTypes,
- const char *const * paramValues,
- const int *paramLengths,
- const int *paramFormats,
- int resultFormat);
-extern PGresult *PQprepare(PGconn *conn, const char *stmtName,
- const char *query, int nParams,
- const Oid *paramTypes);
-extern PGresult *PQexecPrepared(PGconn *conn,
- const char *stmtName,
- int nParams,
- const char *const * paramValues,
- const int *paramLengths,
- const int *paramFormats,
- int resultFormat);
-
-/* Interface for multiple-result or asynchronous queries */
-extern int PQsendQuery(PGconn *conn, const char *query);
-extern int PQsendQueryParams(PGconn *conn,
- const char *command,
- int nParams,
- const Oid *paramTypes,
- const char *const * paramValues,
- const int *paramLengths,
- const int *paramFormats,
- int resultFormat);
-extern int PQsendPrepare(PGconn *conn, const char *stmtName,
- const char *query, int nParams,
- const Oid *paramTypes);
-extern int PQsendQueryPrepared(PGconn *conn,
- const char *stmtName,
- int nParams,
- const char *const * paramValues,
- const int *paramLengths,
- const int *paramFormats,
- int resultFormat);
-extern PGresult *PQgetResult(PGconn *conn);
-
-/* Routines for managing an asynchronous query */
-extern int PQisBusy(PGconn *conn);
-extern int PQconsumeInput(PGconn *conn);
-
-/* LISTEN/NOTIFY support */
-extern PGnotify *PQnotifies(PGconn *conn);
-
-/* Routines for copy in/out */
-extern int PQputCopyData(PGconn *conn, const char *buffer, int nbytes);
-extern int PQputCopyEnd(PGconn *conn, const char *errormsg);
-extern int PQgetCopyData(PGconn *conn, char **buffer, int async);
-
-/* Deprecated routines for copy in/out */
-extern int PQgetline(PGconn *conn, char *string, int length);
-extern int PQputline(PGconn *conn, const char *string);
-extern int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize);
-extern int PQputnbytes(PGconn *conn, const char *buffer, int nbytes);
-extern int PQendcopy(PGconn *conn);
-
-/* Set blocking/nonblocking connection to the backend */
-extern int PQsetnonblocking(PGconn *conn, int arg);
-extern int PQisnonblocking(const PGconn *conn);
-extern int PQisthreadsafe(void);
-
-/* Force the write buffer to be written (or at least try) */
-extern int PQflush(PGconn *conn);
-
-/*
- * "Fast path" interface --- not really recommended for application
- * use
- */
-extern PGresult *PQfn(PGconn *conn,
- int fnid,
- int *result_buf,
- int *result_len,
- int result_is_int,
- const PQArgBlock *args,
- int nargs);
-
-/* Accessor functions for PGresult objects */
-extern ExecStatusType PQresultStatus(const PGresult *res);
-extern char *PQresStatus(ExecStatusType status);
-extern char *PQresultErrorMessage(const PGresult *res);
-extern char *PQresultErrorField(const PGresult *res, int fieldcode);
-extern int PQntuples(const PGresult *res);
-extern int PQnfields(const PGresult *res);
-extern int PQbinaryTuples(const PGresult *res);
-extern char *PQfname(const PGresult *res, int field_num);
-extern int PQfnumber(const PGresult *res, const char *field_name);
-extern Oid PQftable(const PGresult *res, int field_num);
-extern int PQftablecol(const PGresult *res, int field_num);
-extern int PQfformat(const PGresult *res, int field_num);
-extern Oid PQftype(const PGresult *res, int field_num);
-extern int PQfsize(const PGresult *res, int field_num);
-extern int PQfmod(const PGresult *res, int field_num);
-extern char *PQcmdStatus(PGresult *res);
-extern char *PQoidStatus(const PGresult *res); /* old and ugly */
-extern Oid PQoidValue(const PGresult *res); /* new and improved */
-extern char *PQcmdTuples(PGresult *res);
-extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
-extern int PQgetlength(const PGresult *res, int tup_num, int field_num);
-extern int PQgetisnull(const PGresult *res, int tup_num, int field_num);
-extern int PQnparams(const PGresult *res);
-extern Oid PQparamtype(const PGresult *res, int param_num);
-
-/* Describe prepared statements and portals */
-extern PGresult *PQdescribePrepared(PGconn *conn, const char *stmt);
-extern PGresult *PQdescribePortal(PGconn *conn, const char *portal);
-extern int PQsendDescribePrepared(PGconn *conn, const char *stmt);
-extern int PQsendDescribePortal(PGconn *conn, const char *portal);
-
-/* Delete a PGresult */
-extern void PQclear(PGresult *res);
-
-/* For freeing other alloc'd results, such as PGnotify structs */
-extern void PQfreemem(void *ptr);
-
-/* Exists for backward compatibility. bjm 2003-03-24 */
-#define PQfreeNotify(ptr) PQfreemem(ptr)
-
-/* Error when no password was given. */
-/* Note: depending on this is deprecated; use PQconnectionNeedsPassword(). */
-#define PQnoPasswordSupplied "fe_sendauth: no password supplied\n"
-
-/*
- * Make an empty PGresult with given status (some apps find this
- * useful). If conn is not NULL and status indicates an error, the
- * conn's errorMessage is copied.
- */
-extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);
-
-
-/* Quoting strings before inclusion in queries. */
-extern size_t PQescapeStringConn(PGconn *conn,
- char *to, const char *from, size_t length,
- int *error);
-extern unsigned char *PQescapeByteaConn(PGconn *conn,
- const unsigned char *from, size_t from_length,
- size_t *to_length);
-extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
- size_t *retbuflen);
-
-/* These forms are deprecated! */
-extern size_t PQescapeString(char *to, const char *from, size_t length);
-extern unsigned char *PQescapeBytea(const unsigned char *from, size_t from_length,
- size_t *to_length);
-
-
-
-/* === in fe-print.c === */
-
-extern void
-PQprint(FILE *fout, /* output stream */
- const PGresult *res,
- const PQprintOpt *ps); /* option structure */
-
-/*
- * really old printing routines
- */
-extern void
-PQdisplayTuples(const PGresult *res,
- FILE *fp, /* where to send the output */
- int fillAlign, /* pad the fields with spaces */
- const char *fieldSep, /* field separator */
- int printHeader, /* display headers? */
- int quiet);
-
-extern void
-PQprintTuples(const PGresult *res,
- FILE *fout, /* output stream */
- int printAttName, /* print attribute names */
- int terseOutput, /* delimiter bars */
- int width); /* width of column, if 0, use variable width */
-
-
-/* === in fe-lobj.c === */
-
-/* Large-object access routines */
-extern int lo_open(PGconn *conn, Oid lobjId, int mode);
-extern int lo_close(PGconn *conn, int fd);
-extern int lo_read(PGconn *conn, int fd, char *buf, size_t len);
-extern int lo_write(PGconn *conn, int fd, const char *buf, size_t len);
-extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);
-extern Oid lo_creat(PGconn *conn, int mode);
-extern Oid lo_create(PGconn *conn, Oid lobjId);
-extern int lo_tell(PGconn *conn, int fd);
-extern int lo_truncate(PGconn *conn, int fd, size_t len);
-extern int lo_unlink(PGconn *conn, Oid lobjId);
-extern Oid lo_import(PGconn *conn, const char *filename);
-extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);
-
-/* === in fe-misc.c === */
-
-/* Determine length of multibyte encoded char at *s */
-extern int PQmblen(const char *s, int encoding);
-
-/* Determine display length of multibyte encoded char at *s */
-extern int PQdsplen(const char *s, int encoding);
-
-/* Get encoding id from environment variable PGCLIENTENCODING */
-extern int PQenv2encoding(void);
-
-/* === in fe-auth.c === */
-
-extern char *PQencryptPassword(const char *passwd, const char *user);
-
-/* === in encnames.c === */
-
-extern int pg_char_to_encoding(const char *name);
-extern const char *pg_encoding_to_char(int encoding);
-extern int pg_valid_server_encoding_id(int encoding);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* LIBPQ_FE_H */
-
diff --git a/dep/include/postgre/pg_type.h b/dep/include/postgre/pg_type.h
deleted file mode 100644
index ce6331908ba..00000000000
--- a/dep/include/postgre/pg_type.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * pg_type.h
- * definition of the system "type" relation (pg_type)
- * along with the relation's initial contents.
- *
- *
- * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
- * Portions Copyright (c) 1994, Regents of the University of California
- *
- * $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/pg_type.h,v 1.8 2008/01/01 19:45:59 momjian Exp $
- *
- * NOTES
- * the genbki.sh script reads this file and generates .bki
- * information from the DATA() statements.
- *
- *-------------------------------------------------------------------------
- */
-#ifndef PG_TYPE_H
-#define PG_TYPE_H
-
-/* ----------------
- * initial contents of pg_type
- * ----------------
- */
-
-/* keep the following ordered by OID so that later changes can be made easier*/
-
-/* OIDS 1 - 99 */
-#define BOOLOID 16
-#define BYTEAOID 17
-#define CHAROID 18
-#define NAMEOID 19
-#define INT8OID 20
-#define INT2OID 21
-#define INT2VECTOROID 22
-#define INT4OID 23
-#define REGPROCOID 24
-#define TEXTOID 25
-#define OIDOID 26
-#define TIDOID 27
-#define XIDOID 28
-#define CIDOID 29
-#define OIDVECTOROID 30
-#define POINTOID 600
-#define LSEGOID 601
-#define PATHOID 602
-#define BOXOID 603
-#define POLYGONOID 604
-#define LINEOID 628
-#define FLOAT4OID 700
-#define FLOAT8OID 701
-#define ABSTIMEOID 702
-#define RELTIMEOID 703
-#define TINTERVALOID 704
-#define UNKNOWNOID 705
-#define CIRCLEOID 718
-#define CASHOID 790
-#define INETOID 869
-#define CIDROID 650
-#define BPCHAROID 1042
-#define VARCHAROID 1043
-#define DATEOID 1082
-#define TIMEOID 1083
-#define TIMESTAMPOID 1114
-#define TIMESTAMPTZOID 1184
-#define INTERVALOID 1186
-#define TIMETZOID 1266
-#define ZPBITOID 1560
-#define VARBITOID 1562
-#define NUMERICOID 1700
-
-#endif /* PG_TYPE_H */
-
diff --git a/dep/include/postgre/postgres_ext.h b/dep/include/postgre/postgres_ext.h
deleted file mode 100644
index 56914a7adcd..00000000000
--- a/dep/include/postgre/postgres_ext.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * postgres_ext.h
- *
- * This file contains declarations of things that are visible everywhere
- * in PostgreSQL *and* are visible to clients of frontend interface libraries.
- * For example, the Oid type is part of the API of libpq and other libraries.
- *
- * Declarations which are specific to a particular interface should
- * go in the header file for that interface (such as libpq-fe.h). This
- * file is only for fundamental Postgres declarations.
- *
- * User-written C functions don't count as "external to Postgres."
- * Those function much as local modifications to the backend itself, and
- * use header files that are otherwise internal to Postgres to interface
- * with the backend.
- *
- * $PostgreSQL: pgsql/src/include/postgres_ext.h,v 1.17 2007/02/06 09:16:08 petere Exp $
- *
- *-------------------------------------------------------------------------
- */
-
-#ifndef POSTGRES_EXT_H
-#define POSTGRES_EXT_H
-
-/*
- * Object ID is a fundamental type in Postgres.
- */
-typedef unsigned int Oid;
-
-#ifdef __cplusplus
-#define InvalidOid (Oid(0))
-#else
-#define InvalidOid ((Oid) 0)
-#endif
-
-#define OID_MAX UINT_MAX
-/* you will need to include <limits.h> to use the above #define */
-
-
-/*
- * Identifiers of error message fields. Kept here to keep common
- * between frontend and backend, and also to export them to libpq
- * applications.
- */
-#define PG_DIAG_SEVERITY 'S'
-#define PG_DIAG_SQLSTATE 'C'
-#define PG_DIAG_MESSAGE_PRIMARY 'M'
-#define PG_DIAG_MESSAGE_DETAIL 'D'
-#define PG_DIAG_MESSAGE_HINT 'H'
-#define PG_DIAG_STATEMENT_POSITION 'P'
-#define PG_DIAG_INTERNAL_POSITION 'p'
-#define PG_DIAG_INTERNAL_QUERY 'q'
-#define PG_DIAG_CONTEXT 'W'
-#define PG_DIAG_SOURCE_FILE 'F'
-#define PG_DIAG_SOURCE_LINE 'L'
-#define PG_DIAG_SOURCE_FUNCTION 'R'
-
-#endif
-
diff --git a/src/shared/Database/CMakeLists.txt b/src/shared/Database/CMakeLists.txt
index adbd0c6f998..e046906ad67 100644
--- a/src/shared/Database/CMakeLists.txt
+++ b/src/shared/Database/CMakeLists.txt
@@ -7,18 +7,13 @@ SET(trinitydatabase_STAT_SRCS
DatabaseEnv.h
DatabaseImpl.h
DatabaseMysql.cpp
- DatabasePostgre.cpp
DatabaseMysql.h
- DatabasePostgre.h
Field.cpp
Field.h
MySQLDelayThread.h
- PGSQLDelayThread.h
QueryResult.h
QueryResultMysql.cpp
QueryResultMysql.h
- QueryResultPostgre.cpp
- QueryResultPostgre.h
SQLStorage.cpp
SQLStorage.h
SqlDelayThread.cpp
diff --git a/src/shared/Database/DatabaseEnv.h b/src/shared/Database/DatabaseEnv.h
index 67afe0b6162..6546fc217a7 100644
--- a/src/shared/Database/DatabaseEnv.h
+++ b/src/shared/Database/DatabaseEnv.h
@@ -28,16 +28,6 @@
#include "Database/Field.h"
#include "Database/QueryResult.h"
-#ifdef DO_POSTGRESQL
-#include "Database/QueryResultPostgre.h"
-#include "Database/Database.h"
-#include "Database/DatabasePostgre.h"
-typedef DatabasePostgre DatabaseType;
-#define _LIKE_ "ILIKE"
-#define _TABLE_SIM_ "\""
-#define _CONCAT3_(A,B,C) "( " A " || " B " || " C " )"
-#define _OFFSET_ "LIMIT 1 OFFSET %d"
-#else
#include "Database/QueryResultMysql.h"
#include "Database/Database.h"
#include "Database/DatabaseMysql.h"
@@ -46,7 +36,6 @@ typedef DatabaseMysql DatabaseType;
#define _TABLE_SIM_ "`"
#define _CONCAT3_(A,B,C) "CONCAT( " A " , " B " , " C " )"
#define _OFFSET_ "LIMIT %d,1"
-#endif
extern DatabaseType WorldDatabase;
extern DatabaseType CharacterDatabase;
diff --git a/src/shared/Database/DatabaseMysql.cpp b/src/shared/Database/DatabaseMysql.cpp
index 2d5a7b928cc..a595d347e5b 100644
--- a/src/shared/Database/DatabaseMysql.cpp
+++ b/src/shared/Database/DatabaseMysql.cpp
@@ -18,8 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef DO_POSTGRESQL
-
#include "Util.h"
#include "Policies/SingletonImp.h"
#include "Platform/Define.h"
@@ -435,4 +433,3 @@ void DatabaseMysql::HaltDelayThread()
m_delayThread = NULL;
m_threadBody = NULL;
}
-#endif
diff --git a/src/shared/Database/DatabaseMysql.h b/src/shared/Database/DatabaseMysql.h
index 43462558498..cc88843fa1e 100644
--- a/src/shared/Database/DatabaseMysql.h
+++ b/src/shared/Database/DatabaseMysql.h
@@ -18,8 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef DO_POSTGRESQL
-
#ifndef _DATABASEMYSQL_H
#define _DATABASEMYSQL_H
@@ -79,5 +77,4 @@ class DatabaseMysql : public Database
bool _Query(const char *sql, MYSQL_RES **pResult, MYSQL_FIELD **pFields, uint64* pRowCount, uint32* pFieldCount);
};
#endif
-#endif
diff --git a/src/shared/Database/DatabasePostgre.cpp b/src/shared/Database/DatabasePostgre.cpp
deleted file mode 100644
index a1283538b20..00000000000
--- a/src/shared/Database/DatabasePostgre.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
- *
- * Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef DO_POSTGRESQL
-
-#include "Util.h"
-#include "Policies/SingletonImp.h"
-#include "Platform/Define.h"
-#include "Threading.h"
-#include "DatabaseEnv.h"
-#include "Database/PGSQLDelayThread.h"
-#include "Database/SqlOperations.h"
-#include "Timer.h"
-
-void DatabasePostgre::ThreadStart()
-{
-}
-
-void DatabasePostgre::ThreadEnd()
-{
-}
-
-size_t DatabasePostgre::db_count = 0;
-
-DatabasePostgre::DatabasePostgre() : Database(), mPGconn(NULL)
-{
- // before first connection
- if( db_count++ == 0 )
- {
-
- if (!PQisthreadsafe())
- {
- sLog.outError("FATAL ERROR: PostgreSQL libpq isn't thread-safe.");
- exit(1);
- }
- }
-}
-
-DatabasePostgre::~DatabasePostgre()
-{
-
- if (m_delayThread)
- HaltDelayThread();
-
- if( mPGconn )
- {
- PQfinish(mPGconn);
- mPGconn = NULL;
- }
-}
-
-bool DatabasePostgre::Initialize(const char *infoString)
-{
- if(!Database::Initialize(infoString))
- return false;
-
- tranThread = NULL;
-
- InitDelayThread();
-
- Tokens tokens = StrSplit(infoString, ";");
-
- Tokens::iterator iter;
-
- std::string host, port_or_socket_dir, user, password, database;
-
- iter = tokens.begin();
-
- if(iter != tokens.end())
- host = *iter++;
- if(iter != tokens.end())
- port_or_socket_dir = *iter++;
- if(iter != tokens.end())
- user = *iter++;
- if(iter != tokens.end())
- password = *iter++;
- if(iter != tokens.end())
- database = *iter++;
-
- if (host == ".")
- mPGconn = PQsetdbLogin(NULL, port_or_socket_dir == "." ? NULL : port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str());
- else
- mPGconn = PQsetdbLogin(host.c_str(), port_or_socket_dir.c_str(), NULL, NULL, database.c_str(), user.c_str(), password.c_str());
-
- /* check to see that the backend connection was successfully made */
- if (PQstatus(mPGconn) != CONNECTION_OK)
- {
- sLog.outError( "Could not connect to Postgre database at %s: %s",
- host.c_str(), PQerrorMessage(mPGconn));
- PQfinish(mPGconn);
- return false;
- }
- else
- {
- sLog.outDetail( "Connected to Postgre database at %s",
- host.c_str());
- sLog.outString( "PostgreSQL server ver: %d",PQserverVersion(mPGconn));
- return true;
- }
-
-}
-
-bool DatabasePostgre::_Query(const char *sql, PGresult** pResult, uint64* pRowCount, uint32* pFieldCount)
-{
- if (!mPGconn)
- return 0;
-
- // guarded block for thread-safe request
- ACE_Guard<ACE_Thread_Mutex> query_connection_guard(mMutex);
- #ifdef MANGOS_DEBUG
- uint32 _s = getMSTime();
- #endif
- // Send the query
- *pResult = PQexec(mPGconn, sql);
- if(!*pResult )
- return false;
-
- if (PQresultStatus(*pResult) != PGRES_TUPLES_OK)
- {
- sLog.outErrorDb( "SQL : %s", sql );
- sLog.outErrorDb( "SQL %s", PQerrorMessage(mPGconn));
- PQclear(*pResult);
- return false;
- }
- else
- {
- #ifdef TRINITY_DEBUG
- sLog.outDebug("[%u ms] SQL: %s", getMSTime() - _s, sql );
- #endif
- }
-
- *pRowCount = PQntuples(*pResult);
- *pFieldCount = PQnfields(*pResult);
- // end guarded block
-
- if (!*pRowCount)
- {
- PQclear(*pResult);
- return false;
- }
- return true;
-}
-
-QueryResult_AutoPtr DatabasePostgre::Query(const char *sql)
-{
- if (!mPGconn)
- return QueryResult_AutoPtr(NULL);
-
- PGresult* result = NULL;
- uint64 rowCount = 0;
- uint32 fieldCount = 0;
-
- if(!_Query(sql,&result,&rowCount,&fieldCount))
- return QueryResult_AutoPtr(NULL);
-
- QueryResultPostgre * queryResult = new QueryResultPostgre(result, rowCount, fieldCount);
- queryResult->NextRow();
-
- return QueryResult_AutoPtr(queryResult);
-}
-
-QueryNamedResult* DatabasePostgre::QueryNamed(const char *sql)
-{
- if (!mPGconn)
- return 0;
-
- PGresult* result = NULL;
- uint64 rowCount = 0;
- uint32 fieldCount = 0;
-
- if(!_Query(sql,&result,&rowCount,&fieldCount))
- return NULL;
-
- QueryFieldNames names(fieldCount);
- for (uint32 i = 0; i < fieldCount; i++)
- names[i] = PQfname(result, i);
-
- QueryResultPostgre * queryResult = new QueryResultPostgre(result, rowCount, fieldCount);
- queryResult->NextRow();
-
- return new QueryNamedResult(queryResult,names);
-}
-
-bool DatabasePostgre::Execute(const char *sql)
-{
-
- if (!mPGconn)
- return false;
-
- // don't use queued execution if it has not been initialized
- if (!m_threadBody)
- return DirectExecute(sql);
-
- tranThread = ACE_Based::Thread::current(); // owner of this transaction
- TransactionQueues::iterator i = m_tranQueues.find(tranThread);
- if (i != m_tranQueues.end() && i->second != NULL)
- { // Statement for transaction
- i->second->DelayExecute(sql);
- }
- else
- {
- // Simple sql statement
- m_threadBody->Delay(new SqlStatement(sql));
- }
-
- return true;
-}
-
-bool DatabasePostgre::DirectExecute(const char* sql)
-{
- if (!mPGconn)
- return false;
- {
- // guarded block for thread-safe request
- ACE_Guard<ACE_Thread_Mutex> query_connection_guard(mMutex);
- #ifdef MANGOS_DEBUG
- uint32 _s = getMSTime();
- #endif
- PGresult *res = PQexec(mPGconn, sql);
- if (PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- sLog.outErrorDb( "SQL: %s", sql );
- sLog.outErrorDb( "SQL %s", PQerrorMessage(mPGconn) );
- return false;
- }
- else
- {
- #ifdef TRINITY_DEBUG
- sLog.outDebug("[%u ms] SQL: %s", getMSTime() - _s, sql );
- #endif
- }
- PQclear(res);
-
- // end guarded block
- }
- return true;
-}
-
-bool DatabasePostgre::_TransactionCmd(const char *sql)
-{
- if (!mPGconn)
- return false;
-
- PGresult *res = PQexec(mPGconn, sql);
- if (PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- sLog.outError("SQL: %s", sql);
- sLog.outError("SQL ERROR: %s", PQerrorMessage(mPGconn));
- return false;
- }
- else
- {
- DEBUG_LOG("SQL: %s", sql);
- }
- return true;
-}
-
-bool DatabasePostgre::BeginTransaction()
-{
- if (!mPGconn)
- return false;
- // don't use queued execution if it has not been initialized
- if (!m_threadBody)
- {
- if (tranThread == ACE_Based::Thread::current())
- return false; // huh? this thread already started transaction
- mMutex.acquire();
- if (!_TransactionCmd("START TRANSACTION"))
- {
- mMutex.release(); // can't start transaction
- return false;
- }
- return true;
- }
- // transaction started
- tranThread = ACE_Based::Thread::current(); // owner of this transaction
- TransactionQueues::iterator i = m_tranQueues.find(tranThread);
- if (i != m_tranQueues.end() && i->second != NULL)
- // If for thread exists queue and also contains transaction
- // delete that transaction (not allow trans in trans)
- delete i->second;
-
- m_tranQueues[tranThread] = new SqlTransaction();
-
- return true;
-}
-
-bool DatabasePostgre::CommitTransaction()
-{
- if (!mPGconn)
- return false;
-
- // don't use queued execution if it has not been initialized
- if (!m_threadBody)
- {
- if (tranThread != ACE_Based::Thread::current())
- return false;
- bool _res = _TransactionCmd("COMMIT");
- tranThread = NULL;
- mMutex.release();
- return _res;
- }
- tranThread = ACE_Based::Thread::current();
- TransactionQueues::iterator i = m_tranQueues.find(tranThread);
- if (i != m_tranQueues.end() && i->second != NULL)
- {
- m_threadBody->Delay(i->second);
- i->second = NULL;
- return true;
- }
- else
- return false;
-}
-
-bool DatabasePostgre::RollbackTransaction()
-{
- if (!mPGconn)
- return false;
- // don't use queued execution if it has not been initialized
- if (!m_threadBody)
- {
- if (tranThread != ACE_Based::Thread::current())
- return false;
- bool _res = _TransactionCmd("ROLLBACK");
- tranThread = NULL;
- mMutex.release();
- return _res;
- }
- tranThread = ACE_Based::Thread::current();
- TransactionQueues::iterator i = m_tranQueues.find(tranThread);
- if (i != m_tranQueues.end() && i->second != NULL)
- {
- delete i->second;
- i->second = NULL;
- }
- return true;
-}
-
-unsigned long DatabasePostgre::escape_string(char *to, const char *from, unsigned long length)
-{
- if (!mPGconn || !to || !from || !length)
- return 0;
-
- return PQescapeString(to, from, length);
-}
-
-void DatabasePostgre::InitDelayThread()
-{
- assert(!m_delayThread);
-
- //New delay thread for delay execute
- m_threadBody = new PGSQLDelayThread(this); // Will be deleted on m_delayThread delete
- m_delayThread = new ACE_Based::Thread(m_threadBody);
-}
-
-void DatabasePostgre::HaltDelayThread()
-{
- if (!m_threadBody || !m_delayThread) return;
-
- m_threadBody->Stop(); //Stop event
- m_delayThread->wait(); //Wait for flush to DB
- delete m_delayThread; //This also deletes m_threadBody
- m_delayThread = NULL;
- m_threadBody = NULL;
-}
-#endif
-
diff --git a/src/shared/Database/DatabasePostgre.h b/src/shared/Database/DatabasePostgre.h
deleted file mode 100644
index cd93f416bfe..00000000000
--- a/src/shared/Database/DatabasePostgre.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
- *
- * Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _DatabasePostgre_H
-#define _DatabasePostgre_H
-
-#include "Policies/Singleton.h"
-#include <stdarg.h>
-
-#ifdef WIN32
-#define FD_SETSIZE 1024
-#include <winsock2.h>
-#include <postgre/libpq-fe.h>
-#else
-#include <libpq-fe.h>
-#endif
-
-class DatabasePostgre : public Database
-{
- friend class Trinity::OperatorNew<DatabasePostgre>;
-
- public:
- DatabasePostgre();
- ~DatabasePostgre();
-
- //! Initializes Postgres and connects to a server.
- /*! infoString should be formated like hostname;username;password;database. */
- bool Initialize(const char *infoString);
- void InitDelayThread();
- void HaltDelayThread();
- QueryResult_AutoPtr Query(const char *sql);
- QueryNamedResult* QueryNamed(const char *sql);
- bool Execute(const char *sql);
- bool DirectExecute(const char* sql);
- bool BeginTransaction();
- bool CommitTransaction();
- bool RollbackTransaction();
-
- operator bool () const { return mPGconn != NULL; }
-
- unsigned long escape_string(char *to, const char *from, unsigned long length);
- using Database::escape_string;
-
- // must be call before first query in thread
- void ThreadStart();
- // must be call before finish thread run
- void ThreadEnd();
- private:
- ACE_Thread_Mutex mMutex;
- ACE_Based::Thread * tranThread;
-
- PGconn *mPGconn;
-
- static size_t db_count;
-
- bool _TransactionCmd(const char *sql);
- bool _Query(const char *sql, PGresult **pResult, uint64* pRowCount, uint32* pFieldCount);
-};
-#endif
-
diff --git a/src/shared/Database/PGSQLDelayThread.h b/src/shared/Database/PGSQLDelayThread.h
deleted file mode 100644
index 2f0dd4958b3..00000000000
--- a/src/shared/Database/PGSQLDelayThread.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
- *
- * Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __PGSQLDELAYTHREAD_H
-#define __PGSQLDELAYTHREAD_H
-
-#include "Database/SqlDelayThread.h"
-
-class PGSQLDelayThread : public SqlDelayThread
-{
- public:
- PGSQLDelayThread(Database* db) : SqlDelayThread(db) {}
- void Stop() { SqlDelayThread::Stop(); }
-};
-#endif //__PGSQLDELAYTHREAD_H
-
diff --git a/src/shared/Database/QueryResultMysql.cpp b/src/shared/Database/QueryResultMysql.cpp
index e4694e1b9b6..b2bc181a166 100644
--- a/src/shared/Database/QueryResultMysql.cpp
+++ b/src/shared/Database/QueryResultMysql.cpp
@@ -18,8 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef DO_POSTGRESQL
-
#include "DatabaseEnv.h"
QueryResultMysql::QueryResultMysql(MYSQL_RES *result, MYSQL_FIELD *fields, uint64 rowCount, uint32 fieldCount) :
@@ -104,4 +102,3 @@ enum Field::DataTypes QueryResultMysql::ConvertNativeType(enum_field_types mysql
return Field::DB_TYPE_UNKNOWN;
}
}
-#endif
diff --git a/src/shared/Database/QueryResultMysql.h b/src/shared/Database/QueryResultMysql.h
index 4a1749c21c5..a9a7a60f123 100644
--- a/src/shared/Database/QueryResultMysql.h
+++ b/src/shared/Database/QueryResultMysql.h
@@ -18,8 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef DO_POSTGRESQL
-
#if !defined(QUERYRESULTMYSQL_H)
#define QUERYRESULTMYSQL_H
@@ -47,4 +45,3 @@ class QueryResultMysql : public QueryResult
MYSQL_RES *mResult;
};
#endif
-#endif
diff --git a/src/shared/Database/QueryResultPostgre.cpp b/src/shared/Database/QueryResultPostgre.cpp
deleted file mode 100644
index 21e72a884b7..00000000000
--- a/src/shared/Database/QueryResultPostgre.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
- *
- * Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifdef DO_POSTGRESQL
-
-#include "DatabaseEnv.h"
-
-QueryResultPostgre::QueryResultPostgre(PGresult *result, uint64 rowCount, uint32 fieldCount) :
- QueryResult(rowCount, fieldCount), mResult(result), mTableIndex(0)
-{
-
- mCurrentRow = new Field[mFieldCount];
- ASSERT(mCurrentRow);
-
- for (uint32 i = 0; i < mFieldCount; i++)
- mCurrentRow[i].SetType(ConvertNativeType(PQftype( result, i )));
-}
-
-QueryResultPostgre::~QueryResultPostgre()
-{
- EndQuery();
-}
-
-bool QueryResultPostgre::NextRow()
-{
- if (!mResult)
- return false;
-
- if (mTableIndex >= mRowCount)
- {
- EndQuery();
- return false;
- }
-
- char* pPQgetvalue;
- for (int j = 0; j < mFieldCount; j++)
- {
- pPQgetvalue = PQgetvalue(mResult, mTableIndex, j);
- if(pPQgetvalue && !(*pPQgetvalue))
- pPQgetvalue = NULL;
-
- mCurrentRow[j].SetValue(pPQgetvalue);
- }
- ++mTableIndex;
-
- return true;
-}
-
-void QueryResultPostgre::EndQuery()
-{
- if (mCurrentRow)
- {
- delete [] mCurrentRow;
- mCurrentRow = 0;
- }
-
- if (mResult)
- {
- PQclear(mResult);
- mResult = 0;
- }
-}
-
-// see types in #include <postgre/pg_type.h>
-enum Field::DataTypes QueryResultPostgre::ConvertNativeType(Oid pOid ) const
-{
- switch (pOid)
- {
- case BPCHAROID:
- case CIDOID:
- case CIDROID:
- case CIRCLEOID:
- case INETOID:
- case NAMEOID:
- case TEXTOID:
- case VARCHAROID:
- return Field::DB_TYPE_STRING;
- case CASHOID:
- case FLOAT4OID:
- case FLOAT8OID:
- case NUMERICOID:
- return Field::DB_TYPE_FLOAT;
- case DATEOID: // Date
- case RELTIMEOID: // Date
- case TIMEOID: // Time
- case TIMETZOID: // Time
- case ABSTIMEOID: // DateTime
- case INTERVALOID: // DateTime
- case TIMESTAMPOID: // DateTime
- case TIMESTAMPTZOID: // DateTime
- case INT2OID: // Int
- case INT2VECTOROID: // Int
- case INT4OID: // Int
- case OIDOID: // Int
- case CHAROID: // UInt
- case INT8OID: // LongLong
- return Field::DB_TYPE_INTEGER;
- case BOOLOID:
- return Field::DB_TYPE_BOOL; // Bool
-/*
- case BOXOID: Rect;
- case LINEOID: Rect;
- case VARBITOID: BitArray;
- case BYTEAOID: ByteArray;
-*/
- case LSEGOID:
- case OIDVECTOROID:
- case PATHOID:
- case POINTOID:
- case POLYGONOID:
- case REGPROCOID:
- case TIDOID:
- case TINTERVALOID:
- case UNKNOWNOID:
- case XIDOID:
- default:
- return Field::DB_TYPE_UNKNOWN;
- }
- return Field::DB_TYPE_UNKNOWN;
-}
-#endif
-
diff --git a/src/shared/Database/QueryResultPostgre.h b/src/shared/Database/QueryResultPostgre.h
deleted file mode 100644
index bf7e7fa3f9a..00000000000
--- a/src/shared/Database/QueryResultPostgre.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
- *
- * Copyright (C) 2008-2010 Trinity <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#if !defined(QUERYRESULTPOSTGRE_H)
-#define QUERYRESULTPOSTGRE_H
-
-#ifdef WIN32
-#define FD_SETSIZE 1024
-#include <winsock2.h>
-#include <postgre/libpq-fe.h>
-#include <postgre/pg_type.h>
-#else
-#include <libpq-fe.h>
-#include <postgres.h>
-#include <catalog/pg_type.h>
-#endif
-
-class QueryResultPostgre : public QueryResult
-{
- public:
- QueryResultPostgre(PGresult *result, uint64 rowCount, uint32 fieldCount);
-
- ~QueryResultPostgre();
-
- bool NextRow();
-
- private:
- enum Field::DataTypes ConvertNativeType(Oid pOid) const;
- void EndQuery();
-
- PGresult *mResult;
- uint32 mTableIndex;
-};
-#endif
-
diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp
index d3029c858b2..4813c764cba 100644
--- a/src/shared/Database/SQLStorage.cpp
+++ b/src/shared/Database/SQLStorage.cpp
@@ -21,11 +21,7 @@
#include "SQLStorage.h"
#include "SQLStorageImpl.h"
-#ifdef DO_POSTGRESQL
-extern DatabasePostgre WorldDatabase;
-#else
extern DatabaseMysql WorldDatabase;
-#endif
const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifffliiiiiiiliiisi";
const char CreatureInfodstfmt[]="iiiiiiiiiisssibbiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifffliiiiiiiliiiii";
diff --git a/src/shared/Database/SqlDelayThread.cpp b/src/shared/Database/SqlDelayThread.cpp
index 7707d9cf293..43de3c63ffc 100644
--- a/src/shared/Database/SqlDelayThread.cpp
+++ b/src/shared/Database/SqlDelayThread.cpp
@@ -28,9 +28,7 @@ SqlDelayThread::SqlDelayThread(Database* db) : m_dbEngine(db), m_running(true)
void SqlDelayThread::run()
{
- #ifndef DO_POSTGRESQL
mysql_thread_init();
- #endif
SqlAsyncTask * s = NULL;
@@ -47,9 +45,7 @@ void SqlDelayThread::run()
}
}
- #ifndef DO_POSTGRESQL
mysql_thread_end();
- #endif
}
void SqlDelayThread::Stop()
diff --git a/src/trinitycore/CMakeLists.txt b/src/trinitycore/CMakeLists.txt
index 3cd1ac1abec..0efdc63c09e 100644
--- a/src/trinitycore/CMakeLists.txt
+++ b/src/trinitycore/CMakeLists.txt
@@ -33,10 +33,6 @@ add_definitions(
IF (DO_MYSQL)
SET(trinity-core_LINK_FLAGS "-pthread ${trinity-core_LINK_FLAGS}")
ENDIF(DO_MYSQL)
-IF (DO_POSTGRESQL)
- SET(trinity-core_LINK_FLAGS "-pthread ${trinity-core_LINK_FLAGS}")
-ENDIF(DO_POSTGRESQL)
-
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
SET(trinity-core_LINK_FLAGS "-framework Carbon ${trinity-core_LINK_FLAGS}")
@@ -68,7 +64,6 @@ ${SCRIPT_LIB}
${READLINE_LIBRARY}
${TERMCAP_LIBRARY}
${MYSQL_LIBRARIES}
-${POSTGRESQL_LIBRARIES}
${SSLLIB}
${ACE_LIBRARY}
${ZLIB}
diff --git a/src/trinitycore/trinitycore.conf.dist b/src/trinitycore/trinitycore.conf.dist
index 9b1aad966d2..274412fc5dc 100644
--- a/src/trinitycore/trinitycore.conf.dist
+++ b/src/trinitycore/trinitycore.conf.dist
@@ -26,7 +26,6 @@
# CharacterDatabaseInfo
# Database connection settings for the world server.
# Default:
-# ---MYSQL---
# hostname;port;username;password;database
# .;somenumber;username;password;database
# - use named pipes in Windows
@@ -34,11 +33,6 @@
# "enable-named-pipe" to [mysqld] section my.ini
# .;/path/to/unix_socket;username;password;database
# - use Unix sockets in Unix/Linux
-# ---PGSQL---
-# hostname;port;username;password;database
-# .;/path/to/unix_socket/DIRECTORY or . for default path;
-# username;password;database
-# - use Unix sockets in Unix/Linux
#
# MaxPingTime
# Settings for maximum database-ping interval (minutes between pings)
diff --git a/src/trinityrealm/CMakeLists.txt b/src/trinityrealm/CMakeLists.txt
index 9a6128fa656..8f3e9b87540 100644
--- a/src/trinityrealm/CMakeLists.txt
+++ b/src/trinityrealm/CMakeLists.txt
@@ -31,9 +31,6 @@ add_definitions(
IF (DO_MYSQL)
SET(trinity-realm_LINK_FLAGS "-pthread ${trinity-realm_LINK_FLAGS}")
ENDIF(DO_MYSQL)
-IF (DO_POSTGRESQL)
- SET(trinity-realm_LINK_FLAGS "-pthread ${trinity-realm_LINK_FLAGS}")
-ENDIF(DO_POSTGRESQL)
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
SET(trinity-realm_LINK_FLAGS "-framework Carbon ${trinity-realm_LINK_FLAGS}")
@@ -52,7 +49,6 @@ trinityconfig
zlib
${SSLLIB}
${MYSQL_LIBRARIES}
-${POSTGRESQL_LIBRARIES}
${OSX_LIBS}
)
@@ -62,4 +58,3 @@ install(TARGETS trinity-realm DESTINATION bin)
########### install files ###############
install(FILES trinityrealm.conf.dist DESTINATION etc)
-
diff --git a/src/trinityrealm/trinityrealm.conf.dist b/src/trinityrealm/trinityrealm.conf.dist
index a561e652cc1..e98b9386878 100644
--- a/src/trinityrealm/trinityrealm.conf.dist
+++ b/src/trinityrealm/trinityrealm.conf.dist
@@ -8,7 +8,6 @@
# LoginDatabaseInfo
# Database connection settings for the realm server.
# Default:
-# ---MYSQL---
# hostname;port;username;password;database
# .;somenumber;username;password;database
# - use named pipes in Windows
@@ -16,11 +15,6 @@
# "enable-named-pipe" to [mysqld] section my.ini
# .;/path/to/unix_socket;username;password;database
# - use Unix sockets in Unix/Linux
-# ---PGSQL---
-# hostname;port;username;password;database
-# .;/path/to/unix_socket/DIRECTORY or . for default path;
-# username;password;database
-# - use Unix sockets in Unix/Linux
#
# LogsDir
# Logs directory setting.