Unix Technical Forum

bug with fkey-dialog in tables belonging to schemes

This is a discussion on bug with fkey-dialog in tables belonging to schemes within the pgsql Interfaces Pgadmin Support forums, part of the PostgreSQL category; --> I discovered a subtle bug within the dialog for foreign key creation: Be there a database "testdb" structured like: ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Interfaces Pgadmin Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 08:17 PM
Harald Armin Massa
 
Posts: n/a
Default bug with fkey-dialog in tables belonging to schemes

I discovered a subtle bug within the dialog for foreign key creation:

Be there a database "testdb" structured like:

CREATE SCHEMA nb1;

CREATE TABLE nb1.hauptbaer (
id_baer serial NOT NULL,
fischfeld text
);

ALTER TABLE nb1.hauptbaer
ADD CONSTRAINT hauptbaer_pkey PRIMARY KEY(id_baer);

CREATE TABLE nb1.nebenbaer (
id_nb serial NOT NULL,
rede text,
id_baer integer
);

ALTER TABLE ONLY nb1.nebenbaer
ADD CONSTRAINT nebenbaer_pkey PRIMARY KEY (id_nb);

that is, within schema "nb1" there are two tables "nb1.hauptbaer" and "nb1
nebenbaer".

The database, the schema, everthing is owned by a user named nb1.

Now create a connection to the database testdb as user nb1.

When going to "nebenbaer" and trying to add a foreign key constraint to
id_baer of hauptbaer...

you can select hauptbaer from the list of tables, but there is no scheme
prefix. On the dialog-tab where you need to select the columns for the fkey
relationship, no column from hauptbaer is shown.

My guess it's that the nb1-scheme is dropped out because it's same as
username.

If I connect as postgres or any other user, creating that restriction works
fine. I can select columns and all.

I hope I explained understandable; if I can do anything more to make it
reproducable, please let me know.

Harald




--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Reinsburgstraße 202b
70197 Stuttgart
0173/9409607

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 08:17 PM
Miha Radej
 
Posts: n/a
Default Re: bug with fkey-dialog in tables belonging to

hi!

i seem to be having problems with sending email today so if anyone
receives this email twice... i apologize.

******************

http://archives.postgresql.org/pgadm...1/msg00102.php

i've also posted what seems to be the same bug about a month ago. i can
confirm that, like harald said, it occured when working on a schema with
the same name as the name of the user connecting to the database. and in
a follow-up to the above post i've posted the query pgadmin makes and
what it should be (imo) to work properly.

regards,
M

Harald Armin Massa wrote:
> I discovered a subtle bug within the dialog for foreign key creation:
>
> Be there a database "testdb" structured like:
>
> CREATE SCHEMA nb1;
>
> CREATE TABLE nb1.hauptbaer (
> id_baer serial NOT NULL,
> fischfeld text
> );
>
> ALTER TABLE nb1.hauptbaer
> ADD CONSTRAINT hauptbaer_pkey PRIMARY KEY(id_baer);
>
> CREATE TABLE nb1.nebenbaer (
> id_nb serial NOT NULL,
> rede text,
> id_baer integer
> );
>
> ALTER TABLE ONLY nb1.nebenbaer
> ADD CONSTRAINT nebenbaer_pkey PRIMARY KEY (id_nb);
>
> that is, within schema "nb1" there are two tables "nb1.hauptbaer" and
> "nb1 nebenbaer".
>
> The database, the schema, everthing is owned by a user named nb1.
>
> Now create a connection to the database testdb as user nb1.
>
> When going to "nebenbaer" and trying to add a foreign key constraint to
> id_baer of hauptbaer...
>
> you can select hauptbaer from the list of tables, but there is no scheme
> prefix. On the dialog-tab where you need to select the columns for the
> fkey relationship, no column from hauptbaer is shown.
>
> My guess it's that the nb1-scheme is dropped out because it's same as
> username.
>
> If I connect as postgres or any other user, creating that restriction
> works fine. I can select columns and all.
>
> I hope I explained understandable; if I can do anything more to make it
> reproducable, please let me know.
>
> Harald


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 08:17 PM
Miha Radej
 
Posts: n/a
Default Re: bug with fkey-dialog in tables belonging to

hi!

http://archives.postgresql.org/pgadm...1/msg00102.php

i've reported what seems to be the same bug about a month ago. i can
confirm that, like harald said, it occured when working on a schema with
the same name as the user connecting to the database. and in a follow-up
to the above post i've posted the query pgadmin makes and what it should
be (imo) to work properly.

regards,
M

Harald Armin Massa wrote:
> I discovered a subtle bug within the dialog for foreign key creation:
>
> Be there a database "testdb" structured like:
>
> CREATE SCHEMA nb1;
>
> CREATE TABLE nb1.hauptbaer (
> id_baer serial NOT NULL,
> fischfeld text
> );
>
> ALTER TABLE nb1.hauptbaer
> ADD CONSTRAINT hauptbaer_pkey PRIMARY KEY(id_baer);
>
> CREATE TABLE nb1.nebenbaer (
> id_nb serial NOT NULL,
> rede text,
> id_baer integer
> );
>
> ALTER TABLE ONLY nb1.nebenbaer
> ADD CONSTRAINT nebenbaer_pkey PRIMARY KEY (id_nb);
>
> that is, within schema "nb1" there are two tables "nb1.hauptbaer" and
> "nb1 nebenbaer".
>
> The database, the schema, everthing is owned by a user named nb1.
>
> Now create a connection to the database testdb as user nb1.
>
> When going to "nebenbaer" and trying to add a foreign key constraint to
> id_baer of hauptbaer...
>
> you can select hauptbaer from the list of tables, but there is no scheme
> prefix. On the dialog-tab where you need to select the columns for the
> fkey relationship, no column from hauptbaer is shown.
>
> My guess it's that the nb1-scheme is dropped out because it's same as
> username.
>
> If I connect as postgres or any other user, creating that restriction
> works fine. I can select columns and all.
>
> I hope I explained understandable; if I can do anything more to make it
> reproducable, please let me know.
>
> Harald


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 08:18 PM
Andreas Pflug
 
Posts: n/a
Default Re: bug with fkey-dialog in tables belonging to

Harald Armin Massa wrote:
> I discovered a subtle bug within the dialog for foreign key creation:
>
> Be there a database "testdb" structured like:
>
> CREATE SCHEMA nb1;
>
> CREATE TABLE nb1.hauptbaer (
> id_baer serial NOT NULL,
> fischfeld text
> );
>
> ALTER TABLE nb1.hauptbaer
> ADD CONSTRAINT hauptbaer_pkey PRIMARY KEY(id_baer);
>
> CREATE TABLE nb1.nebenbaer (
> id_nb serial NOT NULL,
> rede text,
> id_baer integer
> );
>
> ALTER TABLE ONLY nb1.nebenbaer
> ADD CONSTRAINT nebenbaer_pkey PRIMARY KEY (id_nb);
>
> that is, within schema "nb1" there are two tables "nb1.hauptbaer" and
> "nb1 nebenbaer".
>
> The database, the schema, everthing is owned by a user named nb1.
>
> Now create a connection to the database testdb as user nb1.
>
> When going to "nebenbaer" and trying to add a foreign key constraint to
> id_baer of hauptbaer...
>
> you can select hauptbaer from the list of tables, but there is no scheme
> prefix. On the dialog-tab where you need to select the columns for the
> fkey relationship, no column from hauptbaer is shown.


I did exactly this, replacing nb1 by user/db/schema postgres, and
everything worked as expected. My search_path is the default $user,public.

Actually, suppressing the schema name here wouldn't do any harm, because
the search_path will automatically add the username here.


Regards,
Andreas

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:41 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com