mirror of
https://github.com/postgres/postgres.git
synced 2025-06-05 23:56:58 +03:00
Fix pg_dump's handling of event triggers.
pg_dump with the --clean option failed to emit DROP EVENT TRIGGER commands for event triggers. In a closely related oversight, it also did not emit ALTER OWNER commands for event triggers. Since only superusers can create event triggers, the latter oversight is of little practical consequence ... but if we're going to record an owner for event triggers, then surely pg_dump should preserve it. Per complaint from Greg Atkins. Back-patch to 9.3 where event triggers were introduced. Discussion: https://postgr.es/m/20170722191142.yi4e7tzcg3iacclg@gmail.com
This commit is contained in:
parent
6d9de660dc
commit
68a22bc69d
src/bin/pg_dump
@ -2994,6 +2994,7 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
|
||||
if (strcmp(type, "DATABASE") == 0 ||
|
||||
strcmp(type, "PROCEDURAL LANGUAGE") == 0 ||
|
||||
strcmp(type, "SCHEMA") == 0 ||
|
||||
strcmp(type, "EVENT TRIGGER") == 0 ||
|
||||
strcmp(type, "FOREIGN DATA WRAPPER") == 0 ||
|
||||
strcmp(type, "SERVER") == 0 ||
|
||||
strcmp(type, "USER MAPPING") == 0)
|
||||
@ -3037,7 +3038,7 @@ _getObjectDescription(PQExpBuffer buf, TocEntry *te, ArchiveHandle *AH)
|
||||
return;
|
||||
}
|
||||
|
||||
write_msg(modulename, "WARNING: don't know how to set owner for object type %s\n",
|
||||
write_msg(modulename, "WARNING: don't know how to set owner for object type \"%s\"\n",
|
||||
type);
|
||||
}
|
||||
|
||||
@ -3194,6 +3195,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
|
||||
strcmp(te->desc, "OPERATOR FAMILY") == 0 ||
|
||||
strcmp(te->desc, "PROCEDURAL LANGUAGE") == 0 ||
|
||||
strcmp(te->desc, "SCHEMA") == 0 ||
|
||||
strcmp(te->desc, "EVENT TRIGGER") == 0 ||
|
||||
strcmp(te->desc, "TABLE") == 0 ||
|
||||
strcmp(te->desc, "TYPE") == 0 ||
|
||||
strcmp(te->desc, "VIEW") == 0 ||
|
||||
@ -3227,7 +3229,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt, bool isDat
|
||||
}
|
||||
else
|
||||
{
|
||||
write_msg(modulename, "WARNING: don't know how to set owner for object type %s\n",
|
||||
write_msg(modulename, "WARNING: don't know how to set owner for object type \"%s\"\n",
|
||||
te->desc);
|
||||
}
|
||||
}
|
||||
|
@ -14496,6 +14496,7 @@ static void
|
||||
dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
|
||||
{
|
||||
PQExpBuffer query;
|
||||
PQExpBuffer delqry;
|
||||
PQExpBuffer labelq;
|
||||
|
||||
/* Skip if not to be dumped */
|
||||
@ -14503,6 +14504,7 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
|
||||
return;
|
||||
|
||||
query = createPQExpBuffer();
|
||||
delqry = createPQExpBuffer();
|
||||
labelq = createPQExpBuffer();
|
||||
|
||||
appendPQExpBuffer(query, "CREATE EVENT TRIGGER ");
|
||||
@ -14542,19 +14544,27 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
|
||||
}
|
||||
appendPQExpBuffer(query, ";\n");
|
||||
}
|
||||
|
||||
appendPQExpBuffer(delqry, "DROP EVENT TRIGGER %s;\n",
|
||||
fmtId(evtinfo->dobj.name));
|
||||
|
||||
appendPQExpBuffer(labelq, "EVENT TRIGGER %s",
|
||||
fmtId(evtinfo->dobj.name));
|
||||
|
||||
ArchiveEntry(fout, evtinfo->dobj.catId, evtinfo->dobj.dumpId,
|
||||
evtinfo->dobj.name, NULL, NULL, evtinfo->evtowner, false,
|
||||
evtinfo->dobj.name, NULL, NULL,
|
||||
evtinfo->evtowner, false,
|
||||
"EVENT TRIGGER", SECTION_POST_DATA,
|
||||
query->data, "", NULL, NULL, 0, NULL, NULL);
|
||||
query->data, delqry->data, NULL,
|
||||
NULL, 0,
|
||||
NULL, NULL);
|
||||
|
||||
dumpComment(fout, labelq->data,
|
||||
NULL, evtinfo->evtowner,
|
||||
evtinfo->dobj.catId, 0, evtinfo->dobj.dumpId);
|
||||
|
||||
destroyPQExpBuffer(query);
|
||||
destroyPQExpBuffer(delqry);
|
||||
destroyPQExpBuffer(labelq);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user