Fn_fristPinyin.md 1.14 KB

Fn_fristPinyin (function)

根据首字母拼音查询

  • Type: FUNCTION
  • Returns: varchar(255)
  • Deterministic: NO
  • SQL data access: CONTAINS SQL

Parameters

# Mode Name Type
1 IN P_NAME varchar(255)

Body

Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE FUNCTIONFnfristPinyin'._

Narrative

Business context: Returns the first pinyin letter of a single Chinese character. Building block of Fn_find_pinyin, which assembles full pinyin abbreviations used as code prefixes by the Sp_Sis_GetMaxNo family.

What it does: if the input is single-byte ASCII it returns it unchanged. Otherwise converts the first byte of the GBK-encoded character to its hex value and bucket-matches it against the standard GBK pinyin-range boundary table to pick a letter A–Z. No I, U, V (Mandarin has no surname/initial in those ranges by convention). No table I/O.

Invocation: called only by Fn_find_pinyin and indirectly by the Sp_Sis_GetMaxNo* next-code generators that wrap it. A _copy1 backup of Fn_find_pinyin also references it.