@@ -7,6 +7,7 @@ use bytes::Bytes;
7
7
use fallible_iterator:: FallibleIterator ;
8
8
use futures:: { ready, Stream } ;
9
9
use pin_project_lite:: pin_project;
10
+ use postgres_protocol:: escape:: { escape_identifier, escape_literal} ;
10
11
use postgres_protocol:: message:: backend:: { Message , ReplicationMessage } ;
11
12
use std:: io;
12
13
use std:: marker:: PhantomPinned ;
@@ -103,7 +104,7 @@ impl ReplicationClient {
103
104
/// show the value of the given setting
104
105
pub async fn show ( & self , name : & str ) -> Result < String , Error > {
105
106
let iclient = self . 0 . inner ( ) ;
106
- let command = format ! ( "SHOW \" {} \" " , name) ;
107
+ let command = format ! ( "SHOW {}" , escape_identifier ( name) ) ;
107
108
let buf = simple_query:: encode ( iclient, & command) ?;
108
109
let mut responses = iclient. send ( RequestMessages :: Single ( FrontendMessage :: Raw ( buf) ) ) ?;
109
110
@@ -151,7 +152,7 @@ impl ReplicationClient {
151
152
) -> Result < ReplicationStream , Error > {
152
153
let iclient = self . 0 . inner ( ) ;
153
154
let slot = match slot_name {
154
- Some ( name) => format ! ( " SLOT \" {} \" " , name) ,
155
+ Some ( name) => format ! ( " SLOT {}" , escape_identifier ( name) ) ,
155
156
None => String :: from ( "" ) ,
156
157
} ;
157
158
let timeline = match timeline_id {
@@ -184,13 +185,13 @@ impl ReplicationClient {
184
185
options : & [ ( & str , & str ) ] ,
185
186
) -> Result < ReplicationStream , Error > {
186
187
let iclient = self . 0 . inner ( ) ;
187
- let slot = format ! ( " SLOT \" {} \" " , slot_name) ;
188
+ let slot = format ! ( " SLOT {}" , escape_identifier ( slot_name) ) ;
188
189
let options_string = if !options. is_empty ( ) {
189
190
format ! (
190
191
" ({})" ,
191
192
options
192
193
. iter( )
193
- . map( |pair| format!( "\" {} \" '{}' " , pair. 0 , pair. 1 ) )
194
+ . map( |pair| format!( "{} {} " , escape_identifier ( pair. 0 ) , escape_literal ( pair. 1 ) ) )
194
195
. collect:: <Vec <String >>( )
195
196
. as_slice( )
196
197
. join( ", " )
0 commit comments