Return-Path: pg_adm@postgres.berkeley.edu
Received: by postgres.Berkeley.EDU (5.61/1.29)
	id AA13145; Wed, 16 Jun 93 01:21:47 -0700
Date: Wed, 16 Jun 93 01:21:47 -0700
From: fernando@afrodita.etsimo.uniovi.es (Fernando Ariznavarreta)
Subject: Problems with C++ and float aligment in postgres.
To: postgres@postgres.berkeley.edu
Sender: pg_adm@postgres.berkeley.edu
To: post_questions@postgres.Berkeley.EDU (Postgres Equipo de Desarrollo.)
Cc: postgres@postgres.Berkeley.EDU (Postgres Lista de correo.)
Message-Id: <9306160808.AA02277@afrodita.etsimo.uniovi.es>
X-Envelope-To: post_questions@postgres.berkeley.edu,
 postgres@postgres.berkeley.edu
X-Mailer: ELM [version 2.4 PL20]
Content-Type: text
Content-Transfer-Encoding: 7BIT
Content-Length: 2258

	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:fernando@etsimo.uniovi.es
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

