Thread: Autosave in the SQL Editor

Autosave in the SQL Editor

From
Vinicius Santos
Date:
Hello,
 
I started to implement the feature "autosave" present in many text editors.
 
I would like to listen your opnions about this feature.
 
I put a option "Minutes to save the document automatically" in the frmOptions.
 
What do you think?

Re: Autosave in the SQL Editor

From
Adam Scott
Date:
MySQL Workbench has a similar feature.

This does pose an exposure to save sensitive information without the user knowing. How to solve this?  A complicated development path:  encrypt saved document.   Of course any of the files the user saves should be privileged to that user (not group).  So another method may be just to make sure the file's privileges are for the user only. 

Adam


On Mon, Aug 6, 2012 at 5:22 PM, Vinicius Santos <vinicius.santos.lista@gmail.com> wrote:
Hello,
 
I started to implement the feature "autosave" present in many text editors.
 
I would like to listen your opnions about this feature.
 
I put a option "Minutes to save the document automatically" in the frmOptions.
 
What do you think?

Re: Autosave in the SQL Editor

From
Guillaume Lelarge
Date:
On Mon, 2012-08-06 at 20:22 -0300, Vinicius Santos wrote:
> Hello,
>
> I started to implement the feature "autosave" present in many text editors.
>
> I would like to listen your opnions about this feature.
>
> I put a option "Minutes to save the document automatically" in the
> frmOptions.
>
> What do you think?

Seems good to me. We are talking about the query tool, right? Be careful
that users may have many query tool windows open at the same time.


--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com


Re: Autosave in the SQL Editor

From
Guillaume Lelarge
Date:
On Mon, 2012-08-06 at 20:30 -0600, Adam Scott wrote:
> MySQL Workbench has a similar feature.
>
> This does pose an exposure to save sensitive information without the user
> knowing. How to solve this?  A complicated development path:  encrypt saved
> document.

We won't go that road for sure. Too complicated, too easy to make it
worse.

>    Of course any of the files the user saves should be privileged
> to that user (not group).  So another method may be just to make sure the
> file's privileges are for the user only.

This is the minimum we can do.


--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com


Re: Autosave in the SQL Editor

From
Vinicius Santos
Date:
Seems good to me. We are talking about the query tool, right?

Right.
 
Be careful
that users may have many query tool windows open at the same time.

Actually I thought of something simple.

One file per window, when the window is closed, the pgAdmin will delete it.

We avoid the loss of query, when the pgadmin crashes or because of a power outage.

So, when the user open the window, the pgAdmin will ask to the user if he wants reopen the file found by pgAdmin.

If the user answer is NO, the pgAdmin will delete the file.

Fwd: Autosave in the SQL Editor

From
Vinicius Santos
Date:

> MySQL Workbench has a similar feature.
>
> This does pose an exposure to save sensitive information without the user
> knowing. How to solve this?  A complicated development path:  encrypt saved
> document.

We won't go that road for sure. Too complicated, too easy to make it
worse.

I thought of something simpler.
In plain text.
 

>    Of course any of the files the user saves should be privileged
> to that user (not group).  So another method may be just to make sure the
> file's privileges are for the user only.

This is the minimum we can do.

If the file is plain text, anyone can look through the file system.

What we can do is save the user that has lost the query.

So, just to recover the lost files of the current user.

Re: Autosave in the SQL Editor

From
Guillaume Lelarge
Date:
On Tue, 2012-08-07 at 08:44 -0300, Vinicius Santos wrote:
> > Seems good to me. We are talking about the query tool, right?
>
>
> Right.
>
>
> > Be careful
> > that users may have many query tool windows open at the same time.
> >
>
> Actually I thought of something simple.
>
> One file per window, when the window is closed, the pgAdmin will delete it.
>
> We avoid the loss of query, when the pgadmin crashes or because of a power
> outage.
>
> So, when the user open the window, the pgAdmin will ask to the user if he
> wants reopen the file found by pgAdmin.
>
> If the user answer is NO, the pgAdmin will delete the file.

Well, this seems good but there's an issue I don't know how you want to
deal with it: what's happens if I had more than one window opened? IOW,
how do you decide which file you should open? if there is more than one
file, and some files were open on different databases, how will you
handle this?


--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com


Re: Autosave in the SQL Editor

From
Vinicius Santos
Date:

Well, this seems good but there's an issue I don't know how you want to
deal with it: what's happens if I had more than one window opened?

I'm saving a file for each window.
Each window have a private variable called "fileNameAutoSave"

The query is salved from time-to-time. As configuration.
 
IOW,
how do you decide which file you should open? if there is more than one
file, and some files were open on different databases, how will you
handle this?

I had thought about putting the information in the file name. For example: "server_port_database_date_time.pga".
The date and time are saved in the creation of frmQuery.

We can save it in the file header too. We put this information in the first line. And we put another name for the file.

When there are more than one file, we asked for user, if he wants to open all of them.
Of course we will open only the files that database.

What do you think?

PS: Forgive my English. I'm learning english, and I'm using a little the Google Translate.

Re: Autosave in the SQL Editor

From
Guillaume Lelarge
Date:
On Tue, 2012-08-07 at 18:20 -0300, Vinicius Santos wrote:
>
>
>         Well, this seems good but there's an issue I don't know how
>         you want to
>         deal with it: what's happens if I had more than one window
>         opened?
>
> I'm saving a file for each window.
> Each window have a private variable called "fileNameAutoSave"
>
> The query is salved from time-to-time. As configuration.

OK.

>
>         IOW,
>         how do you decide which file you should open? if there is more
>         than one
>         file, and some files were open on different databases, how
>         will you
>         handle this?
>
> I had thought about putting the information in the file name. For
> example: "server_port_database_date_time.pga".

Where is it saved?

You also need to have a way to delete those files.

> The date and time are saved in the creation of frmQuery.
>
> We can save it in the file header too. We put this information in the
> first line. And we put another name for the file.
>

Yeah, I think the informations should be available in the file (for
example if your database has a _ in its name, it will be hard to decode
the informations from the filename.

> When there are more than one file, we asked for user, if he wants to
> open all of them.
> Of course we will open only the files that database.
>
> What do you think?
>

Should be enough. Not sure how you'll open that many query tools though.

> PS: Forgive my English. I'm learning english, and I'm using a little
> the Google Translate.

No problem, don't worry :) I'm also not a native speaker.


--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com


Re: Autosave in the SQL Editor

From
Vinicius Santos
Date:

Where is it saved?

You also need to have a way to delete those files.

I thought to create a specific directory for it.
 
Yeah, I think the informations should be available in the file (for
example if your database has a _ in its name, it will be hard to decode
the informations from the filename.
 
It's true!
I'll put the informations in the file header.

Should be enough. Not sure how you'll open that many query tools though.

I'm scanning the files with extension .pga.

If the file belongs to the current database and current user, we will open it.

I'll try on Ubuntu. Soon, I will send a preview of the patch.

Re: Autosave in the SQL Editor

From
Guillaume Lelarge
Date:
On Wed, 2012-08-08 at 12:50 -0300, Vinicius Santos wrote:
>
>         Where is it saved?
>
>         You also need to have a way to delete those files.
>
> I thought to create a specific directory for it.
>
>
>         Yeah, I think the informations should be available in the file
>         (for
>         example if your database has a _ in its name, it will be hard
>         to decode
>         the informations from the filename.
>
> It's true!
> I'll put the informations in the file header.
>
>
>         Should be enough. Not sure how you'll open that many query
>         tools though.
>
> I'm scanning the files with extension .pga.
>
> If the file belongs to the current database and current user, we will
> open it.
>
> I'll try on Ubuntu. Soon, I will send a preview of the patch.

Do you have any progress on this patch?

Thanks.


--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com



Re: Autosave in the SQL Editor

From
Vinicius Santos
Date:

Do you have any progress on this patch?

Yes.

I am finishing a preview. I'm testing on Windows 7 and Ubuntu.
I think I should finish by the end of today.

Re: Autosave in the SQL Editor

From
Vinicius Santos
Date:
Hello!

I finished the patch. I'm testing deeper, on W7 and Ubuntu.

I will probably send it tonight.

Thanks!

Re: Autosave in the SQL Editor

From
Vinicius Santos
Date:
Hello,

I did several tests and seems to be working good.

If you have any suggestion for improvement, please let me know.

Thanks!

Attachment