@@ -138,25 +138,30 @@ bool parse_pool_nodeids(const char* opt_str,
138
138
/* Get the port number for processinfo.
139
139
NDB is being initialized before server networking, so mysqld_port
140
140
may not yet have been set, and we are forced to duplicate some
141
- code from mysqld.cc here to calculate the port number.
141
+ code from set_ports() in mysqld.cc here to calculate the port number.
142
142
*/
143
143
static int
144
144
get_processinfo_port ()
145
145
{
146
- int port = mysqld_port;
147
- if (port == 0 )
146
+ int port = 0 ;
147
+
148
+ if (! opt_disable_networking)
148
149
{
149
- const char * env = getenv ( " MYSQL_TCP_PORT " ) ;
150
- if (MYSQL_PORT_DEFAULT == 0 )
150
+ port = mysqld_port ;
151
+ if (port == 0 )
151
152
{
152
- struct servent *serv_ptr = getservbyname (" mysql" , " tcp" );
153
- if (serv_ptr)
154
- port = ntohs ((u_short) serv_ptr->s_port ); /* purecov: inspected */
153
+ const char * env = getenv (" MYSQL_TCP_PORT" );
154
+ if (MYSQL_PORT_DEFAULT == 0 )
155
+ {
156
+ struct servent *serv_ptr = getservbyname (" mysql" , " tcp" );
157
+ if (serv_ptr)
158
+ port = ntohs ((u_short) serv_ptr->s_port ); /* purecov: inspected */
159
+ }
160
+ else if (env)
161
+ port = atoi (env);
162
+ else
163
+ port = MYSQL_PORT;
155
164
}
156
- else if (env)
157
- port = atoi (env);
158
- else
159
- port = MYSQL_PORT;
160
165
}
161
166
return port;
162
167
}
@@ -174,6 +179,30 @@ get_processinfo_host()
174
179
return host;
175
180
}
176
181
182
+ /* Like get_processinfo_port(), this code must be duplicated from
183
+ set_ports() in mysqld.cc.
184
+ */
185
+ #ifdef _WIN32
186
+ #define URI_PATH_SOCKET MYSQL_NAMEDPIPE;
187
+ #else
188
+ #define URI_PATH_SOCKET MYSQL_UNIX_ADDR;
189
+ #endif
190
+
191
+ static const char *
192
+ get_processinfo_path ()
193
+ {
194
+ const char * uri_path = mysqld_unix_port;
195
+ char * env;
196
+ if (!uri_path)
197
+ {
198
+ if ((env = getenv (" MYSQL_UNIX_PORT" )))
199
+ uri_path= env; /* purecov: inspected */
200
+ else
201
+ uri_path= (char *) URI_PATH_SOCKET;
202
+ }
203
+ return uri_path;
204
+ }
205
+
177
206
/*
178
207
Global flag in ndbapi to specify if api should wait to connect
179
208
until dict cache is clean.
@@ -199,13 +228,22 @@ ndbcluster_connect(int (*connect_callback)(void),
199
228
#else
200
229
const char mysqld_name[]= " libmysqld" ;
201
230
#endif
202
- const int processinfo_port = get_processinfo_port ();
203
- const char * processinfo_host = get_processinfo_host ();
204
231
int res;
205
232
DBUG_ENTER (" ndbcluster_connect" );
206
233
DBUG_PRINT (" enter" , (" connect_string: %s, force_nodeid: %d" ,
207
234
connect_string, force_nodeid));
208
235
236
+ /* For Service URI in ndbinfo */
237
+ const int processinfo_port = get_processinfo_port ();
238
+ const char * processinfo_host = get_processinfo_host ();
239
+ const char * processinfo_path = processinfo_port ? " " : get_processinfo_path ();
240
+ char server_id_string[64 ];
241
+ if (server_id > 0 )
242
+ my_snprintf (server_id_string, sizeof (server_id_string), " ?server-id=%lu" ,
243
+ server_id);
244
+ else
245
+ server_id_string[0 ] = ' \0 ' ;
246
+
209
247
// Parse the --ndb-cluster-connection-pool-nodeids=nodeid[,nodeidN]
210
248
// comma separated list of nodeids to use for the pool
211
249
Vector<uint> nodeids;
@@ -241,9 +279,10 @@ ndbcluster_connect(int (*connect_callback)(void),
241
279
my_snprintf (buf, sizeof (buf), " %s --server-id=%lu" ,
242
280
mysqld_name, server_id);
243
281
g_ndb_cluster_connection->set_name (buf);
244
- g_ndb_cluster_connection->set_application_address (processinfo_host, processinfo_port);
282
+ my_snprintf (buf, sizeof (buf), " %s%s" , processinfo_path, server_id_string);
283
+ g_ndb_cluster_connection->set_service_uri (" mysql" , processinfo_host,
284
+ processinfo_port, buf);
245
285
}
246
-
247
286
g_ndb_cluster_connection->set_optimized_node_selection (optimized_node_select);
248
287
g_ndb_cluster_connection->set_recv_thread_activation_threshold (
249
288
recv_thread_activation_threshold);
@@ -315,7 +354,10 @@ ndbcluster_connect(int (*connect_callback)(void),
315
354
my_snprintf (buf, sizeof (buf), " %s --server-id=%lu (connection %u)" ,
316
355
mysqld_name, server_id, i+1 );
317
356
g_pool[i]->set_name (buf);
318
- g_pool[i]->set_application_address (processinfo_host, processinfo_port);
357
+ const char * uri_sep = server_id ? " ;" : " ?" ;
358
+ my_snprintf (buf, sizeof (buf), " %s%s%sconnection=%u" ,
359
+ processinfo_path, server_id_string, uri_sep, i+1 );
360
+ g_pool[i]->set_service_uri (" mysql" , processinfo_host, processinfo_port, buf);
319
361
}
320
362
g_pool[i]->set_optimized_node_selection (optimized_node_select);
321
363
g_pool[i]->set_recv_thread_activation_threshold (recv_thread_activation_threshold);
0 commit comments