diff --git a/pgadmin/dlg/dlgForeignTable.cpp b/pgadmin/dlg/dlgForeignTable.cpp
new file mode 100644
index 0000000..74acb61
--- /dev/null
+++ b/pgadmin/dlg/dlgForeignTable.cpp
@@ -0,0 +1,614 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+//
+// Copyright (C) 2002 - 2011, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dlgForeignTable.cpp - PostgreSQL Foreign Table Property
+//
+//////////////////////////////////////////////////////////////////////////
+
+#include "pgAdmin3.h"
+
+// wxWindows headers
+#include <wx/wx.h>
+
+
+// App headers
+#include "utils/misc.h"
+#include "dlg/dlgForeignTable.h"
+#include "schema/pgSchema.h"
+#include "schema/pgForeignTable.h"
+#include "schema/pgDatatype.h"
+
+
+// pointer to controls
+#define cbForeignServer      CTRL_COMBOBOX("cbForeignServer")
+#define lstMembers           CTRL_LISTVIEW("lstMembers")
+#define txtMembername        CTRL_TEXT("txtMembername")
+#define btnAddMember         CTRL_BUTTON("btnAddMember")
+#define btnChangeMember      CTRL_BUTTON("btnChangeMember")
+#define btnRemoveMember      CTRL_BUTTON("btnRemoveMember")
+#define lstOptions           CTRL_LISTVIEW("lstOptions")
+#define txtOption            CTRL_TEXT("txtOption")
+#define txtValue             CTRL_TEXT("txtValue")
+#define btnAdd               CTRL_BUTTON("wxID_ADD")
+#define btnRemove            CTRL_BUTTON("wxID_REMOVE")
+#define chkNotNull           CTRL_CHECKBOX("chkNotNull")
+
+
+BEGIN_EVENT_TABLE(dlgForeignTable, dlgTypeProperty)
+	EVT_BUTTON(XRCID("btnAddMember"),               dlgForeignTable::OnMemberAdd)
+	EVT_BUTTON(XRCID("btnChangeMember"),            dlgForeignTable::OnMemberChange)
+	EVT_BUTTON(XRCID("btnRemoveMember"),            dlgForeignTable::OnMemberRemove)
+	EVT_LIST_ITEM_SELECTED(XRCID("lstMembers"),     dlgForeignTable::OnMemberSelChange)
+	EVT_TEXT(XRCID("cbDatatype"),                   dlgForeignTable::OnSelChangeTyp)
+	EVT_COMBOBOX(XRCID("cbDatatype"),               dlgForeignTable::OnSelChangeTyp)
+	EVT_TEXT(XRCID("txtMembername"),                dlgForeignTable::OnChangeMember)
+	EVT_TEXT(XRCID("cbDatatype"),                   dlgForeignTable::OnSelChangeTyp)
+	EVT_COMBOBOX(XRCID("cbDatatype"),               dlgForeignTable::OnSelChangeTyp)
+	EVT_TEXT(XRCID("txtLength"),                    dlgForeignTable::OnSelChangeTypOrLen)
+	EVT_TEXT(XRCID("txtPrecision"),                 dlgForeignTable::OnSelChangeTypOrLen)
+	EVT_CHECKBOX(XRCID("chkNotNull"),               dlgForeignTable::OnChangeMember)
+    EVT_LIST_ITEM_SELECTED(XRCID("lstOptions"),     dlgForeignTable::OnSelChangeOption)
+	EVT_TEXT(XRCID("txtOption"),                    dlgForeignTable::OnChangeOptionName)
+	EVT_BUTTON(wxID_ADD,                            dlgForeignTable::OnAddOption)
+	EVT_BUTTON(wxID_REMOVE,                         dlgForeignTable::OnRemoveOption)
+END_EVENT_TABLE();
+
+
+dlgProperty *pgForeignTableFactory::CreateDialog(frmMain *frame, pgObject *node, pgObject *parent)
+{
+	return new dlgForeignTable(this, frame, (pgForeignTable *)node, (pgSchema *)parent);
+}
+
+
+dlgForeignTable::dlgForeignTable(pgaFactory *f, frmMain *frame, pgForeignTable *node, pgSchema *sch)
+	: dlgTypeProperty(f, frame, wxT("dlgForeignTable"))
+{
+	foreigntable = node;
+	schema = sch;
+    
+	lstMembers->CreateColumns(0, _("Member"), _("Data type"), _("Constraint"), -1);
+
+	queriesToBeSplitted = false;
+}
+
+
+void dlgForeignTable::OnChangeMember(wxCommandEvent &ev)
+{
+	btnAddMember->Enable(
+	    !txtMembername->GetValue().Strip(wxString::both).IsEmpty()
+	    && cbDatatype->GetGuessedSelection() >= 0);
+	btnChangeMember->Enable(true);
+}
+
+
+pgObject *dlgForeignTable::GetObject()
+{
+	return foreigntable;
+}
+
+
+int dlgForeignTable::Go(bool modal)
+{
+	pgSet *set;
+
+	// Fill owner combobox
+	AddGroups();
+	AddUsers(cbOwner);
+    // Fill datatype combobox
+	FillDatatype(cbDatatype);
+
+	// Initialize options listview and buttons
+	lstOptions->AddColumn(_("Option"), 80);
+	lstOptions->AddColumn(_("Value"), 40);
+	txtOption->SetValue(wxT(""));
+	txtValue->SetValue(wxT(""));
+	btnAdd->Disable();
+	btnRemove->Disable();
+
+	if (foreigntable)
+	{
+		// Edit Mode
+        cbForeignServer->SetValue(foreigntable->GetForeignServer());
+        cbForeignServer->Disable();
+        
+		txtMembername->Enable(true);
+		btnAddMember->Enable(true);
+		btnChangeMember->Enable(false);
+		btnRemoveMember->Enable(false);
+
+		wxArrayString elements = foreigntable->GetTypesArray();
+		wxString fullType, typeName, typeLength, typePrecision;
+		size_t pos;
+		size_t i;
+		for (i = 0 ; i < elements.GetCount() ; i += 3)
+		{
+			lstMembers->AppendItem(0, elements.Item(i), elements.Item(i + 1), elements.Item(i + 2));
+
+			fullType = elements.Item(i + 1);
+			typeName = fullType;
+			typeLength = wxEmptyString;
+			typePrecision = wxEmptyString;
+
+			if (fullType.Find(wxT("(")) > 0)
+			{
+				// there is at least a length
+				typeName = fullType.BeforeFirst('(');
+				if (fullType.Find(wxT(",")) > 0)
+				{
+					// there is also a precision
+					typeLength = fullType.AfterFirst('(').BeforeFirst(',');
+					typePrecision = fullType.AfterFirst(',').BeforeFirst(')');
+				}
+				else
+					typeLength = fullType.AfterFirst('(').BeforeFirst(')');
+			}
+
+			for (pos = 0; pos < cbDatatype->GetCount() - 1; pos++)
+			{
+				if (cbDatatype->GetString(pos) == typeName)
+				{
+					memberTypes.Add(GetTypeInfo(pos));
+					break;
+				}
+			}
+			memberLengths.Add(typeLength);
+			memberPrecisions.Add(typePrecision);
+            memberNotNulls.Add(elements.Item(i + 2));
+		}
+
+		cbDatatype->Enable();
+		txtLength->Enable();
+
+		wxString options = foreigntable->GetOptions();
+		wxString option, optionname, optionvalue;
+		while (options.Length() > 0)
+		{
+			option = options.BeforeFirst(',');
+			optionname = option.BeforeFirst(wxT('=')).Trim(false).Trim();
+			optionvalue = option.AfterFirst(wxT('=')).Trim(false).Trim();
+			lstOptions->AppendItem(optionname, optionvalue);
+			options = options.AfterFirst(',');
+		}
+	}
+	else
+	{
+		// Create mode
+		cbOwner->Append(wxEmptyString);
+		cbOwner->Disable();
+        
+        pgSet *set = connection->ExecuteSet(
+                         wxT("SELECT srvname\n")
+                         wxT("  FROM pg_foreign_server\n")
+                         wxT("  ORDER BY srvname"));
+        if (set)
+        {
+            while (!set->Eof())
+            {
+                wxString srvname = set->GetVal(wxT("srvname"));
+                cbForeignServer->Append(srvname);
+                set->MoveNext();
+            }
+            delete set;
+        }
+        cbForeignServer->SetSelection(0);
+	}
+
+	txtLength->SetValidator(numericValidator);
+
+	return dlgTypeProperty::Go(modal);
+}
+
+
+void dlgForeignTable::OnSelChangeTyp(wxCommandEvent &ev)
+{
+	txtLength->SetValue(wxEmptyString);
+	txtPrecision->SetValue(wxEmptyString);
+	cbDatatype->GuessSelection(ev);
+    chkNotNull->SetValue(false);
+	OnSelChangeTypOrLen(ev);
+}
+
+
+void dlgForeignTable::OnSelChangeTypOrLen(wxCommandEvent &ev)
+{
+	CheckLenEnable();
+    txtLength->Enable(isVarLen);
+    txtPrecision->Enable(isVarPrec);
+    CheckChange();
+    OnChangeMember(ev);
+}
+
+
+void dlgForeignTable::CheckChange()
+{
+	if (foreigntable)
+	{
+		EnableOK(txtComment->GetValue() != foreigntable->GetComment()
+		         || cbOwner->GetValue() != foreigntable->GetOwner()
+		         || GetSqlForTypes() != wxEmptyString
+		         || GetSql().Length() > 0);
+	}
+	else
+	{
+		wxString name = GetName();
+
+		bool enable = true;
+		CheckValid(enable, !name.IsEmpty(), _("Please specify name."));
+		CheckValid(enable, cbForeignServer->GetCurrentSelection() >= 0, _("Please specify a foreign server."));
+		EnableOK(enable);
+	}
+}
+
+
+void dlgForeignTable::OnMemberSelChange(wxListEvent &ev)
+{
+	long pos = lstMembers->GetSelection();
+	if (pos >= 0)
+	{
+		txtMembername->SetValue(lstMembers->GetText(pos));
+		cbDatatype->SetValue(memberTypes.Item(pos).AfterFirst(':'));
+		txtLength->SetValue(memberLengths.Item(pos));
+		txtLength->Enable(!txtLength->GetValue().IsEmpty());
+		txtPrecision->SetValue(memberPrecisions.Item(pos));
+		txtPrecision->Enable(!txtPrecision->GetValue().IsEmpty());
+        chkNotNull->SetValue(memberNotNulls.Item(pos) == wxT("NOT NULL"));
+        chkNotNull->Enable();
+		btnChangeMember->Enable();
+		btnRemoveMember->Enable();
+	}
+}
+
+
+void dlgForeignTable::OnMemberAdd(wxCommandEvent &ev)
+{
+	wxString name = txtMembername->GetValue().Strip(wxString::both);
+	wxString type = cbDatatype->GetValue();
+	wxString length = wxEmptyString;
+	wxString precision = wxEmptyString;
+    wxString notnull = wxEmptyString;
+
+	if (txtLength->GetValue() != wxT("") && txtLength->IsEnabled())
+		length = txtLength->GetValue();
+	if (txtPrecision->GetValue() != wxT("") && txtPrecision->IsEnabled())
+		precision = txtPrecision->GetValue();
+    notnull = chkNotNull->GetValue() ? wxT("NOT NULL") : wxEmptyString;
+
+	if (!length.IsEmpty())
+	{
+		type += wxT("(") + length;
+		if (!precision.IsEmpty())
+			type += wxT(",") + precision;
+		type += wxT(")");
+	}
+
+	if (!name.IsEmpty())
+	{
+		size_t pos = lstMembers->GetItemCount();
+		lstMembers->InsertItem(pos, name, 0);
+		lstMembers->SetItem(pos, 1, type);
+		lstMembers->SetItem(pos, 2, notnull);
+		memberTypes.Add(GetTypeInfo(cbDatatype->GetGuessedSelection()));
+		memberLengths.Add(length);
+		memberPrecisions.Add(precision);
+        memberNotNulls.Add(notnull);
+	}
+
+	CheckChange();
+}
+
+
+void dlgForeignTable::OnMemberChange(wxCommandEvent &ev)
+{
+	wxString name = txtMembername->GetValue().Strip(wxString::both);
+	wxString type = cbDatatype->GetValue();
+	wxString length = wxEmptyString;
+	wxString precision = wxEmptyString;
+    wxString notnull = wxEmptyString;
+
+	if (txtLength->GetValue() != wxT("") && txtLength->IsEnabled())
+		length = txtLength->GetValue();
+	if (txtPrecision->GetValue() != wxT("") && txtPrecision->IsEnabled())
+		precision = txtPrecision->GetValue();
+    notnull = chkNotNull->GetValue() ? wxT("NOT NULL") : wxEmptyString;
+
+	if (!length.IsEmpty())
+	{
+		type += wxT("(") + length;
+		if (!precision.IsEmpty())
+			type += wxT(",") + precision;
+		type += wxT(")");
+	}
+
+	if (!name.IsEmpty())
+	{
+		long pos = lstMembers->GetFirstSelected();
+		if (pos >= 0)
+		{
+			lstMembers->SetItem(pos, 0, name);
+			lstMembers->SetItem(pos, 1, type);
+            lstMembers->SetItem(pos, 2, notnull);
+			memberTypes.Insert(GetTypeInfo(cbDatatype->GetGuessedSelection()), pos);
+			memberLengths.Insert(length, pos);
+			memberPrecisions.Insert(precision, pos);
+            memberNotNulls.Insert(notnull, pos);
+			memberTypes.RemoveAt(pos + 1);
+			memberLengths.RemoveAt(pos + 1);
+			memberPrecisions.RemoveAt(pos + 1);
+            memberNotNulls.RemoveAt(pos + 1);
+		}
+	}
+
+	CheckChange();
+}
+
+
+void dlgForeignTable::OnMemberRemove(wxCommandEvent &ev)
+{
+	long pos = lstMembers->GetSelection();
+
+	if (pos >= 0)
+	{
+		lstMembers->DeleteItem(pos);
+		memberTypes.RemoveAt(pos);
+		memberLengths.RemoveAt(pos);
+		memberPrecisions.RemoveAt(pos);
+		memberNotNulls.RemoveAt(pos);
+	}
+	CheckChange();
+}
+
+
+pgObject *dlgForeignTable::CreateObject(pgCollection *collection)
+{
+	wxString name = GetName();
+
+	pgObject *obj = 0;
+	return obj;
+}
+
+
+void dlgForeignTable::OnChangeOptionName(wxCommandEvent &ev)
+{
+	btnAdd->Enable(txtOption->GetValue().Length() > 0);
+}
+
+
+void dlgForeignTable::OnSelChangeOption(wxListEvent &ev)
+{
+	int row = lstOptions->GetSelection();
+	if (row >= 0)
+	{
+		txtOption->SetValue(lstOptions->GetText(row, 0));
+		txtValue->SetValue(lstOptions->GetText(row, 1));
+	}
+
+	btnRemove->Enable(row >= 0);
+}
+
+
+void dlgForeignTable::OnAddOption(wxCommandEvent &ev)
+{
+	bool found = false;
+
+	for (int pos = 0 ; pos < lstOptions->GetItemCount() ; pos++)
+	{
+		if (lstOptions->GetText(pos).IsSameAs(txtOption->GetValue(), false))
+		{
+			lstOptions->SetItem(pos, 1, txtValue->GetValue());
+			found = true;
+			break;
+		}
+	}
+
+	if (!found)
+	{
+		lstOptions->AppendItem(txtOption->GetValue(), txtValue->GetValue());
+	}
+
+	txtOption->SetValue(wxT(""));
+	txtValue->SetValue(wxT(""));
+	btnAdd->Disable();
+
+	CheckChange();
+}
+
+
+void dlgForeignTable::OnRemoveOption(wxCommandEvent &ev)
+{
+	int sel = lstOptions->GetSelection();
+	lstOptions->DeleteItem(sel);
+
+	txtOption->SetValue(wxT(""));
+	txtValue->SetValue(wxT(""));
+	btnRemove->Disable();
+
+	CheckChange();
+}
+
+
+wxString dlgForeignTable::GetOptionsSql()
+{
+	wxString options = foreigntable->GetOptions();
+	wxString option, optionname, optionvalue, sqloptions;
+	bool found;
+	int pos;
+
+	while (options.Length() > 0)
+	{
+		option = options.BeforeFirst(',');
+		optionname = option.BeforeFirst(wxT('=')).Trim(false).Trim();
+		optionvalue = option.AfterFirst(wxT('=')).Trim(false).Trim();
+
+		// check for options
+		found = false;
+		for (pos = 0 ; pos < lstOptions->GetItemCount() && !found; pos++)
+		{
+			found = lstOptions->GetText(pos, 0).Cmp(optionname) == 0;
+			if (found) break;
+		}
+
+		if (found)
+		{
+			if (lstOptions->GetText(pos, 1).Cmp(optionvalue) != 0)
+			{
+				if (sqloptions.Length() > 0)
+					sqloptions += wxT(", ");
+				sqloptions += wxT("SET ") + optionname + wxT(" '") + lstOptions->GetText(pos, 1) + wxT("'");
+			}
+		}
+		else
+		{
+			if (sqloptions.Length() > 0)
+				sqloptions += wxT(", ");
+			sqloptions += wxT("DROP ") + optionname;
+		}
+
+		options = options.AfterFirst(',');
+	}
+
+	for (pos = 0 ; pos < lstOptions->GetItemCount() ; pos++)
+	{
+		options = foreigntable->GetOptions();
+		found = false;
+
+		while (options.Length() > 0 && !found)
+		{
+			option = options.BeforeFirst(',');
+			optionname = option.BeforeFirst(wxT('=')).Trim(false).Trim();
+			found = lstOptions->GetText(pos, 0).Cmp(optionname) == 0;
+			options = options.AfterFirst(',');
+		}
+
+		if (!found)
+		{
+			optionvalue = option.AfterFirst(wxT('=')).Trim(false).Trim();
+
+			if (sqloptions.Length() > 0)
+				sqloptions += wxT(", ");
+			sqloptions += wxT("ADD ") + lstOptions->GetText(pos, 0) + wxT(" '") + lstOptions->GetText(pos, 1) + wxT("'");
+		}
+	}
+
+	return sqloptions;
+}
+
+
+wxString dlgForeignTable::GetSql()
+{
+	wxString sql, direction;
+	size_t existingitems_index, listitems_index, offset;
+
+	if (foreigntable)
+	{
+		// Edit Mode
+		AppendOwnerChange(sql, wxT("FOREIGN TABLE ") + foreigntable->GetQuotedFullIdentifier());
+        
+		sql += GetSqlForTypes();
+        
+		wxString sqloptions = GetOptionsSql();
+		if (sqloptions.Length() > 0)
+		{
+			sql += wxT("ALTER FOREIGN TABLE ") + foreigntable->GetQuotedFullIdentifier()
+			       + wxT(" OPTIONS (") + sqloptions + wxT(");\n");
+		}
+	}
+	else
+	{
+		// Create Mode
+		sql = wxT("CREATE FOREIGN TABLE ") + schema->GetQuotedPrefix() + qtIdent(GetName());
+		sql += wxT(" (");
+
+        int i;
+        for (i = 0 ; i < lstMembers->GetItemCount() ; i++)
+        {
+            if (i)
+                sql += wxT(",\n    ");
+            sql += qtIdent(lstMembers->GetItemText(i)) + wxT(" ")
+                   + GetFullTypeName(i);
+        }
+
+		sql += wxT(") SERVER ") + cbForeignServer->GetValue();
+        
+		// check for options
+		if (lstOptions->GetItemCount() > 0)
+		{
+			wxString options = wxEmptyString;
+			for (int pos = 0 ; pos < lstOptions->GetItemCount() ; pos++)
+			{
+				if (options.Length() > 0)
+					options += wxT(", ");
+
+				options += lstOptions->GetText(pos, 0)
+				           + wxT(" '") + lstOptions->GetText(pos, 1) + wxT("' ");
+			}
+			sql += wxT("\n  OPTIONS (") + options + wxT(")");
+		}
+
+		sql += wxT(";\n");
+	}
+	AppendComment(sql, wxT("TYPE"), schema, foreigntable);
+
+	return sql;
+}
+
+wxString dlgForeignTable::GetFullTypeName(int type)
+{
+	wxString typname = memberTypes.Item(type).AfterFirst(':');
+
+	if (!memberLengths.Item(type).IsEmpty())
+	{
+		typname += wxT("(") + memberLengths.Item(type);
+		if (!memberPrecisions.Item(type).IsEmpty())
+			typname += wxT(",") + memberPrecisions.Item(type);
+		typname += wxT(")");
+	}
+    
+    typname += wxT(" ") + memberNotNulls.Item(type);
+
+	return typname;
+}
+
+wxString dlgForeignTable::GetSqlForTypes()
+{
+	wxString sql = wxEmptyString;
+	wxString old_name, old_type, new_name, new_type;
+	wxArrayString elements = foreigntable->GetTypesArray();
+	bool modified = lstMembers->GetItemCount()*3 != (int)elements.GetCount();
+	size_t i;
+
+	// Check if there is a change
+	for (int i = 0 ; i < lstMembers->GetItemCount() && !modified; i++)
+	{
+		old_name = elements.Item(i * 3);
+		old_type = elements.Item(i * 3 + 1) + wxT(" ") + elements.Item(i * 3 + 2);
+		new_name = lstMembers->GetItemText(i);
+		new_type = GetFullTypeName(i);
+		modified = modified || old_name != new_name || old_type != new_type;
+	}
+
+	if (modified)
+	{
+		// Drop all old attributes
+		for (i = 0 ; i < elements.GetCount() ; i += 3)
+		{
+			old_name = elements.Item(i);
+			sql += wxT("ALTER FOREIGN TABLE ") + foreigntable->GetQuotedFullIdentifier()
+                + wxT(" DROP COLUMN ") + old_name + wxT(";\n");
+		}
+
+		// Add all new attributes
+		for (int i = 0 ; i < lstMembers->GetItemCount() ; i++)
+		{
+			new_name = lstMembers->GetItemText(i);
+			new_type = GetFullTypeName(i);
+			sql += wxT("ALTER FOREIGN TABLE ") + foreigntable->GetQuotedFullIdentifier()
+                + wxT(" ADD COLUMN ") + new_name + wxT(" ") + new_type + wxT(";\n");
+		}
+	}
+
+	return sql;
+}
diff --git a/pgadmin/dlg/module.mk b/pgadmin/dlg/module.mk
index 2252957..015ba5d 100644
--- a/pgadmin/dlg/module.mk
+++ b/pgadmin/dlg/module.mk
@@ -25,6 +25,7 @@ pgadmin3_SOURCES += \
 	$(srcdir)/dlg/dlgForeignDataWrapper.cpp \
 	$(srcdir)/dlg/dlgForeignKey.cpp \
 	$(srcdir)/dlg/dlgForeignServer.cpp \
+	$(srcdir)/dlg/dlgForeignTable.cpp \
 	$(srcdir)/dlg/dlgFunction.cpp \
 	$(srcdir)/dlg/dlgGroup.cpp \
 	$(srcdir)/dlg/dlgHbaConfig.cpp \
diff --git a/pgadmin/frm/frmEditGrid.cpp b/pgadmin/frm/frmEditGrid.cpp
index 4f09b5e..446ac24 100644
--- a/pgadmin/frm/frmEditGrid.cpp
+++ b/pgadmin/frm/frmEditGrid.cpp
@@ -29,6 +29,7 @@
 #include "frm/frmHint.h"
 #include "schema/pgCatalogObject.h"
 #include "schema/pgTable.h"
+#include "schema/pgForeignTable.h"
 #include "schema/pgView.h"
 #include "schema/gpExtTable.h"
 
@@ -1278,7 +1279,7 @@ void frmEditGrid::ShowForm(bool filter)
 {
 	bool abort = false;
 
-	if (relkind == 'r' || relkind == 'v' || relkind == 'x')
+	if (relkind == 'r' || relkind == 'v' || relkind == 'x' || relkind == 'f')
 	{
 		if (filter)
 		{
@@ -3257,7 +3258,7 @@ bool editGridFactoryBase::CheckEnable(pgObject *obj)
 	if (obj)
 	{
 		pgaFactory *factory = obj->GetFactory();
-		return factory == &tableFactory || factory == &viewFactory || factory == &extTableFactory || factory == &catalogObjectFactory;
+		return factory == &tableFactory || factory == &foreignTableFactory || factory == &viewFactory || factory == &extTableFactory || factory == &catalogObjectFactory;
 	}
 	return false;
 }
diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp
index f5f15be..6f0fe40 100644
--- a/pgadmin/frm/frmQuery.cpp
+++ b/pgadmin/frm/frmQuery.cpp
@@ -45,6 +45,7 @@
 #include "schema/pgDatabase.h"
 #include "schema/pgFunction.h"
 #include "schema/pgTable.h"
+#include "schema/pgForeignTable.h"
 #include "schema/pgView.h"
 #include "schema/gpExtTable.h"
 #include "schema/pgServer.h"
@@ -3071,7 +3072,7 @@ queryToolSelectFactory::queryToolSelectFactory(menuFactoryList *list, wxMenu *mn
 bool queryToolSelectFactory::CheckEnable(pgObject *obj)
 {
 	return queryToolBaseFactory::CheckEnable(obj) && !obj->IsCollection() &&
-	       (obj->IsCreatedBy(tableFactory) || obj->IsCreatedBy(viewFactory) || obj->IsCreatedBy(functionFactory));
+	       (obj->IsCreatedBy(tableFactory) || obj->IsCreatedBy(foreignTableFactory) || obj->IsCreatedBy(viewFactory) || obj->IsCreatedBy(functionFactory));
 }
 
 wxWindow *queryToolSelectFactory::StartDialog(frmMain *form, pgObject *obj)
@@ -3096,6 +3097,11 @@ wxWindow *queryToolSelectFactory::StartDialog(frmMain *form, pgObject *obj)
 		pgFunction *function = (pgFunction *)obj;
 		return StartDialogSql(form, obj, function->GetSelectSql(form->GetBrowser()));
 	}
+	else if (obj->IsCreatedBy(foreignTableFactory))
+	{
+		pgForeignTable *foreigntable = (pgForeignTable *)obj;
+		return StartDialogSql(form, obj, foreigntable->GetSelectSql(form->GetBrowser()));
+	}
 	return 0;
 }
 
diff --git a/pgadmin/include/dlg/dlgForeignTable.h b/pgadmin/include/dlg/dlgForeignTable.h
new file mode 100644
index 0000000..2787bb5
--- /dev/null
+++ b/pgadmin/include/dlg/dlgForeignTable.h
@@ -0,0 +1,68 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+//
+// Copyright (C) 2002 - 2011, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// dlgForeignTable.h - Foreign Table property
+//
+//////////////////////////////////////////////////////////////////////////
+
+
+#ifndef __DLG_FOREIGNTABLEPROP
+#define __DLG_FOREIGNTABLEPROP
+
+#include "dlg/dlgProperty.h"
+
+class pgForeignTable;
+
+class dlgForeignTable : public dlgTypeProperty
+{
+public:
+	dlgForeignTable(pgaFactory *factory, frmMain *frame, pgForeignTable *node, pgSchema *schema);
+
+	void CheckChange();
+	wxString GetSql();
+	wxString GetSqlForTypes();
+	pgObject *CreateObject(pgCollection *collection);
+	pgObject *GetObject();
+
+	bool WannaSplitQueries()
+	{
+		return queriesToBeSplitted;
+	}
+
+	int Go(bool modal);
+
+private:
+	pgSchema *schema;
+	pgForeignTable *foreigntable;
+    
+	void OnMemberAdd(wxCommandEvent &ev);
+	void OnMemberChange(wxCommandEvent &ev);
+	void OnMemberRemove(wxCommandEvent &ev);
+	void OnMemberSelChange(wxListEvent &ev);
+	void OnSelChangeTyp(wxCommandEvent &ev);
+	void OnSelChangeTypOrLen(wxCommandEvent &ev);
+	void OnChangeMember(wxCommandEvent &ev);
+    
+    void OnSelChangeOption(wxListEvent &ev);
+	void OnChangeOptionName(wxCommandEvent &ev);
+	void OnAddOption(wxCommandEvent &ev);
+	void OnChangeOption(wxCommandEvent &ev);
+	void OnRemoveOption(wxCommandEvent &ev);
+
+	wxString GetOptionsSql();
+
+	void showDefinition(int panel);
+	wxString GetFullTypeName(int type);
+
+	wxArrayString memberTypes, memberLengths, memberPrecisions, memberNotNulls;
+	bool queriesToBeSplitted;
+
+	DECLARE_EVENT_TABLE()
+};
+
+
+#endif
diff --git a/pgadmin/include/dlg/module.mk b/pgadmin/include/dlg/module.mk
index 4bf7cd1..af2d538 100644
--- a/pgadmin/include/dlg/module.mk
+++ b/pgadmin/include/dlg/module.mk
@@ -25,6 +25,7 @@ pgadmin3_SOURCES += \
 	$(srcdir)/include/dlg/dlgForeignDataWrapper.h \
 	$(srcdir)/include/dlg/dlgForeignKey.h \
 	$(srcdir)/include/dlg/dlgForeignServer.h \
+	$(srcdir)/include/dlg/dlgForeignTable.h \
 	$(srcdir)/include/dlg/dlgFunction.h \
 	$(srcdir)/include/dlg/dlgGroup.h \
 	$(srcdir)/include/dlg/dlgHbaConfig.h \
diff --git a/pgadmin/include/images/foreigntable.png b/pgadmin/include/images/foreigntable.png
new file mode 100755
index 0000000..53c1338
Binary files /dev/null and b/pgadmin/include/images/foreigntable.png differ
diff --git a/pgadmin/include/images/foreigntables.png b/pgadmin/include/images/foreigntables.png
new file mode 100755
index 0000000..dc1f742
Binary files /dev/null and b/pgadmin/include/images/foreigntables.png differ
diff --git a/pgadmin/include/images/module.mk b/pgadmin/include/images/module.mk
index 6a666b2..9417df6 100644
--- a/pgadmin/include/images/module.mk
+++ b/pgadmin/include/images/module.mk
@@ -116,6 +116,8 @@ pgadmin3_SOURCES += \
 	$(srcdir)/include/images/foreignserver.png \
 	$(srcdir)/include/images/foreignserver-sm.png \
 	$(srcdir)/include/images/foreignservers.png \
+	$(srcdir)/include/images/foreigntable.png \
+	$(srcdir)/include/images/foreigntables.png \
 	$(srcdir)/include/images/forward.png \
 	$(srcdir)/include/images/function.png \
 	$(srcdir)/include/images/functions.png \
diff --git a/pgadmin/include/schema/module.mk b/pgadmin/include/schema/module.mk
index e897e37..004096a 100644
--- a/pgadmin/include/schema/module.mk
+++ b/pgadmin/include/schema/module.mk
@@ -29,6 +29,7 @@ pgadmin3_SOURCES += \
 	$(srcdir)/include/schema/pgForeignDataWrapper.h \
 	$(srcdir)/include/schema/pgForeignKey.h \
     $(subdir)/pgForeignServer.h \
+	$(srcdir)/include/schema/pgForeignTable.h \
 	$(srcdir)/include/schema/pgFunction.h \
 	$(srcdir)/include/schema/pgGroup.h \
 	$(srcdir)/include/schema/pgIndex.h \
diff --git a/pgadmin/include/schema/pgForeignTable.h b/pgadmin/include/schema/pgForeignTable.h
new file mode 100644
index 0000000..dfb643a
--- /dev/null
+++ b/pgadmin/include/schema/pgForeignTable.h
@@ -0,0 +1,102 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+//
+// Copyright (C) 2002 - 2011, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// pgForeignTable.h PostgreSQL Foreign Table
+//
+//////////////////////////////////////////////////////////////////////////
+
+#ifndef PGFOREIGNTABLE_H
+#define PGFOREIGNTABLE_H
+
+#include "pgSchema.h"
+
+class pgForeignTableFactory : public pgSchemaObjFactory
+{
+public:
+	pgForeignTableFactory();
+	virtual dlgProperty *CreateDialog(frmMain *frame, pgObject *node, pgObject *parent);
+	virtual pgObject *CreateObjects(pgCollection *obj, ctlTree *browser, const wxString &restr = wxEmptyString);
+};
+extern pgForeignTableFactory foreignTableFactory;
+
+class pgForeignTable : public pgSchemaObject
+{
+public:
+	pgForeignTable(pgSchema *newSchema, const wxString &newName = wxT(""));
+	~pgForeignTable();
+
+	wxString GetTranslatedMessage(int kindOfMessage) const;
+	void ShowTreeDetail(ctlTree *browser, frmMain *form = 0, ctlListView *properties = 0, ctlSQLBox *sqlPane = 0);
+	bool CanDropCascaded()
+	{
+		return !GetSystemObject() && pgSchemaObject::CanDrop();
+	}
+
+	wxString GetForeignServer() const
+	{
+		return foreignserver;
+	}
+	void iSetForeignServer(const wxString &s)
+	{
+		foreignserver = s;
+	}
+	wxString GetOptions() const
+	{
+		return options;
+	}
+	void iSetOptions(const wxString &s)
+	{
+		options = s;
+	}
+	const wxArrayString &GetTypesArray()
+	{
+		return typesArray;
+	}
+	wxString GetTypesList() const
+	{
+		return typesList;
+	}
+	wxString GetQuotedTypesList() const
+	{
+		return quotedTypesList;
+	}
+
+	bool DropObject(wxFrame *frame, ctlTree *browser, bool cascaded);
+	wxString GetSql(ctlTree *browser);
+	wxString GetSelectSql(ctlTree *browser);
+	pgObject *Refresh(ctlTree *browser, const wxTreeItemId item);
+
+	bool HasStats()
+	{
+		return false;
+	}
+	bool HasDepends()
+	{
+		return true;
+	}
+	bool HasReferences()
+	{
+		return true;
+	}
+	bool CanView()
+	{
+		return true;
+	}
+
+private:
+	wxString foreignserver, options, typesList, quotedTypesList;
+	wxArrayString typesArray;
+};
+
+class pgForeignTableCollection : public pgSchemaObjCollection
+{
+public:
+	pgForeignTableCollection(pgaFactory *factory, pgSchema *sch);
+	wxString GetTranslatedMessage(int kindOfMessage) const;
+};
+
+#endif
diff --git a/pgadmin/schema/module.mk b/pgadmin/schema/module.mk
index bbcd106..1fb0435 100644
--- a/pgadmin/schema/module.mk
+++ b/pgadmin/schema/module.mk
@@ -31,6 +31,7 @@ pgadmin3_SOURCES += \
         $(subdir)/pgForeignDataWrapper.cpp \
         $(subdir)/pgForeignKey.cpp \
         $(subdir)/pgForeignServer.cpp \
+        $(subdir)/pgForeignTable.cpp \
         $(subdir)/pgFunction.cpp \
         $(subdir)/pgGroup.cpp \
         $(subdir)/pgIndex.cpp \
diff --git a/pgadmin/schema/pgForeignTable.cpp b/pgadmin/schema/pgForeignTable.cpp
new file mode 100644
index 0000000..d5cfa6b
--- /dev/null
+++ b/pgadmin/schema/pgForeignTable.cpp
@@ -0,0 +1,297 @@
+//////////////////////////////////////////////////////////////////////////
+//
+// pgAdmin III - PostgreSQL Tools
+//
+// Copyright (C) 2002 - 2011, The pgAdmin Development Team
+// This software is released under the PostgreSQL Licence
+//
+// pgForeignTable.cpp - Foreign Table class
+//
+//////////////////////////////////////////////////////////////////////////
+
+// wxWindows headers
+#include <wx/wx.h>
+
+// App headers
+#include "pgAdmin3.h"
+#include "utils/misc.h"
+#include "schema/pgForeignTable.h"
+#include "schema/pgDatatype.h"
+
+
+pgForeignTable::pgForeignTable(pgSchema *newSchema, const wxString &newName)
+	: pgSchemaObject(newSchema, foreignTableFactory, newName)
+{
+}
+
+pgForeignTable::~pgForeignTable()
+{
+}
+
+wxString pgForeignTable::GetTranslatedMessage(int kindOfMessage) const
+{
+	wxString message = wxEmptyString;
+
+	switch (kindOfMessage)
+	{
+		case RETRIEVINGDETAILS:
+			message = _("Retrieving details on foreign table");
+			message += wxT(" ") + GetName();
+			break;
+		case REFRESHINGDETAILS:
+			message = _("Refreshing foreign table");
+			message += wxT(" ") + GetName();
+			break;
+		case DROPINCLUDINGDEPS:
+			message = wxString::Format(_("Are you sure you wish to drop foreign table \"%s\" including all objects that depend on it?"),
+			                           GetFullIdentifier().c_str());
+			break;
+		case DROPEXCLUDINGDEPS:
+			message = wxString::Format(_("Are you sure you wish to drop foreign table \"%s?\""),
+			                           GetFullIdentifier().c_str());
+			break;
+		case DROPCASCADETITLE:
+			message = _("Drop foreign table cascaded?");
+			break;
+		case DROPTITLE:
+			message = _("Drop foreign table?");
+			break;
+		case PROPERTIESREPORT:
+			message = _("Foreign table properties report");
+			message += wxT(" - ") + GetName();
+			break;
+		case PROPERTIES:
+			message = _("Foreign table properties");
+			break;
+		case DDLREPORT:
+			message = _("Foreign table DDL report");
+			message += wxT(" - ") + GetName();
+			break;
+		case DDL:
+			message = _("Foreign table DDL");
+			break;
+		case DEPENDENCIESREPORT:
+			message = _("Foreign table dependencies report");
+			message += wxT(" - ") + GetName();
+			break;
+		case DEPENDENCIES:
+			message = _("Foreign table dependencies");
+			break;
+		case DEPENDENTSREPORT:
+			message = _("Foreign table dependents report");
+			message += wxT(" - ") + GetName();
+			break;
+		case DEPENDENTS:
+			message = _("Foreign table dependents");
+			break;
+	}
+
+	return message;
+}
+
+
+bool pgForeignTable::DropObject(wxFrame *frame, ctlTree *browser, bool cascaded)
+{
+	wxString sql = wxT("DROP FOREIGN TABLE ") + this->GetSchema()->GetQuotedIdentifier() + wxT(".") + this->GetQuotedIdentifier();
+	if (cascaded)
+		sql += wxT(" CASCADE");
+	return GetDatabase()->ExecuteVoid(sql);
+}
+
+wxString pgForeignTable::GetSql(ctlTree *browser)
+{
+	if (sql.IsNull())
+	{
+		sql = wxT("-- Foreign Table: ") + GetQuotedFullIdentifier() + wxT("\n\n")
+		      + wxT("-- DROP FOREIGN TABLE ") + GetQuotedFullIdentifier() + wxT(";")
+		      + wxT("\n\nCREATE FOREIGN TABLE ") + GetQuotedFullIdentifier()
+              + wxT("\n   (") + GetQuotedTypesList()
+              + wxT(")\n   SERVER ") + GetForeignServer();
+
+        if (!GetOptions().IsEmpty())
+            sql += wxT("\n   OPTIONS (") + GetOptions() + wxT(")");
+              
+        sql += wxT(";\n")
+              + GetOwnerSql(9, 1)
+              + GetCommentSql();
+	}
+
+	return sql;
+}
+
+
+
+void pgForeignTable::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
+{
+    wxString constraint;
+    
+	if (!expandedKids)
+	{
+		expandedKids = true;
+        pgSet *set = ExecuteSet(
+                         wxT("SELECT attname, format_type(t.oid,NULL) AS typname, attndims, atttypmod, nspname, attnotnull,\n")
+                         wxT("       (SELECT COUNT(1) from pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup\n")
+                         wxT("  FROM pg_attribute att\n")
+                         wxT("  JOIN pg_type t ON t.oid=atttypid\n")
+                         wxT("  JOIN pg_namespace nsp ON t.typnamespace=nsp.oid\n")
+                         wxT("  LEFT OUTER JOIN pg_type b ON t.typelem=b.oid\n")
+                         wxT(" WHERE att.attrelid=") + GetOidStr() + wxT("\n")
+                         wxT(" AND attnum>0\n")
+                         wxT(" ORDER by attnum"));
+        if (set)
+        {
+            int anzvar = 0;
+            while (!set->Eof())
+            {
+                pgDatatype dt(set->GetVal(wxT("nspname")), set->GetVal(wxT("typname")),
+                              set->GetBool(wxT("isdup")), set->GetLong(wxT("attndims")) > 0, set->GetLong(wxT("atttypmod")));
+                constraint = set->GetBool(wxT("attnotnull")) ? wxT("NOT NULL") : wxT("");
+
+                if (anzvar++)
+                {
+                    typesList += wxT(", ");
+                    quotedTypesList += wxT(",\n    ");
+                }
+
+                typesList += set->GetVal(wxT("attname")) + wxT(" ")
+                            + dt.GetSchemaPrefix(GetDatabase()) + dt.FullName() + wxT(" ")
+                            + constraint;
+
+                quotedTypesList += qtIdent(set->GetVal(wxT("attname"))) + wxT(" ")
+                            + dt.GetQuotedSchemaPrefix(GetDatabase()) + dt.QuotedFullName() + wxT(" ")
+                            + constraint;
+
+                typesArray.Add(set->GetVal(wxT("attname")));
+                typesArray.Add(dt.GetSchemaPrefix(GetDatabase()) + dt.FullName());
+                typesArray.Add(constraint);
+
+                set->MoveNext();
+            }
+            delete set;
+        }
+	}
+
+	if (properties)
+	{
+		CreateListColumns(properties);
+
+		properties->AppendItem(_("Name"), GetName());
+		properties->AppendItem(_("OID"), GetOid());
+		properties->AppendItem(_("Owner"), GetOwner());
+		properties->AppendItem(_("Server"), GetForeignServer());
+        properties->AppendItem(_("Columns"), GetTypesList());
+        properties->AppendItem(_("Options"), GetOptions());
+		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));
+	}
+}
+
+
+wxString pgForeignTable::GetSelectSql(ctlTree *browser)
+{
+    
+	wxString columns = wxEmptyString;
+    wxArrayString elements = GetTypesArray();
+    size_t i;
+    for (i = 0 ; i < elements.GetCount() ; i += 3)
+    {
+        if (!columns.IsEmpty())
+            columns += wxT(", ");
+        columns += elements.Item(i);
+    }
+
+	wxString sql =
+	    wxT("SELECT ") + columns + wxT("\n")
+	    wxT("  FROM ") + GetQuotedFullIdentifier() + wxT(";\n");
+	return sql;
+}
+
+
+pgObject *pgForeignTable::Refresh(ctlTree *browser, const wxTreeItemId item)
+{
+	pgObject *ft = 0;
+	pgCollection *coll = browser->GetParentCollection(item);
+	if (coll)
+		ft = foreignTableFactory.CreateObjects(coll, 0, wxT("\n   AND c.oid=") + GetOidStr());
+
+	return ft;
+}
+
+
+wxString pgForeignTableCollection::GetTranslatedMessage(int kindOfMessage) const
+{
+	wxString message = wxEmptyString;
+
+	switch (kindOfMessage)
+	{
+		case RETRIEVINGDETAILS:
+			message = _("Retrieving details on foreign tables");
+			break;
+		case REFRESHINGDETAILS:
+			message = _("Refreshing foreign tables");
+			break;
+		case OBJECTSLISTREPORT:
+			message = _("Foreign tables list report");
+			break;
+	}
+
+	return message;
+}
+
+
+/////////////////////////////////////////////////////////
+
+
+pgObject *pgForeignTableFactory::CreateObjects(pgCollection *collection, ctlTree *browser, const wxString &restriction)
+{
+	pgForeignTable *foreigntable = 0;
+
+	wxString sql =	wxT("SELECT c.oid AS ftoid, c.relname AS ftrelname, pg_get_userbyid(relowner) AS ftowner, ")
+                    wxT("array_to_string(ftoptions, ',') AS ftoptions, srvname AS ftsrvname, description\n")
+	                wxT("  FROM pg_class c\n")
+	                wxT("  JOIN pg_foreign_table ft ON c.oid=ft.ftrelid\n")
+	                wxT("  LEFT OUTER JOIN pg_foreign_server fs ON ft.ftserver=fs.oid\n")
+	                wxT("  LEFT OUTER JOIN pg_description des ON des.objoid=c.oid\n")
+                    wxT(" WHERE c.relnamespace = ") + collection->GetSchema()->GetOidStr() + wxT("\n")
+                    + restriction +
+                    wxT(" ORDER BY c.relname");
+
+	pgSet *foreigntables = collection->GetDatabase()->ExecuteSet(sql);
+
+	if (foreigntables)
+	{
+		while (!foreigntables->Eof())
+		{
+			foreigntable = new pgForeignTable(collection->GetSchema(), foreigntables->GetVal(wxT("ftrelname")));
+
+			foreigntable->iSetOid(foreigntables->GetOid(wxT("ftoid")));
+			foreigntable->iSetOwner(foreigntables->GetVal(wxT("ftowner")));
+			foreigntable->iSetForeignServer(foreigntables->GetVal(wxT("ftsrvname")));
+			foreigntable->iSetOptions(foreigntables->GetVal(wxT("ftoptions")));
+			foreigntable->iSetComment(foreigntables->GetVal(wxT("description")));
+
+			if (browser)
+			{
+				browser->AppendObject(collection, foreigntable);
+				foreigntables->MoveNext();
+			}
+			else
+				break;
+		}
+
+		delete foreigntables;
+	}
+	return foreigntable;
+}
+
+
+#include "images/foreigntable.pngc"
+#include "images/foreigntables.pngc"
+
+pgForeignTableFactory::pgForeignTableFactory()
+	: pgSchemaObjFactory(__("Foreign Table"), __("New Foreign Table..."), __("Create a new Foreign Table."), foreigntable_png_img)
+{
+}
+
+
+pgForeignTableFactory foreignTableFactory;
+static pgaCollectionFactory cf(&foreignTableFactory, __("Foreign Tables"), foreigntables_png_img);
diff --git a/pgadmin/schema/pgObject.cpp b/pgadmin/schema/pgObject.cpp
index 56faa73..badfa97 100644
--- a/pgadmin/schema/pgObject.cpp
+++ b/pgadmin/schema/pgObject.cpp
@@ -42,6 +42,7 @@
 #include "schema/pgForeignKey.h"
 #include "schema/pgForeignDataWrapper.h"
 #include "schema/pgForeignServer.h"
+#include "schema/pgForeignTable.h"
 #include "schema/pgRule.h"
 #include "schema/pgRole.h"
 #include "schema/pgCast.h"
@@ -122,6 +123,8 @@ wxString pgObject::GetTranslatedMessage(int kindOfMessage) const
 		message = ((pgForeignKey *)this)->GetTranslatedMessage(kindOfMessage);
 	else if (type == wxT("Foreign Data Wrapper"))
 		message = ((pgForeignDataWrapper *)this)->GetTranslatedMessage(kindOfMessage);
+	else if (type == wxT("Foreign Table"))
+		message = ((pgForeignTable *)this)->GetTranslatedMessage(kindOfMessage);
 	else if (type == wxT("Foreign Server"))
 		message = ((pgForeignServer *)this)->GetTranslatedMessage(kindOfMessage);
 	else if (type == wxT("FTS Configuration"))
@@ -219,6 +222,8 @@ wxString pgObject::GetTranslatedMessage(int kindOfMessage) const
 			message = ((pgForeignDataWrapperObjCollection *)this)->GetTranslatedMessage(kindOfMessage);
 		else if (type == wxT("Foreign Servers"))
 			message = ((pgForeignServerCollection *)this)->GetTranslatedMessage(kindOfMessage);
+		else if (type == wxT("Foreign Tables"))
+			message = ((pgForeignTableCollection *)this)->GetTranslatedMessage(kindOfMessage);
 		else if (type == wxT("FTS Configurations"))
 			message = ((pgTextSearchConfigurationCollection *)this)->GetTranslatedMessage(kindOfMessage);
 		else if (type == wxT("FTS Dictionaries"))
diff --git a/pgadmin/schema/pgSchema.cpp b/pgadmin/schema/pgSchema.cpp
index f0e5f7a..656bc43 100644
--- a/pgadmin/schema/pgSchema.cpp
+++ b/pgadmin/schema/pgSchema.cpp
@@ -23,6 +23,7 @@
 #include "schema/pgDomain.h"
 #include "schema/pgAggregate.h"
 #include "schema/pgConversion.h"
+#include "schema/pgForeignTable.h"
 #include "schema/pgFunction.h"
 #include "schema/pgOperator.h"
 #include "schema/pgOperatorClass.h"
@@ -238,6 +239,15 @@ wxMenu *pgSchemaBase::GetNewMenu()
 			if (GetConnection()->BackendMinimumVersion(8, 3))
 				textSearchConfigurationFactory.AppendMenu(menu);
 		}
+        /*
+		if (settings->GetDisplayOption(_("Foreign Tables")))
+		{
+        */
+			if (GetConnection()->BackendMinimumVersion(9, 1))
+				foreignTableFactory.AppendMenu(menu);
+		/*
+        }
+        */
 		if (settings->GetDisplayOption(_("Trigger Functions")))
 			triggerFunctionFactory.AppendMenu(menu);
 		if (settings->GetDisplayOption(_("Types")))
@@ -313,6 +323,8 @@ void pgSchemaBase::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *
 				browser->AppendCollection(this, conversionFactory);
 			if (settings->GetDisplayOption(_("Domains")))
 				browser->AppendCollection(this, domainFactory);
+			if (settings->GetDisplayOption(_("Foreign Tables")))
+				browser->AppendCollection(this, foreignTableFactory);
 			if (settings->GetDisplayOption(_("FTS Configurations")))
 			{
 				if (GetConnection()->BackendMinimumVersion(8, 3))
diff --git a/pgadmin/ui/dlgForeignTable.xrc b/pgadmin/ui/dlgForeignTable.xrc
new file mode 100644
index 0000000..6faf607
--- /dev/null
+++ b/pgadmin/ui/dlgForeignTable.xrc
@@ -0,0 +1,380 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<resource>
+  <object class="wxDialog" name="dlgForeignTable">
+    <title></title>
+    <size>220,280d</size>
+    <style>wxDEFAULT_DIALOG_STYLE|wxCAPTION|wxSYSTEM_MENU|wxRESIZE_BORDER</style>
+    <object class="wxFlexGridSizer">
+      <cols>1</cols>
+      <growablerows>0</growablerows>
+      <growablecols>0</growablecols>
+      <object class="sizeritem">
+        <object class="wxNotebook" name="nbNotebook">
+          <size>216,255d</size>
+          <selected>0</selected>
+          <object class="notebookpage">
+            <label>Properties</label>
+            <object class="wxPanel" name="pnlProperties">
+              <object class="wxFlexGridSizer">
+                <cols>2</cols>
+                <rows>6</rows>
+                <vgap>5</vgap>
+                <hgap>5</hgap>
+                <growablerows>4</growablerows>
+                <growablecols>1</growablecols>
+                <object class="sizeritem">
+                  <object class="wxStaticText" name="stName">
+                    <label>Name</label>
+                  </object>
+                  <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxTextCtrl" name="txtName">
+                  </object>
+                  <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxStaticText" name="stOID">
+                    <label>OID</label>
+                  </object>
+                  <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxTextCtrl" name="txtOID">
+                  </object>
+                  <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxStaticText" name="stOwner">
+                    <label>Owner</label>
+                  </object>
+                  <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="ctlComboBox" name="cbOwner">
+                    <content/>
+                    <style>wxCB_DROPDOWN</style>
+                  </object>
+                  <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxStaticText" name="stForeignServer">
+                    <label>Foreign Server</label>
+                  </object>
+                  <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxComboBox" name="cbForeignServer">
+                    <content/>
+                    <style>wxCB_READONLY|wxCB_DROPDOWN</style>
+                  </object>
+                  <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxStaticText" name="stComment">
+                    <label>Comment</label>
+                  </object>
+                  <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxTextCtrl" name="txtComment">
+                    <style>wxTE_MULTILINE</style>
+                  </object>
+                  <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxStaticText" name="stClusterSet">
+                    <label>Use replication</label>
+                  </object>
+                  <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxComboBox" name="cbClusterSet">
+                    <content/>
+                    <style>wxCB_READONLY|wxCB_DROPDOWN</style>
+                  </object>
+                  <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+              </object>
+            </object>
+          </object>
+          <object class="notebookpage">
+            <label>Definition</label>
+            <object class="wxPanel" name="pnlDefinition">
+              <object class="wxFlexGridSizer">
+                <cols>1</cols>
+                <rows>3</rows>
+                <vgap>5</vgap>
+                <hgap>5</hgap>
+                <growablerows>0,1,2</growablerows>
+                <growablecols>0</growablecols>
+                <object class="sizeritem">
+                  <object class="wxPanel" name="pnlDefinitionComposite">
+                    <object class="wxFlexGridSizer">
+                    <cols>1</cols>
+                    <rows>3</rows>
+                    <vgap>5</vgap>
+                    <hgap>5</hgap>
+                    <growablecols>0</growablecols>
+                    <growablerows>0</growablerows>
+                    <object class="sizeritem">
+                      <object class="wxListCtrl" name="lstMembers">
+                        <style>wxLC_REPORT|wxLC_SINGLE_SEL</style>
+                      </object>
+                      <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                      <border>4</border>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxFlexGridSizer">
+                        <cols>2</cols>
+                        <rows>5</rows>
+                        <vgap>5</vgap>
+                        <hgap>5</hgap>
+                        <growablecols>1</growablecols>
+                        <object class="sizeritem">
+                          <object class="wxStaticText" name="stMembername">
+                            <label>Member name</label>
+                          </object>
+                          <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxTextCtrl" name="txtMembername">
+                          </object>
+                          <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxStaticText" name="stDatatype">
+                            <label>Data type</label>
+                          </object>
+                          <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxComboBox" name="cbDatatype">
+                            <content/>
+                            <style>wxCB_DROPDOWN</style>
+                          </object>
+                          <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxStaticText" name="stLength">
+                            <label>Length</label>
+                          </object>
+                          <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxTextCtrl" name="txtLength">
+                          </object>
+                          <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxStaticText" name="stPrecision">
+                            <label>Precision</label>
+                          </object>
+                          <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxTextCtrl" name="txtPrecision">
+                          </object>
+                          <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxStaticText" name="stNotNull">
+                            <label>NOT NULL</label>
+                          </object>
+                          <flag>wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxCheckBox" name="chkNotNull">
+                          </object>
+                          <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                          <border>4</border>
+                        </object>
+                      </object>
+                      <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                      <border>4</border>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxFlexGridSizer">
+                        <object class="sizeritem">
+                          <object class="wxButton" name="btnRemoveMember">
+                            <label>Remove</label>
+                          </object>
+                          <flag>wxALL|wxALIGN_RIGHT</flag>
+                          <border>2</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxButton" name="btnAddMember">
+                            <label>Add</label>
+                          </object>
+                          <flag>wxALL|wxALIGN_RIGHT</flag>
+                          <border>2</border>
+                        </object>
+                        <object class="sizeritem">
+                          <object class="wxButton" name="btnChangeMember">
+                            <label>Change</label>
+                          </object>
+                          <flag>wxALL|wxALIGN_RIGHT</flag>
+                          <border>2</border>
+                        </object>
+                        <cols>3</cols>
+                        <rows>1</rows>
+                      </object>
+                      <flag>wxALIGN_RIGHT</flag>
+                    </object>
+                    </object>
+                  </object>
+                  <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                  <border>4</border>
+                </object>
+              </object>
+            </object>
+          </object>
+          <object class="notebookpage">
+            <label>Options</label>
+            <object class="wxPanel" name="pnlOptions">
+              <object class="wxFlexGridSizer">
+                <cols>1</cols>
+                <rows>3</rows>
+                <growablerows>0</growablerows>
+                <growablecols>0</growablecols>
+                <object class="sizeritem">
+                  <object class="wxListCtrl" name="lstOptions">
+                    <pos>70,15d</pos>
+                    <style>wxLC_REPORT|wxLC_SINGLE_SEL</style>
+                  </object>
+                  <option>80</option>
+                  <flag>wxALL|wxEXPAND</flag>
+                  <border>5</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxFlexGridSizer">
+                    <cols>2</cols>
+                    <rows>2</rows>
+                    <vgap>5</vgap>
+                    <hgap>5</hgap>
+                    <growablecols>1</growablecols>
+                    <object class="sizeritem">
+                      <object class="wxStaticText" name="stOption">
+                        <label>Option</label>
+                      </object>
+                      <flag>wxALIGN_CENTRE_VERTICAL</flag>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxTextCtrl" name="txtOption">
+                        <size>135,-1d</size>
+                      </object>
+                      <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                      <border>4</border>
+                      <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxStaticText" name="stValue">
+                        <label>Value</label>
+                      </object>
+                      <flag>wxALIGN_CENTRE_VERTICAL</flag>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxTextCtrl" name="txtValue">
+                        <size>135,-1d</size>
+                      </object>
+                      <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                      <border>4</border>
+                      <flag>wxEXPAND|wxALIGN_CENTRE_VERTICAL</flag>
+                    </object>
+                  </object>
+                  <flag>wxALL|wxEXPAND|wxALIGN_BOTTOM|wxALIGN_CENTRE_HORIZONTAL</flag>
+                  <border>5</border>
+                </object>
+                <object class="sizeritem">
+                  <object class="wxFlexGridSizer">
+                    <cols>2</cols>
+                    <rows>1</rows>
+                    <object class="sizeritem">
+                      <object class="wxButton" name="wxID_REMOVE">
+                        <label>Remove</label>
+                        <pos>13,58d</pos>
+                      </object>
+                      <flag>wxALL|wxALIGN_RIGHT</flag>
+                      <border>2</border>
+                    </object>
+                    <object class="sizeritem">
+                      <object class="wxButton" name="wxID_ADD">
+                        <label>Add/Change</label>
+                        <pos>13,78d</pos>
+                      </object>
+                      <flag>wxALL|wxALIGN_RIGHT</flag>
+                      <border>2</border>
+                    </object>
+                  </object>
+                  <flag>wxALIGN_RIGHT</flag>
+                </object>
+              </object>
+            </object>
+          </object>
+        </object>
+        <flag>wxEXPAND|wxALIGN_CENTRE|wxALL</flag>
+        <border>3</border>
+      </object>
+      <object class="sizeritem">
+        <object class="wxFlexGridSizer">
+          <cols>4</cols>
+          <growablecols>1</growablecols>
+          <object class="sizeritem">
+            <object class="wxButton" name="wxID_HELP">
+              <label>Help</label>
+            </object>
+            <flag>wxEXPAND|wxALL</flag>
+            <border>3</border>
+          </object>
+          <object class="spacer">
+            <size>0,0d</size>
+          </object>
+          <object class="sizeritem">
+            <object class="wxButton" name="wxID_OK">
+              <label>&amp;OK</label>
+              <default>1</default>
+            </object>
+            <flag>wxEXPAND|wxALL</flag>
+            <border>3</border>
+          </object>
+          <object class="sizeritem">
+            <object class="wxButton" name="wxID_CANCEL">
+              <label>&amp;Cancel</label>
+            </object>
+            <flag>wxEXPAND|wxALL</flag>
+            <border>3</border>
+          </object>
+        </object>
+        <flag>wxEXPAND|wxTOP|wxLEFT|wxRIGHT</flag>
+      </object>
+      <object class="sizeritem">
+        <object class="wxStatusBar" name="unkStatusBar">
+          <style>wxST_SIZEGRIP</style>
+        </object>
+        <flag>wxEXPAND|wxALIGN_CENTRE</flag>
+        <border>3</border>
+      </object>
+    </object>
+  </object>
+</resource>
diff --git a/pgadmin/ui/module.mk b/pgadmin/ui/module.mk
index 79da290..b82a84c 100644
--- a/pgadmin/ui/module.mk
+++ b/pgadmin/ui/module.mk
@@ -29,6 +29,7 @@ TMP_ui += \
 	$(srcdir)/ui/dlgForeignDataWrapper.xrc \
 	$(srcdir)/ui/dlgForeignKey.xrc \
 	$(srcdir)/ui/dlgForeignServer.xrc \
+	$(srcdir)/ui/dlgForeignTable.xrc \
 	$(srcdir)/ui/dlgFunction.xrc \
 	$(srcdir)/ui/dlgGroup.xrc \
 	$(srcdir)/ui/dlgHbaConfig.xrc \
