diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-02 18:15:10 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-08-02 18:15:10 +0000 |
commit | 38bb77a5d15aa022248488bc8c0147139ce120a9 (patch) | |
tree | d01573bceae2db61eb97421f91c6068ef8522b66 /src/backend/commands/analyze.c | |
parent | 5e6528adf726429463a5c1f3edf712f98d6b5f7e (diff) | |
download | postgresql-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/commands/analyze.c')
-rw-r--r-- | src/backend/commands/analyze.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 55069aa6feb..9844a5df0a9 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.39 2002/07/31 17:19:51 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.40 2002/08/02 18:15:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -27,6 +27,7 @@ #include "commands/vacuum.h" #include "miscadmin.h" #include "parser/parse_oper.h" +#include "parser/parse_relation.h" #include "utils/acl.h" #include "utils/builtins.h" #include "utils/datum.h" @@ -147,7 +148,6 @@ void analyze_rel(Oid relid, VacuumStmt *vacstmt) { Relation onerel; - Form_pg_attribute *attr; int attr_cnt, tcnt, i; @@ -234,9 +234,6 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) * * Note that system attributes are never analyzed. */ - attr = onerel->rd_att->attrs; - attr_cnt = onerel->rd_att->natts; - if (vacstmt->va_cols != NIL) { List *le; @@ -248,15 +245,8 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) { char *col = strVal(lfirst(le)); - for (i = 0; i < attr_cnt; i++) - { - if (namestrcmp(&(attr[i]->attname), col) == 0) - break; - } - if (i >= attr_cnt) - elog(ERROR, "ANALYZE: there is no attribute %s in %s", - col, RelationGetRelationName(onerel)); - vacattrstats[tcnt] = examine_attribute(onerel, i + 1); + i = attnameAttNum(onerel, col, false); + vacattrstats[tcnt] = examine_attribute(onerel, i); if (vacattrstats[tcnt] != NULL) tcnt++; } @@ -264,12 +254,13 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) } else { + attr_cnt = onerel->rd_att->natts; vacattrstats = (VacAttrStats **) palloc(attr_cnt * sizeof(VacAttrStats *)); tcnt = 0; - for (i = 0; i < attr_cnt; i++) + for (i = 1; i <= attr_cnt; i++) { - vacattrstats[tcnt] = examine_attribute(onerel, i + 1); + vacattrstats[tcnt] = examine_attribute(onerel, i); if (vacattrstats[tcnt] != NULL) tcnt++; } @@ -388,6 +379,10 @@ examine_attribute(Relation onerel, int attnum) Oid ltopr = InvalidOid; VacAttrStats *stats; + /* Don't analyze dropped columns */ + if (attr->attisdropped) + return NULL; + /* Don't analyze column if user has specified not to */ if (attr->attstattarget == 0) return NULL; |