@@ -1173,18 +1173,25 @@ PLySequence_ToArray(PLyObToDatum *arg, PyObject *plrv,
1173
1173
break ;
1174
1174
1175
1175
if (ndim == MAXDIM )
1176
- PLy_elog (ERROR , "number of array dimensions exceeds the maximum allowed (%d)" , MAXDIM );
1176
+ ereport (ERROR ,
1177
+ (errcode (ERRCODE_PROGRAM_LIMIT_EXCEEDED ),
1178
+ errmsg ("number of array dimensions exceeds the maximum allowed (%d)" ,
1179
+ MAXDIM )));
1177
1180
1178
1181
dims [ndim ] = PySequence_Length (pyptr );
1179
1182
if (dims [ndim ] < 0 )
1180
1183
PLy_elog (ERROR , "could not determine sequence length for function return value" );
1181
1184
1182
1185
if (dims [ndim ] > MaxAllocSize )
1183
- PLy_elog (ERROR , "array size exceeds the maximum allowed" );
1186
+ ereport (ERROR ,
1187
+ (errcode (ERRCODE_PROGRAM_LIMIT_EXCEEDED ),
1188
+ errmsg ("array size exceeds the maximum allowed" )));
1184
1189
1185
1190
len *= dims [ndim ];
1186
1191
if (len > MaxAllocSize )
1187
- PLy_elog (ERROR , "array size exceeds the maximum allowed" );
1192
+ ereport (ERROR ,
1193
+ (errcode (ERRCODE_PROGRAM_LIMIT_EXCEEDED ),
1194
+ errmsg ("array size exceeds the maximum allowed" )));
1188
1195
1189
1196
if (dims [ndim ] == 0 )
1190
1197
{
@@ -1210,7 +1217,9 @@ PLySequence_ToArray(PLyObToDatum *arg, PyObject *plrv,
1210
1217
if (ndim == 0 )
1211
1218
{
1212
1219
if (!PySequence_Check (plrv ))
1213
- PLy_elog (ERROR , "return value of function with array return type is not a Python sequence" );
1220
+ ereport (ERROR ,
1221
+ (errcode (ERRCODE_DATATYPE_MISMATCH ),
1222
+ errmsg ("return value of function with array return type is not a Python sequence" )));
1214
1223
1215
1224
ndim = 1 ;
1216
1225
len = dims [0 ] = PySequence_Length (plrv );
@@ -1256,7 +1265,8 @@ PLySequence_ToArray_recurse(PLyObToDatum *elm, PyObject *list,
1256
1265
1257
1266
if (PySequence_Length (list ) != dims [dim ])
1258
1267
ereport (ERROR ,
1259
- (errmsg ("wrong length of inner sequence: has length %d, but %d was expected" ,
1268
+ (errcode (ERRCODE_ARRAY_SUBSCRIPT_ERROR ),
1269
+ errmsg ("wrong length of inner sequence: has length %d, but %d was expected" ,
1260
1270
(int ) PySequence_Length (list ), dims [dim ]),
1261
1271
(errdetail ("To construct a multidimensional array, the inner sequences must all have the same length." ))));
1262
1272
0 commit comments