1

我已经从 MySQL 数据库转换为 Postgres。在转换过程中,Postgres 中的图片列被创建为 bytea。

此 Xojo 代码适用于 MySQL,但不适用于 Postgres。

Dim mImage as Picture

mImage = rs.Field("Picture").PictureValue

有任何想法吗?

4

1 回答 1

1

I don't know about this particular issue, but here's what you can do to find out yourself, perhaps:

Pictures are stored as BLOBs in the database. Now, this means that the column must also be declared as BLOB (or a similar binary type). If it was accidentally marked as TEXT, this would work as long as the database does not get exported by other means. I.e, as long as only your Xojo code reads and writes to the record, using the PictureValue functions, that takes care of keeping the data in BLOB form. But if you'd then convert to another database, the BLOB data would be read as text, and in that process it might get mangled.

So, it may be relevant to let us know how you converted the DB. Did you perform a export as SQL commands and then imported it into Postgres by running these commands again? Do you still have the export file? If so, find a record with picture data in it and see if that data is starting with: x' and then contains hex byte code, e.g. x'45FE1200... and so on. If it doesn't, that's another indicator for my suspicion.

So, check the type of the Picture column in your old DB first. If that specifies a binary data type, then the above probably does not apply.

Next, you can look at the actualy binary data that Xojo reads. To do that, get the BlobValue instead of the PictureValue, and store that in a MemoryBlock. Do the same for a single picture, both with the old and the new database. The memoryblock should contain the same bytes. If not, that would suggest that the data was not transferred correctly. Why? Well, that depends on how you converted it.

于 2014-03-19T14:15:58.103 回答