850 query->params.count++; |
850 query->params.count++; |
851 |
851 |
852 // allocate the vertical storage for the parameters |
852 // allocate the vertical storage for the parameters |
853 if (0 |
853 if (0 |
854 |
854 |
855 // !(query->params.types = calloc(query->params.count, sizeof(Oid))) |
855 || !(query->params.types = calloc(query->params.count, sizeof(Oid))) |
856 || !(query->params.values = calloc(query->params.count, sizeof(char *))) |
856 || !(query->params.values = calloc(query->params.count, sizeof(char *))) |
857 || !(query->params.lengths = calloc(query->params.count, sizeof(int))) |
857 || !(query->params.lengths = calloc(query->params.count, sizeof(int))) |
858 || !(query->params.formats = calloc(query->params.count, sizeof(int))) |
858 || !(query->params.formats = calloc(query->params.count, sizeof(int))) |
859 ) |
859 ) |
860 ERROR("calloc"); |
860 ERROR("calloc"); |
861 |
861 |
862 // transform |
862 // transform |
863 for (param = params->list, idx = 0; param->type; param++, idx++) { |
863 for (param = params->list, idx = 0; param->type; param++, idx++) { |
864 // `types` stays NULL |
864 // `set for NULLs, otherwise not |
865 // query->params.types[idx] = 0; |
865 query->params.types[idx] = param->data_raw ? 0 : 16; |
866 |
866 |
867 // values |
867 // values |
868 query->params.values[idx] = param->data_raw; |
868 query->params.values[idx] = param->data_raw; |
869 |
869 |
870 // lengths |
870 // lengths |
871 query->params.lengths[idx] = param->length; |
871 query->params.lengths[idx] = param->length; |
872 |
872 |
873 // formats, binary if length is nonzero |
873 // formats, binary if length is nonzero, but text for NULLs |
874 query->params.formats[idx] = param->length ? 1 : 0; |
874 query->params.formats[idx] = param->length && param->data_raw ? 1 : 0; |
875 } |
875 } |
876 |
876 |
877 // result format |
877 // result format |
878 switch (params->result_fmt) { |
878 switch (params->result_fmt) { |
879 case EVSQL_FMT_TEXT: |
879 case EVSQL_FMT_TEXT: |