~ubuntu-branches/ubuntu/utopic/pgadmin3/utopic-proposed

« back to all changes in this revision

Viewing changes to pgadmin/debugger/debugger.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs
  • Date: 2011-06-07 23:03:54 UTC
  • mfrom: (1.3.1 upstream) (13 sid)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20110607230354-3td4j9y71u4ahcvj
Tags: 1.14.0~beta1-1
* New upstream development release, adding Build-Depends on
  postgresql-server-dev-all >= 117~.
* Add Build-Depends on quilt, (un)patch to debian/rules and patch for fixing
  the include for kwlist.h in pgadmin/db/keywords.c.
* Add pg_config --includedir-server output to CPPFLAGS.
* Remove unrecognized configure options: --with-wx-config,
  --with-pgsql-include, --enable-gtk2, --enable-unicode.
* Clean up manually the files that are left behind after the broken
  distclean.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//////////////////////////////////////////////////////////////////////////
2
2
//
3
3
// pgAdmin III - PostgreSQL Tools
4
 
// 
5
 
// Copyright (C) 2002 - 2010, The pgAdmin Development Team
 
4
//
 
5
// Copyright (C) 2002 - 2011, The pgAdmin Development Team
6
6
// This software is released under the PostgreSQL Licence
7
7
//
8
8
// debugger.cpp - Debugger factories
28
28
///////////////////////////////////////////////////
29
29
debuggerFactory::debuggerFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar) : actionFactory(list)
30
30
{
31
 
    mnu->Append(id, _("&Debug"), _("Debug the selected object"));
 
31
        mnu->Append(id, _("&Debug"), _("Debug the selected object"));
32
32
}
33
33
 
34
34
wxWindow *debuggerFactory::StartDialog(frmMain *form, pgObject *obj)
35
35
{
36
 
    // Check here to make sure the function still exists before proceeding.
37
 
    // There is still a very small window in which it might be dropped, but
38
 
    // that will be handled by a cache lookup failure error in the database
39
 
    // We also make sure the function name doesn't contain a : as that will
40
 
    // sent the debugger API nuts.
41
 
    pgSet *res = obj->GetConnection()->ExecuteSet(wxT("SELECT count(*) AS count, proname FROM pg_proc WHERE oid = ") + NumToStr((long)obj->GetOid()) + wxT(" GROUP BY proname"));
42
 
    if (res->GetVal(wxT("proname")).Contains(wxT(":")))
43
 
    {
44
 
        wxLogError(_("Functions with a colon in the name cannot be debugged."));
45
 
        return 0;
46
 
    }
47
 
 
48
 
    if (res->GetLong(wxT("count")) != 1)
49
 
    {
50
 
        wxLogError(_("The selected function could not be found."));
51
 
        ctlTree *browser = form->GetBrowser();
52
 
        wxTreeItemId item=browser->GetSelection();
53
 
        if (obj == browser->GetObject(item))
54
 
        {
55
 
            pgCollection *coll=browser->GetParentCollection(obj->GetId());
56
 
            browser->DeleteChildren(coll->GetId());
57
 
            coll->ShowTreeDetail(browser);
58
 
        }
59
 
        return 0;
60
 
    }
61
 
 
62
 
    // Setup the debugger frame
63
 
    frmDebugger *debugger = new frmDebugger(form, wxString::Format(_("Debugger - %s"), obj->GetFullIdentifier().c_str()));
64
 
 
65
 
    // Setup the connection properties to be used by the debugger
66
 
    dbgConnProp cp;
67
 
    cp.m_database = obj->GetDatabase()->GetIdentifier();
68
 
    cp.m_host = obj->GetServer()->GetName();
69
 
    cp.m_password = obj->GetDatabase()->GetServer()->GetPassword();
70
 
    cp.m_port = NumToStr((long)obj->GetServer()->GetPort());
71
 
    cp.m_sslMode = obj->GetServer()->GetSSL();
72
 
    cp.m_userName = obj->GetServer()->GetUsername();
73
 
 
74
 
    // Setup the debugging session
75
 
    dlgDirectDbg *directDebugger = NULL;
76
 
    directDebugger = debugger->addDirectDbg(cp);
77
 
    if (directDebugger == NULL)
78
 
    {
79
 
        return 0;
80
 
    }
81
 
 
82
 
    dbgBreakPointList &breakpoints = directDebugger->getBreakpointList();
83
 
    breakpoints.Append(new dbgBreakPoint(dbgBreakPoint::OID, NumToStr((long)obj->GetOid()), wxT("'NULL'")));
84
 
    if (!directDebugger->startDebugging())
85
 
    {
86
 
        ctlTree *browser = form->GetBrowser();
87
 
        wxTreeItemId item=browser->GetSelection();
88
 
        if (obj == browser->GetObject(item))
89
 
        {
90
 
            pgCollection *coll=browser->GetParentCollection(obj->GetId());
91
 
            browser->DeleteChildren(coll->GetId());
92
 
            coll->ShowTreeDetail(browser);
93
 
        }
94
 
        return 0;
95
 
    }
96
 
 
97
 
    // Return the debugger window to frmMain.
98
 
    if (debugger && !directDebugger->GetCancelled())
99
 
        return debugger;
100
 
    else
101
 
        return 0;
 
36
        // Check here to make sure the function still exists before proceeding.
 
37
        // There is still a very small window in which it might be dropped, but
 
38
        // that will be handled by a cache lookup failure error in the database
 
39
        // We also make sure the function name doesn't contain a : as that will
 
40
        // sent the debugger API nuts.
 
41
        pgSet *res = obj->GetConnection()->ExecuteSet(wxT("SELECT count(*) AS count, proname FROM pg_proc WHERE oid = ") + NumToStr((long)obj->GetOid()) + wxT(" GROUP BY proname"));
 
42
        if (res->GetVal(wxT("proname")).Contains(wxT(":")))
 
43
        {
 
44
                wxLogError(_("Functions with a colon in the name cannot be debugged."));
 
45
                return 0;
 
46
        }
 
47
 
 
48
        if (res->GetLong(wxT("count")) != 1)
 
49
        {
 
50
                wxLogError(_("The selected function could not be found."));
 
51
                ctlTree *browser = form->GetBrowser();
 
52
                wxTreeItemId item = browser->GetSelection();
 
53
                if (obj == browser->GetObject(item))
 
54
                {
 
55
                        pgCollection *coll = browser->GetParentCollection(obj->GetId());
 
56
                        browser->DeleteChildren(coll->GetId());
 
57
                        coll->ShowTreeDetail(browser);
 
58
                }
 
59
                return 0;
 
60
        }
 
61
 
 
62
        // Setup the debugger frame
 
63
        frmDebugger *debugger = new frmDebugger(form, wxString::Format(_("Debugger - %s"), obj->GetFullIdentifier().c_str()));
 
64
 
 
65
        // Setup the connection properties to be used by the debugger
 
66
        dbgConnProp cp;
 
67
        cp.m_database = obj->GetDatabase()->GetIdentifier();
 
68
        cp.m_host = obj->GetServer()->GetName();
 
69
        cp.m_password = obj->GetDatabase()->GetServer()->GetPassword();
 
70
        cp.m_port = NumToStr((long)obj->GetServer()->GetPort());
 
71
        cp.m_sslMode = obj->GetServer()->GetSSL();
 
72
        cp.m_userName = obj->GetServer()->GetUsername();
 
73
 
 
74
        // Setup the debugging session
 
75
        dlgDirectDbg *directDebugger = NULL;
 
76
        directDebugger = debugger->addDirectDbg(cp);
 
77
        if (directDebugger == NULL)
 
78
        {
 
79
                return 0;
 
80
        }
 
81
 
 
82
        dbgBreakPointList &breakpoints = directDebugger->getBreakpointList();
 
83
        breakpoints.Append(new dbgBreakPoint(dbgBreakPoint::OID, NumToStr((long)obj->GetOid()), wxT("'NULL'")));
 
84
        if (!directDebugger->startDebugging())
 
85
        {
 
86
                ctlTree *browser = form->GetBrowser();
 
87
                wxTreeItemId item = browser->GetSelection();
 
88
                if (obj == browser->GetObject(item))
 
89
                {
 
90
                        pgCollection *coll = browser->GetParentCollection(obj->GetId());
 
91
                        browser->DeleteChildren(coll->GetId());
 
92
                        coll->ShowTreeDetail(browser);
 
93
                }
 
94
                return 0;
 
95
        }
 
96
 
 
97
        // Return the debugger window to frmMain.
 
98
        if (debugger && !directDebugger->GetCancelled())
 
99
                return debugger;
 
100
        else
 
101
                return 0;
102
102
}
103
103
 
104
104
bool debuggerFactory::CheckEnable(pgObject *obj)
105
105
{
106
 
    if (!obj)
107
 
        return false;
108
 
 
109
 
    // Can't debug catalog objects.
110
 
    if (obj->GetSchema() && obj->GetSchema()->GetMetaType() == PGM_CATALOG)
111
 
        return false;
112
 
 
113
 
    // Must be a super user or object owner to create breakpoints of any kind.
114
 
    if (!obj->GetServer() || !(obj->GetServer()->GetSuperUser() || obj->GetServer()->GetUsername() == obj->GetOwner()))
115
 
        return false;
116
 
 
117
 
    // EnterpriseDB 8.3 or earlier does not support debugging by the non-superuser
118
 
    if (!obj->GetServer()->GetSuperUser() && !obj->GetConnection()->EdbMinimumVersion(8, 4) && obj->GetConnection()->GetIsEdb())
119
 
        return false;
120
 
 
121
 
    if (!obj->IsCollection())
122
 
    {
123
 
        switch (obj->GetMetaType())
124
 
        {
125
 
            case PGM_FUNCTION:
126
 
                {
127
 
                    pgFunction *func = (pgFunction *)obj;
128
 
 
129
 
                    // If this is an EDB wrapped function, no debugging allowed
130
 
                    if (obj->GetConnection()->GetIsEdb() && func->GetSource().Trim(false).StartsWith(wxT("$__EDBwrapped__$")))
131
 
                        return false;
132
 
 
133
 
                    if (func->GetReturnType() != wxT("trigger") && func->GetReturnType() != wxT("\"trigger\""))
134
 
                    {
135
 
                        if (func->GetLanguage() == wxT("plpgsql") && obj->GetDatabase()->CanDebugPlpgsql())
136
 
                            return true;
 
106
        if (!obj)
 
107
                return false;
 
108
 
 
109
        // Can't debug catalog objects.
 
110
        if (obj->GetSchema() && obj->GetSchema()->GetMetaType() == PGM_CATALOG)
 
111
                return false;
 
112
 
 
113
        // Must be a super user or object owner to create breakpoints of any kind.
 
114
        if (!obj->GetServer() || !(obj->GetServer()->GetSuperUser() || obj->GetServer()->GetUsername() == obj->GetOwner()))
 
115
                return false;
 
116
 
 
117
        // EnterpriseDB 8.3 or earlier does not support debugging by the non-superuser
 
118
        if (!obj->GetServer()->GetSuperUser() && !obj->GetConnection()->EdbMinimumVersion(8, 4) && obj->GetConnection()->GetIsEdb())
 
119
                return false;
 
120
 
 
121
        if (!obj->IsCollection())
 
122
        {
 
123
                switch (obj->GetMetaType())
 
124
                {
 
125
                        case PGM_FUNCTION:
 
126
                        {
 
127
                                pgFunction *func = (pgFunction *)obj;
 
128
 
 
129
                                // If this is an EDB wrapped function, no debugging allowed
 
130
                                if (obj->GetConnection()->GetIsEdb() && func->GetSource().Trim(false).StartsWith(wxT("$__EDBwrapped__$")))
 
131
                                        return false;
 
132
 
 
133
                                if (func->GetReturnType() != wxT("trigger") && func->GetReturnType() != wxT("\"trigger\""))
 
134
                                {
 
135
                                        if (func->GetLanguage() == wxT("plpgsql") && obj->GetDatabase()->CanDebugPlpgsql())
 
136
                                                return true;
137
137
#ifndef EDB_LIBPQ
138
138
#ifdef __WXMSW__
139
 
                        else if (func->GetLanguage() == wxT("edbspl") &&
140
 
                                 obj->GetConnection()->EdbMinimumVersion(8, 4) &&
141
 
                                 !(PQiGetOutResult && PQiPrepareOut && PQiSendQueryPreparedOut))
142
 
                            return false;
 
139
                                        else if (func->GetLanguage() == wxT("edbspl") &&
 
140
                                                 obj->GetConnection()->EdbMinimumVersion(8, 4) &&
 
141
                                                 !obj->GetConnection()->EdbMinimumVersion(9, 0) &&
 
142
                                                 !(PQiGetOutResult && PQiPrepareOut && PQiSendQueryPreparedOut))
 
143
                                                return false;
143
144
#else
144
 
                        else if (func->GetLanguage() == wxT("edbspl") && obj->GetConnection()->EdbMinimumVersion(8, 4))
145
 
                            return false;
146
 
#endif
147
 
#endif
148
 
                        else if (func->GetLanguage() == wxT("edbspl") && obj->GetDatabase()->CanDebugEdbspl())
149
 
                            return true;
150
 
                        else
151
 
                            return false;
152
 
                    }
153
 
                    else
154
 
                        return false;
155
 
                }
156
 
                break;
157
 
 
158
 
            case EDB_PACKAGEFUNCTION:
159
 
                if (obj->GetDatabase()->GetConnection()->EdbMinimumVersion(8, 2) && 
160
 
                    obj->GetDatabase()->CanDebugEdbspl() && 
161
 
                    obj->GetName() != wxT("cons") &&
162
 
                    ((edbPackageFunction *)obj)->GetSource() != wxEmptyString &&
163
 
                    (!((edbPackageFunction *)obj)->GetSource().Trim(false).StartsWith(wxT("$__EDBwrapped__$"))))
164
 
                    return true;
165
 
                break;
166
 
 
167
 
            default:
168
 
                break;
169
 
        }
170
 
    }
171
 
    return false;
 
145
                                        else if (func->GetLanguage() == wxT("edbspl") && obj->GetConnection()->EdbMinimumVersion(8, 4))
 
146
                                                return false;
 
147
#endif
 
148
#endif
 
149
                                        else if (func->GetLanguage() == wxT("edbspl") && obj->GetDatabase()->CanDebugEdbspl())
 
150
                                                return true;
 
151
                                        else
 
152
                                                return false;
 
153
                                }
 
154
                                else
 
155
                                        return false;
 
156
                        }
 
157
                        break;
 
158
 
 
159
                        case EDB_PACKAGEFUNCTION:
 
160
                                if (obj->GetDatabase()->GetConnection()->EdbMinimumVersion(8, 2) &&
 
161
                                        obj->GetDatabase()->CanDebugEdbspl() &&
 
162
                                        obj->GetName() != wxT("cons") &&
 
163
                                        ((edbPackageFunction *)obj)->GetSource() != wxEmptyString &&
 
164
                                        (!((edbPackageFunction *)obj)->GetSource().Trim(false).StartsWith(wxT("$__EDBwrapped__$"))))
 
165
                                        return true;
 
166
                                break;
 
167
 
 
168
                        default:
 
169
                                break;
 
170
                }
 
171
        }
 
172
        return false;
172
173
}
173
174
 
174
175
///////////////////////////////////////////////////
176
177
///////////////////////////////////////////////////
177
178
breakpointFactory::breakpointFactory(menuFactoryList *list, wxMenu *mnu, ctlMenuToolbar *toolbar) : actionFactory(list)
178
179
{
179
 
    mnu->Append(id, _("&Set breakpoint"), _("Set a breakpoint on the selected object"));
 
180
        mnu->Append(id, _("&Set breakpoint"), _("Set a breakpoint on the selected object"));
180
181
}
181
182
 
182
183
wxWindow *breakpointFactory::StartDialog(frmMain *form, pgObject *obj)
183
184
{
184
 
    wxString dbgOid;
185
 
    if (obj->GetMetaType() == PGM_TRIGGER)
186
 
        dbgOid = NumToStr((long)((pgTrigger *)obj)->GetFunctionOid());
187
 
    else
188
 
        dbgOid = NumToStr((long)obj->GetOid());
189
 
 
190
 
    // Check here to make sure the function still exists before proceeding.
191
 
    // There is still a very small window in which it might be dropped, but
192
 
    // we should be able to handle most cases here without having to do this 
193
 
    // deep down in query threads.
194
 
    // We also make sure the function name doesn't contain a : as that will
195
 
    // sent the debugger API nuts.
196
 
    pgSet *res = obj->GetConnection()->ExecuteSet(wxT("SELECT count(*) AS count, proname FROM pg_proc WHERE oid = ") + dbgOid + wxT(" GROUP BY proname"));
197
 
    if (res->GetVal(wxT("proname")).Contains(wxT(":")))
198
 
    {
199
 
        wxLogError(_("Functions with a colon in the name cannot be debugged."));
200
 
        return 0;
201
 
    }
202
 
 
203
 
    if (res->GetLong(wxT("count")) != 1)
204
 
    {
205
 
        wxLogError(_("The selected function could not be found."));
206
 
        ctlTree *browser = form->GetBrowser();
207
 
        wxTreeItemId item=browser->GetSelection();
208
 
        if (obj == browser->GetObject(item))
209
 
        {
210
 
            pgCollection *coll=browser->GetParentCollection(obj->GetId());
211
 
            browser->DeleteChildren(coll->GetId());
212
 
            coll->ShowTreeDetail(browser);
213
 
        }
214
 
        return 0;
215
 
    }
216
 
 
217
 
    // Setup the debugger frame
218
 
    frmDebugger *debugger = new frmDebugger(form, wxString::Format(_("Debugger - %s"), obj->GetFullIdentifier().c_str()));
219
 
    debugger->Show(true);
220
 
    debugger->Raise();
221
 
 
222
 
    // Setup the connection properties to be used by the debugger
223
 
    dbgConnProp cp;
224
 
    cp.m_database = obj->GetDatabase()->GetIdentifier();
225
 
    cp.m_host = obj->GetServer()->GetName();
226
 
    cp.m_password = obj->GetDatabase()->GetServer()->GetPassword();
227
 
    cp.m_port = NumToStr((long)obj->GetServer()->GetPort());
228
 
    cp.m_sslMode = obj->GetServer()->GetSSL();
229
 
    cp.m_userName = obj->GetServer()->GetUsername();
230
 
 
231
 
    // Setup the debugging session
232
 
    ctlCodeWindow *globalDebugger = NULL;
233
 
    globalDebugger = debugger->addDebug(cp);
 
185
        wxString dbgOid;
 
186
        if (obj->GetMetaType() == PGM_TRIGGER)
 
187
                dbgOid = NumToStr((long)((pgTrigger *)obj)->GetFunctionOid());
 
188
        else
 
189
                dbgOid = NumToStr((long)obj->GetOid());
 
190
 
 
191
        // Check here to make sure the function still exists before proceeding.
 
192
        // There is still a very small window in which it might be dropped, but
 
193
        // we should be able to handle most cases here without having to do this
 
194
        // deep down in query threads.
 
195
        // We also make sure the function name doesn't contain a : as that will
 
196
        // sent the debugger API nuts.
 
197
        pgSet *res = obj->GetConnection()->ExecuteSet(wxT("SELECT count(*) AS count, proname FROM pg_proc WHERE oid = ") + dbgOid + wxT(" GROUP BY proname"));
 
198
        if (res->GetVal(wxT("proname")).Contains(wxT(":")))
 
199
        {
 
200
                wxLogError(_("Functions with a colon in the name cannot be debugged."));
 
201
                return 0;
 
202
        }
 
203
 
 
204
        if (res->GetLong(wxT("count")) != 1)
 
205
        {
 
206
                wxLogError(_("The selected function could not be found."));
 
207
                ctlTree *browser = form->GetBrowser();
 
208
                wxTreeItemId item = browser->GetSelection();
 
209
                if (obj == browser->GetObject(item))
 
210
                {
 
211
                        pgCollection *coll = browser->GetParentCollection(obj->GetId());
 
212
                        browser->DeleteChildren(coll->GetId());
 
213
                        coll->ShowTreeDetail(browser);
 
214
                }
 
215
                return 0;
 
216
        }
 
217
 
 
218
        // Setup the debugger frame
 
219
        frmDebugger *debugger = new frmDebugger(form, wxString::Format(_("Debugger - %s"), obj->GetFullIdentifier().c_str()));
 
220
        debugger->Show(true);
 
221
        debugger->Raise();
 
222
 
 
223
        // Setup the connection properties to be used by the debugger
 
224
        dbgConnProp cp;
 
225
        cp.m_database = obj->GetDatabase()->GetIdentifier();
 
226
        cp.m_host = obj->GetServer()->GetName();
 
227
        cp.m_password = obj->GetDatabase()->GetServer()->GetPassword();
 
228
        cp.m_port = NumToStr((long)obj->GetServer()->GetPort());
 
229
        cp.m_sslMode = obj->GetServer()->GetSSL();
 
230
        cp.m_userName = obj->GetServer()->GetUsername();
 
231
 
 
232
        // Setup the debugging session
 
233
        ctlCodeWindow *globalDebugger = NULL;
 
234
        globalDebugger = debugger->addDebug(cp);
234
235
        if (globalDebugger == NULL)
235
236
                return 0;
236
237
 
237
 
    dbgBreakPointList &breakpoints = globalDebugger->getBreakpointList();
238
 
    breakpoints.Append(new dbgBreakPoint(dbgBreakPoint::OID, dbgOid, wxT("'NULL'")));
239
 
 
240
 
    globalDebugger->startGlobalDebugging();
241
 
 
242
 
    // Return the debugger window to frmMain.
243
 
    return debugger;
 
238
        dbgBreakPointList &breakpoints = globalDebugger->getBreakpointList();
 
239
        breakpoints.Append(new dbgBreakPoint(dbgBreakPoint::OID, dbgOid, wxT("'NULL'")));
 
240
 
 
241
        globalDebugger->startGlobalDebugging();
 
242
 
 
243
        // Return the debugger window to frmMain.
 
244
        return debugger;
244
245
}
245
246
 
246
247
bool breakpointFactory::CheckEnable(pgObject *obj)
247
248
{
248
 
    if (!obj)
249
 
        return false;
250
 
 
251
 
    // Can't debug catalog objects.
252
 
    if (obj->GetSchema() && obj->GetSchema()->GetMetaType() == PGM_CATALOG)
253
 
        return false;
254
 
 
255
 
    // Must be a super user to create breakpoints of any kind.
256
 
    if (!obj->GetServer() || !obj->GetServer()->GetSuperUser())
257
 
        return false;
258
 
 
259
 
    if (!obj->IsCollection())
260
 
    {
261
 
        switch (obj->GetMetaType())
262
 
        {
263
 
            case PGM_FUNCTION:
264
 
                {
265
 
                    pgFunction *func = (pgFunction *)obj;
266
 
 
267
 
                    // If this is an EDB wrapped function, no debugging allowed
268
 
                    if (obj->GetConnection()->GetIsEdb() && func->GetSource().Trim(false).StartsWith(wxT("$__EDBwrapped__$")))
269
 
                        return false;
270
 
 
271
 
                    if (func->GetLanguage() == wxT("plpgsql") && obj->GetDatabase()->CanDebugPlpgsql())
272
 
                        return true;
 
249
        if (!obj)
 
250
                return false;
 
251
 
 
252
        // Can't debug catalog objects.
 
253
        if (obj->GetSchema() && obj->GetSchema()->GetMetaType() == PGM_CATALOG)
 
254
                return false;
 
255
 
 
256
        // Must be a super user to create breakpoints of any kind.
 
257
        if (!obj->GetServer() || !obj->GetServer()->GetSuperUser())
 
258
                return false;
 
259
 
 
260
        if (!obj->IsCollection())
 
261
        {
 
262
                switch (obj->GetMetaType())
 
263
                {
 
264
                        case PGM_FUNCTION:
 
265
                        {
 
266
                                pgFunction *func = (pgFunction *)obj;
 
267
 
 
268
                                // If this is an EDB wrapped function, no debugging allowed
 
269
                                if (obj->GetConnection()->GetIsEdb() && func->GetSource().Trim(false).StartsWith(wxT("$__EDBwrapped__$")))
 
270
                                        return false;
 
271
 
 
272
                                if (func->GetLanguage() == wxT("plpgsql") && obj->GetDatabase()->CanDebugPlpgsql())
 
273
                                        return true;
273
274
#ifndef EDB_LIBPQ
274
275
#ifdef __WXMSW__
275
 
                        else if (func->GetLanguage() == wxT("edbspl") &&
276
 
                                 obj->GetConnection()->EdbMinimumVersion(8, 4) &&
277
 
                                 !(PQiGetOutResult && PQiPrepareOut && PQiSendQueryPreparedOut))
278
 
                            return false;
 
276
                                else if (func->GetLanguage() == wxT("edbspl") &&
 
277
                                         obj->GetConnection()->EdbMinimumVersion(8, 4) &&
 
278
                                         !(PQiGetOutResult && PQiPrepareOut && PQiSendQueryPreparedOut))
 
279
                                        return false;
279
280
#else
280
 
                        else if (func->GetLanguage() == wxT("edbspl") && obj->GetConnection()->EdbMinimumVersion(8, 4))
281
 
                            return false;
282
 
#endif
283
 
#endif
284
 
                    else if (func->GetLanguage() == wxT("edbspl") && obj->GetDatabase()->CanDebugEdbspl())
285
 
                        return true;
286
 
                    else
287
 
                        return false;
288
 
                }
289
 
                break;
290
 
 
291
 
            case EDB_PACKAGEFUNCTION:
292
 
                if (obj->GetDatabase()->GetConnection()->EdbMinimumVersion(8, 2) && 
293
 
                    obj->GetDatabase()->CanDebugEdbspl() && 
294
 
                    obj->GetName() != wxT("cons") &&
295
 
                    ((edbPackageFunction *)obj)->GetSource() != wxEmptyString &&
296
 
                    (!((edbPackageFunction *)obj)->GetSource().Trim(false).StartsWith(wxT("$__EDBwrapped__$"))))
297
 
                    return true;
298
 
                break;
299
 
 
300
 
            case PGM_TRIGGER:
301
 
                {
302
 
                    pgTrigger *trig = (pgTrigger *)obj;
303
 
 
304
 
                    // If this is an EDB wrapped function, no debugging allowed
305
 
                    if (obj->GetConnection()->GetIsEdb() && trig->GetSource().Trim(false).StartsWith(wxT("$__EDBwrapped__$")))
306
 
                        return false;
307
 
 
308
 
                    if (trig->GetLanguage() == wxT("plpgsql") && obj->GetDatabase()->CanDebugPlpgsql())
309
 
                        return true;
310
 
                    else if (trig->GetLanguage() == wxT("edbspl") && obj->GetDatabase()->CanDebugEdbspl())
311
 
                        return true;
312
 
                    else
313
 
                        return false;
314
 
                }
315
 
                break;
316
 
 
317
 
            default:
318
 
                break;
319
 
        }
320
 
    }
321
 
    return false;
 
281
                                else if (func->GetLanguage() == wxT("edbspl") && obj->GetConnection()->EdbMinimumVersion(8, 4))
 
282
                                        return false;
 
283
#endif
 
284
#endif
 
285
                                else if (func->GetLanguage() == wxT("edbspl") && obj->GetDatabase()->CanDebugEdbspl())
 
286
                                        return true;
 
287
                                else
 
288
                                        return false;
 
289
                        }
 
290
                        break;
 
291
 
 
292
                        case EDB_PACKAGEFUNCTION:
 
293
                                if (obj->GetDatabase()->GetConnection()->EdbMinimumVersion(8, 2) &&
 
294
                                        obj->GetDatabase()->CanDebugEdbspl() &&
 
295
                                        obj->GetName() != wxT("cons") &&
 
296
                                        ((edbPackageFunction *)obj)->GetSource() != wxEmptyString &&
 
297
                                        (!((edbPackageFunction *)obj)->GetSource().Trim(false).StartsWith(wxT("$__EDBwrapped__$"))))
 
298
                                        return true;
 
299
                                break;
 
300
 
 
301
                        case PGM_TRIGGER:
 
302
                        {
 
303
                                pgTrigger *trig = (pgTrigger *)obj;
 
304
 
 
305
                                // If this is an EDB wrapped function, no debugging allowed
 
306
                                if (obj->GetConnection()->GetIsEdb() && trig->GetSource().Trim(false).StartsWith(wxT("$__EDBwrapped__$")))
 
307
                                        return false;
 
308
 
 
309
                                if (trig->GetLanguage() == wxT("plpgsql") && obj->GetDatabase()->CanDebugPlpgsql())
 
310
                                        return true;
 
311
                                else if (trig->GetLanguage() == wxT("edbspl") && obj->GetDatabase()->CanDebugEdbspl())
 
312
                                        return true;
 
313
                                else
 
314
                                        return false;
 
315
                        }
 
316
                        break;
 
317
 
 
318
                        default:
 
319
                                break;
 
320
                }
 
321
        }
 
322
        return false;
322
323
}
323
324
 
324
325