Re: [HACKERS] Index USING in pg_dump

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [HACKERS] Index USING in pg_dump
Дата
Msg-id 200203081643.g28Ghl025690@candle.pha.pa.us
обсуждение исходный текст
Список pgsql-patches
Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Yes, but it doesn't look like the way they created it.
>
> (a) And you know that how?  (b) Are we also supposed to preserve
> spacing, keyword case, etc?  Not much of an argument...

Well, the USING part was confusing people because they didn't even know
we had other index types.  It is just an attempt to clean up pg_dump
output to be clearer.  One change I did make is to add a
DEFAULT_INDEX_TYPE macro and replace "btree" with the use of that macro
in a few places.

Here is a new patch.  I am moving the discussion to patches because of
the patch attachment.

How is this?  Comments from others?

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
Index: src/backend/parser/analyze.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/parser/analyze.c,v
retrieving revision 1.217
diff -c -r1.217 analyze.c
*** src/backend/parser/analyze.c    6 Mar 2002 06:09:51 -0000    1.217
--- src/backend/parser/analyze.c    8 Mar 2002 16:25:59 -0000
***************
*** 16,21 ****
--- 16,22 ----
  #include "access/heapam.h"
  #include "catalog/catname.h"
  #include "catalog/heap.h"
+ #include "catalog/index.h"
  #include "catalog/pg_index.h"
  #include "catalog/pg_type.h"
  #include "nodes/makefuncs.h"
***************
*** 1049,1055 ****
              index->idxname = NULL;        /* will set it later */

          index->relname = cxt->relname;
!         index->accessMethod = "btree";
          index->indexParams = NIL;
          index->whereClause = NULL;

--- 1050,1056 ----
              index->idxname = NULL;        /* will set it later */

          index->relname = cxt->relname;
!         index->accessMethod = DEFAULT_INDEX_TYPE;
          index->indexParams = NIL;
          index->whereClause = NULL;

Index: src/backend/parser/gram.y
===================================================================
RCS file: /cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.287
diff -c -r2.287 gram.y
*** src/backend/parser/gram.y    7 Mar 2002 16:35:35 -0000    2.287
--- src/backend/parser/gram.y    8 Mar 2002 16:26:03 -0000
***************
*** 51,56 ****
--- 51,57 ----
  #include <ctype.h>

  #include "access/htup.h"
+ #include "catalog/index.h"
  #include "catalog/pg_type.h"
  #include "nodes/params.h"
  #include "nodes/parsenodes.h"
***************
*** 2539,2545 ****
          ;

  access_method_clause:  USING access_method        { $$ = $2; }
!         | /*EMPTY*/                                { $$ = "btree"; }
          ;

  index_params:  index_list                        { $$ = $1; }
--- 2540,2547 ----
          ;

  access_method_clause:  USING access_method        { $$ = $2; }
!         /* If btree changes as our default, update pg_get_indexdef() */
!         | /*EMPTY*/                                { $$ = DEFAULT_INDEX_TYPE; }
          ;

  index_params:  index_list                        { $$ = $1; }
Index: src/backend/utils/adt/ruleutils.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v
retrieving revision 1.92
diff -c -r1.92 ruleutils.c
*** src/backend/utils/adt/ruleutils.c    6 Mar 2002 19:58:26 -0000    1.92
--- src/backend/utils/adt/ruleutils.c    8 Mar 2002 16:26:08 -0000
***************
*** 395,405 ****
       * Start the index definition
       */
      initStringInfo(&buf);
!     appendStringInfo(&buf, "CREATE %sINDEX %s ON %s USING %s (",
                       idxrec->indisunique ? "UNIQUE " : "",
                       quote_identifier(NameStr(idxrelrec->relname)),
!                      quote_identifier(NameStr(indrelrec->relname)),
                       quote_identifier(NameStr(amrec->amname)));

      /*
       * Collect the indexed attributes in keybuf
--- 395,410 ----
       * Start the index definition
       */
      initStringInfo(&buf);
!     appendStringInfo(&buf, "CREATE %sINDEX %s ON %s ",
                       idxrec->indisunique ? "UNIQUE " : "",
                       quote_identifier(NameStr(idxrelrec->relname)),
!                      quote_identifier(NameStr(indrelrec->relname)));
!
!     if (strcmp(NameStr(amrec->amname), DEFAULT_INDEX_TYPE) != 0)
!         appendStringInfo(&buf, "USING %s ",
                       quote_identifier(NameStr(amrec->amname)));
+
+     appendStringInfo(&buf, "(");

      /*
       * Collect the indexed attributes in keybuf
Index: src/include/catalog/index.h
===================================================================
RCS file: /cvsroot/pgsql/src/include/catalog/index.h,v
retrieving revision 1.44
diff -c -r1.44 index.h
*** src/include/catalog/index.h    19 Feb 2002 20:11:19 -0000    1.44
--- src/include/catalog/index.h    8 Mar 2002 16:26:12 -0000
***************
*** 18,23 ****
--- 18,24 ----
  #include "catalog/pg_index.h"
  #include "nodes/execnodes.h"

+ #define DEFAULT_INDEX_TYPE    "btree"

  /* Typedef for callback function for IndexBuildHeapScan */
  typedef void (*IndexBuildCallback) (Relation index,

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

Предыдущее
От: "Rod Taylor"
Дата:
Сообщение: Re: Domain Support -- another round
Следующее
От: Liam Stewart
Дата:
Сообщение: minor error reporting fixes