Aggregate funcion: decimal_sum(X) ** ** Works like sum() except that it uses decimal arithmetic for unlimited ** precision. */
| 4977 | ** precision. |
| 4978 | */ |
| 4979 | static void decimalSumStep( |
| 4980 | sqlite3_context *context, |
| 4981 | int argc, |
| 4982 | sqlite3_value **argv |
| 4983 | ){ |
| 4984 | Decimal *p; |
| 4985 | Decimal *pArg; |
| 4986 | UNUSED_PARAMETER(argc); |
| 4987 | p = sqlite3_aggregate_context(context, sizeof(*p)); |
| 4988 | if( p==0 ) return; |
| 4989 | if( !p->isInit ){ |
| 4990 | p->isInit = 1; |
| 4991 | p->a = sqlite3_malloc(2); |
| 4992 | if( p->a==0 ){ |
| 4993 | p->oom = 1; |
| 4994 | }else{ |
| 4995 | p->a[0] = 0; |
| 4996 | } |
| 4997 | p->nDigit = 1; |
| 4998 | p->nFrac = 0; |
| 4999 | } |
| 5000 | if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; |
| 5001 | pArg = decimal_new(context, argv[0], 0, 0); |
| 5002 | decimal_add(p, pArg); |
| 5003 | decimal_free(pArg); |
| 5004 | } |
| 5005 | static void decimalSumInverse( |
| 5006 | sqlite3_context *context, |
| 5007 | int argc, |
nothing calls this directly
no test coverage detected