diff options
author | Itagaki Takahiro <itagaki.takahiro@gmail.com> | 2010-01-21 06:11:46 +0000 |
---|---|---|
committer | Itagaki Takahiro <itagaki.takahiro@gmail.com> | 2010-01-21 06:11:46 +0000 |
commit | 3b992cf5904c6149d5b8d3b4a86a590f3d057a41 (patch) | |
tree | 4b478a047917a4911e2b45a0c1a63efc7399be49 /src/backend/utils/adt/ruleutils.c | |
parent | 58565d78db67cfb4752ef3d3e315aa9ce3c9d946 (diff) | |
download | postgresql-3b992cf5904c6149d5b8d3b4a86a590f3d057a41.tar.gz postgresql-3b992cf5904c6149d5b8d3b4a86a590f3d057a41.zip |
Adjust psql to use pg_get_triggerdef(pretty=true) to remove extra ()'s
from description of triggers with WHEN clause.
Thanks to Brad T. Sliger for the review.
Diffstat (limited to 'src/backend/utils/adt/ruleutils.c')
-rw-r--r-- | src/backend/utils/adt/ruleutils.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 2eeb0bc5152..6e81a88b304 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.319 2010/01/17 22:56:22 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.320 2010/01/21 06:11:45 itagaki Exp $ * *------------------------------------------------------------------------- */ @@ -518,10 +518,9 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) initStringInfo(&buf); tgname = NameStr(trigrec->tgname); - appendStringInfo(&buf, "CREATE %sTRIGGER %s", + appendStringInfo(&buf, "CREATE %sTRIGGER %s ", OidIsValid(trigrec->tgconstraint) ? "CONSTRAINT " : "", quote_identifier(tgname)); - appendStringInfoString(&buf, pretty ? "\n " : " "); if (TRIGGER_FOR_BEFORE(trigrec->tgtype)) appendStringInfo(&buf, "BEFORE"); @@ -573,33 +572,27 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) appendStringInfo(&buf, " TRUNCATE"); findx++; } - appendStringInfo(&buf, " ON %s", + appendStringInfo(&buf, " ON %s ", generate_relation_name(trigrec->tgrelid, NIL)); - appendStringInfoString(&buf, pretty ? "\n " : " "); if (OidIsValid(trigrec->tgconstraint)) { if (OidIsValid(trigrec->tgconstrrelid)) - { - appendStringInfo(&buf, "FROM %s", + appendStringInfo(&buf, "FROM %s ", generate_relation_name(trigrec->tgconstrrelid, NIL)); - appendStringInfoString(&buf, pretty ? "\n " : " "); - } if (!trigrec->tgdeferrable) appendStringInfo(&buf, "NOT "); appendStringInfo(&buf, "DEFERRABLE INITIALLY "); if (trigrec->tginitdeferred) - appendStringInfo(&buf, "DEFERRED"); + appendStringInfo(&buf, "DEFERRED "); else - appendStringInfo(&buf, "IMMEDIATE"); - appendStringInfoString(&buf, pretty ? "\n " : " "); + appendStringInfo(&buf, "IMMEDIATE "); } if (TRIGGER_FOR_ROW(trigrec->tgtype)) - appendStringInfo(&buf, "FOR EACH ROW"); + appendStringInfo(&buf, "FOR EACH ROW "); else - appendStringInfo(&buf, "FOR EACH STATEMENT"); - appendStringInfoString(&buf, pretty ? "\n " : " "); + appendStringInfo(&buf, "FOR EACH STATEMENT "); /* If the trigger has a WHEN qualification, add that */ value = fastgetattr(ht_trig, Anum_pg_trigger_tgqual, @@ -643,12 +636,12 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) context.windowClause = NIL; context.windowTList = NIL; context.varprefix = true; - context.prettyFlags = pretty ? PRETTYFLAG_PAREN | PRETTYFLAG_INDENT : 0; + context.prettyFlags = pretty ? PRETTYFLAG_PAREN : 0; context.indentLevel = PRETTYINDENT_STD; get_rule_expr(qual, &context, false); - appendStringInfo(&buf, ")%s", pretty ? "\n " : " "); + appendStringInfo(&buf, ") "); } appendStringInfo(&buf, "EXECUTE PROCEDURE %s(", |