Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: support casting arrays to string #24746

Closed
awoods187 opened this issue Apr 12, 2018 · 1 comment · Fixed by #28183
Closed

sql: support casting arrays to string #24746

awoods187 opened this issue Apr 12, 2018 · 1 comment · Fixed by #28183
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-semantics C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@awoods187
Copy link
Contributor

No error pops up in Navicat when selecting roles.

SELECT fdwname AS name, fdwacl AS acl FROM pg_foreign_data_wrapper WHERE fdwacl::VARCHAR LIKE '%admin%'

I180409 23:48:05.179837 8072 sql/conn_executor.go:1805 [n1,client=[::1]:59064,user=root] execution error: invalid cast: string[] -> VARCHAR

@awoods187 awoods187 added the A-sql-pgcompat Semantic compatibility with PostgreSQL label Apr 12, 2018
@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-semantics labels Apr 27, 2018
@knz knz changed the title Support cast string array to string sql: support casting arrays to string May 5, 2018
@knz
Copy link
Contributor

knz commented May 5, 2018

For reference in pg:

>  select array[1,2,3]::varchar;
  array
---------
 {1,2,3}

craig bot pushed a commit that referenced this issue Aug 3, 2018
28183: sql: support casting arrays and tuples to strings r=knz a=knz

Fixes #24746.
Forked off #28143.

The previous patch to fix pgwire text encoding for tuples/arrays
really defines a different conversion algorithm from array/tuples to
strings.

This incidentally is the general-purpose algorithm used in PostgreSQL
to convert arrays and tuples to strings, not just for pgwire.

This patch utilizes this observation to define the new
(and now correct) casts from array and tuple types to strings
based on the new algorithm, like PostgreSQL does.

Release note (sql change): CockroachDB now supports converting arrays
and tuples to strings for compatibility with PostgreSQL.

Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
@craig craig bot closed this as completed in #28183 Aug 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-semantics C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants