Subject: Problems with C++ and float aligment in postgres.

From: [email-masked] (Fernando Ariznavarreta)
Date: Wed, 16 Jun 93 01:21:47 -0700

Hello,
	We are developing a program that uses postgres database.
	It is a C++ program and implements an X/Motif interface.
	We had to make some minor changes to the postgres header files in
order to let them compile properly.
	We are using a porting of version 4.01 to HP UX 8.07.
	The problem is that in the header files there is a pragma 
#pragma HP_ALIGN that changes the natural aligment of floating point numbers
in our machine (an HP Apollo 720) to match that used by postgres in Sun machines
The problem is that the C++ compiler doesn't have that pragma and complains 
about it. I removed the pragma and the program seems to work anyway.

My question is: Is this pragma neccessary at all?
I don't understand very well why you need the pragma in the libpq frontend
part, as long as you use ascii transfer between the frontend and the server.

May I ignore the pragma?

I made this question to the HP porting person and here is what he answered:

**************************

If you do not have the #pragma then you are in for a lot of work!! Originally,
I intended to work around the alignment problem but this proved very difficult.The purpose of the pragma is to align DOUBLEs onto 8-byte boundaries.

It's true that it should only be needed when info is passed to the database.
However, due to the internal organisation of a postgres database it is not
that simple. For example, it is not just the alignment of the double within
a tuple, but then the tuple must be aligned within the relation and then
the relation aligned within the page and the page in the database. This means
a lot of reworking of the postgres data structures eg. to account for the
extra space created when alignment occurs.

With this in mind I don't have a solution! My only suggestion is to contact
Berkeley and ask them where alignment needs to be done or do a lot of work!

***********************

Any idea will be welcome:

-- 
Fernando Ariznavarreta Fernandez       E-Mail:[email-masked]
Dpto. Explotacion y Prospeccion de Minas     Phone: +34 8 510 4267
School of Mines. University of Oviedo               +34 8 510 4336
Independencia, 13                            Fax:   +34 8 510 4242
Oviedo 33004, SPAIN                                 +34 8 510 4340