- Notifications
You must be signed in to change notification settings - Fork5.3k
Commit44eba8f
committed
Add input function for data type pg_ndistinct
pg_ndistinct is used as data type for the contents of ndistinct extendedstatistics. This new input function consumes the format that has beenestablished by1f927cc for the output function of pg_ndistinct,enforcing some sanity checks for:- Checks for the input object, which should be a one-dimension arraywith correct attributes and values.- The key names: "attributes", "ndistinct". Both are required, otherkey names are blocked.- Value types for each key: "attributes" requires an array of integers,and "ndistinct" an integer.- List of attributes. Note that this enforces a check so as anattribute list has to be a subset of the longest attribute list found.This does not enforce that a full group of attribute sets exist, basedon how the groups are generated when the ndistinct objects aregenerated, making the list of ndistinct items a bit loose. Note a checkwould still be required at import to see if the attributes listed matchwith the attribute numbers set in the definition of a statistics object.- Based on the discussion, the checks on the values are loose, as thereis also an argument for potentially stats injection. The relation andattribute level stats follow the same line of argument for the values.This is required for a follow-up patch that aims to implement the importof extended statistics. Some tests are added to check the code paths ofthe JSON parser checking the shape of the pg_ndistinct inputs, with 90%of code coverage reached. The tests are located in their own new testfile, for clarity.Author: Corey Huinker <corey.huinker@gmail.com>Reviewed-by: Jian He <jian.universality@gmail.com>Reviewed-by: Chao Li <li.evan.chao@gmail.com>Reviewed-by: Michael Paquier <michael@paquier.xyz>Reviewed-by: Yuefei Shi <shiyuefei1004@gmail.com>Discussion:https://postgr.es/m/CADkLM=dpz3KFnqP-dgJ-zvRvtjsa8UZv8wDAQdqho=qN3kX0Zg@mail.gmail.com1 parentcd38b7e commit44eba8f
File tree
5 files changed
+1316
-9
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
- tools/pgindent
5 files changed
+1316
-9
lines changed0 commit comments
Comments
(0)