pgScript update - ensure that we get a useful error message if the user attempts...
authordpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Thu, 12 Mar 2009 17:27:31 +0000 (17:27 +0000)
committerdpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Thu, 12 Mar 2009 17:27:31 +0000 (17:27 +0000)
git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@7692 a7884b65-44f6-0310-8a51-81a127f17b15

pgadmin/frm/frmQuery.cpp
pgadmin/include/pgscript/parser.tab.hh
pgadmin/pgscript/lex.pgs.cc
pgadmin/pgscript/parser.tab.cc
pgadmin/pgscript/pgsApplication.cpp
pgadmin/pgscript/pgsScanner.ll

index 78d7de3684d0696420b0628f68b36a5f92329ece..33c0dd33a0d10b85b47430c29466a3e560937349 100644 (file)
@@ -2198,7 +2198,6 @@ void frmQuery::OnScriptComplete(wxCommandEvent &ev)
         int selStart = sqlQuery->GetSelectionStart(), selEnd = sqlQuery->GetSelectionEnd();
         if (selStart == selEnd)
             selStart = 0;
-        SetStatusText(wxString() << selStart, STATUSPOS_MSGS);
         int line = 0, maxLine = sqlQuery->GetLineCount();
         while (line < maxLine && sqlQuery->GetLineEndPosition(line) < selStart)
             line++;
index 6f57136b46ad9b0cea8029b0cf8a0ce7c11b787d..db4b48b1a2e466900a9e18945bdadfcc4a6fcb51 100644 (file)
@@ -54,7 +54,7 @@ namespace pgscript
 //////////////////////////////////////////////////////////////////////////
 //
 // pgScript - PostgreSQL Tools
-// RCS-ID:      $Id: parser.tab.hh,v 1.8 2008/08/10 22:11:29 pgunittest Exp $
+// RCS-ID:      $Id: pgsParser.yy,v 1.6 2008/08/10 22:11:29 pgunittest Exp $
 // Copyright (C) 2002 - 2009, The pgAdmin Development Team
 // This software is released under the Artistic Licence
 //
@@ -68,7 +68,7 @@ namespace pgscript
 
 
 
-/* Line 303 of lalr1.cc.  */
+/* Line 35 of lalr1.cc.  */
 #line 73 "pgscript/parser.tab.hh"
 
 #include "location.hh"
@@ -128,7 +128,7 @@ namespace pgscript
        pgsStmt * stmt;
        pgsStmtList * stmt_list;
 }
-/* Line 303 of lalr1.cc.  */
+/* Line 35 of lalr1.cc.  */
 #line 133 "pgscript/parser.tab.hh"
        ;
 #else
index bf548577e865ad174fb062f67b20df912382df4c..d0479d441b68f562e1c74c0feb5d54b92102bb95 100644 (file)
@@ -687,7 +687,7 @@ static yyconst flex_int16_t yy_chk[563] =
 //////////////////////////////////////////////////////////////////////////
 //
 // pgScript - PostgreSQL Tools
-// RCS-ID:      $Id: lex.pgs.cc,v 1.8 2008/08/10 22:11:29 pgunittest Exp $
+// RCS-ID:      $Id: pgsScanner.ll,v 1.5 2008/08/10 22:11:29 pgunittest Exp $
 // Copyright (C) 2002 - 2009, The pgAdmin Development Team
 // This software is released under the Artistic Licence
 //
@@ -1603,63 +1603,73 @@ YY_RULE_SETUP
 #line 288 "pgscript/pgsScanner.ll"
 { query += yytext; yylloc->lines(yyleng); yylloc->step(); }
        YY_BREAK
+case YY_STATE_EOF(SC_QUERY):
+#line 289 "pgscript/pgsScanner.ll"
+{ yylval->str = pnew wxString(query.c_str(), m_conv);
+                                         query.clear(); m_parent = 0; return query_token; }
+       YY_BREAK
 case 122:
 YY_RULE_SETUP
-#line 289 "pgscript/pgsScanner.ll"
+#line 291 "pgscript/pgsScanner.ll"
 { yylloc->columns(columns(*yytext)); query += yytext; }
        YY_BREAK
 
 
 case 123:
 YY_RULE_SETUP
-#line 293 "pgscript/pgsScanner.ll"
+#line 295 "pgscript/pgsScanner.ll"
 { query += yytext;
                                          if (std::string(yytext) == dollar) BEGIN(SC_QUERY); }
        YY_BREAK
 case 124:
 YY_RULE_SETUP
-#line 295 "pgscript/pgsScanner.ll"
+#line 297 "pgscript/pgsScanner.ll"
 { query += yytext; yylloc->step(); }
        YY_BREAK
 case 125:
 /* rule 125 can match eol */
 YY_RULE_SETUP
-#line 296 "pgscript/pgsScanner.ll"
+#line 298 "pgscript/pgsScanner.ll"
 { query += yytext; yylloc->lines(yyleng); yylloc->step(); }
        YY_BREAK
+case YY_STATE_EOF(SC_DOLLAR):
+#line 299 "pgscript/pgsScanner.ll"
+{ query += yytext; yylval->str = pnew wxString(query.c_str(), m_conv);
+                                         query.clear(); m_parent = 0; return query_token; }
+       YY_BREAK
 case 126:
 YY_RULE_SETUP
-#line 297 "pgscript/pgsScanner.ll"
+#line 301 "pgscript/pgsScanner.ll"
 { yylloc->columns(columns(*yytext)); query += yytext; }
        YY_BREAK
 
 
 case 127:
 YY_RULE_SETUP
-#line 301 "pgscript/pgsScanner.ll"
+#line 305 "pgscript/pgsScanner.ll"
 { BEGIN(comment_caller); }
        YY_BREAK
 case 128:
 YY_RULE_SETUP
-#line 302 "pgscript/pgsScanner.ll"
+#line 306 "pgscript/pgsScanner.ll"
 { yylloc->step(); }
        YY_BREAK
 case 129:
 /* rule 129 can match eol */
 YY_RULE_SETUP
-#line 303 "pgscript/pgsScanner.ll"
+#line 307 "pgscript/pgsScanner.ll"
 { yylloc->lines(yyleng); yylloc->step(); }
        YY_BREAK
 case 130:
 YY_RULE_SETUP
-#line 304 "pgscript/pgsScanner.ll"
+#line 308 "pgscript/pgsScanner.ll"
 { yylloc->columns(columns(*yytext)); }
        YY_BREAK
 
 
 case 131:
 YY_RULE_SETUP
-#line 308 "pgscript/pgsScanner.ll"
+#line 312 "pgscript/pgsScanner.ll"
 {
                                                if (string_caller == SC_QUERY)
                                                        query += yytext;
@@ -1669,7 +1679,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 132:
 YY_RULE_SETUP
-#line 314 "pgscript/pgsScanner.ll"
+#line 318 "pgscript/pgsScanner.ll"
 {
                                                if (string_caller == SC_QUERY)
                                                        query += yytext;
@@ -1680,7 +1690,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 133:
 YY_RULE_SETUP
-#line 321 "pgscript/pgsScanner.ll"
+#line 325 "pgscript/pgsScanner.ll"
 {
                                                if (string_caller == SC_QUERY)
                                                {
@@ -1698,7 +1708,7 @@ YY_RULE_SETUP
        YY_BREAK
 case 134:
 YY_RULE_SETUP
-#line 335 "pgscript/pgsScanner.ll"
+#line 339 "pgscript/pgsScanner.ll"
 {
                                                if (string_caller == SC_QUERY)
                                                        query += yytext;
@@ -1710,7 +1720,7 @@ YY_RULE_SETUP
 case 135:
 /* rule 135 can match eol */
 YY_RULE_SETUP
-#line 342 "pgscript/pgsScanner.ll"
+#line 346 "pgscript/pgsScanner.ll"
 {
                                                if (string_caller == SC_QUERY)
                                                        query += yytext;
@@ -1719,9 +1729,26 @@ YY_RULE_SETUP
                                                yylloc->lines(yyleng); yylloc->step();
                                        }
        YY_BREAK
+case YY_STATE_EOF(SC_STRING):
+#line 353 "pgscript/pgsScanner.ll"
+{
+                                               if (string_caller == SC_QUERY)
+                                               {
+                                                       query += yytext; yylval->str = pnew wxString(query.c_str(), m_conv);
+                                                       query.clear(); m_parent = 0; return query_token;
+                                               }
+                                               else
+                                               {
+                                                       yylval->str = pnew wxString(str.c_str(), m_conv);
+                                                       str.clear();
+                                                       BEGIN(string_caller);
+                                                       return token::PGS_VAL_STR;
+                                               }
+                                       }
+       YY_BREAK
 case 136:
 YY_RULE_SETUP
-#line 349 "pgscript/pgsScanner.ll"
+#line 367 "pgscript/pgsScanner.ll"
 { 
                                                if (string_caller == SC_QUERY)
                                                        query += yytext;
@@ -1733,15 +1760,12 @@ YY_RULE_SETUP
 
 case 137:
 YY_RULE_SETUP
-#line 358 "pgscript/pgsScanner.ll"
+#line 376 "pgscript/pgsScanner.ll"
 ECHO;
        YY_BREAK
-#line 1737 "pgscript/lex.pgs.cc"
+#line 1764 "pgscript/lex.pgs.cc"
 case YY_STATE_EOF(INITIAL):
 case YY_STATE_EOF(SC_COMMENT):
-case YY_STATE_EOF(SC_QUERY):
-case YY_STATE_EOF(SC_DOLLAR):
-case YY_STATE_EOF(SC_STRING):
        yyterminate();
 
        case YY_END_OF_BUFFER:
@@ -2621,7 +2645,7 @@ void pgsfree (void * ptr )
 
 #define YYTABLES_NAME "yytables"
 
-#line 358 "pgscript/pgsScanner.ll"
+#line 376 "pgscript/pgsScanner.ll"
 
 
 
index c52ecfffddd3b665b618d1689c8457b4f4065ff0..47aa63ffe27303860b58dc4e6eebfaf8b817435f 100644 (file)
@@ -534,7 +534,7 @@ namespace pgscript
        // Initialize the initial location object
        yylloc.begin.filename = yylloc.end.filename;
 }
-  /* Line 555 of yacc.c.  */
+  /* Line 547 of yacc.c.  */
 #line 534 "pgscript/parser.tab.cc"
     /* Initialize the stacks.  The initial state will be pushed in
        yynewstate, since the latter expects the semantical and the
index f6e5600ddace04486bdd017efdbd524a2644f30c..f76fc1ed01da24c717cd5cc1d65f352afb780437 100644 (file)
@@ -142,6 +142,10 @@ void pgsApplication::Terminate()
 
 void pgsApplication::Complete()
 {
+       // If last_error_line() == -1 then there was no error
+       // Else get the line number where the error occurred
+       m_last_error_line = m_thread->last_error_line();
+       
 #if !defined(PGSCLI)
        if (m_caller != 0)
        {
@@ -149,10 +153,6 @@ void pgsApplication::Complete()
                m_caller->AddPendingEvent(resultEvent);
     }
 #endif // PGSCLI
-
-       // If last_error_line() == -1 then there was no error
-       // Else get the line number where the error occurred
-       m_last_error_line = m_thread->last_error_line();
        
        wxLogScript(wxT("Execution completed"));
 }
index ad5873ebf175a3f51f8ad2c48362470ac177e5c9..7e5385be0370cfebf060f92ce92746af6aaf3ced 100644 (file)
@@ -286,6 +286,8 @@ typedef pgscript::pgsParser::token_type token_type;
                                        }
 \r                                     { query += yytext; yylloc->step(); }
 \n                                     { query += yytext; yylloc->lines(yyleng); yylloc->step(); }
+<<EOF>>                                { yylval->str = pnew wxString(query.c_str(), m_conv);
+                                         query.clear(); m_parent = 0; return query_token; }
 .                                      { yylloc->columns(columns(*yytext)); query += yytext; }
 }
 
@@ -294,6 +296,8 @@ typedef pgscript::pgsParser::token_type token_type;
                                          if (std::string(yytext) == dollar) BEGIN(SC_QUERY); }
 \r                                     { query += yytext; yylloc->step(); }
 \n                                     { query += yytext; yylloc->lines(yyleng); yylloc->step(); }
+<<EOF>>                                { query += yytext; yylval->str = pnew wxString(query.c_str(), m_conv);
+                                         query.clear(); m_parent = 0; return query_token; }
 .                                      { yylloc->columns(columns(*yytext)); query += yytext; }
 }
 
@@ -346,6 +350,20 @@ typedef pgscript::pgsParser::token_type token_type;
                                                        str += yytext;
                                                yylloc->lines(yyleng); yylloc->step();
                                        }
+<<EOF>>                                {
+                                               if (string_caller == SC_QUERY)
+                                               {
+                                                       query += yytext; yylval->str = pnew wxString(query.c_str(), m_conv);
+                                                       query.clear(); m_parent = 0; return query_token;
+                                               }
+                                               else
+                                               {
+                                                       yylval->str = pnew wxString(str.c_str(), m_conv);
+                                                       str.clear();
+                                                       BEGIN(string_caller);
+                                                       return token::PGS_VAL_STR;
+                                               }
+                                       }
 .                                      { 
                                                if (string_caller == SC_QUERY)
                                                        query += yytext;