constraint defaults still print
Remember how we made DEFERRABLE/DEFERRED not print if the constraint was
the default. Shouldn't we do the same for MATCH and ON UPDATE/ON DELETE
sections of the constraint in pg_get_constraintdef()?
Doing \d I see:
test=> \d sales
Table "public.sales"
Column | Type | Modifiers
-------------------+---------+-----------
product_id | integer | not null
store_id | integer | not null
quantity_sold | integer | not null
date_time_of_sale | date | not null
Foreign Key constraints: $1 FOREIGN KEY (product_id) REFERENCES
products(product_id) ON UPDATE NO ACTION ON DELETE NO ACTION,
$2 FOREIGN KEY (store_id) REFERENCES
stores(store_id) ON UPDATE NO ACTION ON DELETE NO ACTION
If NO ACTION is the default, is there a need to print them? This would
also shorten pg_dump output.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Assume a database with a couple of namespaces. Give two of these
namespaces the names test_1 and test_2. Under these namespaces create a
couple of tables with the names: example, example_2, example_3.
set search_path to test_1, test_2;
In the psql client, using a standard \d you will only see the namespace
test_1 listed and the tables underneath that. test_2 will not be visible
due to the fact they fail the pg_table_is_visible() check.
I am not sure that is wise to do the pg_table_is_visible check on those
commands. In my humble opinion, those commands are for understanding the
layout/structure/nature of the database. If you can't see all your
namespaces that you set in your search_path then it could distort ones
understanding of the database.
--
//========================================================\\
|| D. Hageman <dhageman@dracken.com> ||
\\========================================================//
I vote for not showing 'NO ACTION', so long as it's the SQL standard
default...
Chris
On Sat, 18 Jan 2003, Bruce Momjian wrote:
Show quoted text
Remember how we made DEFERRABLE/DEFERRED not print if the constraint was
the default. Shouldn't we do the same for MATCH and ON UPDATE/ON DELETE
sections of the constraint in pg_get_constraintdef()?Doing \d I see:
test=> \d sales
Table "public.sales"
Column | Type | Modifiers
-------------------+---------+-----------
product_id | integer | not null
store_id | integer | not null
quantity_sold | integer | not null
date_time_of_sale | date | not null
Foreign Key constraints: $1 FOREIGN KEY (product_id) REFERENCES
products(product_id) ON UPDATE NO ACTION ON DELETE NO ACTION,
$2 FOREIGN KEY (store_id) REFERENCES
stores(store_id) ON UPDATE NO ACTION ON DELETE NO ACTIONIf NO ACTION is the default, is there a need to print them? This would
also shorten pg_dump output.-- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
"D. Hageman" <dhageman@dracken.com> writes:
I am not sure that is wise to do the pg_table_is_visible check on those
commands. In my humble opinion, those commands are for understanding the
layout/structure/nature of the database. If you can't see all your
namespaces that you set in your search_path then it could distort ones
understanding of the database.
What would you have it do --- list tables that you cannot actually
access without qualification? That doesn't seem like an improvement to
me.
You could write "\d *.*" to see everything, or "\d test_1.*" and
"\d test_2.*" to see the full contents of those two schemas. But
ISTM that \d without any schema qualification should only show tables
that you can access without any schema qualification.
regards, tom lane
OK, NO ACTION (the default) no longer prints for foreign key constraints:
regression=> \d clstr_tst
Table "public.clstr_tst"
Column | Type | Modifiers
--------+---------+----------------------------------------------------------
a | integer | not null default nextval('public.clstr_tst_a_seq'::text)
b | integer |
c | text |
d | text |
Indexes: clstr_tst_pkey primary key btree (a),
clstr_tst_b btree (b),
clstr_tst_b_c btree (b, c),
clstr_tst_c btree (c),
clstr_tst_c_b btree (c, b)
Foreign Key constraints: clstr_tst_con FOREIGN KEY (b) REFERENCES clstr_tst_s(rf_a)
---------------------------------------------------------------------------
Christopher Kings-Lynne wrote:
I vote for not showing 'NO ACTION', so long as it's the SQL standard
default...Chris
On Sat, 18 Jan 2003, Bruce Momjian wrote:
Remember how we made DEFERRABLE/DEFERRED not print if the constraint was
the default. Shouldn't we do the same for MATCH and ON UPDATE/ON DELETE
sections of the constraint in pg_get_constraintdef()?Doing \d I see:
test=> \d sales
Table "public.sales"
Column | Type | Modifiers
-------------------+---------+-----------
product_id | integer | not null
store_id | integer | not null
quantity_sold | integer | not null
date_time_of_sale | date | not null
Foreign Key constraints: $1 FOREIGN KEY (product_id) REFERENCES
products(product_id) ON UPDATE NO ACTION ON DELETE NO ACTION,
$2 FOREIGN KEY (store_id) REFERENCES
stores(store_id) ON UPDATE NO ACTION ON DELETE NO ACTIONIf NO ACTION is the default, is there a need to print them? This would
also shorten pg_dump output.-- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073
Attachments:
/bjm/difftext/plainDownload
Index: src/backend/utils/adt/ruleutils.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/ruleutils.c,v
retrieving revision 1.132
diff -c -c -r1.132 ruleutils.c
*** src/backend/utils/adt/ruleutils.c 10 Jan 2003 21:08:15 -0000 1.132
--- src/backend/utils/adt/ruleutils.c 3 Feb 2003 14:57:33 -0000
***************
*** 642,648 ****
switch (conForm->confupdtype)
{
case FKCONSTR_ACTION_NOACTION:
! string = "NO ACTION";
break;
case FKCONSTR_ACTION_RESTRICT:
string = "RESTRICT";
--- 642,648 ----
switch (conForm->confupdtype)
{
case FKCONSTR_ACTION_NOACTION:
! string = "";
break;
case FKCONSTR_ACTION_RESTRICT:
string = "RESTRICT";
***************
*** 662,673 ****
string = ""; /* keep compiler quiet */
break;
}
! appendStringInfo(&buf, " ON UPDATE %s", string);
switch (conForm->confdeltype)
{
case FKCONSTR_ACTION_NOACTION:
! string = "NO ACTION";
break;
case FKCONSTR_ACTION_RESTRICT:
string = "RESTRICT";
--- 662,674 ----
string = ""; /* keep compiler quiet */
break;
}
! if (strlen(string) != 0)
! appendStringInfo(&buf, " ON UPDATE %s", string);
switch (conForm->confdeltype)
{
case FKCONSTR_ACTION_NOACTION:
! string = "";
break;
case FKCONSTR_ACTION_RESTRICT:
string = "RESTRICT";
***************
*** 687,693 ****
string = ""; /* keep compiler quiet */
break;
}
! appendStringInfo(&buf, " ON DELETE %s", string);
if (conForm->condeferrable)
appendStringInfo(&buf, " DEFERRABLE");
--- 688,695 ----
string = ""; /* keep compiler quiet */
break;
}
! if (strlen(string) != 0)
! appendStringInfo(&buf, " ON DELETE %s", string);
if (conForm->condeferrable)
appendStringInfo(&buf, " DEFERRABLE");