# openHalo

> MySQL-compatible Postgres 14 branch

---

LLMS index: [llms.txt](/llms.txt)

---

[OpenHalo](https://www.openhalo.org/) is an open-source PostgreSQL kernel that provides MySQL wire-protocol compatibility.

openHalo is based on PostgreSQL 14.18 and provides wire-level compatibility with MySQL 5.7.32-log / 8.0.
Pigsty delivers it through `pg_mode: mysql` and the `openhalo` package alias.

Pigsty supports OpenHalo deployment on all supported Linux platforms.

- RPM build spec: [github.com/pgsty/rpm/rpmbuild/specs/openhalodb.spec](https://github.com/pgsty/rpm/blob/main/rpmbuild/SPECS/openhalodb.spec)
- DEB build spec: [github.com/pgsty/deb/debbuild/openhalodb](https://github.com/pgsty/deb/tree/main/debbuild/openhalodb)


------

## Quick Start

Prepare a Pigsty working directory with the [**standard installation flow**](/docs/setup/install), then select the [`halo`](/docs/conf/mysql) template.

The configuration commands below apply to current development sources containing `conf/fork/halo.yml`; `-c halo` and `-c fork/halo` are equivalent.
The [v4.5.0 release package](https://github.com/pgsty/pigsty/blob/v4.5.0/conf/mysql.yml) still uses `-c mysql`.
In current development sources, `-c mysql` selects the native MySQL example.

```bash
./configure -c halo     # Use the OpenHalo template
./deploy.yml            # Install (change passwords in pigsty.yml before production use)
```


------

## Cluster Config

```yaml
pg-meta:
  hosts:
    10.10.10.10: { pg_seq: 1, pg_role: primary }
  vars:
    pg_cluster: pg-meta
    pg_users:
      - {name: dbuser_meta ,password: DBUser.Meta   ,pgbouncer: true ,roles: [dbrole_admin]    ,comment: pigsty admin user }
      - {name: dbuser_view ,password: DBUser.Viewer ,pgbouncer: true ,roles: [dbrole_readonly] ,comment: read-only viewer for meta database }
    pg_databases:
      - {name: postgres, extensions: [ aux_mysql ]} # mysql-compatible database
      - {name: meta ,baseline: cmdb.sql ,comment: pigsty meta database ,schemas: [pigsty]}
    pg_hba_rules:
      - {user: dbuser_view , db: all ,addr: infra ,auth: pwd ,title: 'allow grafana dashboard access cmdb from infra nodes'}
    pg_crontab: [ '00 01 * * * /pg/bin/pg-backup full' ] # full backup at 1 AM daily

    # OpenHalo specific settings
    pg_mode: mysql
    pg_version: 14
    pg_packages: [ openhalo, pgsql-common ]
```

The OpenHalo extension `aux_mysql` provides functions and types for MySQL compatibility.
Enable it in the `postgres` database for full compatibility behavior.

- aux_mysql 1.5: MySQL Supplementary Extension
- `/usr/halo-14/share/postgresql/extension/aux_mysql.control`
- `$libdir/mysm`, `mysm.so`


------

## Usage

MySQL connections use the `postgres` database.
A MySQL database maps to a PostgreSQL schema.
Thus, `use mysql` selects the `mysql` schema in the `postgres` database.

Use the PostgreSQL usernames and passwords for MySQL access.

### Client Access

OpenHalo listens on port `3306` for MySQL wire protocol clients.

The [`fork/halo`](/docs/conf/mysql/) template installs the OpenHalo server. Install a compatible MySQL client separately before using the command below.

```bash
mysql -h 127.0.0.1 -u dbuser_dba
```

OpenHalo upstream currently reports that Navicat works normally on this port.
IntelliJ DataGrip may fail.


--------

## Compatibility Parameters

Pigsty sets `database_compat_mode` to `mysql` by default.
To adjust compatibility behavior, use settings such as:

```ini
mysql.listener_on = true                        # enable MySQL listener; restart required
mysql.port = 3306                               # second_port for MySQL mode; restart required
mysql.halo_mysql_version = '5.7.32-log'         # restart required
mysql.ci_collation = true                       # restart required
mysql.explicit_defaults_for_timestamp = false   # restart required
mysql.auto_rollback_tx_on_error = false         # restart required
```


------

## Patch Notes

Pigsty packages the [OpenHalo](https://github.com/pgsty/openHalo) kernel from [HaloTech-Co-Ltd/openHalo](https://github.com/HaloTech-Co-Ltd/openHalo) with these adjustments:

- Restore default database name from `halo0root` to `postgres`
- Remove `1.0.` prefix in the default version string, keeping `14.18`
- Adjust default config to enable MySQL compatibility and listen on `3306`

Pigsty does not provide warranty coverage for OpenHalo kernel behavior.
Contact the upstream vendor about kernel-specific issues.

> **Warning**: This kernel is currently in beta1. Evaluate its risks carefully before production use.


--------

## Available Extensions

The table lists selected non-Contrib extensions for reference. [Query the target instance](/docs/pgsql/kernel/#versions) to confirm actual availability and versions.

| Extension | Version | Description |
|:----------|:--------|:------------|
| [aux_mysql](/ext/e/aux_mysql) | `1.5` | MySQL Supplementary Extension |
| hstore_plpython2u | `1.0` | transform between hstore and plpython2u |
| hstore_plpythonu | `1.0` | transform between hstore and plpythonu |
| jsonb_plpython2u | `1.0` | transform between jsonb and plpython2u |
| jsonb_plpythonu | `1.0` | transform between jsonb and plpythonu |
| ltree_plpython2u | `1.0` | transform between ltree and plpython2u |
| ltree_plpythonu | `1.0` | transform between ltree and plpythonu |
{.full-width}
