2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #pragma warning(disable:4996)
40 typedef unsigned __int64 uint64
;
41 typedef unsigned int uint32
;
45 #include <linux/types.h>
47 typedef uint64_t uint64
;
48 typedef unsigned int uint32
;
53 string name
; // field name
54 string def
; // field default data
55 string type
; // field type
56 uint32 flags
; // filed flags, see field flags;
58 typedef vector
<sField
> T_Table
;
59 typedef vector
<string
> T_TableList
;
60 typedef map
< string
, T_Table
> TDataBase
;
63 void pg_notice(void *arg
, const char *message
)
66 //printf("%s\n", message);
70 string
ConvertNativeType(enum_field_types mysqlType
, uint32 length
)
75 case FIELD_TYPE_TIMESTAMP
:
79 case FIELD_TYPE_DATETIME
:
88 case FIELD_TYPE_SHORT
:
89 case FIELD_TYPE_INT24
:
91 case FIELD_TYPE_LONGLONG
:
95 case FIELD_TYPE_DECIMAL
:
96 case FIELD_TYPE_FLOAT
:
97 case FIELD_TYPE_DOUBLE
:
99 case FIELD_TYPE_STRING
:
107 sprintf(str
,"%d",length
);
113 case FIELD_TYPE_VAR_STRING
:
121 sprintf(str
,"%d",length
);
134 bool IsNeeedEscapeString(enum_field_types mysqlType
)
138 case FIELD_TYPE_VAR_STRING
:
139 case FIELD_TYPE_STRING
:
140 case FIELD_TYPE_TINY_BLOB
:
141 case FIELD_TYPE_MEDIUM_BLOB
:
142 case FIELD_TYPE_LONG_BLOB
:
143 case FIELD_TYPE_BLOB
:
152 void PG_Exec_str(string sql
, PGconn
*mPGconn
)
154 PGresult
*res
= PQexec (mPGconn
, sql
.c_str());
155 if (PQresultStatus(res
) != PGRES_COMMAND_OK
)
157 printf( "SQL: %s", sql
.c_str() );
158 printf( "SQL %s", PQerrorMessage(mPGconn
) );
162 void PG_Escape_Str(string
& str
)
166 char* buf
= new char[str
.size()*2+1];
167 PQescapeString(buf
,str
.c_str(),str
.size());