Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Facebook
Downloads
Home
>
mailing lists
Re: Re: BUG #18632: Whether you need to consider modifying the array's handling of delimiters? - Mailing list pgsql-bugs
From
曾满
Subject
Re: Re: BUG #18632: Whether you need to consider modifying the array's handling of delimiters?
Date
September 25, 2024
12:16:51
Msg-id
tencent_7DAA8DBD2F7167F20912BFB6@qq.com
Whole thread
Raw
In response to
BUG #18632: Whether you need to consider modifying the array's handling of delimiters?
(PG Bug reporting form <noreply@postgresql.org>)
Responses
Re: BUG #18632: Whether you need to consider modifying the array's handling of delimiters?
List
pgsql-bugs
Tree view
(Sorry, there was a garbled situation in the last email)
Thank you. I know that the way you said can be handled normally.
postgres=# SELECT ('{''a-3'',''a,3''}'::varchar[]);
varchar
---------------
{'a-3','a,3'}
(1 row)
I wonder if we need to modify array_in so that ''a,3'' and ''a-3'' behave the same and have a uniform style.
Would it be better?
postgres=# SELECT ('{''a-3'',''a,3''}'::varchar[])[1];
varchar
---------
'a-3'
(1 row)
postgres=# SELECT ('{''a-3'',''a,3''}'::varchar[])[2];
varchar
---------
'a
(1 row)
Erik Wienhold
<ewie@ewie.name>
在
2024年9月25日 周三 16:32
写道:
On 2024-09-25 09:57 +0200, PG Bug reporting form wrote:
> The following bug has been logged on the website:
>
> Bug reference: 18632
> Logged by: Man Zeng
> Email address: zengman@halodbtech.com
> PostgreSQL version: 14.10
> Operating system: centos-8
> Description:
>
> Hi, I found a problem with array separator handling.
> The current handling of delimiters is not quite as expected (not very
> flexible).
> The test SQL and results are shown below.
>
> [postgres@halo-centos-8-release ~]$ psql
> psql (14.10)
> Type "help" for help.
>
> postgres=# CREATE OR REPLACE FUNCTION arrayfunc()
> postgres-# RETURNS _varchar
> postgres-# AS $$
> postgres$# SELECT '{''a,3'',''b'',''c''}'::_varchar;
> postgres$# $$ LANGUAGE SQL;
> CREATE FUNCTION
> postgres=# -- array cstring
> postgres=# SELECT arrayfunc();
> arrayfunc
> -----------------
> {'a,3','b','c'}
> (1 row)
>
> postgres=# -- length is 4
> postgres=# SELECT array_length(arrayfunc(), 1);
> array_length
> --------------
> 4
> (1 row)
>
> postgres=# -- first element
> postgres=# SELECT (arrayfunc())[1];
> arrayfunc
> -----------
> 'a
> (1 row)
>
> postgres=# -- second element
> postgres=# SELECT (arrayfunc())[2];
> arrayfunc
> -----------
> 3'
> (1 row)
You need to double-quote elements that contain the separator:
SELECT '{"''a,3''",''b'',''c''}'::varchar[];
That's also documented in the first paragraph of
https://www.postgresql.org/docs/current/arrays.html#ARRAYS-INPUT
So, not a bug.
> postgres=# -- other
> postgres=# SELECT (arrayfunc())[3];
> arrayfunc
> -----------
> 'b'
> (1 row)
>
> postgres=# SELECT (arrayfunc())[4];
> arrayfunc
> -----------
> 'c'
> (1 row)
>
> postgres=# -- The following SQL tests are as expected
> postgres=# CREATE OR REPLACE FUNCTION arrayfunc2()
> postgres-# RETURNS _varchar
> postgres-# AS $$
> postgres$# SELECT '{''a-3'',''b'',''c''}'::_varchar;
> postgres$# $$ LANGUAGE SQL;
> CREATE FUNCTION
> postgres=# -- array cstring
> postgres=# SELECT arrayfunc2();
> arrayfunc2
> -----------------
> {'a-3','b','c'}
> (1 row)
>
> postgres=# -- length is 3
> postgres=# SELECT array_length(arrayfunc2(), 1);
> array_length
> --------------
> 3
> (1 row)
>
> postgres=# -- first element
> postgres=# SELECT (arrayfunc2())[1];
> arrayfunc2
> ------------
> 'a-3'
> (1 row)
>
> So should we consider modifying "array_in" to enhance the handling of
> separators to be more consistent with people's expectations?
>
--
Erik
pgsql-bugs
by date:
Previous
From:
"曾满"
Date:
25 September 2024, 11:54:41
Subject:
回复:Re: BUG #18632: Whether you need to consider modifying the array's handling of delimiters?
Next
From:
Wolfgang Walther
Date:
25 September 2024, 13:13:44
Subject:
Re: BUG #18632: Whether you need to consider modifying the array's handling of delimiters?
Есть вопросы? Напишите нам!
Соглашаюсь с условиями обработки персональных данных
I confirm that I have read and accepted PostgresPro’s
Privacy Policy
.
I agree to get Postgres Pro discount offers and other marketing communications.
✖
×
×
Everywhere
Documentation
Mailing list
List:
all lists
pgsql-general
pgsql-hackers
buildfarm-members
pgadmin-hackers
pgadmin-support
pgsql-admin
pgsql-advocacy
pgsql-announce
pgsql-benchmarks
pgsql-bugs
pgsql-chat
pgsql-cluster-hackers
pgsql-committers
pgsql-cygwin
pgsql-docs
pgsql-hackers-pitr
pgsql-hackers-win32
pgsql-interfaces
pgsql-jdbc
pgsql-jobs
pgsql-novice
pgsql-odbc
pgsql-patches
pgsql-performance
pgsql-php
pgsql-pkg-debian
pgsql-pkg-yum
pgsql-ports
pgsql-rrreviewers
pgsql-ru-general
pgsql-sql
pgsql-students
pgsql-testers
pgsql-translators
pgsql-www
psycopg
Period
anytime
within last day
within last week
within last month
within last 6 months
within last year
Sort by
date
reverse date
rank
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
By continuing to browse this website, you agree to the use of cookies. Go to
Privacy Policy
.
I accept cookies