188
188
static const struct dropmsgstrings dropmsgstringarray[] = {
189
189
{RELKIND_RELATION,
190
ERRCODE_UNDEFINED_TABLE,
191
gettext_noop("table \"%s\" does not exist"),
192
gettext_noop("table \"%s\" does not exist, skipping"),
193
gettext_noop("\"%s\" is not a table"),
194
gettext_noop("Use DROP TABLE to remove a table.")},
190
ERRCODE_UNDEFINED_TABLE,
191
gettext_noop("table \"%s\" does not exist"),
192
gettext_noop("table \"%s\" does not exist, skipping"),
193
gettext_noop("\"%s\" is not a table"),
194
gettext_noop("Use DROP TABLE to remove a table.")},
195
195
{RELKIND_SEQUENCE,
196
ERRCODE_UNDEFINED_TABLE,
197
gettext_noop("sequence \"%s\" does not exist"),
198
gettext_noop("sequence \"%s\" does not exist, skipping"),
199
gettext_noop("\"%s\" is not a sequence"),
200
gettext_noop("Use DROP SEQUENCE to remove a sequence.")},
196
ERRCODE_UNDEFINED_TABLE,
197
gettext_noop("sequence \"%s\" does not exist"),
198
gettext_noop("sequence \"%s\" does not exist, skipping"),
199
gettext_noop("\"%s\" is not a sequence"),
200
gettext_noop("Use DROP SEQUENCE to remove a sequence.")},
202
ERRCODE_UNDEFINED_TABLE,
203
gettext_noop("view \"%s\" does not exist"),
204
gettext_noop("view \"%s\" does not exist, skipping"),
205
gettext_noop("\"%s\" is not a view"),
206
gettext_noop("Use DROP VIEW to remove a view.")},
202
ERRCODE_UNDEFINED_TABLE,
203
gettext_noop("view \"%s\" does not exist"),
204
gettext_noop("view \"%s\" does not exist, skipping"),
205
gettext_noop("\"%s\" is not a view"),
206
gettext_noop("Use DROP VIEW to remove a view.")},
208
ERRCODE_UNDEFINED_OBJECT,
209
gettext_noop("index \"%s\" does not exist"),
210
gettext_noop("index \"%s\" does not exist, skipping"),
211
gettext_noop("\"%s\" is not an index"),
212
gettext_noop("Use DROP INDEX to remove an index.")},
208
ERRCODE_UNDEFINED_OBJECT,
209
gettext_noop("index \"%s\" does not exist"),
210
gettext_noop("index \"%s\" does not exist, skipping"),
211
gettext_noop("\"%s\" is not an index"),
212
gettext_noop("Use DROP INDEX to remove an index.")},
213
213
{RELKIND_COMPOSITE_TYPE,
214
ERRCODE_UNDEFINED_OBJECT,
215
gettext_noop("type \"%s\" does not exist"),
216
gettext_noop("type \"%s\" does not exist, skipping"),
217
gettext_noop("\"%s\" is not a type"),
218
gettext_noop("Use DROP TYPE to remove a type.")},
214
ERRCODE_UNDEFINED_OBJECT,
215
gettext_noop("type \"%s\" does not exist"),
216
gettext_noop("type \"%s\" does not exist, skipping"),
217
gettext_noop("\"%s\" is not a type"),
218
gettext_noop("Use DROP TYPE to remove a type.")},
219
219
{'\0', 0, NULL, NULL, NULL, NULL}
290
290
static void ATExecAddIndex(AlteredTableInfo *tab, Relation rel,
291
291
IndexStmt *stmt, bool is_rebuild);
292
292
static void ATExecAddConstraint(List **wqueue,
293
AlteredTableInfo *tab, Relation rel,
294
Node *newConstraint, bool recurse);
293
AlteredTableInfo *tab, Relation rel,
294
Node *newConstraint, bool recurse);
295
295
static void ATAddCheckConstraint(List **wqueue,
296
AlteredTableInfo *tab, Relation rel,
298
bool recurse, bool recursing);
296
AlteredTableInfo *tab, Relation rel,
298
bool recurse, bool recursing);
299
299
static void ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
300
300
FkConstraint *fkconstraint);
301
301
static void ATExecDropConstraint(Relation rel, const char *constrName,
302
DropBehavior behavior,
303
bool recurse, bool recursing);
302
DropBehavior behavior,
303
bool recurse, bool recursing);
304
304
static void ATPrepAlterColumnType(List **wqueue,
305
305
AlteredTableInfo *tab, Relation rel,
306
306
bool recurse, bool recursing,
448
448
* Find columns with default values and prepare for insertion of the
449
449
* defaults. Pre-cooked (that is, inherited) defaults go into a list of
450
450
* CookedConstraint structs that we'll pass to heap_create_with_catalog,
451
* while raw defaults go into a list of RawColumnDefault structs that
452
* will be processed by AddRelationNewConstraints. (We can't deal with
453
* raw expressions until we can do transformExpr.)
451
* while raw defaults go into a list of RawColumnDefault structs that will
452
* be processed by AddRelationNewConstraints. (We can't deal with raw
453
* expressions until we can do transformExpr.)
455
455
* We can set the atthasdef flags now in the tuple descriptor; this just
456
456
* saves StoreAttrDefault from having to do an immediate update of the
865
* If we are asked to restart sequences, find all the sequences,
866
* lock them (we only need AccessShareLock because that's all that
867
* ALTER SEQUENCE takes), and check permissions. We want to do this
868
* early since it's pointless to do all the truncation work only to fail
869
* on sequence permissions.
865
* If we are asked to restart sequences, find all the sequences, lock them
866
* (we only need AccessShareLock because that's all that ALTER SEQUENCE
867
* takes), and check permissions. We want to do this early since it's
868
* pointless to do all the truncation work only to fail on sequence
871
871
if (stmt->restart_seqs)
998
998
* Lastly, restart any owned sequences if we were asked to. This is done
999
* last because it's nontransactional: restarts will not roll back if
1000
* we abort later. Hence it's important to postpone them as long as
999
* last because it's nontransactional: restarts will not roll back if we
1000
* abort later. Hence it's important to postpone them as long as
1001
1001
* possible. (This is also a big reason why we locked and
1002
1002
* permission-checked the sequences beforehand.)
1004
1004
if (stmt->restart_seqs)
1006
List *options = list_make1(makeDefElem("restart", NULL));
1006
List *options = list_make1(makeDefElem("restart", NULL));
1008
1008
foreach(cell, seq_relids)
1010
Oid seq_relid = lfirst_oid(cell);
1010
Oid seq_relid = lfirst_oid(cell);
1012
1012
AlterSequenceInternal(seq_relid, options);
3690
3694
* returned by AddRelationNewConstraints, so that the right thing happens
3691
3695
* when a datatype's default applies.
3693
* We skip this step completely for views. For a view, we can only get
3697
* We skip this step completely for views. For a view, we can only get
3694
3698
* here from CREATE OR REPLACE VIEW, which historically doesn't set up
3695
* defaults, not even for domain-typed columns. And in any case we mustn't
3696
* invoke Phase 3 on a view, since it has no storage.
3699
* defaults, not even for domain-typed columns. And in any case we
3700
* mustn't invoke Phase 3 on a view, since it has no storage.
3698
3702
if (relkind != RELKIND_VIEW && attribute.attnum > 0)
5400
5401
/* Don't drop inherited constraints */
5401
5402
if (con->coninhcount > 0 && !recursing)
5403
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
5404
errmsg("cannot drop inherited constraint \"%s\" of relation \"%s\"",
5405
constrName, RelationGetRelationName(rel))));
5404
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
5405
errmsg("cannot drop inherited constraint \"%s\" of relation \"%s\"",
5406
constrName, RelationGetRelationName(rel))));
5407
5408
/* Right now only CHECK constraints can be inherited */
5408
5409
if (con->contype == CONSTRAINT_CHECK)
6619
6620
datum = SysCacheGetAttr(RELOID, tuple, Anum_pg_class_reloptions, &isnull);
6621
6622
newOptions = transformRelOptions(isnull ? (Datum) 0 : datum,
6622
defList, "toast", validnsps, false, isReset);
6623
defList, "toast", validnsps, false, isReset);
6624
6625
(void) heap_reloptions(RELKIND_TOASTVALUE, newOptions, true);