Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit236d6d4

Browse files
committed
Remove redundant has_null member from PartitionBoundInfoData.
Jeevan Ladhe, with some changes by me.Discussion:http://postgr.es/m/CAOgcT0NZ_30-pjBpW2OgneV1ammArHkZDZ8B_KFC3q+_Xb2H9A@mail.gmail.com
1 parent3db2279 commit236d6d4

File tree

1 file changed

+13
-21
lines changed

1 file changed

+13
-21
lines changed

‎src/backend/catalog/partition.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
* Information about bounds of a partitioned relation
5454
*
5555
* A list partition datum that is known to be NULL is never put into the
56-
* datums array. Instead, it is tracked usinghas_null andnull_indexfields.
56+
* datums array. Instead, it is tracked usingthenull_indexfield.
5757
*
5858
* In the case of range partitioning, ndatums will typically be far less than
5959
* 2 * nparts, because a partition's upper bound and the next partition's lower
@@ -86,12 +86,12 @@ typedef struct PartitionBoundInfoData
8686
int*indexes;/* Partition indexes; one entry per member of
8787
* the datums array (plus one if range
8888
* partitioned table) */
89-
boolhas_null;/* Is there a null-accepting partition? false
90-
* for range partitioned tables */
9189
intnull_index;/* Index of the null-accepting partition; -1
92-
*for range partitioned tables */
90+
*if there isn't one */
9391
}PartitionBoundInfoData;
9492

93+
#definepartition_bound_accepts_nulls(bi) ((bi)->null_index != -1)
94+
9595
/*
9696
* When qsort'ing partition bounds after reading from the catalog, each bound
9797
* is represented with one of the following structs.
@@ -173,7 +173,6 @@ RelationBuildPartitionDesc(Relation rel)
173173

174174
/* List partitioning specific */
175175
PartitionListValue**all_values=NULL;
176-
boolfound_null= false;
177176
intnull_index=-1;
178177

179178
/* Range partitioning specific */
@@ -245,7 +244,6 @@ RelationBuildPartitionDesc(Relation rel)
245244
* Create a unified list of non-null values across all partitions.
246245
*/
247246
i=0;
248-
found_null= false;
249247
null_index=-1;
250248
foreach(cell,boundspecs)
251249
{
@@ -274,9 +272,8 @@ RelationBuildPartitionDesc(Relation rel)
274272
* instead for the code further down below where we
275273
* construct the actual relcache struct.
276274
*/
277-
if (found_null)
275+
if (null_index!=-1)
278276
elog(ERROR,"found null more than once");
279-
found_null= true;
280277
null_index=i;
281278
}
282279

@@ -466,7 +463,6 @@ RelationBuildPartitionDesc(Relation rel)
466463
{
467464
casePARTITION_STRATEGY_LIST:
468465
{
469-
boundinfo->has_null=found_null;
470466
boundinfo->indexes= (int*)palloc(ndatums*sizeof(int));
471467

472468
/*
@@ -498,20 +494,18 @@ RelationBuildPartitionDesc(Relation rel)
498494
* accepts only null and hence not covered in the above
499495
* loop which only handled non-null values.
500496
*/
501-
if (found_null)
497+
if (null_index!=-1)
502498
{
503499
Assert(null_index >=0);
504500
if (mapping[null_index]==-1)
505501
mapping[null_index]=next_index++;
502+
boundinfo->null_index=mapping[null_index];
506503
}
504+
else
505+
boundinfo->null_index=-1;
507506

508507
/* All partition must now have a valid mapping */
509508
Assert(next_index==nparts);
510-
511-
if (found_null)
512-
boundinfo->null_index=mapping[null_index];
513-
else
514-
boundinfo->null_index=-1;
515509
break;
516510
}
517511

@@ -611,9 +605,6 @@ partition_bounds_equal(PartitionKey key,
611605
if (b1->ndatums!=b2->ndatums)
612606
return false;
613607

614-
if (b1->has_null!=b2->has_null)
615-
return false;
616-
617608
if (b1->null_index!=b2->null_index)
618609
return false;
619610

@@ -696,7 +687,8 @@ check_new_partition_bound(char *relname, Relation parent, Node *bound)
696687

697688
Assert(boundinfo&&
698689
boundinfo->strategy==PARTITION_STRATEGY_LIST&&
699-
(boundinfo->ndatums>0||boundinfo->has_null));
690+
(boundinfo->ndatums>0||
691+
partition_bound_accepts_nulls(boundinfo)));
700692

701693
foreach(cell,spec->listdatums)
702694
{
@@ -717,7 +709,7 @@ check_new_partition_bound(char *relname, Relation parent, Node *bound)
717709
break;
718710
}
719711
}
720-
elseif (boundinfo->has_null)
712+
elseif (partition_bound_accepts_nulls(boundinfo))
721713
{
722714
overlap= true;
723715
with=boundinfo->null_index;
@@ -1985,7 +1977,7 @@ get_partition_for_tuple(PartitionDispatch *pd,
19851977
* partition exists.
19861978
*/
19871979
cur_index=-1;
1988-
if (isnull[0]&&partdesc->boundinfo->has_null)
1980+
if (isnull[0]&&partition_bound_accepts_nulls(partdesc->boundinfo))
19891981
cur_index=partdesc->boundinfo->null_index;
19901982
elseif (!isnull[0])
19911983
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp