Hi,

I've attached a patch to adjust the error message for CREATE STATISTICS
to account for expressions. 

Previously, when attempting to create extended statistics on a single column,
the following error is raised.

 ERROR:  extended statistics require at least 2 columns

However, this message assumed only columns. In reality, an expression on a
single column is also allowed, so two columns are not necessarily required.
Thgis patch updates the message to: 

 ERROR:  extended statistics require at least 2 columns or an expression

Regards,
Yugo Nagata

-- 
Yugo Nagata <[email protected]>
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index c1da79f36ba..b4a4e663f35 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -437,7 +437,7 @@ CreateStatistics(CreateStatsStmt *stmt, bool check_rights)
 	if ((numcols < 2) && (list_length(stxexprs) != 1))
 		ereport(ERROR,
 				(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
-				 errmsg("extended statistics require at least 2 columns")));
+				 errmsg("extended statistics require at least 2 columns or an expression")));
 
 	/*
 	 * Sort the attnums, which makes detecting duplicates somewhat easier, and

Reply via email to