| 223 | } |
| 224 | |
| 225 | static CursorData * |
| 226 | get_cursor(FunctionCallInfo fcinfo, bool should_be_assigned) |
| 227 | { |
| 228 | CursorData *cursor; |
| 229 | int cid; |
| 230 | |
| 231 | if (PG_ARGISNULL(0)) |
| 232 | ereport(ERROR, |
| 233 | (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED), |
| 234 | errmsg("cursor id is NULL"))); |
| 235 | |
| 236 | cid = PG_GETARG_INT32(0); |
| 237 | if (cid < 0 || cid >= MAX_CURSORS) |
| 238 | ereport(ERROR, |
| 239 | (errcode(ERRCODE_INVALID_PARAMETER_VALUE), |
| 240 | errmsg("value of cursor id is out of range"))); |
| 241 | |
| 242 | cursor = &cursors[cid]; |
| 243 | if (!cursor->assigned && should_be_assigned) |
| 244 | ereport(ERROR, |
| 245 | (errcode(ERRCODE_UNDEFINED_CURSOR), |
| 246 | errmsg("cursor is not valid"))); |
| 247 | |
| 248 | return cursor; |
| 249 | } |
| 250 | |
| 251 | /* |
| 252 | * CREATE FUNCTION dbms_sql.is_open(c int) RETURNS bool; |
no test coverage detected