mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-26 04:09:50 -05:00
### Does this PR have any customer impact? Yes ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Feature ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) Yes ### Are you introducing any new config? If yes, do you have tests with and without them being set? Yes ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ### Description More general improvements to order by and composite: Create Indexes 1) Support creating a composite index side by side with a regular index 2) Block creation of descending or wildcard and unsupported set ups for composite indexes Planner: 1) Support ordering by the Nth path of an index if the prefixes are equality. 2) Validate that if it's not the first column, prefixes are provided 3) Support incremental sort with index pushdown. ---- #### AI description (iteration 1) #### PR Classification This pull request delivers a new feature and API enhancement to enable order-by index pushdown and refined composite index support. #### PR Summary The update streamlines composite index processing by introducing stricter equivalency checks, new UDF functions for full-scan order-by pushdown, and enhanced validations during index creation while updating explain outputs and tests. - `src/metadata/index.c` refines index options equivalency logic to correctly compare composite term settings. - `src/opclass/bson_gin_composite_entrypoint.c` and `src/index_am/rum.c` add functions to support order-by pushdown and manage duplicate entries efficiently. - `sql/udfs/query/bson_dollar_comparison--0.105-0.sql` (and related operator files) introduce new UDFs including `bson_dollar_fullscan` to enable full scan operations. - `src/commands/create_indexes.c` enforces new composite index validations (restricting use to ascending, non-wildcard regular indexes) with precise error reporting. - Test scripts and explain plan outputs in the `regress` and `pgmongo` directories are updated to confirm the new composite order-by behavior. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
75 lines
2.9 KiB
SQL
75 lines
2.9 KiB
SQL
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.dollar_support(internal)
|
|
RETURNS internal
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
AS 'MODULE_PATHNAME', $$dollar_support$$;
|
|
|
|
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.bson_dollar_eq(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_eq$function$;
|
|
|
|
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.bson_dollar_lt(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_lt$function$;
|
|
|
|
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.bson_dollar_lte(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_lte$function$;
|
|
|
|
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.bson_dollar_gt(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_gt$function$;
|
|
|
|
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.bson_dollar_gte(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_gte$function$;
|
|
|
|
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.bson_dollar_in(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_in$function$;
|
|
|
|
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.bson_dollar_ne(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_ne$function$;
|
|
|
|
CREATE OR REPLACE FUNCTION __API_CATALOG_SCHEMA__.bson_dollar_nin(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_nin$function$;
|
|
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.bson_dollar_range(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_range$function$;
|
|
|
|
CREATE OR REPLACE FUNCTION __API_SCHEMA_INTERNAL_V2__.bson_dollar_fullscan(__CORE_SCHEMA__.bson, __CORE_SCHEMA__.bson)
|
|
RETURNS bool
|
|
LANGUAGE c
|
|
IMMUTABLE PARALLEL SAFE STRICT
|
|
SUPPORT __API_CATALOG_SCHEMA__.dollar_support
|
|
AS 'MODULE_PATHNAME', $function$bson_dollar_fullscan$function$; |