* Extract and parse reloptions from a pg_class tuple. * * This is a low-level routine, expected to be used by relcache code and * callers that do not have a table's relcache entry (e.g. autovacuum). For * other uses, consider grabbing the rd_options pointer from the relcache entry * instead. * * tupdesc is pg_class' tuple descriptor. amoptions is a pointer to the index * AM's options par
| 1407 | * index, or NULL otherwise. |
| 1408 | */ |
| 1409 | bytea * |
| 1410 | extractRelOptions(HeapTuple tuple, TupleDesc tupdesc, |
| 1411 | reloption_function amoptions) |
| 1412 | { |
| 1413 | bytea *options; |
| 1414 | bool isnull; |
| 1415 | Datum datum; |
| 1416 | Form_pg_class classForm; |
| 1417 | |
| 1418 | datum = fastgetattr(tuple, |
| 1419 | Anum_pg_class_reloptions, |
| 1420 | tupdesc, |
| 1421 | &isnull); |
| 1422 | if (isnull) |
| 1423 | return NULL; |
| 1424 | |
| 1425 | classForm = (Form_pg_class) GETSTRUCT(tuple); |
| 1426 | |
| 1427 | /* Parse into appropriate format; don't error out here */ |
| 1428 | switch (classForm->relkind) |
| 1429 | { |
| 1430 | case RELKIND_RELATION: |
| 1431 | case RELKIND_TOASTVALUE: |
| 1432 | case RELKIND_MATVIEW: |
| 1433 | case RELKIND_DIRECTORY_TABLE: |
| 1434 | options = table_reloptions((tamoptions_function)amoptions, datum, classForm->relkind, false); |
| 1435 | break; |
| 1436 | case RELKIND_PARTITIONED_TABLE: |
| 1437 | options = partitioned_table_reloptions(datum, false); |
| 1438 | break; |
| 1439 | case RELKIND_VIEW: |
| 1440 | options = view_reloptions(datum, false); |
| 1441 | break; |
| 1442 | case RELKIND_INDEX: |
| 1443 | case RELKIND_PARTITIONED_INDEX: |
| 1444 | options = index_reloptions((amoptions_function)amoptions, datum, false); |
| 1445 | break; |
| 1446 | case RELKIND_FOREIGN_TABLE: |
| 1447 | options = NULL; |
| 1448 | break; |
| 1449 | default: |
| 1450 | Assert(false); /* can't get here */ |
| 1451 | options = NULL; /* keep compiler quiet */ |
| 1452 | break; |
| 1453 | } |
| 1454 | |
| 1455 | return options; |
| 1456 | } |
| 1457 | |
| 1458 | static void |
| 1459 | parseRelOptionsInternal(Datum options, bool validate, |
no test coverage detected