addFieldScript (procedure)
- Type: PROCEDURE
- Deterministic: NO
- SQL data access: CONTAINS SQL
Parameters
| # | Mode | Name | Type |
|---|---|---|---|
| 1 | IN | sColumnName |
varchar(100) |
| 2 | IN | sTableName |
varchar(100) |
| 3 | IN | sType |
varchar(100) |
| 4 | IN | sDefault |
varchar(100) |
| 5 | IN | sIsNull |
varchar(100) |
| 6 | IN | sComment |
varchar(255) |
Body
Body is not pre-cached. To inspect: mysql --defaults-file=~/.my.cnf -e 'SHOW CREATE PROCEDUREaddFieldScript'.
Narrative
Business context: DBA upgrade helper — adds a column to a table idempotently (no-op if the column already exists). Lives in the 2021-11-04 standalone backend upgrade bundle (script/标版/upgrade/20211104单独升级后台包需要执行/) where dozens of quoquotationslave cost-breakdown columns (印前/印刷/印后/主料/辅料/折扣 money + rate fields) get appended through it.
What it does: queries information_schema.COLUMNS for the <sTableName, sColumnName> pair in the current DATABASE(). If absent, builds an ALTER TABLE ... ADD COLUMN dynamic statement — synthesises a sensible DEFAULT clause per type family (varchar/int/decimal/bit/datetime), appends sIsNull and a COMMENT literal — then prepares/executes it. If the column already exists it returns silently.
Invocation: called from the upgrade script script/标版/upgrade/20211104单独升级后台包需要执行/zAddFieldAppendPro.sql (proc scriptSqlProAppend, ~30 column-adds against quoquotationslave). No live runtime caller, no form binding, no gdsmodule hook — strictly a migration helper. Status: maintained as part of upgrade tooling, not orphaned in the audit sense, but unused at runtime.