|
| 1 | + Postgres int8 |
| 2 | + |
| 3 | +Thomas G. Lockhart <Thomas.Lockhart@jpl.nasa.gov> |
| 4 | + |
| 5 | +This is a first attempt at 64-bit integer arithmetic for Postgres. The code |
| 6 | +should support any 64-bit architecture and any 32-bit machine using a recent |
| 7 | +GNU C compiler. At the moment, DEC-Alpha and Linux/gcc are explicitly |
| 8 | +supported. The code uses "long long int" support in GNU C on 32-bit machines. |
| 9 | +This type is an extension to ANSI-C, and may not appear on any other compiler. |
| 10 | + |
| 11 | +The modules are built and installed as user-defined types, so destination |
| 12 | + directories are pointing away from the standard Postgres areas. |
| 13 | + |
| 14 | +Other compilers and architectures should be supportable, so please let me know |
| 15 | +what changes were required to run on your machine, and I will fold those into |
| 16 | +this standard distribution. |
| 17 | + |
| 18 | +Good luck! |
| 19 | + |
| 20 | + - Tom |
| 21 | + |
| 22 | + |
| 23 | + Installation |
| 24 | + |
| 25 | +You will need to modify the Makefile paths to fit your machine. Since this |
| 26 | +is packaged as a "user-installable" type, the libraries and source code |
| 27 | +can reside outside of the standard Postgres areas. |
| 28 | + |
| 29 | +If you are compiling on a DEC-Alpha, then the code might compile |
| 30 | +and run without change. (I do a lot of code development on Alphas, |
| 31 | +but do not have a Postgres installation to test). |
| 32 | + |
| 33 | + make |
| 34 | + make install |
| 35 | + psql dbname < int8.sql |
| 36 | + |
| 37 | +If you are running gcc on a 32-bit machine, you will probably need to: |
| 38 | + - remove the extra library reference in the Makefile. |
| 39 | + - if there are unresolved symbols when you try running, then find |
| 40 | + the right library. The one I had chosen might be a clue. |
| 41 | + |
| 42 | +If you are not running gcc on a 32-bit machine, you will need to: |
| 43 | + - redeclare the 64 bit data type. |
| 44 | + - modify the scanf and printf() arguments to use the appropriate |
| 45 | + 64-bit int arguments. |
| 46 | + |
| 47 | +On my Linux box, I had to find an extra library for the division function. |
| 48 | +For Alpha boxes, both the DEC and GNU compilers should need "long int" only. |
| 49 | +I have a reference to "__alpha" in the C source code, but have not tested it |
| 50 | + and am not certain that this is the correct pre-defined symbol for that machine. |
| 51 | + |
| 52 | +itest.sql is a small test file which exercises some of the I/O, functions, |
| 53 | + and boolean operators. |
| 54 | + |
| 55 | +int8: |
| 56 | + = |
| 57 | + <> |
| 58 | + < |
| 59 | + > |
| 60 | + <= |
| 61 | + >= |
| 62 | + |
| 63 | + - unary minus |
| 64 | + + addition |
| 65 | + - subtraction |
| 66 | + * multiplication |
| 67 | + / division |
| 68 | + |
| 69 | + int4() convert to 4-byte integer |
| 70 | + float8() convert to double float |
| 71 | + |
| 72 | +Routines defined are: |
| 73 | + |
| 74 | +int64 *int8in(char *str); |
| 75 | +char *int8out(int64 *val); |
| 76 | + |
| 77 | +bool int8eq(int64 *val1, int64 *val2); |
| 78 | +bool int8ne(int64 *val1, int64 *val2); |
| 79 | +bool int8lt(int64 *val1, int64 *val2); |
| 80 | +bool int8gt(int64 *val1, int64 *val2); |
| 81 | +bool int8le(int64 *val1, int64 *val2); |
| 82 | +bool int8ge(int64 *val1, int64 *val2); |
| 83 | + |
| 84 | +bool int84eq(int64 *val1, int32 val2); |
| 85 | +bool int84ne(int64 *val1, int32 val2); |
| 86 | +bool int84lt(int64 *val1, int32 val2); |
| 87 | +bool int84gt(int64 *val1, int32 val2); |
| 88 | +bool int84le(int64 *val1, int32 val2); |
| 89 | +bool int84ge(int64 *val1, int32 val2); |
| 90 | + |
| 91 | +int64 *int8um(int64 *val); |
| 92 | +int64 *int8pl(int64 *val1, int64 *val2); |
| 93 | +int64 *int8mi(int64 *val1, int64 *val2); |
| 94 | +int64 *int8mul(int64 *val1, int64 *val2); |
| 95 | +int64 *int8div(int64 *val1, int64 *val2); |
| 96 | + |
| 97 | +int64 *int48(int32 val); |
| 98 | +int32 int84(int64 *val); |
| 99 | + |
| 100 | +int64 *dtoi8(float8 *val); |
| 101 | +float8 *i8tod(int64 *val); |
0 commit comments