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

Commit33b4ad6

Browse files
committed
Revert patch, doesn't do what it should:
* %Disallow changing default expression of a SERIAL columnDhanaraj M
1 parentcdd5178 commit33b4ad6

File tree

7 files changed

+14
-151
lines changed

7 files changed

+14
-151
lines changed

‎doc/TODO

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ Data Types
208208
The positive modulus result returned by NUMERICs might be considered
209209
inaccurate, in one sense.
210210

211-
* -Disallow changing DEFAULT expression of a SERIAL column
211+
* %Disallow changing DEFAULT expression of a SERIAL column?
212+
213+
This should be done only if the existing SERIAL problems cannot be
214+
fixed.
215+
212216
* %Disallow ALTER SEQUENCE changes for SERIAL sequences because pg_dump
213217
does not dump the changes
214218
* Fix data types where equality comparison isn't intuitive, e.g. box

‎doc/src/FAQ/TODO.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ <h1><a name="section_4">Data Types</a></h1>
190190
inaccurate, in one sense.
191191
</p>
192192
<ul>
193-
<li>-<em>Disallow changing DEFAULT expression of a SERIAL column</em>
193+
<li>%Disallow changing DEFAULT expression of a SERIAL column?
194+
<p> This should be done only if the existing SERIAL problems cannot be
195+
fixed.
196+
</p>
194197
</li><li>%Disallow ALTER SEQUENCE changes for SERIAL sequences because pg_dump
195198
does not dump the changes
196199
</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.55 2006/06/2703:21:54 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/dependency.c,v 1.56 2006/06/2718:35:05 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1927,89 +1927,3 @@ getRelationDescription(StringInfo buffer, Oid relid)
19271927

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

‎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.300 2006/06/2703:21:54 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.301 2006/06/2718:35:05 momjian Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -2133,50 +2133,3 @@ heap_truncate_find_FKs(List *relationIds)
21332133

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

‎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.187 2006/06/2703:43:19 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.188 2006/06/2718:35:05 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3404,11 +3404,6 @@ ATExecColumnDefault(Relation rel, const char *colName,
34043404
* safety, but at present we do not expect anything to depend on the
34053405
* default.
34063406
*/
3407-
if (newDefault)
3408-
RemoveSequenceDefault(RelationGetRelid(rel),attnum,DROP_RESTRICT, false);
3409-
else
3410-
RemoveSequenceDefault(RelationGetRelid(rel),attnum,DROP_RESTRICT, true);
3411-
34123407
RemoveAttrDefault(RelationGetRelid(rel),attnum,DROP_RESTRICT, false);
34133408

34143409
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.24 2006/06/2703:21:55 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/dependency.h,v 1.25 2006/06/2718:35:05 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.81 2006/06/2703:21:55 momjian Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/heap.h,v 1.82 2006/06/2718:35:05 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