aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/analyze.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-08-02 18:15:10 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-08-02 18:15:10 +0000
commit38bb77a5d15aa022248488bc8c0147139ce120a9 (patch)
treed01573bceae2db61eb97421f91c6068ef8522b66 /src/backend/parser/analyze.c
parent5e6528adf726429463a5c1f3edf712f98d6b5f7e (diff)
downloadpostgresql-38bb77a5d15aa022248488bc8c0147139ce120a9.tar.gz
postgresql-38bb77a5d15aa022248488bc8c0147139ce120a9.zip
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.
Diffstat (limited to 'src/backend/parser/analyze.c')
-rw-r--r--src/backend/parser/analyze.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 6337b61f2ac..e3d8ce070bc 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.239 2002/07/16 22:12:19 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.240 2002/08/02 18:15:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1143,6 +1143,8 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
Form_pg_attribute inhattr = rel->rd_att->attrs[count];
char *inhname = NameStr(inhattr->attname);
+ if (inhattr->attisdropped)
+ continue;
if (strcmp(key->name, inhname) == 0)
{
found = true;
@@ -1178,10 +1180,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
/* ALTER TABLE case: does column already exist? */
HeapTuple atttuple;
- atttuple = SearchSysCache(ATTNAME,
- ObjectIdGetDatum(cxt->relOid),
- PointerGetDatum(key->name),
- 0, 0);
+ atttuple = SearchSysCacheAttName(cxt->relOid, key->name);
if (HeapTupleIsValid(atttuple))
{
found = true;
@@ -2369,7 +2368,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
origTarget = (ResTarget *) lfirst(origTargetList);
updateTargetListEntry(pstate, tle, origTarget->name,
attnameAttNum(pstate->p_target_relation,
- origTarget->name),
+ origTarget->name, true),
origTarget->indirection);
origTargetList = lnext(origTargetList);
}
@@ -2820,11 +2819,14 @@ transformFkeyGetColType(CreateStmtContext *cxt, char *colname)
inh->relname);
for (count = 0; count < rel->rd_att->natts; count++)
{
- char *name = NameStr(rel->rd_att->attrs[count]->attname);
+ Form_pg_attribute inhattr = rel->rd_att->attrs[count];
+ char *inhname = NameStr(inhattr->attname);
- if (strcmp(name, colname) == 0)
+ if (inhattr->attisdropped)
+ continue;
+ if (strcmp(inhname, colname) == 0)
{
- result = rel->rd_att->attrs[count]->atttypid;
+ result = inhattr->atttypid;
heap_close(rel, NoLock);
return result;
}
@@ -2836,10 +2838,7 @@ transformFkeyGetColType(CreateStmtContext *cxt, char *colname)
{
HeapTuple atttuple;
- atttuple = SearchSysCache(ATTNAME,
- ObjectIdGetDatum(cxt->relOid),
- PointerGetDatum(colname),
- 0, 0);
+ atttuple = SearchSysCacheAttName(cxt->relOid, colname);
if (HeapTupleIsValid(atttuple))
{
result = ((Form_pg_attribute) GETSTRUCT(atttuple))->atttypid;