comment doesn't match code

Started by Robert Haasover 10 years ago2 messages
#1Robert Haas
robertmhaas@gmail.com

/*
* ALTER TABLE INHERIT
*
* Add a parent to the child's parents. This verifies that all the columns and
* check constraints of the parent appear in the child and that they have the
* same data types and expressions.
*/
static void
ATPrepAddInherit(Relation child_rel)
{
if (child_rel->rd_rel->reloftype)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot change inheritance of typed table")));
}

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Etsuro Fujita
fujita.etsuro@lab.ntt.co.jp
In reply to: Robert Haas (#1)
1 attachment(s)
Re: comment doesn't match code

On 2015/06/10 20:18, Robert Haas wrote:

/*
* ALTER TABLE INHERIT
*
* Add a parent to the child's parents. This verifies that all the columns and
* check constraints of the parent appear in the child and that they have the
* same data types and expressions.
*/
static void
ATPrepAddInherit(Relation child_rel)
{
if (child_rel->rd_rel->reloftype)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("cannot change inheritance of typed table")));
}

I agree with you.

Besides that, ISTM taht the error message is a little bit confusing
because I think typed tables cannot inherit. Maybe I'm missing
something though. Proposed patch attached.

Best regards,
Etsuro Fujita

Attachments:

alter-table-inherit.patchtext/x-patch; name=alter-table-inherit.patchDownload
*** a/src/backend/commands/tablecmds.c
--- b/src/backend/commands/tablecmds.c
***************
*** 9853,9862 **** ATExecEnableDisableRule(Relation rel, char *trigname,
  
  /*
   * ALTER TABLE INHERIT
-  *
-  * Add a parent to the child's parents. This verifies that all the columns and
-  * check constraints of the parent appear in the child and that they have the
-  * same data types and expressions.
   */
  static void
  ATPrepAddInherit(Relation child_rel)
--- 9853,9858 ----
***************
*** 9864,9873 **** ATPrepAddInherit(Relation child_rel)
  	if (child_rel->rd_rel->reloftype)
  		ereport(ERROR,
  				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
! 				 errmsg("cannot change inheritance of typed table")));
  }
  
  /*
   * Return the address of the new parent relation.
   */
  static ObjectAddress
--- 9860,9873 ----
  	if (child_rel->rd_rel->reloftype)
  		ereport(ERROR,
  				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
! 				 errmsg("typed tables cannot inherit")));
  }
  
  /*
+  * Add a parent to the child's parents. This verifies that all the columns and
+  * check constraints of the parent appear in the child and that they have the
+  * same data types and expressions.
+  *
   * Return the address of the new parent relation.
   */
  static ObjectAddress