Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions content/compatibility/sql_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ the [system table compatibility](../system_table) page.
| uuid | Yes | [UUID Documentation](/docs/references/datatypes/uuid) |
| xml | No | |

CedarDB also supports additional integer types not present in PostgreSQL:
`tinyint` (`int1`, 8-bit signed), and unsigned variants `uint1`, `uint2`, `uint4`, `uint8`.
See the [Integer Documentation](/docs/references/datatypes/integer) for details.

### Operators & Functions

#### Logical
Expand Down
11 changes: 8 additions & 3 deletions content/references/datatypes/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ We additionally support additional ones popularized by PostgreSQL (e.g., `array`
The complete list of supported data types in CedarDB is as follows:

* [`array`](array)
* [`bigint`](integer)
* [`bigint`](integer) (`int8`)
* [`bignumeric`](numeric)
* [`bit`](bit)
* [`bit varying`](bit)
Expand All @@ -24,16 +24,21 @@ The complete list of supported data types in CedarDB is as follows:
* [`double precision`](float)
* [`enum`](enums)
* [`float`](float)
* [`integer`](integer)
* [`integer`](integer) (`int4`)
* [`interval`](interval)
* [`json`](json)
* [`jsonb`](json)
* [`numeric`](numeric)
* [`real`](float)
* [`smallint`](integer)
* [`smallint`](integer) (`int2`)
* [`tinyint`](integer) (`int1`)
* [`text`](text)
* [`time`](time)
* [`timestamp`](timestamp) (with or without time zone)
* [`uint1`](integer)
* [`uint2`](integer)
* [`uint4`](integer)
* [`uint8`](integer)
* [`uuid`](uuid)
* [`varchar`](text)
* [`vector`](vector)
30 changes: 20 additions & 10 deletions content/references/datatypes/integer.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ weight: 10
---

Integers are whole numbers that are typically used to represent counters or identifiers.
CedarDB supports three different widths of integers:
* A two-byte `smallint`,
* a four-byte `integer`,
* and an eight-byte `bigint`.
CedarDB supports the following signed integer types:

* A one-byte `tinyint` (alias: `int1`),
* a two-byte `smallint` (alias: `int2`),
* a four-byte `integer` (alias: `int4`),
* and an eight-byte `bigint` (alias: `int8`).

CedarDB also supports unsigned variants for each width: `uint1`, `uint2`, `uint4`, and `uint8`.

## Usage Example
```sql
Expand All @@ -31,11 +35,18 @@ select id from example;

## Value Range

| Type | Min | Max |
|------------|----------:|-----------:|
| `smallint` | $-2^{15}$ | $2^{15}-1$ |
| `integer` | $-2^{31}$ | $2^{31}-1$ |
| `bigint` | $-2^{63}$ | $2^{63}-1$ |
### Signed

| Type | Min | Max |
|---------------------|----------:|-----------:|
| `tinyint` (`int1`) | $-2^{7}$ | $2^{7}-1$ |
| `smallint` (`int2`) | $-2^{15}$ | $2^{15}-1$ |
| `integer` (`int4`) | $-2^{31}$ | $2^{31}-1$ |
| `bigint` (`int8`) | $-2^{63}$ | $2^{63}-1$ |
| `uint1` | $0$ | $2^{8}-1$ |
| `uint2` | $0$ | $2^{16}-1$ |
| `uint4` | $0$ | $2^{32}-1$ |
| `uint8` | $0$ | $2^{64}-1$ |

Storing values outside of the supported ranges will result in an overflow exception.
Operations on integers are range checked, so that e.g., numeric overflows will never cause wrong results.
Expand Down Expand Up @@ -83,4 +94,3 @@ select i::bigint + i from integers;
2147483648
(2 rows)
```