|
|
@ -483,7 +483,7 @@ pg_get_ruledef_worker(Oid ruleoid, int prettyFlags) |
|
|
|
if (spirc != SPI_OK_SELECT) |
|
|
|
if (spirc != SPI_OK_SELECT) |
|
|
|
elog(ERROR, "failed to get pg_rewrite tuple for rule %u", ruleoid); |
|
|
|
elog(ERROR, "failed to get pg_rewrite tuple for rule %u", ruleoid); |
|
|
|
if (SPI_processed != 1) |
|
|
|
if (SPI_processed != 1) |
|
|
|
appendStringInfo(&buf, "-"); |
|
|
|
appendStringInfoChar(&buf, '-'); |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -638,7 +638,7 @@ pg_get_viewdef_worker(Oid viewoid, int prettyFlags, int wrapColumn) |
|
|
|
if (spirc != SPI_OK_SELECT) |
|
|
|
if (spirc != SPI_OK_SELECT) |
|
|
|
elog(ERROR, "failed to get pg_rewrite tuple for view %u", viewoid); |
|
|
|
elog(ERROR, "failed to get pg_rewrite tuple for view %u", viewoid); |
|
|
|
if (SPI_processed != 1) |
|
|
|
if (SPI_processed != 1) |
|
|
|
appendStringInfo(&buf, "Not a view"); |
|
|
|
appendStringInfoString(&buf, "Not a view"); |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
/*
|
|
|
|
/*
|
|
|
@ -725,33 +725,33 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) |
|
|
|
quote_identifier(tgname)); |
|
|
|
quote_identifier(tgname)); |
|
|
|
|
|
|
|
|
|
|
|
if (TRIGGER_FOR_BEFORE(trigrec->tgtype)) |
|
|
|
if (TRIGGER_FOR_BEFORE(trigrec->tgtype)) |
|
|
|
appendStringInfo(&buf, "BEFORE"); |
|
|
|
appendStringInfoString(&buf, "BEFORE"); |
|
|
|
else if (TRIGGER_FOR_AFTER(trigrec->tgtype)) |
|
|
|
else if (TRIGGER_FOR_AFTER(trigrec->tgtype)) |
|
|
|
appendStringInfo(&buf, "AFTER"); |
|
|
|
appendStringInfoString(&buf, "AFTER"); |
|
|
|
else if (TRIGGER_FOR_INSTEAD(trigrec->tgtype)) |
|
|
|
else if (TRIGGER_FOR_INSTEAD(trigrec->tgtype)) |
|
|
|
appendStringInfo(&buf, "INSTEAD OF"); |
|
|
|
appendStringInfoString(&buf, "INSTEAD OF"); |
|
|
|
else |
|
|
|
else |
|
|
|
elog(ERROR, "unexpected tgtype value: %d", trigrec->tgtype); |
|
|
|
elog(ERROR, "unexpected tgtype value: %d", trigrec->tgtype); |
|
|
|
|
|
|
|
|
|
|
|
if (TRIGGER_FOR_INSERT(trigrec->tgtype)) |
|
|
|
if (TRIGGER_FOR_INSERT(trigrec->tgtype)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(&buf, " INSERT"); |
|
|
|
appendStringInfoString(&buf, " INSERT"); |
|
|
|
findx++; |
|
|
|
findx++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (TRIGGER_FOR_DELETE(trigrec->tgtype)) |
|
|
|
if (TRIGGER_FOR_DELETE(trigrec->tgtype)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (findx > 0) |
|
|
|
if (findx > 0) |
|
|
|
appendStringInfo(&buf, " OR DELETE"); |
|
|
|
appendStringInfoString(&buf, " OR DELETE"); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(&buf, " DELETE"); |
|
|
|
appendStringInfoString(&buf, " DELETE"); |
|
|
|
findx++; |
|
|
|
findx++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (TRIGGER_FOR_UPDATE(trigrec->tgtype)) |
|
|
|
if (TRIGGER_FOR_UPDATE(trigrec->tgtype)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (findx > 0) |
|
|
|
if (findx > 0) |
|
|
|
appendStringInfo(&buf, " OR UPDATE"); |
|
|
|
appendStringInfoString(&buf, " OR UPDATE"); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(&buf, " UPDATE"); |
|
|
|
appendStringInfoString(&buf, " UPDATE"); |
|
|
|
findx++; |
|
|
|
findx++; |
|
|
|
/* tgattr is first var-width field, so OK to access directly */ |
|
|
|
/* tgattr is first var-width field, so OK to access directly */ |
|
|
|
if (trigrec->tgattr.dim1 > 0) |
|
|
|
if (trigrec->tgattr.dim1 > 0) |
|
|
@ -774,9 +774,9 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) |
|
|
|
if (TRIGGER_FOR_TRUNCATE(trigrec->tgtype)) |
|
|
|
if (TRIGGER_FOR_TRUNCATE(trigrec->tgtype)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (findx > 0) |
|
|
|
if (findx > 0) |
|
|
|
appendStringInfo(&buf, " OR TRUNCATE"); |
|
|
|
appendStringInfoString(&buf, " OR TRUNCATE"); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(&buf, " TRUNCATE"); |
|
|
|
appendStringInfoString(&buf, " TRUNCATE"); |
|
|
|
findx++; |
|
|
|
findx++; |
|
|
|
} |
|
|
|
} |
|
|
|
appendStringInfo(&buf, " ON %s ", |
|
|
|
appendStringInfo(&buf, " ON %s ", |
|
|
@ -788,18 +788,18 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) |
|
|
|
appendStringInfo(&buf, "FROM %s ", |
|
|
|
appendStringInfo(&buf, "FROM %s ", |
|
|
|
generate_relation_name(trigrec->tgconstrrelid, NIL)); |
|
|
|
generate_relation_name(trigrec->tgconstrrelid, NIL)); |
|
|
|
if (!trigrec->tgdeferrable) |
|
|
|
if (!trigrec->tgdeferrable) |
|
|
|
appendStringInfo(&buf, "NOT "); |
|
|
|
appendStringInfoString(&buf, "NOT "); |
|
|
|
appendStringInfo(&buf, "DEFERRABLE INITIALLY "); |
|
|
|
appendStringInfoString(&buf, "DEFERRABLE INITIALLY "); |
|
|
|
if (trigrec->tginitdeferred) |
|
|
|
if (trigrec->tginitdeferred) |
|
|
|
appendStringInfo(&buf, "DEFERRED "); |
|
|
|
appendStringInfoString(&buf, "DEFERRED "); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(&buf, "IMMEDIATE "); |
|
|
|
appendStringInfoString(&buf, "IMMEDIATE "); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (TRIGGER_FOR_ROW(trigrec->tgtype)) |
|
|
|
if (TRIGGER_FOR_ROW(trigrec->tgtype)) |
|
|
|
appendStringInfo(&buf, "FOR EACH ROW "); |
|
|
|
appendStringInfoString(&buf, "FOR EACH ROW "); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(&buf, "FOR EACH STATEMENT "); |
|
|
|
appendStringInfoString(&buf, "FOR EACH STATEMENT "); |
|
|
|
|
|
|
|
|
|
|
|
/* If the trigger has a WHEN qualification, add that */ |
|
|
|
/* If the trigger has a WHEN qualification, add that */ |
|
|
|
value = fastgetattr(ht_trig, Anum_pg_trigger_tgqual, |
|
|
|
value = fastgetattr(ht_trig, Anum_pg_trigger_tgqual, |
|
|
@ -859,7 +859,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) |
|
|
|
|
|
|
|
|
|
|
|
get_rule_expr(qual, &context, false); |
|
|
|
get_rule_expr(qual, &context, false); |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(&buf, ") "); |
|
|
|
appendStringInfoString(&buf, ") "); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(&buf, "EXECUTE PROCEDURE %s(", |
|
|
|
appendStringInfo(&buf, "EXECUTE PROCEDURE %s(", |
|
|
@ -880,7 +880,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) |
|
|
|
for (i = 0; i < trigrec->tgnargs; i++) |
|
|
|
for (i = 0; i < trigrec->tgnargs; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (i > 0) |
|
|
|
if (i > 0) |
|
|
|
appendStringInfo(&buf, ", "); |
|
|
|
appendStringInfoString(&buf, ", "); |
|
|
|
simple_quote_literal(&buf, p); |
|
|
|
simple_quote_literal(&buf, p); |
|
|
|
/* advance p to next string embedded in tgargs */ |
|
|
|
/* advance p to next string embedded in tgargs */ |
|
|
|
while (*p) |
|
|
|
while (*p) |
|
|
@ -890,7 +890,7 @@ pg_get_triggerdef_worker(Oid trigid, bool pretty) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* We deliberately do not put semi-colon at end */ |
|
|
|
/* We deliberately do not put semi-colon at end */ |
|
|
|
appendStringInfo(&buf, ")"); |
|
|
|
appendStringInfoChar(&buf, ')'); |
|
|
|
|
|
|
|
|
|
|
|
/* Clean up */ |
|
|
|
/* Clean up */ |
|
|
|
systable_endscan(tgscan); |
|
|
|
systable_endscan(tgscan); |
|
|
@ -1154,15 +1154,15 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, |
|
|
|
/* if it supports sort ordering, report DESC and NULLS opts */ |
|
|
|
/* if it supports sort ordering, report DESC and NULLS opts */ |
|
|
|
if (opt & INDOPTION_DESC) |
|
|
|
if (opt & INDOPTION_DESC) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(&buf, " DESC"); |
|
|
|
appendStringInfoString(&buf, " DESC"); |
|
|
|
/* NULLS FIRST is the default in this case */ |
|
|
|
/* NULLS FIRST is the default in this case */ |
|
|
|
if (!(opt & INDOPTION_NULLS_FIRST)) |
|
|
|
if (!(opt & INDOPTION_NULLS_FIRST)) |
|
|
|
appendStringInfo(&buf, " NULLS LAST"); |
|
|
|
appendStringInfoString(&buf, " NULLS LAST"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (opt & INDOPTION_NULLS_FIRST) |
|
|
|
if (opt & INDOPTION_NULLS_FIRST) |
|
|
|
appendStringInfo(&buf, " NULLS FIRST"); |
|
|
|
appendStringInfoString(&buf, " NULLS FIRST"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1312,7 +1312,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, |
|
|
|
const char *string; |
|
|
|
const char *string; |
|
|
|
|
|
|
|
|
|
|
|
/* Start off the constraint definition */ |
|
|
|
/* Start off the constraint definition */ |
|
|
|
appendStringInfo(&buf, "FOREIGN KEY ("); |
|
|
|
appendStringInfoString(&buf, "FOREIGN KEY ("); |
|
|
|
|
|
|
|
|
|
|
|
/* Fetch and build referencing-column list */ |
|
|
|
/* Fetch and build referencing-column list */ |
|
|
|
val = SysCacheGetAttr(CONSTROID, tup, |
|
|
|
val = SysCacheGetAttr(CONSTROID, tup, |
|
|
@ -1337,7 +1337,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, |
|
|
|
|
|
|
|
|
|
|
|
decompile_column_index_array(val, conForm->confrelid, &buf); |
|
|
|
decompile_column_index_array(val, conForm->confrelid, &buf); |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(&buf, ")"); |
|
|
|
appendStringInfoChar(&buf, ')'); |
|
|
|
|
|
|
|
|
|
|
|
/* Add match type */ |
|
|
|
/* Add match type */ |
|
|
|
switch (conForm->confmatchtype) |
|
|
|
switch (conForm->confmatchtype) |
|
|
@ -1423,9 +1423,9 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, |
|
|
|
|
|
|
|
|
|
|
|
/* Start off the constraint definition */ |
|
|
|
/* Start off the constraint definition */ |
|
|
|
if (conForm->contype == CONSTRAINT_PRIMARY) |
|
|
|
if (conForm->contype == CONSTRAINT_PRIMARY) |
|
|
|
appendStringInfo(&buf, "PRIMARY KEY ("); |
|
|
|
appendStringInfoString(&buf, "PRIMARY KEY ("); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(&buf, "UNIQUE ("); |
|
|
|
appendStringInfoString(&buf, "UNIQUE ("); |
|
|
|
|
|
|
|
|
|
|
|
/* Fetch and build target column list */ |
|
|
|
/* Fetch and build target column list */ |
|
|
|
val = SysCacheGetAttr(CONSTROID, tup, |
|
|
|
val = SysCacheGetAttr(CONSTROID, tup, |
|
|
@ -1436,7 +1436,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, |
|
|
|
|
|
|
|
|
|
|
|
decompile_column_index_array(val, conForm->conrelid, &buf); |
|
|
|
decompile_column_index_array(val, conForm->conrelid, &buf); |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(&buf, ")"); |
|
|
|
appendStringInfoChar(&buf, ')'); |
|
|
|
|
|
|
|
|
|
|
|
indexId = get_constraint_index(constraintId); |
|
|
|
indexId = get_constraint_index(constraintId); |
|
|
|
|
|
|
|
|
|
|
@ -1520,7 +1520,7 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, |
|
|
|
* throw an error; if we throw error then this function couldn't |
|
|
|
* throw an error; if we throw error then this function couldn't |
|
|
|
* safely be applied to all rows of pg_constraint. |
|
|
|
* safely be applied to all rows of pg_constraint. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
appendStringInfo(&buf, "TRIGGER"); |
|
|
|
appendStringInfoString(&buf, "TRIGGER"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CONSTRAINT_EXCLUSION: |
|
|
|
case CONSTRAINT_EXCLUSION: |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1565,9 +1565,9 @@ pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (conForm->condeferrable) |
|
|
|
if (conForm->condeferrable) |
|
|
|
appendStringInfo(&buf, " DEFERRABLE"); |
|
|
|
appendStringInfoString(&buf, " DEFERRABLE"); |
|
|
|
if (conForm->condeferred) |
|
|
|
if (conForm->condeferred) |
|
|
|
appendStringInfo(&buf, " INITIALLY DEFERRED"); |
|
|
|
appendStringInfoString(&buf, " INITIALLY DEFERRED"); |
|
|
|
if (!conForm->convalidated) |
|
|
|
if (!conForm->convalidated) |
|
|
|
appendStringInfoString(&buf, " NOT VALID"); |
|
|
|
appendStringInfoString(&buf, " NOT VALID"); |
|
|
|
|
|
|
|
|
|
|
@ -2029,7 +2029,7 @@ pg_get_functiondef(PG_FUNCTION_ARGS) |
|
|
|
appendStringInfoString(&buf, prosrc); |
|
|
|
appendStringInfoString(&buf, prosrc); |
|
|
|
appendStringInfoString(&buf, dq.data); |
|
|
|
appendStringInfoString(&buf, dq.data); |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfoString(&buf, "\n"); |
|
|
|
appendStringInfoChar(&buf, '\n'); |
|
|
|
|
|
|
|
|
|
|
|
ReleaseSysCache(langtup); |
|
|
|
ReleaseSysCache(langtup); |
|
|
|
ReleaseSysCache(proctup); |
|
|
|
ReleaseSysCache(proctup); |
|
|
@ -3789,19 +3789,19 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, |
|
|
|
switch (ev_type) |
|
|
|
switch (ev_type) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case '1': |
|
|
|
case '1': |
|
|
|
appendStringInfo(buf, "SELECT"); |
|
|
|
appendStringInfoString(buf, "SELECT"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case '2': |
|
|
|
case '2': |
|
|
|
appendStringInfo(buf, "UPDATE"); |
|
|
|
appendStringInfoString(buf, "UPDATE"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case '3': |
|
|
|
case '3': |
|
|
|
appendStringInfo(buf, "INSERT"); |
|
|
|
appendStringInfoString(buf, "INSERT"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case '4': |
|
|
|
case '4': |
|
|
|
appendStringInfo(buf, "DELETE"); |
|
|
|
appendStringInfoString(buf, "DELETE"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
@ -3827,7 +3827,7 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, |
|
|
|
|
|
|
|
|
|
|
|
if (prettyFlags & PRETTYFLAG_INDENT) |
|
|
|
if (prettyFlags & PRETTYFLAG_INDENT) |
|
|
|
appendStringInfoString(buf, "\n "); |
|
|
|
appendStringInfoString(buf, "\n "); |
|
|
|
appendStringInfo(buf, " WHERE "); |
|
|
|
appendStringInfoString(buf, " WHERE "); |
|
|
|
|
|
|
|
|
|
|
|
qual = stringToNode(ev_qual); |
|
|
|
qual = stringToNode(ev_qual); |
|
|
|
|
|
|
|
|
|
|
@ -3862,11 +3862,11 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, |
|
|
|
get_rule_expr(qual, &context, false); |
|
|
|
get_rule_expr(qual, &context, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(buf, " DO "); |
|
|
|
appendStringInfoString(buf, " DO "); |
|
|
|
|
|
|
|
|
|
|
|
/* The INSTEAD keyword (if so) */ |
|
|
|
/* The INSTEAD keyword (if so) */ |
|
|
|
if (is_instead) |
|
|
|
if (is_instead) |
|
|
|
appendStringInfo(buf, "INSTEAD "); |
|
|
|
appendStringInfoString(buf, "INSTEAD "); |
|
|
|
|
|
|
|
|
|
|
|
/* Finally the rules actions */ |
|
|
|
/* Finally the rules actions */ |
|
|
|
if (list_length(actions) > 1) |
|
|
|
if (list_length(actions) > 1) |
|
|
@ -3874,22 +3874,22 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, |
|
|
|
ListCell *action; |
|
|
|
ListCell *action; |
|
|
|
Query *query; |
|
|
|
Query *query; |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(buf, "("); |
|
|
|
appendStringInfoChar(buf, '('); |
|
|
|
foreach(action, actions) |
|
|
|
foreach(action, actions) |
|
|
|
{ |
|
|
|
{ |
|
|
|
query = (Query *) lfirst(action); |
|
|
|
query = (Query *) lfirst(action); |
|
|
|
get_query_def(query, buf, NIL, NULL, |
|
|
|
get_query_def(query, buf, NIL, NULL, |
|
|
|
prettyFlags, WRAP_COLUMN_DEFAULT, 0); |
|
|
|
prettyFlags, WRAP_COLUMN_DEFAULT, 0); |
|
|
|
if (prettyFlags) |
|
|
|
if (prettyFlags) |
|
|
|
appendStringInfo(buf, ";\n"); |
|
|
|
appendStringInfoString(buf, ";\n"); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(buf, "; "); |
|
|
|
appendStringInfoString(buf, "; "); |
|
|
|
} |
|
|
|
} |
|
|
|
appendStringInfo(buf, ");"); |
|
|
|
appendStringInfoString(buf, ");"); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (list_length(actions) == 0) |
|
|
|
else if (list_length(actions) == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(buf, "NOTHING;"); |
|
|
|
appendStringInfoString(buf, "NOTHING;"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -3898,7 +3898,7 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, |
|
|
|
query = (Query *) linitial(actions); |
|
|
|
query = (Query *) linitial(actions); |
|
|
|
get_query_def(query, buf, NIL, NULL, |
|
|
|
get_query_def(query, buf, NIL, NULL, |
|
|
|
prettyFlags, WRAP_COLUMN_DEFAULT, 0); |
|
|
|
prettyFlags, WRAP_COLUMN_DEFAULT, 0); |
|
|
|
appendStringInfo(buf, ";"); |
|
|
|
appendStringInfoChar(buf, ';'); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3945,7 +3945,7 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, |
|
|
|
|
|
|
|
|
|
|
|
if (list_length(actions) != 1) |
|
|
|
if (list_length(actions) != 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(buf, "Not a view"); |
|
|
|
appendStringInfoString(buf, "Not a view"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3954,7 +3954,7 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, |
|
|
|
if (ev_type != '1' || !is_instead || |
|
|
|
if (ev_type != '1' || !is_instead || |
|
|
|
strcmp(ev_qual, "<>") != 0 || query->commandType != CMD_SELECT) |
|
|
|
strcmp(ev_qual, "<>") != 0 || query->commandType != CMD_SELECT) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(buf, "Not a view"); |
|
|
|
appendStringInfoString(buf, "Not a view"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -3962,7 +3962,7 @@ make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, |
|
|
|
|
|
|
|
|
|
|
|
get_query_def(query, buf, NIL, RelationGetDescr(ev_relation), |
|
|
|
get_query_def(query, buf, NIL, RelationGetDescr(ev_relation), |
|
|
|
prettyFlags, wrapColumn, 0); |
|
|
|
prettyFlags, wrapColumn, 0); |
|
|
|
appendStringInfo(buf, ";"); |
|
|
|
appendStringInfoChar(buf, ';'); |
|
|
|
|
|
|
|
|
|
|
|
heap_close(ev_relation, AccessShareLock); |
|
|
|
heap_close(ev_relation, AccessShareLock); |
|
|
|
} |
|
|
|
} |
|
|
@ -4022,7 +4022,7 @@ get_query_def(Query *query, StringInfo buf, List *parentnamespace, |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case CMD_NOTHING: |
|
|
|
case CMD_NOTHING: |
|
|
|
appendStringInfo(buf, "NOTHING"); |
|
|
|
appendStringInfoString(buf, "NOTHING"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case CMD_UTILITY: |
|
|
|
case CMD_UTILITY: |
|
|
@ -4211,7 +4211,7 @@ get_select_query_def(Query *query, deparse_context *context, |
|
|
|
-PRETTYINDENT_STD, PRETTYINDENT_STD, 0); |
|
|
|
-PRETTYINDENT_STD, PRETTYINDENT_STD, 0); |
|
|
|
if (IsA(query->limitCount, Const) && |
|
|
|
if (IsA(query->limitCount, Const) && |
|
|
|
((Const *) query->limitCount)->constisnull) |
|
|
|
((Const *) query->limitCount)->constisnull) |
|
|
|
appendStringInfo(buf, "ALL"); |
|
|
|
appendStringInfoString(buf, "ALL"); |
|
|
|
else |
|
|
|
else |
|
|
|
get_rule_expr(query->limitCount, context, false); |
|
|
|
get_rule_expr(query->limitCount, context, false); |
|
|
|
} |
|
|
|
} |
|
|
@ -4251,7 +4251,7 @@ get_select_query_def(Query *query, deparse_context *context, |
|
|
|
quote_identifier(get_rtable_name(rc->rti, |
|
|
|
quote_identifier(get_rtable_name(rc->rti, |
|
|
|
context))); |
|
|
|
context))); |
|
|
|
if (rc->noWait) |
|
|
|
if (rc->noWait) |
|
|
|
appendStringInfo(buf, " NOWAIT"); |
|
|
|
appendStringInfoString(buf, " NOWAIT"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -4325,14 +4325,14 @@ get_basic_select_query(Query *query, deparse_context *context, |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Build up the query string - first we say SELECT |
|
|
|
* Build up the query string - first we say SELECT |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
appendStringInfo(buf, "SELECT"); |
|
|
|
appendStringInfoString(buf, "SELECT"); |
|
|
|
|
|
|
|
|
|
|
|
/* Add the DISTINCT clause if given */ |
|
|
|
/* Add the DISTINCT clause if given */ |
|
|
|
if (query->distinctClause != NIL) |
|
|
|
if (query->distinctClause != NIL) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (query->hasDistinctOn) |
|
|
|
if (query->hasDistinctOn) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(buf, " DISTINCT ON ("); |
|
|
|
appendStringInfoString(buf, " DISTINCT ON ("); |
|
|
|
sep = ""; |
|
|
|
sep = ""; |
|
|
|
foreach(l, query->distinctClause) |
|
|
|
foreach(l, query->distinctClause) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -4343,10 +4343,10 @@ get_basic_select_query(Query *query, deparse_context *context, |
|
|
|
false, context); |
|
|
|
false, context); |
|
|
|
sep = ", "; |
|
|
|
sep = ", "; |
|
|
|
} |
|
|
|
} |
|
|
|
appendStringInfo(buf, ")"); |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(buf, " DISTINCT"); |
|
|
|
appendStringInfoString(buf, " DISTINCT"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Then we tell what to select (the targetlist) */ |
|
|
|
/* Then we tell what to select (the targetlist) */ |
|
|
@ -4603,7 +4603,7 @@ get_setop_query(Node *setOp, Query *query, deparse_context *context, |
|
|
|
(int) op->op); |
|
|
|
(int) op->op); |
|
|
|
} |
|
|
|
} |
|
|
|
if (op->all) |
|
|
|
if (op->all) |
|
|
|
appendStringInfo(buf, "ALL "); |
|
|
|
appendStringInfoString(buf, "ALL "); |
|
|
|
|
|
|
|
|
|
|
|
if (PRETTY_INDENT(context)) |
|
|
|
if (PRETTY_INDENT(context)) |
|
|
|
appendContextKeyword(context, "", 0, 0, 0); |
|
|
|
appendContextKeyword(context, "", 0, 0, 0); |
|
|
@ -4693,14 +4693,14 @@ get_rule_orderby(List *orderList, List *targetList, |
|
|
|
{ |
|
|
|
{ |
|
|
|
/* ASC is default, so emit nothing for it */ |
|
|
|
/* ASC is default, so emit nothing for it */ |
|
|
|
if (srt->nulls_first) |
|
|
|
if (srt->nulls_first) |
|
|
|
appendStringInfo(buf, " NULLS FIRST"); |
|
|
|
appendStringInfoString(buf, " NULLS FIRST"); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (srt->sortop == typentry->gt_opr) |
|
|
|
else if (srt->sortop == typentry->gt_opr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(buf, " DESC"); |
|
|
|
appendStringInfoString(buf, " DESC"); |
|
|
|
/* DESC defaults to NULLS FIRST */ |
|
|
|
/* DESC defaults to NULLS FIRST */ |
|
|
|
if (!srt->nulls_first) |
|
|
|
if (!srt->nulls_first) |
|
|
|
appendStringInfo(buf, " NULLS LAST"); |
|
|
|
appendStringInfoString(buf, " NULLS LAST"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -4710,9 +4710,9 @@ get_rule_orderby(List *orderList, List *targetList, |
|
|
|
sortcoltype)); |
|
|
|
sortcoltype)); |
|
|
|
/* be specific to eliminate ambiguity */ |
|
|
|
/* be specific to eliminate ambiguity */ |
|
|
|
if (srt->nulls_first) |
|
|
|
if (srt->nulls_first) |
|
|
|
appendStringInfo(buf, " NULLS FIRST"); |
|
|
|
appendStringInfoString(buf, " NULLS FIRST"); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(buf, " NULLS LAST"); |
|
|
|
appendStringInfoString(buf, " NULLS LAST"); |
|
|
|
} |
|
|
|
} |
|
|
|
sep = ", "; |
|
|
|
sep = ", "; |
|
|
|
} |
|
|
|
} |
|
|
@ -4964,7 +4964,7 @@ get_insert_query_def(Query *query, deparse_context *context) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (query->targetList) |
|
|
|
if (query->targetList) |
|
|
|
appendStringInfo(buf, ") "); |
|
|
|
appendStringInfoString(buf, ") "); |
|
|
|
|
|
|
|
|
|
|
|
if (select_rte) |
|
|
|
if (select_rte) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -4989,7 +4989,7 @@ get_insert_query_def(Query *query, deparse_context *context) |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
/* No expressions, so it must be DEFAULT VALUES */ |
|
|
|
/* No expressions, so it must be DEFAULT VALUES */ |
|
|
|
appendStringInfo(buf, "DEFAULT VALUES"); |
|
|
|
appendStringInfoString(buf, "DEFAULT VALUES"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Add RETURNING if present */ |
|
|
|
/* Add RETURNING if present */ |
|
|
@ -5062,7 +5062,7 @@ get_update_query_def(Query *query, deparse_context *context) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
expr = processIndirection((Node *) tle->expr, context, true); |
|
|
|
expr = processIndirection((Node *) tle->expr, context, true); |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(buf, " = "); |
|
|
|
appendStringInfoString(buf, " = "); |
|
|
|
|
|
|
|
|
|
|
|
get_rule_expr(expr, context, false); |
|
|
|
get_rule_expr(expr, context, false); |
|
|
|
} |
|
|
|
} |
|
|
@ -6426,7 +6426,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
if (!PRETTY_PAREN(context)) |
|
|
|
if (!PRETTY_PAREN(context)) |
|
|
|
appendStringInfoChar(buf, '('); |
|
|
|
appendStringInfoChar(buf, '('); |
|
|
|
get_rule_expr_paren(arg1, context, true, node); |
|
|
|
get_rule_expr_paren(arg1, context, true, node); |
|
|
|
appendStringInfo(buf, " IS DISTINCT FROM "); |
|
|
|
appendStringInfoString(buf, " IS DISTINCT FROM "); |
|
|
|
get_rule_expr_paren(arg2, context, true, node); |
|
|
|
get_rule_expr_paren(arg2, context, true, node); |
|
|
|
if (!PRETTY_PAREN(context)) |
|
|
|
if (!PRETTY_PAREN(context)) |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
@ -6437,7 +6437,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
{ |
|
|
|
{ |
|
|
|
NullIfExpr *nullifexpr = (NullIfExpr *) node; |
|
|
|
NullIfExpr *nullifexpr = (NullIfExpr *) node; |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(buf, "NULLIF("); |
|
|
|
appendStringInfoString(buf, "NULLIF("); |
|
|
|
get_rule_expr((Node *) nullifexpr->args, context, true); |
|
|
|
get_rule_expr((Node *) nullifexpr->args, context, true); |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
} |
|
|
|
} |
|
|
@ -6480,7 +6480,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
false, node); |
|
|
|
false, node); |
|
|
|
while (arg) |
|
|
|
while (arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(buf, " AND "); |
|
|
|
appendStringInfoString(buf, " AND "); |
|
|
|
get_rule_expr_paren((Node *) lfirst(arg), context, |
|
|
|
get_rule_expr_paren((Node *) lfirst(arg), context, |
|
|
|
false, node); |
|
|
|
false, node); |
|
|
|
arg = lnext(arg); |
|
|
|
arg = lnext(arg); |
|
|
@ -6496,7 +6496,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
false, node); |
|
|
|
false, node); |
|
|
|
while (arg) |
|
|
|
while (arg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(buf, " OR "); |
|
|
|
appendStringInfoString(buf, " OR "); |
|
|
|
get_rule_expr_paren((Node *) lfirst(arg), context, |
|
|
|
get_rule_expr_paren((Node *) lfirst(arg), context, |
|
|
|
false, node); |
|
|
|
false, node); |
|
|
|
arg = lnext(arg); |
|
|
|
arg = lnext(arg); |
|
|
@ -6508,7 +6508,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
case NOT_EXPR: |
|
|
|
case NOT_EXPR: |
|
|
|
if (!PRETTY_PAREN(context)) |
|
|
|
if (!PRETTY_PAREN(context)) |
|
|
|
appendStringInfoChar(buf, '('); |
|
|
|
appendStringInfoChar(buf, '('); |
|
|
|
appendStringInfo(buf, "NOT "); |
|
|
|
appendStringInfoString(buf, "NOT "); |
|
|
|
get_rule_expr_paren(first_arg, context, |
|
|
|
get_rule_expr_paren(first_arg, context, |
|
|
|
false, node); |
|
|
|
false, node); |
|
|
|
if (!PRETTY_PAREN(context)) |
|
|
|
if (!PRETTY_PAREN(context)) |
|
|
@ -6549,7 +6549,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
ListCell *lc; |
|
|
|
ListCell *lc; |
|
|
|
|
|
|
|
|
|
|
|
/* As above, this can only happen during EXPLAIN */ |
|
|
|
/* As above, this can only happen during EXPLAIN */ |
|
|
|
appendStringInfo(buf, "(alternatives: "); |
|
|
|
appendStringInfoString(buf, "(alternatives: "); |
|
|
|
foreach(lc, asplan->subplans) |
|
|
|
foreach(lc, asplan->subplans) |
|
|
|
{ |
|
|
|
{ |
|
|
|
SubPlan *splan = (SubPlan *) lfirst(lc); |
|
|
|
SubPlan *splan = (SubPlan *) lfirst(lc); |
|
|
@ -6558,11 +6558,11 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
if (splan->useHashTable) |
|
|
|
if (splan->useHashTable) |
|
|
|
appendStringInfo(buf, "hashed %s", splan->plan_name); |
|
|
|
appendStringInfo(buf, "hashed %s", splan->plan_name); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(buf, "%s", splan->plan_name); |
|
|
|
appendStringInfoString(buf, splan->plan_name); |
|
|
|
if (lnext(lc)) |
|
|
|
if (lnext(lc)) |
|
|
|
appendStringInfo(buf, " or "); |
|
|
|
appendStringInfoString(buf, " or "); |
|
|
|
} |
|
|
|
} |
|
|
|
appendStringInfo(buf, ")"); |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
@ -6774,7 +6774,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
appendContextKeyword(context, "WHEN ", |
|
|
|
appendContextKeyword(context, "WHEN ", |
|
|
|
0, 0, 0); |
|
|
|
0, 0, 0); |
|
|
|
get_rule_expr(w, context, false); |
|
|
|
get_rule_expr(w, context, false); |
|
|
|
appendStringInfo(buf, " THEN "); |
|
|
|
appendStringInfoString(buf, " THEN "); |
|
|
|
get_rule_expr((Node *) when->result, context, true); |
|
|
|
get_rule_expr((Node *) when->result, context, true); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!PRETTY_INDENT(context)) |
|
|
|
if (!PRETTY_INDENT(context)) |
|
|
@ -6798,7 +6798,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
* be unable to avoid that (see comments for CaseExpr). If we |
|
|
|
* be unable to avoid that (see comments for CaseExpr). If we |
|
|
|
* do see one, print it as CASE_TEST_EXPR. |
|
|
|
* do see one, print it as CASE_TEST_EXPR. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
appendStringInfo(buf, "CASE_TEST_EXPR"); |
|
|
|
appendStringInfoString(buf, "CASE_TEST_EXPR"); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
@ -6806,7 +6806,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
{ |
|
|
|
{ |
|
|
|
ArrayExpr *arrayexpr = (ArrayExpr *) node; |
|
|
|
ArrayExpr *arrayexpr = (ArrayExpr *) node; |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(buf, "ARRAY["); |
|
|
|
appendStringInfoString(buf, "ARRAY["); |
|
|
|
get_rule_expr((Node *) arrayexpr->elements, context, true); |
|
|
|
get_rule_expr((Node *) arrayexpr->elements, context, true); |
|
|
|
appendStringInfoChar(buf, ']'); |
|
|
|
appendStringInfoChar(buf, ']'); |
|
|
|
|
|
|
|
|
|
|
@ -6844,7 +6844,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
* SQL99 allows "ROW" to be omitted when there is more than |
|
|
|
* SQL99 allows "ROW" to be omitted when there is more than |
|
|
|
* one column, but for simplicity we always print it. |
|
|
|
* one column, but for simplicity we always print it. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
appendStringInfo(buf, "ROW("); |
|
|
|
appendStringInfoString(buf, "ROW("); |
|
|
|
sep = ""; |
|
|
|
sep = ""; |
|
|
|
i = 0; |
|
|
|
i = 0; |
|
|
|
foreach(arg, rowexpr->args) |
|
|
|
foreach(arg, rowexpr->args) |
|
|
@ -6867,7 +6867,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
if (!tupdesc->attrs[i]->attisdropped) |
|
|
|
if (!tupdesc->attrs[i]->attisdropped) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfoString(buf, sep); |
|
|
|
appendStringInfoString(buf, sep); |
|
|
|
appendStringInfo(buf, "NULL"); |
|
|
|
appendStringInfoString(buf, "NULL"); |
|
|
|
sep = ", "; |
|
|
|
sep = ", "; |
|
|
|
} |
|
|
|
} |
|
|
|
i++; |
|
|
|
i++; |
|
|
@ -6875,7 +6875,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
|
|
|
|
|
|
|
|
ReleaseTupleDesc(tupdesc); |
|
|
|
ReleaseTupleDesc(tupdesc); |
|
|
|
} |
|
|
|
} |
|
|
|
appendStringInfo(buf, ")"); |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
if (rowexpr->row_format == COERCE_EXPLICIT_CAST) |
|
|
|
if (rowexpr->row_format == COERCE_EXPLICIT_CAST) |
|
|
|
appendStringInfo(buf, "::%s", |
|
|
|
appendStringInfo(buf, "::%s", |
|
|
|
format_type_with_typemod(rowexpr->row_typeid, -1)); |
|
|
|
format_type_with_typemod(rowexpr->row_typeid, -1)); |
|
|
@ -6892,7 +6892,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
* SQL99 allows "ROW" to be omitted when there is more than |
|
|
|
* SQL99 allows "ROW" to be omitted when there is more than |
|
|
|
* one column, but for simplicity we always print it. |
|
|
|
* one column, but for simplicity we always print it. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
appendStringInfo(buf, "(ROW("); |
|
|
|
appendStringInfoString(buf, "(ROW("); |
|
|
|
sep = ""; |
|
|
|
sep = ""; |
|
|
|
foreach(arg, rcexpr->largs) |
|
|
|
foreach(arg, rcexpr->largs) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -6923,7 +6923,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
get_rule_expr(e, context, true); |
|
|
|
get_rule_expr(e, context, true); |
|
|
|
sep = ", "; |
|
|
|
sep = ", "; |
|
|
|
} |
|
|
|
} |
|
|
|
appendStringInfo(buf, "))"); |
|
|
|
appendStringInfoString(buf, "))"); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
@ -6931,7 +6931,7 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
{ |
|
|
|
{ |
|
|
|
CoalesceExpr *coalesceexpr = (CoalesceExpr *) node; |
|
|
|
CoalesceExpr *coalesceexpr = (CoalesceExpr *) node; |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(buf, "COALESCE("); |
|
|
|
appendStringInfoString(buf, "COALESCE("); |
|
|
|
get_rule_expr((Node *) coalesceexpr->args, context, true); |
|
|
|
get_rule_expr((Node *) coalesceexpr->args, context, true); |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
} |
|
|
|
} |
|
|
@ -6944,10 +6944,10 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
switch (minmaxexpr->op) |
|
|
|
switch (minmaxexpr->op) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case IS_GREATEST: |
|
|
|
case IS_GREATEST: |
|
|
|
appendStringInfo(buf, "GREATEST("); |
|
|
|
appendStringInfoString(buf, "GREATEST("); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case IS_LEAST: |
|
|
|
case IS_LEAST: |
|
|
|
appendStringInfo(buf, "LEAST("); |
|
|
|
appendStringInfoString(buf, "LEAST("); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
get_rule_expr((Node *) minmaxexpr->args, context, true); |
|
|
|
get_rule_expr((Node *) minmaxexpr->args, context, true); |
|
|
@ -7122,10 +7122,10 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
switch (ntest->nulltesttype) |
|
|
|
switch (ntest->nulltesttype) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case IS_NULL: |
|
|
|
case IS_NULL: |
|
|
|
appendStringInfo(buf, " IS NULL"); |
|
|
|
appendStringInfoString(buf, " IS NULL"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case IS_NOT_NULL: |
|
|
|
case IS_NOT_NULL: |
|
|
|
appendStringInfo(buf, " IS NOT NULL"); |
|
|
|
appendStringInfoString(buf, " IS NOT NULL"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
elog(ERROR, "unrecognized nulltesttype: %d", |
|
|
|
elog(ERROR, "unrecognized nulltesttype: %d", |
|
|
@ -7146,22 +7146,22 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
switch (btest->booltesttype) |
|
|
|
switch (btest->booltesttype) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case IS_TRUE: |
|
|
|
case IS_TRUE: |
|
|
|
appendStringInfo(buf, " IS TRUE"); |
|
|
|
appendStringInfoString(buf, " IS TRUE"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case IS_NOT_TRUE: |
|
|
|
case IS_NOT_TRUE: |
|
|
|
appendStringInfo(buf, " IS NOT TRUE"); |
|
|
|
appendStringInfoString(buf, " IS NOT TRUE"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case IS_FALSE: |
|
|
|
case IS_FALSE: |
|
|
|
appendStringInfo(buf, " IS FALSE"); |
|
|
|
appendStringInfoString(buf, " IS FALSE"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case IS_NOT_FALSE: |
|
|
|
case IS_NOT_FALSE: |
|
|
|
appendStringInfo(buf, " IS NOT FALSE"); |
|
|
|
appendStringInfoString(buf, " IS NOT FALSE"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case IS_UNKNOWN: |
|
|
|
case IS_UNKNOWN: |
|
|
|
appendStringInfo(buf, " IS UNKNOWN"); |
|
|
|
appendStringInfoString(buf, " IS UNKNOWN"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case IS_NOT_UNKNOWN: |
|
|
|
case IS_NOT_UNKNOWN: |
|
|
|
appendStringInfo(buf, " IS NOT UNKNOWN"); |
|
|
|
appendStringInfoString(buf, " IS NOT UNKNOWN"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
elog(ERROR, "unrecognized booltesttype: %d", |
|
|
|
elog(ERROR, "unrecognized booltesttype: %d", |
|
|
@ -7194,11 +7194,11 @@ get_rule_expr(Node *node, deparse_context *context, |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case T_CoerceToDomainValue: |
|
|
|
case T_CoerceToDomainValue: |
|
|
|
appendStringInfo(buf, "VALUE"); |
|
|
|
appendStringInfoString(buf, "VALUE"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case T_SetToDefault: |
|
|
|
case T_SetToDefault: |
|
|
|
appendStringInfo(buf, "DEFAULT"); |
|
|
|
appendStringInfoString(buf, "DEFAULT"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case T_CurrentOfExpr: |
|
|
|
case T_CurrentOfExpr: |
|
|
@ -7592,7 +7592,7 @@ get_const_expr(Const *constval, deparse_context *context, int showtype) |
|
|
|
* Always label the type of a NULL constant to prevent misdecisions |
|
|
|
* Always label the type of a NULL constant to prevent misdecisions |
|
|
|
* about type when reparsing. |
|
|
|
* about type when reparsing. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
appendStringInfo(buf, "NULL"); |
|
|
|
appendStringInfoString(buf, "NULL"); |
|
|
|
if (showtype >= 0) |
|
|
|
if (showtype >= 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(buf, "::%s", |
|
|
|
appendStringInfo(buf, "::%s", |
|
|
@ -7654,9 +7654,9 @@ get_const_expr(Const *constval, deparse_context *context, int showtype) |
|
|
|
|
|
|
|
|
|
|
|
case BOOLOID: |
|
|
|
case BOOLOID: |
|
|
|
if (strcmp(extval, "t") == 0) |
|
|
|
if (strcmp(extval, "t") == 0) |
|
|
|
appendStringInfo(buf, "true"); |
|
|
|
appendStringInfoString(buf, "true"); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(buf, "false"); |
|
|
|
appendStringInfoString(buf, "false"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
default: |
|
|
@ -7763,7 +7763,7 @@ get_sublink_expr(SubLink *sublink, deparse_context *context) |
|
|
|
bool need_paren; |
|
|
|
bool need_paren; |
|
|
|
|
|
|
|
|
|
|
|
if (sublink->subLinkType == ARRAY_SUBLINK) |
|
|
|
if (sublink->subLinkType == ARRAY_SUBLINK) |
|
|
|
appendStringInfo(buf, "ARRAY("); |
|
|
|
appendStringInfoString(buf, "ARRAY("); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfoChar(buf, '('); |
|
|
|
appendStringInfoChar(buf, '('); |
|
|
|
|
|
|
|
|
|
|
@ -7831,12 +7831,12 @@ get_sublink_expr(SubLink *sublink, deparse_context *context) |
|
|
|
switch (sublink->subLinkType) |
|
|
|
switch (sublink->subLinkType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case EXISTS_SUBLINK: |
|
|
|
case EXISTS_SUBLINK: |
|
|
|
appendStringInfo(buf, "EXISTS "); |
|
|
|
appendStringInfoString(buf, "EXISTS "); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case ANY_SUBLINK: |
|
|
|
case ANY_SUBLINK: |
|
|
|
if (strcmp(opname, "=") == 0) /* Represent = ANY as IN */ |
|
|
|
if (strcmp(opname, "=") == 0) /* Represent = ANY as IN */ |
|
|
|
appendStringInfo(buf, " IN "); |
|
|
|
appendStringInfoString(buf, " IN "); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(buf, " %s ANY ", opname); |
|
|
|
appendStringInfo(buf, " %s ANY ", opname); |
|
|
|
break; |
|
|
|
break; |
|
|
@ -7869,7 +7869,7 @@ get_sublink_expr(SubLink *sublink, deparse_context *context) |
|
|
|
context->indentLevel); |
|
|
|
context->indentLevel); |
|
|
|
|
|
|
|
|
|
|
|
if (need_paren) |
|
|
|
if (need_paren) |
|
|
|
appendStringInfo(buf, "))"); |
|
|
|
appendStringInfoString(buf, "))"); |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
} |
|
|
|
} |
|
|
@ -8140,7 +8140,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) |
|
|
|
ListCell *lc; |
|
|
|
ListCell *lc; |
|
|
|
bool first = true; |
|
|
|
bool first = true; |
|
|
|
|
|
|
|
|
|
|
|
appendStringInfo(buf, " USING ("); |
|
|
|
appendStringInfoString(buf, " USING ("); |
|
|
|
/* Use the assigned names, not what's in usingClause */ |
|
|
|
/* Use the assigned names, not what's in usingClause */ |
|
|
|
foreach(lc, colinfo->usingNames) |
|
|
|
foreach(lc, colinfo->usingNames) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -8149,14 +8149,14 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) |
|
|
|
if (first) |
|
|
|
if (first) |
|
|
|
first = false; |
|
|
|
first = false; |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(buf, ", "); |
|
|
|
appendStringInfoString(buf, ", "); |
|
|
|
appendStringInfoString(buf, quote_identifier(colname)); |
|
|
|
appendStringInfoString(buf, quote_identifier(colname)); |
|
|
|
} |
|
|
|
} |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
appendStringInfoChar(buf, ')'); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (j->quals) |
|
|
|
else if (j->quals) |
|
|
|
{ |
|
|
|
{ |
|
|
|
appendStringInfo(buf, " ON "); |
|
|
|
appendStringInfoString(buf, " ON "); |
|
|
|
if (!PRETTY_PAREN(context)) |
|
|
|
if (!PRETTY_PAREN(context)) |
|
|
|
appendStringInfoChar(buf, '('); |
|
|
|
appendStringInfoChar(buf, '('); |
|
|
|
get_rule_expr(j->quals, context, false); |
|
|
|
get_rule_expr(j->quals, context, false); |
|
|
@ -8206,7 +8206,7 @@ get_column_alias_list(deparse_columns *colinfo, deparse_context *context) |
|
|
|
first = false; |
|
|
|
first = false; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
appendStringInfo(buf, ", "); |
|
|
|
appendStringInfoString(buf, ", "); |
|
|
|
appendStringInfoString(buf, quote_identifier(colname)); |
|
|
|
appendStringInfoString(buf, quote_identifier(colname)); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!first) |
|
|
|
if (!first) |
|
|
@ -8243,7 +8243,7 @@ get_from_clause_coldeflist(deparse_columns *colinfo, |
|
|
|
Assert(attname); /* shouldn't be any dropped columns here */ |
|
|
|
Assert(attname); /* shouldn't be any dropped columns here */ |
|
|
|
|
|
|
|
|
|
|
|
if (i > 0) |
|
|
|
if (i > 0) |
|
|
|
appendStringInfo(buf, ", "); |
|
|
|
appendStringInfoString(buf, ", "); |
|
|
|
appendStringInfo(buf, "%s %s", |
|
|
|
appendStringInfo(buf, "%s %s", |
|
|
|
quote_identifier(attname), |
|
|
|
quote_identifier(attname), |
|
|
|
format_type_with_typemod(atttypid, atttypmod)); |
|
|
|
format_type_with_typemod(atttypid, atttypmod)); |
|
|
|