@@ -123,6 +123,29 @@ static bool dispatch_param_event(pdo_stmt_t *stmt, enum pdo_param_event event_ty
123123}
124124/* }}} */
125125
126+ static zend_string * pdo_stmt_change_case (zend_string * str , enum pdo_case_conversion desired_case ) /* {{{ */
127+ {
128+ /*
129+ * Note that input string may be freed; treat this like realloc() and
130+ * reassign the string.
131+ */
132+ zend_string * orig = str ;
133+ switch (desired_case ) {
134+ case PDO_CASE_LOWER :
135+ str = zend_string_tolower (orig );
136+ zend_string_release (orig );
137+ break ;
138+ case PDO_CASE_UPPER :
139+ str = zend_string_toupper (orig );
140+ zend_string_release (orig );
141+ break ;
142+ default :
143+ break ;
144+ }
145+ return str ;
146+ }
147+ /* }}} */
148+
126149bool pdo_stmt_describe_columns (pdo_stmt_t * stmt ) /* {{{ */
127150{
128151 int col ;
@@ -136,26 +159,17 @@ bool pdo_stmt_describe_columns(pdo_stmt_t *stmt) /* {{{ */
136159
137160 /* if we are applying case conversions on column names, do so now */
138161 if (stmt -> dbh -> native_case != stmt -> dbh -> desired_case && stmt -> dbh -> desired_case != PDO_CASE_NATURAL ) {
139- zend_string * orig_name = stmt -> columns [col ].name ;
140- switch (stmt -> dbh -> desired_case ) {
141- case PDO_CASE_LOWER :
142- stmt -> columns [col ].name = zend_string_tolower (orig_name );
143- zend_string_release (orig_name );
144- break ;
145- case PDO_CASE_UPPER :
146- stmt -> columns [col ].name = zend_string_toupper (orig_name );
147- zend_string_release (orig_name );
148- break ;
149- default : ZEND_UNREACHABLE ();
162+ stmt -> columns [col ].name = pdo_stmt_change_case (stmt -> columns [col ].name , stmt -> dbh -> desired_case );
163+ if (stmt -> columns [col ].table ) {
164+ stmt -> columns [col ].table = pdo_stmt_change_case (stmt -> columns [col ].table , stmt -> dbh -> desired_case );
150165 }
151166 }
152167
153168 /* prepend the table name if the attribute is set */
154169 if (stmt -> dbh -> fetch_table_names && stmt -> columns [col ].table && ZSTR_LEN (stmt -> columns [col ].table )) {
155- /* XXX: Apply case to table as well? */
156- zend_string * table_name = stmt -> columns [col ].table ;
157170 zend_string * orig_name = stmt -> columns [col ].name ;
158- stmt -> columns [col ].name = strpprintf (0 , "%pS.%pS" , table_name , orig_name );
171+ stmt -> columns [col ].name = strpprintf (0 , "%pS.%pS" ,
172+ stmt -> columns [col ].table , orig_name );
159173 zend_string_release (orig_name );
160174 }
161175
0 commit comments