go to bug id or search bugs for
When querying for data about a PostgreSQL table, pg_meta_data() does not respect PostgreSQL's search_path setting. When the specified table is not explicitly qualified with a schema, the public schema is always assumed. This is hard-coded in the pgsql extension.
pg_meta_data($link, 'test'); // always looks for "public.test"
When a table name is not explicitly qualified with a schema name, the server search_path setting should be used to determine the correct table.
When a table name is not explicitly qualified with a schema name, the public schema is always assumed.
Add a Patch
Add a Pull Request
Currently, the function appears to parse the supplied table name for an explicit schema qualifier; "public" is assumed if one is not found. A query is constructed where c.relname and n.nspname match the supplied/assumed table and schema respectively. As I mentioned, this ignores PostgreSQL's search_path.
I suggest querying for the user-supplied table name casted to a PG regclass object instead. This improves performance because the table string won't need to be parsed and PostgreSQL will determine the correct object based on its search_path. This is supported in at least PG 7.3+ from 2002 (and likely older).