mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Revert patch pending more discussion:
Disallow changing DEFAULT expression of a SERIAL column.
This commit is contained in:
parent
366682fb66
commit
782df58a1c
4
doc/TODO
4
doc/TODO
@ -2,7 +2,7 @@
|
|||||||
PostgreSQL TODO List
|
PostgreSQL TODO List
|
||||||
====================
|
====================
|
||||||
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
|
Current maintainer: Bruce Momjian (pgman@candle.pha.pa.us)
|
||||||
Last updated: Sat Apr 29 12:44:26 EDT 2006
|
Last updated: Thu Apr 27 11:56:04 EDT 2006
|
||||||
|
|
||||||
The most recent version of this document can be viewed at
|
The most recent version of this document can be viewed at
|
||||||
http://www.postgresql.org/docs/faqs.TODO.html.
|
http://www.postgresql.org/docs/faqs.TODO.html.
|
||||||
@ -200,7 +200,7 @@ Data Types
|
|||||||
The positive modulus result returned by NUMERICs might be considered
|
The positive modulus result returned by NUMERICs might be considered
|
||||||
inaccurate, in one sense.
|
inaccurate, in one sense.
|
||||||
|
|
||||||
* -Disallow changing default expression of a SERIAL column
|
* %Disallow changing default expression of a SERIAL column
|
||||||
* %Disallow ALTER SEQUENCE changes for SERIAL sequences because pg_dump
|
* %Disallow ALTER SEQUENCE changes for SERIAL sequences because pg_dump
|
||||||
does not dump the changes
|
does not dump the changes
|
||||||
* Fix data types where equality comparison isn't intuitive, e.g. box
|
* Fix data types where equality comparison isn't intuitive, e.g. box
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<body bgcolor="#FFFFFF" text="#000000" link="#FF0000" vlink="#A00000" alink="#0000FF">
|
<body bgcolor="#FFFFFF" text="#000000" link="#FF0000" vlink="#A00000" alink="#0000FF">
|
||||||
<h1><a name="section_1">PostgreSQL TODO List</a></h1>
|
<h1><a name="section_1">PostgreSQL TODO List</a></h1>
|
||||||
<p>Current maintainer: Bruce Momjian (<a href="mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</a>)<br/>
|
<p>Current maintainer: Bruce Momjian (<a href="mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</a>)<br/>
|
||||||
Last updated: Sat Apr 29 12:44:26 EDT 2006
|
Last updated: Thu Apr 27 11:56:04 EDT 2006
|
||||||
</p>
|
</p>
|
||||||
<p>The most recent version of this document can be viewed at<br/>
|
<p>The most recent version of this document can be viewed at<br/>
|
||||||
<a href="http://www.postgresql.org/docs/faqs.TODO.html">http://www.postgresql.org/docs/faqs.TODO.html</a>.
|
<a href="http://www.postgresql.org/docs/faqs.TODO.html">http://www.postgresql.org/docs/faqs.TODO.html</a>.
|
||||||
@ -185,7 +185,7 @@ first.
|
|||||||
inaccurate, in one sense.
|
inaccurate, in one sense.
|
||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>-<em>Disallow changing default expression of a SERIAL column</em>
|
<li>%Disallow changing default expression of a SERIAL column
|
||||||
</li><li>%Disallow ALTER SEQUENCE changes for SERIAL sequences because pg_dump
|
</li><li>%Disallow ALTER SEQUENCE changes for SERIAL sequences because pg_dump
|
||||||
does not dump the changes
|
does not dump the changes
|
||||||
</li><li>Fix data types where equality comparison isn't intuitive, e.g. box
|
</li><li>Fix data types where equality comparison isn't intuitive, e.g. box
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.52 2006/04/29 16:43:54 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.53 2006/04/30 01:08:06 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1931,89 +1931,3 @@ getRelationDescription(StringInfo buffer, Oid relid)
|
|||||||
|
|
||||||
ReleaseSysCache(relTup);
|
ReleaseSysCache(relTup);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Recursively travel and search for the default sequence. Finally detach it */
|
|
||||||
|
|
||||||
void performSequenceDefaultDeletion(const ObjectAddress *object,
|
|
||||||
DropBehavior behavior, int deleteFlag)
|
|
||||||
{
|
|
||||||
|
|
||||||
ScanKeyData key[3];
|
|
||||||
int nkeys;
|
|
||||||
SysScanDesc scan;
|
|
||||||
HeapTuple tup;
|
|
||||||
ObjectAddress otherObject;
|
|
||||||
Relation depRel;
|
|
||||||
|
|
||||||
depRel = heap_open(DependRelationId, RowExclusiveLock);
|
|
||||||
|
|
||||||
ScanKeyInit(&key[0],
|
|
||||||
Anum_pg_depend_classid,
|
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
|
||||||
ObjectIdGetDatum(object->classId));
|
|
||||||
ScanKeyInit(&key[1],
|
|
||||||
Anum_pg_depend_objid,
|
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
|
||||||
ObjectIdGetDatum(object->objectId));
|
|
||||||
if (object->objectSubId != 0)
|
|
||||||
{
|
|
||||||
ScanKeyInit(&key[2],
|
|
||||||
Anum_pg_depend_objsubid,
|
|
||||||
BTEqualStrategyNumber, F_INT4EQ,
|
|
||||||
Int32GetDatum(object->objectSubId));
|
|
||||||
nkeys = 3;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
nkeys = 2;
|
|
||||||
|
|
||||||
scan = systable_beginscan(depRel, DependDependerIndexId, true,
|
|
||||||
SnapshotNow, nkeys, key);
|
|
||||||
|
|
||||||
while (HeapTupleIsValid(tup = systable_getnext(scan)))
|
|
||||||
{
|
|
||||||
|
|
||||||
Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup);
|
|
||||||
|
|
||||||
otherObject.classId = foundDep->refclassid;
|
|
||||||
otherObject.objectId = foundDep->refobjid;
|
|
||||||
otherObject.objectSubId = foundDep->refobjsubid;
|
|
||||||
|
|
||||||
/* Detach the default sequence from the relation */
|
|
||||||
if(deleteFlag == 1)
|
|
||||||
{
|
|
||||||
simple_heap_delete(depRel, &tup->t_self);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (foundDep->deptype)
|
|
||||||
{
|
|
||||||
case DEPENDENCY_NORMAL:
|
|
||||||
{
|
|
||||||
|
|
||||||
if(getObjectClass(&otherObject) == OCLASS_CLASS)
|
|
||||||
{
|
|
||||||
/* Dont allow to change the default sequence */
|
|
||||||
if(deleteFlag == 2)
|
|
||||||
{
|
|
||||||
systable_endscan(scan);
|
|
||||||
heap_close(depRel, RowExclusiveLock);
|
|
||||||
elog(ERROR, "%s is a SERIAL sequence. Can't alter the relation", getObjectDescription(&otherObject));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else /* Detach the default sequence from the relation */
|
|
||||||
{
|
|
||||||
performSequenceDefaultDeletion(&otherObject, behavior, 1);
|
|
||||||
systable_endscan(scan);
|
|
||||||
heap_close(depRel, RowExclusiveLock);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
systable_endscan(scan);
|
|
||||||
heap_close(depRel, RowExclusiveLock);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.297 2006/04/29 16:43:54 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.298 2006/04/30 01:08:06 momjian Exp $
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* INTERFACE ROUTINES
|
* INTERFACE ROUTINES
|
||||||
@ -2136,50 +2136,3 @@ heap_truncate_find_FKs(List *relationIds)
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Detach the default sequence and the relation */
|
|
||||||
|
|
||||||
void
|
|
||||||
RemoveSequenceDefault(Oid relid, AttrNumber attnum,
|
|
||||||
DropBehavior behavior, bool flag)
|
|
||||||
{
|
|
||||||
Relation attrdef_rel;
|
|
||||||
ScanKeyData scankeys[2];
|
|
||||||
SysScanDesc scan;
|
|
||||||
HeapTuple tuple;
|
|
||||||
|
|
||||||
attrdef_rel = heap_open(AttrDefaultRelationId, RowExclusiveLock);
|
|
||||||
|
|
||||||
ScanKeyInit(&scankeys[0],
|
|
||||||
Anum_pg_attrdef_adrelid,
|
|
||||||
BTEqualStrategyNumber, F_OIDEQ,
|
|
||||||
ObjectIdGetDatum(relid));
|
|
||||||
ScanKeyInit(&scankeys[1],
|
|
||||||
Anum_pg_attrdef_adnum,
|
|
||||||
BTEqualStrategyNumber, F_INT2EQ,
|
|
||||||
Int16GetDatum(attnum));
|
|
||||||
|
|
||||||
scan = systable_beginscan(attrdef_rel, AttrDefaultIndexId, true,
|
|
||||||
SnapshotNow, 2, scankeys);
|
|
||||||
|
|
||||||
/* There should be at most one matching tuple, but we loop anyway */
|
|
||||||
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
|
|
||||||
{
|
|
||||||
ObjectAddress object;
|
|
||||||
|
|
||||||
object.classId = AttrDefaultRelationId;
|
|
||||||
object.objectId = HeapTupleGetOid(tuple);
|
|
||||||
object.objectSubId = 0;
|
|
||||||
|
|
||||||
if(flag == true) /* Detach the sequence */
|
|
||||||
performSequenceDefaultDeletion(&object, behavior, 0);
|
|
||||||
else /* Don't allow to change the default sequence */
|
|
||||||
performSequenceDefaultDeletion(&object, behavior, 2);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
systable_endscan(scan);
|
|
||||||
heap_close(attrdef_rel, RowExclusiveLock);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.182 2006/04/29 16:43:54 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.183 2006/04/30 01:08:07 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -3362,11 +3362,6 @@ ATExecColumnDefault(Relation rel, const char *colName,
|
|||||||
* safety, but at present we do not expect anything to depend on the
|
* safety, but at present we do not expect anything to depend on the
|
||||||
* default.
|
* default.
|
||||||
*/
|
*/
|
||||||
if (newDefault)
|
|
||||||
RemoveSequenceDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, false);
|
|
||||||
else
|
|
||||||
RemoveSequenceDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, true);
|
|
||||||
|
|
||||||
RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, false);
|
RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, false);
|
||||||
|
|
||||||
if (newDefault)
|
if (newDefault)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/catalog/dependency.h,v 1.22 2006/04/29 16:43:54 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/catalog/dependency.h,v 1.23 2006/04/30 01:08:07 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -207,7 +207,4 @@ extern void shdepDropOwned(List *relids, DropBehavior behavior);
|
|||||||
|
|
||||||
extern void shdepReassignOwned(List *relids, Oid newrole);
|
extern void shdepReassignOwned(List *relids, Oid newrole);
|
||||||
|
|
||||||
extern void performSequenceDefaultDeletion(const ObjectAddress *object,
|
|
||||||
DropBehavior behavior, int deleteFlag);
|
|
||||||
|
|
||||||
#endif /* DEPENDENCY_H */
|
#endif /* DEPENDENCY_H */
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.79 2006/04/29 16:43:54 momjian Exp $
|
* $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.80 2006/04/30 01:08:07 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -97,7 +97,4 @@ extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind);
|
|||||||
|
|
||||||
extern void CheckAttributeType(const char *attname, Oid atttypid);
|
extern void CheckAttributeType(const char *attname, Oid atttypid);
|
||||||
|
|
||||||
extern void RemoveSequenceDefault(Oid relid, AttrNumber attnum,
|
|
||||||
DropBehavior behavior, bool flag);
|
|
||||||
|
|
||||||
#endif /* HEAP_H */
|
#endif /* HEAP_H */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user