@@ -42,7 +42,7 @@ static void shardmaster_sigusr1(SIGNAL_ARGS);
42
42
static void pg_shardman_installed_local (void );
43
43
44
44
static void add_node (Cmd * cmd );
45
- static int insert_node (const char * connstring , int64 cmd_id );
45
+ static int insert_node (const char * connstr , int64 cmd_id );
46
46
static bool node_in_cluster (int id );
47
47
48
48
static void rm_node (Cmd * cmd );
@@ -178,6 +178,8 @@ shardmaster_main(Datum main_arg)
178
178
rm_node (cmd );
179
179
else if (strcmp (cmd -> cmd_type , "create_hash_partitions" ) == 0 )
180
180
create_hash_partitions (cmd );
181
+ else if (strcmp (cmd -> cmd_type , "move_mpart" ) == 0 )
182
+ move_mpart (cmd );
181
183
else
182
184
shmn_elog (FATAL , "Unknown cmd type %s" , cmd -> cmd_type );
183
185
}
@@ -211,12 +213,12 @@ void_spi(char *sql)
211
213
PGconn *
212
214
listen_cmd_log_inserts (void )
213
215
{
214
- char * connstring ;
216
+ char * connstr ;
215
217
PGresult * res ;
216
218
217
- connstring = psprintf ("dbname = %s" , shardman_master_dbname );
218
- conn = PQconnectdb (connstring );
219
- pfree (connstring );
219
+ connstr = psprintf ("dbname = %s" , shardman_master_dbname );
220
+ conn = PQconnectdb (connstr );
221
+ pfree (connstr );
220
222
/* Check to see that the backend connection was successfully made */
221
223
if (PQstatus (conn ) != CONNECTION_OK )
222
224
shmn_elog (FATAL , "Connection to local database failed: %s" ,
@@ -442,17 +444,17 @@ void
442
444
add_node (Cmd * cmd )
443
445
{
444
446
PGconn * conn = NULL ;
445
- const char * connstring = cmd -> opts [0 ];
447
+ const char * connstr = cmd -> opts [0 ];
446
448
PGresult * res = NULL ;
447
449
bool pg_shardman_installed ;
448
- int node_id ;
450
+ int32 node_id ;
449
451
char * sql ;
450
452
451
- shmn_elog (INFO , "Adding node %s" , connstring );
453
+ shmn_elog (INFO , "Adding node %s" , connstr );
452
454
/* Try to execute command indefinitely until it succeeded or canceled */
453
455
while (!got_sigusr1 && !got_sigterm )
454
456
{
455
- conn = PQconnectdb (connstring );
457
+ conn = PQconnectdb (connstr );
456
458
if (PQstatus (conn ) != CONNECTION_OK )
457
459
{
458
460
shmn_elog (NOTICE , "Connection to add_node node failed: %s" ,
@@ -488,12 +490,12 @@ add_node(Cmd *cmd)
488
490
{
489
491
/* Node is in cluster. Was it there before we started adding? */
490
492
node_id = atoi (PQgetvalue (res , 0 , 0 ));
491
- elog (INFO , "NODE IN CLUSTER , %d" , node_id );
493
+ elog (DEBUG1 , "node in cluster , %d" , node_id );
492
494
PQclear (res );
493
495
if (node_in_cluster (node_id ))
494
496
{
495
497
shmn_elog (WARNING , "node %d with connstring %s is already"
496
- " in cluster, won't add it." , node_id , connstring );
498
+ " in cluster, won't add it." , node_id , connstr );
497
499
PQfinish (conn );
498
500
update_cmd_status (cmd -> id , "failed" );
499
501
return ;
@@ -507,7 +509,7 @@ add_node(Cmd *cmd)
507
509
* Now add node to 'nodes' table, if we haven't done that yet, and
508
510
* record that we did so for this cmd
509
511
*/
510
- node_id = insert_node (connstring , cmd -> id );
512
+ node_id = insert_node (connstr , cmd -> id );
511
513
512
514
/*
513
515
* reinstall the extension to reset its state, whether is was
@@ -560,7 +562,7 @@ add_node(Cmd *cmd)
560
562
561
563
/* done */
562
564
elog (INFO , "Node %s successfully added, it is assigned id %d" ,
563
- connstring , node_id );
565
+ connstr , node_id );
564
566
return ;
565
567
566
568
attempt_failed : /* clean resources, sleep, check sigusr1 and try again */
@@ -580,12 +582,12 @@ add_node(Cmd *cmd)
580
582
581
583
/* See sql func */
582
584
static int
583
- insert_node (const char * connstring , int64 cmd_id )
585
+ insert_node (const char * connstr , int64 cmd_id )
584
586
{
585
587
char * sql = psprintf ("select shardman.insert_node('%s', %ld)" ,
586
- connstring , cmd_id );
588
+ connstr , cmd_id );
587
589
int e ;
588
- int node_id ;
590
+ int32 node_id ;
589
591
bool isnull ;
590
592
591
593
SPI_PROLOG ;
@@ -636,7 +638,7 @@ node_in_cluster(int id)
636
638
void
637
639
rm_node (Cmd * cmd )
638
640
{
639
- int node_id = atoi (cmd -> opts [0 ]);
641
+ int32 node_id = atoi (cmd -> opts [0 ]);
640
642
char * sql ;
641
643
642
644
elog (INFO , "Removing node %d " , node_id );
@@ -678,11 +680,11 @@ rm_node(Cmd *cmd)
678
680
679
681
680
682
/*
681
- * Get connstring of worker node with id node_id. Memory is palloc'ed.
683
+ * Get connstr of worker node with id node_id. Memory is palloc'ed.
682
684
* NULL is returned, if there is no such node.
683
685
*/
684
686
char *
685
- get_worker_node_connstring (int node_id )
687
+ get_worker_node_connstr (int node_id )
686
688
{
687
689
MemoryContext oldcxt = CurrentMemoryContext ;
688
690
char * sql = psprintf ("select connstring from shardman.nodes where id = %d"
0 commit comments