Hackathon!

hackathon-pgai-tirgul
Onur Tirtir 2023-05-11 10:19:50 +03:00
parent 07b8cd2634
commit cfb196c1c2
5 changed files with 45 additions and 0 deletions

1
configure vendored
View File

@ -6160,3 +6160,4 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi

View File

@ -86,6 +86,7 @@
#include "distributed/remote_commands.h"
#include "distributed/shard_rebalancer.h"
#include "distributed/shared_library_init.h"
#include "distributed/smart_hint.h"
#include "distributed/statistics_collection.h"
#include "distributed/subplan_execution.h"
#include "distributed/resource_lock.h"
@ -701,6 +702,8 @@ multi_log_hook(ErrorData *edata)
"involved in a distributed deadlock");
}
ReplaceCitusHintSmart(edata);
if (original_emit_log_hook)
{
original_emit_log_hook(edata);

View File

@ -0,0 +1,8 @@
#include "postgres.h"
#include "distributed/smart_hint.h"
void
ReplaceCitusHintSmart(ErrorData *edata)
{
edata->hint = pstrdup("Try to run the query with the smart hint");
}

View File

@ -1,3 +1,27 @@
-- citus--11.3-1--12.0-1
-- bump version to 12.0-1
CREATE OR REPLACE FUNCTION pg_catalog.get_cluster_stats()
RETURNS text
AS $$
DECLARE
cluster_stats text;
BEGIN
WITH citus_tables_arr AS (
SELECT array_agg(row_to_json(t.*)) d FROM public.citus_tables t
),
citus_nodes_arr AS (
SELECT array_agg(row_to_json(t.*)) d FROM pg_catalog.pg_dist_node t
),
key_values AS (
SELECT unnest(ARRAY['citus_tables', 'citus_nodes']) AS key,
unnest(ARRAY[to_json(citus_tables_arr.d), to_json(citus_nodes_arr.d)]::json[]) AS value
FROM citus_tables_arr, citus_nodes_arr
)
SELECT json_object_agg(key, value)::text INTO cluster_stats
FROM key_values;
RETURN cluster_stats;
END;
$$ LANGUAGE plpgsql;

View File

@ -0,0 +1,9 @@
#ifndef DISTRIBUTED_SMART_HINT_H
#define DISTRIBUTED_SMART_HINT_H
#include "postgres.h"
extern void ReplaceCitusHintSmart(ErrorData *edata);
#endif /* DISTRIBUTED_SMART_HINT_H */