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

function-and-operators: enrich instructions for string functions BIT_LENGTH() and CHAR() #15482 #16087

Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f4972cf
functions-and-operators: enrich instructions for string functions CHA…
PitifulPete Jan 9, 2024
ac47fca
functions-and-operators: fix table rendering error
PitifulPete Jan 9, 2024
372b54d
Apply suggestions from code review
PitifulPete Jan 10, 2024
031d59d
functions-and-operators: enrich instructions for BIT_LENGTH and CHAR()
PitifulPete Jan 10, 2024
a9cb5d1
functions-and-operators: enrich instructions for string functions CHA…
PitifulPete Jan 9, 2024
83b3f6b
functions-and-operators: fix table rendering error
PitifulPete Jan 9, 2024
f2ad58b
Apply suggestions from code review
PitifulPete Jan 10, 2024
0c232f2
functions-and-operators: enrich instructions for BIT_LENGTH and CHAR()
PitifulPete Jan 10, 2024
4500edc
functions-and-operators: correct errors in descriptions of both funct…
PitifulPete Jan 11, 2024
7b23e52
functions-and-operators: correct errors in descriptions of both funct…
PitifulPete Jan 11, 2024
600dccf
Apply suggestions from code review
PitifulPete Jan 11, 2024
4b015b0
functions-and-operators: correct one example in BIT_LENGTH and two ex…
PitifulPete Jan 11, 2024
8280c1d
functions-and-operators: fix errors in BIT_LENGTH() examples
PitifulPete Jan 12, 2024
86b275a
functions-and-operators: fix wordings in BIT_LENGTH()
PitifulPete Jan 12, 2024
d8a19a6
Merge remote-tracking branch 'upstream/master' into pr/16087
qiancai Jan 12, 2024
e197638
functions-and-operators: enrich instructions for BIT_LENGTH() and CHAR()
PitifulPete Jan 11, 2024
37bdafe
develop: make format and wording consistent (#16154)
lilin90 Jan 16, 2024
674fe77
add ticdc aws glue schema registry config docs (#16088)
llkdd1 Jan 16, 2024
7a01833
restore: add faq for rule not found (#16091)
RobertCheng-956 Jan 16, 2024
4c2fa0c
tiup: add instructions for the --local option (#16097)
enkilee Jan 16, 2024
b7caa9d
tidb: fix config value for tiproxy (#15635)
xhebox Jan 16, 2024
3e8dea2
Update config.yaml for Docs Dash (#16181)
rpaik Jan 18, 2024
b73e77a
tidb-lightning: tidb.pd-addr supports multiple addresses (#16145)
hfxsd Jan 18, 2024
c420b5a
Update bdr mode && add description related bdr sql (#15925)
hfxsd Jan 18, 2024
528e428
system-variable: add `tidb_analyze_distsql_scan_concurrency` (#15883)
hawkingrei Jan 18, 2024
80da287
translate changes in #15883 from docs-cn (#16047)
enkilee Jan 18, 2024
07c6b30
ticdc: add explanation for csv delimiter config (#15877)
lidezhu Jan 19, 2024
2706a58
*: add a new system variable `tidb_enable_global_index` (#15675)
hfxsd Jan 19, 2024
14b6d03
resource_control: enhance observability (#15934)
hfxsd Jan 19, 2024
5664815
Typo fix for show status (#16180)
dveeden Jan 19, 2024
65a4e32
resource_control: add more info about sql ru consumption (#16039)
hfxsd Jan 19, 2024
c53a938
DM: support for MySQL 8.0 GA (#15959)
hfxsd Jan 19, 2024
5409281
ddl: add description of ddl v2 (#16073)
GMHDBJD Jan 19, 2024
9874fde
fix 2 issues (#16183)
hfxsd Jan 19, 2024
c5aeead
system-variables: set default tidb_auto_analyze_partition_batch_size …
hawkingrei Jan 19, 2024
ffcb52d
txn: add deprecation description of system variable tidb_disable_txn_…
qiancai Jan 19, 2024
2669a4d
Add two json function which supports push down to tiflash now (#15904)
qiancai Jan 19, 2024
24c46aa
data migration: add an example Parquet file name (#16192)
hfxsd Jan 19, 2024
03b5d0d
functions-and-operators: remove href link from BIT_LENGTH()
PitifulPete Jan 19, 2024
8ae7c48
Merge remote-tracking branch 'upstream/master' into pr/16087
qiancai Jan 23, 2024
4af489b
Merge branch 'enrich/instructions-bitlength-char' of https://github.c…
qiancai Jan 24, 2024
2e13ed4
Update functions-and-operators/string-functions.md
PitifulPete Jan 24, 2024
9e97810
refine the output formats
qiancai Jan 29, 2024
32dc80e
revert changes of CHAR()` and `CHAR_LENGTH()` as they are covered in …
qiancai Jan 29, 2024
d5e14f0
revert changes
qiancai Jan 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 95 additions & 2 deletions functions-and-operators/string-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,104 @@ Return a string containing binary representation of a number.

### [`BIT_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_bit-length)

Return length of argument in bits.
The `BIT_LENGTH()` function is used to return the length of a given argument in bits.

Examples:

```sql
SELECT BIT_LENGTH("TiDB");

+--------------------+
| BIT_LENGTH("TiDB") |
+--------------------+
| 32 |
+--------------------+
```

8 bits per character x 4 characters = 32 bits

```sql
SELECT BIT_LENGTH("PingCAP 123");

+---------------------------+
| BIT_LENGTH("PingCAP 123") |
+---------------------------+
| 88 |
+---------------------------+
```

8 bits per character (space is counted because it is a non-alphanumeric character) x 11 characters = 88 bits

```sql
SELECT CustomerName, BIT_LENGTH(CustomerName) AS BitLengthOfName FROM Customers;

+--------------------+-----------------+
| CustomerName | BitLengthOfName |
+--------------------+-----------------+
| Albert Einstein | 120 |
| Robert Oppenheimer | 144 |
+--------------------+-----------------+
```

> **Note:**
>
> The preceding example operates under the assumption that there is a database with a table named `Customers` and a column inside the table named `CustomerName`.

### [`CHAR()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char)

Return the character for each integer passed.
The `CHAR()` function is used to get the corresponding character of a specific ASCII value. It performs the opposite operation of `ASCII()`, which returns the ASCII value of a specific character.

Examples:

```sql
SELECT CHAR(65);

+------------+
| CHAR(65) |
+------------+
| A |
+------------+
```

```sql
SELECT CHAR(84);

+------------+
| CHAR(84) |
+------------+
| T |
+------------+
```

The `CHAR()` function can also be used to get the corresponding character of ASCII values that extend beyond the standard ASCII range (`0` - `127`).

```sql
/*For extended ASCII: */

SELECT CHAR(128);

+------------+
| CHAR(128) |
+------------+
| 0x80 |
+------------+
```

The `CHAR()` function can also get the corresponding character value of a unicode value.

```sql
/* For Unicode: */

--skip-binary-as-hex

SELECT CHAR(50089);

+--------------+
| CHAR(50089) |
+--------------+
| é |
+--------------+
```

### [`CHAR_LENGTH()`](https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_char-length)

Expand Down
Loading