Обсуждение: Support for invalid foreign keys

Поиск
Список
Период
Сортировка

Support for invalid foreign keys

От
Guillaume Lelarge
Дата:
Hi,

This is a new (as in 9.1) feature we have to support in pgAdmin.

From the git log on https://github.com/gleu/pgadmin3/tree/ticket304:

 Add support for invalid foreign key constraints

 This patch adds a checkbox in the dlgForeignKey dialog, so that the
 user can create an "not validated" foreign key. Each foreign key of
 this kind is displayed with the usual icon with a red cross on it. A
 contextual menu allows the user to force the validation of the
 constraint. The user can also do this via the dlgForeignKey dialog.

Patch attached. Comments welcomed :)


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Вложения

Re: Support for invalid foreign keys

От
Dave Page
Дата:
On Sun, Mar 6, 2011 at 10:28 PM, Guillaume Lelarge
<guillaume@lelarge.info> wrote:
> Hi,
>
> This is a new (as in 9.1) feature we have to support in pgAdmin.
>
> From the git log on https://github.com/gleu/pgadmin3/tree/ticket304:
>
>  Add support for invalid foreign key constraints
>
>  This patch adds a checkbox in the dlgForeignKey dialog, so that the
>  user can create an "not validated" foreign key. Each foreign key of
>  this kind is displayed with the usual icon with a red cross on it. A
>  contextual menu allows the user to force the validation of the
>  constraint. The user can also do this via the dlgForeignKey dialog.

So it basically disables the constraint, leaving it as a sort of
documentation of intent?


--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: Support for invalid foreign keys

От
Thom Brown
Дата:
On 7 March 2011 10:18, Dave Page <dpage@pgadmin.org> wrote:
> On Sun, Mar 6, 2011 at 10:28 PM, Guillaume Lelarge
> <guillaume@lelarge.info> wrote:
>> Hi,
>>
>> This is a new (as in 9.1) feature we have to support in pgAdmin.
>>
>> From the git log on https://github.com/gleu/pgadmin3/tree/ticket304:
>>
>>  Add support for invalid foreign key constraints
>>
>>  This patch adds a checkbox in the dlgForeignKey dialog, so that the
>>  user can create an "not validated" foreign key. Each foreign key of
>>  this kind is displayed with the usual icon with a red cross on it. A
>>  contextual menu allows the user to force the validation of the
>>  constraint. The user can also do this via the dlgForeignKey dialog.
>
> So it basically disables the constraint, leaving it as a sort of
> documentation of intent?

Yes, I believe the purpose is to allow the creation of a foreign key
with far less disruptive locking meaning foreign keys can be created
in parallel.

Guillaume, you appear to have commented out an if container, while
also adding a condition to it.  Is this supposed to be commented out
at all?..

+    //if (sql.IsNull() || forceRefresh)

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

Re: Support for invalid foreign keys

От
Guillaume Lelarge
Дата:
Le 07/03/2011 06:49, Thom Brown a écrit :
> On 7 March 2011 10:18, Dave Page <dpage@pgadmin.org> wrote:
>> On Sun, Mar 6, 2011 at 10:28 PM, Guillaume Lelarge
>> <guillaume@lelarge.info> wrote:
>>> Hi,
>>>
>>> This is a new (as in 9.1) feature we have to support in pgAdmin.
>>>
>>> From the git log on https://github.com/gleu/pgadmin3/tree/ticket304:
>>>
>>>  Add support for invalid foreign key constraints
>>>
>>>  This patch adds a checkbox in the dlgForeignKey dialog, so that the
>>>  user can create an "not validated" foreign key. Each foreign key of
>>>  this kind is displayed with the usual icon with a red cross on it. A
>>>  contextual menu allows the user to force the validation of the
>>>  constraint. The user can also do this via the dlgForeignKey dialog.
>>
>> So it basically disables the constraint, leaving it as a sort of
>> documentation of intent?
>
> Yes, I believe the purpose is to allow the creation of a foreign key
> with far less disruptive locking meaning foreign keys can be created
> in parallel.
>

Yeah, you first create the constraint without being disruptive (on big
tables), and you validate the constraint at a time the system is less
used (for example during the night when everyone's asleep :) ).

> Guillaume, you appear to have commented out an if container, while
> also adding a condition to it.  Is this supposed to be commented out
> at all?..
>
> +    //if (sql.IsNull() || forceRefresh)
>

Well, it was supposed to be deleted. Actually, I was supposed to ask if
anyone knows why there is the "if (sql.IsNull())" check at all (the "||
forceRefresh" is a test I should have deleted). I have no idea why there
is this sql.IsNull() test. It doesn't appear in other same sources.
Dave, any idea?


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com

Re: Support for invalid foreign keys

От
Dave Page
Дата:
On Mon, Mar 7, 2011 at 6:21 AM, Guillaume Lelarge
<guillaume@lelarge.info> wrote:
> Well, it was supposed to be deleted. Actually, I was supposed to ask if
> anyone knows why there is the "if (sql.IsNull())" check at all (the "||
> forceRefresh" is a test I should have deleted). I have no idea why there
> is this sql.IsNull() test. It doesn't appear in other same sources.
> Dave, any idea?

It's an optimisation to prevent us regenerating the SQL every time we
need it. For most objects that's cheap - for some (eg. tables) - far
from it.

When refreshing, frmMain->Refresh calls the SetDirty() function on the
object, which causes sql to be cleared ready for regeneration.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: Support for invalid foreign keys

От
Guillaume Lelarge
Дата:
Le 07/03/2011 07:49, Dave Page a écrit :
> On Mon, Mar 7, 2011 at 6:21 AM, Guillaume Lelarge
> <guillaume@lelarge.info> wrote:
>> Well, it was supposed to be deleted. Actually, I was supposed to ask if
>> anyone knows why there is the "if (sql.IsNull())" check at all (the "||
>> forceRefresh" is a test I should have deleted). I have no idea why there
>> is this sql.IsNull() test. It doesn't appear in other same sources.
>> Dave, any idea?
>
> It's an optimisation to prevent us regenerating the SQL every time we
> need it. For most objects that's cheap - for some (eg. tables) - far
> from it.
>
> When refreshing, frmMain->Refresh calls the SetDirty() function on the
> object, which causes sql to be cleared ready for regeneration.
>

OK, commited with a few fixes according to this discussion. Thanks.


--
Guillaume
 http://www.postgresql.fr
 http://dalibo.com