Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6487f97

Browse files
committed
Merge branch 'master' into python_wrapper
2 parents 6d91fb3 + f4dc09d commit 6487f97

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

postgresql.conf.lord.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
shardman.shardlord = on # this instance is shardlord?
2-
shardman.shardlord_dbname = ars # shardlord's dbname
2+
shardman.shardlord_dbname = ars # shardlord's dbname. TODO: merge with connstr
33
shardman.shardlord_connstring = 'port=5432' # shardlord's connstring
44
# Sleep milliseconds after any failure during cmd execution. Also, we restart
55
# shardlord bgw itself after this period of time if it has failed.

shard.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ BEGIN
296296
IF replica_removed THEN -- replica removed on us
297297
PERFORM shardman.eliminate_sub(prim_repl_lname);
298298
ELSE -- primary removed on us
299-
IF replica_exists IS NOT NULL THEN
299+
IF replica_exists THEN
300300
-- If next replica existed, drop pub & rs for data channel
301301
-- Wait sometime to let replica first remove subscription
302302
PERFORM pg_sleep(drop_slot_delay);

src/pg_shardman.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,9 @@ void_spi(char *sql)
304304
PGconn *
305305
listen_cmd_log_inserts(void)
306306
{
307-
char *connstr;
308307
PGresult *res;
309308

310-
connstr = psprintf("dbname = %s", shardman_shardlord_dbname);
311-
conn = PQconnectdb(connstr);
312-
pfree(connstr);
309+
conn = PQconnectdb(shardman_shardlord_connstring);
313310
/* Check to see that the backend connection was successfully made */
314311
if (PQstatus(conn) != CONNECTION_OK)
315312
shmn_elog(FATAL, "Connection to local database failed: %s",

src/udf.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ pg_shardman_cleanup_c(PG_FUNCTION_ARGS)
7575
* defaults, everything. Parameter is not REGCLASS because pg_dump can't
7676
* handle oids anyway. Connstring must be proper libpq connstring, it is feed
7777
* to pg_dump.
78+
* TODO: actually we should have much more control on what is dumped, so we
79+
* need to copy-paste parts of messy pg_dump or collect the needed data
80+
* manually walking over catalogs.
7881
*/
7982
PG_FUNCTION_INFO_V1(gen_create_table_sql);
8083
Datum
@@ -92,13 +95,18 @@ gen_create_table_sql(PG_FUNCTION_ARGS)
9295
char *cmd;
9396
FILE *fp;
9497
size_t bytes_read;
98+
9599
SET_VARSIZE(sql, VARHDRSZ);
96100

97-
/* find pg_dump location */
98-
if (find_my_exec("pg_dump", pg_dump_path) != 0)
99-
{
100-
elog(ERROR, "Failed to find pg_dump location");
101-
}
101+
/* find pg_dump location querying pg_config */
102+
SPI_connect();
103+
if (SPI_execute("select setting from pg_config where name = 'BINDIR';",
104+
true, 0) < 0)
105+
elog(FATAL, "Failed to query pg_config");
106+
strcpy(pg_dump_path,
107+
SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, 1));
108+
SPI_finish();
109+
join_path_components(pg_dump_path, pg_dump_path, "pg_dump");
102110

103111
cmd = psprintf("%s -t '%s' --schema-only --dbname='%s' 2>&1",
104112
pg_dump_path, relation, connstring);

0 commit comments

Comments
 (0)