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

cockroach dump INSERTs do not include collate clauses #48278

Closed
dpkirchner opened this issue May 1, 2020 · 7 comments · Fixed by #48687
Closed

cockroach dump INSERTs do not include collate clauses #48278

dpkirchner opened this issue May 1, 2020 · 7 comments · Fixed by #48687
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. docs-done docs-known-limitation O-community Originated from the community

Comments

@dpkirchner
Copy link

dpkirchner commented May 1, 2020

Describe the problem

If you are using tables with columns that use collation, the SQL generated by cockroach dump won't insert without massaging the queries.

To Reproduce

  1. Install CockroachDB v20.1.0-rc2 -- single node is fine (also, I haven't tested earlier versions)
  2. Create a database and table[1] with a column that uses collation, then insert some data
  3. cockroachdb dump --insecure db > sql [2]
  4. Drop the database and recreate it
  5. cat sql | cockroachdb sql --insecure -d db, see error [3]

Expected behavior
I expected the dump sql to include the necessary collate en_u_ks_level2 clause. I think, anyway -- is there a better way?

Additional data / screenshots

[1]

create database demo;
use demo;
create table demo (greeting varchar(30) collate en_u_ks_level2);
insert into demo (greeting) values ('hello, world' collate en_u_ks_level2);

[2]

cat sql
CREATE TABLE demo (
	demo VARCHAR(30) COLLATE en_u_ks_level2 NULL,
	FAMILY "primary" (greeting, rowid)
);

INSERT INTO demo (greeting) VALUES
	('hello, world');

[3]

CREATE TABLE
Time: 11.7267ms
ERROR: value type string doesn't match type collatedvarchar{en_u_ks_level2} of column "greeting"
SQLSTATE: 42804
ERROR: value type string doesn't match type collatedvarchar{en_u_ks_level2} of column "greeting"
SQLSTATE: 42804
Failed running "sql"

Environment:

  • CockroachDB version v20.1.0-rc2
  • Server OS: Debianish 9 (using the official docker image)
@blathers-crl
Copy link

blathers-crl bot commented May 1, 2020

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I have CC'd a few people who may be able to assist you:

  • @florence-crl (member of the technical support engineering team)

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community X-blathers-oncall labels May 1, 2020
@knz
Copy link
Contributor

knz commented May 1, 2020

Thanks for the report.

cc #28948

@knz
Copy link
Contributor

knz commented May 1, 2020

We'll investigate.

@knz
Copy link
Contributor

knz commented May 1, 2020

cc @dt for triage

@dt
Copy link
Member

dt commented May 5, 2020

@rohany should FmtParsable be printing datums with the coalition clause ?

@rohany
Copy link
Contributor

rohany commented May 5, 2020

It should, and the corresponding format function on DCollatedString looks like it does include the collate clause when formatting.

@jseldess
Copy link
Contributor

Documented in cockroachdb/docs#7311.

craig bot pushed a commit that referenced this issue May 13, 2020
48687: cli: fix `cockroach dump` with collated strings r=dt a=rohany

Fixes #48278.

Release note (bug fix): Fix a bug where `cockroach dump` on a table
with collated strings would omit the collation clause for the data
insertion statements.

Co-authored-by: Rohan Yadav <rohany@alumni.cmu.edu>
@craig craig bot closed this as completed in 4b36317 May 13, 2020
rohany added a commit to rohany/cockroach that referenced this issue May 13, 2020
Fixes cockroachdb#48278.

Release note (bug fix): Fix a bug where `cockroach dump` on a table
with collated strings would omit the collation clause for the data
insertion statements.
rohany added a commit to rohany/cockroach that referenced this issue May 14, 2020
Fixes cockroachdb#48278.

Release note (bug fix): Fix a bug where `cockroach dump` on a table
with collated strings would omit the collation clause for the data
insertion statements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. docs-done docs-known-limitation O-community Originated from the community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants