Thread: minor contrib/btree_gist cleanup

minor contrib/btree_gist cleanup

From
Neil Conway
Date:
This patch makes some minor style cleanups to contrib/btree_gist: remove
the "extern" keyword for function definitions, reorganize some
PG_GETARG_XXX() usage, and similar.

Barring any objections, I'll apply this to HEAD tomorrow.

-Neil
Index: contrib/btree_gist/btree_bit.c
===================================================================
RCS file: /var/lib/cvs/pgsql/contrib/btree_gist/btree_bit.c,v
retrieving revision 1.3
diff -c -r1.3 btree_bit.c
*** contrib/btree_gist/btree_bit.c    1 Mar 2005 15:40:03 -0000    1.3
--- contrib/btree_gist/btree_bit.c    11 May 2005 01:05:20 -0000
***************
*** 127,133 ****
  {
      GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
!     void       *qtst = (void *) DatumGetPointer(PG_GETARG_DATUM(1));
      void       *query = (void *) DatumGetByteaP(PG_GETARG_DATUM(1));
      StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
      bool        retval = FALSE;
--- 127,133 ----
  {
      GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
!     void       *qtst = (void *) PG_GETARG_POINTER(1);
      void       *query = (void *) DatumGetByteaP(PG_GETARG_DATUM(1));
      StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
      bool        retval = FALSE;
***************
*** 184,192 ****
  Datum
  gbt_bit_penalty(PG_FUNCTION_ARGS)
  {
-     float       *result = (float *) PG_GETARG_POINTER(2);
      GISTENTRY  *o = (GISTENTRY *) PG_GETARG_POINTER(0);
      GISTENTRY  *n = (GISTENTRY *) PG_GETARG_POINTER(1);

      PG_RETURN_POINTER(gbt_var_penalty(result, o, n, &tinfo));
  }
--- 184,192 ----
  Datum
  gbt_bit_penalty(PG_FUNCTION_ARGS)
  {
      GISTENTRY  *o = (GISTENTRY *) PG_GETARG_POINTER(0);
      GISTENTRY  *n = (GISTENTRY *) PG_GETARG_POINTER(1);
+     float       *result = (float *) PG_GETARG_POINTER(2);

      PG_RETURN_POINTER(gbt_var_penalty(result, o, n, &tinfo));
  }
Index: contrib/btree_gist/btree_bytea.c
===================================================================
RCS file: /var/lib/cvs/pgsql/contrib/btree_gist/btree_bytea.c,v
retrieving revision 1.3
diff -c -r1.3 btree_bytea.c
*** contrib/btree_gist/btree_bytea.c    1 Mar 2005 15:40:03 -0000    1.3
--- contrib/btree_gist/btree_bytea.c    11 May 2005 01:05:20 -0000
***************
*** 97,103 ****
  {
      GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
!     void       *qtst = (void *) DatumGetPointer(PG_GETARG_DATUM(1));
      void       *query = (void *) DatumGetByteaP(PG_GETARG_DATUM(1));
      StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
      bool        retval = FALSE;
--- 97,103 ----
  {
      GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
!     void       *qtst = (void *) PG_GETARG_POINTER(1);
      void       *query = (void *) DatumGetByteaP(PG_GETARG_DATUM(1));
      StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
      bool        retval = FALSE;
***************
*** 146,154 ****
  Datum
  gbt_bytea_penalty(PG_FUNCTION_ARGS)
  {
-     float       *result = (float *) PG_GETARG_POINTER(2);
      GISTENTRY  *o = (GISTENTRY *) PG_GETARG_POINTER(0);
      GISTENTRY  *n = (GISTENTRY *) PG_GETARG_POINTER(1);

      PG_RETURN_POINTER(gbt_var_penalty(result, o, n, &tinfo));
  }
--- 146,154 ----
  Datum
  gbt_bytea_penalty(PG_FUNCTION_ARGS)
  {
      GISTENTRY  *o = (GISTENTRY *) PG_GETARG_POINTER(0);
      GISTENTRY  *n = (GISTENTRY *) PG_GETARG_POINTER(1);
+     float       *result = (float *) PG_GETARG_POINTER(2);

      PG_RETURN_POINTER(gbt_var_penalty(result, o, n, &tinfo));
  }
Index: contrib/btree_gist/btree_numeric.c
===================================================================
RCS file: /var/lib/cvs/pgsql/contrib/btree_gist/btree_numeric.c,v
retrieving revision 1.3
diff -c -r1.3 btree_numeric.c
*** contrib/btree_gist/btree_numeric.c    1 Mar 2005 15:40:03 -0000    1.3
--- contrib/btree_gist/btree_numeric.c    11 May 2005 01:12:45 -0000
***************
*** 98,104 ****

      GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
!     void       *qtst = (void *) DatumGetPointer(PG_GETARG_DATUM(1));
      void       *query = (void *) DatumGetNumeric(PG_GETARG_DATUM(1));
      StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
      bool        retval = FALSE;
--- 98,104 ----

      GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
!     void       *qtst = (void *) PG_GETARG_POINTER(1);
      void       *query = (void *) DatumGetNumeric(PG_GETARG_DATUM(1));
      StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
      bool        retval = FALSE;
Index: contrib/btree_gist/btree_text.c
===================================================================
RCS file: /var/lib/cvs/pgsql/contrib/btree_gist/btree_text.c,v
retrieving revision 1.4
diff -c -r1.4 btree_text.c
*** contrib/btree_gist/btree_text.c    1 Mar 2005 15:40:04 -0000    1.4
--- contrib/btree_gist/btree_text.c    11 May 2005 01:05:20 -0000
***************
*** 124,130 ****
  {
      GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
!     void       *qtst = (void *) DatumGetPointer(PG_GETARG_DATUM(1));
      void       *query = (void *) DatumGetTextP(PG_GETARG_DATUM(1));
      StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
      bool        retval = FALSE;
--- 124,130 ----
  {
      GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
!     void       *qtst = (void *) PG_GETARG_POINTER(1);
      void       *query = (void *) DatumGetTextP(PG_GETARG_DATUM(1));
      StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
      bool        retval = FALSE;
***************
*** 144,150 ****
  {
      GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
!     void       *qtst = (void *) DatumGetPointer(PG_GETARG_DATUM(1));
      void       *query = (void *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1)));
      void       *trim = (void *) DatumGetPointer(DirectFunctionCall1(rtrim1, PointerGetDatum(query)));
      StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
--- 144,150 ----
  {
      GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
      GBT_VARKEY *key = (GBT_VARKEY *) DatumGetPointer(entry->key);
!     void       *qtst = (void *) PG_GETARG_POINTER(1);
      void       *query = (void *) DatumGetPointer(PG_DETOAST_DATUM(PG_GETARG_DATUM(1)));
      void       *trim = (void *) DatumGetPointer(DirectFunctionCall1(rtrim1, PointerGetDatum(query)));
      StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
***************
*** 197,205 ****
  Datum
  gbt_text_penalty(PG_FUNCTION_ARGS)
  {
-     float       *result = (float *) PG_GETARG_POINTER(2);
      GISTENTRY  *o = (GISTENTRY *) PG_GETARG_POINTER(0);
      GISTENTRY  *n = (GISTENTRY *) PG_GETARG_POINTER(1);

      PG_RETURN_POINTER(gbt_var_penalty(result, o, n, &tinfo));
  }
--- 197,205 ----
  Datum
  gbt_text_penalty(PG_FUNCTION_ARGS)
  {
      GISTENTRY  *o = (GISTENTRY *) PG_GETARG_POINTER(0);
      GISTENTRY  *n = (GISTENTRY *) PG_GETARG_POINTER(1);
+     float       *result = (float *) PG_GETARG_POINTER(2);

      PG_RETURN_POINTER(gbt_var_penalty(result, o, n, &tinfo));
  }
Index: contrib/btree_gist/btree_utils_num.c
===================================================================
RCS file: /var/lib/cvs/pgsql/contrib/btree_gist/btree_utils_num.c,v
retrieving revision 1.5
diff -c -r1.5 btree_utils_num.c
*** contrib/btree_gist/btree_utils_num.c    25 Feb 2005 14:03:04 -0000    1.5
--- contrib/btree_gist/btree_utils_num.c    11 May 2005 01:05:20 -0000
***************
*** 2,8 ****
  #include "btree_utils_num.h"
  #include "utils/date.h"

! extern GISTENTRY *
  gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry, const gbtree_ninfo * tinfo)
  {

--- 2,8 ----
  #include "btree_utils_num.h"
  #include "utils/date.h"

! GISTENTRY *
  gbt_num_compress(GISTENTRY *retval, GISTENTRY *entry, const gbtree_ninfo * tinfo)
  {

***************
*** 61,67 ****
  ** The GiST union method for numerical values
  */

! extern void *
  gbt_num_union(GBT_NUMKEY * out, const GistEntryVector *entryvec, const gbtree_ninfo * tinfo)
  {
      int            i,
--- 61,67 ----
  ** The GiST union method for numerical values
  */

! void *
  gbt_num_union(GBT_NUMKEY * out, const GistEntryVector *entryvec, const gbtree_ninfo * tinfo)
  {
      int            i,
***************
*** 99,105 ****
  ** The GiST same method for numerical values
  */

! extern bool
  gbt_num_same(const GBT_NUMKEY * a, const GBT_NUMKEY * b, const gbtree_ninfo * tinfo)
  {

--- 99,105 ----
  ** The GiST same method for numerical values
  */

! bool
  gbt_num_same(const GBT_NUMKEY * a, const GBT_NUMKEY * b, const gbtree_ninfo * tinfo)
  {

***************
*** 121,127 ****
  }


! extern void
  gbt_num_bin_union(Datum *u, GBT_NUMKEY * e, const gbtree_ninfo * tinfo)
  {

--- 121,127 ----
  }


! void
  gbt_num_bin_union(Datum *u, GBT_NUMKEY * e, const gbtree_ninfo * tinfo)
  {

***************
*** 155,161 ****
  ** The GiST consistent method
  */

! extern bool
  gbt_num_consistent(
                     const GBT_NUMKEY_R * key,
                     const void *query,
--- 155,161 ----
  ** The GiST consistent method
  */

! bool
  gbt_num_consistent(
                     const GBT_NUMKEY_R * key,
                     const void *query,
Index: contrib/btree_gist/btree_utils_var.c
===================================================================
RCS file: /var/lib/cvs/pgsql/contrib/btree_gist/btree_utils_var.c,v
retrieving revision 1.6
diff -c -r1.6 btree_utils_var.c
*** contrib/btree_gist/btree_utils_var.c    1 Mar 2005 15:40:04 -0000    1.6
--- contrib/btree_gist/btree_utils_var.c    11 May 2005 01:05:20 -0000
***************
*** 27,34 ****
  }

  /* Returns a better readable representaion of variable key ( sets pointer ) */
!
! extern        GBT_VARKEY_R
  gbt_var_key_readable(const GBT_VARKEY * k)
  {

--- 27,33 ----
  }

  /* Returns a better readable representaion of variable key ( sets pointer ) */
! GBT_VARKEY_R
  gbt_var_key_readable(const GBT_VARKEY * k)
  {

***************
*** 43,49 ****
  }


! extern GBT_VARKEY *
  gbt_var_key_copy(const GBT_VARKEY_R * u, bool force_node)
  {

--- 42,48 ----
  }


! GBT_VARKEY *
  gbt_var_key_copy(const GBT_VARKEY_R * u, bool force_node)
  {

***************
*** 208,214 ****



! extern void
  gbt_var_bin_union(Datum *u, GBT_VARKEY * e, const gbtree_vinfo * tinfo)
  {

--- 207,213 ----



! void
  gbt_var_bin_union(Datum *u, GBT_VARKEY * e, const gbtree_vinfo * tinfo)
  {

***************
*** 265,271 ****



! extern GISTENTRY *
  gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo * tinfo)
  {

--- 264,270 ----



! GISTENTRY *
  gbt_var_compress(GISTENTRY *entry, const gbtree_vinfo * tinfo)
  {

***************
*** 296,302 ****



! extern GBT_VARKEY *
  gbt_var_union(const GistEntryVector *entryvec, int32 *size, const gbtree_vinfo * tinfo)
  {

--- 295,301 ----



! GBT_VARKEY *
  gbt_var_union(const GistEntryVector *entryvec, int32 *size, const gbtree_vinfo * tinfo)
  {

***************
*** 337,343 ****
  }


! extern bool
  gbt_var_same(bool *result, const Datum d1, const Datum d2, const gbtree_vinfo * tinfo)
  {

--- 336,342 ----
  }


! bool
  gbt_var_same(bool *result, const Datum d1, const Datum d2, const gbtree_vinfo * tinfo)
  {

***************
*** 362,368 ****



! extern float *
  gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree_vinfo * tinfo)
  {

--- 361,367 ----



! float *
  gbt_var_penalty(float *res, const GISTENTRY *o, const GISTENTRY *n, const gbtree_vinfo * tinfo)
  {

***************
*** 458,464 ****
      return (*gbt_vsrt_cmp_tinfo->f_cmp) (ar.lower, br.lower);
  }

! extern GIST_SPLITVEC *
  gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_vinfo * tinfo)
  {
      OffsetNumber i,
--- 457,463 ----
      return (*gbt_vsrt_cmp_tinfo->f_cmp) (ar.lower, br.lower);
  }

! GIST_SPLITVEC *
  gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v, const gbtree_vinfo * tinfo)
  {
      OffsetNumber i,
***************
*** 563,569 ****
  /*
   * The GiST consistent method
   */
! extern bool
  gbt_var_consistent(
                     GBT_VARKEY_R * key,
                     const void *query,
--- 562,568 ----
  /*
   * The GiST consistent method
   */
! bool
  gbt_var_consistent(
                     GBT_VARKEY_R * key,
                     const void *query,
Index: contrib/rtree_gist/README.rtree_gist
===================================================================
RCS file: /var/lib/cvs/pgsql/contrib/rtree_gist/README.rtree_gist,v
retrieving revision 1.3
diff -c -r1.3 README.rtree_gist
*** contrib/rtree_gist/README.rtree_gist    1 Nov 2004 11:11:13 -0000    1.3
--- contrib/rtree_gist/README.rtree_gist    11 May 2005 01:05:20 -0000
***************
*** 56,62 ****

    cd ./bench
    1. createdb TEST
!   2. psql TEST < ../box.sql
    3. ./create_test.pl | psql TEST
       -- change $NUM - number of rows in test dataset
    4. ./bench.pl - perl script to benchmark queries.
--- 56,62 ----

    cd ./bench
    1. createdb TEST
!   2. psql TEST < ../rtree_gist.sql
    3. ./create_test.pl | psql TEST
       -- change $NUM - number of rows in test dataset
    4. ./bench.pl - perl script to benchmark queries.

Re: minor contrib/btree_gist cleanup

From
Neil Conway
Date:
Neil Conway wrote:
> This patch makes some minor style cleanups to contrib/btree_gist: remove
> the "extern" keyword for function definitions, reorganize some
> PG_GETARG_XXX() usage, and similar.

Applied.

-Neil