* transformPartitionRangeBounds * This converts the expressions for range partition bounds from the raw * grammar representation to PartitionRangeDatum structs */
| 5361 | * grammar representation to PartitionRangeDatum structs |
| 5362 | */ |
| 5363 | static List * |
| 5364 | transformPartitionRangeBounds(ParseState *pstate, List *blist, |
| 5365 | Relation parent, PartitionKey key) |
| 5366 | { |
| 5367 | List *result = NIL; |
| 5368 | List *partexprs = get_partition_exprs(key); |
| 5369 | ListCell *lc; |
| 5370 | int i, |
| 5371 | j; |
| 5372 | |
| 5373 | i = j = 0; |
| 5374 | foreach(lc, blist) |
| 5375 | { |
| 5376 | Node *expr = lfirst(lc); |
| 5377 | PartitionRangeDatum *prd = NULL; |
| 5378 | |
| 5379 | /* |
| 5380 | * Infinite range bounds -- "minvalue" and "maxvalue" -- get passed in |
| 5381 | * as ColumnRefs. |
| 5382 | */ |
| 5383 | if (IsA(expr, ColumnRef)) |
| 5384 | { |
| 5385 | ColumnRef *cref = (ColumnRef *) expr; |
| 5386 | char *cname = NULL; |
| 5387 | |
| 5388 | /* |
| 5389 | * There should be a single field named either "minvalue" or |
| 5390 | * "maxvalue". |
| 5391 | */ |
| 5392 | if (list_length(cref->fields) == 1 && |
| 5393 | IsA(linitial(cref->fields), String)) |
| 5394 | cname = strVal(linitial(cref->fields)); |
| 5395 | |
| 5396 | if (cname == NULL) |
| 5397 | { |
| 5398 | /* |
| 5399 | * ColumnRef is not in the desired single-field-name form. For |
| 5400 | * consistency between all partition strategies, let the |
| 5401 | * expression transformation report any errors rather than |
| 5402 | * doing it ourselves. |
| 5403 | */ |
| 5404 | } |
| 5405 | else if (strcmp("minvalue", cname) == 0) |
| 5406 | { |
| 5407 | prd = makeNode(PartitionRangeDatum); |
| 5408 | prd->kind = PARTITION_RANGE_DATUM_MINVALUE; |
| 5409 | prd->value = NULL; |
| 5410 | } |
| 5411 | else if (strcmp("maxvalue", cname) == 0) |
| 5412 | { |
| 5413 | prd = makeNode(PartitionRangeDatum); |
| 5414 | prd->kind = PARTITION_RANGE_DATUM_MAXVALUE; |
| 5415 | prd->value = NULL; |
| 5416 | } |
| 5417 | } |
| 5418 | else if (IsA(expr, PartitionRangeDatum)) |
| 5419 | { |
| 5420 | /* |
no test coverage detected