mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
ALTER TABLE DROP COLUMN works. Patch by Christopher Kings-Lynne,
code review by Tom Lane. Remaining issues: functions that take or return tuple types are likely to break if one drops (or adds!) a column in the table defining the type. Need to think about what to do here. Along the way: some code review for recent COPY changes; mark system columns attnotnull = true where appropriate, per discussion a month ago.
This commit is contained in:
67
src/backend/utils/cache/syscache.c
vendored
67
src/backend/utils/cache/syscache.c
vendored
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.84 2002/07/25 10:07:12 ishii Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.85 2002/08/02 18:15:08 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* These routines allow the parser/planner/executor to perform
|
||||
@ -622,6 +622,71 @@ GetSysCacheOid(int cacheId,
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SearchSysCacheAttName
|
||||
*
|
||||
* This routine is equivalent to SearchSysCache on the ATTNAME cache,
|
||||
* except that it will return NULL if the found attribute is marked
|
||||
* attisdropped. This is convenient for callers that want to act as
|
||||
* though dropped attributes don't exist.
|
||||
*/
|
||||
HeapTuple
|
||||
SearchSysCacheAttName(Oid relid, const char *attname)
|
||||
{
|
||||
HeapTuple tuple;
|
||||
|
||||
tuple = SearchSysCache(ATTNAME,
|
||||
ObjectIdGetDatum(relid),
|
||||
CStringGetDatum(attname),
|
||||
0, 0);
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
return NULL;
|
||||
if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
|
||||
{
|
||||
ReleaseSysCache(tuple);
|
||||
return NULL;
|
||||
}
|
||||
return tuple;
|
||||
}
|
||||
|
||||
/*
|
||||
* SearchSysCacheCopyAttName
|
||||
*
|
||||
* As above, an attisdropped-aware version of SearchSysCacheCopy.
|
||||
*/
|
||||
HeapTuple
|
||||
SearchSysCacheCopyAttName(Oid relid, const char *attname)
|
||||
{
|
||||
HeapTuple tuple,
|
||||
newtuple;
|
||||
|
||||
tuple = SearchSysCacheAttName(relid, attname);
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
return tuple;
|
||||
newtuple = heap_copytuple(tuple);
|
||||
ReleaseSysCache(tuple);
|
||||
return newtuple;
|
||||
}
|
||||
|
||||
/*
|
||||
* SearchSysCacheExistsAttName
|
||||
*
|
||||
* As above, an attisdropped-aware version of SearchSysCacheExists.
|
||||
*/
|
||||
bool
|
||||
SearchSysCacheExistsAttName(Oid relid, const char *attname)
|
||||
{
|
||||
HeapTuple tuple;
|
||||
|
||||
tuple = SearchSysCacheAttName(relid, attname);
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
return false;
|
||||
ReleaseSysCache(tuple);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SysCacheGetAttr
|
||||
*
|
||||
|
Reference in New Issue
Block a user