LCOV - differential code coverage report
Current view: top level - src/backend/statistics - stat_utils.c (source / functions) Coverage Total Hit UNC UBC GBC GNC CBC
Current: 77aeca80249c9e640c811e80633a2e334a9320de vs 38afc3dcb25c45b744d4025029ce0a6c90b7059f Lines: 91.8 % 255 234 1 20 2 22 210
Current Date: 2026-07-25 19:08:27 +0900 Functions: 100.0 % 14 14 1 13
Baseline: lcov-20260725-baseline Branches: 69.7 % 198 138 4 56 5 12 121
Baseline Date: 2026-07-25 19:09:19 +0900 Line coverage date bins:
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
(7,30] days: 96.2 % 26 25 1 22 3
(30,360] days: 90.0 % 160 144 16 2 142
(360..) days: 94.2 % 69 65 4 65
Function coverage date bins:
(7,30] days: 100.0 % 1 1 1
(30,360] days: 100.0 % 7 7 7
(360..) days: 100.0 % 6 6 6
Branch coverage date bins:
(7,30] days: 77.8 % 18 14 4 12 2
(30,360] days: 63.6 % 110 70 40 5 65
(360..) days: 77.1 % 70 54 16 54

 Age         Owner                    Branch data    TLA  Line data    Source code
                                  1                 :                : /*-------------------------------------------------------------------------
                                  2                 :                :  * stat_utils.c
                                  3                 :                :  *
                                  4                 :                :  *    PostgreSQL statistics manipulation utilities.
                                  5                 :                :  *
                                  6                 :                :  * Code supporting the direct manipulation of statistics.
                                  7                 :                :  *
                                  8                 :                :  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
                                  9                 :                :  * Portions Copyright (c) 1994, Regents of the University of California
                                 10                 :                :  *
                                 11                 :                :  * IDENTIFICATION
                                 12                 :                :  *       src/backend/statistics/stat_utils.c
                                 13                 :                :  *
                                 14                 :                :  *-------------------------------------------------------------------------
                                 15                 :                :  */
                                 16                 :                : 
                                 17                 :                : #include "postgres.h"
                                 18                 :                : 
                                 19                 :                : #include "access/htup_details.h"
                                 20                 :                : #include "access/relation.h"
                                 21                 :                : #include "catalog/index.h"
                                 22                 :                : #include "catalog/namespace.h"
                                 23                 :                : #include "catalog/pg_class.h"
                                 24                 :                : #include "catalog/pg_collation.h"
                                 25                 :                : #include "catalog/pg_database.h"
                                 26                 :                : #include "catalog/pg_statistic.h"
                                 27                 :                : #include "funcapi.h"
                                 28                 :                : #include "miscadmin.h"
                                 29                 :                : #include "nodes/nodeFuncs.h"
                                 30                 :                : #include "statistics/stat_utils.h"
                                 31                 :                : #include "storage/lmgr.h"
                                 32                 :                : #include "utils/acl.h"
                                 33                 :                : #include "utils/array.h"
                                 34                 :                : #include "utils/builtins.h"
                                 35                 :                : #include "utils/lsyscache.h"
                                 36                 :                : #include "utils/rangetypes.h"
                                 37                 :                : #include "utils/rel.h"
                                 38                 :                : #include "utils/syscache.h"
                                 39                 :                : #include "utils/typcache.h"
                                 40                 :                : 
                                 41                 :                : /* Default values assigned to new pg_statistic tuples. */
                                 42                 :                : #define DEFAULT_STATATT_NULL_FRAC      Float4GetDatum(0.0)  /* stanullfrac */
                                 43                 :                : #define DEFAULT_STATATT_AVG_WIDTH      Int32GetDatum(0) /* stawidth, same as
                                 44                 :                :                                                          * unknown */
                                 45                 :                : #define DEFAULT_STATATT_N_DISTINCT     Float4GetDatum(0.0)  /* stadistinct, same as
                                 46                 :                :                                                              * unknown */
                                 47                 :                : 
                                 48                 :                : static Node *statatt_get_index_expr(Relation rel, int attnum);
                                 49                 :                : 
                                 50                 :                : /*
                                 51                 :                :  * Ensure that a given argument is not null.
                                 52                 :                :  */
                                 53                 :                : void
  652 jdavis@postgresql.or       54                 :CBC        6854 : stats_check_required_arg(FunctionCallInfo fcinfo,
                                 55                 :                :                          struct StatsArgInfo *arginfo,
                                 56                 :                :                          int argnum)
                                 57                 :                : {
                                 58         [ +  + ]:           6854 :     if (PG_ARGISNULL(argnum))
                                 59         [ +  - ]:             72 :         ereport(ERROR,
                                 60                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 61                 :                :                  errmsg("argument \"%s\" must not be null",
                                 62                 :                :                         arginfo[argnum].argname)));
                                 63                 :           6782 : }
                                 64                 :                : 
                                 65                 :                : /*
                                 66                 :                :  * Check that argument is either NULL or a one dimensional array with no
                                 67                 :                :  * NULLs.
                                 68                 :                :  *
                                 69                 :                :  * If a problem is found, emit a WARNING, and return false. Otherwise return
                                 70                 :                :  * true.
                                 71                 :                :  */
                                 72                 :                : bool
  641                            73                 :           2523 : stats_check_arg_array(FunctionCallInfo fcinfo,
                                 74                 :                :                       struct StatsArgInfo *arginfo,
                                 75                 :                :                       int argnum)
                                 76                 :                : {
                                 77                 :                :     ArrayType  *arr;
                                 78                 :                : 
                                 79         [ +  + ]:           2523 :     if (PG_ARGISNULL(argnum))
                                 80                 :           2061 :         return true;
                                 81                 :                : 
                                 82                 :            462 :     arr = DatumGetArrayTypeP(PG_GETARG_DATUM(argnum));
                                 83                 :                : 
                                 84         [ -  + ]:            462 :     if (ARR_NDIM(arr) != 1)
                                 85                 :                :     {
  515 jdavis@postgresql.or       86         [ #  # ]:UBC           0 :         ereport(WARNING,
                                 87                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 88                 :                :                  errmsg("argument \"%s\" must not be a multidimensional array",
                                 89                 :                :                         arginfo[argnum].argname)));
  641                            90                 :              0 :         return false;
                                 91                 :                :     }
                                 92                 :                : 
  641 jdavis@postgresql.or       93         [ +  + ]:CBC         462 :     if (array_contains_nulls(arr))
                                 94                 :                :     {
  515                            95         [ +  - ]:              4 :         ereport(WARNING,
                                 96                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                 97                 :                :                  errmsg("argument \"%s\" array must not contain null values",
                                 98                 :                :                         arginfo[argnum].argname)));
  641                            99                 :              4 :         return false;
                                100                 :                :     }
                                101                 :                : 
                                102                 :            458 :     return true;
                                103                 :                : }
                                104                 :                : 
                                105                 :                : /*
                                106                 :                :  * Enforce parameter pairs that must be specified together (or not at all) for
                                107                 :                :  * a particular stakind, such as most_common_vals and most_common_freqs for
                                108                 :                :  * STATISTIC_KIND_MCV.
                                109                 :                :  *
                                110                 :                :  * If a problem is found, emit a WARNING, and return false. Otherwise return
                                111                 :                :  * true.
                                112                 :                :  */
                                113                 :                : bool
                                114                 :           2523 : stats_check_arg_pair(FunctionCallInfo fcinfo,
                                115                 :                :                      struct StatsArgInfo *arginfo,
                                116                 :                :                      int argnum1, int argnum2)
                                117                 :                : {
                                118   [ +  +  +  + ]:           2523 :     if (PG_ARGISNULL(argnum1) && PG_ARGISNULL(argnum2))
                                119                 :           2044 :         return true;
                                120                 :                : 
                                121   [ +  +  +  + ]:            479 :     if (PG_ARGISNULL(argnum1) || PG_ARGISNULL(argnum2))
                                122                 :                :     {
                                123         [ +  + ]:             28 :         int         nullarg = PG_ARGISNULL(argnum1) ? argnum1 : argnum2;
                                124         [ +  + ]:             28 :         int         otherarg = PG_ARGISNULL(argnum1) ? argnum2 : argnum1;
                                125                 :                : 
  515                           126         [ +  - ]:             28 :         ereport(WARNING,
                                127                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                128                 :                :                  errmsg("argument \"%s\" must be specified when argument \"%s\" is specified",
                                129                 :                :                         arginfo[nullarg].argname,
                                130                 :                :                         arginfo[otherarg].argname)));
                                131                 :                : 
  641                           132                 :             28 :         return false;
                                133                 :                :     }
                                134                 :                : 
                                135                 :            451 :     return true;
                                136                 :                : }
                                137                 :                : 
                                138                 :                : /*
                                139                 :                :  * A role has privileges to set statistics on the relation if any of the
                                140                 :                :  * following are true:
                                141                 :                :  *   - the role owns the current database and the relation is not shared
                                142                 :                :  *   - the role has the MAINTAIN privilege on the relation
                                143                 :                :  */
                                144                 :                : void
  283 nathan@postgresql.or      145                 :           2403 : RangeVarCallbackForStats(const RangeVar *relation,
                                146                 :                :                          Oid relId, Oid oldRelId, void *arg)
                                147                 :                : {
                                148                 :           2403 :     Oid        *locked_oid = (Oid *) arg;
                                149                 :           2403 :     Oid         table_oid = relId;
                                150                 :                :     HeapTuple   tuple;
                                151                 :                :     Form_pg_class form;
                                152                 :                :     char        relkind;
                                153                 :                : 
                                154                 :                :     /*
                                155                 :                :      * If we previously locked some other index's heap, and the name we're
                                156                 :                :      * looking up no longer refers to that relation, release the now-useless
                                157                 :                :      * lock.
                                158                 :                :      */
                                159   [ +  +  -  + ]:           2403 :     if (relId != oldRelId && OidIsValid(*locked_oid))
                                160                 :                :     {
  283 nathan@postgresql.or      161                 :UBC           0 :         UnlockRelationOid(*locked_oid, ShareUpdateExclusiveLock);
                                162                 :              0 :         *locked_oid = InvalidOid;
                                163                 :                :     }
                                164                 :                : 
                                165                 :                :     /* If the relation does not exist, there's nothing more to do. */
  283 nathan@postgresql.or      166         [ +  + ]:CBC        2403 :     if (!OidIsValid(relId))
                                167                 :             16 :         return;
                                168                 :                : 
                                169                 :                :     /* If the relation does exist, check whether it's an index. */
                                170                 :           2387 :     relkind = get_rel_relkind(relId);
                                171   [ +  +  +  + ]:           2387 :     if (relkind == RELKIND_INDEX ||
                                172                 :                :         relkind == RELKIND_PARTITIONED_INDEX)
                                173                 :            337 :         table_oid = IndexGetRelation(relId, false);
                                174                 :                : 
                                175                 :                :     /*
                                176                 :                :      * If retrying yields the same OID, there are a couple of extremely
                                177                 :                :      * unlikely scenarios we need to handle.
                                178                 :                :      */
                                179         [ +  + ]:           2387 :     if (relId == oldRelId)
                                180                 :                :     {
                                181                 :                :         /*
                                182                 :                :          * If a previous lookup found an index, but the current lookup did
                                183                 :                :          * not, the index was dropped and the OID was reused for something
                                184                 :                :          * else between lookups.  In theory, we could simply drop our lock on
                                185                 :                :          * the index's parent table and proceed, but in the interest of
                                186                 :                :          * avoiding complexity, we just error.
                                187                 :                :          */
  283 nathan@postgresql.or      188   [ -  +  -  - ]:GBC           1 :         if (table_oid == relId && OidIsValid(*locked_oid))
  283 nathan@postgresql.or      189         [ #  # ]:UBC           0 :             ereport(ERROR,
                                190                 :                :                     (errcode(ERRCODE_UNDEFINED_OBJECT),
                                191                 :                :                      errmsg("index \"%s\" was concurrently dropped",
                                192                 :                :                             relation->relname)));
                                193                 :                : 
                                194                 :                :         /*
                                195                 :                :          * If the current lookup found an index but a previous lookup either
                                196                 :                :          * did not find an index or found one with a different parent
                                197                 :                :          * relation, the relation was dropped and the OID was reused for an
                                198                 :                :          * index between lookups.  RangeVarGetRelidExtended() will have
                                199                 :                :          * already locked the index at this point, so we can't just lock the
                                200                 :                :          * newly discovered parent table OID without risking deadlock.  As
                                201                 :                :          * above, we just error in this case.
                                202                 :                :          */
  283 nathan@postgresql.or      203   [ +  -  -  + ]:GBC           1 :         if (table_oid != relId && table_oid != *locked_oid)
  283 nathan@postgresql.or      204         [ #  # ]:UBC           0 :             ereport(ERROR,
                                205                 :                :                     (errcode(ERRCODE_UNDEFINED_OBJECT),
                                206                 :                :                      errmsg("index \"%s\" was concurrently created",
                                207                 :                :                             relation->relname)));
                                208                 :                :     }
                                209                 :                : 
  283 nathan@postgresql.or      210                 :CBC        2387 :     tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(table_oid));
                                211         [ -  + ]:           2387 :     if (!HeapTupleIsValid(tuple))
  283 nathan@postgresql.or      212         [ #  # ]:UBC           0 :         elog(ERROR, "cache lookup failed for OID %u", table_oid);
  283 nathan@postgresql.or      213                 :CBC        2387 :     form = (Form_pg_class) GETSTRUCT(tuple);
                                214                 :                : 
                                215                 :                :     /* the relkinds that can be used with ANALYZE */
                                216         [ +  + ]:           2387 :     switch (form->relkind)
                                217                 :                :     {
  652 jdavis@postgresql.or      218                 :           2375 :         case RELKIND_RELATION:
                                219                 :                :         case RELKIND_MATVIEW:
                                220                 :                :         case RELKIND_FOREIGN_TABLE:
                                221                 :                :         case RELKIND_PARTITIONED_TABLE:
                                222                 :           2375 :             break;
                                223                 :             12 :         default:
                                224         [ +  - ]:             12 :             ereport(ERROR,
                                225                 :                :                     (errcode(ERRCODE_WRONG_OBJECT_TYPE),
                                226                 :                :                      errmsg("cannot modify statistics for relation \"%s\"",
                                227                 :                :                             NameStr(form->relname)),
                                228                 :                :                      errdetail_relkind_not_supported(form->relkind)));
                                229                 :                :     }
                                230                 :                : 
  283 nathan@postgresql.or      231         [ -  + ]:           2375 :     if (form->relisshared)
  652 jdavis@postgresql.or      232         [ #  # ]:UBC           0 :         ereport(ERROR,
                                233                 :                :                 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
                                234                 :                :                  errmsg("cannot modify statistics for shared relation")));
                                235                 :                : 
                                236                 :                :     /* Check permissions */
  652 jdavis@postgresql.or      237         [ +  + ]:CBC        2375 :     if (!object_ownercheck(DatabaseRelationId, MyDatabaseId, GetUserId()))
                                238                 :                :     {
  283 nathan@postgresql.or      239                 :             16 :         AclResult   aclresult = pg_class_aclcheck(table_oid,
                                240                 :                :                                                   GetUserId(),
                                241                 :                :                                                   ACL_MAINTAIN);
                                242                 :                : 
  652 jdavis@postgresql.or      243         [ +  + ]:             16 :         if (aclresult != ACLCHECK_OK)
                                244                 :              8 :             aclcheck_error(aclresult,
  283 nathan@postgresql.or      245                 :              8 :                            get_relkind_objtype(form->relkind),
                                246                 :              8 :                            NameStr(form->relname));
                                247                 :                :     }
                                248                 :                : 
                                249                 :           2367 :     ReleaseSysCache(tuple);
                                250                 :                : 
                                251                 :                :     /* Lock heap before index to avoid deadlock. */
                                252   [ +  +  +  + ]:           2367 :     if (relId != oldRelId && table_oid != relId)
                                253                 :                :     {
                                254                 :            336 :         LockRelationOid(table_oid, ShareUpdateExclusiveLock);
                                255                 :            336 :         *locked_oid = table_oid;
                                256                 :                :     }
                                257                 :                : }
                                258                 :                : 
                                259                 :                : 
                                260                 :                : /*
                                261                 :                :  * Find the argument number for the given argument name, returning -1 if not
                                262                 :                :  * found.
                                263                 :                :  */
                                264                 :                : static int
  515 jdavis@postgresql.or      265                 :          16878 : get_arg_by_name(const char *argname, struct StatsArgInfo *arginfo)
                                266                 :                : {
                                267                 :                :     int         argnum;
                                268                 :                : 
  639                           269         [ +  + ]:          81128 :     for (argnum = 0; arginfo[argnum].argname != NULL; argnum++)
                                270         [ +  + ]:          81120 :         if (pg_strcasecmp(argname, arginfo[argnum].argname) == 0)
                                271                 :          16870 :             return argnum;
                                272                 :                : 
  515                           273         [ +  - ]:              8 :     ereport(WARNING,
                                274                 :                :             (errmsg("unrecognized argument name: \"%s\"", argname)));
                                275                 :                : 
  639                           276                 :              8 :     return -1;
                                277                 :                : }
                                278                 :                : 
                                279                 :                : /*
                                280                 :                :  * Ensure that a given argument matched the expected type.
                                281                 :                :  */
                                282                 :                : static bool
  515                           283                 :          16870 : stats_check_arg_type(const char *argname, Oid argtype, Oid expectedtype)
                                284                 :                : {
  639                           285         [ +  + ]:          16870 :     if (argtype != expectedtype)
                                286                 :                :     {
  515                           287         [ +  - ]:             16 :         ereport(WARNING,
                                288                 :                :                 (errmsg("argument \"%s\" has type %s, expected type %s",
                                289                 :                :                         argname, format_type_be(argtype),
                                290                 :                :                         format_type_be(expectedtype))));
  639                           291                 :             16 :         return false;
                                292                 :                :     }
                                293                 :                : 
                                294                 :          16854 :     return true;
                                295                 :                : }
                                296                 :                : 
                                297                 :                : /*
                                298                 :                :  * Check if attribute of an index is an expression, then retrieve the
                                299                 :                :  * expression if is it the case.
                                300                 :                :  *
                                301                 :                :  * If the attnum specified is known to be an expression, then we must
                                302                 :                :  * walk the list attributes up to the specified attnum to get the right
                                303                 :                :  * expression.
                                304                 :                :  */
                                305                 :                : static Node *
  212 michael@paquier.xyz       306                 :            841 : statatt_get_index_expr(Relation rel, int attnum)
                                307                 :                : {
                                308                 :                :     List       *index_exprs;
                                309                 :                :     ListCell   *indexpr_item;
                                310                 :                : 
                                311                 :                :     /* relation is not an index */
                                312         [ +  + ]:            841 :     if (rel->rd_rel->relkind != RELKIND_INDEX &&
                                313         [ +  - ]:            833 :         rel->rd_rel->relkind != RELKIND_PARTITIONED_INDEX)
                                314                 :            833 :         return NULL;
                                315                 :                : 
                                316                 :              8 :     index_exprs = RelationGetIndexExpressions(rel);
                                317                 :                : 
                                318                 :                :     /* index has no expressions to give */
                                319         [ -  + ]:              8 :     if (index_exprs == NIL)
  212 michael@paquier.xyz       320                 :UBC           0 :         return NULL;
                                321                 :                : 
                                322                 :                :     /*
                                323                 :                :      * The index's attnum points directly to a relation attnum, hence it is
                                324                 :                :      * not an expression attribute.
                                325                 :                :      */
  212 michael@paquier.xyz       326         [ -  + ]:CBC           8 :     if (rel->rd_index->indkey.values[attnum - 1] != 0)
  212 michael@paquier.xyz       327                 :UBC           0 :         return NULL;
                                328                 :                : 
  212 michael@paquier.xyz       329                 :CBC           8 :     indexpr_item = list_head(rel->rd_indexprs);
                                330                 :                : 
                                331         [ -  + ]:              8 :     for (int i = 0; i < attnum - 1; i++)
  212 michael@paquier.xyz       332         [ #  # ]:UBC           0 :         if (rel->rd_index->indkey.values[i] == 0)
                                333                 :              0 :             indexpr_item = lnext(rel->rd_indexprs, indexpr_item);
                                334                 :                : 
  212 michael@paquier.xyz       335         [ -  + ]:CBC           8 :     if (indexpr_item == NULL)   /* shouldn't happen */
  212 michael@paquier.xyz       336         [ #  # ]:UBC           0 :         elog(ERROR, "too few entries in indexprs list");
                                337                 :                : 
  212 michael@paquier.xyz       338                 :CBC           8 :     return (Node *) lfirst(indexpr_item);
                                339                 :                : }
                                340                 :                : 
                                341                 :                : /*
                                342                 :                :  * Translate variadic argument pairs from 'pairs_fcinfo' into a
                                343                 :                :  * 'positional_fcinfo' appropriate for calling relation_statistics_update() or
                                344                 :                :  * attribute_statistics_update() with positional arguments.
                                345                 :                :  *
                                346                 :                :  * Caller should have already initialized positional_fcinfo with a size
                                347                 :                :  * appropriate for calling the intended positional function, and arginfo
                                348                 :                :  * should also match the intended positional function.
                                349                 :                :  */
                                350                 :                : bool
  639 jdavis@postgresql.or      351                 :           2414 : stats_fill_fcinfo_from_arg_pairs(FunctionCallInfo pairs_fcinfo,
                                352                 :                :                                  FunctionCallInfo positional_fcinfo,
                                353                 :                :                                  struct StatsArgInfo *arginfo)
                                354                 :                : {
                                355                 :                :     Datum      *args;
                                356                 :                :     bool       *argnulls;
                                357                 :                :     Oid        *types;
                                358                 :                :     int         nargs;
                                359                 :           2414 :     bool        result = true;
                                360                 :                : 
                                361                 :                :     /* clear positional args */
                                362         [ +  + ]:          29006 :     for (int i = 0; arginfo[i].argname != NULL; i++)
                                363                 :                :     {
                                364                 :          26592 :         positional_fcinfo->args[i].value = (Datum) 0;
                                365                 :          26592 :         positional_fcinfo->args[i].isnull = true;
                                366                 :                :     }
                                367                 :                : 
                                368                 :           2414 :     nargs = extract_variadic_args(pairs_fcinfo, 0, true,
                                369                 :                :                                   &args, &types, &argnulls);
                                370                 :                : 
                                371         [ +  + ]:           2414 :     if (nargs % 2 != 0)
                                372         [ +  - ]:              4 :         ereport(ERROR,
                                373                 :                :                 errmsg("variadic arguments must be name/value pairs"),
                                374                 :                :                 errhint("Provide an even number of variadic arguments that can be divided into pairs."));
                                375                 :                : 
                                376                 :                :     /*
                                377                 :                :      * For each argument name/value pair, find corresponding positional
                                378                 :                :      * argument for the argument name, and assign the argument value to
                                379                 :                :      * positional_fcinfo.
                                380                 :                :      */
                                381         [ +  + ]:          21354 :     for (int i = 0; i < nargs; i += 2)
                                382                 :                :     {
                                383                 :                :         int         argnum;
                                384                 :                :         char       *argname;
                                385                 :                : 
                                386         [ +  + ]:          18948 :         if (argnulls[i])
                                387         [ +  - ]:              4 :             ereport(ERROR,
                                388                 :                :                     (errmsg("name at variadic position %d is null", i + 1)));
                                389                 :                : 
                                390         [ -  + ]:          18944 :         if (types[i] != TEXTOID)
  639 jdavis@postgresql.or      391         [ #  # ]:UBC           0 :             ereport(ERROR,
                                392                 :                :                     (errmsg("name at variadic position %d has type %s, expected type %s",
                                393                 :                :                             i + 1, format_type_be(types[i]),
                                394                 :                :                             format_type_be(TEXTOID))));
                                395                 :                : 
  639 jdavis@postgresql.or      396         [ +  + ]:CBC       18944 :         if (argnulls[i + 1])
                                397                 :            204 :             continue;
                                398                 :                : 
                                399                 :          18740 :         argname = TextDatumGetCString(args[i]);
                                400                 :                : 
                                401                 :                :         /*
                                402                 :                :          * The 'version' argument is a special case, not handled by arginfo
                                403                 :                :          * because it's not a valid positional argument.
                                404                 :                :          *
                                405                 :                :          * For now, 'version' is accepted but ignored. In the future it can be
                                406                 :                :          * used to interpret older statistics properly.
                                407                 :                :          */
                                408         [ +  + ]:          18740 :         if (pg_strcasecmp(argname, "version") == 0)
                                409                 :           1862 :             continue;
                                410                 :                : 
  515                           411                 :          16878 :         argnum = get_arg_by_name(argname, arginfo);
                                412                 :                : 
  639                           413   [ +  +  +  + ]:          33748 :         if (argnum < 0 || !stats_check_arg_type(argname, types[i + 1],
  515                           414                 :          16870 :                                                 arginfo[argnum].argtype))
                                415                 :                :         {
  639                           416                 :             24 :             result = false;
                                417                 :             24 :             continue;
                                418                 :                :         }
                                419                 :                : 
                                420                 :          16854 :         positional_fcinfo->args[argnum].value = args[i + 1];
                                421                 :          16854 :         positional_fcinfo->args[argnum].isnull = false;
                                422                 :                :     }
                                423                 :                : 
                                424                 :           2406 :     return result;
                                425                 :                : }
                                426                 :                : 
                                427                 :                : /*
                                428                 :                :  * Derive type information from a relation attribute.
                                429                 :                :  *
                                430                 :                :  * This is needed for setting most slot statistics for all data types.
                                431                 :                :  *
                                432                 :                :  * This duplicates the logic in examine_attribute() but it will not skip the
                                433                 :                :  * attribute if the attstattarget is 0.
                                434                 :                :  *
                                435                 :                :  * This information, retrieved from pg_attribute and pg_type with some
                                436                 :                :  * specific handling for index expressions, is a prerequisite to calling
                                437                 :                :  * any of the other statatt_*() functions.
                                438                 :                :  */
                                439                 :                : void
  212 michael@paquier.xyz       440                 :            841 : statatt_get_type(Oid reloid, AttrNumber attnum,
                                441                 :                :                  Oid *atttypid, int32 *atttypmod,
                                442                 :                :                  char *atttyptype, Oid *atttypcoll,
                                443                 :                :                  Oid *eq_opr, Oid *lt_opr)
                                444                 :                : {
                                445                 :            841 :     Relation    rel = relation_open(reloid, AccessShareLock);
                                446                 :                :     Form_pg_attribute attr;
                                447                 :                :     HeapTuple   atup;
                                448                 :                :     Node       *expr;
                                449                 :                :     TypeCacheEntry *typcache;
                                450                 :                : 
                                451                 :            841 :     atup = SearchSysCache2(ATTNUM, ObjectIdGetDatum(reloid),
                                452                 :                :                            Int16GetDatum(attnum));
                                453                 :                : 
                                454                 :                :     /* Attribute not found */
                                455         [ -  + ]:            841 :     if (!HeapTupleIsValid(atup))
  212 michael@paquier.xyz       456         [ #  # ]:UBC           0 :         ereport(ERROR,
                                457                 :                :                 (errcode(ERRCODE_UNDEFINED_COLUMN),
                                458                 :                :                  errmsg("column %d of relation \"%s\" does not exist",
                                459                 :                :                         attnum, RelationGetRelationName(rel))));
                                460                 :                : 
  212 michael@paquier.xyz       461                 :CBC         841 :     attr = (Form_pg_attribute) GETSTRUCT(atup);
                                462                 :                : 
                                463         [ -  + ]:            841 :     if (attr->attisdropped)
  212 michael@paquier.xyz       464         [ #  # ]:UBC           0 :         ereport(ERROR,
                                465                 :                :                 (errcode(ERRCODE_UNDEFINED_COLUMN),
                                466                 :                :                  errmsg("column %d of relation \"%s\" does not exist",
                                467                 :                :                         attnum, RelationGetRelationName(rel))));
                                468                 :                : 
  212 michael@paquier.xyz       469                 :CBC         841 :     expr = statatt_get_index_expr(rel, attr->attnum);
                                470                 :                : 
                                471                 :                :     /*
                                472                 :                :      * When analyzing an expression index, believe the expression tree's type
                                473                 :                :      * not the column datatype --- the latter might be the opckeytype storage
                                474                 :                :      * type of the opclass, which is not interesting for our purposes.  This
                                475                 :                :      * mimics the behavior of examine_attribute().
                                476                 :                :      */
                                477         [ +  + ]:            841 :     if (expr == NULL)
                                478                 :                :     {
                                479                 :            833 :         *atttypid = attr->atttypid;
                                480                 :            833 :         *atttypmod = attr->atttypmod;
                                481                 :            833 :         *atttypcoll = attr->attcollation;
                                482                 :                :     }
                                483                 :                :     else
                                484                 :                :     {
                                485                 :              8 :         *atttypid = exprType(expr);
                                486                 :              8 :         *atttypmod = exprTypmod(expr);
                                487                 :                : 
                                488         [ -  + ]:              8 :         if (OidIsValid(attr->attcollation))
  212 michael@paquier.xyz       489                 :UBC           0 :             *atttypcoll = attr->attcollation;
                                490                 :                :         else
  212 michael@paquier.xyz       491                 :CBC           8 :             *atttypcoll = exprCollation(expr);
                                492                 :                :     }
                                493                 :            841 :     ReleaseSysCache(atup);
                                494                 :                : 
                                495                 :                :     /*
                                496                 :                :      * If it's a multirange, step down to the range type, as is done by
                                497                 :                :      * multirange_typanalyze().
                                498                 :                :      */
                                499         [ +  + ]:            841 :     if (type_is_multirange(*atttypid))
                                500                 :              5 :         *atttypid = get_multirange_range(*atttypid);
                                501                 :                : 
                                502                 :                :     /* finds the right operators even if atttypid is a domain */
                                503                 :            841 :     typcache = lookup_type_cache(*atttypid, TYPECACHE_LT_OPR | TYPECACHE_EQ_OPR);
                                504                 :            841 :     *atttyptype = typcache->typtype;
                                505                 :            841 :     *eq_opr = typcache->eq_opr;
                                506                 :            841 :     *lt_opr = typcache->lt_opr;
                                507                 :                : 
                                508                 :                :     /*
                                509                 :                :      * Special case: collation for tsvector is DEFAULT_COLLATION_OID. See
                                510                 :                :      * compute_tsvector_stats().
                                511                 :                :      */
                                512         [ +  + ]:            841 :     if (*atttypid == TSVECTOROID)
                                513                 :              1 :         *atttypcoll = DEFAULT_COLLATION_OID;
                                514                 :                : 
                                515                 :            841 :     relation_close(rel, NoLock);
                                516                 :            841 : }
                                517                 :                : 
                                518                 :                : /*
                                519                 :                :  * Derive element type information from the attribute type.  This information
                                520                 :                :  * is needed when the given type is one that contains elements of other types.
                                521                 :                :  *
                                522                 :                :  * The atttypid and atttyptype should be derived from a previous call to
                                523                 :                :  * statatt_get_type().
                                524                 :                :  */
                                525                 :                : bool
                                526                 :             60 : statatt_get_elem_type(Oid atttypid, char atttyptype,
                                527                 :                :                       Oid *elemtypid, Oid *elem_eq_opr)
                                528                 :                : {
                                529                 :                :     TypeCacheEntry *elemtypcache;
                                530                 :                : 
                                531         [ +  + ]:             60 :     if (atttypid == TSVECTOROID)
                                532                 :                :     {
                                533                 :                :         /*
                                534                 :                :          * Special case: element type for tsvector is text. See
                                535                 :                :          * compute_tsvector_stats().
                                536                 :                :          */
                                537                 :              5 :         *elemtypid = TEXTOID;
                                538                 :                :     }
                                539                 :                :     else
                                540                 :                :     {
                                541                 :                :         /* find underlying element type through any domain */
                                542                 :             55 :         *elemtypid = get_base_element_type(atttypid);
                                543                 :                :     }
                                544                 :                : 
                                545         [ +  + ]:             60 :     if (!OidIsValid(*elemtypid))
                                546                 :             20 :         return false;
                                547                 :                : 
                                548                 :                :     /* finds the right operator even if elemtypid is a domain */
                                549                 :             40 :     elemtypcache = lookup_type_cache(*elemtypid, TYPECACHE_EQ_OPR);
                                550         [ -  + ]:             40 :     if (!OidIsValid(elemtypcache->eq_opr))
  212 michael@paquier.xyz       551                 :UBC           0 :         return false;
                                552                 :                : 
  212 michael@paquier.xyz       553                 :CBC          40 :     *elem_eq_opr = elemtypcache->eq_opr;
                                554                 :                : 
                                555                 :             40 :     return true;
                                556                 :                : }
                                557                 :                : 
                                558                 :                : /*
                                559                 :                :  * Build an array with element type typid from a text datum, used as
                                560                 :                :  * value of an attribute in a tuple to-be-inserted into pg_statistic.
                                561                 :                :  *
                                562                 :                :  * The typid and typmod should be derived from a previous call to
                                563                 :                :  * statatt_get_type().
                                564                 :                :  *
                                565                 :                :  * If an error is encountered, capture it and throw a WARNING, with "ok" set
                                566                 :                :  * to false.  If the resulting array contains NULLs, raise a WARNING and
                                567                 :                :  * set "ok" to false.  When the operation succeeds, set "ok" to true.
                                568                 :                :  */
                                569                 :                : Datum
                                570                 :            851 : statatt_build_stavalues(const char *staname, FmgrInfo *array_in, Datum d, Oid typid,
                                571                 :                :                         int32 typmod, bool *ok)
                                572                 :                : {
                                573                 :                :     char       *s;
                                574                 :                :     Datum       result;
                                575                 :            851 :     ErrorSaveContext escontext = {T_ErrorSaveContext};
                                576                 :                : 
                                577                 :            851 :     escontext.details_wanted = true;
                                578                 :                : 
                                579                 :            851 :     s = TextDatumGetCString(d);
                                580                 :                : 
   25                           581         [ +  + ]:            851 :     if (!InputFunctionCallSafe(array_in, s, typid, typmod,
                                582                 :                :                                (Node *) &escontext, &result))
                                583                 :                :     {
                                584                 :              4 :         pfree(s);
  212                           585                 :              4 :         escontext.error_data->elevel = WARNING;
                                586                 :              4 :         ThrowErrorData(escontext.error_data);
                                587                 :              4 :         *ok = false;
                                588                 :              4 :         return (Datum) 0;
                                589                 :                :     }
                                590                 :                : 
   25                           591                 :            847 :     pfree(s);
                                592                 :                : 
   75                           593         [ +  + ]:            847 :     if (ARR_NDIM(DatumGetArrayTypeP(result)) != 1)
                                594                 :                :     {
                                595         [ +  - ]:              4 :         ereport(WARNING,
                                596                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                597                 :                :                  errmsg("\"%s\" must be a one-dimensional array", staname)));
                                598                 :              4 :         *ok = false;
                                599                 :              4 :         return (Datum) 0;
                                600                 :                :     }
                                601                 :                : 
  212                           602         [ +  + ]:            843 :     if (array_contains_nulls(DatumGetArrayTypeP(result)))
                                603                 :                :     {
                                604         [ +  - ]:              4 :         ereport(WARNING,
                                605                 :                :                 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                606                 :                :                  errmsg("\"%s\" array must not contain null values", staname)));
                                607                 :              4 :         *ok = false;
                                608                 :              4 :         return (Datum) 0;
                                609                 :                :     }
                                610                 :                : 
                                611                 :            839 :     *ok = true;
                                612                 :                : 
                                613                 :            839 :     return result;
                                614                 :                : }
                                615                 :                : 
                                616                 :                : /*
                                617                 :                :  * Find and update the slot of a stakind, or use the first empty slot.
                                618                 :                :  *
                                619                 :                :  * Core statistics types expect the stakind value to be one of the
                                620                 :                :  * STATISTIC_KIND_* constants defined in pg_statistic.h, but types defined
                                621                 :                :  * by extensions are not restricted to those values.
                                622                 :                :  *
                                623                 :                :  * In the case of core statistics, the required staop is determined by the
                                624                 :                :  * stakind given and will either be a hardcoded oid, or the eq/lt operator
                                625                 :                :  * derived from statatt_get_type().  Likewise, types defined by extensions
                                626                 :                :  * have no such restriction.
                                627                 :                :  *
                                628                 :                :  * The stacoll value should be either the atttypcoll derived from
                                629                 :                :  * statatt_get_type(), or a hardcoded value required by that particular
                                630                 :                :  * stakind.
                                631                 :                :  *
                                632                 :                :  * The value/null pairs for stanumbers and stavalues should be calculated
                                633                 :                :  * based on the stakind, using statatt_build_stavalues() or constructed arrays.
                                634                 :                :  */
                                635                 :                : void
                                636                 :           1651 : statatt_set_slot(Datum *values, bool *nulls, bool *replaces,
                                637                 :                :                  int16 stakind, Oid staop, Oid stacoll,
                                638                 :                :                  Datum stanumbers, bool stanumbers_isnull,
                                639                 :                :                  Datum stavalues, bool stavalues_isnull)
                                640                 :                : {
                                641                 :                :     int         slotidx;
                                642                 :           1651 :     int         first_empty = -1;
                                643                 :                :     AttrNumber  stakind_attnum;
                                644                 :                :     AttrNumber  staop_attnum;
                                645                 :                :     AttrNumber  stacoll_attnum;
                                646                 :                : 
                                647                 :                :     /* find existing slot with given stakind */
                                648         [ +  + ]:           9906 :     for (slotidx = 0; slotidx < STATISTIC_NUM_SLOTS; slotidx++)
                                649                 :                :     {
                                650                 :           8255 :         stakind_attnum = Anum_pg_statistic_stakind1 - 1 + slotidx;
                                651                 :                : 
                                652   [ +  +  +  + ]:          10935 :         if (first_empty < 0 &&
                                653                 :           2680 :             DatumGetInt16(values[stakind_attnum]) == 0)
                                654                 :           1651 :             first_empty = slotidx;
                                655         [ -  + ]:           8255 :         if (DatumGetInt16(values[stakind_attnum]) == stakind)
  212 michael@paquier.xyz       656                 :UBC           0 :             break;
                                657                 :                :     }
                                658                 :                : 
  212 michael@paquier.xyz       659   [ +  -  +  - ]:CBC        1651 :     if (slotidx >= STATISTIC_NUM_SLOTS && first_empty >= 0)
                                660                 :           1651 :         slotidx = first_empty;
                                661                 :                : 
                                662         [ -  + ]:           1651 :     if (slotidx >= STATISTIC_NUM_SLOTS)
  212 michael@paquier.xyz       663         [ #  # ]:UBC           0 :         ereport(ERROR,
                                664                 :                :                 (errmsg("maximum number of statistics slots exceeded: %d",
                                665                 :                :                         slotidx + 1)));
                                666                 :                : 
  212 michael@paquier.xyz       667                 :CBC        1651 :     stakind_attnum = Anum_pg_statistic_stakind1 - 1 + slotidx;
                                668                 :           1651 :     staop_attnum = Anum_pg_statistic_staop1 - 1 + slotidx;
                                669                 :           1651 :     stacoll_attnum = Anum_pg_statistic_stacoll1 - 1 + slotidx;
                                670                 :                : 
                                671         [ +  - ]:           1651 :     if (DatumGetInt16(values[stakind_attnum]) != stakind)
                                672                 :                :     {
                                673                 :           1651 :         values[stakind_attnum] = Int16GetDatum(stakind);
                                674                 :           1651 :         replaces[stakind_attnum] = true;
                                675                 :                :     }
                                676         [ +  + ]:           1651 :     if (DatumGetObjectId(values[staop_attnum]) != staop)
                                677                 :                :     {
                                678                 :           1627 :         values[staop_attnum] = ObjectIdGetDatum(staop);
                                679                 :           1627 :         replaces[staop_attnum] = true;
                                680                 :                :     }
                                681         [ +  + ]:           1651 :     if (DatumGetObjectId(values[stacoll_attnum]) != stacoll)
                                682                 :                :     {
                                683                 :            367 :         values[stacoll_attnum] = ObjectIdGetDatum(stacoll);
                                684                 :            367 :         replaces[stacoll_attnum] = true;
                                685                 :                :     }
                                686         [ +  + ]:           1651 :     if (!stanumbers_isnull)
                                687                 :                :     {
                                688                 :           1227 :         values[Anum_pg_statistic_stanumbers1 - 1 + slotidx] = stanumbers;
                                689                 :           1227 :         nulls[Anum_pg_statistic_stanumbers1 - 1 + slotidx] = false;
                                690                 :           1227 :         replaces[Anum_pg_statistic_stanumbers1 - 1 + slotidx] = true;
                                691                 :                :     }
                                692         [ +  + ]:           1651 :     if (!stavalues_isnull)
                                693                 :                :     {
                                694                 :            922 :         values[Anum_pg_statistic_stavalues1 - 1 + slotidx] = stavalues;
                                695                 :            922 :         nulls[Anum_pg_statistic_stavalues1 - 1 + slotidx] = false;
                                696                 :            922 :         replaces[Anum_pg_statistic_stavalues1 - 1 + slotidx] = true;
                                697                 :                :     }
                                698                 :           1651 : }
                                699                 :                : 
                                700                 :                : /*
                                701                 :                :  * Initialize values and nulls for a new pg_statistic tuple.
                                702                 :                :  *
                                703                 :                :  * The caller is responsible for allocating the arrays where the results are
                                704                 :                :  * stored, which should be of size Natts_pg_statistic.
                                705                 :                :  *
                                706                 :                :  * When using this routine for a tuple inserted into pg_statistic, reloid,
                                707                 :                :  * attnum and inherited flags should all be set.
                                708                 :                :  *
                                709                 :                :  * When using this routine for a tuple that is an element of a stxdexpr
                                710                 :                :  * array inserted into pg_statistic_ext_data, reloid, attnum and inherited
                                711                 :                :  * should be respectively set to InvalidOid, InvalidAttrNumber and false.
                                712                 :                :  */
                                713                 :                : void
                                714                 :            908 : statatt_init_empty_tuple(Oid reloid, int16 attnum, bool inherited,
                                715                 :                :                          Datum *values, bool *nulls, bool *replaces)
                                716                 :                : {
                                717                 :            908 :     memset(nulls, true, sizeof(bool) * Natts_pg_statistic);
                                718                 :            908 :     memset(replaces, true, sizeof(bool) * Natts_pg_statistic);
                                719                 :                : 
                                720                 :                :     /* This must initialize non-NULL attributes */
                                721                 :            908 :     values[Anum_pg_statistic_starelid - 1] = ObjectIdGetDatum(reloid);
                                722                 :            908 :     nulls[Anum_pg_statistic_starelid - 1] = false;
                                723                 :            908 :     values[Anum_pg_statistic_staattnum - 1] = Int16GetDatum(attnum);
                                724                 :            908 :     nulls[Anum_pg_statistic_staattnum - 1] = false;
                                725                 :            908 :     values[Anum_pg_statistic_stainherit - 1] = BoolGetDatum(inherited);
                                726                 :            908 :     nulls[Anum_pg_statistic_stainherit - 1] = false;
                                727                 :                : 
                                728                 :            908 :     values[Anum_pg_statistic_stanullfrac - 1] = DEFAULT_STATATT_NULL_FRAC;
                                729                 :            908 :     nulls[Anum_pg_statistic_stanullfrac - 1] = false;
                                730                 :            908 :     values[Anum_pg_statistic_stawidth - 1] = DEFAULT_STATATT_AVG_WIDTH;
                                731                 :            908 :     nulls[Anum_pg_statistic_stawidth - 1] = false;
                                732                 :            908 :     values[Anum_pg_statistic_stadistinct - 1] = DEFAULT_STATATT_N_DISTINCT;
                                733                 :            908 :     nulls[Anum_pg_statistic_stadistinct - 1] = false;
                                734                 :                : 
                                735                 :                :     /* initialize stakind, staop, and stacoll slots */
                                736         [ +  + ]:           5448 :     for (int slotnum = 0; slotnum < STATISTIC_NUM_SLOTS; slotnum++)
                                737                 :                :     {
                                738                 :           4540 :         values[Anum_pg_statistic_stakind1 + slotnum - 1] = (Datum) 0;
                                739                 :           4540 :         nulls[Anum_pg_statistic_stakind1 + slotnum - 1] = false;
                                740                 :           4540 :         values[Anum_pg_statistic_staop1 + slotnum - 1] = ObjectIdGetDatum(InvalidOid);
                                741                 :           4540 :         nulls[Anum_pg_statistic_staop1 + slotnum - 1] = false;
                                742                 :           4540 :         values[Anum_pg_statistic_stacoll1 + slotnum - 1] = ObjectIdGetDatum(InvalidOid);
                                743                 :           4540 :         nulls[Anum_pg_statistic_stacoll1 + slotnum - 1] = false;
                                744                 :                :     }
                                745                 :            908 : }
                                746                 :                : 
                                747                 :                : /*
                                748                 :                :  * Check that an imported bounds histogram (STATISTIC_KIND_BOUNDS_HISTOGRAM)
                                749                 :                :  * is shaped the same way ANALYZE builds it in compute_range_stats().
                                750                 :                :  *
                                751                 :                :  * For both range-typed and multirange-typed columns the histogram is an array
                                752                 :                :  * of ranges, so we take the range type from the array's element type.
                                753                 :                :  */
                                754                 :                : bool
   16 michael@paquier.xyz       755                 :GNC          40 : statatt_check_bounds_histogram(Datum arrayval)
                                756                 :                : {
                                757                 :             40 :     ArrayType  *arr = DatumGetArrayTypeP(arrayval);
                                758                 :             40 :     Oid         rngtypid = ARR_ELEMTYPE(arr);
                                759                 :                :     TypeCacheEntry *typcache;
                                760                 :                :     int16       elmlen;
                                761                 :                :     bool        elmbyval;
                                762                 :                :     char        elmalign;
                                763                 :                :     Datum      *elems;
                                764                 :                :     bool       *nulls;
                                765                 :                :     int         nelems;
                                766                 :             40 :     RangeBound  prev_lower = {0};
                                767                 :             40 :     RangeBound  prev_upper = {0};
                                768                 :                : 
                                769                 :             40 :     typcache = lookup_type_cache(rngtypid, TYPECACHE_RANGE_INFO);
                                770                 :                : 
                                771                 :                :     /*
                                772                 :                :      * The element type should always be a range type here.  This is
                                773                 :                :      * defensive. If it isn't, the bounds histogram is never consulted by the
                                774                 :                :      * range estimator, and there is nothing to verify.
                                775                 :                :      */
                                776         [ -  + ]:             40 :     if (typcache->rngelemtype == NULL)
   16 michael@paquier.xyz       777                 :UNC           0 :         return true;
                                778                 :                : 
   16 michael@paquier.xyz       779                 :GNC          40 :     get_typlenbyvalalign(rngtypid, &elmlen, &elmbyval, &elmalign);
                                780                 :             40 :     deconstruct_array(arr, rngtypid, elmlen, elmbyval, elmalign,
                                781                 :                :                       &elems, &nulls, &nelems);
                                782                 :                : 
                                783         [ +  + ]:            330 :     for (int i = 0; i < nelems; i++)
                                784                 :                :     {
                                785                 :                :         RangeBound  lower,
                                786                 :                :                     upper;
                                787                 :                :         bool        empty;
                                788                 :                : 
                                789                 :                :         /*
                                790                 :                :          * NULL elements are already rejected by statatt_build_stavalues() and
                                791                 :                :          * array_in_safe().
                                792                 :                :          */
                                793                 :            306 :         range_deserialize(typcache, DatumGetRangeTypeP(elems[i]),
                                794                 :                :                           &lower, &upper, &empty);
                                795                 :                : 
                                796         [ +  + ]:            306 :         if (empty)
                                797                 :                :         {
                                798         [ +  - ]:              8 :             ereport(WARNING,
                                799                 :                :                     (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                800                 :                :                      errmsg("\"%s\" must not contain empty ranges",
                                801                 :                :                             "range_bounds_histogram")));
                                802                 :             16 :             return false;
                                803                 :                :         }
                                804                 :                : 
                                805   [ +  +  +  + ]:            564 :         if (i > 0 &&
                                806         [ -  + ]:            524 :             (range_cmp_bounds(typcache, &lower, &prev_lower) < 0 ||
                                807                 :            258 :              range_cmp_bounds(typcache, &upper, &prev_upper) < 0))
                                808                 :                :         {
                                809         [ +  - ]:              8 :             ereport(WARNING,
                                810                 :                :                     (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
                                811                 :                :                      errmsg("\"%s\" must have its lower and upper bounds sorted in ascending order",
                                812                 :                :                             "range_bounds_histogram")));
                                813                 :              8 :             return false;
                                814                 :                :         }
                                815                 :                : 
                                816                 :            290 :         prev_lower = lower;
                                817                 :            290 :         prev_upper = upper;
                                818                 :                :     }
                                819                 :                : 
                                820                 :             24 :     return true;
                                821                 :                : }
        

Generated by: LCOV version 2.0-1