Unix Technical Forum

Views an non-present column

This is a discussion on Views an non-present column within the pgsql Novice forums, part of the PostgreSQL category; --> Hi everyone, I am playing with Postgresql 8.0 (Mandriva 2006) and there is something I don't understand. Let's assume ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 10:22 PM
Fabien SK
 
Posts: n/a
Default Views an non-present column

Hi everyone,

I am playing with Postgresql 8.0 (Mandriva 2006) and there is something
I don't understand. Let's assume that I have a table with some columns.
I create the following view:

CREATE VIEW vista as select name from mytable;

Then I check that everything is fine:

EXPLAIN select name from vista;

OK, I get a "Seq Scan on...".

but if I do:

EXPLAIN select mytable.name from vista;

I get an horrible:

Nested Loop (cost=17.70..9834.70 rows=490000 width=82)
-> Seq Scan on mytable (cost=0.00..17.00 rows=700 width=0)
-> Materialize (cost=17.70..24.70 rows=700 width=82)
-> Seq Scan on mytable (cost=0.00..17.00 rows=700 width=82)


I also get the following notice:
NOTICE: Ajout d'une entrée manquante dans FROM (table «mytable»)

Bad translation:
adding an entry missing in the clause FROM (table «mytable»)

My question is: is there a way to prevent such a behaviour ? I would
like to get an error instead.

Cheers,
Fabien SK


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 10:22 PM
Bruno Wolff III
 
Posts: n/a
Default Re: Views an non-present column

On Sat, Dec 10, 2005 at 19:04:18 +0100,
Fabien SK <fabsk@free.fr> wrote:
> Hi everyone,
>
> I am playing with Postgresql 8.0 (Mandriva 2006) and there is something
> I don't understand. Let's assume that I have a table with some columns.
> I create the following view:
>
> CREATE VIEW vista as select name from mytable;
>
> Then I check that everything is fine:
>
> EXPLAIN select name from vista;
>
> OK, I get a "Seq Scan on...".
>
> but if I do:
>
> EXPLAIN select mytable.name from vista;
>
> I get an horrible:
>
> Nested Loop (cost=17.70..9834.70 rows=490000 width=82)
> -> Seq Scan on mytable (cost=0.00..17.00 rows=700 width=0)
> -> Materialize (cost=17.70..24.70 rows=700 width=82)
> -> Seq Scan on mytable (cost=0.00..17.00 rows=700 width=82)
>
>
> I also get the following notice:
> NOTICE: Ajout d'une entrée manquante dans FROM (table «mytable»)
>
> Bad translation:
> adding an entry missing in the clause FROM (table «mytable»)
>
> My question is: is there a way to prevent such a behaviour ? I would
> like to get an error instead.


It depends on which version of postgres you are using. In 8.1 its off by
default. My memory is that the option to turn it off was first put in 8.0.
You can use SET ADD_MISSING_FROM = OFF to disable this.

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 10:22 PM
Fabien SK
 
Posts: n/a
Default Re: Views an non-present column

Le samedi 10 décembre 2005 à 12:52 -0600, Bruno Wolff III a écrit :

> It depends on which version of postgres you are using. In 8.1 its off by
> default. My memory is that the option to turn it off was first put in 8.0.
> You can use SET ADD_MISSING_FROM = OFF to disable this.


Thank you a lot, it works perfectly, goodbye errors !

Fabien


---------------------------(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
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 04:25 PM.


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