Compare commits

...

3 Commits

Author SHA1 Message Date
Jeff Davis 869ee4f10e Disallow modifying statistics on system columns. 1 day ago
Nathan Bossart efdc7d7475 Add INT64_HEX_FORMAT and UINT64_HEX_FORMAT to c.h. 1 day ago
Nathan Bossart 8589876b79 Add a couple of recent commits to .git-blame-ignore-revs. 1 day ago
  1. 6
      .git-blame-ignore-revs
  2. 2
      contrib/postgres_fdw/option.c
  3. 14
      src/backend/statistics/attribute_stats.c
  4. 2
      src/backend/utils/error/csvlog.c
  5. 4
      src/backend/utils/error/elog.c
  6. 2
      src/backend/utils/error/jsonlog.c
  7. 2
      src/include/c.h
  8. 2
      src/test/modules/test_radixtree/test_radixtree.c
  9. 15
      src/test/regress/expected/stats_import.out
  10. 15
      src/test/regress/sql/stats_import.sql

@ -14,6 +14,12 @@
#
# $ git log --pretty=format:"%H # %cd%n# %s" $PGINDENTGITHASH -1 --date=iso
53dcba9be5746cc126bdb949bf81c29ea2cfc24d # 2024-11-21 21:40:17 +0100
# pgindent run
a7f2f6adc240a2823c2344b89e90bb630dea8803 # 2024-10-16 12:21:13 -0700
# Whitespace fixup from generated unicode tables.
7f7474a8e4002ac9fd4979cc7b16b50b70b70c28 # 2024-09-27 11:14:31 -0400
# Reindent pg_verifybackup.c.

@ -521,7 +521,7 @@ process_pgfdw_appname(const char *appname)
appendStringInfoString(&buf, application_name);
break;
case 'c':
appendStringInfo(&buf, "%" INT64_MODIFIER "x.%x", MyStartTime, MyProcPid);
appendStringInfo(&buf, INT64_HEX_FORMAT ".%x", MyStartTime, MyProcPid);
break;
case 'C':
appendStringInfoString(&buf, cluster_name);

@ -167,6 +167,13 @@ attribute_statistics_update(FunctionCallInfo fcinfo, int elevel)
stats_check_required_arg(fcinfo, attarginfo, ATTNAME_ARG);
attname = PG_GETARG_NAME(ATTNAME_ARG);
attnum = get_attnum(reloid, NameStr(*attname));
if (attnum < 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot modify statistics on system column \"%s\"",
NameStr(*attname))));
if (attnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),
@ -882,6 +889,13 @@ pg_clear_attribute_stats(PG_FUNCTION_ARGS)
stats_check_required_arg(fcinfo, attarginfo, ATTNAME_ARG);
attname = PG_GETARG_NAME(ATTNAME_ARG);
attnum = get_attnum(reloid, NameStr(*attname));
if (attnum < 0)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot clear statistics on system column \"%s\"",
NameStr(*attname))));
if (attnum == InvalidAttrNumber)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_COLUMN),

@ -120,7 +120,7 @@ write_csvlog(ErrorData *edata)
appendStringInfoChar(&buf, ',');
/* session id */
appendStringInfo(&buf, "%" INT64_MODIFIER "x.%x", MyStartTime, MyProcPid);
appendStringInfo(&buf, INT64_HEX_FORMAT ".%x", MyStartTime, MyProcPid);
appendStringInfoChar(&buf, ',');
/* Line number */

@ -2947,12 +2947,12 @@ log_status_format(StringInfo buf, const char *format, ErrorData *edata)
{
char strfbuf[128];
snprintf(strfbuf, sizeof(strfbuf) - 1, "%" INT64_MODIFIER "x.%x",
snprintf(strfbuf, sizeof(strfbuf) - 1, INT64_HEX_FORMAT ".%x",
MyStartTime, MyProcPid);
appendStringInfo(buf, "%*s", padding, strfbuf);
}
else
appendStringInfo(buf, "%" INT64_MODIFIER "x.%x", MyStartTime, MyProcPid);
appendStringInfo(buf, INT64_HEX_FORMAT ".%x", MyStartTime, MyProcPid);
break;
case 'p':
if (padding != 0)

@ -168,7 +168,7 @@ write_jsonlog(ErrorData *edata)
}
/* Session id */
appendJSONKeyValueFmt(&buf, "session_id", true, "%" INT64_MODIFIER "x.%x",
appendJSONKeyValueFmt(&buf, "session_id", true, INT64_HEX_FORMAT ".%x",
MyStartTime, MyProcPid);
/* Line number */

@ -550,6 +550,8 @@ typedef unsigned long long int uint64;
/* snprintf format strings to use for 64-bit integers */
#define INT64_FORMAT "%" INT64_MODIFIER "d"
#define UINT64_FORMAT "%" INT64_MODIFIER "u"
#define INT64_HEX_FORMAT "%" INT64_MODIFIER "x"
#define UINT64_HEX_FORMAT "%" INT64_MODIFIER "x"
/*
* 128-bit signed and unsigned integers

@ -21,8 +21,6 @@
/* uncomment to use shared memory for the tree */
/* #define TEST_SHARED_RT */
#define UINT64_HEX_FORMAT "%" INT64_MODIFIER "X"
/* Convenient macros to test results */
#define EXPECT_TRUE(expr) \
do { \

@ -195,6 +195,15 @@ SELECT pg_catalog.pg_set_attribute_stats(
avg_width => 2::integer,
n_distinct => 0.3::real);
ERROR: "relation" cannot be NULL
-- error: attribute is system column
SELECT pg_catalog.pg_set_attribute_stats(
relation => 'stats_import.test'::regclass,
attname => 'xmin'::name,
inherited => false::boolean,
null_frac => 0.1::real,
avg_width => 2::integer,
n_distinct => 0.3::real);
ERROR: cannot modify statistics on system column "xmin"
-- error: attname doesn't exist
SELECT pg_catalog.pg_set_attribute_stats(
relation => 'stats_import.test'::regclass,
@ -204,6 +213,12 @@ SELECT pg_catalog.pg_set_attribute_stats(
avg_width => 2::integer,
n_distinct => 0.3::real);
ERROR: column "nope" of relation "test" does not exist
-- error: attribute is system column
SELECT pg_catalog.pg_clear_attribute_stats(
relation => 'stats_import.test'::regclass,
attname => 'ctid'::name,
inherited => false::boolean);
ERROR: cannot clear statistics on system column "ctid"
-- error: attname doesn't exist
SELECT pg_catalog.pg_clear_attribute_stats(
relation => 'stats_import.test'::regclass,

@ -145,6 +145,15 @@ SELECT pg_catalog.pg_set_attribute_stats(
avg_width => 2::integer,
n_distinct => 0.3::real);
-- error: attribute is system column
SELECT pg_catalog.pg_set_attribute_stats(
relation => 'stats_import.test'::regclass,
attname => 'xmin'::name,
inherited => false::boolean,
null_frac => 0.1::real,
avg_width => 2::integer,
n_distinct => 0.3::real);
-- error: attname doesn't exist
SELECT pg_catalog.pg_set_attribute_stats(
relation => 'stats_import.test'::regclass,
@ -154,6 +163,12 @@ SELECT pg_catalog.pg_set_attribute_stats(
avg_width => 2::integer,
n_distinct => 0.3::real);
-- error: attribute is system column
SELECT pg_catalog.pg_clear_attribute_stats(
relation => 'stats_import.test'::regclass,
attname => 'ctid'::name,
inherited => false::boolean);
-- error: attname doesn't exist
SELECT pg_catalog.pg_clear_attribute_stats(
relation => 'stats_import.test'::regclass,

Loading…
Cancel
Save