| 1888 | } |
| 1889 | |
| 1890 | static bool |
| 1891 | ExecHashJoinReloadHashTable(HashJoinState *hjstate) |
| 1892 | { |
| 1893 | HashState *hashState = (HashState *) innerPlanState(hjstate); |
| 1894 | HashJoinTable hashtable = hjstate->hj_HashTable; |
| 1895 | TupleTableSlot *slot; |
| 1896 | uint32 hashvalue; |
| 1897 | int curbatch = hashtable->curbatch; |
| 1898 | int nmoved = 0; |
| 1899 | #if 0 |
| 1900 | int orignbatch = hashtable->nbatch; |
| 1901 | #endif |
| 1902 | |
| 1903 | /* |
| 1904 | * Reload the hash table with the new inner batch (which could be empty) |
| 1905 | */ |
| 1906 | ExecHashTableReset(hashState, hashtable); |
| 1907 | |
| 1908 | if (hashtable->innerBatchFile[curbatch] != NULL) |
| 1909 | { |
| 1910 | /* Rewind batch file */ |
| 1911 | if (BufFileSeek(hashtable->innerBatchFile[curbatch], 0, 0, SEEK_SET) != 0) |
| 1912 | { |
| 1913 | ereport(ERROR, (errcode_for_file_access(), |
| 1914 | errmsg("could not access temporary file"))); |
| 1915 | } |
| 1916 | |
| 1917 | for (;;) |
| 1918 | { |
| 1919 | CHECK_FOR_INTERRUPTS(); |
| 1920 | |
| 1921 | if (QueryFinishPending) |
| 1922 | return false; |
| 1923 | |
| 1924 | slot = ExecHashJoinGetSavedTuple(hjstate, |
| 1925 | hashtable->innerBatchFile[curbatch], |
| 1926 | &hashvalue, |
| 1927 | hjstate->hj_HashTupleSlot); |
| 1928 | if (!slot) |
| 1929 | break; |
| 1930 | |
| 1931 | /* |
| 1932 | * NOTE: some tuples may be sent to future batches. Also, it is |
| 1933 | * possible for hashtable->nbatch to be increased here! |
| 1934 | */ |
| 1935 | if (!ExecHashTableInsert(hashState, hashtable, slot, hashvalue)) |
| 1936 | nmoved++; |
| 1937 | } |
| 1938 | |
| 1939 | /* |
| 1940 | * after we build the hash table, the inner batch file is no longer |
| 1941 | * needed |
| 1942 | */ |
| 1943 | if (hjstate->js.ps.instrument && hjstate->js.ps.instrument->need_cdb) |
| 1944 | { |
| 1945 | Assert(hashtable->stats); |
| 1946 | hashtable->stats->batchstats[curbatch].innerfilesize = |
| 1947 | BufFileSize(hashtable->innerBatchFile[curbatch]); |
no test coverage detected