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

userfile: IMPORT doesn't correctly build a default 'host' for users with special characters in the username #99971

Open
smcvey opened this issue Mar 29, 2023 · 2 comments
Labels
A-disaster-recovery A-import Issues related to IMPORT syntax C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team

Comments

@smcvey
Copy link
Contributor

smcvey commented Mar 29, 2023

Describe the problem

Create a user with a . in the username (or any other special character).

CREATE USER "my.user" WITH PASSWORD 'p';

Use this user to upload a small csv file for future import:

cockroach userfile upload data.csv data.csv -u my.user

Note that this creates the userfiles table with names in a hex format (encode('my.user', 'hex')):

  public      | userfilesx_6d792e75736572_upload_files   | table | my.user     |                   0 | NULL
  public      | userfilesx_6d792e75736572_upload_payload | table | my.user     |                   0 | NULL

Now create a table and try to import that file:

my.user@localhost:26257/defaultdb> create table t(id uuid primary key);
CREATE TABLE

Time: 17ms total (execution 17ms / network 0ms)

my.user@localhost:26257/defaultdb> import into t (id) csv data ('userfile:///data.csv');
ERROR: failed to create file table to store uploaded file names: create-file-table: at or near "_upload_files": syntax error
SQLSTATE: 42601
DETAIL: source SQL:
CREATE TABLE defaultdb.public."userfiles_my.user"_upload_files (filename STRING PRIMARY KEY,
                                                 ^
HINT: try \h CREATE TABLE

It looks like it's attempting to deal with a table called "userfiles_my.user"_upload_files instead of the hex-encoded version.

Running this as a user without a special character in the name works fine.

Jira issue: CRDB-26160

@smcvey smcvey added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Mar 29, 2023
@smcvey smcvey changed the title Sessions: IMPORT doesn't correctly build a default 'host' for users with special characters in the username IMPORT doesn't correctly build a default 'host' for users with special characters in the username Mar 29, 2023
@ZhouXing19 ZhouXing19 added the A-import Issues related to IMPORT syntax label Mar 29, 2023
@blathers-crl
Copy link

blathers-crl bot commented Mar 29, 2023

cc @cockroachdb/disaster-recovery

@chengxiong-ruan
Copy link
Contributor

chengxiong-ruan commented Mar 29, 2023

We need to handle the table name construction better here. We made composedTableName by adding the userfiles_ prefix to the username, then composedTableName.SQLIdentifier() returns a double quoted version of the string because there is a dot. We may do something similar to this function where the user name is hexed if it contains fun characters.

@shermanCRL shermanCRL changed the title IMPORT doesn't correctly build a default 'host' for users with special characters in the username userfile: IMPORT doesn't correctly build a default 'host' for users with special characters in the username Mar 29, 2023
@smcvey smcvey added the O-support Would prevent or help troubleshoot a customer escalation - bugs, missing observability/tooling, docs label May 16, 2024
@exalate-issue-sync exalate-issue-sync bot added T-sql-queries SQL Queries Team and removed T-disaster-recovery labels May 30, 2024
@rytaft rytaft added the P-3 Issues/test failures with no fix SLA label May 31, 2024
@mgartner mgartner removed O-support Would prevent or help troubleshoot a customer escalation - bugs, missing observability/tooling, docs P-3 Issues/test failures with no fix SLA labels Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-disaster-recovery A-import Issues related to IMPORT syntax C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team
Projects
Status: Backlog
Development

No branches or pull requests

7 participants