|
9 | 9 | * |
10 | 10 | *****************************************************************************/ |
11 | 11 |
|
| 12 | +HTAB *deactivated_queries = NULL; |
| 13 | + |
12 | 14 | static void deform_matrix(Datum datum, double **matrix); |
13 | 15 | static void deform_vector(Datum datum, double *vector, int *nelems); |
14 | 16 | static ArrayType *form_matrix(double **matrix, int nrows, int ncols); |
@@ -832,3 +834,46 @@ my_simple_heap_update(Relation relation, ItemPointer otid, HeapTuple tup) |
832 | 834 | break; |
833 | 835 | } |
834 | 836 | } |
| 837 | + |
| 838 | +/* Creates a storage for hashes of deactivated queries */ |
| 839 | +void |
| 840 | +init_deactivated_queries_storage(void) |
| 841 | +{ |
| 842 | + HASHCTL hash_ctl; |
| 843 | + |
| 844 | + /* Create the hashtable proper */ |
| 845 | + MemSet(&hash_ctl, 0, sizeof(hash_ctl)); |
| 846 | + hash_ctl.keysize = sizeof(int); |
| 847 | + hash_ctl.entrysize = sizeof(int); |
| 848 | + deactivated_queries = hash_create("aqo_deactivated_queries", |
| 849 | + 128, /* start small and extend */ |
| 850 | + &hash_ctl, |
| 851 | + HASH_ELEM); |
| 852 | +} |
| 853 | + |
| 854 | +/* Destroys the storage for hash of deactivated queries */ |
| 855 | +void |
| 856 | +fini_deactivated_queries_storage(void) |
| 857 | +{ |
| 858 | + hash_destroy(deactivated_queries); |
| 859 | + deactivated_queries = NULL; |
| 860 | +} |
| 861 | + |
| 862 | +/* Checks whether the query with given hash is deactivated */ |
| 863 | +bool |
| 864 | +query_is_deactivated(int query_hash) |
| 865 | +{ |
| 866 | + bool found; |
| 867 | + |
| 868 | + hash_search(deactivated_queries, &query_hash, HASH_FIND, &found); |
| 869 | + return found; |
| 870 | +} |
| 871 | + |
| 872 | +/* Adds given query hash into the set of hashes of deactivated queries*/ |
| 873 | +void |
| 874 | +add_deactivated_query(int query_hash) |
| 875 | +{ |
| 876 | + bool found; |
| 877 | + |
| 878 | + hash_search(deactivated_queries, &query_hash, HASH_ENTER, &found); |
| 879 | +} |
0 commit comments