Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit782df58

Browse files
committed
Revert patch pending more discussion:
Disallow changing DEFAULT expression of a SERIAL column.
1 parent366682f commit782df58

File tree

7 files changed

+9
-153
lines changed

7 files changed

+9
-153
lines changed

‎doc/TODO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
PostgreSQL TODO List
33
====================
44
Current maintainer:Bruce Momjian (pgman@candle.pha.pa.us)
5-
Last updated:Sat Apr29 12:44:26 EDT 2006
5+
Last updated:Thu Apr27 11:56:04 EDT 2006
66

77
The most recent version of this document can be viewed at
88
http://www.postgresql.org/docs/faqs.TODO.html.
@@ -200,7 +200,7 @@ Data Types
200200
The positive modulus result returned by NUMERICs might be considered
201201
inaccurate, in one sense.
202202

203-
*-Disallow changing default expression of a SERIAL column
203+
*%Disallow changing default expression of a SERIAL column
204204
* %Disallow ALTER SEQUENCE changes for SERIAL sequences because pg_dump
205205
does not dump the changes
206206
* Fix data types where equality comparison isn't intuitive, e.g. box

‎doc/src/FAQ/TODO.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<bodybgcolor="#FFFFFF"text="#000000"link="#FF0000"vlink="#A00000"alink="#0000FF">
99
<h1><aname="section_1">PostgreSQL TODO List</a></h1>
1010
<p>Current maintainer: Bruce Momjian (<ahref="mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us</a>)<br/>
11-
Last updated:Sat Apr29 12:44:26 EDT 2006
11+
Last updated:Thu Apr27 11:56:04 EDT 2006
1212
</p>
1313
<p>The most recent version of this document can be viewed at<br/>
1414
<ahref="http://www.postgresql.org/docs/faqs.TODO.html">http://www.postgresql.org/docs/faqs.TODO.html</a>.
@@ -185,7 +185,7 @@ <h1><a name="section_4">Data Types</a></h1>
185185
inaccurate, in one sense.
186186
</p>
187187
<ul>
188-
<li>-<em>Disallow changing default expression of a SERIAL column</em>
188+
<li>%Disallow changing default expression of a SERIAL column
189189
</li><li>%Disallow ALTER SEQUENCE changes for SERIAL sequences because pg_dump
190190
does not dump the changes
191191
</li><li>Fix data types where equality comparison isn't intuitive, e.g. box

‎src/backend/catalog/dependency.c

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.52 2006/04/29 16:43:54 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.53 2006/04/30 01:08:06 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1931,89 +1931,3 @@ getRelationDescription(StringInfo buffer, Oid relid)
19311931

19321932
ReleaseSysCache(relTup);
19331933
}
1934-
1935-
/* Recursively travel and search for the default sequence. Finally detach it */
1936-
1937-
voidperformSequenceDefaultDeletion(constObjectAddress*object,
1938-
DropBehaviorbehavior,intdeleteFlag)
1939-
{
1940-
1941-
ScanKeyDatakey[3];
1942-
intnkeys;
1943-
SysScanDescscan;
1944-
HeapTupletup;
1945-
ObjectAddressotherObject;
1946-
RelationdepRel;
1947-
1948-
depRel=heap_open(DependRelationId,RowExclusiveLock);
1949-
1950-
ScanKeyInit(&key[0],
1951-
Anum_pg_depend_classid,
1952-
BTEqualStrategyNumber,F_OIDEQ,
1953-
ObjectIdGetDatum(object->classId));
1954-
ScanKeyInit(&key[1],
1955-
Anum_pg_depend_objid,
1956-
BTEqualStrategyNumber,F_OIDEQ,
1957-
ObjectIdGetDatum(object->objectId));
1958-
if (object->objectSubId!=0)
1959-
{
1960-
ScanKeyInit(&key[2],
1961-
Anum_pg_depend_objsubid,
1962-
BTEqualStrategyNumber,F_INT4EQ,
1963-
Int32GetDatum(object->objectSubId));
1964-
nkeys=3;
1965-
}
1966-
else
1967-
nkeys=2;
1968-
1969-
scan=systable_beginscan(depRel,DependDependerIndexId, true,
1970-
SnapshotNow,nkeys,key);
1971-
1972-
while (HeapTupleIsValid(tup=systable_getnext(scan)))
1973-
{
1974-
1975-
Form_pg_dependfoundDep= (Form_pg_depend)GETSTRUCT(tup);
1976-
1977-
otherObject.classId=foundDep->refclassid;
1978-
otherObject.objectId=foundDep->refobjid;
1979-
otherObject.objectSubId=foundDep->refobjsubid;
1980-
1981-
/* Detach the default sequence from the relation */
1982-
if(deleteFlag==1)
1983-
{
1984-
simple_heap_delete(depRel,&tup->t_self);
1985-
break;
1986-
}
1987-
1988-
switch (foundDep->deptype)
1989-
{
1990-
caseDEPENDENCY_NORMAL:
1991-
{
1992-
1993-
if(getObjectClass(&otherObject)==OCLASS_CLASS)
1994-
{
1995-
/* Dont allow to change the default sequence */
1996-
if(deleteFlag==2)
1997-
{
1998-
systable_endscan(scan);
1999-
heap_close(depRel,RowExclusiveLock);
2000-
elog(ERROR,"%s is a SERIAL sequence. Can't alter the relation",getObjectDescription(&otherObject));
2001-
return;
2002-
}
2003-
else/* Detach the default sequence from the relation */
2004-
{
2005-
performSequenceDefaultDeletion(&otherObject,behavior,1);
2006-
systable_endscan(scan);
2007-
heap_close(depRel,RowExclusiveLock);
2008-
return;
2009-
}
2010-
}
2011-
}
2012-
2013-
}
2014-
}
2015-
2016-
systable_endscan(scan);
2017-
heap_close(depRel,RowExclusiveLock);
2018-
2019-
}

‎src/backend/catalog/heap.c

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.297 2006/04/29 16:43:54 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.298 2006/04/30 01:08:06 momjian Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -2136,50 +2136,3 @@ heap_truncate_find_FKs(List *relationIds)
21362136

21372137
returnresult;
21382138
}
2139-
2140-
2141-
/* Detach the default sequence and the relation */
2142-
2143-
void
2144-
RemoveSequenceDefault(Oidrelid,AttrNumberattnum,
2145-
DropBehaviorbehavior,boolflag)
2146-
{
2147-
Relationattrdef_rel;
2148-
ScanKeyDatascankeys[2];
2149-
SysScanDescscan;
2150-
HeapTupletuple;
2151-
2152-
attrdef_rel=heap_open(AttrDefaultRelationId,RowExclusiveLock);
2153-
2154-
ScanKeyInit(&scankeys[0],
2155-
Anum_pg_attrdef_adrelid,
2156-
BTEqualStrategyNumber,F_OIDEQ,
2157-
ObjectIdGetDatum(relid));
2158-
ScanKeyInit(&scankeys[1],
2159-
Anum_pg_attrdef_adnum,
2160-
BTEqualStrategyNumber,F_INT2EQ,
2161-
Int16GetDatum(attnum));
2162-
2163-
scan=systable_beginscan(attrdef_rel,AttrDefaultIndexId, true,
2164-
SnapshotNow,2,scankeys);
2165-
2166-
/* There should be at most one matching tuple, but we loop anyway */
2167-
while (HeapTupleIsValid(tuple=systable_getnext(scan)))
2168-
{
2169-
ObjectAddressobject;
2170-
2171-
object.classId=AttrDefaultRelationId;
2172-
object.objectId=HeapTupleGetOid(tuple);
2173-
object.objectSubId=0;
2174-
2175-
if(flag== true)/* Detach the sequence */
2176-
performSequenceDefaultDeletion(&object,behavior,0);
2177-
else/* Don't allow to change the default sequence */
2178-
performSequenceDefaultDeletion(&object,behavior,2);
2179-
2180-
}
2181-
2182-
systable_endscan(scan);
2183-
heap_close(attrdef_rel,RowExclusiveLock);
2184-
2185-
}

‎src/backend/commands/tablecmds.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.182 2006/04/29 16:43:54 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.183 2006/04/30 01:08:07 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3362,11 +3362,6 @@ ATExecColumnDefault(Relation rel, const char *colName,
33623362
* safety, but at present we do not expect anything to depend on the
33633363
* default.
33643364
*/
3365-
if (newDefault)
3366-
RemoveSequenceDefault(RelationGetRelid(rel),attnum,DROP_RESTRICT, false);
3367-
else
3368-
RemoveSequenceDefault(RelationGetRelid(rel),attnum,DROP_RESTRICT, true);
3369-
33703365
RemoveAttrDefault(RelationGetRelid(rel),attnum,DROP_RESTRICT, false);
33713366

33723367
if (newDefault)

‎src/include/catalog/dependency.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/dependency.h,v 1.22 2006/04/29 16:43:54 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/dependency.h,v 1.23 2006/04/30 01:08:07 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -207,7 +207,4 @@ extern void shdepDropOwned(List *relids, DropBehavior behavior);
207207

208208
externvoidshdepReassignOwned(List*relids,Oidnewrole);
209209

210-
externvoidperformSequenceDefaultDeletion(constObjectAddress*object,
211-
DropBehaviorbehavior,intdeleteFlag);
212-
213210
#endif/* DEPENDENCY_H */

‎src/include/catalog/heap.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.79 2006/04/29 16:43:54 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.80 2006/04/30 01:08:07 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -97,7 +97,4 @@ extern void CheckAttributeNamesTypes(TupleDesc tupdesc, char relkind);
9797

9898
externvoidCheckAttributeType(constchar*attname,Oidatttypid);
9999

100-
externvoidRemoveSequenceDefault(Oidrelid,AttrNumberattnum,
101-
DropBehaviorbehavior,boolflag);
102-
103100
#endif/* HEAP_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp