# File lib/dbd/mysql/database.rb, line 179
179:         def columns(table)
180:             dbh = DBI::DatabaseHandle.new(self)
181:             uniques = []
182:             dbh.execute("SHOW INDEX FROM #{table}") do |sth|
183:                 sth.each do |row|
184:                     uniques << row[4] if row[1] == 0
185:                 end
186:             end  
187: 
188:             ret = nil
189:             dbh.execute("SHOW FIELDS FROM #{table}") do |sth|
190:                 ret = sth.collect do |row|
191:                     name, type, nullable, key, default, extra = row
192:                     #type = row[1]
193:                     #size = type[type.index('(')+1..type.index(')')-1]
194:                     #size = 0
195:                     #type = type[0..type.index('(')-1]
196: 
197:                     sqltype, type, size, decimal = mysql_type_info(row[1])
198:                     col = Hash.new
199:                     col['name']           = name
200:                     col['sql_type']       = sqltype
201:                     col['type_name']      = type
202:                     col['nullable']       = nullable == "YES"
203:                     col['indexed']        = key != ""
204:                     col['primary']        = key == "PRI"
205:                     col['unique']         = uniques.index(name) != nil
206:                     col['precision']      = size
207:                     col['scale']          = decimal
208:                     col['default']        = row[4]
209: 
210:                     case col['type_name']
211:                     when 'timestamp'
212:                         col['dbi_type'] = DBI::DBD::Mysql::Type::Timestamp
213:                     end
214: 
215:                     col
216:                 end # collect
217:             end # execute
218: 
219:             ret
220:         end