On Wed, Dec 15, 2004 at 11:08:29PM -0500, Ron Peterson wrote: > How are bytea values encoded internally? > > Or maybe a better question would be what is the proper way to access > bytea data from within a C function? Are there utility functions for > reading the bytea data as a stream of scalar values, for example?
If I do something like: bytea* bindat = PG_GETARG_BYTEA_P(0); int32 total_data_bytes = VARSIZE( bindat ) - VARHDRSZ; char* test_cp = (char*)palloc( total_data_bytes ); memcpy( test_cp, VARDATA( bindat ), total_data_bytes ); fwrite( test_cp, 1, total_data_bytes, test_fp ); I get the exactly the same binary file out that I stuffed into PostgreSQL by octal escaping it and doing an insert. Am I asking for trouble writing code like this? -- Ron Peterson Network & Systems Manager Mount Holyoke College http://www.mtholyoke.edu/~rpeterso ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org