Hi,

Robert Haas commited a patch to add support for a new CLI option to
pg_dump and pg_dumpall. "--quote-all-identifiers" forces the use of
double quotes on all identifiers. The patch attached adds support for
this on our frmBackup, frmBackupGlobals and frmBackupServer windows.

BTW, it is a GIT patch.

Comments?


-- 
Guillaume
 http://www.postgresql.fr
 http://dalibo.com
From be226c21fb444744d1fb669ce08b6f90a25d1014 Mon Sep 17 00:00:00 2001
From: Guillaume Lelarge <guilla...@lelarge.info>
Date: Mon, 26 Jul 2010 21:37:25 +0200
Subject: [PATCH] Add support for --quote-all-identifiers CLI option on 9.1 pg_dump/pg_dumpall.

---
 pgadmin/frm/frmBackup.cpp              |    7 +++++++
 pgadmin/frm/frmBackupGlobals.cpp       |   24 +++++++++++++++++-------
 pgadmin/frm/frmBackupServer.cpp        |   24 +++++++++++++++++-------
 pgadmin/include/frm/frmBackupGlobals.h |    2 ++
 pgadmin/include/frm/frmBackupServer.h  |    2 ++
 pgadmin/ui/frmBackup.xrc               |    9 ++++++++-
 pgadmin/ui/frmBackupGlobals.xrc        |    6 +++++-
 pgadmin/ui/frmBackupServer.xrc         |    6 +++++-
 8 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/pgadmin/frm/frmBackup.cpp b/pgadmin/frm/frmBackup.cpp
index a347597..7922216 100644
--- a/pgadmin/frm/frmBackup.cpp
+++ b/pgadmin/frm/frmBackup.cpp
@@ -48,6 +48,7 @@
 #define chkNoPrivileges         CTRL_CHECKBOX("chkNoPrivileges")
 #define chkNoTablespaces        CTRL_CHECKBOX("chkNoTablespaces")
 #define chkUseSetSession        CTRL_CHECKBOX("chkUseSetSession")
+#define chkForceQuoteForIdent   CTRL_CHECKBOX("chkForceQuoteForIdent")
 #define ctvObjects              CTRL_CHECKTREEVIEW("ctvObjects")
 
 
@@ -184,6 +185,10 @@ frmBackup::frmBackup(frmMain *form, pgObject *obj) : ExternProcessDialog(form)
         delete objects;
     }
 
+    if (!pgAppMinimumVersion(backupExecutable, 9,1))
+    {
+        chkForceQuoteForIdent->Disable();
+    }
     if (!pgAppMinimumVersion(backupExecutable, 8, 4))
     {
         chkNoTablespaces->Disable();
@@ -372,6 +377,8 @@ wxString frmBackup::getCmdPart2()
         cmd.Append(wxT(" --ignore-version"));
     if (chkVerbose->GetValue())
         cmd.Append(wxT(" --verbose"));
+    if (chkForceQuoteForIdent->GetValue())
+        cmd.Append(wxT(" --quote-all-identifiers"));
 
     cmd.Append(wxT(" --file \"") + txtFilename->GetValue() + wxT("\""));
 
diff --git a/pgadmin/frm/frmBackupGlobals.cpp b/pgadmin/frm/frmBackupGlobals.cpp
index ec2c9c4..7f7ea6f 100644
--- a/pgadmin/frm/frmBackupGlobals.cpp
+++ b/pgadmin/frm/frmBackupGlobals.cpp
@@ -30,6 +30,7 @@
 #define txtFilename             CTRL_TEXT("txtFilename")
 #define btnFilename             CTRL_BUTTON("btnFilename")
 #define chkVerbose              CTRL_CHECKBOX("chkVerbose")
+#define chkForceQuoteForIdent   CTRL_CHECKBOX("chkForceQuoteForIdent")
 
 
 BEGIN_EVENT_TABLE(frmBackupGlobals, ExternProcessDialog)
@@ -51,6 +52,14 @@ frmBackupGlobals::frmBackupGlobals(frmMain *form, pgObject *obj) : ExternProcess
 
     SetTitle(object->GetTranslatedMessage(BACKUPGLOBALS));
 
+    pgServer *server = (pgServer *)object;
+    if (server->GetConnection()->EdbMinimumVersion(8,0))
+        backupExecutable=edbBackupAllExecutable;
+    else if (server->GetConnection()->GetIsGreenplum())
+        backupExecutable=gpBackupAllExecutable;
+    else
+        backupExecutable=pgBackupAllExecutable;
+
     wxString val;
     settings->Read(wxT("frmBackupGlobals/LastFile"), &val, wxEmptyString);
     txtFilename->SetValue(val);
@@ -79,6 +88,11 @@ frmBackupGlobals::frmBackupGlobals(frmMain *form, pgObject *obj) : ExternProcess
     txtMessages->SetMaxLength(0L);
     btnOK->Disable();
 
+    if (!pgAppMinimumVersion(backupExecutable, 9,1))
+    {
+        chkForceQuoteForIdent->Disable();
+    }
+
     wxCommandEvent ev;
     OnChange(ev);
 }
@@ -150,13 +164,7 @@ wxString frmBackupGlobals::getCmdPart1()
 	else
         server=object->GetDatabase()->GetServer();
 
-    wxString cmd;
-    if (server->GetConnection()->EdbMinimumVersion(8,0))
-        cmd=edbBackupAllExecutable;
-    else if (server->GetConnection()->GetIsGreenplum())
-        cmd=gpBackupAllExecutable;
-    else
-        cmd=pgBackupAllExecutable;
+    wxString cmd = backupExecutable;
 
     if (!server->GetName().IsEmpty())
         cmd += wxT(" --host ") + server->GetName();
@@ -175,6 +183,8 @@ wxString frmBackupGlobals::getCmdPart2()
         cmd.Append(wxT(" --ignore-version"));
     if (chkVerbose->GetValue())
         cmd.Append(wxT(" --verbose"));
+    if (chkForceQuoteForIdent->GetValue())
+        cmd.Append(wxT(" --quote-all-identifiers"));
 
     cmd.Append(wxT(" --file \"") + txtFilename->GetValue() + wxT("\""));
 
diff --git a/pgadmin/frm/frmBackupServer.cpp b/pgadmin/frm/frmBackupServer.cpp
index 46f08d3..34de3b1 100644
--- a/pgadmin/frm/frmBackupServer.cpp
+++ b/pgadmin/frm/frmBackupServer.cpp
@@ -30,6 +30,7 @@
 #define txtFilename             CTRL_TEXT("txtFilename")
 #define btnFilename             CTRL_BUTTON("btnFilename")
 #define chkVerbose              CTRL_CHECKBOX("chkVerbose")
+#define chkForceQuoteForIdent   CTRL_CHECKBOX("chkForceQuoteForIdent")
 
 
 BEGIN_EVENT_TABLE(frmBackupServer, ExternProcessDialog)
@@ -51,6 +52,14 @@ frmBackupServer::frmBackupServer(frmMain *form, pgObject *obj) : ExternProcessDi
 
     SetTitle(object->GetTranslatedMessage(BACKUPSERVERTITLE));
 
+    pgServer *server = (pgServer *)object;
+    if (server->GetConnection()->EdbMinimumVersion(8,0))
+        backupExecutable=edbBackupAllExecutable;
+    else if (server->GetConnection()->GetIsGreenplum())
+        backupExecutable=gpBackupAllExecutable;
+    else
+        backupExecutable=pgBackupAllExecutable;
+
     wxString val;
     settings->Read(wxT("frmBackupServer/LastFile"), &val, wxEmptyString);
     txtFilename->SetValue(val);
@@ -68,6 +77,11 @@ frmBackupServer::frmBackupServer(frmMain *form, pgObject *obj) : ExternProcessDi
     txtMessages->SetMaxLength(0L);
     btnOK->Disable();
 
+    if (!pgAppMinimumVersion(backupExecutable, 9,1))
+    {
+        chkForceQuoteForIdent->Disable();
+    }
+
     wxCommandEvent ev;
     OnChange(ev);
 }
@@ -135,13 +149,7 @@ wxString frmBackupServer::getCmdPart1()
 {
     pgServer *server = (pgServer *)object;
 
-    wxString cmd;
-    if (server->GetConnection()->EdbMinimumVersion(8,0))
-        cmd=edbBackupAllExecutable;
-    else if (server->GetConnection()->GetIsGreenplum())
-        cmd=gpBackupAllExecutable;
-    else
-        cmd=pgBackupAllExecutable;
+    wxString cmd = backupExecutable;
 
     if (!server->GetName().IsEmpty())
         cmd += wxT(" --host ") + server->GetName();
@@ -160,6 +168,8 @@ wxString frmBackupServer::getCmdPart2()
         cmd.Append(wxT(" --ignore-version"));
     if (chkVerbose->GetValue())
         cmd.Append(wxT(" --verbose"));
+    if (chkForceQuoteForIdent->GetValue())
+        cmd.Append(wxT(" --quote-all-identifiers"));
 
     cmd.Append(wxT(" --file \"") + txtFilename->GetValue() + wxT("\""));
 
diff --git a/pgadmin/include/frm/frmBackupGlobals.h b/pgadmin/include/frm/frmBackupGlobals.h
index 97833e9..78cf6a4 100644
--- a/pgadmin/include/frm/frmBackupGlobals.h
+++ b/pgadmin/include/frm/frmBackupGlobals.h
@@ -37,6 +37,8 @@ private:
     void OnOK(wxCommandEvent &ev);
 
     pgObject *object;
+
+    wxString backupExecutable;
     wxString processedFile;
 
     DECLARE_EVENT_TABLE()
diff --git a/pgadmin/include/frm/frmBackupServer.h b/pgadmin/include/frm/frmBackupServer.h
index eb464d5..7430626 100644
--- a/pgadmin/include/frm/frmBackupServer.h
+++ b/pgadmin/include/frm/frmBackupServer.h
@@ -37,6 +37,8 @@ private:
     void OnOK(wxCommandEvent &ev);
 
     pgObject *object;
+
+    wxString backupExecutable;
     wxString processedFile;
 
     DECLARE_EVENT_TABLE()
diff --git a/pgadmin/ui/frmBackup.xrc b/pgadmin/ui/frmBackup.xrc
index 3f91aa9..eb1c17c 100644
--- a/pgadmin/ui/frmBackup.xrc
+++ b/pgadmin/ui/frmBackup.xrc
@@ -268,7 +268,7 @@
                   <object class="wxStaticBoxSizer">
                     <label>Miscellanous</label>
                     <cols>1</cols>
-                    <rows>3</rows>
+                    <rows>4</rows>
                     <vgap>5</vgap>
                     <hgap>5</hgap>
                     <growablecols>0</growablecols>
@@ -295,6 +295,13 @@
                       <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
                       <border>4</border>
                     </object>
+                    <object class="sizeritem">
+                      <object class="wxCheckBox" name="chkForceQuoteForIdent">
+                        <label>Force double quotes on identifiers</label>
+                      </object>
+                      <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
+                      <border>4</border>
+                    </object>
                   </object>
                   <flag>wxEXPAND|wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT</flag>
                   <border>4</border>
diff --git a/pgadmin/ui/frmBackupGlobals.xrc b/pgadmin/ui/frmBackupGlobals.xrc
index f2561ee..457afd8 100644
--- a/pgadmin/ui/frmBackupGlobals.xrc
+++ b/pgadmin/ui/frmBackupGlobals.xrc
@@ -31,6 +31,10 @@
                 <pos>8,25d</pos>
                 <style></style>
               </object>
+              <object class="wxCheckBox" name="chkForceQuoteForIdent">
+                <label>Force double quotes on identifiers</label>
+                <pos>10,120d</pos>
+              </object>
               <object class="wxCheckBox" name="chkVerbose">
                 <label>Verbose messages</label>
                 <checked>1</checked>
@@ -91,4 +95,4 @@
       <growablerows>0</growablerows>
     </object>
   </object>
-</resource>
\ No newline at end of file
+</resource>
diff --git a/pgadmin/ui/frmBackupServer.xrc b/pgadmin/ui/frmBackupServer.xrc
index 997098a..2560488 100644
--- a/pgadmin/ui/frmBackupServer.xrc
+++ b/pgadmin/ui/frmBackupServer.xrc
@@ -31,6 +31,10 @@
                 <pos>8,25d</pos>
                 <style></style>
               </object>
+              <object class="wxCheckBox" name="chkForceQuoteForIdent">
+                <label>Force double quotes on identifiers</label>
+                <pos>10,120d</pos>
+              </object>
               <object class="wxCheckBox" name="chkVerbose">
                 <label>Verbose messages</label>
                 <checked>1</checked>
@@ -91,4 +95,4 @@
       <growablerows>0</growablerows>
     </object>
   </object>
-</resource>
\ No newline at end of file
+</resource>
-- 
1.7.0.4

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to