* Extract an int64 value from a DefElem. */
| 187 | * Extract an int64 value from a DefElem. |
| 188 | */ |
| 189 | int64 |
| 190 | defGetInt64(DefElem *def) |
| 191 | { |
| 192 | if (def->arg == NULL) |
| 193 | ereport(ERROR, |
| 194 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 195 | errmsg("%s requires a numeric value", |
| 196 | def->defname))); |
| 197 | switch (nodeTag(def->arg)) |
| 198 | { |
| 199 | case T_Integer: |
| 200 | return (int64) intVal(def->arg); |
| 201 | case T_Float: |
| 202 | |
| 203 | /* |
| 204 | * Values too large for int4 will be represented as Float |
| 205 | * constants by the lexer. Accept these if they are valid int8 |
| 206 | * strings. |
| 207 | */ |
| 208 | return DatumGetInt64(DirectFunctionCall1(int8in, |
| 209 | CStringGetDatum(strVal(def->arg)))); |
| 210 | default: |
| 211 | ereport(ERROR, |
| 212 | (errcode(ERRCODE_SYNTAX_ERROR), |
| 213 | errmsg("%s requires a numeric value", |
| 214 | def->defname))); |
| 215 | } |
| 216 | return 0; /* keep compiler quiet */ |
| 217 | } |
| 218 | |
| 219 | /* |
| 220 | * Extract a possibly-qualified name (as a List of Strings) from a DefElem. |
no test coverage detected