stats_check_required_arg(fcinfo, attarginfo, ATTNAME_ARG);
attname = PG_GETARG_NAME(ATTNAME_ARG);
attnum = get_attnum(reloid, NameStr(*attname));
+ if (attnum == InvalidAttrNumber)
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("column \"%s\" of relation \"%s\" does not exist",
+ NameStr(*attname), get_rel_name(reloid))));
stats_check_required_arg(fcinfo, attarginfo, INHERITED_ARG);
inherited = PG_GETARG_BOOL(INHERITED_ARG);
stats_check_required_arg(fcinfo, attarginfo, ATTNAME_ARG);
attname = PG_GETARG_NAME(ATTNAME_ARG);
attnum = get_attnum(reloid, NameStr(*attname));
+ if (attnum == InvalidAttrNumber)
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_COLUMN),
+ errmsg("column \"%s\" of relation \"%s\" does not exist",
+ NameStr(*attname), get_rel_name(reloid))));
stats_check_required_arg(fcinfo, attarginfo, INHERITED_ARG);
inherited = PG_GETARG_BOOL(INHERITED_ARG);
avg_width => 2::integer,
n_distinct => 0.3::real);
ERROR: could not open relation with OID 0
+-- error: object doesn't exist
+SELECT pg_catalog.pg_clear_attribute_stats(
+ relation => '0'::oid,
+ attname => 'id'::name,
+ inherited => false::boolean);
+ERROR: could not open relation with OID 0
-- error: relation null
SELECT pg_catalog.pg_set_attribute_stats(
relation => NULL::oid,
avg_width => 2::integer,
n_distinct => 0.3::real);
ERROR: "relation" cannot be NULL
+-- error: attname doesn't exist
+SELECT pg_catalog.pg_set_attribute_stats(
+ relation => 'stats_import.test'::regclass,
+ attname => 'nope'::name,
+ inherited => false::boolean,
+ null_frac => 0.1::real,
+ avg_width => 2::integer,
+ n_distinct => 0.3::real);
+ERROR: column "nope" of relation "test" does not exist
+-- error: attname doesn't exist
+SELECT pg_catalog.pg_clear_attribute_stats(
+ relation => 'stats_import.test'::regclass,
+ attname => 'nope'::name,
+ inherited => false::boolean);
+ERROR: column "nope" of relation "test" does not exist
-- error: attname null
SELECT pg_catalog.pg_set_attribute_stats(
relation => 'stats_import.test'::regclass,
most_common_freqs => '{0.2,0.1}'::real[]
);
ERROR: invalid input syntax for type integer: "2023-09-30"
--- warning: mcv cast failure
+-- error: mcv cast failure
SELECT pg_catalog.pg_set_attribute_stats(
relation => 'stats_import.test'::regclass,
attname => 'id'::name,
avg_width => 2::integer,
n_distinct => 0.3::real);
+-- error: object doesn't exist
+SELECT pg_catalog.pg_clear_attribute_stats(
+ relation => '0'::oid,
+ attname => 'id'::name,
+ inherited => false::boolean);
+
-- error: relation null
SELECT pg_catalog.pg_set_attribute_stats(
relation => NULL::oid,
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,
+ attname => 'nope'::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_clear_attribute_stats(
+ relation => 'stats_import.test'::regclass,
+ attname => 'nope'::name,
+ inherited => false::boolean);
+
-- error: attname null
SELECT pg_catalog.pg_set_attribute_stats(
relation => 'stats_import.test'::regclass,
most_common_freqs => '{0.2,0.1}'::real[]
);
--- warning: mcv cast failure
+-- error: mcv cast failure
SELECT pg_catalog.pg_set_attribute_stats(
relation => 'stats_import.test'::regclass,
attname => 'id'::name,