From: | Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Regina Obe <lr(at)pcorp(dot)us> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: substring odd behavior |
Date: | 2022-01-28 03:11:25 |
Message-ID: | 96AAD5E0-F055-42FB-8494-DC9E4F0A7708@enterprisedb.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On Jan 27, 2022, at 7:06 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> In short: you can call substring() with the SQL syntax, which is a
> special-purpose production that does not involve any schema name,
> or you can call it as an ordinary function with ordinary function
> notation. You can't mix pieces of those notations.
Beware that your choice of grammar interacts with search_path considerations. If you use what looks like a regular function call, the search_path will be consulted, but if you use the "from" based syntax, the one from pg_catalog will be used:
SET search_path = substr_test, pg_catalog;
SELECT substring('first', 'second');
substring
----------------------------
substr_test: first, second
(1 row)
SELECT substring('first' FROM 'second');
substring
-----------
(1 row)
SET search_path = pg_catalog, substr_test;
SELECT substring('first', 'second');
substring
-----------
(1 row)
SELECT substring('first' FROM 'second');
substring
-----------
(1 row)
SELECT substr_test.substring('first', 'second');
substring
----------------------------
substr_test: first, second
(1 row)
SELECT substr_test.substring('first' FROM 'second');
ERROR: syntax error at or near "FROM"
LINE 1: SELECT substr_test.substring('first' FROM 'second');
—
Mark Dilger
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
From | Date | Subject | |
---|---|---|---|
Next Message | Julien Rouhaud | 2022-01-28 03:12:03 | Re: substring odd behavior |
Previous Message | Tom Lane | 2022-01-28 03:06:28 | Re: substring odd behavior |