citusdata / citusdata/citus

Nested function call does not work in function-based index when using a custom search_path

Open
#7,045 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

This bug is close, but not similar, to issue #5350

```
CREATE SCHEMA nestfunc;
SET search_path TO nestfunc;
CREATE FUNCTION f(n int) RETURNS int LANGUAGE SQL IMMUTABLE AS 'SELECT n';
CREATE FUNCTION f_implicit(n int) RETURNS int LANGUAGE SQL IMMUTABLE AS 'SELECT f(n)';
CREATE FUNCTION f_explicit(n int) RETURNS int LANGUAGE SQL IMMUTABLE AS 'SELECT nestfunc.f(n)';
CREATE TABLE t(i int PRIMARY KEY, j int);
SELECT create_distributed_table('t', 'i');
CREATE INDEX i_explicit ON t (f_explicit(j));
CREATE INDEX i_implicit ON t (f_implicit(j));
```

The last `CREATE INDEX` fails with:
```
ERROR: function f(integer) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
CONTEXT: SQL function "f_implicit" during inlining
while executing command on citus-worker-1:5432
```

Versions checked: 11.2 & 11.3

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.