Cleanup for "#option dump" in PL/PgSQL: don't print empty ELSE blocks,
authorNeil Conway
Tue, 14 Jun 2005 00:10:02 +0000 (00:10 +0000)
committerNeil Conway
Tue, 14 Jun 2005 00:10:02 +0000 (00:10 +0000)
fix two grammatical errors, and print the INTO target of EXECUTE INTO
if one is specified.

src/pl/plpgsql/src/pl_funcs.c

index 9e2ef4902c2b246d99077390da7cbf6ba4a4897e..21d8d9b7f7d8bd2ccbf01cd1e2e593ecd4e0e409 100644 (file)
@@ -3,7 +3,7 @@
  *           procedural language
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.41 2005/06/10 16:23:11 neilc Exp $
+ *   $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_funcs.c,v 1.42 2005/06/14 00:10:02 neilc Exp $
  *
  *   This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -675,10 +675,12 @@ dump_if(PLpgSQL_stmt_if *stmt)
 
    dump_stmts(stmt->true_body);
 
-   dump_ind();
-   printf("    ELSE\n");
-
-   dump_stmts(stmt->false_body);
+   if (stmt->false_body != NIL)
+   {
+       dump_ind();
+       printf("    ELSE\n");
+       dump_stmts(stmt->false_body);
+   }
 
    dump_ind();
    printf("    ENDIF\n");
@@ -908,6 +910,18 @@ dump_dynexecute(PLpgSQL_stmt_dynexecute *stmt)
    printf("EXECUTE ");
    dump_expr(stmt->query);
    printf("\n");
+
+   dump_indent += 2;
+   if (stmt->rec != NULL)
+   {
+       dump_ind();
+       printf("    target = %d %s\n", stmt->rec->recno, stmt->rec->refname);
+   } else if (stmt->row != NULL)
+   {
+       dump_ind();
+       printf("    target = %d %s\n", stmt->row->rowno, stmt->row->refname);
+   }
+   dump_indent -= 2;
 }
 
 static void
@@ -987,7 +1001,7 @@ plpgsql_dumptree(PLpgSQL_function *func)
    printf("\nExecution tree of successfully compiled PL/pgSQL function %s:\n",
           func->fn_name);
 
-   printf("\nFunctions data area:\n");
+   printf("\nFunction's data area:\n");
    for (i = 0; i < func->ndatums; i++)
    {
        d = func->datums[i];
@@ -1062,7 +1076,7 @@ plpgsql_dumptree(PLpgSQL_function *func)
                printf("??? unknown data type %d\n", d->dtype);
        }
    }
-   printf("\nFunctions statements:\n");
+   printf("\nFunction's statements:\n");
 
    dump_indent = 0;
    printf("%3d:", func->action->lineno);