1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
//////////////////////////////////////////////////////////////////////////
//
// pgScript - PostgreSQL Tools
//
// Copyright (C) 2002 - 2012, The pgAdmin Development Team
// This software is released under the PostgreSQL Licence
//
//////////////////////////////////////////////////////////////////////////
#include "pgAdmin3.h"
#include "pgscript/statements/pgsStmtList.h"
#include <typeinfo>
#include "pgscript/exceptions/pgsBreakException.h"
#include "pgscript/exceptions/pgsContinueException.h"
#include "pgscript/exceptions/pgsInterruptException.h"
#include "pgscript/utilities/pgsThread.h"
#include "pgscript/utilities/pgsUtilities.h"
#include <wx/listimpl.cpp>
WX_DEFINE_LIST(pgsListStmt);
bool pgsStmtList::m_exception_thrown = false;
pgsStmtList::pgsStmtList(pgsOutputStream &cout, pgsThread *app) :
pgsStmt(app), m_cout(cout)
{
}
pgsStmtList::~pgsStmtList()
{
pgsListStmt::iterator it;
for (it = m_stmt_list.begin(); it != m_stmt_list.end(); it++)
{
pdelete(*it);
}
}
void pgsStmtList::eval(pgsVarMap &vars) const
{
pgsListStmt::const_iterator it;
for (it = m_stmt_list.begin(); it != m_stmt_list.end(); it++)
{
pgsStmt *current = *it;
try
{
current->eval(vars);
if (m_app != 0 && m_app->TestDestroy())
throw pgsInterruptException();
}
catch (const pgsException &e)
{
if (!m_exception_thrown && (typeid(e) != typeid(pgsBreakException))
&& (typeid(e) != typeid(pgsContinueException)))
{
if (m_app != 0)
{
m_app->LockOutput();
m_app->last_error_line(current->line());
}
m_cout << wx_static_cast(const wxString, e.message())
<< wxT(" on line ") << current->line() << wxT("\n");
m_exception_thrown = true;
if (m_app != 0)
{
m_app->UnlockOutput();
}
}
throw;
}
catch (const std::exception &e)
{
if (!m_exception_thrown)
{
if (m_app != 0)
{
m_app->LockOutput();
m_app->last_error_line(current->line());
}
m_cout << PGSOUTERROR << _("Unknown exception:\n")
<< wx_static_cast(const wxString,
wxString(e.what(), wxConvUTF8));
m_exception_thrown = true;
if (m_app != 0)
{
m_app->UnlockOutput();
}
}
throw;
}
if (m_app != 0)
{
m_app->Yield();
}
}
}
void pgsStmtList::insert_front(pgsStmt *stmt)
{
m_stmt_list.push_front(stmt);
}
void pgsStmtList::insert_back(pgsStmt *stmt)
{
m_stmt_list.push_back(stmt);
}
|