* ALTER TABLE ALTER COLUMN CHECK NOT NULL * * This doesn't exist in the grammar, but we generate AT_CheckNotNull * commands against the partitions of a partitioned table if the user * writes ALTER TABLE ONLY ... SET NOT NULL on the partitioned table, * or tries to create a primary key on it (which internally creates * AT_SetNotNull on the partitioned table). Such a command doesn't * allow
| 9302 | * For now we need only check for the presence of the flag. |
| 9303 | */ |
| 9304 | static void |
| 9305 | ATExecCheckNotNull(AlteredTableInfo *tab, Relation rel, |
| 9306 | const char *colName, LOCKMODE lockmode) |
| 9307 | { |
| 9308 | HeapTuple tuple; |
| 9309 | |
| 9310 | tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName); |
| 9311 | |
| 9312 | if (!HeapTupleIsValid(tuple)) |
| 9313 | ereport(ERROR, |
| 9314 | (errcode(ERRCODE_UNDEFINED_COLUMN), |
| 9315 | errmsg("column \"%s\" of relation \"%s\" does not exist", |
| 9316 | colName, RelationGetRelationName(rel)))); |
| 9317 | |
| 9318 | if (!((Form_pg_attribute) GETSTRUCT(tuple))->attnotnull) |
| 9319 | ereport(ERROR, |
| 9320 | (errcode(ERRCODE_INVALID_TABLE_DEFINITION), |
| 9321 | errmsg("constraint must be added to child tables too"), |
| 9322 | errdetail("Column \"%s\" of relation \"%s\" is not already NOT NULL.", |
| 9323 | colName, RelationGetRelationName(rel)), |
| 9324 | errhint("Do not specify the ONLY keyword."))); |
| 9325 | |
| 9326 | ReleaseSysCache(tuple); |
| 9327 | } |
| 9328 | |
| 9329 | /* |
| 9330 | * NotNullImpliedByRelConstraints |
no test coverage detected