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

Commitc26a44d

Browse files
author
Hiroshi Inoue
committed
Removed obsolete DROP_COLUMN_HACK stuff.
1 parentb4bedfa commitc26a44d

File tree

5 files changed

+5
-331
lines changed

5 files changed

+5
-331
lines changed

‎src/backend/commands/command.c

Lines changed: 1 addition & 299 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.171 2002/04/01 22:36:09 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.172 2002/04/02 08:51:50 inoue Exp $
1212
*
1313
* NOTES
1414
* The PerformAddAttribute() code, like most of the relation
@@ -1115,140 +1115,6 @@ AlterTableAlterColumnFlags(Oid myrelid,
11151115
}
11161116

11171117

1118-
#ifdef_DROP_COLUMN_HACK__
1119-
/*
1120-
*ALTER TABLE DROP COLUMN trial implementation
1121-
*/
1122-
1123-
/*
1124-
*find a specified attribute in a node entry
1125-
*/
1126-
staticbool
1127-
find_attribute_walker(Node*node,int*attnump)
1128-
{
1129-
if (node==NULL)
1130-
return false;
1131-
if (IsA(node,Var))
1132-
{
1133-
Var*var= (Var*)node;
1134-
1135-
if (var->varlevelsup==0&&var->varno==1&&
1136-
var->varattno==*attnump)
1137-
return true;
1138-
}
1139-
returnexpression_tree_walker(node,find_attribute_walker,
1140-
(void*)attnump);
1141-
}
1142-
1143-
staticbool
1144-
find_attribute_in_node(Node*node,intattnum)
1145-
{
1146-
returnfind_attribute_walker(node,&attnum);
1147-
}
1148-
1149-
/*
1150-
*Remove/check references for the column
1151-
*/
1152-
staticbool
1153-
RemoveColumnReferences(Oidreloid,intattnum,boolcheckonly,HeapTuplereltup)
1154-
{
1155-
RelationindexRelation,
1156-
rcrel;
1157-
ScanKeyDataentry;
1158-
HeapScanDescscan;
1159-
void*sysscan;
1160-
HeapTuplehtup,
1161-
indexTuple;
1162-
Form_pg_indexindex;
1163-
Form_pg_classpgcform= (Form_pg_class)NULL;
1164-
inti;
1165-
boolcheckok= true;
1166-
1167-
1168-
if (!checkonly)
1169-
pgcform= (Form_pg_class)GETSTRUCT(reltup);
1170-
1171-
/*
1172-
* Remove/check constraints here
1173-
*/
1174-
ScanKeyEntryInitialize(&entry, (bits16)0x0,
1175-
Anum_pg_relcheck_rcrelid,
1176-
(RegProcedure)F_OIDEQ,
1177-
ObjectIdGetDatum(reloid));
1178-
1179-
rcrel=heap_openr(RelCheckRelationName,RowExclusiveLock);
1180-
sysscan=systable_beginscan(rcrel,RelCheckIndex, true,
1181-
SnapshotNow,
1182-
1,&entry);
1183-
1184-
while (HeapTupleIsValid(htup=systable_getnext(sysscan)))
1185-
{
1186-
Form_pg_relcheckrelcheck;
1187-
char*ccbin;
1188-
Node*node;
1189-
1190-
relcheck= (Form_pg_relcheck)GETSTRUCT(htup);
1191-
ccbin=DatumGetCString(DirectFunctionCall1(textout,
1192-
PointerGetDatum(&relcheck->rcbin)));
1193-
node=stringToNode(ccbin);
1194-
pfree(ccbin);
1195-
if (find_attribute_in_node(node,attnum))
1196-
{
1197-
if (checkonly)
1198-
{
1199-
checkok= false;
1200-
elog(ERROR,"target column is used in a constraint");
1201-
}
1202-
else
1203-
{
1204-
simple_heap_delete(rcrel,&htup->t_self);
1205-
pgcform->relchecks--;
1206-
}
1207-
}
1208-
}
1209-
1210-
systable_endscan(sysscan);
1211-
heap_close(rcrel,NoLock);
1212-
1213-
/*
1214-
* What to do with triggers/rules/views/procedues ?
1215-
*/
1216-
1217-
/*
1218-
* Remove/check indexes
1219-
*/
1220-
indexRelation=heap_openr(IndexRelationName,RowExclusiveLock);
1221-
ScanKeyEntryInitialize(&entry,0,Anum_pg_index_indrelid,F_OIDEQ,
1222-
ObjectIdGetDatum(reloid));
1223-
scan=heap_beginscan(indexRelation, false,SnapshotNow,1,&entry);
1224-
while (HeapTupleIsValid(indexTuple=heap_getnext(scan,0)))
1225-
{
1226-
index= (Form_pg_index)GETSTRUCT(indexTuple);
1227-
for (i=0;i<INDEX_MAX_KEYS;i++)
1228-
{
1229-
if (index->indkey[i]==InvalidAttrNumber)
1230-
break;
1231-
elseif (index->indkey[i]==attnum)
1232-
{
1233-
if (checkonly)
1234-
{
1235-
checkok= false;
1236-
elog(ERROR,"target column is used in an index");
1237-
}
1238-
else
1239-
{
1240-
index_drop(index->indexrelid);
1241-
}
1242-
break;
1243-
}
1244-
}
1245-
}
1246-
heap_endscan(scan);
1247-
heap_close(indexRelation,NoLock);
1248-
1249-
returncheckok;
1250-
}
1251-
#endif/* _DROP_COLUMN_HACK__ */
12521118

12531119
/*
12541120
* ALTER TABLE DROP COLUMN
@@ -1258,171 +1124,7 @@ AlterTableDropColumn(Oid myrelid,
12581124
boolinh,constchar*colName,
12591125
intbehavior)
12601126
{
1261-
#ifdef_DROP_COLUMN_HACK__
1262-
Relationrel,
1263-
attrdesc;
1264-
HeapTuplereltup;
1265-
HeapTupleDataclasstuple;
1266-
Bufferbuffer;
1267-
Form_pg_attributeattribute;
1268-
HeapTupletup;
1269-
Relationidescs[Num_pg_attr_indices];
1270-
intattnum;
1271-
boolhasindex;
1272-
chardropColname[32];
1273-
1274-
if (inh)
1275-
elog(ERROR,"ALTER TABLE / DROP COLUMN with inherit option is not supported yet");
1276-
1277-
/*
1278-
* Grab an exclusive lock on the target table, which we will NOT
1279-
* release until end of transaction.
1280-
*/
1281-
rel=heap_open(myrelid,AccessExclusiveLock);
1282-
1283-
if (rel->rd_rel->relkind!=RELKIND_RELATION)
1284-
elog(ERROR,"ALTER TABLE: relation \"%s\" is not a table",
1285-
RelationGetRelationName(rel));
1286-
1287-
if (!allowSystemTableMods
1288-
&&IsSystemRelationName(RelationGetRelationName(rel)))
1289-
elog(ERROR,"ALTER TABLE: relation \"%s\" is a system catalog",
1290-
RelationGetRelationName(rel));
1291-
1292-
/*
1293-
* permissions checking. this would normally be done in utility.c,
1294-
* but this particular routine is recursive.
1295-
*
1296-
* normally, only the owner of a class can change its schema.
1297-
*/
1298-
if (!pg_class_ownercheck(myrelid,GetUserId()))
1299-
elog(ERROR,"ALTER TABLE: \"%s\": permission denied",
1300-
RelationGetRelationName(rel));
1301-
1302-
heap_close(rel,NoLock);/* close rel but keep lock! */
1303-
1304-
/*
1305-
* What to do when rel has inheritors ?
1306-
*/
1307-
if (length(find_all_inheritors(myrelid))>1)
1308-
elog(ERROR,"ALTER TABLE: cannot drop a column on table that is inherited from");
1309-
1310-
/*
1311-
* lock the pg_class tuple for update
1312-
*/
1313-
rel=heap_openr(RelationRelationName,RowExclusiveLock);
1314-
reltup=SearchSysCache(RELOID,
1315-
ObjectIdGetDatum(myrelid),
1316-
0,0,0);
1317-
if (!HeapTupleIsValid(reltup))
1318-
{
1319-
Relationmyrel;
1320-
char*myrelname;
1321-
1322-
myrel=heap_open(myrelid,AccessExclusiveLock);
1323-
myrelname=pstrdup(RelationGetRelationName(myrel));
1324-
heap_close(myrel,AccessExclusiveLock);
1325-
1326-
elog(ERROR,"ALTER TABLE: relation \"%s\" not found",
1327-
myrelname);
1328-
}
1329-
classtuple.t_self=reltup->t_self;
1330-
ReleaseSysCache(reltup);
1331-
1332-
switch (heap_mark4update(rel,&classtuple,&buffer))
1333-
{
1334-
caseHeapTupleSelfUpdated:
1335-
caseHeapTupleMayBeUpdated:
1336-
break;
1337-
default:
1338-
elog(ERROR,"couldn't lock pg_class tuple");
1339-
}
1340-
reltup=heap_copytuple(&classtuple);
1341-
ReleaseBuffer(buffer);
1342-
1343-
attrdesc=heap_openr(AttributeRelationName,RowExclusiveLock);
1344-
1345-
/*
1346-
* Get the target pg_attribute tuple and make a modifiable copy
1347-
*/
1348-
tup=SearchSysCacheCopy(ATTNAME,
1349-
ObjectIdGetDatum(myrelid),
1350-
PointerGetDatum(colName),
1351-
0,0);
1352-
if (!HeapTupleIsValid(tup))
1353-
{
1354-
Relationmyrel;
1355-
char*myrelname;
1356-
1357-
myrel=heap_open(myrelid,AccessExclusiveLock);
1358-
myrelname=pstrdup(RelationGetRelationName(myrel));
1359-
heap_close(myrel,AccessExclusiveLock);
1360-
1361-
elog(ERROR,"ALTER TABLE: column name \"%s\" doesn't exist in table \"%s\"",
1362-
colName,myrelname);
1363-
}
1364-
1365-
attribute= (Form_pg_attribute)GETSTRUCT(tup);
1366-
attnum=attribute->attnum;
1367-
if (attnum <=0)
1368-
elog(ERROR,"ALTER TABLE: column name \"%s\" was already dropped",
1369-
colName);
1370-
1371-
/*
1372-
* Check constraints/indices etc here
1373-
*/
1374-
if (behavior!=CASCADE)
1375-
{
1376-
if (!RemoveColumnReferences(myrelid,attnum, true,NULL))
1377-
elog(ERROR,"the column is referenced");
1378-
}
1379-
1380-
/*
1381-
* change the target pg_attribute tuple
1382-
*/
1383-
sprintf(dropColname,"*already Dropped*%d",attnum);
1384-
namestrcpy(&(attribute->attname),dropColname);
1385-
ATTRIBUTE_DROP_COLUMN(attribute);
1386-
1387-
simple_heap_update(attrdesc,&tup->t_self,tup);
1388-
hasindex= (!IsIgnoringSystemIndexes()&&RelationGetForm(attrdesc)->relhasindex);
1389-
if (hasindex)
1390-
{
1391-
CatalogOpenIndices(Num_pg_attr_indices,Name_pg_attr_indices,idescs);
1392-
CatalogIndexInsert(idescs,Num_pg_attr_indices,
1393-
attrdesc,tup);
1394-
CatalogCloseIndices(Num_pg_attr_indices,idescs);
1395-
}
1396-
heap_close(attrdesc,NoLock);
1397-
heap_freetuple(tup);
1398-
1399-
/* delete comment for this attribute only */
1400-
CreateComments(RelationGetRelid(rel),RelOid_pg_class,
1401-
(int32)attnum,NULL);
1402-
1403-
/* delete attrdef */
1404-
drop_default(myrelid,attnum);
1405-
1406-
/*
1407-
* Remove objects which reference this column
1408-
*/
1409-
if (behavior==CASCADE)
1410-
{
1411-
Relationridescs[Num_pg_class_indices];
1412-
1413-
RemoveColumnReferences(myrelid,attnum, false,reltup);
1414-
/* update pg_class tuple */
1415-
simple_heap_update(rel,&reltup->t_self,reltup);
1416-
CatalogOpenIndices(Num_pg_class_indices,Name_pg_class_indices,ridescs);
1417-
CatalogIndexInsert(ridescs,Num_pg_class_indices,rel,reltup);
1418-
CatalogCloseIndices(Num_pg_class_indices,ridescs);
1419-
}
1420-
1421-
heap_freetuple(reltup);
1422-
heap_close(rel,NoLock);
1423-
#else
14241127
elog(ERROR,"ALTER TABLE / DROP COLUMN is not implemented");
1425-
#endif/* _DROP_COLUMN_HACK__ */
14261128
}
14271129

14281130

‎src/backend/optimizer/prep/preptlist.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.50 2002/03/20 19:44:15 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.51 2002/04/02 08:51:51 inoue Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -198,11 +198,6 @@ expand_targetlist(List *tlist, int command_type,
198198
new_expr=build_column_default(rel,attrno);
199199
break;
200200
caseCMD_UPDATE:
201-
#ifdef_DROP_COLUMN_HACK__
202-
if (COLUMN_IS_DROPPED(att_tup))
203-
new_expr= (Node*)makeNullConst(atttype);
204-
else
205-
#endif/* _DROP_COLUMN_HACK__ */
206201
new_expr= (Node*)makeVar(result_relation,
207202
attrno,
208203
atttype,

‎src/backend/parser/parse_relation.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.66 2002/03/26 19:15:59 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.67 2002/04/02 08:51:51 inoue Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -855,11 +855,6 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte,
855855
{
856856
Form_pg_attributeattr=rel->rd_att->attrs[varattno];
857857

858-
#ifdef_DROP_COLUMN_HACK__
859-
if (COLUMN_IS_DROPPED(attr))
860-
continue;
861-
#endif/* _DROP_COLUMN_HACK__ */
862-
863858
if (colnames)
864859
{
865860
char*label;

‎src/backend/parser/parse_target.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.80 2002/03/29 19:06:12 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.81 2002/04/02 08:51:52 inoue Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -373,10 +373,6 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
373373
{
374374
ResTarget*col=makeNode(ResTarget);
375375

376-
#ifdef_DROP_COLUMN_HACK__
377-
if (COLUMN_IS_DROPPED(attr[i]))
378-
continue;
379-
#endif/* _DROP_COLUMN_HACK__ */
380376
col->name=pstrdup(NameStr(attr[i]->attname));
381377
col->indirection=NIL;
382378
col->val=NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp