File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
pgdog/src/frontend/router/parser/query Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -121,8 +121,14 @@ impl QueryParser {
121
121
}
122
122
}
123
123
124
+ let shard = if let Shard :: Direct ( _) = self . shard {
125
+ self . shard . clone ( )
126
+ } else {
127
+ Shard :: All
128
+ } ;
129
+
124
130
Ok ( Command :: Query (
125
- Route :: write ( Shard :: All ) . set_read ( context. read_only ) ,
131
+ Route :: write ( shard ) . set_read ( context. read_only ) ,
126
132
) )
127
133
}
128
134
}
Original file line number Diff line number Diff line change @@ -545,3 +545,20 @@ fn test_dry_run_simple() {
545
545
assert_eq ! ( stmt. stats. lock( ) . multi, 0 ) ;
546
546
assert_eq ! ( command. route( ) . shard( ) , & Shard :: Direct ( 0 ) ) ;
547
547
}
548
+
549
+ #[ test]
550
+ fn test_set_comments ( ) {
551
+ let command = query_parser ! (
552
+ QueryParser :: default ( ) ,
553
+ Query :: new( "/* pgdog_sharding_key: 1234 */ SET statement_timeout TO 1" ) ,
554
+ true
555
+ ) ;
556
+ assert_eq ! ( command. route( ) . shard( ) , & Shard :: Direct ( 0 ) ) ;
557
+
558
+ let command = query_parser ! (
559
+ QueryParser :: default ( ) ,
560
+ Query :: new( "SET statement_timeout TO 1" ) ,
561
+ true
562
+ ) ;
563
+ assert_eq ! ( command. route( ) . shard( ) , & Shard :: All ) ;
564
+ }
You can’t perform that action at this time.
0 commit comments