You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "Jibing-Li (via GitHub)" <gi...@apache.org> on 2024/09/18 10:11:19 UTC

[PR] Support COM_CHANGE_USER and other mysql command. [doris]

Jibing-Li opened a new pull request, #40932:
URL: https://github.com/apache/doris/pull/40932

   Support COM_CHANGE_USER and other mysql command.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](mysql)Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #40932:
URL: https://github.com/apache/doris/pull/40932#issuecomment-2372763971

   PR approved by anyone and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](mysql)Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on code in PR #40932:
URL: https://github.com/apache/doris/pull/40932#discussion_r1766288814


##########
fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java:
##########
@@ -249,6 +271,110 @@ private void handleFieldList() throws ConnectionException {
         handleFieldList(tableName);
     }
 
+    private void handleChangeUser() throws IOException {
+        // Random bytes generated when creating connection.
+        byte[] authPluginData = getConnectContext().getAuthPluginData();
+        String userName = new String(MysqlProto.readNulTerminateString(packetBuf));
+        int passwordLen = MysqlProto.readInt1(packetBuf);
+        byte[] password = MysqlProto.readFixedString(packetBuf, passwordLen);
+        String db = new String(MysqlProto.readNulTerminateString(packetBuf));
+        // Read the character set.
+        MysqlProto.readInt2(packetBuf);
+        String authPluginName = new String(MysqlProto.readNulTerminateString(packetBuf));
+
+        // Send Protocol::AuthSwitchRequest to client if auth plugin name is not mysql_native_password
+        if (!MysqlHandshakePacket.AUTH_PLUGIN_NAME.equals(authPluginName)) {
+            MysqlChannel channel = ctx.mysqlChannel;
+            MysqlSerializer serializer = MysqlSerializer.newInstance();
+            serializer.writeInt1((byte) 0xfe);
+            serializer.writeNulTerminateString(MysqlHandshakePacket.AUTH_PLUGIN_NAME);
+            serializer.writeBytes(authPluginData);
+            serializer.writeInt1(0);
+            channel.sendAndFlush(serializer.toByteBuffer());
+            // Server receive auth switch response packet from client.
+            ByteBuffer authSwitchResponse = channel.fetchOnePacket();
+            int length = authSwitchResponse.limit();
+            password = new byte[length];
+            System.arraycopy(authSwitchResponse.array(), 0, password, 0, length);
+        }
+
+        // For safety, not allowed to change to root or admin.
+        if (Auth.ROOT_USER.equals(userName) || Auth.ADMIN_USER.equals(userName)) {
+            ctx.getState().setError(ErrorCode.ERR_ACCESS_DENIED_ERROR, "Change to root or admin is forbidden");
+            return;
+        }
+
+        // Check password.
+        List<UserIdentity> currentUserIdentity = Lists.newArrayList();
+        try {
+            Env.getCurrentEnv().getAuth()
+                .checkPassword(userName, ctx.remoteIP, password, authPluginData, currentUserIdentity);
+        } catch (AuthenticationException e) {
+            ctx.getState().setError(ErrorCode.ERR_ACCESS_DENIED_ERROR, "Authentication failed.");
+            return;
+        }
+        ctx.setCurrentUserIdentity(currentUserIdentity.get(0));
+        ctx.setQualifiedUser(userName);
+
+        // Change default db if set.
+        if (Strings.isNullOrEmpty(db)) {
+            ctx.changeDefaultCatalog(InternalCatalog.INTERNAL_CATALOG_NAME);
+        } else {
+            String catalogName = null;
+            String dbName = null;
+            String[] dbNames = db.split("\\.");

Review Comment:
   could `db` like
   ```
   `123.456`.`789.012`
   ```
   ? 
   do we need parse it with `NereidsParser.visitMultipartIdentifier`?



##########
fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java:
##########
@@ -249,6 +271,110 @@ private void handleFieldList() throws ConnectionException {
         handleFieldList(tableName);
     }
 
+    private void handleChangeUser() throws IOException {
+        // Random bytes generated when creating connection.
+        byte[] authPluginData = getConnectContext().getAuthPluginData();
+        String userName = new String(MysqlProto.readNulTerminateString(packetBuf));
+        int passwordLen = MysqlProto.readInt1(packetBuf);
+        byte[] password = MysqlProto.readFixedString(packetBuf, passwordLen);
+        String db = new String(MysqlProto.readNulTerminateString(packetBuf));
+        // Read the character set.
+        MysqlProto.readInt2(packetBuf);
+        String authPluginName = new String(MysqlProto.readNulTerminateString(packetBuf));
+
+        // Send Protocol::AuthSwitchRequest to client if auth plugin name is not mysql_native_password
+        if (!MysqlHandshakePacket.AUTH_PLUGIN_NAME.equals(authPluginName)) {
+            MysqlChannel channel = ctx.mysqlChannel;
+            MysqlSerializer serializer = MysqlSerializer.newInstance();
+            serializer.writeInt1((byte) 0xfe);
+            serializer.writeNulTerminateString(MysqlHandshakePacket.AUTH_PLUGIN_NAME);
+            serializer.writeBytes(authPluginData);

Review Comment:
   authPluginData could be null, should we handle it before write?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](mysql)Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on PR #40932:
URL: https://github.com/apache/doris/pull/40932#issuecomment-2367146493

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #40932:
URL: https://github.com/apache/doris/pull/40932#issuecomment-2358060398

   Thank you for your contribution to Apache Doris.
   Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/How+to+process+your+PR)
   
   Since 2024-03-18, the Document has been moved to [doris-website](https://github.com/apache/doris-website).
   See [Doris Document](https://cwiki.apache.org/confluence/display/DORIS/Doris+Document).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #40932:
URL: https://github.com/apache/doris/pull/40932#issuecomment-2358169823

   
   <details>
   <summary>ClickBench: <b>Total hot run time: 32.89 s</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
   ClickBench test result on commit 6242cf822bc1fbaa7f3457d3aea36e65d757a528, data reload: false
   
   query1	0.04	0.05	0.04
   query2	0.06	0.02	0.03
   query3	0.23	0.07	0.06
   query4	1.65	0.10	0.10
   query5	0.52	0.50	0.52
   query6	1.13	0.72	0.73
   query7	0.02	0.01	0.01
   query8	0.03	0.03	0.04
   query9	0.58	0.51	0.50
   query10	0.58	0.57	0.54
   query11	0.15	0.11	0.10
   query12	0.13	0.11	0.11
   query13	0.60	0.60	0.59
   query14	2.99	3.03	2.94
   query15	0.88	0.82	0.82
   query16	0.40	0.39	0.39
   query17	1.07	0.98	1.05
   query18	0.21	0.20	0.19
   query19	1.92	1.88	1.98
   query20	0.01	0.01	0.01
   query21	15.36	0.59	0.61
   query22	2.73	2.11	2.03
   query23	17.27	0.90	0.78
   query24	2.82	1.28	0.94
   query25	0.22	0.29	0.05
   query26	0.41	0.14	0.13
   query27	0.03	0.04	0.03
   query28	10.59	1.09	1.06
   query29	12.55	3.26	3.30
   query30	0.24	0.06	0.06
   query31	2.89	0.38	0.39
   query32	3.27	0.46	0.46
   query33	3.00	3.07	3.03
   query34	17.08	4.40	4.42
   query35	4.42	4.39	4.40
   query36	0.68	0.49	0.50
   query37	0.09	0.06	0.05
   query38	0.04	0.03	0.04
   query39	0.03	0.02	0.02
   query40	0.16	0.12	0.12
   query41	0.07	0.02	0.02
   query42	0.03	0.02	0.01
   query43	0.03	0.03	0.03
   Total cold run time: 107.21 s
   Total hot run time: 32.89 s
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](mysql)Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "Jibing-Li (via GitHub)" <gi...@apache.org>.
Jibing-Li commented on PR #40932:
URL: https://github.com/apache/doris/pull/40932#issuecomment-2358551196

   run cloud_p0


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #40932:
URL: https://github.com/apache/doris/pull/40932#issuecomment-2358159389

   
   <details>
   <summary>TPC-DS: <b>Total hot run time: 198444 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
   TPC-DS sf100 test result on commit 6242cf822bc1fbaa7f3457d3aea36e65d757a528, data reload: false
   
   query1	1310	861	916	861
   query2	6398	2086	2006	2006
   query3	10795	3906	3709	3709
   query4	63528	29396	23526	23526
   query5	5035	483	454	454
   query6	412	157	161	157
   query7	5448	286	289	286
   query8	305	227	225	225
   query9	8437	2640	2630	2630
   query10	428	276	273	273
   query11	17334	15293	15730	15293
   query12	160	111	113	111
   query13	1485	412	423	412
   query14	10795	7037	7430	7037
   query15	199	176	171	171
   query16	6897	469	478	469
   query17	1237	600	587	587
   query18	1580	309	306	306
   query19	207	156	158	156
   query20	128	110	111	110
   query21	214	111	105	105
   query22	4722	4657	4664	4657
   query23	34732	33909	34567	33909
   query24	6048	2865	2865	2865
   query25	514	412	413	412
   query26	651	154	160	154
   query27	1653	282	280	280
   query28	4139	2449	2458	2449
   query29	669	415	427	415
   query30	229	158	162	158
   query31	949	772	796	772
   query32	69	52	55	52
   query33	403	302	291	291
   query34	890	484	478	478
   query35	837	731	734	731
   query36	1083	948	906	906
   query37	145	85	79	79
   query38	4132	3957	3972	3957
   query39	1453	1417	1394	1394
   query40	204	97	96	96
   query41	47	49	48	48
   query42	124	94	99	94
   query43	526	484	477	477
   query44	1140	804	794	794
   query45	198	162	164	162
   query46	1112	738	761	738
   query47	1955	1844	1860	1844
   query48	458	358	355	355
   query49	699	405	410	405
   query50	823	402	398	398
   query51	7142	7030	6818	6818
   query52	100	84	84	84
   query53	254	176	178	176
   query54	561	454	449	449
   query55	75	79	81	79
   query56	275	231	277	231
   query57	1219	1069	1129	1069
   query58	223	232	233	232
   query59	3255	3171	3108	3108
   query60	281	261	267	261
   query61	101	118	97	97
   query62	754	652	665	652
   query63	208	180	178	178
   query64	1307	650	636	636
   query65	3243	3154	3174	3154
   query66	606	301	304	301
   query67	16238	15649	15383	15383
   query68	1296	545	543	543
   query69	448	275	289	275
   query70	1164	1111	1132	1111
   query71	330	269	263	263
   query72	6325	4121	3982	3982
   query73	759	324	320	320
   query74	9223	9052	8909	8909
   query75	3313	2665	2646	2646
   query76	1614	854	900	854
   query77	486	302	272	272
   query78	10168	9397	9645	9397
   query79	1228	886	859	859
   query80	750	556	605	556
   query81	507	254	253	253
   query82	231	230	231	230
   query83	165	159	155	155
   query84	292	99	104	99
   query85	740	402	348	348
   query86	346	297	326	297
   query87	4373	4259	4263	4259
   query88	4493	4046	4027	4027
   query89	377	363	360	360
   query90	1839	311	301	301
   query91	162	163	158	158
   query92	74	72	72	72
   query93	931	885	885	885
   query94	698	360	376	360
   query95	461	393	405	393
   query96	485	485	481	481
   query97	3145	3108	3133	3108
   query98	229	244	230	230
   query99	1488	1279	1354	1279
   Total cold run time: 306918 ms
   Total hot run time: 198444 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](mysql)Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #40932:
URL: https://github.com/apache/doris/pull/40932#issuecomment-2372763909

   PR approved by at least one committer and no changes requested.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "Jibing-Li (via GitHub)" <gi...@apache.org>.
Jibing-Li commented on PR #40932:
URL: https://github.com/apache/doris/pull/40932#issuecomment-2358063889

   run buildall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #40932:
URL: https://github.com/apache/doris/pull/40932#issuecomment-2358136480

   
   <details>
   <summary>TPC-H: <b>Total hot run time: 41503 ms</b></summary>
   
   ```
   machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
   scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
   Tpch sf100 test result on commit 6242cf822bc1fbaa7f3457d3aea36e65d757a528, data reload: false
   
   ------ Round 1 ----------------------------------
   q1	17576	7301	7240	7240
   q2	2053	164	158	158
   q3	10576	1083	1172	1083
   q4	10571	735	740	735
   q5	7762	3094	3072	3072
   q6	240	155	149	149
   q7	1015	624	602	602
   q8	9427	2050	2022	2022
   q9	6821	6399	6443	6399
   q10	7016	2276	2320	2276
   q11	440	240	244	240
   q12	411	215	213	213
   q13	17763	2968	3013	2968
   q14	237	211	211	211
   q15	562	519	534	519
   q16	683	617	631	617
   q17	965	796	829	796
   q18	7207	6699	6738	6699
   q19	1394	975	1074	975
   q20	589	280	280	280
   q21	4106	3240	3247	3240
   q22	1100	1015	1009	1009
   Total cold run time: 108514 ms
   Total hot run time: 41503 ms
   
   ----- Round 2, with runtime_filter_mode=off -----
   q1	7298	7235	7231	7231
   q2	332	225	230	225
   q3	3028	2963	3009	2963
   q4	1998	1831	1849	1831
   q5	5606	5595	5549	5549
   q6	235	141	143	141
   q7	2275	1812	1781	1781
   q8	3306	3460	3430	3430
   q9	8799	8940	8799	8799
   q10	3537	3391	3471	3391
   q11	590	496	487	487
   q12	831	635	595	595
   q13	10722	3235	3100	3100
   q14	301	276	272	272
   q15	587	524	534	524
   q16	719	674	671	671
   q17	1792	1609	1583	1583
   q18	8178	7929	7848	7848
   q19	1744	1420	1548	1420
   q20	2128	1913	1903	1903
   q21	5504	5345	5435	5345
   q22	1154	1057	1057	1057
   Total cold run time: 70664 ms
   Total hot run time: 60146 ms
   ```
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](mysql)Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "Jibing-Li (via GitHub)" <gi...@apache.org>.
Jibing-Li commented on code in PR #40932:
URL: https://github.com/apache/doris/pull/40932#discussion_r1766550316


##########
fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java:
##########
@@ -249,6 +271,110 @@ private void handleFieldList() throws ConnectionException {
         handleFieldList(tableName);
     }
 
+    private void handleChangeUser() throws IOException {
+        // Random bytes generated when creating connection.
+        byte[] authPluginData = getConnectContext().getAuthPluginData();
+        String userName = new String(MysqlProto.readNulTerminateString(packetBuf));
+        int passwordLen = MysqlProto.readInt1(packetBuf);
+        byte[] password = MysqlProto.readFixedString(packetBuf, passwordLen);
+        String db = new String(MysqlProto.readNulTerminateString(packetBuf));
+        // Read the character set.
+        MysqlProto.readInt2(packetBuf);
+        String authPluginName = new String(MysqlProto.readNulTerminateString(packetBuf));
+
+        // Send Protocol::AuthSwitchRequest to client if auth plugin name is not mysql_native_password
+        if (!MysqlHandshakePacket.AUTH_PLUGIN_NAME.equals(authPluginName)) {
+            MysqlChannel channel = ctx.mysqlChannel;
+            MysqlSerializer serializer = MysqlSerializer.newInstance();
+            serializer.writeInt1((byte) 0xfe);
+            serializer.writeNulTerminateString(MysqlHandshakePacket.AUTH_PLUGIN_NAME);
+            serializer.writeBytes(authPluginData);
+            serializer.writeInt1(0);
+            channel.sendAndFlush(serializer.toByteBuffer());
+            // Server receive auth switch response packet from client.
+            ByteBuffer authSwitchResponse = channel.fetchOnePacket();
+            int length = authSwitchResponse.limit();
+            password = new byte[length];
+            System.arraycopy(authSwitchResponse.array(), 0, password, 0, length);
+        }
+
+        // For safety, not allowed to change to root or admin.
+        if (Auth.ROOT_USER.equals(userName) || Auth.ADMIN_USER.equals(userName)) {
+            ctx.getState().setError(ErrorCode.ERR_ACCESS_DENIED_ERROR, "Change to root or admin is forbidden");
+            return;
+        }
+
+        // Check password.
+        List<UserIdentity> currentUserIdentity = Lists.newArrayList();
+        try {
+            Env.getCurrentEnv().getAuth()
+                .checkPassword(userName, ctx.remoteIP, password, authPluginData, currentUserIdentity);
+        } catch (AuthenticationException e) {
+            ctx.getState().setError(ErrorCode.ERR_ACCESS_DENIED_ERROR, "Authentication failed.");
+            return;
+        }
+        ctx.setCurrentUserIdentity(currentUserIdentity.get(0));
+        ctx.setQualifiedUser(userName);
+
+        // Change default db if set.
+        if (Strings.isNullOrEmpty(db)) {
+            ctx.changeDefaultCatalog(InternalCatalog.INTERNAL_CATALOG_NAME);
+        } else {
+            String catalogName = null;
+            String dbName = null;
+            String[] dbNames = db.split("\\.");

Review Comment:
   Tested, seems like `123.456` is not a valid database name. So I don't think we need to use visitMultipartIdentifier here.



##########
fe/fe-core/src/main/java/org/apache/doris/qe/MysqlConnectProcessor.java:
##########
@@ -249,6 +271,110 @@ private void handleFieldList() throws ConnectionException {
         handleFieldList(tableName);
     }
 
+    private void handleChangeUser() throws IOException {
+        // Random bytes generated when creating connection.
+        byte[] authPluginData = getConnectContext().getAuthPluginData();
+        String userName = new String(MysqlProto.readNulTerminateString(packetBuf));
+        int passwordLen = MysqlProto.readInt1(packetBuf);
+        byte[] password = MysqlProto.readFixedString(packetBuf, passwordLen);
+        String db = new String(MysqlProto.readNulTerminateString(packetBuf));
+        // Read the character set.
+        MysqlProto.readInt2(packetBuf);
+        String authPluginName = new String(MysqlProto.readNulTerminateString(packetBuf));
+
+        // Send Protocol::AuthSwitchRequest to client if auth plugin name is not mysql_native_password
+        if (!MysqlHandshakePacket.AUTH_PLUGIN_NAME.equals(authPluginName)) {
+            MysqlChannel channel = ctx.mysqlChannel;
+            MysqlSerializer serializer = MysqlSerializer.newInstance();
+            serializer.writeInt1((byte) 0xfe);
+            serializer.writeNulTerminateString(MysqlHandshakePacket.AUTH_PLUGIN_NAME);
+            serializer.writeBytes(authPluginData);

Review Comment:
   Fixed. Check not null before using it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](mysql)Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "Jibing-Li (via GitHub)" <gi...@apache.org>.
Jibing-Li commented on PR #40932:
URL: https://github.com/apache/doris/pull/40932#issuecomment-2367182129

   run p0


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


Re: [PR] [fix](mysql)Support COM_CHANGE_USER and other mysql command. [doris]

Posted by "Jibing-Li (via GitHub)" <gi...@apache.org>.
Jibing-Li merged PR #40932:
URL: https://github.com/apache/doris/pull/40932


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org