473,569 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

putting binary data in a char field?

I'm attempting to use spamassassin 3.0 (beta) with an SQL backend, and have
identified one performance gain so far that makes PostgreSQL a good (IMO)
candidate for the backend. I need some advice though on another aspect--
instead of storing each token as text in the database, the token is being
sha1()'d and then possibly pack()'d.

That's all just background for my real question-- is there anything in the
standards (or elsewhere) that says you can't put binary(**) data into a char
field? When I changed the field to a bytea, processing time was
significantly reduced.

(**) Based on what very little I know of sha1 and of the tokens that have
been created by SA, it certainly looks like it's binary data that is being
inserted into the char field.

Thanks,
-ron

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #1
2 1874
Ron Snyder <sn****@roguewa ve.com> writes:
That's all just background for my real question-- is there anything in the
standards (or elsewhere) that says you can't put binary(**) data into a char
field? When I changed the field to a bytea, processing time was
significantly reduced.


bytea is the right thing. char will not support null (zero) bytes in
the data, and you may have character-set-encoding issues as well.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 23 '05 #2
Ron Snyder <sn****@roguewa ve.com> writes:
That's all just background for my real question-- is there anything in the
standards (or elsewhere) that says you can't put binary(**) data into a char
field? When I changed the field to a bytea, processing time was
significantly reduced.


bytea is the right thing. char will not support null (zero) bytes in
the data, and you may have character-set-encoding issues as well.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7518
by: G-Factor | last post by:
Hi all I've just started learning about saving files. I got bit of a problem. The following code gives me an error about incompatible types. (Cannot covert from class character to char *). I would appreciate it if anyone could either help me out, or direct me to an online resource site that has information on saving/loading classes. I have...
1
8739
by: Niko Korhonen | last post by:
I'm currently in the process of programming a multimedia tagging library in standard C++. However, I've stumbled across one or two unclear issues while working with the library. First of all, is it safe to store binary data in std::string? This question rose from my implementation with APEv2 tags. An APEv2 tag's field value can contain...
2
2510
by: John H | last post by:
Hi , Have a Visual C++ app that use odbc to access sql server database. Doing a select to get value of binary field and bind a char to that field as follows , field in database in binary(16) char lpResourceID; rc = SQLBindCol(hstmt, 1, SQL_C_CHAR, &lpResourceID, RESOURCE_ID_LEN_PLUS_NULL , &nLen1); and this works fine , however trying...
0
4819
by: sangui | last post by:
Helllo. this is biginner programmer. Would u check the file that I programed on c#(winform)? I tryed to make the program reading the binary file by C# programming but I failed. If u have more free time, would u program for ur skill up and me ^^; below contens is programed by unix c.
0
316
by: Ron Snyder | last post by:
I'm attempting to use spamassassin 3.0 (beta) with an SQL backend, and have identified one performance gain so far that makes PostgreSQL a good (IMO) candidate for the backend. I need some advice though on another aspect-- instead of storing each token as text in the database, the token is being sha1()'d and then possibly pack()'d. That's...
6
10030
by: SandyMan | last post by:
Hi, I am able to open a binary file for reading but can someone tell me as how to go about converting a Binary file to ASCII file using C. Thanks In Advance SandyMan
3
3390
by: tracethepath | last post by:
hello everybody... i am trying to make a project on binary files and that needs a function to modify data in a binary file. I have made the following class. class example { public: char name, number; void getdetails();
11
4280
by: David Mathog | last post by:
In the beginning (Kernighan & Ritchie 1978) there was fprintf, and unix write, but no fwrite. That is, no portable C method for writing binary data, only system calls which were OS specific. At C89 fwrite/fread were added to the C standard to allow portable binary IO to files. I wonder though why the choice was made to extend the unix...
3
5995
by: ist | last post by:
Hi, I am trying to get (and transfer over ASP.NET) some encrypted data from some MySQL fields. Since the data contains many unicode characters, I tried to get the data as a series of ASCII values, transfer those numeric values over ASP.NET. I had no problem doing this on my local computer, by getting the field with "cast(field as BINARY)"...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7974
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.