#include "access/committs.h"
#include "access/heapam.h"
#include "access/xact.h"
+#include "catalog/namespace.h"
#include "catalog/pg_extension.h"
#include "catalog/pg_index.h"
#include "catalog/catversion.h"
#include "replication/replication_identifier.h"
#include "utils/builtins.h"
#include "utils/guc.h"
+#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/snapmgr.h"
#include "utils/timestamp.h"
replication_origin_id = replication_identifier;
- /* setup initial queued_cmds OID */
- setup_queuedcmds_relid();
-
while (!got_sigterm)
{
/* int ret; */
{
Relation extrel;
Oid extoid;
+ Oid schema_oid;
StartTransactionCommand();
PushActiveSnapshot(GetTransactionSnapshot());
heap_close(extrel, NoLock);
+ /* setup initial queued_cmds OID */
+ schema_oid = get_namespace_oid("bdr", false);
+ if (schema_oid != InvalidOid)
+ {
+ QueuedDDLCommandsRelid = get_relname_relid("bdr_queued_commands",
+ schema_oid);
+ }
+
+ elog(LOG, "bdr.bdr_queued_commands OID set to %u", QueuedDDLCommandsRelid);
+
PopActiveSnapshot();
CommitTransactionCommand();
}
extern BDRWorkerCon *bdr_apply_con;
extern BDRSequencerCon *bdr_sequencer_con;
+/* DDL replication support */
+extern Oid QueuedDDLCommandsRelid;
+
/* apply support */
extern void process_remote_begin(StringInfo s);
extern void process_remote_commit(StringInfo s);
extern void bdr_sequence_setval(PG_FUNCTION_ARGS);
extern Datum bdr_sequence_options(PG_FUNCTION_ARGS);
-/* DDL replication support */
-extern void setup_queuedcmds_relid(void);
-
/* statistic functions */
extern void bdr_count_shmem_init(size_t nnodes);
extern void bdr_count_set_current_node(RepNodeId node_id);
static void check_sequencer_wakeup(Relation rel);
bool request_sequencer_wakeup = false;
-static Oid QueuedDDLCommandsRelid = InvalidOid;
+Oid QueuedDDLCommandsRelid = InvalidOid;
void
process_remote_begin(StringInfo s)
return tuple;
}
-
-void
-setup_queuedcmds_relid(void)
-{
- Datum oid;
- int ret;
- bool isnull;
-
- StartTransactionCommand();
- SPI_connect();
- PushActiveSnapshot(GetTransactionSnapshot());
-
- ret = SPI_execute("SELECT oid FROM pg_class "
- "WHERE oid = 'bdr.bdr_queued_commands'::regclass",
- true, 0);
- if (ret != SPI_OK_SELECT)
- goto failed;
-
- if (SPI_processed != 1)
- goto failed;
-
- oid = SPI_getbinval(SPI_tuptable->vals[0],
- SPI_tuptable->tupdesc,
- 1, &isnull);
- if (isnull)
- goto failed;
-
- if (true)
- QueuedDDLCommandsRelid = DatumGetObjectId(oid);
- else
- {
-failed:
- QueuedDDLCommandsRelid = InvalidOid;
- }
-
- SPI_finish();
- PopActiveSnapshot();
- CommitTransactionCommand();
- pgstat_report_activity(STATE_IDLE, NULL);
-
- elog(LOG, "bdr.bdr_queued_commands OID set to %u", QueuedDDLCommandsRelid);
-}