2008-05-17 03:28:26 +02:00
|
|
|
/*
|
2010-09-20 22:08:53 +02:00
|
|
|
* contrib/intarray/_int.h
|
2008-05-17 03:28:26 +02:00
|
|
|
*/
|
2006-07-11 00:06:11 +02:00
|
|
|
#ifndef ___INT_H__
|
|
|
|
#define ___INT_H__
|
|
|
|
|
2003-06-11 21:31:05 +02:00
|
|
|
#include "utils/array.h"
|
2014-02-17 15:33:31 +01:00
|
|
|
#include "utils/memutils.h"
|
2003-06-11 21:31:05 +02:00
|
|
|
|
|
|
|
/* number ranges for compression */
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
#define G_INT_NUMRANGES_DEFAULT 100
|
|
|
|
#define G_INT_NUMRANGES_MAX ((GISTMaxIndexKeySize - VARHDRSZ) / \
|
|
|
|
(2 * sizeof(int32)))
|
|
|
|
#define G_INT_GET_NUMRANGES() (PG_HAS_OPCLASS_OPTIONS() ? \
|
|
|
|
((GISTIntArrayOptions *) PG_GET_OPCLASS_OPTIONS())->num_ranges : \
|
|
|
|
G_INT_NUMRANGES_DEFAULT)
|
|
|
|
|
|
|
|
/* gist_int_ops opclass options */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
|
|
|
int num_ranges; /* number of ranges */
|
|
|
|
} GISTIntArrayOptions;
|
2003-06-11 21:31:05 +02:00
|
|
|
|
|
|
|
/* useful macros for accessing int4 arrays */
|
2012-06-25 00:51:46 +02:00
|
|
|
#define ARRPTR(x) ( (int32 *) ARR_DATA_PTR(x) )
|
2005-11-19 04:00:09 +01:00
|
|
|
#define ARRNELEMS(x) ArrayGetNItems(ARR_NDIM(x), ARR_DIMS(x))
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
/* reject arrays we can't handle; to wit, those containing nulls */
|
2005-11-19 04:00:09 +01:00
|
|
|
#define CHECKARRVALID(x) \
|
|
|
|
do { \
|
2011-01-09 06:39:21 +01:00
|
|
|
if (ARR_HASNULL(x) && array_contains_nulls(x)) \
|
|
|
|
ereport(ERROR, \
|
|
|
|
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), \
|
|
|
|
errmsg("array must not contain nulls"))); \
|
2005-11-19 04:00:09 +01:00
|
|
|
} while(0)
|
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
#define ARRISEMPTY(x) (ARRNELEMS(x) == 0)
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
/* sort the elements of the array */
|
2003-06-11 21:31:05 +02:00
|
|
|
#define SORT(x) \
|
|
|
|
do { \
|
2011-01-09 06:39:21 +01:00
|
|
|
int _nelems_ = ARRNELEMS(x); \
|
|
|
|
if (_nelems_ > 1) \
|
|
|
|
isort(ARRPTR(x), _nelems_); \
|
2003-06-11 21:31:05 +02:00
|
|
|
} while(0)
|
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
/* sort the elements of the array and remove duplicates */
|
2003-06-11 21:31:05 +02:00
|
|
|
#define PREPAREARR(x) \
|
|
|
|
do { \
|
2011-01-09 06:39:21 +01:00
|
|
|
int _nelems_ = ARRNELEMS(x); \
|
|
|
|
if (_nelems_ > 1) \
|
|
|
|
if (isort(ARRPTR(x), _nelems_)) \
|
|
|
|
(x) = _int_unique(x); \
|
2003-06-11 21:31:05 +02:00
|
|
|
} while(0)
|
|
|
|
|
|
|
|
/* "wish" function */
|
|
|
|
#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
|
|
|
|
|
|
|
|
|
|
|
|
/* bigint defines */
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
#define SIGLEN_DEFAULT (63 * 4)
|
|
|
|
#define SIGLEN_MAX GISTMaxIndexKeySize
|
|
|
|
#define SIGLENBIT(siglen) ((siglen) * BITS_PER_BYTE)
|
|
|
|
#define GET_SIGLEN() (PG_HAS_OPCLASS_OPTIONS() ? \
|
|
|
|
((GISTIntArrayBigOptions *) PG_GET_OPCLASS_OPTIONS())->siglen : \
|
|
|
|
SIGLEN_DEFAULT)
|
2003-06-11 21:31:05 +02:00
|
|
|
|
|
|
|
typedef char *BITVECP;
|
|
|
|
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
#define LOOPBYTE(siglen) \
|
|
|
|
for (i = 0; i < siglen; i++)
|
2003-06-11 21:31:05 +02:00
|
|
|
|
|
|
|
/* beware of multiple evaluation of arguments to these macros! */
|
2005-11-14 17:11:37 +01:00
|
|
|
#define GETBYTE(x,i) ( *( (BITVECP)(x) + (int)( (i) / BITS_PER_BYTE ) ) )
|
2003-06-11 21:31:05 +02:00
|
|
|
#define GETBITBYTE(x,i) ( (*((char*)(x)) >> (i)) & 0x01 )
|
2005-11-14 17:11:37 +01:00
|
|
|
#define CLRBIT(x,i) GETBYTE(x,i) &= ~( 0x01 << ( (i) % BITS_PER_BYTE ) )
|
|
|
|
#define SETBIT(x,i) GETBYTE(x,i) |= ( 0x01 << ( (i) % BITS_PER_BYTE ) )
|
|
|
|
#define GETBIT(x,i) ( (GETBYTE(x,i) >> ( (i) % BITS_PER_BYTE )) & 0x01 )
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
#define HASHVAL(val, siglen) (((unsigned int)(val)) % SIGLENBIT(siglen))
|
|
|
|
#define HASH(sign, val, siglen) SETBIT((sign), HASHVAL(val, siglen))
|
|
|
|
|
|
|
|
/* gist_intbig_ops opclass options */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
|
|
|
int siglen; /* signature length in bytes */
|
|
|
|
} GISTIntArrayBigOptions;
|
2003-06-11 21:31:05 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* type of index key
|
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2007-02-28 23:44:38 +01:00
|
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
2012-06-25 00:51:46 +02:00
|
|
|
int32 flag;
|
2015-02-20 06:11:42 +01:00
|
|
|
char data[FLEXIBLE_ARRAY_MEMBER];
|
2009-06-11 16:49:15 +02:00
|
|
|
} GISTTYPE;
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
#define ALLISTRUE 0x04
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
#define ISALLTRUE(x) ( ((GISTTYPE*)x)->flag & ALLISTRUE )
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2012-06-25 00:51:46 +02:00
|
|
|
#define GTHDRSIZE (VARHDRSZ + sizeof(int32))
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
#define CALCGTSIZE(flag, siglen) ( GTHDRSIZE+(((flag) & ALLISTRUE) ? 0 : (siglen)) )
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
#define GETSIGN(x) ( (BITVECP)( (char*)x+GTHDRSIZE ) )
|
2003-06-11 21:31:05 +02:00
|
|
|
|
|
|
|
/*
|
2011-01-09 06:39:21 +01:00
|
|
|
* useful functions
|
|
|
|
*/
|
2012-06-25 00:51:46 +02:00
|
|
|
bool isort(int32 *a, int len);
|
2003-08-04 02:43:34 +02:00
|
|
|
ArrayType *new_intArrayType(int num);
|
|
|
|
ArrayType *copy_intArrayType(ArrayType *a);
|
|
|
|
ArrayType *resize_intArrayType(ArrayType *a, int num);
|
|
|
|
int internal_size(int *a, int len);
|
|
|
|
ArrayType *_int_unique(ArrayType *a);
|
|
|
|
int32 intarray_match_first(ArrayType *a, int32 elem);
|
|
|
|
ArrayType *intarray_add_elem(ArrayType *a, int32 elem);
|
|
|
|
ArrayType *intarray_concat_arrays(ArrayType *a, ArrayType *b);
|
|
|
|
ArrayType *int_to_intset(int32 elem);
|
|
|
|
bool inner_int_overlap(ArrayType *a, ArrayType *b);
|
|
|
|
bool inner_int_contains(ArrayType *a, ArrayType *b);
|
|
|
|
ArrayType *inner_int_union(ArrayType *a, ArrayType *b);
|
|
|
|
ArrayType *inner_int_inter(ArrayType *a, ArrayType *b);
|
|
|
|
void rt__int_size(ArrayType *a, float *size);
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
void gensign(BITVECP sign, int *a, int len, int siglen);
|
2003-06-11 21:31:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Boolean Search
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#define BooleanSearchStrategy 20
|
|
|
|
|
|
|
|
/*
|
|
|
|
* item in polish notation with back link
|
|
|
|
* to left operand
|
|
|
|
*/
|
|
|
|
typedef struct ITEM
|
|
|
|
{
|
2012-06-25 00:51:46 +02:00
|
|
|
int16 type;
|
|
|
|
int16 left;
|
|
|
|
int32 val;
|
2009-06-11 16:49:15 +02:00
|
|
|
} ITEM;
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
typedef struct QUERYTYPE
|
2003-06-11 21:31:05 +02:00
|
|
|
{
|
2007-02-28 23:44:38 +01:00
|
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
2012-06-25 00:51:46 +02:00
|
|
|
int32 size; /* number of ITEMs */
|
2015-02-20 06:11:42 +01:00
|
|
|
ITEM items[FLEXIBLE_ARRAY_MEMBER];
|
2009-06-11 16:49:15 +02:00
|
|
|
} QUERYTYPE;
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
#define HDRSIZEQT offsetof(QUERYTYPE, items)
|
|
|
|
#define COMPUTESIZE(size) ( HDRSIZEQT + (size) * sizeof(ITEM) )
|
2014-02-17 15:33:31 +01:00
|
|
|
#define QUERYTYPEMAXITEMS ((MaxAllocSize - HDRSIZEQT) / sizeof(ITEM))
|
2011-01-09 06:39:21 +01:00
|
|
|
#define GETQUERY(x) ( (x)->items )
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
/* "type" codes for ITEM */
|
2006-10-04 02:30:14 +02:00
|
|
|
#define END 0
|
|
|
|
#define ERR 1
|
|
|
|
#define VAL 2
|
|
|
|
#define OPR 3
|
|
|
|
#define OPEN 4
|
|
|
|
#define CLOSE 5
|
2006-05-03 18:31:07 +02:00
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
/* fmgr macros for QUERYTYPE objects */
|
|
|
|
#define DatumGetQueryTypeP(X) ((QUERYTYPE *) PG_DETOAST_DATUM(X))
|
|
|
|
#define DatumGetQueryTypePCopy(X) ((QUERYTYPE *) PG_DETOAST_DATUM_COPY(X))
|
|
|
|
#define PG_GETARG_QUERYTYPE_P(n) DatumGetQueryTypeP(PG_GETARG_DATUM(n))
|
|
|
|
#define PG_GETARG_QUERYTYPE_P_COPY(n) DatumGetQueryTypePCopy(PG_GETARG_DATUM(n))
|
|
|
|
|
Implement operator class parameters
PostgreSQL provides set of template index access methods, where opclasses have
much freedom in the semantics of indexing. These index AMs are GiST, GIN,
SP-GiST and BRIN. There opclasses define representation of keys, operations on
them and supported search strategies. So, it's natural that opclasses may be
faced some tradeoffs, which require user-side decision. This commit implements
opclass parameters allowing users to set some values, which tell opclass how to
index the particular dataset.
This commit doesn't introduce new storage in system catalog. Instead it uses
pg_attribute.attoptions, which is used for table column storage options but
unused for index attributes.
In order to evade changing signature of each opclass support function, we
implement unified way to pass options to opclass support functions. Options
are set to fn_expr as the constant bytea expression. It's possible due to the
fact that opclass support functions are executed outside of expressions, so
fn_expr is unused for them.
This commit comes with some examples of opclass options usage. We parametrize
signature length in GiST. That applies to multiple opclasses: tsvector_ops,
gist__intbig_ops, gist_ltree_ops, gist__ltree_ops, gist_trgm_ops and
gist_hstore_ops. Also we parametrize maximum number of integer ranges for
gist__int_ops. However, the main future usage of this feature is expected
to be json, where users would be able to specify which way to index particular
json parts.
Catversion is bumped.
Discussion: https://postgr.es/m/d22c3a18-31c7-1879-fc11-4c1ce2f5e5af%40postgrespro.ru
Author: Nikita Glukhov, revised by me
Reviwed-by: Nikolay Shaplov, Robert Haas, Tom Lane, Tomas Vondra, Alvaro Herrera
2020-03-30 18:17:11 +02:00
|
|
|
bool signconsistent(QUERYTYPE *query, BITVECP sign, int siglen, bool calcnot);
|
2009-06-11 16:49:15 +02:00
|
|
|
bool execconsistent(QUERYTYPE *query, ArrayType *array, bool calcnot);
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
bool gin_bool_consistent(QUERYTYPE *query, bool *check);
|
|
|
|
bool query_has_required_values(QUERYTYPE *query);
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
int compASC(const void *a, const void *b);
|
2003-08-04 02:43:34 +02:00
|
|
|
int compDESC(const void *a, const void *b);
|
2003-06-11 21:31:05 +02:00
|
|
|
|
2011-01-09 06:39:21 +01:00
|
|
|
/* sort, either ascending or descending */
|
|
|
|
#define QSORT(a, direction) \
|
|
|
|
do { \
|
|
|
|
int _nelems_ = ARRNELEMS(a); \
|
|
|
|
if (_nelems_ > 1) \
|
2012-06-25 00:51:46 +02:00
|
|
|
qsort((void*) ARRPTR(a), _nelems_, sizeof(int32), \
|
2011-01-09 06:39:21 +01:00
|
|
|
(direction) ? compASC : compDESC ); \
|
|
|
|
} while(0)
|
2006-07-11 00:06:11 +02:00
|
|
|
|
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4dd0dad0dd9eea4be9cc1412373a8c89 wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 21:18:54 +02:00
|
|
|
#endif /* ___INT_H__ */
|