* Gets the sum of the relation sizes and table sizes for the shards located on the current node * for a given table and array of shards. */
| 763 | * for a given table and array of shards. |
| 764 | */ |
| 765 | static void |
| 766 | GetPostgresRelationSizes(ArrayType *relationIds, int64 *totalRelationSize, |
| 767 | int64 *totalTableSize) |
| 768 | { |
| 769 | const char *query = |
| 770 | "SELECT SUM(pg_catalog.pg_total_relation_size(r))::int8, SUM(pg_catalog.pg_table_size(r))::int8 FROM unnest($1) r"; |
| 771 | |
| 772 | int nargs = 1; |
| 773 | Oid argTypes[1] = { OIDARRAYOID }; |
| 774 | Datum argValues[1] = { PointerGetDatum(relationIds) }; |
| 775 | |
| 776 | bool readOnly = true; |
| 777 | Datum resultValues[2]; |
| 778 | bool nullValues[2]; |
| 779 | int numResults = 2; |
| 780 | ExtensionExecuteMultiValueQueryWithArgsViaSPI(query, nargs, argTypes, argValues, NULL, |
| 781 | readOnly, |
| 782 | SPI_OK_SELECT, resultValues, nullValues, |
| 783 | numResults); |
| 784 | |
| 785 | *totalRelationSize = 0; |
| 786 | *totalTableSize = 0; |
| 787 | |
| 788 | if (nullValues[0] || nullValues[1]) |
| 789 | { |
| 790 | return; |
| 791 | } |
| 792 | |
| 793 | *totalRelationSize = DatumGetInt64(resultValues[0]); |
| 794 | *totalTableSize = DatumGetInt64(resultValues[1]); |
| 795 | } |
| 796 | |
| 797 | |
| 798 | /* |
no test coverage detected