@@ -2,8 +2,10 @@ use std::collections::HashMap;
22use std:: sync:: atomic:: { AtomicU32 , Ordering } ;
33use std:: sync:: Arc ;
44
5- use datafusion:: arrow:: array:: { ArrayRef , BooleanArray , Int32Array , RecordBatch , StringArray } ;
6- use datafusion:: arrow:: datatypes:: { DataType , Field , Schema , SchemaRef } ;
5+ use datafusion:: arrow:: array:: {
6+ ArrayRef , BooleanArray , Int32Array , ListArray , RecordBatch , StringArray ,
7+ } ;
8+ use datafusion:: arrow:: datatypes:: { DataType , Field , Int32Type , Schema , SchemaRef } ;
79use datafusion:: error:: Result ;
810use datafusion:: execution:: { SendableRecordBatchStream , TaskContext } ;
911use datafusion:: physical_plan:: stream:: RecordBatchStreamAdapter ;
@@ -36,16 +38,23 @@ impl<C: CatalogInfo> PgDatabaseTable<C> {
3638 Field :: new( "datname" , DataType :: Utf8 , false ) , // Database name
3739 Field :: new( "datdba" , DataType :: Int32 , false ) , // Database owner's user ID
3840 Field :: new( "encoding" , DataType :: Int32 , false ) , // Character encoding
41+ Field :: new( "datlocprovider" , DataType :: Utf8 , false ) ,
3942 Field :: new( "datcollate" , DataType :: Utf8 , false ) , // LC_COLLATE for this database
40- Field :: new( "datctype" , DataType :: Utf8 , false ) , // LC_CTYPE for this database
43+ Field :: new( "datctype" , DataType :: Utf8 , false ) , // LC_CTYPE for this database
4144 Field :: new( "datistemplate" , DataType :: Boolean , false ) , // If true, database can be used as a template
4245 Field :: new( "datallowconn" , DataType :: Boolean , false ) , // If false, no one can connect to this database
4346 Field :: new( "datconnlimit" , DataType :: Int32 , false ) , // Max number of concurrent connections (-1=no limit)
4447 Field :: new( "datlastsysoid" , DataType :: Int32 , false ) , // Last system OID in database
4548 Field :: new( "datfrozenxid" , DataType :: Int32 , false ) , // Frozen XID for this database
4649 Field :: new( "datminmxid" , DataType :: Int32 , false ) , // Minimum multixact ID
4750 Field :: new( "dattablespace" , DataType :: Int32 , false ) , // Default tablespace for this database
48- Field :: new( "datacl" , DataType :: Utf8 , true ) , // Access privileges
51+ Field :: new( "daticulocale" , DataType :: Utf8 , true ) ,
52+ Field :: new( "daticurules" , DataType :: Utf8 , true ) ,
53+ Field :: new(
54+ "datacl" ,
55+ DataType :: List ( Arc :: new( Field :: new( "item" , DataType :: Int32 , true ) ) ) ,
56+ true ,
57+ ) , // Access privileges
4958 ] ) ) ;
5059
5160 Self {
@@ -63,6 +72,7 @@ impl<C: CatalogInfo> PgDatabaseTable<C> {
6372 let mut datnames = Vec :: new ( ) ;
6473 let mut datdbas = Vec :: new ( ) ;
6574 let mut encodings = Vec :: new ( ) ;
75+ let mut datlocproviders = Vec :: new ( ) ;
6676 let mut datcollates = Vec :: new ( ) ;
6777 let mut datctypes = Vec :: new ( ) ;
6878 let mut datistemplates = Vec :: new ( ) ;
@@ -72,7 +82,9 @@ impl<C: CatalogInfo> PgDatabaseTable<C> {
7282 let mut datfrozenxids = Vec :: new ( ) ;
7383 let mut datminmxids = Vec :: new ( ) ;
7484 let mut dattablespaces = Vec :: new ( ) ;
75- let mut datacles: Vec < Option < String > > = Vec :: new ( ) ;
85+ let mut daticulocales: Vec < Option < String > > = Vec :: new ( ) ;
86+ let mut daticurules: Vec < Option < String > > = Vec :: new ( ) ;
87+ let mut datacls: Vec < Option < Vec < Option < i32 > > > > = Vec :: new ( ) ;
7688
7789 // to store all schema-oid mapping temporarily before adding to global oid cache
7890 let mut catalog_oid_cache = HashMap :: new ( ) ;
@@ -93,6 +105,7 @@ impl<C: CatalogInfo> PgDatabaseTable<C> {
93105 datnames. push ( catalog_name. clone ( ) ) ;
94106 datdbas. push ( 10 ) ; // Default owner (assuming 10 = postgres user)
95107 encodings. push ( 6 ) ; // 6 = UTF8 in PostgreSQL
108+ datlocproviders. push ( "libc" . to_string ( ) ) ;
96109 datcollates. push ( "en_US.UTF-8" . to_string ( ) ) ; // Default collation
97110 datctypes. push ( "en_US.UTF-8" . to_string ( ) ) ; // Default ctype
98111 datistemplates. push ( false ) ;
@@ -102,7 +115,9 @@ impl<C: CatalogInfo> PgDatabaseTable<C> {
102115 datfrozenxids. push ( 1 ) ; // Simplified transaction ID
103116 datminmxids. push ( 1 ) ; // Simplified multixact ID
104117 dattablespaces. push ( 1663 ) ; // Default tablespace (1663 = pg_default in PostgreSQL)
105- datacles. push ( None ) ; // No specific ACLs
118+ daticulocales. push ( None ) ;
119+ daticurules. push ( None ) ;
120+ datacls. push ( None ) ; // No specific ACLs
106121 }
107122
108123 // Always include a "postgres" database entry if not already present
@@ -121,6 +136,7 @@ impl<C: CatalogInfo> PgDatabaseTable<C> {
121136 datnames. push ( default_datname) ;
122137 datdbas. push ( 10 ) ;
123138 encodings. push ( 6 ) ;
139+ datlocproviders. push ( "libc" . to_string ( ) ) ;
124140 datcollates. push ( "en_US.UTF-8" . to_string ( ) ) ;
125141 datctypes. push ( "en_US.UTF-8" . to_string ( ) ) ;
126142 datistemplates. push ( false ) ;
@@ -130,7 +146,9 @@ impl<C: CatalogInfo> PgDatabaseTable<C> {
130146 datfrozenxids. push ( 1 ) ;
131147 datminmxids. push ( 1 ) ;
132148 dattablespaces. push ( 1663 ) ;
133- datacles. push ( None ) ;
149+ daticulocales. push ( None ) ;
150+ daticurules. push ( None ) ;
151+ datacls. push ( None ) ;
134152 }
135153
136154 // Create Arrow arrays from the collected data
@@ -139,6 +157,7 @@ impl<C: CatalogInfo> PgDatabaseTable<C> {
139157 Arc :: new( StringArray :: from( datnames) ) ,
140158 Arc :: new( Int32Array :: from( datdbas) ) ,
141159 Arc :: new( Int32Array :: from( encodings) ) ,
160+ Arc :: new( StringArray :: from( datlocproviders) ) ,
142161 Arc :: new( StringArray :: from( datcollates) ) ,
143162 Arc :: new( StringArray :: from( datctypes) ) ,
144163 Arc :: new( BooleanArray :: from( datistemplates) ) ,
@@ -148,7 +167,11 @@ impl<C: CatalogInfo> PgDatabaseTable<C> {
148167 Arc :: new( Int32Array :: from( datfrozenxids) ) ,
149168 Arc :: new( Int32Array :: from( datminmxids) ) ,
150169 Arc :: new( Int32Array :: from( dattablespaces) ) ,
151- Arc :: new( StringArray :: from_iter( datacles. into_iter( ) ) ) ,
170+ Arc :: new( StringArray :: from( daticulocales) ) ,
171+ Arc :: new( StringArray :: from( daticurules) ) ,
172+ Arc :: new( ListArray :: from_iter_primitive:: <Int32Type , _, _>(
173+ datacls. into_iter( ) ,
174+ ) ) ,
152175 ] ;
153176
154177 // Create a full record batch
0 commit comments