~ubuntu-branches/debian/sid/pgadmin3/sid

« back to all changes in this revision

Viewing changes to pgadmin/dlg/dlgTrigger.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2009-07-30 12:27:16 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730122716-fddbh42on721bbs2
Tags: 1.10.0-1
* New upstream release.
* Adjusted watch file to match release candidates.
* Updated to Standards-Version 3.8.2:
  - Moved to Section: database.
  - Add DEB_BUILD_OPTIONS support for parallel building.
  - Move from findstring to filter suggestion for DEB_BUILD_OPTIONS parsing.
* pgagent got split into its own separate source package by upstream.
* Exclude Docs.vcproj from installation.
* Move doc-base.enus from pgadmin3 to pgadmin3-data package, the files are
  in there too.

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: dlgTrigger.cpp 7012 2008-01-23 14:04:46Z dpage $
5
 
// Copyright (C) 2002 - 2008, The pgAdmin Development Team
6
 
// This software is released under the Artistic Licence
 
4
// RCS-ID:      $Id: dlgTrigger.cpp 7916 2009-06-11 10:12:17Z dpage $
 
5
// Copyright (C) 2002 - 2009, The pgAdmin Development Team
 
6
// This software is released under the BSD Licence
7
7
//
8
8
// dlgTrigger.cpp - PostgreSQL Trigger Property
9
9
//
32
32
#define chkInsert       CTRL_CHECKBOX("chkInsert")
33
33
#define chkUpdate       CTRL_CHECKBOX("chkUpdate")
34
34
#define chkDelete       CTRL_CHECKBOX("chkDelete")
 
35
#define chkTruncate     CTRL_CHECKBOX("chkTruncate")
35
36
#define txtBody         CTRL_SQLBOX("txtBody")
36
37
 
37
38
BEGIN_EVENT_TABLE(dlgTrigger, dlgProperty)
40
41
    EVT_CHECKBOX(XRCID("chkInsert"),                dlgProperty::OnChange)
41
42
    EVT_CHECKBOX(XRCID("chkUpdate"),                dlgProperty::OnChange)
42
43
    EVT_CHECKBOX(XRCID("chkDelete"),                dlgProperty::OnChange)
 
44
    EVT_CHECKBOX(XRCID("chkTruncate"),              dlgProperty::OnChange)
43
45
    EVT_TEXT(XRCID("cbFunction"),                   dlgTrigger::OnChangeFunc)
44
46
    EVT_COMBOBOX(XRCID("cbFunction"),               dlgProperty::OnChange)
45
47
    EVT_TEXT(XRCID("txtArguments"),                 dlgProperty::OnChange)
60
62
{
61
63
    trigger=node;
62
64
    table=parentNode;
63
 
    wxASSERT(!table || table->GetMetaType() == PGM_TABLE);
 
65
    wxASSERT(!table || table->GetMetaType() == PGM_TABLE || table->GetMetaType() == GP_PARTITION);
64
66
 
65
67
    txtBody->SetMarginType(1, wxSTC_MARGIN_NUMBER);
66
68
    txtBody->SetMarginWidth(1, ConvertDialogToPixels(wxPoint(16, 0)).x);
82
84
        chkInsert->SetValue((trigger->GetTriggerType() & TRIGGER_TYPE_INSERT) != 0);
83
85
        chkUpdate->SetValue((trigger->GetTriggerType() & TRIGGER_TYPE_UPDATE) != 0);
84
86
        chkDelete->SetValue((trigger->GetTriggerType() & TRIGGER_TYPE_DELETE) != 0);
 
87
                chkTruncate->SetValue((trigger->GetTriggerType() & TRIGGER_TYPE_TRUNCATE) != 0);
85
88
        rdbFires->SetSelection(trigger->GetTriggerType() & TRIGGER_TYPE_BEFORE ? 0 : 1);
86
89
        txtArguments->SetValue(trigger->GetArguments());
87
90
        if (!connection->BackendMinimumVersion(7, 4))
109
112
            chkInsert->Disable();
110
113
            chkUpdate->Disable();
111
114
            chkDelete->Disable();
 
115
                    chkTruncate->Disable();
112
116
        }
 
117
        else if (!connection->BackendMinimumVersion(8, 4))
 
118
                        chkTruncate->Disable();
113
119
    }
114
120
    else
115
121
    {
124
130
        pgSet *set=connection->ExecuteSet(
125
131
            wxT("SELECT quote_ident(nspname) || '.' || quote_ident(proname)\n")
126
132
            wxT("  FROM pg_proc p, pg_namespace n, pg_language l\n")
127
 
            wxT(" WHERE p.pronamespace = n.oid AND p.prolang = l.oid AND l.lanname != 'edbspl' AND prorettype=") + NumToStr(PGOID_TYPE_TRIGGER) + sysRestr);
 
133
            wxT(" WHERE p.pronamespace = n.oid AND p.prolang = l.oid AND l.lanname != 'edbspl' AND prorettype=") + NumToStr(PGOID_TYPE_TRIGGER) + sysRestr + 
 
134
            wxT(" ORDER BY nspname ASC, proname ASC "));
128
135
        if (set)
129
136
        {
130
137
            while (!set->Eof())
141
148
        }
142
149
        
143
150
        txtBody->Disable();
 
151
 
 
152
                if (!connection->BackendMinimumVersion(8, 4))
 
153
                        chkTruncate->Disable();
 
154
 
144
155
    }
 
156
 
145
157
    return dlgProperty::Go(modal);
146
158
}
147
159
 
164
176
        chkInsert->GetValue() != (trigger->GetTriggerType() & TRIGGER_TYPE_INSERT ? true : false) ||
165
177
        chkUpdate->GetValue() != (trigger->GetTriggerType() & TRIGGER_TYPE_UPDATE ? true : false) ||
166
178
        chkDelete->GetValue() != (trigger->GetTriggerType() & TRIGGER_TYPE_DELETE ? true : false) ||
 
179
                chkTruncate->GetValue() != (trigger->GetTriggerType() & TRIGGER_TYPE_TRUNCATE ? true : false) ||
167
180
        rdbFires->GetSelection() != (trigger->GetTriggerType() & TRIGGER_TYPE_BEFORE ? 0 : 1))
168
181
    {
169
182
        if (cbFunction->GetValue() == wxString::Format(wxT("<%s>"), _("Inline EDB-SPL")))
194
207
                sql += wxT(" OR");
195
208
            sql += wxT(" DELETE");
196
209
        }
 
210
        if (chkTruncate->GetValue())
 
211
        {
 
212
            if (actionCount++)
 
213
                sql += wxT(" OR");
 
214
            sql += wxT(" TRUNCATE");
 
215
        }
197
216
        sql += wxT("\n   ON ") + table->GetQuotedFullIdentifier()
198
217
            + wxT(" FOR EACH ");
199
218
        if (chkRow->GetValue())
258
277
    wxString function=cbFunction->GetValue();
259
278
    wxString name=GetName();
260
279
 
 
280
        // We can only have per-statement TRUNCATE triggers
 
281
        if (connection->BackendMinimumVersion(8, 4))
 
282
        {
 
283
                if (chkRow->GetValue())
 
284
                {
 
285
                        chkTruncate->Disable();
 
286
                        chkTruncate->SetValue(false);
 
287
                }
 
288
                else
 
289
                        chkTruncate->Enable();
 
290
        }
 
291
 
261
292
    CheckValid(enable, !name.IsEmpty(), _("Please specify name."));
262
293
    CheckValid(enable, !function.IsEmpty(), _("Please specify trigger function."));
263
 
    CheckValid(enable, chkInsert->GetValue() || chkUpdate->GetValue() ||chkDelete->GetValue(),
 
294
 
 
295
    CheckValid(enable, chkInsert->GetValue() || chkUpdate->GetValue() ||chkDelete->GetValue() ||chkTruncate->GetValue(),
264
296
        _("Please specify at least one action."));
265
297
 
 
298
    if (cbFunction->GetValue() == wxString::Format(wxT("<%s>"), _("Inline EDB-SPL")))
 
299
        CheckValid(enable, !txtBody->GetText().IsEmpty(), _("Please specify trigger body."));
 
300
 
266
301
    if (trigger)
267
302
    {
268
303
        EnableOK(enable &&
273
308
                 chkInsert->GetValue() != (trigger->GetTriggerType() & TRIGGER_TYPE_INSERT ? true : false) ||
274
309
                 chkUpdate->GetValue() != (trigger->GetTriggerType() & TRIGGER_TYPE_UPDATE ? true : false) ||
275
310
                 chkDelete->GetValue() != (trigger->GetTriggerType() & TRIGGER_TYPE_DELETE ? true : false) ||
 
311
                                 chkTruncate->GetValue() != (trigger->GetTriggerType() & TRIGGER_TYPE_TRUNCATE ? true : false) ||
276
312
                 rdbFires->GetSelection() != (trigger->GetTriggerType() & TRIGGER_TYPE_BEFORE ? 0 : 1)));
277
313
    }
278
314
    else
290
326
}
291
327
 
292
328
 
 
329