Re: [pgadmin-hackers] [PATCH] Fix crash when disabling auto commit

2015-06-15 Thread John Obaterspok
I'm using Visual Studio 2010 on Windows 7 x64. wxWidgets is wxMSW-3.0.2.
It might be an assert that triggers in wxwidgets, but ignoring it just
causes pgadmin to terminate.

-- john

2015-06-14 18:44 GMT+02:00 Ashesh Vashi :

> John,
>
> As I understand correctly, 8th character will be '\0' (null character).
> Hence - wxIsAlpha() will come out of the loop in general.
>
> But - it is possible every platform has different behaviour for wxWidgets.
> Can you please be specific about the operating system?
>
> --
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB (Software Architect)
>
> [Sent through mobile]
> On Jun 14, 2015 2:41 PM, "Sanket Mehta" 
> wrote:
>
>> Hi John,
>>
>> I have tried the same, I am not getting any out of the bounds error, it
>> simply comes out of the while loop.
>>
>> Regards,
>> Sanket Mehta
>> Sr Software engineer
>> Enterprisedb
>>
>> On Sun, Jun 14, 2015 at 2:00 PM, John Obaterspok <
>> john.obaters...@gmail.com> wrote:
>>
>>> Hello Sanket,
>>>
>>> Just enter "rollback" and exec
>>>
>>> The
>>>  while(wxIsalpha(query.GetChar(wordlen)))
>>>   wordlen++;
>>>
>>> As the 'k' in rollback is a char it also tries the next character
>>> (worklen = 8) which causes out of bounds check.
>>>
>>> -- john
>>>
>>>
>>> 2015-06-12 13:25 GMT+02:00 Sanket Mehta :
>>>
 Hi John,

 I have tried to reproduce the scenario but not able to reproduce the
 crash in my system.
 can you please provide your steps which causes crash on your machine?

 Regards,
 Sanket Mehta
 Sr Software engineer
 Enterprisedb

 On Fri, Jun 12, 2015 at 11:50 AM, Sanket Mehta <
 sanket.me...@enterprisedb.com> wrote:

> Hi,
>
> I am looking into the same and few other issues in code and will send
> the patch soon.
>
>
> Regards,
> Sanket Mehta
> Sr Software engineer
> Enterprisedb
>
> On Fri, Jun 12, 2015 at 1:49 AM, John Obaterspok <
> john.obaters...@gmail.com> wrote:
>
>> Fix crash when string has only alphas (like 'rollback')
>>
>> diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp
>> index b5a2f56..110bbc7 100644
>> --- a/pgadmin/frm/frmQuery.cpp
>> +++ b/pgadmin/frm/frmQuery.cpp
>> @@ -2522,7 +2522,7 @@ bool frmQuery::isBeginNotRequired(wxString
>> query)
>>   /*
>>   * Check word length (since "beginx" is not "begin").
>>   */
>> - while(wxIsalpha(query.GetChar(wordlen)))
>> + while(wordlen < query.Length() &&
>> wxIsalpha(query.GetChar(wordlen)))
>>   wordlen++;
>>
>>   /*
>>
>
>

>>>
>>


Re: [pgadmin-hackers] [PATCH] Add ElapsedTimeToString to format execution time in a more readable manner (instead of showing everything as msec)

2015-06-15 Thread John Obaterspok
Hi,

Attached is an updated patch.

-- john

2015-06-12 6:50 GMT+02:00 Ashesh Vashi :

> Hi John,
>
> Can you please add comments for the below piece of code for explanation?
> -
> *@@ -3088,13 +3090,22 @@ void frmQuery::OnTimer(wxTimerEvent &event)*
> *  }*
>
> *  // Increase the granularity for longer running queries*
> *- if (elapsedQuery > 200 && timer.GetInterval() == 10 &&
> timer.IsRunning())*
> *+ if (timer.IsRunning())*
> *  {*
> *- timer.Stop();*
> *- timer.Start(100);*
> *+ if (elapsedQuery > 200 && timer.GetInterval() < 100)*
> *+ {*
> *+ timer.Stop();*
> *+ timer.Start(100);*
> *+ }*
> *+ else if (elapsedQuery > 60 * 1000 && timer.GetInterval() < 1000)*
> *+ {*
> *+ timer.Stop();*
> *+ timer.Start(1000);*
> *+ }*
>
> -
>
> And, please send patch as an attachment.
>
> --
>
> Thanks & Regards,
>
> Ashesh Vashi
> EnterpriseDB INDIA: Enterprise PostgreSQL Company
> 
>
>
> *http://www.linkedin.com/in/asheshvashi*
> 
>
> On Fri, Jun 12, 2015 at 1:50 AM, John Obaterspok <
> john.obaters...@gmail.com> wrote:
>
>> Add ElapsedTimeToString to format execution time in a more readable
>> manner (instead of showing everything as msec)
>>
>> Signed-off-by: John Obaterspok 
>>
>> diff --git a/pgadmin/dlg/dlgClasses.cpp b/pgadmin/dlg/dlgClasses.cpp
>> index 9a3e473..e6fa488 100644
>> --- a/pgadmin/dlg/dlgClasses.cpp
>> +++ b/pgadmin/dlg/dlgClasses.cpp
>> @@ -562,7 +562,7 @@ void ExecutionDialog::OnOK(wxCommandEvent &ev)
>>   {
>>   if (txtMessages)
>>   txtMessages->AppendText(_("Total query runtime: ")
>> -+ (wxGetLocalTimeMillis() -
>> startTime).ToString() + wxT(" ms."));
>> ++ ElapsedTimeToString(wxGetLocalTimeMillis() -
>> startTime));
>>
>>   btnOK->SetLabel(_("Done"));
>>   btnCancel->Disable();
>> diff --git a/pgadmin/frm/frmMain.cpp b/pgadmin/frm/frmMain.cpp
>> index 8629dda..94528e8 100644
>> --- a/pgadmin/frm/frmMain.cpp
>> +++ b/pgadmin/frm/frmMain.cpp
>> @@ -1352,9 +1352,7 @@ void frmMain::EndMsg(bool done)
>>   {
>>   // Get the execution time & display it
>>   float timeval = stopwatch.Time();
>> - wxString time;
>> - time.Printf(_("%.2f secs"), (timeval / 1000));
>> - statusBar->SetStatusText(time, 2);
>> + statusBar->SetStatusText(ElapsedTimeToString(timeval), 2);
>>
>>   // Display the 'Done' message
>>   if (done)
>> @@ -1362,7 +1360,7 @@ void frmMain::EndMsg(bool done)
>>   else
>>   statusBar->SetStatusText(timermsg + _(" Failed."), 1);
>>
>> - wxLogStatus(wxT("%s (%s)"), timermsg.c_str(), time.c_str());
>> + wxLogStatus(wxT("%s (%s)"), timermsg.c_str(),
>> ElapsedTimeToString(timeval).c_str());
>>   wxEndBusyCursor();
>>   }
>>  }
>> diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp
>> index 110bbc7..6198c83 100644
>> --- a/pgadmin/frm/frmQuery.cpp
>> +++ b/pgadmin/frm/frmQuery.cpp
>> @@ -55,6 +55,7 @@
>>  #include "utils/sysLogger.h"
>>  #include "utils/sysSettings.h"
>>  #include "utils/utffile.h"
>> +#include "utils/misc.h"
>>  #include "pgscript/pgsApplication.h"
>>
>>  // Icons
>> @@ -2711,7 +2712,7 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent
>> &ev)
>>   msgHistory->AppendText(str);
>>
>>   elapsedQuery = wxGetLocalTimeMillis() - startTimeQuery;
>> - SetStatusText(elapsedQuery.ToString() + wxT(" ms"), STATUSPOS_SECS);
>> + SetStatusText(ElapsedTimeToString(elapsedQuery), STATUSPOS_SECS);
>>
>>   if (sqlResult->RunStatus() != PGRES_TUPLES_OK)
>>   {
>> @@ -2724,28 +2725,28 @@ void frmQuery::OnQueryComplete(pgQueryResultEvent
>> &ev)
>>   OID insertedOid = sqlResult->InsertedOid();
>>   if (insertedCount < 0)
>>   {
>> - showMessage(wxString::Format(_("Query returned successfully with no
>> result in %s ms."),
>> - elapsedQuery.ToString().c_str()),
>> _("OK."));
>> + showMessage(wxString::Format(_("Query returned successfully with no
>> result in %s."),
>> +
>> ElapsedTimeToString(elapsedQuery).c_str()), _("OK."));
>>   }
>>   else if (insertedCount == 1)
>>   {
>>   if (insertedOid)
>>   {
>> - showMessage(wxString::Format(_("Query returned successfully: one row
>> with OID %ld inserted, %s ms execution time."),
>> - (long)insertedOid,
>> elapsedQuery.ToString().c_str()),
>> + showMessage(wxString::Format(_("Query returned successfully: one row
>> with OID %ld inserted, %s execution time."),
>> + (long)insertedOid,
>> ElapsedTimeToString(elapsedQuery).c_str()),
>>  wxString::Format(_("One row with OID %ld inserted."),
>> (long)insertedOid));
>>   }
>>   else
>>   {
>> - showMessage(wxString::Format(_("Query returned successfully: one row
>> affected, %s ms execution time."),
>> - elapsedQuery.ToString().c_str()),
>> + showMessage(wxString::Format(_("Query returned successfully: one row
>> affected, %s execution time."),
>> + ElapsedTimeToString(elapsedQuery).c_str()),
>>  

[pgadmin-hackers] [PATCH] Add Commit/Rollback toolbar action

2015-06-15 Thread John Obaterspok
Hello,

With the newly added option to disable auto commit (hurray) I really missed
commit/rollback toolbar buttons. Attached patch adds this.

-- john


0001-Add-Commit-Rollback-toolbar-action.patch
Description: Binary data

-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Re: [pgadmin-hackers] [PATCH] Fix crash when disabling auto commit

2015-06-15 Thread Sanket Mehta
Hi,

We were using wxWidgets 2.8.12 so that may be the issue.
I will now try with wxwidgets 3.0.2 and let you know.

Btw apart from this issue, we have also resolved other issues in the code,
i will soon send a new patch for the same.

Regards,
Sanket Mehta
Sr Software engineer
Enterprisedb

On Mon, Jun 15, 2015 at 11:33 PM, John Obaterspok  wrote:

> I'm using Visual Studio 2010 on Windows 7 x64. wxWidgets is wxMSW-3.0.2.
> It might be an assert that triggers in wxwidgets, but ignoring it just
> causes pgadmin to terminate.
>
> -- john
>
> 2015-06-14 18:44 GMT+02:00 Ashesh Vashi :
>
>> John,
>>
>> As I understand correctly, 8th character will be '\0' (null character).
>> Hence - wxIsAlpha() will come out of the loop in general.
>>
>> But - it is possible every platform has different behaviour for
>> wxWidgets. Can you please be specific about the operating system?
>>
>> --
>> Thanks & Regards,
>>
>> Ashesh Vashi
>> EnterpriseDB (Software Architect)
>>
>> [Sent through mobile]
>> On Jun 14, 2015 2:41 PM, "Sanket Mehta" 
>> wrote:
>>
>>> Hi John,
>>>
>>> I have tried the same, I am not getting any out of the bounds error, it
>>> simply comes out of the while loop.
>>>
>>> Regards,
>>> Sanket Mehta
>>> Sr Software engineer
>>> Enterprisedb
>>>
>>> On Sun, Jun 14, 2015 at 2:00 PM, John Obaterspok <
>>> john.obaters...@gmail.com> wrote:
>>>
 Hello Sanket,

 Just enter "rollback" and exec

 The
  while(wxIsalpha(query.GetChar(wordlen)))
   wordlen++;

 As the 'k' in rollback is a char it also tries the next character
 (worklen = 8) which causes out of bounds check.

 -- john


 2015-06-12 13:25 GMT+02:00 Sanket Mehta 
 :

> Hi John,
>
> I have tried to reproduce the scenario but not able to reproduce the
> crash in my system.
> can you please provide your steps which causes crash on your machine?
>
> Regards,
> Sanket Mehta
> Sr Software engineer
> Enterprisedb
>
> On Fri, Jun 12, 2015 at 11:50 AM, Sanket Mehta <
> sanket.me...@enterprisedb.com> wrote:
>
>> Hi,
>>
>> I am looking into the same and few other issues in code and will send
>> the patch soon.
>>
>>
>> Regards,
>> Sanket Mehta
>> Sr Software engineer
>> Enterprisedb
>>
>> On Fri, Jun 12, 2015 at 1:49 AM, John Obaterspok <
>> john.obaters...@gmail.com> wrote:
>>
>>> Fix crash when string has only alphas (like 'rollback')
>>>
>>> diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp
>>> index b5a2f56..110bbc7 100644
>>> --- a/pgadmin/frm/frmQuery.cpp
>>> +++ b/pgadmin/frm/frmQuery.cpp
>>> @@ -2522,7 +2522,7 @@ bool frmQuery::isBeginNotRequired(wxString
>>> query)
>>>   /*
>>>   * Check word length (since "beginx" is not "begin").
>>>   */
>>> - while(wxIsalpha(query.GetChar(wordlen)))
>>> + while(wordlen < query.Length() &&
>>> wxIsalpha(query.GetChar(wordlen)))
>>>   wordlen++;
>>>
>>>   /*
>>>
>>
>>
>

>>>
>