index 686f2e639c66adb9d6bae69ac148134eec7d5adc..b97ba7b0c0c062fa8bfe725e310a8ab15bcfe272 100644 (file)
@@ -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),
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),
index 9186fc01ecc46321483e4b86c34f761435dc4669..aab862c97c717ebbeaf10e68ad8891082ec51680 100644 (file)
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,
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,
index c7d5e017d9004d7b30e529f5a5962c93f39d6027..31455b58c1dac7f3b254ec2e87b2e73af6d00c43 100644 (file)
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,
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,