@@ -26,7 +26,7 @@ struct PgCollation {
2626 collencoding : i32 ,
2727 collcollate : Option < String > ,
2828 collctype : Option < String > ,
29- // Column `colliculocale` renamed to `colllocale` since PostgreSQL 17.
29+ // Column `colliculocale` is renamed to `colllocale` since PostgreSQL 17.
3030 colllocale : Option < String > ,
3131 collicurules : Option < String > ,
3232 collversion : Option < String > ,
@@ -40,13 +40,13 @@ struct PgCatalogCollationBuilder {
4040 collprovider : StringBuilder ,
4141 collisdeterministic : BooleanBuilder ,
4242 collencoding : Int32Builder ,
43- // Column `colliculocale` renamed to `colllocale` since PostgreSQL 17.
44- // Support both columns for backward-compatibility.
45- // Reference: https://pgpedia.info/p/pg_collation.html
46- colliculocale : StringBuilder ,
4743 collcollate : StringBuilder ,
4844 collctype : StringBuilder ,
45+ // Column `colliculocale` is renamed to `colllocale` since PostgreSQL 17.
46+ // Support both columns for backward-compatibility.
47+ // Reference: https://pgpedia.info/p/pg_collation.html
4948 colllocale : StringBuilder ,
49+ colliculocale : StringBuilder ,
5050 collicurules : StringBuilder ,
5151 collversion : StringBuilder ,
5252}
@@ -61,10 +61,10 @@ impl PgCatalogCollationBuilder {
6161 collprovider : StringBuilder :: new ( capacity) ,
6262 collisdeterministic : BooleanBuilder :: new ( capacity) ,
6363 collencoding : Int32Builder :: new ( capacity) ,
64- colliculocale : StringBuilder :: new ( capacity) ,
6564 collcollate : StringBuilder :: new ( capacity) ,
6665 collctype : StringBuilder :: new ( capacity) ,
6766 colllocale : StringBuilder :: new ( capacity) ,
67+ colliculocale : StringBuilder :: new ( capacity) ,
6868 collicurules : StringBuilder :: new ( capacity) ,
6969 collversion : StringBuilder :: new ( capacity) ,
7070 }
@@ -81,9 +81,6 @@ impl PgCatalogCollationBuilder {
8181 . append_value ( coll. collisdeterministic )
8282 . unwrap ( ) ;
8383 self . collencoding . append_value ( coll. collencoding ) . unwrap ( ) ;
84- self . colliculocale
85- . append_option ( coll. colliculocale . clone ( ) )
86- . unwrap ( ) ;
8784 self . collcollate
8885 . append_option ( coll. collcollate . clone ( ) )
8986 . unwrap ( ) ;
@@ -93,6 +90,10 @@ impl PgCatalogCollationBuilder {
9390 self . colllocale
9491 . append_option ( coll. colllocale . clone ( ) )
9592 . unwrap ( ) ;
93+ // Column `colliculocale` is renamed to `colllocale` since PostgreSQL 17.
94+ self . colliculocale
95+ . append_option ( coll. colllocale . clone ( ) )
96+ . unwrap ( ) ;
9697 self . collicurules
9798 . append_option ( coll. collicurules . clone ( ) )
9899 . unwrap ( ) ;
@@ -110,10 +111,10 @@ impl PgCatalogCollationBuilder {
110111 Arc :: new( self . collprovider. finish( ) ) ,
111112 Arc :: new( self . collisdeterministic. finish( ) ) ,
112113 Arc :: new( self . collencoding. finish( ) ) ,
113- Arc :: new( self . colliculocale. finish( ) ) ,
114114 Arc :: new( self . collcollate. finish( ) ) ,
115115 Arc :: new( self . collctype. finish( ) ) ,
116116 Arc :: new( self . colllocale. finish( ) ) ,
117+ Arc :: new( self . colliculocale. finish( ) ) ,
117118 Arc :: new( self . collicurules. finish( ) ) ,
118119 Arc :: new( self . collversion. finish( ) ) ,
119120 ] ;
@@ -127,11 +128,13 @@ pub struct PgCatalogCollationProvider {
127128
128129impl PgCatalogCollationProvider {
129130 pub fn new ( ) -> Self {
130- // See https://github.com/postgres/postgres/blob/REL_16_4 /src/include/catalog/pg_collation.h
131- let mut builder = PgCatalogCollationBuilder :: new ( ) ;
131+ // See https://github.com/postgres/postgres/blob/REL_17_6 /src/include/catalog/pg_collation.h
132+ let mut builder = PgCatalogCollationBuilder :: new ( 6 ) ;
132133
133134 // Initial contents of the pg_collation system catalog.
134- // See https://github.com/postgres/postgres/blob/REL_16_4/src/include/catalog/pg_collation.dat
135+ // See https://github.com/postgres/postgres/blob/REL_17_6/src/include/catalog/pg_collation.dat
136+
137+ // database's default collation
135138 builder. add_collation ( & PgCollation {
136139 oid : 100 ,
137140 collname : "default" ,
@@ -141,12 +144,12 @@ impl PgCatalogCollationProvider {
141144 collisdeterministic : true ,
142145 collencoding : -1 ,
143146 collcollate : None ,
144- colliculocale : None ,
145147 collctype : None ,
146148 colllocale : None ,
147149 collicurules : None ,
148150 collversion : None ,
149151 } ) ;
152+ // standard C collation
150153 builder. add_collation ( & PgCollation {
151154 oid : 950 ,
152155 collname : "C" ,
@@ -156,12 +159,12 @@ impl PgCatalogCollationProvider {
156159 collisdeterministic : true ,
157160 collencoding : -1 ,
158161 collcollate : Some ( "C" . to_string ( ) ) ,
159- colliculocale : Some ( "C" . to_string ( ) ) ,
160162 collctype : Some ( "C" . to_string ( ) ) ,
161163 colllocale : None ,
162164 collicurules : None ,
163165 collversion : None ,
164166 } ) ;
167+ // standard POSIX collation
165168 builder. add_collation ( & PgCollation {
166169 oid : 951 ,
167170 collname : "POSIX" ,
@@ -171,27 +174,27 @@ impl PgCatalogCollationProvider {
171174 collisdeterministic : true ,
172175 collencoding : -1 ,
173176 collcollate : Some ( "POSIX" . to_string ( ) ) ,
174- colliculocale : Some ( "POSIX" . to_string ( ) ) ,
175177 collctype : Some ( "POSIX" . to_string ( ) ) ,
176178 colllocale : None ,
177179 collicurules : None ,
178180 collversion : None ,
179181 } ) ;
182+ // sorts by Unicode code point, C character semantics
180183 builder. add_collation ( & PgCollation {
181184 oid : 962 ,
182- collname : "usc_basic " ,
185+ collname : "ucs_basic " ,
183186 collnamespace : PG_NAMESPACE_CATALOG_OID ,
184187 collowner : 10 ,
185- collprovider : "c " . to_string ( ) ,
188+ collprovider : "b " . to_string ( ) ,
186189 collisdeterministic : true ,
187190 collencoding : 6 ,
188- collcollate : Some ( "C" . to_string ( ) ) ,
189- colliculocale : Some ( "C" . to_string ( ) ) ,
190- collctype : Some ( "C" . to_string ( ) ) ,
191- colllocale : None ,
191+ collcollate : None ,
192+ collctype : None ,
193+ colllocale : Some ( "C" . to_string ( ) ) ,
192194 collicurules : None ,
193- collversion : None ,
195+ collversion : Some ( "1" . to_string ( ) ) ,
194196 } ) ;
197+ // sorts using the Unicode Collation Algorithm with default settings
195198 builder. add_collation ( & PgCollation {
196199 oid : 963 ,
197200 collname : "unicode" ,
@@ -201,11 +204,25 @@ impl PgCatalogCollationProvider {
201204 collisdeterministic : true ,
202205 collencoding : -1 ,
203206 collcollate : None ,
204- colliculocale : None ,
205207 collctype : None ,
206208 colllocale : Some ( "und" . to_string ( ) ) ,
207209 collicurules : None ,
208- collversion : Some ( "153.121" . to_string ( ) ) ,
210+ collversion : Some ( "153.128" . to_string ( ) ) ,
211+ } ) ;
212+ // sorts by Unicode code point; Unicode and POSIX character semantics
213+ builder. add_collation ( & PgCollation {
214+ oid : 811 ,
215+ collname : "pg_c_utf8" ,
216+ collnamespace : PG_NAMESPACE_CATALOG_OID ,
217+ collowner : 10 ,
218+ collprovider : "b" . to_string ( ) ,
219+ collisdeterministic : true ,
220+ collencoding : 6 ,
221+ collcollate : None ,
222+ collctype : None ,
223+ colllocale : Some ( "C.UTF-8" . to_string ( ) ) ,
224+ collicurules : None ,
225+ collversion : Some ( "1" . to_string ( ) ) ,
209226 } ) ;
210227 Self {
211228 data : Arc :: new ( builder. finish ( ) ) ,
@@ -227,12 +244,12 @@ impl TableProvider for PgCatalogCollationProvider {
227244 Field :: new( "collprovider" , DataType :: Utf8 , false ) ,
228245 Field :: new( "collisdeterministic" , DataType :: Boolean , false ) ,
229246 Field :: new( "collencoding" , DataType :: Int32 , false ) ,
230- Field :: new( "colliculocale " , DataType :: Utf8 , false ) ,
231- Field :: new( "collcollate " , DataType :: Utf8 , false ) ,
232- Field :: new( "collctype " , DataType :: Utf8 , false ) ,
233- Field :: new( "colllocale " , DataType :: Utf8 , false ) ,
234- Field :: new( "collicurules" , DataType :: Utf8 , false ) ,
235- Field :: new( "collversion" , DataType :: Utf8 , false ) ,
247+ Field :: new( "collcollate " , DataType :: Utf8 , true ) ,
248+ Field :: new( "collctype " , DataType :: Utf8 , true ) ,
249+ Field :: new( "colllocale " , DataType :: Utf8 , true ) ,
250+ Field :: new( "colliculocale " , DataType :: Utf8 , true ) ,
251+ Field :: new( "collicurules" , DataType :: Utf8 , true ) ,
252+ Field :: new( "collversion" , DataType :: Utf8 , true ) ,
236253 ] ) )
237254 }
238255 async fn scan (
0 commit comments