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

About fixed_string() truncation #2709

Open
Amber1990Zhang opened this issue Nov 4, 2020 · 1 comment
Open

About fixed_string() truncation #2709

Amber1990Zhang opened this issue Nov 4, 2020 · 1 comment
Labels
need to discuss Solution: issue or PR without a clear conclusion on whether to handle it type/enhancement Type: make the code neat or more efficient

Comments

@Amber1990Zhang
Copy link
Contributor

As title.
I created a tag and insert a vertex :

(w@nebula) [nba]> CREATE TAG t5(p1 fixed_string(5) NOT NULL, p2 int, p3 int DEFAULT NULL);
Execution succeeded (time spent 16330/17552 us)

(w@nebula) [nba]> INSERT VERTEX t5(p1, p2) VALUES "004":("shalalalala", 4);
Execution succeeded (time spent 5978/6981 us)

(w@nebula) [nba]> FETCH PROP on t5 "004"
+----------+---------+-------+-------+
| VertexID | t5.p1   | t5.p2 | t5.p3 |
+----------+---------+-------+-------+
| "004"    | "shala" | 4     | NULL  |
+----------+---------+-------+-------+
Got 1 rows (time spent 2790/4418 us)

Actually I’m expecting a warning or an error is returned when I insert a vertex with the property strength greater than the maximum length.

Refer to MySQL, users can disable STRICT_TRANS_TABLES and STRICT_ALL_TABLES. This allows the automatic truncation of the inserted string.

Quote from MySQL Documantation.

Strict mode controls how MySQL handles invalid or missing values in data-change statements such as INSERT or UPDATE. A value can be invalid for several reasons. For example, it might have the wrong data type for the column, or it might be out of range. A value is missing when a new row to be inserted does not contain a value for a non-NULL column that has no explicit DEFAULT clause in its definition. (For a NULL column, NULL is inserted if the value is missing.)

@czpmango
Copy link
Contributor

mysql test:

mysql> create table test_fix_str(a char(3));
Query OK, 0 rows affected (0.12 sec)
mysql> insert into test_fix_str values ("abcdefg");
ERROR 1406 (22001): Data too long for column 'a' at row 1

@CPWstatic CPWstatic transferred this issue from vesoft-inc/nebula-graph Aug 28, 2021
@CPWstatic CPWstatic added the need to discuss Solution: issue or PR without a clear conclusion on whether to handle it label Aug 28, 2021
@Sophie-Xie Sophie-Xie added the type/enhancement Type: make the code neat or more efficient label Aug 30, 2021
yixinglu pushed a commit to yixinglu/nebula that referenced this issue Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need to discuss Solution: issue or PR without a clear conclusion on whether to handle it type/enhancement Type: make the code neat or more efficient
Projects
None yet
Development

No branches or pull requests

4 participants