Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: psql: no sc...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 3441 of 3717
Post > Topic >>

Re: psql: no schema info

by alvherre@[EMAIL PROTECTED] (Alvaro Herrera) Apr 27, 2008 at 08:05 PM

chester c young wrote:

> # create table new_schema.table1(
> #    col1 integer default nextval( 'seq1' )
> # );
> 
> using old_schema.seq1, not new_schema.seq1

Yes, that's correct -- assuming you had an old_schema.seq1 sequence too.

> and imho to make matters more difficult to troubleshoot:
> 
> # \dt table1 -> does not show which schema for seq1

I agree it can be confusing if you're not looking for it.

alvherre=# set search_path to old_s;
SET
alvherre=# \d new_s.table1
                 Tabla «new_s.table1»
 Columna |  Tipo   |           Modificadores           
---------+---------+-----------------------------------
 col1    | integer | default nextval('seq1'::regclass)

Here, the nextval() is correctly _not_ qualified, because the current
search path is the sequence's schema.  But it is certainly confusing.

You have to set the search_path to the table's search path for the
problem to be obvious:

alvherre=# set search_path to new_s;
SET
alvherre=# \d new_s.table1
                    Tabla «new_s.table1»
 Columna |  Tipo   |              Modificadores              
---------+---------+-----------------------------------------
 col1    | integer | default nextval('old_s.seq1'::regclass)

alvherre=# \d table1
                    Tabla «new_s.table1»
 Columna |  Tipo   |              Modificadores              
---------+---------+-----------------------------------------
 col1    | integer | default nextval('old_s.seq1'::regclass)


I'm not sure what's a good solution here.  Perhaps the \d command should
tem****arily set the schema to something that would cause regclass to
display qualified names all the time, when you passed it a qualified
name (using SET LOCAL perhaps, but reverting to the original value after
then \d is done).  You can't just use a nonexistant schema or some kind
of NULL or empty value, because SET rejects it.  I can set it to $user,
which is accepted but doesn't exist on my scratch database:

alvherre=# set search_path to '$user';
SET
alvherre=# \d new_s.table1
                    Tabla «new_s.table1»
 Columna |  Tipo   |              Modificadores              
---------+---------+-----------------------------------------
 col1    | integer | default nextval('old_s.seq1'::regclass)


Another option would be to set it to the given schema, so that any name
not on that schema is qualified.

-- 
Alvaro Herrera                               
http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 sup****t

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 6 Posts in Topic:
psql: no schema info
chestercyoung@[EMAIL PROT  2008-04-27 14:33:33 
Re: psql: no schema info
tgl@[EMAIL PROTECTED] (T  2008-04-27 18:36:59 
Re: psql: no schema info
chestercyoung@[EMAIL PROT  2008-04-27 16:33:26 
Re: psql: no schema info
dev@[EMAIL PROTECTED] (R  2008-04-28 08:30:09 
Re: psql: no schema info
chestercyoung@[EMAIL PROT  2008-04-28 10:01:37 
Re: psql: no schema info
alvherre@[EMAIL PROTECTED  2008-04-27 20:05:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 21:05:43 CDT 2008.