Fun_GetBarId.md 1.34 KB

Fun_GetBarId (function)

生成27位纯数字的ID 模仿后台Java代码生成

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

Parameters

# Mode Name Type
1 IN iIndex int

Body

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

Narrative

Business context: Numeric ID generator — header comment 生成27位纯数字的ID 模仿后台Java代码生成 ("27-digit numeric ID, mimics the Java backend"). The xly Java code mints all-numeric IDs by stitching together a timestamp and a counter; this is the SQL equivalent for procs that need to allocate IDs without a round-trip.

What it does: returns DATE_FORMAT(NOW(),'%y%m%d%H%i%s') (12 digits, yyMMddHHmmss) concatenated with LPAD(iIndex,2,'0'). Final length is 14 — not 27 as the comment claims. Caller is expected to supply a monotonically increasing iIndex per second to avoid collisions.

Invocation: Status: appears orphaned. No caller found in any channel (form-master sSqlStr, gdsmodule hooks, other routines, exhaustive xly-src grep, dynamic-dispatch search) — candidate for maintainer audit. Production ID minting happens Java-side via IdWorker/SnowflakeId, leaving this as a stale convenience.