]> granicus.if.org Git - postgresql/commitdiff
Rename columns in new pg_statistic_ext catalog
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 17 Apr 2017 21:34:29 +0000 (18:34 -0300)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Mon, 17 Apr 2017 21:34:29 +0000 (18:34 -0300)
The new catalog reused a column prefix "sta" from pg_statistic, but this
is undesirable, so change the catalog to use prefix "stx" instead.
Also, rename the column that lists enabled statistic kinds as "stxkind"
rather than "enabled".

Discussion: https://postgr.es/m/CAKJS1f_2t5jhSN7huYRFH3w3rrHfG2QU7hiUHsu-Vdjd1rYT3w@mail.gmail.com

22 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/planstats.sgml
src/backend/catalog/aclchk.c
src/backend/catalog/heap.c
src/backend/catalog/objectaddress.c
src/backend/commands/statscmds.c
src/backend/optimizer/util/plancat.c
src/backend/statistics/dependencies.c
src/backend/statistics/extended_stats.c
src/backend/statistics/mvdistinct.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/cache/relcache.c
src/backend/utils/cache/syscache.c
src/bin/pg_dump/pg_dump.c
src/bin/psql/describe.c
src/include/catalog/catversion.h
src/include/catalog/indexing.h
src/include/catalog/pg_statistic_ext.h
src/test/regress/expected/alter_generic.out
src/test/regress/expected/stats_ext.out
src/test/regress/sql/alter_generic.sql
src/test/regress/sql/stats_ext.sql

index 5254bb3025a9238f2f7d20b517c3fd779f479ed0..ef36e87a720d98b966a5f103c613416faba69ca4 100644 (file)
     <tbody>
 
      <row>
-      <entry><structfield>starelid</structfield></entry>
+      <entry><structfield>stxrelid</structfield></entry>
       <entry><type>oid</type></entry>
       <entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
       <entry>The table that the described columns belongs to</entry>
      </row>
 
      <row>
-      <entry><structfield>staname</structfield></entry>
+      <entry><structfield>stxname</structfield></entry>
       <entry><type>name</type></entry>
       <entry></entry>
       <entry>Name of the statistic.</entry>
      </row>
 
      <row>
-      <entry><structfield>stanamespace</structfield></entry>
+      <entry><structfield>stxnamespace</structfield></entry>
       <entry><type>oid</type></entry>
       <entry><literal><link linkend="catalog-pg-namespace"><structname>pg_namespace</structname></link>.oid</literal></entry>
       <entry>
      </row>
 
      <row>
-      <entry><structfield>staowner</structfield></entry>
+      <entry><structfield>stxowner</structfield></entry>
       <entry><type>oid</type></entry>
       <entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
       <entry>Owner of the statistic</entry>
      </row>
 
      <row>
-      <entry><structfield>staenabled</structfield></entry>
+      <entry><structfield>stxkind</structfield></entry>
       <entry><type>char[]</type></entry>
       <entry></entry>
       <entry>
-        An array with the modes of the enabled statistic types, encoded as
-        <literal>d</literal> for ndistinct coefficients.
+        An array with the modes of the enabled statistic types.  Valid values
+        are:
+        <literal>d</literal> for ndistinct coefficients,
+        <literal>f</literal> for functional dependencies.
       </entry>
      </row>
 
      <row>
-      <entry><structfield>stakeys</structfield></entry>
+      <entry><structfield>stxkeys</structfield></entry>
       <entry><type>int2vector</type></entry>
       <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
       <entry>
      </row>
 
      <row>
-      <entry><structfield>standistinct</structfield></entry>
+      <entry><structfield>stxndistinct</structfield></entry>
       <entry><type>pg_ndistinct</type></entry>
       <entry></entry>
       <entry>
      </row>
 
      <row>
-      <entry><structfield>stadependencies</structfield></entry>
+      <entry><structfield>stxdependencies</structfield></entry>
       <entry><type>pg_dependencies</type></entry>
       <entry></entry>
       <entry>
index a4f91c737afd798f1cc4d9d8473fcdf6cde5aa03..124e7e20cede9d7d63d749cdcdb0e4c342dbf2fc 100644 (file)
@@ -525,8 +525,8 @@ EXPLAIN ANALYZE SELECT * FROM t WHERE a = 1 AND b = 1;
     you may do this:
 
 <programlisting>
-SELECT staname,stadependencies FROM pg_statistic_ext WHERE staname = 's1';
- staname |              stadependencies
+SELECT stxname,stxdependencies FROM pg_statistic_ext WHERE stxname = 's1';
+ stxname |              stxdependencies
 ---------+--------------------------------------------
  s1      | [{1 => 2 : 1.000000}, {2 => 1 : 1.000000}]
 (1 row)
index 70e3e6229c935d87a2446c4c64d3982b59c9e064..32989df2b51a834860e07595b4eb71b2186072d5 100644 (file)
@@ -5148,7 +5148,7 @@ pg_statistics_ownercheck(Oid stat_oid, Oid roleid)
                                (errcode(ERRCODE_UNDEFINED_OBJECT),
                                 errmsg("statistics with OID %u do not exist", stat_oid)));
 
-       ownerId = ((Form_pg_statistic_ext) GETSTRUCT(tuple))->staowner;
+       ownerId = ((Form_pg_statistic_ext) GETSTRUCT(tuple))->stxowner;
 
        ReleaseSysCache(tuple);
 
index 4a5f545dc67228159de76fdb11f5638478b68422..ece4df02cde98ba626838d9e22461d135c1ef929 100644 (file)
@@ -2805,7 +2805,7 @@ RemoveStatisticsExt(Oid relid, AttrNumber attnum)
        pgstatisticext = heap_open(StatisticExtRelationId, RowExclusiveLock);
 
        ScanKeyInit(&key,
-                               Anum_pg_statistic_ext_starelid,
+                               Anum_pg_statistic_ext_stxrelid,
                                BTEqualStrategyNumber, F_OIDEQ,
                                ObjectIdGetDatum(relid));
 
@@ -2825,13 +2825,13 @@ RemoveStatisticsExt(Oid relid, AttrNumber attnum)
                        int                     i;
 
                        /*
-                        * Decode the stakeys array and delete any stats that involve the
+                        * Decode the stxkeys array and delete any stats that involve the
                         * specified column.
                         */
                        staForm = (Form_pg_statistic_ext) GETSTRUCT(tuple);
-                       for (i = 0; i < staForm->stakeys.dim1; i++)
+                       for (i = 0; i < staForm->stxkeys.dim1; i++)
                        {
-                               if (staForm->stakeys.values[i] == attnum)
+                               if (staForm->stxkeys.values[i] == attnum)
                                {
                                        delete = true;
                                        break;
index 1492722865c77f091a460c884f5b6b604834e2cf..a9e529fba0a8d9e72862de4682e27f67a108184d 100644 (file)
@@ -485,9 +485,9 @@ static const ObjectPropertyType ObjectProperty[] =
                StatisticExtOidIndexId,
                STATEXTOID,
                STATEXTNAMENSP,
-               Anum_pg_statistic_ext_staname,
-               Anum_pg_statistic_ext_stanamespace,
-               Anum_pg_statistic_ext_staowner,
+               Anum_pg_statistic_ext_stxname,
+               Anum_pg_statistic_ext_stxnamespace,
+               Anum_pg_statistic_ext_stxowner,
                InvalidAttrNumber,              /* no ACL (same as relation) */
                ACL_KIND_STATISTICS,
                true
@@ -4936,13 +4936,13 @@ getObjectIdentityParts(const ObjectAddress *object,
                                        elog(ERROR, "cache lookup failed for statistics %u",
                                                 object->objectId);
                                formStatistic = (Form_pg_statistic_ext) GETSTRUCT(tup);
-                               schema = get_namespace_name_or_temp(formStatistic->stanamespace);
+                               schema = get_namespace_name_or_temp(formStatistic->stxnamespace);
                                appendStringInfoString(&buffer,
                                                                           quote_qualified_identifier(schema,
-                                                                                  NameStr(formStatistic->staname)));
+                                                                                  NameStr(formStatistic->stxname)));
                                if (objname)
                                        *objname = list_make2(schema,
-                                                                  pstrdup(NameStr(formStatistic->staname)));
+                                                                  pstrdup(NameStr(formStatistic->stxname)));
                                ReleaseSysCache(tup);
                        }
                        break;
index 2dd32d9318a823e6023b36399321d9344c6e97d2..f95cd153f5a18f3f3e6238cc6cc505a20dc46ee2 100644 (file)
@@ -50,13 +50,13 @@ CreateStatistics(CreateStatsStmt *stmt)
        int                     numcols = 0;
        ObjectAddress address = InvalidObjectAddress;
        char       *namestr;
-       NameData        staname;
+       NameData        stxname;
        Oid                     statoid;
        Oid                     namespaceId;
        HeapTuple       htup;
        Datum           values[Natts_pg_statistic_ext];
        bool            nulls[Natts_pg_statistic_ext];
-       int2vector *stakeys;
+       int2vector *stxkeys;
        Relation        statrel;
        Relation        rel;
        Oid                     relid;
@@ -64,7 +64,7 @@ CreateStatistics(CreateStatsStmt *stmt)
                                childobject;
        Datum           types[2];               /* one for each possible type of statistics */
        int                     ntypes;
-       ArrayType  *staenabled;
+       ArrayType  *stxkind;
        bool            build_ndistinct;
        bool            build_dependencies;
        bool            requested_type = false;
@@ -73,13 +73,13 @@ CreateStatistics(CreateStatsStmt *stmt)
 
        /* resolve the pieces of the name (namespace etc.) */
        namespaceId = QualifiedNameGetCreationNamespace(stmt->defnames, &namestr);
-       namestrcpy(&staname, namestr);
+       namestrcpy(&stxname, namestr);
 
        /*
         * If if_not_exists was given and the statistics already exists, bail out.
         */
        if (SearchSysCacheExists2(STATEXTNAMENSP,
-                                                         PointerGetDatum(&staname),
+                                                         PointerGetDatum(&stxname),
                                                          ObjectIdGetDatum(namespaceId)))
        {
                if (stmt->if_not_exists)
@@ -184,7 +184,7 @@ CreateStatistics(CreateStatsStmt *stmt)
                                        (errcode(ERRCODE_UNDEFINED_COLUMN),
                                  errmsg("duplicate column name in statistics definition")));
 
-       stakeys = buildint2vector(attnums, numcols);
+       stxkeys = buildint2vector(attnums, numcols);
 
        /*
         * Parse the statistics options.  Currently only statistics types are
@@ -226,23 +226,23 @@ CreateStatistics(CreateStatsStmt *stmt)
        if (build_dependencies)
                types[ntypes++] = CharGetDatum(STATS_EXT_DEPENDENCIES);
        Assert(ntypes > 0);
-       staenabled = construct_array(types, ntypes, CHAROID, 1, true, 'c');
+       stxkind = construct_array(types, ntypes, CHAROID, 1, true, 'c');
 
        /*
         * Everything seems fine, so let's build the pg_statistic_ext tuple.
         */
        memset(values, 0, sizeof(values));
        memset(nulls, false, sizeof(nulls));
-       values[Anum_pg_statistic_ext_starelid - 1] = ObjectIdGetDatum(relid);
-       values[Anum_pg_statistic_ext_staname - 1] = NameGetDatum(&staname);
-       values[Anum_pg_statistic_ext_stanamespace - 1] = ObjectIdGetDatum(namespaceId);
-       values[Anum_pg_statistic_ext_staowner - 1] = ObjectIdGetDatum(GetUserId());
-       values[Anum_pg_statistic_ext_stakeys - 1] = PointerGetDatum(stakeys);
-       values[Anum_pg_statistic_ext_staenabled - 1] = PointerGetDatum(staenabled);
+       values[Anum_pg_statistic_ext_stxrelid - 1] = ObjectIdGetDatum(relid);
+       values[Anum_pg_statistic_ext_stxname - 1] = NameGetDatum(&stxname);
+       values[Anum_pg_statistic_ext_stxnamespace - 1] = ObjectIdGetDatum(namespaceId);
+       values[Anum_pg_statistic_ext_stxowner - 1] = ObjectIdGetDatum(GetUserId());
+       values[Anum_pg_statistic_ext_stxkeys - 1] = PointerGetDatum(stxkeys);
+       values[Anum_pg_statistic_ext_stxkind - 1] = PointerGetDatum(stxkind);
 
        /* no statistics build yet */
-       nulls[Anum_pg_statistic_ext_standistinct - 1] = true;
-       nulls[Anum_pg_statistic_ext_stadependencies - 1] = true;
+       nulls[Anum_pg_statistic_ext_stxndistinct - 1] = true;
+       nulls[Anum_pg_statistic_ext_stxdependencies - 1] = true;
 
        /* insert it into pg_statistic_ext */
        statrel = heap_open(StatisticExtRelationId, RowExclusiveLock);
@@ -303,7 +303,7 @@ RemoveStatisticsById(Oid statsOid)
                elog(ERROR, "cache lookup failed for statistics %u", statsOid);
 
        statext = (Form_pg_statistic_ext) GETSTRUCT(tup);
-       relid = statext->starelid;
+       relid = statext->stxrelid;
 
        rel = heap_open(relid, AccessExclusiveLock);
 
index 28322cec0e803f0b6ca7f087996073b401f76728..9207c8d8098bbab7d8327209de7bff9f04dd592b 100644 (file)
@@ -1293,8 +1293,8 @@ get_relation_statistics(RelOptInfo *rel, Relation relation)
                 * wasted if no stats are actually built, but it doesn't seem worth
                 * troubling over that case.
                 */
-               for (i = 0; i < staForm->stakeys.dim1; i++)
-                       keys = bms_add_member(keys, staForm->stakeys.values[i]);
+               for (i = 0; i < staForm->stxkeys.dim1; i++)
+                       keys = bms_add_member(keys, staForm->stxkeys.values[i]);
 
                /* add one StatisticExtInfo for each kind built */
                if (statext_is_kind_built(htup, STATS_EXT_NDISTINCT))
index fee07c6b34dad0f81d2794e48154683310eda38d..0890514bf789effc932020353d9129f2ecfcd1f6 100644 (file)
@@ -411,7 +411,7 @@ statext_dependencies_build(int numrows, HeapTuple *rows, Bitmapset *attrs,
                        d = (MVDependency *) palloc0(offsetof(MVDependency, attributes)
                                                                                 + k * sizeof(AttrNumber));
 
-                       /* copy the dependency (and keep the indexes into stakeys) */
+                       /* copy the dependency (and keep the indexes into stxkeys) */
                        d->degree = degree;
                        d->nattributes = k;
                        for (i = 0; i < k; i++)
@@ -652,7 +652,7 @@ staext_dependencies_load(Oid mvoid)
                elog(ERROR, "cache lookup failed for extended statistics %u", mvoid);
 
        deps = SysCacheGetAttr(STATEXTOID, htup,
-                                                  Anum_pg_statistic_ext_stadependencies, &isnull);
+                                                  Anum_pg_statistic_ext_stxdependencies, &isnull);
 
        Assert(!isnull);
 
index 64d0cc3e691e0c678a44f618cde05c6b5ced9fe6..b334140c48a1132b8338759b7be00588bc23df6a 100644 (file)
@@ -145,11 +145,11 @@ statext_is_kind_built(HeapTuple htup, char type)
        switch (type)
        {
                case STATS_EXT_NDISTINCT:
-                       attnum = Anum_pg_statistic_ext_standistinct;
+                       attnum = Anum_pg_statistic_ext_stxndistinct;
                        break;
 
                case STATS_EXT_DEPENDENCIES:
-                       attnum = Anum_pg_statistic_ext_stadependencies;
+                       attnum = Anum_pg_statistic_ext_stxdependencies;
                        break;
 
                default:
@@ -175,7 +175,7 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid)
         * rel.
         */
        ScanKeyInit(&skey,
-                               Anum_pg_statistic_ext_starelid,
+                               Anum_pg_statistic_ext_stxrelid,
                                BTEqualStrategyNumber, F_OIDEQ,
                                ObjectIdGetDatum(relid));
 
@@ -195,23 +195,23 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid)
                entry = palloc0(sizeof(StatExtEntry));
                entry->statOid = HeapTupleGetOid(htup);
                staForm = (Form_pg_statistic_ext) GETSTRUCT(htup);
-               entry->schema = get_namespace_name(staForm->stanamespace);
-               entry->name = pstrdup(NameStr(staForm->staname));
-               for (i = 0; i < staForm->stakeys.dim1; i++)
+               entry->schema = get_namespace_name(staForm->stxnamespace);
+               entry->name = pstrdup(NameStr(staForm->stxname));
+               for (i = 0; i < staForm->stxkeys.dim1; i++)
                {
                        entry->columns = bms_add_member(entry->columns,
-                                                                                       staForm->stakeys.values[i]);
+                                                                                       staForm->stxkeys.values[i]);
                }
 
-               /* decode the staenabled char array into a list of chars */
+               /* decode the stxkind char array into a list of chars */
                datum = SysCacheGetAttr(STATEXTOID, htup,
-                                                               Anum_pg_statistic_ext_staenabled, &isnull);
+                                                               Anum_pg_statistic_ext_stxkind, &isnull);
                Assert(!isnull);
                arr = DatumGetArrayTypeP(datum);
                if (ARR_NDIM(arr) != 1 ||
                        ARR_HASNULL(arr) ||
                        ARR_ELEMTYPE(arr) != CHAROID)
-                       elog(ERROR, "staenabled is not a 1-D char array");
+                       elog(ERROR, "stxkind is not a 1-D char array");
                enabled = (char *) ARR_DATA_PTR(arr);
                for (i = 0; i < ARR_DIMS(arr)[0]; i++)
                {
@@ -231,7 +231,7 @@ fetch_statentries_for_relation(Relation pg_statext, Oid relid)
 /*
  * Using 'vacatts' of size 'nvacatts' as input data, return a newly built
  * VacAttrStats array which includes only the items corresponding to
- * attributes indicated by 'stakeys'. If we don't have all of the per column
+ * attributes indicated by 'stxkeys'. If we don't have all of the per column
  * stats available to compute the extended stats, then we return NULL to indicate
  * to the caller that the stats should not be built.
  */
@@ -310,21 +310,21 @@ statext_store(Relation pg_stext, Oid statOid,
        {
                bytea      *data = statext_ndistinct_serialize(ndistinct);
 
-               nulls[Anum_pg_statistic_ext_standistinct - 1] = (data == NULL);
-               values[Anum_pg_statistic_ext_standistinct - 1] = PointerGetDatum(data);
+               nulls[Anum_pg_statistic_ext_stxndistinct - 1] = (data == NULL);
+               values[Anum_pg_statistic_ext_stxndistinct - 1] = PointerGetDatum(data);
        }
 
        if (dependencies != NULL)
        {
                bytea      *data = statext_dependencies_serialize(dependencies);
 
-               nulls[Anum_pg_statistic_ext_stadependencies - 1] = (data == NULL);
-               values[Anum_pg_statistic_ext_stadependencies - 1] = PointerGetDatum(data);
+               nulls[Anum_pg_statistic_ext_stxdependencies - 1] = (data == NULL);
+               values[Anum_pg_statistic_ext_stxdependencies - 1] = PointerGetDatum(data);
        }
 
        /* always replace the value (either by bytea or NULL) */
-       replaces[Anum_pg_statistic_ext_standistinct - 1] = true;
-       replaces[Anum_pg_statistic_ext_stadependencies - 1] = true;
+       replaces[Anum_pg_statistic_ext_stxndistinct - 1] = true;
+       replaces[Anum_pg_statistic_ext_stxdependencies - 1] = true;
 
        /* there should already be a pg_statistic_ext tuple */
        oldtup = SearchSysCache1(STATEXTOID, ObjectIdGetDatum(statOid));
index ece544b3a3c0232a0f01280dcde916aebfd1bf6b..b77113fb393c08e598cbde3e6eccbce63f6e78de 100644 (file)
@@ -134,7 +134,7 @@ statext_ndistinct_load(Oid mvoid)
                elog(ERROR, "cache lookup failed for statistics %u", mvoid);
 
        ndist = SysCacheGetAttr(STATEXTOID, htup,
-                                                       Anum_pg_statistic_ext_standistinct, &isnull);
+                                                       Anum_pg_statistic_ext_stxndistinct, &isnull);
        if (isnull)
                elog(ERROR,
                         "requested statistic kind %c not yet built for statistics %u",
index 5f11af2ee6e26f944fe7cfa72f0432a7500a9947..184e5daa05b77a64092864317cca58182d454e29 100644 (file)
@@ -1473,23 +1473,23 @@ pg_get_statisticsext_worker(Oid statextid, bool missing_ok)
 
        initStringInfo(&buf);
 
-       nsp = get_namespace_name(statextrec->stanamespace);
+       nsp = get_namespace_name(statextrec->stxnamespace);
        appendStringInfo(&buf, "CREATE STATISTICS %s",
                                         quote_qualified_identifier(nsp,
-                                                                                               NameStr(statextrec->staname)));
+                                                                                               NameStr(statextrec->stxname)));
 
        /*
-        * Lookup the staenabled column so that we know how to handle the WITH
+        * Lookup the stxkind column so that we know how to handle the WITH
         * clause.
         */
        datum = SysCacheGetAttr(STATEXTOID, statexttup,
-                                                       Anum_pg_statistic_ext_staenabled, &isnull);
+                                                       Anum_pg_statistic_ext_stxkind, &isnull);
        Assert(!isnull);
        arr = DatumGetArrayTypeP(datum);
        if (ARR_NDIM(arr) != 1 ||
                ARR_HASNULL(arr) ||
                ARR_ELEMTYPE(arr) != CHAROID)
-               elog(ERROR, "staenabled is not a 1-D char array");
+               elog(ERROR, "stxkind is not a 1-D char array");
        enabled = (char *) ARR_DATA_PTR(arr);
 
        ndistinct_enabled = false;
@@ -1523,21 +1523,21 @@ pg_get_statisticsext_worker(Oid statextid, bool missing_ok)
 
        appendStringInfoString(&buf, " ON (");
 
-       for (colno = 0; colno < statextrec->stakeys.dim1; colno++)
+       for (colno = 0; colno < statextrec->stxkeys.dim1; colno++)
        {
-               AttrNumber      attnum = statextrec->stakeys.values[colno];
+               AttrNumber      attnum = statextrec->stxkeys.values[colno];
                char       *attname;
 
                if (colno > 0)
                        appendStringInfoString(&buf, ", ");
 
-               attname = get_relid_attribute_name(statextrec->starelid, attnum);
+               attname = get_relid_attribute_name(statextrec->stxrelid, attnum);
 
                appendStringInfoString(&buf, quote_identifier(attname));
        }
 
        appendStringInfo(&buf, ") FROM %s",
-                                        generate_relation_name(statextrec->starelid, NIL));
+                                        generate_relation_name(statextrec->stxrelid, NIL));
 
        ReleaseSysCache(statexttup);
 
index 5bf02d4c0e63342d9c717f8e54955ac57dd1f26b..85c6b6131025edefa7839eaa33d41eec726be078 100644 (file)
@@ -4497,9 +4497,9 @@ RelationGetStatExtList(Relation relation)
         */
        result = NIL;
 
-       /* Prepare to scan pg_statistic_ext for entries having starelid = this rel. */
+       /* Prepare to scan pg_statistic_ext for entries having stxrelid = this rel. */
        ScanKeyInit(&skey,
-                               Anum_pg_statistic_ext_starelid,
+                               Anum_pg_statistic_ext_stxrelid,
                                BTEqualStrategyNumber, F_OIDEQ,
                                ObjectIdGetDatum(RelationGetRelid(relation)));
 
index d8c823f42b529fbf9ced2964fa7ff01ddbca7be9..edbc151f33e83490c50571658f473238e4c3ddba 100644 (file)
@@ -731,8 +731,8 @@ static const struct cachedesc cacheinfo[] = {
                StatisticExtNameIndexId,
                2,
                {
-                       Anum_pg_statistic_ext_staname,
-                       Anum_pg_statistic_ext_stanamespace,
+                       Anum_pg_statistic_ext_stxname,
+                       Anum_pg_statistic_ext_stxnamespace,
                        0,
                        0
                },
index 88240187866380f29a8307354db4e4b146e3d6e8..e9b5c8a448385c1f155ef3a9a309d0e12b70df63 100644 (file)
@@ -6663,8 +6663,8 @@ getExtendedStatistics(Archive *fout, TableInfo tblinfo[], int numTables)
        int                             ntups;
        int                             i_tableoid;
        int                             i_oid;
-       int                             i_staname;
-       int                             i_stadef;
+       int                             i_stxname;
+       int                             i_stxdef;
 
        /* Extended statistics were new in v10 */
        if (fout->remoteVersion < 100000)
@@ -6707,11 +6707,11 @@ getExtendedStatistics(Archive *fout, TableInfo tblinfo[], int numTables)
                                                  "SELECT "
                                                        "tableoid, "
                                                        "oid, "
-                                                       "staname, "
-                                                 "pg_catalog.pg_get_statisticsextdef(oid) AS stadef "
+                                                       "stxname, "
+                                                 "pg_catalog.pg_get_statisticsextdef(oid) AS stxdef "
                                                  "FROM pg_statistic_ext "
-                                                 "WHERE starelid = '%u' "
-                                                 "ORDER BY staname", tbinfo->dobj.catId.oid);
+                                                 "WHERE stxrelid = '%u' "
+                                                 "ORDER BY stxname", tbinfo->dobj.catId.oid);
 
                res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
 
@@ -6719,8 +6719,8 @@ getExtendedStatistics(Archive *fout, TableInfo tblinfo[], int numTables)
 
                i_tableoid = PQfnumber(res, "tableoid");
                i_oid = PQfnumber(res, "oid");
-               i_staname = PQfnumber(res, "staname");
-               i_stadef = PQfnumber(res, "stadef");
+               i_stxname = PQfnumber(res, "stxname");
+               i_stxdef = PQfnumber(res, "stxdef");
 
                statsextinfo = (StatsExtInfo *) pg_malloc(ntups * sizeof(StatsExtInfo));
 
@@ -6730,10 +6730,10 @@ getExtendedStatistics(Archive *fout, TableInfo tblinfo[], int numTables)
                        statsextinfo[j].dobj.catId.tableoid = atooid(PQgetvalue(res, j, i_tableoid));
                        statsextinfo[j].dobj.catId.oid = atooid(PQgetvalue(res, j, i_oid));
                        AssignDumpId(&statsextinfo[j].dobj);
-                       statsextinfo[j].dobj.name = pg_strdup(PQgetvalue(res, j, i_staname));
+                       statsextinfo[j].dobj.name = pg_strdup(PQgetvalue(res, j, i_stxname));
                        statsextinfo[j].dobj.namespace = tbinfo->dobj.namespace;
                        statsextinfo[j].statsexttable = tbinfo;
-                       statsextinfo[j].statsextdef = pg_strdup(PQgetvalue(res, j, i_stadef));
+                       statsextinfo[j].statsextdef = pg_strdup(PQgetvalue(res, j, i_stxdef));
                }
 
                PQclear(res);
index 59121b8d1b06eaf5d1e55858e005ed2ae5ccd038..0f9f497c66441a77deabdba5ceac2bea9ea438b4 100644 (file)
@@ -2344,16 +2344,16 @@ describeOneTableDetails(const char *schemaname,
                {
                        printfPQExpBuffer(&buf,
                                                          "SELECT oid, "
-                                                         "stanamespace::pg_catalog.regnamespace AS nsp, "
-                                                         "staname, stakeys,\n"
+                                                         "stxnamespace::pg_catalog.regnamespace AS nsp, "
+                                                         "stxname, stxkeys,\n"
                                                          "  (SELECT pg_catalog.string_agg(pg_catalog.quote_ident(attname),', ')\n"
-                                                         "   FROM pg_catalog.unnest(stakeys) s(attnum)\n"
-                                                         "   JOIN pg_catalog.pg_attribute a ON (starelid = a.attrelid AND\n"
+                                                         "   FROM pg_catalog.unnest(stxkeys) s(attnum)\n"
+                                                         "   JOIN pg_catalog.pg_attribute a ON (stxrelid = a.attrelid AND\n"
                                                          "        a.attnum = s.attnum AND NOT attisdropped)) AS columns,\n"
-                                                         "  (staenabled @> '{d}') AS ndist_enabled,\n"
-                                                         "  (staenabled @> '{f}') AS deps_enabled\n"
+                                                         "  (stxkind @> '{d}') AS ndist_enabled,\n"
+                                                         "  (stxkind @> '{f}') AS deps_enabled\n"
                                                          "FROM pg_catalog.pg_statistic_ext stat "
-                                                         "WHERE starelid = '%s'\n"
+                                                         "WHERE stxrelid = '%s'\n"
                                                          "ORDER BY 1;",
                                                          oid);
 
index e978b3a8a5ea0fe094c7a2008055778d05f72df4..ab92fd88ed8d2083e5a1055874b541b8c9481fca 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     201704141
+#define CATALOG_VERSION_NO     201704171
 
 #endif
index a7266860ceb0923cccf9e36918af6e8c36072cae..07300f8a2bd9e50a881f65754766b3e21923cf99 100644 (file)
@@ -184,9 +184,9 @@ DECLARE_UNIQUE_INDEX(pg_largeobject_metadata_oid_index, 2996, on pg_largeobject_
 
 DECLARE_UNIQUE_INDEX(pg_statistic_ext_oid_index, 3380, on pg_statistic_ext using btree(oid oid_ops));
 #define StatisticExtOidIndexId 3380
-DECLARE_UNIQUE_INDEX(pg_statistic_ext_name_index, 3997, on pg_statistic_ext using btree(staname name_ops, stanamespace oid_ops));
+DECLARE_UNIQUE_INDEX(pg_statistic_ext_name_index, 3997, on pg_statistic_ext using btree(stxname name_ops, stxnamespace oid_ops));
 #define StatisticExtNameIndexId 3997
-DECLARE_INDEX(pg_statistic_ext_relid_index, 3379, on pg_statistic_ext using btree(starelid oid_ops));
+DECLARE_INDEX(pg_statistic_ext_relid_index, 3379, on pg_statistic_ext using btree(stxrelid oid_ops));
 #define StatisticExtRelidIndexId 3379
 
 DECLARE_UNIQUE_INDEX(pg_namespace_nspname_index, 2684, on pg_namespace using btree(nspname name_ops));
index 0a1cc0446ed0b3292a96c6cf37b1a11eece040f5..b0fda076fe4b1888b649394f7af7cad8c75e4586 100644 (file)
 CATALOG(pg_statistic_ext,3381)
 {
        /* These fields form the unique key for the entry: */
-       Oid                     starelid;               /* relation containing attributes */
-       NameData        staname;                /* statistics name */
-       Oid                     stanamespace;   /* OID of namespace containing this statistics */
-       Oid                     staowner;               /* statistics owner */
+       Oid                     stxrelid;               /* relation containing attributes */
+       NameData        stxname;                /* statistics name */
+       Oid                     stxnamespace;   /* OID of namespace containing this statistics */
+       Oid                     stxowner;               /* statistics owner */
 
        /*
         * variable-length fields start here, but we allow direct access to
-        * stakeys
+        * stxkeys
         */
-       int2vector      stakeys;                /* array of column keys */
+       int2vector      stxkeys;                /* array of column keys */
 
 #ifdef CATALOG_VARLEN
-       char            staenabled[1] BKI_FORCE_NOT_NULL;       /* statistic types
+       char            stxkind[1] BKI_FORCE_NOT_NULL;          /* statistic types
                                                                                                         * requested to build */
-       pg_ndistinct standistinct;      /* ndistinct coefficients (serialized) */
-       pg_dependencies stadependencies;        /* dependencies (serialized) */
+       pg_ndistinct stxndistinct;      /* ndistinct coefficients (serialized) */
+       pg_dependencies stxdependencies;        /* dependencies (serialized) */
 #endif
 
 } FormData_pg_statistic_ext;
@@ -63,14 +63,14 @@ typedef FormData_pg_statistic_ext *Form_pg_statistic_ext;
  * ----------------
  */
 #define Natts_pg_statistic_ext                                 8
-#define Anum_pg_statistic_ext_starelid                 1
-#define Anum_pg_statistic_ext_staname                  2
-#define Anum_pg_statistic_ext_stanamespace             3
-#define Anum_pg_statistic_ext_staowner                 4
-#define Anum_pg_statistic_ext_stakeys                  5
-#define Anum_pg_statistic_ext_staenabled               6
-#define Anum_pg_statistic_ext_standistinct             7
-#define Anum_pg_statistic_ext_stadependencies  8
+#define Anum_pg_statistic_ext_stxrelid                 1
+#define Anum_pg_statistic_ext_stxname                  2
+#define Anum_pg_statistic_ext_stxnamespace             3
+#define Anum_pg_statistic_ext_stxowner                 4
+#define Anum_pg_statistic_ext_stxkeys                  5
+#define Anum_pg_statistic_ext_stxkind                  6
+#define Anum_pg_statistic_ext_stxndistinct             7
+#define Anum_pg_statistic_ext_stxdependencies  8
 
 #define STATS_EXT_NDISTINCT                    'd'
 #define STATS_EXT_DEPENDENCIES         'f'
index ce581bb93d5e3f6ec17d50b5979fea08b15a72bf..a81a4edfb2b43ae5881306738952bff47f40005b 100644 (file)
@@ -525,12 +525,12 @@ ERROR:  must be owner of statistics alt_stat3
 ALTER STATISTICS alt_stat2 SET SCHEMA alt_nsp2;                -- failed (name conflict)
 ERROR:  statistics "alt_stat2" already exists in schema "alt_nsp2"
 RESET SESSION AUTHORIZATION;
-SELECT nspname, staname, rolname
+SELECT nspname, stxname, rolname
   FROM pg_statistic_ext s, pg_namespace n, pg_authid a
- WHERE s.stanamespace = n.oid AND s.staowner = a.oid
+ WHERE s.stxnamespace = n.oid AND s.stxowner = a.oid
    AND n.nspname in ('alt_nsp1', 'alt_nsp2')
- ORDER BY nspname, staname;
- nspname  |  staname  |       rolname       
+ ORDER BY nspname, stxname;
+ nspname  |  stxname  |       rolname       
 ----------+-----------+---------------------
  alt_nsp1 | alt_stat2 | regress_alter_user2
  alt_nsp1 | alt_stat3 | regress_alter_user1
index 658d28576958fa27eef94660de0a99162d236185..0d6f65e604b833a01d5f2caeb244a08070dc249e 100644 (file)
@@ -12,7 +12,7 @@ DROP STATISTICS ab1_a_b_stats;
 CREATE SCHEMA regress_schema_2;
 CREATE STATISTICS regress_schema_2.ab1_a_b_stats ON (a, b) FROM ab1;
 -- Let's also verify the pg_get_statisticsextdef output looks sane.
-SELECT pg_get_statisticsextdef(oid) FROM pg_statistic_ext WHERE staname = 'ab1_a_b_stats';
+SELECT pg_get_statisticsextdef(oid) FROM pg_statistic_ext WHERE stxname = 'ab1_a_b_stats';
                        pg_get_statisticsextdef                       
 ---------------------------------------------------------------------
  CREATE STATISTICS regress_schema_2.ab1_a_b_stats ON (a, b) FROM ab1
@@ -173,11 +173,11 @@ ERROR:  duplicate column name in statistics definition
 -- correct command
 CREATE STATISTICS s10 ON (a, b, c) FROM ndistinct;
 ANALYZE ndistinct;
-SELECT staenabled, standistinct
-  FROM pg_statistic_ext WHERE starelid = 'ndistinct'::regclass;
- staenabled |                                          standistinct                                          
-------------+------------------------------------------------------------------------------------------------
- {d,f}      | [{(b 3 4), 301.000000}, {(b 3 6), 301.000000}, {(b 4 6), 301.000000}, {(b 3 4 6), 301.000000}]
+SELECT stxkind, stxndistinct
+  FROM pg_statistic_ext WHERE stxrelid = 'ndistinct'::regclass;
+ stxkind |                                          stxndistinct                                          
+---------+------------------------------------------------------------------------------------------------
+ {d,f}   | [{(b 3 4), 301.000000}, {(b 3 6), 301.000000}, {(b 4 6), 301.000000}, {(b 3 4 6), 301.000000}]
 (1 row)
 
 -- Hash Aggregate, thanks to estimates improved by the statistic
@@ -239,11 +239,11 @@ INSERT INTO ndistinct (a, b, c, filler1)
             cash_words(mod(i,33)::int::money)
        FROM generate_series(1,10000) s(i);
 ANALYZE ndistinct;
-SELECT staenabled, standistinct
-  FROM pg_statistic_ext WHERE starelid = 'ndistinct'::regclass;
- staenabled |                                            standistinct                                            
-------------+----------------------------------------------------------------------------------------------------
- {d,f}      | [{(b 3 4), 2550.000000}, {(b 3 6), 800.000000}, {(b 4 6), 1632.000000}, {(b 3 4 6), 10000.000000}]
+SELECT stxkind, stxndistinct
+  FROM pg_statistic_ext WHERE stxrelid = 'ndistinct'::regclass;
+ stxkind |                                            stxndistinct                                            
+---------+----------------------------------------------------------------------------------------------------
+ {d,f}   | [{(b 3 4), 2550.000000}, {(b 3 6), 800.000000}, {(b 4 6), 1632.000000}, {(b 3 4 6), 10000.000000}]
 (1 row)
 
 -- plans using Group Aggregate, thanks to using correct esimates
@@ -299,10 +299,10 @@ EXPLAIN (COSTS off)
 (3 rows)
 
 DROP STATISTICS s10;
-SELECT staenabled, standistinct
-  FROM pg_statistic_ext WHERE starelid = 'ndistinct'::regclass;
- staenabled | standistinct 
-------------+--------------
+SELECT stxkind, stxndistinct
+  FROM pg_statistic_ext WHERE stxrelid = 'ndistinct'::regclass;
+ stxkind | stxndistinct 
+---------+--------------
 (0 rows)
 
 -- dropping the statistics switches the plans to Hash Aggregate,
index f6fa8d8bfdb8421059226419562b467b905dddd0..88e8d7eb86b9ae901e09c1bf429fe07ef0abd81f 100644 (file)
@@ -459,11 +459,11 @@ ALTER STATISTICS alt_stat3 SET SCHEMA alt_nsp2;           -- failed (not owner)
 ALTER STATISTICS alt_stat2 SET SCHEMA alt_nsp2;                -- failed (name conflict)
 
 RESET SESSION AUTHORIZATION;
-SELECT nspname, staname, rolname
+SELECT nspname, stxname, rolname
   FROM pg_statistic_ext s, pg_namespace n, pg_authid a
- WHERE s.stanamespace = n.oid AND s.staowner = a.oid
+ WHERE s.stxnamespace = n.oid AND s.stxowner = a.oid
    AND n.nspname in ('alt_nsp1', 'alt_nsp2')
- ORDER BY nspname, staname;
+ ORDER BY nspname, stxname;
 
 --
 -- Text Search Dictionary
index 3c7e0684d3ec148186889eda549ab363bc603a90..72c7659c4b1d8a94fa6cad38e08455a7f4a12e4d 100644 (file)
@@ -16,7 +16,7 @@ CREATE SCHEMA regress_schema_2;
 CREATE STATISTICS regress_schema_2.ab1_a_b_stats ON (a, b) FROM ab1;
 
 -- Let's also verify the pg_get_statisticsextdef output looks sane.
-SELECT pg_get_statisticsextdef(oid) FROM pg_statistic_ext WHERE staname = 'ab1_a_b_stats';
+SELECT pg_get_statisticsextdef(oid) FROM pg_statistic_ext WHERE stxname = 'ab1_a_b_stats';
 
 DROP STATISTICS regress_schema_2.ab1_a_b_stats;
 
@@ -130,8 +130,8 @@ CREATE STATISTICS s10 ON (a, b, c) FROM ndistinct;
 
 ANALYZE ndistinct;
 
-SELECT staenabled, standistinct
-  FROM pg_statistic_ext WHERE starelid = 'ndistinct'::regclass;
+SELECT stxkind, stxndistinct
+  FROM pg_statistic_ext WHERE stxrelid = 'ndistinct'::regclass;
 
 -- Hash Aggregate, thanks to estimates improved by the statistic
 EXPLAIN (COSTS off)
@@ -161,8 +161,8 @@ INSERT INTO ndistinct (a, b, c, filler1)
 
 ANALYZE ndistinct;
 
-SELECT staenabled, standistinct
-  FROM pg_statistic_ext WHERE starelid = 'ndistinct'::regclass;
+SELECT stxkind, stxndistinct
+  FROM pg_statistic_ext WHERE stxrelid = 'ndistinct'::regclass;
 
 -- plans using Group Aggregate, thanks to using correct esimates
 EXPLAIN (COSTS off)
@@ -182,8 +182,8 @@ EXPLAIN (COSTS off)
 
 DROP STATISTICS s10;
 
-SELECT staenabled, standistinct
-  FROM pg_statistic_ext WHERE starelid = 'ndistinct'::regclass;
+SELECT stxkind, stxndistinct
+  FROM pg_statistic_ext WHERE stxrelid = 'ndistinct'::regclass;
 
 -- dropping the statistics switches the plans to Hash Aggregate,
 -- due to under-estimates