diff --git a/uppsrc/PostgreSQL/PostgreSQL.upp b/uppsrc/PostgreSQL/PostgreSQL.upp index fed086b12..caccbbc1b 100644 --- a/uppsrc/PostgreSQL/PostgreSQL.upp +++ b/uppsrc/PostgreSQL/PostgreSQL.upp @@ -1,3 +1,6 @@ +acceptflags + NOPOSTGRESQL; + uses Sql; diff --git a/uppsrc/SqlCommander/SqlCommander.cpp b/uppsrc/SqlCommander/SqlCommander.cpp index e992bab5f..1aa914b64 100644 --- a/uppsrc/SqlCommander/SqlCommander.cpp +++ b/uppsrc/SqlCommander/SqlCommander.cpp @@ -13,6 +13,11 @@ #define HAVE_MYSQL #endif +#ifndef flagNOPOSTGRESQL + #define HAVE_POSTGRESQL + #include +#endif + #if defined(PLATFORM_WIN32) && defined(COMPILER_MSC) #define HAVE_OLEDB #endif @@ -64,6 +69,9 @@ SqlCommanderApp::SqlCommanderApp() { #ifdef HAVE_MYSQL login.connection.Add("MYSQL"); #endif +#ifdef HAVE_POSTGRESQL + login.connection.Add("POSTGRESQL"); +#endif #ifdef HAVE_SQLLITE login.connection.Add("SQLLITE"); #endif @@ -132,6 +140,29 @@ void SqlCommanderApp::Run() { session = -mysql; } #endif +#ifdef HAVE_POSTGRESQL + if(co == "POSTGRESQL") { + One postgres = new PostgreSQLSession; + String conninfo; + conninfo << "user='" << un << "' password='" << pw << "' "; + if(!IsNull(sv)) { + String port; + int f = sv.Find(':'); + if(f >= 0) { + port = sv.Mid(f + 1); + sv.Trim(f); + } + if(!IsNull(sv)) + conninfo << "host='" << sv << "' "; + if(!IsNull(port)) + conninfo << "port=" << port << ' '; + } + if(!IsNull(db)) + conninfo << "dbname='" << db << "' "; + postgres->Open(conninfo); + session = -postgres; + } +#endif #ifdef HAVE_SQLLITE if(co == "SQLLITE") { One sqlite = new Sqlite3Session; diff --git a/uppsrc/SqlCommander/SqlCommander.upp b/uppsrc/SqlCommander/SqlCommander.upp index a1e00c4ce..0c1d004e8 100644 --- a/uppsrc/SqlCommander/SqlCommander.upp +++ b/uppsrc/SqlCommander/SqlCommander.upp @@ -1,11 +1,12 @@ -description "Simple SQL console utility"; +description "Simple SQL console utility\377"; uses SqlCtrl, Oracle, OleDB, MySql, - plugin\sqlite3; + plugin\sqlite3, + PostgreSQL; link(WIN32 DEBUG MSC) /NODEFAULTLIB:libcmt; diff --git a/uppsrc/SqlCommander/init b/uppsrc/SqlCommander/init index 5bcc20cc1..68f8c165a 100644 --- a/uppsrc/SqlCommander/init +++ b/uppsrc/SqlCommander/init @@ -5,4 +5,5 @@ #include "OleDB/init" #include "MySql/init" #include "plugin\sqlite3/init" +#include "PostgreSQL/init" #endif