[unixODBC-support] RE : Image data corruption in the Postgre

SEUNGHO PARK shpark94 at samsung.com
Thu Jul 7 03:15:50 BST 2005


Hello
I am sending to ask you again because I am still have this problem.
The problem is as following.
The image data from postgre DB(7.3) is corrupted on Linux(RED HAT
Enterprise.
On windows, it's OK.
All environment is same except OS(WIN & Linux) and ODBC Driver.
I downloaded 2.2.11 unixODBC driver.

On windows, I use Insight Distribution System ODBC driver 7.03.02.00 for
Postgre.( http://www.postgresql.org/ftp/odbc/versions/dll/ )

Ps. How can I get the log file? I changed trace option to YES and set the
file name on ODBCConfig but it didn't work.

Seungho Park
---------------------------------------------------------------------------
How can I get the log file? I changed the odbc setting trace to yes and make
the filename but I couldn't get the log file.

The reason why append the data in do-while loop is just in case of the big
file (more than MAX_LONGDATA_FOR_ACCESS size) but in this case the image
files that I sent you is small, so it doesn't' matter.

Thank you for your immediate feedback.


-----Original Message-----
Hi,

Your posting (including the log I asked for I guess, is to large for the
list), could you send it directly to me?

--
Nick


>I attach the source code
>I add some code that write to file from the binary data of the DB.
>I am still wonder that why the pData is different from data of windows
>driver that was no problem .
>  
>

What driver are you using on the non windows side, it may be that there 
are problems, or it may be that you could try the current postgres 
driver from the DB vendors. That will build fine with a --with-unixODBC 
flag.

>UCHAR* CRQOdbcQueryInfo::GetLongData(RQLONG index, SDWORD& nColLen, SWORD
>cType)
>{
>	switch(m_pDatabase->m_nDatabase)
>	{
>	default:
>	{
>		UCHAR *pData;
>		SDWORD nSize;
>		SDWORD fLen = 0;
>
>		UCHAR*	lpOutData = new UCHAR[MAX_LONGDATA_FOR_ACCESS];
>
>		pData = (UCHAR*) malloc(1L);
>		if (pData == NULL)
>		{
>			delete lpOutData;
>			return NULL;
>		}
>
>		do
>		{
>			// cType is SQL_C_BINARY
>			m_rc = SQLGetData(m_hstmt, (RQWORD)index, cType,
>lpOutData, MAX_LONGDATA_FOR_ACCESS, &nColLen);
>
>			if (m_rc != SQL_SUCCESS && m_rc !=
>SQL_SUCCESS_WITH_INFO)
>			{
>				delete lpOutData;
>				free(pData);
>				return NULL;
>			}
>			
>			if (nColLen == SQL_NULL_DATA)
>			{
>				delete lpOutData;
>				free(pData);
>				return NULL;
>			}
>
>			pData = (UCHAR*) realloc(pData, fLen+nColLen+1);
>
>			if (m_rc == SQL_SUCCESS) 
>				nSize = nColLen;
>			else 
>				nSize = MAX_LONGDATA_FOR_ACCESS;
>			memcpy(pData+fLen, (UCHAR *)lpOutData, nSize);
>			fLen += nSize;
>		}
>		while (m_rc == SQL_SUCCESS_WITH_INFO);
>
>		nColLen = fLen;
>		delete [] lpOutData;
>		// determine the image pData
>		FILE *pFile;
>		pFile = fopen( "image_win.bmp", "w+b" );
>		RQLONG	ret = fseek(pFile, 0, SEEK_END);
>		if ( fwrite(pData, sizeof(UCHAR), nColLen, pFile) != nColLen
>)
>		;
>		fclose(pFile);
>
>		return pData;
>	}	// default
>	}	// end of switch
>
>	return NULL;
>}
>  
>

I am not sure why you append the data to the file each time, why not 
just write it from the start. pData and its length nColLen should 
contain the entire image.

-- 
Nick
_______________________________________________
unixODBC-support mailing list
unixODBC-support at easysoft.com
http://mail.easysoft.com/mailman/listinfo/unixodbc-support

-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.bmp
Type: image/bmp
Size: 12664 bytes
Desc: not available
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20050707/097e1c09/attachment.bmp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image_win.bmp
Type: image/bmp
Size: 12660 bytes
Desc: not available
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-support/attachments/20050707/097e1c09/attachment-0001.bmp>


More information about the unixODBC-support mailing list