|
8 | 8 | * Portions Copyright (c) 1994, Regents of the University of California |
9 | 9 | * |
10 | 10 | * 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 $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -1927,89 +1927,3 @@ getRelationDescription(StringInfo buffer, Oid relid) |
1927 | 1927 |
|
1928 | 1928 | ReleaseSysCache(relTup); |
1929 | 1929 | } |
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 | | -} |