aboutsummaryrefslogtreecommitdiff
path: root/src/pq/pq_query_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pq/pq_query_helper.c')
-rw-r--r--src/pq/pq_query_helper.c112
1 files changed, 80 insertions, 32 deletions
diff --git a/src/pq/pq_query_helper.c b/src/pq/pq_query_helper.c
index 0199f21dd..71421345f 100644
--- a/src/pq/pq_query_helper.c
+++ b/src/pq/pq_query_helper.c
@@ -962,15 +962,18 @@ struct GNUNET_PQ_QueryParam
962GNUNET_PQ_query_param_array_bool ( 962GNUNET_PQ_query_param_array_bool (
963 unsigned int num, 963 unsigned int num,
964 const bool *elements, 964 const bool *elements,
965 const struct GNUNET_PQ_Context *db) 965 struct GNUNET_PQ_Context *db)
966{ 966{
967 Oid oid;
968 GNUNET_assert (GNUNET_OK ==
969 GNUNET_PQ_get_oid_by_name (db,"bool",&oid));
967 return query_param_array_generic (num, 970 return query_param_array_generic (num,
968 true, 971 true,
969 elements, 972 elements,
970 NULL, 973 NULL,
971 sizeof(bool), 974 sizeof(bool),
972 array_of_bool, 975 array_of_bool,
973 db->oids[GNUNET_PQ_DATATYPE_BOOL]); 976 oid);
974} 977}
975 978
976 979
@@ -978,15 +981,18 @@ struct GNUNET_PQ_QueryParam
978GNUNET_PQ_query_param_array_uint16 ( 981GNUNET_PQ_query_param_array_uint16 (
979 unsigned int num, 982 unsigned int num,
980 const uint16_t *elements, 983 const uint16_t *elements,
981 const struct GNUNET_PQ_Context *db) 984 struct GNUNET_PQ_Context *db)
982{ 985{
986 Oid oid;
987 GNUNET_assert (GNUNET_OK ==
988 GNUNET_PQ_get_oid_by_name (db,"int2",&oid));
983 return query_param_array_generic (num, 989 return query_param_array_generic (num,
984 true, 990 true,
985 elements, 991 elements,
986 NULL, 992 NULL,
987 sizeof(uint16_t), 993 sizeof(uint16_t),
988 array_of_uint16, 994 array_of_uint16,
989 db->oids[GNUNET_PQ_DATATYPE_INT2]); 995 oid);
990} 996}
991 997
992 998
@@ -994,15 +1000,18 @@ struct GNUNET_PQ_QueryParam
994GNUNET_PQ_query_param_array_uint32 ( 1000GNUNET_PQ_query_param_array_uint32 (
995 unsigned int num, 1001 unsigned int num,
996 const uint32_t *elements, 1002 const uint32_t *elements,
997 const struct GNUNET_PQ_Context *db) 1003 struct GNUNET_PQ_Context *db)
998{ 1004{
1005 Oid oid;
1006 GNUNET_assert (GNUNET_OK ==
1007 GNUNET_PQ_get_oid_by_name (db,"int4",&oid));
999 return query_param_array_generic (num, 1008 return query_param_array_generic (num,
1000 true, 1009 true,
1001 elements, 1010 elements,
1002 NULL, 1011 NULL,
1003 sizeof(uint32_t), 1012 sizeof(uint32_t),
1004 array_of_uint32, 1013 array_of_uint32,
1005 db->oids[GNUNET_PQ_DATATYPE_INT4]); 1014 oid);
1006} 1015}
1007 1016
1008 1017
@@ -1010,15 +1019,18 @@ struct GNUNET_PQ_QueryParam
1010GNUNET_PQ_query_param_array_uint64 ( 1019GNUNET_PQ_query_param_array_uint64 (
1011 unsigned int num, 1020 unsigned int num,
1012 const uint64_t *elements, 1021 const uint64_t *elements,
1013 const struct GNUNET_PQ_Context *db) 1022 struct GNUNET_PQ_Context *db)
1014{ 1023{
1024 Oid oid;
1025 GNUNET_assert (GNUNET_OK ==
1026 GNUNET_PQ_get_oid_by_name (db,"int8",&oid));
1015 return query_param_array_generic (num, 1027 return query_param_array_generic (num,
1016 true, 1028 true,
1017 elements, 1029 elements,
1018 NULL, 1030 NULL,
1019 sizeof(uint64_t), 1031 sizeof(uint64_t),
1020 array_of_uint64, 1032 array_of_uint64,
1021 db->oids[GNUNET_PQ_DATATYPE_INT8]); 1033 oid);
1022} 1034}
1023 1035
1024 1036
@@ -1027,15 +1039,18 @@ GNUNET_PQ_query_param_array_bytes (
1027 unsigned int num, 1039 unsigned int num,
1028 const void *elements, 1040 const void *elements,
1029 const size_t *sizes, 1041 const size_t *sizes,
1030 const struct GNUNET_PQ_Context *db) 1042 struct GNUNET_PQ_Context *db)
1031{ 1043{
1044 Oid oid;
1045 GNUNET_assert (GNUNET_OK ==
1046 GNUNET_PQ_get_oid_by_name (db,"bytea",&oid));
1032 return query_param_array_generic (num, 1047 return query_param_array_generic (num,
1033 true, 1048 true,
1034 elements, 1049 elements,
1035 sizes, 1050 sizes,
1036 0, 1051 0,
1037 array_of_byte, 1052 array_of_byte,
1038 db->oids[GNUNET_PQ_DATATYPE_BYTEA]); 1053 oid);
1039} 1054}
1040 1055
1041 1056
@@ -1044,15 +1059,18 @@ GNUNET_PQ_query_param_array_ptrs_bytes (
1044 unsigned int num, 1059 unsigned int num,
1045 const void *elements[], 1060 const void *elements[],
1046 const size_t *sizes, 1061 const size_t *sizes,
1047 const struct GNUNET_PQ_Context *db) 1062 struct GNUNET_PQ_Context *db)
1048{ 1063{
1064 Oid oid;
1065 GNUNET_assert (GNUNET_OK ==
1066 GNUNET_PQ_get_oid_by_name (db,"bytea",&oid));
1049 return query_param_array_generic (num, 1067 return query_param_array_generic (num,
1050 false, 1068 false,
1051 elements, 1069 elements,
1052 sizes, 1070 sizes,
1053 0, 1071 0,
1054 array_of_byte, 1072 array_of_byte,
1055 db->oids[GNUNET_PQ_DATATYPE_BYTEA]); 1073 oid);
1056} 1074}
1057 1075
1058 1076
@@ -1061,15 +1079,18 @@ GNUNET_PQ_query_param_array_bytes_same_size (
1061 unsigned int num, 1079 unsigned int num,
1062 const void *elements, 1080 const void *elements,
1063 size_t same_size, 1081 size_t same_size,
1064 const struct GNUNET_PQ_Context *db) 1082 struct GNUNET_PQ_Context *db)
1065{ 1083{
1084 Oid oid;
1085 GNUNET_assert (GNUNET_OK ==
1086 GNUNET_PQ_get_oid_by_name (db,"bytea",&oid));
1066 return query_param_array_generic (num, 1087 return query_param_array_generic (num,
1067 true, 1088 true,
1068 elements, 1089 elements,
1069 NULL, 1090 NULL,
1070 same_size, 1091 same_size,
1071 array_of_byte, 1092 array_of_byte,
1072 db->oids[GNUNET_PQ_DATATYPE_BYTEA]); 1093 oid);
1073} 1094}
1074 1095
1075 1096
@@ -1078,15 +1099,18 @@ GNUNET_PQ_query_param_array_ptrs_bytes_same_size (
1078 unsigned int num, 1099 unsigned int num,
1079 const void *elements[], 1100 const void *elements[],
1080 size_t same_size, 1101 size_t same_size,
1081 const struct GNUNET_PQ_Context *db) 1102 struct GNUNET_PQ_Context *db)
1082{ 1103{
1104 Oid oid;
1105 GNUNET_assert (GNUNET_OK ==
1106 GNUNET_PQ_get_oid_by_name (db,"bytea",&oid));
1083 return query_param_array_generic (num, 1107 return query_param_array_generic (num,
1084 false, 1108 false,
1085 elements, 1109 elements,
1086 NULL, 1110 NULL,
1087 same_size, 1111 same_size,
1088 array_of_byte, 1112 array_of_byte,
1089 db->oids[GNUNET_PQ_DATATYPE_BYTEA]); 1113 oid);
1090} 1114}
1091 1115
1092 1116
@@ -1094,15 +1118,18 @@ struct GNUNET_PQ_QueryParam
1094GNUNET_PQ_query_param_array_string ( 1118GNUNET_PQ_query_param_array_string (
1095 unsigned int num, 1119 unsigned int num,
1096 const char *elements, 1120 const char *elements,
1097 const struct GNUNET_PQ_Context *db) 1121 struct GNUNET_PQ_Context *db)
1098{ 1122{
1123 Oid oid;
1124 GNUNET_assert (GNUNET_OK ==
1125 GNUNET_PQ_get_oid_by_name (db,"varchar",&oid));
1099 return query_param_array_generic (num, 1126 return query_param_array_generic (num,
1100 true, 1127 true,
1101 elements, 1128 elements,
1102 NULL, 1129 NULL,
1103 0, 1130 0,
1104 array_of_string, 1131 array_of_string,
1105 db->oids[GNUNET_PQ_DATATYPE_VARCHAR]); 1132 oid);
1106} 1133}
1107 1134
1108 1135
@@ -1110,15 +1137,18 @@ struct GNUNET_PQ_QueryParam
1110GNUNET_PQ_query_param_array_ptrs_string ( 1137GNUNET_PQ_query_param_array_ptrs_string (
1111 unsigned int num, 1138 unsigned int num,
1112 const char *elements[], 1139 const char *elements[],
1113 const struct GNUNET_PQ_Context *db) 1140 struct GNUNET_PQ_Context *db)
1114{ 1141{
1142 Oid oid;
1143 GNUNET_assert (GNUNET_OK ==
1144 GNUNET_PQ_get_oid_by_name (db,"varchar",&oid));
1115 return query_param_array_generic (num, 1145 return query_param_array_generic (num,
1116 false, 1146 false,
1117 elements, 1147 elements,
1118 NULL, 1148 NULL,
1119 0, 1149 0,
1120 array_of_string, 1150 array_of_string,
1121 db->oids[GNUNET_PQ_DATATYPE_VARCHAR]); 1151 oid);
1122} 1152}
1123 1153
1124 1154
@@ -1126,15 +1156,18 @@ struct GNUNET_PQ_QueryParam
1126GNUNET_PQ_query_param_array_abs_time ( 1156GNUNET_PQ_query_param_array_abs_time (
1127 unsigned int num, 1157 unsigned int num,
1128 const struct GNUNET_TIME_Absolute *elements, 1158 const struct GNUNET_TIME_Absolute *elements,
1129 const struct GNUNET_PQ_Context *db) 1159 struct GNUNET_PQ_Context *db)
1130{ 1160{
1161 Oid oid;
1162 GNUNET_assert (GNUNET_OK ==
1163 GNUNET_PQ_get_oid_by_name (db,"int8",&oid));
1131 return query_param_array_generic (num, 1164 return query_param_array_generic (num,
1132 true, 1165 true,
1133 elements, 1166 elements,
1134 NULL, 1167 NULL,
1135 sizeof(struct GNUNET_TIME_Absolute), 1168 sizeof(struct GNUNET_TIME_Absolute),
1136 array_of_abs_time, 1169 array_of_abs_time,
1137 db->oids[GNUNET_PQ_DATATYPE_INT8]); 1170 oid);
1138} 1171}
1139 1172
1140 1173
@@ -1142,15 +1175,18 @@ struct GNUNET_PQ_QueryParam
1142GNUNET_PQ_query_param_array_ptrs_abs_time ( 1175GNUNET_PQ_query_param_array_ptrs_abs_time (
1143 unsigned int num, 1176 unsigned int num,
1144 const struct GNUNET_TIME_Absolute *elements[], 1177 const struct GNUNET_TIME_Absolute *elements[],
1145 const struct GNUNET_PQ_Context *db) 1178 struct GNUNET_PQ_Context *db)
1146{ 1179{
1180 Oid oid;
1181 GNUNET_assert (GNUNET_OK ==
1182 GNUNET_PQ_get_oid_by_name (db,"int8",&oid));
1147 return query_param_array_generic (num, 1183 return query_param_array_generic (num,
1148 false, 1184 false,
1149 elements, 1185 elements,
1150 NULL, 1186 NULL,
1151 sizeof(struct GNUNET_TIME_Absolute), 1187 sizeof(struct GNUNET_TIME_Absolute),
1152 array_of_abs_time, 1188 array_of_abs_time,
1153 db->oids[GNUNET_PQ_DATATYPE_INT8]); 1189 oid);
1154} 1190}
1155 1191
1156 1192
@@ -1158,15 +1194,18 @@ struct GNUNET_PQ_QueryParam
1158GNUNET_PQ_query_param_array_rel_time ( 1194GNUNET_PQ_query_param_array_rel_time (
1159 unsigned int num, 1195 unsigned int num,
1160 const struct GNUNET_TIME_Relative *elements, 1196 const struct GNUNET_TIME_Relative *elements,
1161 const struct GNUNET_PQ_Context *db) 1197 struct GNUNET_PQ_Context *db)
1162{ 1198{
1199 Oid oid;
1200 GNUNET_assert (GNUNET_OK ==
1201 GNUNET_PQ_get_oid_by_name (db,"int8",&oid));
1163 return query_param_array_generic (num, 1202 return query_param_array_generic (num,
1164 true, 1203 true,
1165 elements, 1204 elements,
1166 NULL, 1205 NULL,
1167 sizeof(struct GNUNET_TIME_Relative), 1206 sizeof(struct GNUNET_TIME_Relative),
1168 array_of_abs_time, 1207 array_of_abs_time,
1169 db->oids[GNUNET_PQ_DATATYPE_INT8]); 1208 oid);
1170} 1209}
1171 1210
1172 1211
@@ -1174,15 +1213,18 @@ struct GNUNET_PQ_QueryParam
1174GNUNET_PQ_query_param_array_ptrs_rel_time ( 1213GNUNET_PQ_query_param_array_ptrs_rel_time (
1175 unsigned int num, 1214 unsigned int num,
1176 const struct GNUNET_TIME_Relative *elements[], 1215 const struct GNUNET_TIME_Relative *elements[],
1177 const struct GNUNET_PQ_Context *db) 1216 struct GNUNET_PQ_Context *db)
1178{ 1217{
1218 Oid oid;
1219 GNUNET_assert (GNUNET_OK ==
1220 GNUNET_PQ_get_oid_by_name (db,"int8",&oid));
1179 return query_param_array_generic (num, 1221 return query_param_array_generic (num,
1180 false, 1222 false,
1181 elements, 1223 elements,
1182 NULL, 1224 NULL,
1183 sizeof(struct GNUNET_TIME_Relative), 1225 sizeof(struct GNUNET_TIME_Relative),
1184 array_of_abs_time, 1226 array_of_abs_time,
1185 db->oids[GNUNET_PQ_DATATYPE_INT8]); 1227 oid);
1186} 1228}
1187 1229
1188 1230
@@ -1190,15 +1232,18 @@ struct GNUNET_PQ_QueryParam
1190GNUNET_PQ_query_param_array_timestamp ( 1232GNUNET_PQ_query_param_array_timestamp (
1191 unsigned int num, 1233 unsigned int num,
1192 const struct GNUNET_TIME_Timestamp *elements, 1234 const struct GNUNET_TIME_Timestamp *elements,
1193 const struct GNUNET_PQ_Context *db) 1235 struct GNUNET_PQ_Context *db)
1194{ 1236{
1237 Oid oid;
1238 GNUNET_assert (GNUNET_OK ==
1239 GNUNET_PQ_get_oid_by_name (db,"int8",&oid));
1195 return query_param_array_generic (num, 1240 return query_param_array_generic (num,
1196 true, 1241 true,
1197 elements, 1242 elements,
1198 NULL, 1243 NULL,
1199 sizeof(struct GNUNET_TIME_Timestamp), 1244 sizeof(struct GNUNET_TIME_Timestamp),
1200 array_of_timestamp, 1245 array_of_timestamp,
1201 db->oids[GNUNET_PQ_DATATYPE_INT8]); 1246 oid);
1202} 1247}
1203 1248
1204 1249
@@ -1206,15 +1251,18 @@ struct GNUNET_PQ_QueryParam
1206GNUNET_PQ_query_param_array_ptrs_timestamp ( 1251GNUNET_PQ_query_param_array_ptrs_timestamp (
1207 unsigned int num, 1252 unsigned int num,
1208 const struct GNUNET_TIME_Timestamp *elements[], 1253 const struct GNUNET_TIME_Timestamp *elements[],
1209 const struct GNUNET_PQ_Context *db) 1254 struct GNUNET_PQ_Context *db)
1210{ 1255{
1256 Oid oid;
1257 GNUNET_assert (GNUNET_OK ==
1258 GNUNET_PQ_get_oid_by_name (db,"int8",&oid));
1211 return query_param_array_generic (num, 1259 return query_param_array_generic (num,
1212 false, 1260 false,
1213 elements, 1261 elements,
1214 NULL, 1262 NULL,
1215 sizeof(struct GNUNET_TIME_Timestamp), 1263 sizeof(struct GNUNET_TIME_Timestamp),
1216 array_of_timestamp, 1264 array_of_timestamp,
1217 db->oids[GNUNET_PQ_DATATYPE_INT8]); 1265 oid);
1218} 1266}
1219 1267
1220 1268