pg_pinyin
Overview
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2200 | pg_pinyin | No | Yes | No | Yes | No | Yes | pinyin |
| Related | pg_cjk_parser pg_jieba pg_bigm zhparser pgroonga pg_tokenizer icu_ext pg_xenophile gb18030_2022 |
|---|
optional tokenizer-input overload can integrate with pg_search.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.0.8 | 1817161514 | pg_pinyin | - |
| RPM | PIGSTY | 0.0.8 | 1817161514 | pg_pinyin_$v | - |
| DEB | PIGSTY | 0.0.8 | 1817161514 | postgresql-$v-pinyin | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.0.8 el8.x86_64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.0.8 el8.x86_64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.0.8 el8.x86_64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.0.8 el8.x86_64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el8.x86_64.rpm
| PIGSTY 0.0.8 el8.x86_64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el8.x86_64.rpm
|
| el8.aarch64 | PIGSTY 0.0.8 el8.aarch64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.0.8 el8.aarch64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.0.8 el8.aarch64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.0.8 el8.aarch64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el8.aarch64.rpm
| PIGSTY 0.0.8 el8.aarch64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el8.aarch64.rpm
|
| el9.x86_64 | PIGSTY 0.0.8 el9.x86_64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.0.8 el9.x86_64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.0.8 el9.x86_64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.0.8 el9.x86_64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el9.x86_64.rpm
| PIGSTY 0.0.8 el9.x86_64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el9.x86_64.rpm
|
| el9.aarch64 | PIGSTY 0.0.8 el9.aarch64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.0.8 el9.aarch64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.0.8 el9.aarch64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.0.8 el9.aarch64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el9.aarch64.rpm
| PIGSTY 0.0.8 el9.aarch64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el9.aarch64.rpm
|
| el10.x86_64 | PIGSTY 0.0.8 el10.x86_64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.0.8 el10.x86_64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.0.8 el10.x86_64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.0.8 el10.x86_64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el10.x86_64.rpm
| PIGSTY 0.0.8 el10.x86_64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el10.x86_64.rpm
|
| el10.aarch64 | PIGSTY 0.0.8 el10.aarch64.pg18 : pg_pinyin_18 pg_pinyin_18-0.0.8-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.0.8 el10.aarch64.pg17 : pg_pinyin_17 pg_pinyin_17-0.0.8-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.0.8 el10.aarch64.pg16 : pg_pinyin_16 pg_pinyin_16-0.0.8-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.0.8 el10.aarch64.pg15 : pg_pinyin_15 pg_pinyin_15-0.0.8-1PGSTY.el10.aarch64.rpm
| PIGSTY 0.0.8 el10.aarch64.pg14 : pg_pinyin_14 pg_pinyin_14-0.0.8-1PGSTY.el10.aarch64.rpm
|
| d12.x86_64 | PIGSTY 0.0.8 d12.x86_64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.0.8 d12.x86_64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.0.8 d12.x86_64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.0.8 d12.x86_64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~bookworm_amd64.deb
| PIGSTY 0.0.8 d12.x86_64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~bookworm_amd64.deb
|
| d12.aarch64 | PIGSTY 0.0.8 d12.aarch64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.0.8 d12.aarch64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.0.8 d12.aarch64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.0.8 d12.aarch64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~bookworm_arm64.deb
| PIGSTY 0.0.8 d12.aarch64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~bookworm_arm64.deb
|
| d13.x86_64 | PIGSTY 0.0.8 d13.x86_64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~trixie_amd64.deb
| PIGSTY 0.0.8 d13.x86_64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~trixie_amd64.deb
| PIGSTY 0.0.8 d13.x86_64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~trixie_amd64.deb
| PIGSTY 0.0.8 d13.x86_64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~trixie_amd64.deb
| PIGSTY 0.0.8 d13.x86_64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~trixie_amd64.deb
|
| d13.aarch64 | PIGSTY 0.0.8 d13.aarch64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~trixie_arm64.deb
| PIGSTY 0.0.8 d13.aarch64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~trixie_arm64.deb
| PIGSTY 0.0.8 d13.aarch64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~trixie_arm64.deb
| PIGSTY 0.0.8 d13.aarch64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~trixie_arm64.deb
| PIGSTY 0.0.8 d13.aarch64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~trixie_arm64.deb
|
| u22.x86_64 | PIGSTY 0.0.8 u22.x86_64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~jammy_amd64.deb
| PIGSTY 0.0.8 u22.x86_64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~jammy_amd64.deb
| PIGSTY 0.0.8 u22.x86_64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~jammy_amd64.deb
| PIGSTY 0.0.8 u22.x86_64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~jammy_amd64.deb
| PIGSTY 0.0.8 u22.x86_64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~jammy_amd64.deb
|
| u22.aarch64 | PIGSTY 0.0.8 u22.aarch64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~jammy_arm64.deb
| PIGSTY 0.0.8 u22.aarch64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~jammy_arm64.deb
| PIGSTY 0.0.8 u22.aarch64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~jammy_arm64.deb
| PIGSTY 0.0.8 u22.aarch64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~jammy_arm64.deb
| PIGSTY 0.0.8 u22.aarch64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~jammy_arm64.deb
|
| u24.x86_64 | PIGSTY 0.0.8 u24.x86_64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~noble_amd64.deb
| PIGSTY 0.0.8 u24.x86_64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~noble_amd64.deb
| PIGSTY 0.0.8 u24.x86_64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~noble_amd64.deb
| PIGSTY 0.0.8 u24.x86_64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~noble_amd64.deb
| PIGSTY 0.0.8 u24.x86_64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~noble_amd64.deb
|
| u24.aarch64 | PIGSTY 0.0.8 u24.aarch64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~noble_arm64.deb
| PIGSTY 0.0.8 u24.aarch64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~noble_arm64.deb
| PIGSTY 0.0.8 u24.aarch64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~noble_arm64.deb
| PIGSTY 0.0.8 u24.aarch64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~noble_arm64.deb
| PIGSTY 0.0.8 u24.aarch64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~noble_arm64.deb
|
| u26.x86_64 | PIGSTY 0.0.8 u26.x86_64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~resolute_amd64.deb
| PIGSTY 0.0.8 u26.x86_64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~resolute_amd64.deb
| PIGSTY 0.0.8 u26.x86_64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~resolute_amd64.deb
| PIGSTY 0.0.8 u26.x86_64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~resolute_amd64.deb
| PIGSTY 0.0.8 u26.x86_64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~resolute_amd64.deb
|
| u26.aarch64 | PIGSTY 0.0.8 u26.aarch64.pg18 : postgresql-18-pinyin postgresql-18-pinyin_0.0.8-1PGSTY~resolute_arm64.deb
| PIGSTY 0.0.8 u26.aarch64.pg17 : postgresql-17-pinyin postgresql-17-pinyin_0.0.8-1PGSTY~resolute_arm64.deb
| PIGSTY 0.0.8 u26.aarch64.pg16 : postgresql-16-pinyin postgresql-16-pinyin_0.0.8-1PGSTY~resolute_arm64.deb
| PIGSTY 0.0.8 u26.aarch64.pg15 : postgresql-15-pinyin postgresql-15-pinyin_0.0.8-1PGSTY~resolute_arm64.deb
| PIGSTY 0.0.8 u26.aarch64.pg14 : postgresql-14-pinyin postgresql-14-pinyin_0.0.8-1PGSTY~resolute_arm64.deb
|
Build
You can build the RPM / DEB packages for pg_pinyin using pig build:
Install
You can install pg_pinyin directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
Sources:
- pg_pinyin v0.0.8 README
- pg_pinyin v0.0.8 control file
- 0.0.7 to 0.0.8 upgrade SQL
- 0.0.8 parallel read-only regression
- 0.0.8 implementation
pg_pinyin romanizes Chinese text and exposes tokenizer and query helpers for search applications. Use pg_pinyin to create stable Pinyin search keys, tokenize Han text, or expand Pinyin input into a pg_search regular-expression query.
Version 0.0.8 fixes read-only SPI access for parallel romanization, tokenizer conversion and suffix-dictionary queries. It uses pgrx 0.19.3 and supports PostgreSQL 14-18 plus PostgreSQL 19 beta4. The provided 0.0.7-to-0.0.8 migration makes no SQL object changes; the runtime fix is in the shared library. After installing the new extension files, run ALTER EXTENSION pg_pinyin UPDATE TO ‘0.0.8’. Pigsty package metadata is maintained separately.
Create the Extension
CREATE EXTENSION pg_pinyin;
The extension is relocatable and does not require shared_preload_libraries or a server restart.
Romanize Text
Romanize character by character or use word-aware segmentation:
SELECT pinyin_char_romanize('重庆');
SELECT pinyin_word_romanize('重庆火锅');
SELECT pinyin_word_romanize('重庆火锅', '_custom');
The optional suffix selects custom dictionary tables; it is not an output separator. For example, _custom selects pinyin.pinyin_mapping_custom and pinyin.pinyin_words_custom, whose entries override the built-in dictionaries. Word mode uses dictionary segmentation to resolve contextual pronunciations. Clear the suffix cache after modifying these tables using public.pinyin_clear_suffix_cache(’_custom’).
Use pg_search Tokenizer Input
Word romanization also accepts a pg_search tokenizer result when that extension is available:
SELECT pinyin_word_romanize(
description::pdb.icu::text[]
)
FROM documents;
The overload returns romanized text; it does not expose a row-per-token API. Use the plain-text overload when pg_search tokenization is not required.
Build a pg_search Query
When pg_search was installed before pg_pinyin, pg_pinyin provides a typed overload that returns pdb.query:
SELECT *
FROM documents
WHERE id @@@ pinyin_regex_phrase(
'chong qing',
slope => 1,
max_expansions => 64,
generated_pinyin => true
);
If pg_search is absent, the same entry point is installed as an error-reporting stub rather than silently returning a different type. Install dependencies in the intended order and test the function signature after upgrades.
Object Index
- pinyin_char_romanize(text [, suffix]) returns character-based Pinyin text.
- pinyin_word_romanize(text [, suffix]) returns dictionary-segmented Pinyin text.
- pinyin_word_romanize(tokenizer_input [, suffix]) accepts a pg_search tokenizer result.
- pinyin_regex_phrase(text, slope, max_expansions, generated_pinyin) constructs a pg_search Pinyin phrase query when that integration is available.
- pinyin_regex_phrase_patterns is an internal pattern-building helper; prefer the public query function.
Operational Notes
The extension ships generated character and word dictionaries in its pinyin schema. Treat those tables as extension-managed data rather than application tables. Romanization is normalization, not translation, and ambiguous or domain-specific readings may require application-side review.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)