* Extract a numeric value (actually double) from a DefElem. */
| 82 | * Extract a numeric value (actually double) from a DefElem. |
| 83 | */ |
| 84 | double |
| 85 | defGetNumeric(DefElem *def) |
| 86 | { |
| 87 | if (def->arg == NULL) |
| 88 | ereport(ERROR, |
| 89 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 90 | errmsg("%s requires a numeric value", |
| 91 | def->defname))); |
| 92 | switch (nodeTag(def->arg)) |
| 93 | { |
| 94 | case T_Integer: |
| 95 | return (double) intVal(def->arg); |
| 96 | case T_Float: |
| 97 | return floatVal(def->arg); |
| 98 | default: |
| 99 | ereport(ERROR, |
| 100 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 101 | errmsg("%s requires a numeric value", |
| 102 | def->defname))); |
| 103 | } |
| 104 | return 0; /* keep compiler quiet */ |
| 105 | } |
| 106 | |
| 107 | /* |
| 108 | * Extract a boolean value from a DefElem. |
no test coverage detected