@@ -2,6 +2,7 @@ use collections::{Deque, RingBuf};
22use std:: cell:: Cell ;
33use std:: from_str:: FromStr ;
44use std:: task;
5+ use std:: vec_ng:: Vec ;
56
67use PostgresConnection ;
78use error:: { PgDbError ,
@@ -116,16 +117,16 @@ pub trait PostgresStatement {
116117pub struct NormalPostgresStatement < ' conn > {
117118 priv conn : & ' conn PostgresConnection ,
118119 priv name : ~str ,
119- priv param_types : ~ [ PostgresType ] ,
120- priv result_desc : ~ [ ResultDescription ] ,
120+ priv param_types : Vec < PostgresType > ,
121+ priv result_desc : Vec < ResultDescription > ,
121122 priv next_portal_id : Cell < uint > ,
122123 priv finished : Cell < bool > ,
123124}
124125
125126pub fn make_NormalPostgresStatement < ' a > ( conn : & ' a PostgresConnection ,
126127 name : ~str ,
127- param_types : ~ [ PostgresType ] ,
128- result_desc : ~ [ ResultDescription ] )
128+ param_types : Vec < PostgresType > ,
129+ result_desc : Vec < ResultDescription > )
129130 -> NormalPostgresStatement < ' a > {
130131 NormalPostgresStatement {
131132 conn : conn,
@@ -174,8 +175,8 @@ impl<'conn> NormalPostgresStatement<'conn> {
174175
175176 fn execute ( & self , portal_name : & str , row_limit : uint , params : & [ & ToSql ] )
176177 -> Result < ( ) , PostgresError > {
177- let mut formats = ~ [ ] ;
178- let mut values = ~ [ ] ;
178+ let mut formats = Vec :: new ( ) ;
179+ let mut values = Vec :: new ( ) ;
179180 assert ! ( self . param_types. len( ) == params. len( ) ,
180181 "Expected {} parameters but found {}" ,
181182 self . param_types. len( ) , params. len( ) ) ;
@@ -185,17 +186,17 @@ impl<'conn> NormalPostgresStatement<'conn> {
185186 values. push ( value) ;
186187 } ;
187188
188- let result_formats: ~ [ i16 ] = self . result_desc . iter ( ) . map ( |desc| {
189+ let result_formats: Vec < i16 > = self . result_desc . iter ( ) . map ( |desc| {
189190 desc. ty . result_format ( ) as i16
190191 } ) . collect ( ) ;
191192
192193 if_ok_pg ! ( self . conn. write_messages( [
193194 Bind {
194195 portal: portal_name,
195196 statement: self . name. as_slice( ) ,
196- formats: formats,
197- values: values,
198- result_formats: result_formats
197+ formats: formats. as_slice ( ) ,
198+ values: values. as_slice ( ) ,
199+ result_formats: result_formats. as_slice ( )
199200 } ,
200201 Execute {
201202 portal: portal_name,
@@ -380,7 +381,7 @@ impl<'conn> TransactionalPostgresStatement<'conn> {
380381pub struct PostgresResult < ' stmt > {
381382 priv stmt : & ' stmt NormalPostgresStatement < ' stmt > ,
382383 priv name : ~str ,
383- priv data : RingBuf < ~ [ Option < ~[ u8 ] > ] > ,
384+ priv data : RingBuf < Vec < Option < ~[ u8 ] > > > ,
384385 priv row_limit : uint ,
385386 priv more_rows : bool ,
386387 priv finished : bool ,
@@ -514,7 +515,7 @@ impl<'stmt> Iterator<PostgresRow<'stmt>> for PostgresResult<'stmt> {
514515/// ```
515516pub struct PostgresRow < ' stmt > {
516517 priv stmt : & ' stmt NormalPostgresStatement < ' stmt > ,
517- priv data : ~ [ Option < ~[ u8 ] > ]
518+ priv data : Vec < Option < ~[ u8 ] > >
518519}
519520
520521impl < ' stmt > Container for PostgresRow < ' stmt > {
@@ -527,7 +528,7 @@ impl<'stmt> Container for PostgresRow<'stmt> {
527528impl < ' stmt , I : RowIndex , T : FromSql > Index < I , T > for PostgresRow < ' stmt > {
528529 fn index ( & self , idx : & I ) -> T {
529530 let idx = idx. idx ( self . stmt ) ;
530- FromSql :: from_sql ( & self . stmt . result_desc [ idx] . ty , & self . data [ idx] )
531+ FromSql :: from_sql ( & self . stmt . result_desc . get ( idx) . ty , self . data . get ( idx) )
531532 }
532533}
533534
0 commit comments