postgresql/contrib/int8
1999-05-25 22:43:53 +00:00
..
int8.c Another pgindent run. Sorry folks. 1999-05-25 22:43:53 +00:00
int8.source Initial 64-bit integer package. 1997-05-17 14:24:09 +00:00
itest.sql Initial 64-bit integer package. 1997-05-17 14:24:09 +00:00
Makefile From: Jun Kuwamura <juk@rccm.co.jp> 1998-04-22 04:16:46 +00:00
README Initial 64-bit integer package. 1997-05-17 14:24:09 +00:00

			Postgres int8

Thomas G. Lockhart <Thomas.Lockhart@jpl.nasa.gov>

This is a first attempt at 64-bit integer arithmetic for Postgres. The code
should support any 64-bit architecture and any 32-bit machine using a recent
GNU C compiler. At the moment, DEC-Alpha and Linux/gcc are explicitly
supported. The code uses "long long int" support in GNU C on 32-bit machines.
This type is an extension to ANSI-C, and may not appear on any other compiler.

The modules are built and installed as user-defined types, so destination
 directories are pointing away from the standard Postgres areas.

Other compilers and architectures should be supportable, so please let me know 
what changes were required to run on your machine, and I will fold those into 
this standard distribution.

Good luck!

			- Tom


			Installation

You will need to modify the Makefile paths to fit your machine. Since this
is packaged as a "user-installable" type, the libraries and source code
can reside outside of the standard Postgres areas.

If you are compiling on a DEC-Alpha, then the code might compile
and run without change. (I do a lot of code development on Alphas,
but do not have a Postgres installation to test).

  make
  make install
  psql dbname < int8.sql

If you are running gcc on a 32-bit machine, you will probably need to:
 - remove the extra library reference in the Makefile.
 - if there are unresolved symbols when you try running, then find
    the right library. The one I had chosen might be a clue.

If you are not running gcc on a 32-bit machine, you will need to:
 - redeclare the 64 bit data type.
 - modify the scanf and printf() arguments to use the appropriate
    64-bit int arguments.

On my Linux box, I had to find an extra library for the division function.
For Alpha boxes, both the DEC and GNU compilers should need "long int" only.
I have a reference to "__alpha" in the C source code, but have not tested it
 and am not certain that this is the correct pre-defined symbol for that machine.

itest.sql is a small test file which exercises some of the I/O, functions,
 and boolean operators.

int8:
	=
	<>
	<
	>
	<=
	>=

	-	unary minus
	+	addition
	-	subtraction
	*	multiplication
	/	division

	int4()	convert to 4-byte integer
	float8()	convert to double float

Routines defined are:

int64 *int8in(char *str);
char *int8out(int64 *val);

bool int8eq(int64 *val1, int64 *val2);
bool int8ne(int64 *val1, int64 *val2);
bool int8lt(int64 *val1, int64 *val2);
bool int8gt(int64 *val1, int64 *val2);
bool int8le(int64 *val1, int64 *val2);
bool int8ge(int64 *val1, int64 *val2);

bool int84eq(int64 *val1, int32 val2);
bool int84ne(int64 *val1, int32 val2);
bool int84lt(int64 *val1, int32 val2);
bool int84gt(int64 *val1, int32 val2);
bool int84le(int64 *val1, int32 val2);
bool int84ge(int64 *val1, int32 val2);

int64 *int8um(int64 *val);
int64 *int8pl(int64 *val1, int64 *val2);
int64 *int8mi(int64 *val1, int64 *val2);
int64 *int8mul(int64 *val1, int64 *val2);
int64 *int8div(int64 *val1, int64 *val2);

int64 *int48(int32 val);
int32 int84(int64 *val);

int64 *dtoi8(float8 *val);
float8 *i8tod(int64 *val);