pl/pgsql dump tree cleanup

Поиск
Список
Период
Сортировка
От Neil Conway
Тема pl/pgsql dump tree cleanup
Дата
Msg-id 42AD0866.5080103@samurai.com
обсуждение исходный текст
Ответы Re: pl/pgsql dump tree cleanup  (Neil Conway <neilc@samurai.com>)
Список pgsql-patches
This makes a few improvements to PL/PgSQL's ability to dump the parse
tree of a compiled function (via "#option dump", which is currently
undocumented):

- functions -> function's

- dump INTO target for EXECUTE

- don't dump ELSE clause for IF statements if the ELSE is empty (since
we have an explicit END IF, this shouldn't be ambiguous)

- minor tweak to RAISE dump format

Barring any objections I'll apply this later today or tomorrow.

-Neil
Index: src/pl/plpgsql/src/pl_funcs.c
===================================================================
RCS file: /var/lib/cvs/pgsql/src/pl/plpgsql/src/pl_funcs.c,v
retrieving revision 1.41
diff -c -r1.41 pl_funcs.c
*** src/pl/plpgsql/src/pl_funcs.c    10 Jun 2005 16:23:11 -0000    1.41
--- src/pl/plpgsql/src/pl_funcs.c    13 Jun 2005 03:29:57 -0000
***************
*** 675,684 ****

      dump_stmts(stmt->true_body);

!     dump_ind();
!     printf("    ELSE\n");
!
!     dump_stmts(stmt->false_body);

      dump_ind();
      printf("    ENDIF\n");
--- 675,686 ----

      dump_stmts(stmt->true_body);

!     if (stmt->false_body != NIL)
!     {
!         dump_ind();
!         printf("    ELSE\n");
!         dump_stmts(stmt->false_body);
!     }

      dump_ind();
      printf("    ENDIF\n");
***************
*** 888,894 ****
      dump_ind();
      printf("RAISE '%s'", stmt->message);
      foreach (l, stmt->params)
!         printf(" %d", lfirst_int(l));
      printf("\n");
  }

--- 890,896 ----
      dump_ind();
      printf("RAISE '%s'", stmt->message);
      foreach (l, stmt->params)
!         printf(", %d", lfirst_int(l));
      printf("\n");
  }

***************
*** 908,913 ****
--- 910,927 ----
      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,993 ****
      printf("\nExecution tree of successfully compiled PL/pgSQL function %s:\n",
             func->fn_name);

!     printf("\nFunctions data area:\n");
      for (i = 0; i < func->ndatums; i++)
      {
          d = func->datums[i];
--- 1001,1007 ----
      printf("\nExecution tree of successfully compiled PL/pgSQL function %s:\n",
             func->fn_name);

!     printf("\nFunction's data area:\n");
      for (i = 0; i < func->ndatums; i++)
      {
          d = func->datums[i];
***************
*** 1062,1068 ****
                  printf("??? unknown data type %d\n", d->dtype);
          }
      }
!     printf("\nFunctions statements:\n");

      dump_indent = 0;
      printf("%3d:", func->action->lineno);
--- 1076,1082 ----
                  printf("??? unknown data type %d\n", d->dtype);
          }
      }
!     printf("\nFunction's statements:\n");

      dump_indent = 0;
      printf("%3d:", func->action->lineno);

В списке pgsql-patches по дате отправления:

Предыдущее
От: Neil Conway
Дата:
Сообщение: psql: make \x affect normal queries only
Следующее
От: Pavel Stehule
Дата:
Сообщение: plpgsql raise - parameters can be expressions