v20240609-0004-fix-pgindent.patch
text/x-patch
Filename: v20240609-0004-fix-pgindent.patch
Type: text/x-patch
Part: 3
Patch
Format: format-patch
Series: patch v20240609-0004
Subject: fix: pgindent
| File | + | − |
|---|---|---|
| src/backend/utils/sort/mk_qsort_tuple.c | 63 | 58 |
| src/backend/utils/sort/tuplesort.c | 11 | 15 |
| src/backend/utils/sort/tuplesortvariants.c | 62 | 63 |
| src/include/utils/tuplesort.h | 16 | 18 |
From a2788b2f7dcceeeaa9229bfbf1ba2e5c413afb99 Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tv@fuzzy.cz>
Date: Sun, 9 Jun 2024 13:41:54 +0200
Subject: [PATCH v20240609 4/4] fix: pgindent
---
src/backend/utils/sort/mk_qsort_tuple.c | 121 ++++++++++----------
src/backend/utils/sort/tuplesort.c | 26 ++---
src/backend/utils/sort/tuplesortvariants.c | 125 ++++++++++-----------
src/include/utils/tuplesort.h | 34 +++---
4 files changed, 152 insertions(+), 154 deletions(-)
diff --git a/src/backend/utils/sort/mk_qsort_tuple.c b/src/backend/utils/sort/mk_qsort_tuple.c
index 9c5715380aa..e44bc50d652 100644
--- a/src/backend/utils/sort/mk_qsort_tuple.c
+++ b/src/backend/utils/sort/mk_qsort_tuple.c
@@ -22,11 +22,11 @@
/* Swap two tuples in sort tuple array */
static inline void
-mkqs_swap(int a,
- int b,
+mkqs_swap(int a,
+ int b,
SortTuple *x)
{
- SortTuple t;
+ SortTuple t;
if (a == b)
return;
@@ -37,9 +37,9 @@ mkqs_swap(int a,
/* Swap tuples by batch in sort tuple array */
static inline void
-mkqs_vec_swap(int a,
- int b,
- int size,
+mkqs_vec_swap(int a,
+ int b,
+ int size,
SortTuple *x)
{
while (size-- > 0)
@@ -56,12 +56,12 @@ mkqs_vec_swap(int a,
* a tuple array, so tupleIndex is unnecessary
*/
static inline bool
-check_datum_null(SortTuple *x,
- int depth,
+check_datum_null(SortTuple *x,
+ int depth,
Tuplesortstate *state)
{
- Datum datum;
- bool isNull;
+ Datum datum;
+ bool isNull;
Assert(depth < state->base.nKeys);
@@ -94,15 +94,17 @@ check_datum_null(SortTuple *x,
* See comparetup_heap() for details.
*/
static inline int
-mkqs_compare_datum(SortTuple *tuple1,
- SortTuple *tuple2,
- int depth,
+mkqs_compare_datum(SortTuple *tuple1,
+ SortTuple *tuple2,
+ int depth,
Tuplesortstate *state)
{
- Datum datum1, datum2;
- bool isNull1, isNull2;
+ Datum datum1,
+ datum2;
+ bool isNull1,
+ isNull2;
SortSupport sortKey;
- int ret = 0;
+ int ret = 0;
Assert(state->base.mkqsGetDatumFunc);
Assert(depth < state->base.nKeys);
@@ -120,10 +122,10 @@ mkqs_compare_datum(SortTuple *tuple1,
sortKey);
/*
- * If "abbreviated key" is enabled, and we are in the first depth, it means
- * only "abbreviated keys" are compared. If the two datums are determined to
- * be equal by ApplySortComparator(), we need to perform an extra "full"
- * comparing by ApplySortAbbrevFullComparator().
+ * If "abbreviated key" is enabled, and we are in the first depth, it
+ * means only "abbreviated keys" are compared. If the two datums are
+ * determined to be equal by ApplySortComparator(), we need to perform an
+ * extra "full" comparing by ApplySortAbbrevFullComparator().
*/
if (sortKey->abbrev_converter &&
depth == 0 &&
@@ -150,14 +152,14 @@ mkqs_compare_datum(SortTuple *tuple1,
* Verify whether the SortTuple list is ordered or not at specified depth
*/
static void
-mkqs_verify(SortTuple *x,
- int n,
- int depth,
+mkqs_verify(SortTuple *x,
+ int n,
+ int depth,
Tuplesortstate *state)
{
- int ret;
+ int ret;
- for (int i = 0;i < n - 1;i++)
+ for (int i = 0; i < n - 1; i++)
{
ret = mkqs_compare_datum(x + i,
x + i + 1,
@@ -174,27 +176,31 @@ mkqs_verify(SortTuple *x,
* seenNull indicates whether we have seen NULL in any datum we checked
*/
static void
-mk_qsort_tuple(SortTuple *x,
- size_t n,
- int depth,
- Tuplesortstate *state,
- bool seenNull)
+mk_qsort_tuple(SortTuple *x,
+ size_t n,
+ int depth,
+ Tuplesortstate *state,
+ bool seenNull)
{
/*
- * In the process, the tuple array consists of five parts:
- * left equal, less, not-processed, greater, right equal
+ * In the process, the tuple array consists of five parts: left equal,
+ * less, not-processed, greater, right equal
*
- * lessStart indicates the first position of less part
- * lessEnd indicates the next position after less part
- * greaterStart indicates the prior position before greater part
- * greaterEnd indicates the latest position of greater part
- * the range between lessEnd and greaterStart (inclusive) is not-processed
+ * lessStart indicates the first position of less part lessEnd indicates
+ * the next position after less part greaterStart indicates the prior
+ * position before greater part greaterEnd indicates the latest position
+ * of greater part the range between lessEnd and greaterStart (inclusive)
+ * is not-processed
*/
- int lessStart, lessEnd, greaterStart, greaterEnd, tupCount;
- int32 dist;
- SortTuple *pivot;
- bool isDatumNull;
- bool strictOrdered = true;
+ int lessStart,
+ lessEnd,
+ greaterStart,
+ greaterEnd,
+ tupCount;
+ int32 dist;
+ SortTuple *pivot;
+ bool isDatumNull;
+ bool strictOrdered = true;
Assert(depth <= state->base.nKeys);
Assert(state->base.sortKeys);
@@ -212,12 +218,12 @@ mk_qsort_tuple(SortTuple *x,
/*
* Check if the array is ordered already. If yes, return immediately.
* Different from qsort_tuple(), the array must be strict ordered (no
- * equal datums). If there are equal datums, we must continue the mk
- * qsort process to check datums on lower depth.
+ * equal datums). If there are equal datums, we must continue the mk qsort
+ * process to check datums on lower depth.
*/
- for (int i = 0;i < n - 1;i++)
+ for (int i = 0; i < n - 1; i++)
{
- int ret;
+ int ret;
CHECK_FOR_INTERRUPTS();
ret = mkqs_compare_datum(x + i,
@@ -299,8 +305,7 @@ mk_qsort_tuple(SortTuple *x,
}
/*
- * Now the array has four parts:
- * left equal, lesser, greater, right equal
+ * Now the array has four parts: left equal, lesser, greater, right equal
* Note greaterStart is less than lessEnd now
*/
@@ -313,9 +318,8 @@ mk_qsort_tuple(SortTuple *x,
mkqs_vec_swap(lessEnd, n - dist, dist, x);
/*
- * Now the array has three parts:
- * lesser, equal, greater
- * Note that one or two parts may have no element at all.
+ * Now the array has three parts: lesser, equal, greater Note that one or
+ * two parts may have no element at all.
*/
/* Recursively sort the lesser part */
@@ -331,9 +335,9 @@ mk_qsort_tuple(SortTuple *x,
/* Recursively sort the equal part */
/*
- * (x + dist) means the first tuple in the equal part
- * Since all tuples have equal datums at current depth, we just check any one
- * of them to determine whether we have seen null datum.
+ * (x + dist) means the first tuple in the equal part Since all tuples
+ * have equal datums at current depth, we just check any one of them to
+ * determine whether we have seen null datum.
*/
isDatumNull = check_datum_null(x + dist, depth, state);
@@ -347,7 +351,9 @@ mk_qsort_tuple(SortTuple *x,
depth + 1,
state,
seenNull || isDatumNull);
- } else {
+ }
+ else
+ {
/*
* We have reach the max depth: Call mkqsHandleDupFunc to handle
* duplicated tuples if necessary, e.g. checking uniqueness or extra
@@ -355,9 +361,8 @@ mk_qsort_tuple(SortTuple *x,
*/
/*
- * Call mkqsHandleDupFunc if:
- * 1. mkqsHandleDupFunc is filled
- * 2. the size of equal part > 1
+ * Call mkqsHandleDupFunc if: 1. mkqsHandleDupFunc is filled 2. the
+ * size of equal part > 1
*/
if (state->base.mkqsHandleDupFunc &&
(tupCount > 1))
diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index 5718911eb9b..d51d97b1136 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -340,7 +340,7 @@ struct Tuplesortstate
#endif
/* Whether multi-key quick sort is used */
- bool mkqsUsed;
+ bool mkqsUsed;
};
/*
@@ -2729,23 +2729,19 @@ tuplesort_sort_memtuples(Tuplesortstate *state)
if (state->memtupcount > 1)
{
/*
- * Apply multi-key quick sort when:
- * 1. enable_mk_sort is set
- * 2. There are multiple keys available
- * 3. mkqsGetDatumFunc is filled, which implies that current tuple
- * type is supported by mk qsort. (By now only Heap tuple and Btree
- * Index tuple are supported, and more types may be supported in
- * future.)
+ * Apply multi-key quick sort when: 1. enable_mk_sort is set 2. There
+ * are multiple keys available 3. mkqsGetDatumFunc is filled, which
+ * implies that current tuple type is supported by mk qsort. (By now
+ * only Heap tuple and Btree Index tuple are supported, and more types
+ * may be supported in future.)
*
* A summary of tuple types supported by mk qsort:
*
- * HeapTuple: supported
- * IndexTuple(btree): supported
- * IndexTuple(hash): not supported because there is only one key
- * DatumTuple: not supported because there is only one key
- * HeapTuple(for cluster): not supported yet
- * IndexTuple(gist): not supported yet
- * IndexTuple(brin): not supported yet
+ * HeapTuple: supported IndexTuple(btree): supported IndexTuple(hash):
+ * not supported because there is only one key DatumTuple: not
+ * supported because there is only one key HeapTuple(for cluster): not
+ * supported yet IndexTuple(gist): not supported yet IndexTuple(brin):
+ * not supported yet
*/
if (enable_mk_sort &&
state->base.nKeys > 1 &&
diff --git a/src/backend/utils/sort/tuplesortvariants.c b/src/backend/utils/sort/tuplesortvariants.c
index 412e5b9b588..a41d4daa4b3 100644
--- a/src/backend/utils/sort/tuplesortvariants.c
+++ b/src/backend/utils/sort/tuplesortvariants.c
@@ -93,40 +93,40 @@ static void readtup_datum(Tuplesortstate *state, SortTuple *stup,
LogicalTape *tape, unsigned int len);
static void freestate_cluster(Tuplesortstate *state);
-static Datum mkqs_get_datum_heap(SortTuple *x,
- const int tupleIndex,
- const int depth,
+static Datum mkqs_get_datum_heap(SortTuple *x,
+ const int tupleIndex,
+ const int depth,
Tuplesortstate *state,
- Datum *datum,
- bool *isNull,
- bool useFullKey);
+ Datum *datum,
+ bool *isNull,
+ bool useFullKey);
-static Datum mkqs_get_datum_index_btree(SortTuple *x,
- const int tupleIndex,
- const int depth,
+static Datum mkqs_get_datum_index_btree(SortTuple *x,
+ const int tupleIndex,
+ const int depth,
Tuplesortstate *state,
- Datum *datum,
- bool *isNull,
- bool useFullKey);
+ Datum *datum,
+ bool *isNull,
+ bool useFullKey);
static void
-mkqs_handle_dup_index_btree(SortTuple *x,
- const int tupleCount,
- const bool seenNull,
- Tuplesortstate *state);
+ mkqs_handle_dup_index_btree(SortTuple *x,
+ const int tupleCount,
+ const bool seenNull,
+ Tuplesortstate *state);
static int
-mkqs_compare_equal_index_btree(const SortTuple *a,
- const SortTuple *b,
- Tuplesortstate *state);
+ mkqs_compare_equal_index_btree(const SortTuple *a,
+ const SortTuple *b,
+ Tuplesortstate *state);
static inline int
-tuplesort_compare_by_item_pointer(const IndexTuple tuple1,
- const IndexTuple tuple2);
+ tuplesort_compare_by_item_pointer(const IndexTuple tuple1,
+ const IndexTuple tuple2);
static inline void
-raise_error_of_dup_index(IndexTuple x,
- Tuplesortstate *state);
+ raise_error_of_dup_index(IndexTuple x,
+ Tuplesortstate *state);
/*
* Data structure pointed by "TuplesortPublic.arg" for the CLUSTER case. Set by
@@ -1918,18 +1918,18 @@ readtup_datum(Tuplesortstate *state, SortTuple *stup,
* See comparetup_heap() for details.
*/
static Datum
-mkqs_get_datum_heap(SortTuple *x,
- int tupleIndex,
- int depth,
+mkqs_get_datum_heap(SortTuple *x,
+ int tupleIndex,
+ int depth,
Tuplesortstate *state,
- Datum *datum,
- bool *isNull,
- bool useFullKey)
+ Datum *datum,
+ bool *isNull,
+ bool useFullKey)
{
- TupleDesc tupDesc = NULL;
+ TupleDesc tupDesc = NULL;
HeapTupleData heapTuple;
- AttrNumber attno;
- SortTuple *sortTuple = x + tupleIndex;
+ AttrNumber attno;
+ SortTuple *sortTuple = x + tupleIndex;
TuplesortPublic *base = TuplesortstateGetPublic(state);
SortSupport sortKey = base->sortKeys + depth;;
@@ -1942,7 +1942,7 @@ mkqs_get_datum_heap(SortTuple *x,
*/
AssertImply(useFullKey, depth == 0);
- tupDesc = (TupleDesc)base->arg;
+ tupDesc = (TupleDesc) base->arg;
/*
* When useFullKey is false, and the first datum is requested, return the
@@ -1979,16 +1979,16 @@ mkqs_get_datum_heap(SortTuple *x,
* See comparetup_index_btree() for details.
*/
static Datum
-mkqs_get_datum_index_btree(SortTuple *x,
- const int tupleIndex,
- const int depth,
+mkqs_get_datum_index_btree(SortTuple *x,
+ const int tupleIndex,
+ const int depth,
Tuplesortstate *state,
- Datum *datum,
- bool *isNull,
- bool useFullKey)
+ Datum *datum,
+ bool *isNull,
+ bool useFullKey)
{
- TupleDesc tupDesc;
- IndexTuple indexTuple;
+ TupleDesc tupDesc;
+ IndexTuple indexTuple;
SortTuple *sortTuple = x + tupleIndex;
TuplesortPublic *base = TuplesortstateGetPublic(state);
TuplesortIndexBTreeArg *arg = (TuplesortIndexBTreeArg *) base->arg;
@@ -2031,9 +2031,9 @@ mkqs_get_datum_index_btree(SortTuple *x,
* tupleCount: count of the tuples
*/
static void
-mkqs_handle_dup_index_btree(SortTuple *x,
- const int tupleCount,
- const bool seenNull,
+mkqs_handle_dup_index_btree(SortTuple *x,
+ const int tupleCount,
+ const bool seenNull,
Tuplesortstate *state)
{
TuplesortPublic *base = TuplesortstateGetPublic(state);
@@ -2043,11 +2043,10 @@ mkqs_handle_dup_index_btree(SortTuple *x,
if (arg->enforceUnique && !(!arg->uniqueNullsNotDistinct && seenNull))
{
/*
- * x means the first tuple of duplicated tuple list
- * Since they are duplicated, simply pick up the first one
- * to raise error
+ * x means the first tuple of duplicated tuple list Since they are
+ * duplicated, simply pick up the first one to raise error
*/
- raise_error_of_dup_index((IndexTuple)(x->tuple), state);
+ raise_error_of_dup_index((IndexTuple) (x->tuple), state);
}
/*
@@ -2069,10 +2068,10 @@ mkqs_handle_dup_index_btree(SortTuple *x,
static int
mkqs_compare_equal_index_btree(const SortTuple *a,
const SortTuple *b,
- Tuplesortstate *state)
+ Tuplesortstate *state)
{
- IndexTuple tuple1;
- IndexTuple tuple2;
+ IndexTuple tuple1;
+ IndexTuple tuple2;
tuple1 = (IndexTuple) a->tuple;
tuple2 = (IndexTuple) b->tuple;
@@ -2108,26 +2107,26 @@ tuplesort_compare_by_item_pointer(const IndexTuple tuple1,
/* Raise error for duplicated tuple when creating unique index */
static inline void
-raise_error_of_dup_index(IndexTuple x,
+raise_error_of_dup_index(IndexTuple x,
Tuplesortstate *state)
{
- Datum values[INDEX_MAX_KEYS];
- bool isnull[INDEX_MAX_KEYS];
- TupleDesc tupDesc;
- char *key_desc;
+ Datum values[INDEX_MAX_KEYS];
+ bool isnull[INDEX_MAX_KEYS];
+ TupleDesc tupDesc;
+ char *key_desc;
TuplesortPublic *base = TuplesortstateGetPublic(state);
TuplesortIndexBTreeArg *arg = (TuplesortIndexBTreeArg *) base->arg;
tupDesc = RelationGetDescr(arg->index.indexRel);
- index_deform_tuple((IndexTuple)x, tupDesc, values, isnull);
+ index_deform_tuple((IndexTuple) x, tupDesc, values, isnull);
key_desc = BuildIndexValueDescription(arg->index.indexRel, values, isnull);
ereport(ERROR,
(errcode(ERRCODE_UNIQUE_VIOLATION),
- errmsg("could not create unique index \"%s\"",
- RelationGetRelationName(arg->index.indexRel)),
- key_desc ? errdetail("Key %s is duplicated.", key_desc) :
- errdetail("Duplicate keys exist."),
- errtableconstraint(arg->index.heapRel,
- RelationGetRelationName(arg->index.indexRel))));
+ errmsg("could not create unique index \"%s\"",
+ RelationGetRelationName(arg->index.indexRel)),
+ key_desc ? errdetail("Key %s is duplicated.", key_desc) :
+ errdetail("Duplicate keys exist."),
+ errtableconstraint(arg->index.heapRel,
+ RelationGetRelationName(arg->index.indexRel))));
}
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index 74a6a5ae5ce..380a106789c 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -158,19 +158,19 @@ typedef int (*SortTupleComparator) (const SortTuple *a, const SortTuple *b,
/* Multi-key quick sort */
typedef Datum
-(*MkqsGetDatumFunc) (SortTuple *x,
- const int tupleIndex,
- const int depth,
- Tuplesortstate *state,
- Datum *datum,
- bool *isNull,
- bool useFullKey);
+ (*MkqsGetDatumFunc) (SortTuple *x,
+ const int tupleIndex,
+ const int depth,
+ Tuplesortstate *state,
+ Datum *datum,
+ bool *isNull,
+ bool useFullKey);
typedef void
-(*MkqsHandleDupFunc) (SortTuple *x,
- const int tupleCount,
- const bool seenNull,
- Tuplesortstate *state);
+ (*MkqsHandleDupFunc) (SortTuple *x,
+ const int tupleCount,
+ const bool seenNull,
+ Tuplesortstate *state);
/*
* The public part of a Tuple sort operation state. This data structure
@@ -269,17 +269,15 @@ typedef struct
/*
* Function pointer, referencing a function to get specified datum from
- * SortTuple list with multi-key.
- * Used by mk_qsort_tuple().
- */
+ * SortTuple list with multi-key. Used by mk_qsort_tuple().
+ */
MkqsGetDatumFunc mkqsGetDatumFunc;
/*
* Function pointer, referencing a function to handle duplicated tuple
- * from SortTuple list with multi-key.
- * Used by mk_qsort_tuple().
- * For now, the function pointer is filled for only btree index tuple.
- */
+ * from SortTuple list with multi-key. Used by mk_qsort_tuple(). For now,
+ * the function pointer is filled for only btree index tuple.
+ */
MkqsHandleDupFunc mkqsHandleDupFunc;
} TuplesortPublic;
--
2.45.1