Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for logical streaming replication #1271

Merged
merged 3 commits into from Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/client.js
Expand Up @@ -26,6 +26,7 @@ var Client = function(config) {
this.port = this.connectionParameters.port;
this.host = this.connectionParameters.host;
this.password = this.connectionParameters.password;
this.replication = this.connectionParameters.replication;

var c = config || {};

Expand Down Expand Up @@ -222,6 +223,9 @@ Client.prototype.getStartupConf = function() {
if (appName) {
data.application_name = appName;
}
if (params.replication) {
data.replication = params.replication === true ? 'true' : params.replication;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly: '' + params.replication

}

return data;
};
Expand Down
4 changes: 4 additions & 0 deletions lib/connection-parameters.js
Expand Up @@ -57,6 +57,7 @@ var ConnectionParameters = function(config) {
this.binary = val('binary', config);
this.ssl = typeof config.ssl === 'undefined' ? useSsl() : config.ssl;
this.client_encoding = val("client_encoding", config);
this.replication = val("replication", config);
//a domain socket begins with '/'
this.isDomainSocket = (!(this.host||'').indexOf('/'));

Expand Down Expand Up @@ -88,6 +89,9 @@ ConnectionParameters.prototype.getLibpqConnectionString = function(cb) {
if(this.database) {
params.push("dbname='" + this.database + "'");
}
if(this.replication) {
params.push("replication='" + (this.database === true ? "true" : this.replication) + "'");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Replication" can have "database", "true" and "false" values.

This is checking this.database === true, though – not this.replication === true. Is that really intended? I’m not sure why dbname='true' (not replication='true') would have any special meaning beyond a database named “true”.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry. I understand. You are right.
I'll change that code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this issue in last commit. Check please :)

}
if(this.host) {
params.push("host=" + this.host);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/connection.js
Expand Up @@ -425,6 +425,9 @@ Connection.prototype.parseMessage = function(buffer) {
case 0x48: //H
return this.parseH(buffer, length);

case 0x57: //W
return new Message('replicationStart', length);

case 0x63: //c
return new Message('copyDone', length);

Expand Down