Re: ruleutils with pretty-print option - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: ruleutils with pretty-print option
Date
Msg-id 200307310452.h6V4qJV12980@candle.pha.pa.us
Whole thread Raw
In response to Re: ruleutils with pretty-print option  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: ruleutils with pretty-print option  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
I didn't like the functions ending in _ext.  I renamed them to _pp for
pretty print.  Patch attached and applied.

---------------------------------------------------------------------------

Tom Lane wrote:
> Andreas Pflug <pgadmin@pse-consulting.de> writes:
> > I recoded the stuff as Tom recommended, leaving the non-pretty version
> > function names as they used to be, inventing new pg_get_XXXX_ext
> > functions for the extended stuff, and pushing the code down into
> > pg_get_XXXX_worker functions when needed. We now need the additional
> > prototype include patch from builtins.h.
>
> Applied with some editorializing.  In particular, I don't believe the
> original did the right thing with (a - (b - c)).
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/backend/utils/adt/ruleutils.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/utils/adt/ruleutils.c,v
retrieving revision 1.147
diff -c -c -r1.147 ruleutils.c
*** src/backend/utils/adt/ruleutils.c    30 Jul 2003 22:56:23 -0000    1.147
--- src/backend/utils/adt/ruleutils.c    31 Jul 2003 04:48:35 -0000
***************
*** 228,234 ****


  Datum
! pg_get_ruledef_ext(PG_FUNCTION_ARGS)
  {
      Oid            ruleoid = PG_GETARG_OID(0);
      bool        pretty = PG_GETARG_BOOL(1);
--- 228,234 ----


  Datum
! pg_get_ruledef_pp(PG_FUNCTION_ARGS)
  {
      Oid            ruleoid = PG_GETARG_OID(0);
      bool        pretty = PG_GETARG_BOOL(1);
***************
*** 337,343 ****


  Datum
! pg_get_viewdef_ext(PG_FUNCTION_ARGS)
  {
      /* By OID */
      Oid            viewoid = PG_GETARG_OID(0);
--- 337,343 ----


  Datum
! pg_get_viewdef_pp(PG_FUNCTION_ARGS)
  {
      /* By OID */
      Oid            viewoid = PG_GETARG_OID(0);
***************
*** 369,375 ****


  Datum
! pg_get_viewdef_name_ext(PG_FUNCTION_ARGS)
  {
      /* By qualified name */
      text       *viewname = PG_GETARG_TEXT_P(0);
--- 369,375 ----


  Datum
! pg_get_viewdef_name_pp(PG_FUNCTION_ARGS)
  {
      /* By qualified name */
      text       *viewname = PG_GETARG_TEXT_P(0);
***************
*** 630,636 ****
  }

  Datum
! pg_get_indexdef_ext(PG_FUNCTION_ARGS)
  {
      Oid            indexrelid = PG_GETARG_OID(0);
      int32       colno = PG_GETARG_INT32(1);
--- 630,636 ----
  }

  Datum
! pg_get_indexdef_pp(PG_FUNCTION_ARGS)
  {
      Oid            indexrelid = PG_GETARG_OID(0);
      int32       colno = PG_GETARG_INT32(1);
***************
*** 856,862 ****
  }

  Datum
! pg_get_constraintdef_ext(PG_FUNCTION_ARGS)
  {
      Oid            constraintId = PG_GETARG_OID(0);
      bool        pretty = PG_GETARG_BOOL(1);
--- 856,862 ----
  }

  Datum
! pg_get_constraintdef_pp(PG_FUNCTION_ARGS)
  {
      Oid            constraintId = PG_GETARG_OID(0);
      bool        pretty = PG_GETARG_BOOL(1);
***************
*** 1175,1181 ****
  }

  Datum
! pg_get_expr_ext(PG_FUNCTION_ARGS)
  {
      text    *expr = PG_GETARG_TEXT_P(0);
      Oid    relid = PG_GETARG_OID(1);
--- 1175,1181 ----
  }

  Datum
! pg_get_expr_pp(PG_FUNCTION_ARGS)
  {
      text    *expr = PG_GETARG_TEXT_P(0);
      Oid    relid = PG_GETARG_OID(1);
Index: src/include/catalog/pg_proc.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/catalog/pg_proc.h,v
retrieving revision 1.310
diff -c -c -r1.310 pg_proc.h
*** src/include/catalog/pg_proc.h    30 Jul 2003 22:56:24 -0000    1.310
--- src/include/catalog/pg_proc.h    31 Jul 2003 04:48:40 -0000
***************
*** 3406,3422 ****
  DESCR("I/O");

  /* System-view support functions with pretty-print option */
! DATA(insert OID = 2504 (  pg_get_ruledef       PGNSP PGUID 12 f f t f s 2 25 "26 16"  pg_get_ruledef_ext - _null_ ));
  DESCR("source text of a rule with pretty-print option");
! DATA(insert OID = 2505 (  pg_get_viewdef       PGNSP PGUID 12 f f t f s 2 25 "25 16"  pg_get_viewdef_name_ext -
_null_)); 
  DESCR("select statement of a view with pretty-print option");
! DATA(insert OID = 2506 (  pg_get_viewdef       PGNSP PGUID 12 f f t f s 2 25 "26 16"  pg_get_viewdef_ext - _null_ ));
  DESCR("select statement of a view with pretty-print option");
! DATA(insert OID = 2507 (  pg_get_indexdef       PGNSP PGUID 12 f f t f s 3 25 "26 23 16"  pg_get_indexdef_ext -
_null_)); 
  DESCR("index description (full create statement or single expression) with pretty-print option");
! DATA(insert OID = 2508 (  pg_get_constraintdef PGNSP PGUID 12 f f t f s 2 25 "26 16"  pg_get_constraintdef_ext -
_null_)); 
  DESCR("constraint description with pretty-print option");
! DATA(insert OID = 2509 (  pg_get_expr           PGNSP PGUID 12 f f t f s 3 25 "25 26 16"    pg_get_expr_ext - _null_
));
  DESCR("deparse an encoded expression with pretty-print option");


--- 3406,3422 ----
  DESCR("I/O");

  /* System-view support functions with pretty-print option */
! DATA(insert OID = 2504 (  pg_get_ruledef       PGNSP PGUID 12 f f t f s 2 25 "26 16"  pg_get_ruledef_pp - _null_ ));
  DESCR("source text of a rule with pretty-print option");
! DATA(insert OID = 2505 (  pg_get_viewdef       PGNSP PGUID 12 f f t f s 2 25 "25 16"  pg_get_viewdef_name_pp - _null_
));
  DESCR("select statement of a view with pretty-print option");
! DATA(insert OID = 2506 (  pg_get_viewdef       PGNSP PGUID 12 f f t f s 2 25 "26 16"  pg_get_viewdef_pp - _null_ ));
  DESCR("select statement of a view with pretty-print option");
! DATA(insert OID = 2507 (  pg_get_indexdef       PGNSP PGUID 12 f f t f s 3 25 "26 23 16"  pg_get_indexdef_pp - _null_
));
  DESCR("index description (full create statement or single expression) with pretty-print option");
! DATA(insert OID = 2508 (  pg_get_constraintdef PGNSP PGUID 12 f f t f s 2 25 "26 16"  pg_get_constraintdef_pp -
_null_)); 
  DESCR("constraint description with pretty-print option");
! DATA(insert OID = 2509 (  pg_get_expr           PGNSP PGUID 12 f f t f s 3 25 "25 26 16"    pg_get_expr_pp - _null_
));
  DESCR("deparse an encoded expression with pretty-print option");


Index: src/include/utils/builtins.h
===================================================================
RCS file: /cvsroot/pgsql-server/src/include/utils/builtins.h,v
retrieving revision 1.224
diff -c -c -r1.224 builtins.h
*** src/include/utils/builtins.h    30 Jul 2003 22:56:24 -0000    1.224
--- src/include/utils/builtins.h    31 Jul 2003 04:48:41 -0000
***************
*** 441,459 ****

  /* ruleutils.c */
  extern Datum pg_get_ruledef(PG_FUNCTION_ARGS);
! extern Datum pg_get_ruledef_ext(PG_FUNCTION_ARGS);
  extern Datum pg_get_viewdef(PG_FUNCTION_ARGS);
! extern Datum pg_get_viewdef_ext(PG_FUNCTION_ARGS);
  extern Datum pg_get_viewdef_name(PG_FUNCTION_ARGS);
! extern Datum pg_get_viewdef_name_ext(PG_FUNCTION_ARGS);
  extern Datum pg_get_indexdef(PG_FUNCTION_ARGS);
! extern Datum pg_get_indexdef_ext(PG_FUNCTION_ARGS);
  extern Datum pg_get_triggerdef(PG_FUNCTION_ARGS);
  extern Datum pg_get_constraintdef(PG_FUNCTION_ARGS);
! extern Datum pg_get_constraintdef_ext(PG_FUNCTION_ARGS);
  extern Datum pg_get_userbyid(PG_FUNCTION_ARGS);
  extern Datum pg_get_expr(PG_FUNCTION_ARGS);
! extern Datum pg_get_expr_ext(PG_FUNCTION_ARGS);
  extern char *deparse_expression(Node *expr, List *dpcontext,
                     bool forceprefix, bool showimplicit);
  extern List *deparse_context_for(const char *aliasname, Oid relid);
--- 441,459 ----

  /* ruleutils.c */
  extern Datum pg_get_ruledef(PG_FUNCTION_ARGS);
! extern Datum pg_get_ruledef_pp(PG_FUNCTION_ARGS);
  extern Datum pg_get_viewdef(PG_FUNCTION_ARGS);
! extern Datum pg_get_viewdef_pp(PG_FUNCTION_ARGS);
  extern Datum pg_get_viewdef_name(PG_FUNCTION_ARGS);
! extern Datum pg_get_viewdef_name_pp(PG_FUNCTION_ARGS);
  extern Datum pg_get_indexdef(PG_FUNCTION_ARGS);
! extern Datum pg_get_indexdef_pp(PG_FUNCTION_ARGS);
  extern Datum pg_get_triggerdef(PG_FUNCTION_ARGS);
  extern Datum pg_get_constraintdef(PG_FUNCTION_ARGS);
! extern Datum pg_get_constraintdef_pp(PG_FUNCTION_ARGS);
  extern Datum pg_get_userbyid(PG_FUNCTION_ARGS);
  extern Datum pg_get_expr(PG_FUNCTION_ARGS);
! extern Datum pg_get_expr_pp(PG_FUNCTION_ARGS);
  extern char *deparse_expression(Node *expr, List *dpcontext,
                     bool forceprefix, bool showimplicit);
  extern List *deparse_context_for(const char *aliasname, Oid relid);

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Spelling fix
Next
From: Bruce Momjian
Date:
Subject: Re: ruleutils with pretty-print option