~ubuntu-branches/ubuntu/maverick/pgadmin3/maverick

« back to all changes in this revision

Viewing changes to pgadmin/slony/dlgRepCluster.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2009-12-17 20:34:00 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20091217203400-tlnmt4m3v7udjp0h
Tags: 1.10.1-1
* New upstream release, containing fix for:
  - default value in function parameters not shown (closes: #547940)
  - cannot open files without dot in names for restore (closes: #451038)
* Suggest postgresql-contrib (closes: #503291)
* Set myself as Maintainer and remove Raphael. Thanks for his work so far.
* Switch Uploaders and Maintainer role to better describe reality.
* Bump to Standards-Version to 3.8.3.
* Update to debhelper level 7, use dh_prep instead of dh_clean -k.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//////////////////////////////////////////////////////////////////////////
2
2
//
3
3
// pgAdmin III - PostgreSQL Tools
4
 
// RCS-ID:      $Id: dlgRepCluster.cpp 7885 2009-05-27 13:36:54Z dpage $
 
4
// RCS-ID:      $Id: dlgRepCluster.cpp 8057 2009-10-01 12:54:22Z dpage $
5
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
6
6
// This software is released under the BSD Licence
7
7
//
139
139
                }
140
140
                delete set;
141
141
 
142
 
                cbDatabase->SetSelection(0);
 
142
                if (cbDatabase->GetCount())
 
143
                    cbDatabase->SetSelection(0);
143
144
            }
144
145
        }
145
146
 
179
180
                }
180
181
                delete set;
181
182
            }
182
 
            cbClusterName->SetSelection(0);
 
183
 
 
184
            if (cbClusterName->GetCount())
 
185
                cbClusterName->SetSelection(0);
183
186
        }
184
187
    }
185
188
    OnChangeCluster(ev);
232
235
    return page;
233
236
}
234
237
 
 
238
bool dlgRepCluster::SlonyMaximumVersion(const wxString &series, long minor)
 
239
{
 
240
 
 
241
    wxString slonySeries;
 
242
    long slonyMinorVersion;
 
243
 
 
244
    slonySeries = slonyVersion.BeforeLast('.');  
 
245
    slonyVersion.AfterLast('.').ToLong(&slonyMinorVersion);
 
246
 
 
247
    return slonySeries == series && slonyMinorVersion <= minor;
 
248
}
 
249
 
 
250
 
235
251
 
236
252
int dlgRepCluster::Go(bool modal)
237
253
{
296
312
        // create mode
297
313
        cbAdminNode->Hide();
298
314
 
 
315
        wxString scriptVersion = wxEmptyString;
 
316
        wxString xxidVersion = wxEmptyString;
 
317
 
299
318
        txtNodeID->SetValidator(numericValidator);
300
319
        txtAdminNodeID->SetValidator(numericValidator);
301
320
        txtClusterName->Hide();
302
321
 
303
 
                if (connection->BackendMinimumVersion(8, 0))
304
 
                {
305
 
                        if (!AddScript(createScript, wxT("xxid.v80.sql")) || 
306
 
                                !AddScript(createScript, wxT("slony1_base.sql")) || 
307
 
                                !AddScript(createScript, wxT("slony1_funcs.sql")) || 
308
 
                                !AddScript(createScript, wxT("slony1_funcs.v80.sql")))
309
 
                                createScript = wxEmptyString;
310
 
                }
311
 
                else
312
 
                {
313
 
                        if (!AddScript(createScript, wxT("xxid.v74.sql")) || 
314
 
                                !AddScript(createScript, wxT("slony1_base.sql")) || 
315
 
                                !AddScript(createScript, wxT("slony1_funcs.sql")) || 
316
 
                                !AddScript(createScript, wxT("slony1_funcs.v74.sql")))
317
 
                                createScript = wxEmptyString;
318
 
                }
319
 
 
 
322
        //We need to find the exact Slony Version.
 
323
        //NOTE: We are not supporting Slony versions less than 1.2.0
 
324
 
 
325
        wxString tempScript;
 
326
        AddScript(tempScript, wxT("slony1_funcs.sql"));
 
327
 
 
328
        if (tempScript.Contains(wxT("@MODULEVERSION@")) && slonyVersion.IsEmpty())
 
329
        {
 
330
                this->database->ExecuteVoid(wxT("CREATE OR REPLACE FUNCTION pgadmin_slony_version() returns text as '$libdir/slony1_funcs', '_Slony_I_getModuleVersion' LANGUAGE C"));
 
331
                slonyVersion = this->database->ExecuteScalar(wxT("SELECT pgadmin_slony_version();"));
 
332
                this->database->ExecuteVoid(wxT("DROP FUNCTION pgadmin_slony_version()"));
 
333
 
 
334
                if (slonyVersion.IsEmpty())
 
335
                {
 
336
                    wxLogError(_("Couldn't test for the Slony version. Assuming 1.2.0"));
 
337
                    slonyVersion = wxT("1.2.0");
 
338
                }
 
339
        }
 
340
 
 
341
        //Here we are finding the exact slony scripts version, which is based on Slony Version and PG Version.
 
342
        // For Slony 1.2.0 to 1.2.17 and 2.0.0 if PG 7.3 script version is v73 
 
343
        // For Slony 1.2.0 to 1.2.17 and 2.0.0 if PG 7.4 script version is v74 
 
344
        // For Slony 1.2.0 to 1.2.6 if PG 8.0+ script version is v80 
 
345
        // For Slony 1.2.7 to 1.2.17 and 2.0.0 if PG 8.0 script version is v80 
 
346
        // For Slony 1.2.7 to 1.2.17 and 2.0.0 if PG 8.1+ script version is v81 
 
347
        // For Slony 2.0.1 and 2.0.2 if PG 8.3+ script version is v83. (These version onwards do not support PG Version less than 8.3) 
 
348
        // For Slony 2.0.3 if PG 8.3 script version is v83.
 
349
        // For Slony 2.0.3 if PG 8.4+ script version is v84.
 
350
 
 
351
        //Since both 1.2 and 2.0 series is increasing, the following code needs to be updated with each Slony or PG update.
 
352
          
 
353
 
 
354
        if (!tempScript.IsEmpty())
 
355
        {
 
356
                //Set the slony_base and slony_funcs script version.
 
357
                if (SlonyMaximumVersion(wxT("1.2"), 6)) 
 
358
                { 
 
359
                        if (connection->BackendMinimumVersion(8, 0))
 
360
                                scriptVersion = wxT("v80");
 
361
                        else 
 
362
                        {
 
363
                                if (connection->BackendMinimumVersion(7, 4))
 
364
                                        scriptVersion = wxT("v74");
 
365
                                else 
 
366
                                        scriptVersion = wxT("v73");
 
367
                        }
 
368
                }
 
369
                else 
 
370
                {
 
371
                        if (SlonyMaximumVersion(wxT("1.2"), 17) || SlonyMaximumVersion(wxT("2.0"), 0))
 
372
                        {
 
373
                                if (connection->BackendMinimumVersion(8, 1))
 
374
                                        scriptVersion = wxT("v81");
 
375
                                else 
 
376
                                {
 
377
                                        if (connection->BackendMinimumVersion(8, 0))
 
378
                                                scriptVersion = wxT("v80");
 
379
                                        else 
 
380
                                        {
 
381
                                                if (connection->BackendMinimumVersion(7, 4))
 
382
                                                         scriptVersion = wxT("v74");
 
383
                                                else 
 
384
                                                         scriptVersion = wxT("v73");
 
385
                                        }
 
386
                                }
 
387
                        }
 
388
                        else 
 
389
                        {
 
390
                                if (SlonyMaximumVersion(wxT("2.0"), 2))
 
391
                                        scriptVersion = wxT("v83");
 
392
                                else 
 
393
                                {
 
394
                                        if (SlonyMaximumVersion(wxT("2.0"), 3))
 
395
                                        {
 
396
                                                if (connection->BackendMinimumVersion(8, 4))
 
397
                                                        scriptVersion = wxT("v84");
 
398
                                        }
 
399
                                        else
 
400
                                                scriptVersion = wxT("v83");
 
401
                                }
 
402
                        }
 
403
 
 
404
               }
 
405
 
 
406
               //Set the correct xxid version if applicable
 
407
               // For Slony 1.2.0 to 1.2.17 and 2.0.0 if PG 7.3 xxid version is v73 
 
408
               // For Slony 1.2.1 to 1.2.17 and 2.0.0 if PG 7.4+ xxid version is v74
 
409
               // For Slony 1.2.0 if PG 8.0 xxid version is v80
 
410
               // For Slony 2.0.1+ and PG8.4+ xxid is obsolete. 
 
411
                        
 
412
               if (SlonyMaximumVersion(wxT("1.2"), 0))
 
413
               {
 
414
                       if (connection->BackendMinimumVersion(8, 0))
 
415
                               xxidVersion = wxT("v80");
 
416
                       else
 
417
                       {
 
418
                               if (connection->BackendMinimumVersion(7, 4))
 
419
                                        xxidVersion = wxT("v74");
 
420
                               else
 
421
                                        xxidVersion = wxT("v73"); 
 
422
                       }
 
423
               }
 
424
               else
 
425
               {
 
426
                       if (SlonyMaximumVersion(wxT("1.2"), 17) || SlonyMaximumVersion(wxT("2.0"), 0))
 
427
                       {
 
428
                               if (!connection->BackendMinimumVersion(8, 4))
 
429
                               {
 
430
                                       if (connection->BackendMinimumVersion(7, 4))
 
431
                                               xxidVersion = wxT("v74");
 
432
                                       else
 
433
                                               xxidVersion = wxT("v73");  
 
434
                               }
 
435
                       } 
 
436
               } 
 
437
  
 
438
 
 
439
                wxString slonyBaseVersionFilename = wxT("slony1_base.") + scriptVersion + wxT(".sql");
 
440
                wxString slonyFuncsVersionFilename = wxT("slony1_funcs.") + scriptVersion + wxT(".sql");
 
441
 
 
442
                wxString xxidVersionFilename;
 
443
                
 
444
                if (!xxidVersion.IsEmpty())
 
445
                        xxidVersionFilename = wxT("xxid.") + xxidVersion + wxT(".sql");
 
446
       
 
447
                if (((!xxidVersion.IsEmpty() && !AddScript(createScript, xxidVersionFilename)) ||
 
448
                    !AddScript(createScript, wxT("slony1_base.sql")) || 
 
449
                    !AddScript(createScript, slonyBaseVersionFilename) ||
 
450
                    !AddScript(createScript, wxT("slony1_funcs.sql")) ||
 
451
                    !AddScript(createScript, slonyFuncsVersionFilename)))
 
452
                        createScript = wxEmptyString;
 
453
                  
 
454
        }
 
455
 
320
456
        treeObjectIterator it(mainForm->GetBrowser(), mainForm->GetServerCollection());
321
457
        pgServer *s;
322
458
        int sel=-1;