@@ -2453,6 +2453,353 @@ drop aggregate sum$0(bigint);
24532453 " ) ;
24542454 }
24552455
2456+ #[ test]
2457+ fn goto_drop_routine_function ( ) {
2458+ assert_snapshot ! ( goto( "
2459+ create function foo() returns int as $$ select 1 $$ language sql;
2460+ drop routine foo$0();
2461+ " ) , @r"
2462+ ββΈ
2463+ 2 β create function foo() returns int as $$ select 1 $$ language sql;
2464+ β βββ 2. destination
2465+ 3 β drop routine foo();
2466+ β°β΄ β 1. source
2467+ " ) ;
2468+ }
2469+
2470+ #[ test]
2471+ fn goto_drop_routine_aggregate ( ) {
2472+ assert_snapshot ! ( goto( "
2473+ create aggregate myavg(int) (sfunc = int4_avg_accum, stype = _int8);
2474+ drop routine myavg$0(int);
2475+ " ) , @r"
2476+ ββΈ
2477+ 2 β create aggregate myavg(int) (sfunc = int4_avg_accum, stype = _int8);
2478+ β βββββ 2. destination
2479+ 3 β drop routine myavg(int);
2480+ β°β΄ β 1. source
2481+ " ) ;
2482+ }
2483+
2484+ #[ test]
2485+ fn goto_drop_routine_with_schema ( ) {
2486+ assert_snapshot ! ( goto( "
2487+ set search_path to public;
2488+ create function foo() returns int as $$ select 1 $$ language sql;
2489+ drop routine public.foo$0();
2490+ " ) , @r"
2491+ ββΈ
2492+ 3 β create function foo() returns int as $$ select 1 $$ language sql;
2493+ β βββ 2. destination
2494+ 4 β drop routine public.foo();
2495+ β°β΄ β 1. source
2496+ " ) ;
2497+ }
2498+
2499+ #[ test]
2500+ fn goto_drop_routine_defined_after ( ) {
2501+ assert_snapshot ! ( goto( "
2502+ drop routine foo$0();
2503+ create function foo() returns int as $$ select 1 $$ language sql;
2504+ " ) , @r"
2505+ ββΈ
2506+ 2 β drop routine foo();
2507+ β β 1. source
2508+ 3 β create function foo() returns int as $$ select 1 $$ language sql;
2509+ β°β΄ βββ 2. destination
2510+ " ) ;
2511+ }
2512+
2513+ #[ test]
2514+ fn goto_drop_routine_with_search_path ( ) {
2515+ assert_snapshot ! ( goto( "
2516+ create function foo() returns int as $$ select 1 $$ language sql;
2517+ set search_path to bar;
2518+ create function foo() returns int as $$ select 1 $$ language sql;
2519+ set search_path to default;
2520+ drop routine foo$0();
2521+ " ) , @r"
2522+ ββΈ
2523+ 2 β create function foo() returns int as $$ select 1 $$ language sql;
2524+ β βββ 2. destination
2525+ β‘
2526+ 6 β drop routine foo();
2527+ β°β΄ β 1. source
2528+ " ) ;
2529+ }
2530+
2531+ #[ test]
2532+ fn goto_drop_routine_overloaded ( ) {
2533+ assert_snapshot ! ( goto( "
2534+ create function add(complex) returns complex as $$ select null $$ language sql;
2535+ create function add(bigint) returns bigint as $$ select 1 $$ language sql;
2536+ drop routine add$0(complex);
2537+ " ) , @r"
2538+ ββΈ
2539+ 2 β create function add(complex) returns complex as $$ select null $$ language sql;
2540+ β βββ 2. destination
2541+ 3 β create function add(bigint) returns bigint as $$ select 1 $$ language sql;
2542+ 4 β drop routine add(complex);
2543+ β°β΄ β 1. source
2544+ " ) ;
2545+ }
2546+
2547+ #[ test]
2548+ fn goto_drop_routine_second_overload ( ) {
2549+ assert_snapshot ! ( goto( "
2550+ create function add(complex) returns complex as $$ select null $$ language sql;
2551+ create function add(bigint) returns bigint as $$ select 1 $$ language sql;
2552+ drop routine add$0(bigint);
2553+ " ) , @r"
2554+ ββΈ
2555+ 3 β create function add(bigint) returns bigint as $$ select 1 $$ language sql;
2556+ β βββ 2. destination
2557+ 4 β drop routine add(bigint);
2558+ β°β΄ β 1. source
2559+ " ) ;
2560+ }
2561+
2562+ #[ test]
2563+ fn goto_drop_routine_aggregate_overloaded ( ) {
2564+ assert_snapshot ! ( goto( "
2565+ create aggregate sum(complex) (sfunc = complex_add, stype = complex, initcond = '(0,0)');
2566+ create aggregate sum(bigint) (sfunc = bigint_add, stype = bigint, initcond = '0');
2567+ drop routine sum$0(complex);
2568+ " ) , @r"
2569+ ββΈ
2570+ 2 β create aggregate sum(complex) (sfunc = complex_add, stype = complex, initcond = '(0,0)');
2571+ β βββ 2. destination
2572+ 3 β create aggregate sum(bigint) (sfunc = bigint_add, stype = bigint, initcond = '0');
2573+ 4 β drop routine sum(complex);
2574+ β°β΄ β 1. source
2575+ " ) ;
2576+ }
2577+
2578+ #[ test]
2579+ fn goto_drop_routine_multiple ( ) {
2580+ assert_snapshot ! ( goto( "
2581+ create function foo() returns int as $$ select 1 $$ language sql;
2582+ create function bar() returns int as $$ select 1 $$ language sql;
2583+ drop routine foo(), bar$0();
2584+ " ) , @r"
2585+ ββΈ
2586+ 3 β create function bar() returns int as $$ select 1 $$ language sql;
2587+ β βββ 2. destination
2588+ 4 β drop routine foo(), bar();
2589+ β°β΄ β 1. source
2590+ " ) ;
2591+ }
2592+
2593+ #[ test]
2594+ fn goto_drop_procedure ( ) {
2595+ assert_snapshot ! ( goto( "
2596+ create procedure foo() language sql as $$ select 1 $$;
2597+ drop procedure foo$0();
2598+ " ) , @r"
2599+ ββΈ
2600+ 2 β create procedure foo() language sql as $$ select 1 $$;
2601+ β βββ 2. destination
2602+ 3 β drop procedure foo();
2603+ β°β΄ β 1. source
2604+ " ) ;
2605+ }
2606+
2607+ #[ test]
2608+ fn goto_drop_procedure_with_schema ( ) {
2609+ assert_snapshot ! ( goto( "
2610+ set search_path to public;
2611+ create procedure foo() language sql as $$ select 1 $$;
2612+ drop procedure public.foo$0();
2613+ " ) , @r"
2614+ ββΈ
2615+ 3 β create procedure foo() language sql as $$ select 1 $$;
2616+ β βββ 2. destination
2617+ 4 β drop procedure public.foo();
2618+ β°β΄ β 1. source
2619+ " ) ;
2620+ }
2621+
2622+ #[ test]
2623+ fn goto_drop_procedure_defined_after ( ) {
2624+ assert_snapshot ! ( goto( "
2625+ drop procedure foo$0();
2626+ create procedure foo() language sql as $$ select 1 $$;
2627+ " ) , @r"
2628+ ββΈ
2629+ 2 β drop procedure foo();
2630+ β β 1. source
2631+ 3 β create procedure foo() language sql as $$ select 1 $$;
2632+ β°β΄ βββ 2. destination
2633+ " ) ;
2634+ }
2635+
2636+ #[ test]
2637+ fn goto_drop_procedure_with_search_path ( ) {
2638+ assert_snapshot ! ( goto( "
2639+ create procedure foo() language sql as $$ select 1 $$;
2640+ set search_path to bar;
2641+ create procedure foo() language sql as $$ select 1 $$;
2642+ set search_path to default;
2643+ drop procedure foo$0();
2644+ " ) , @r"
2645+ ββΈ
2646+ 2 β create procedure foo() language sql as $$ select 1 $$;
2647+ β βββ 2. destination
2648+ β‘
2649+ 6 β drop procedure foo();
2650+ β°β΄ β 1. source
2651+ " ) ;
2652+ }
2653+
2654+ #[ test]
2655+ fn goto_drop_procedure_overloaded ( ) {
2656+ assert_snapshot ! ( goto( "
2657+ create procedure add(complex) language sql as $$ select null $$;
2658+ create procedure add(bigint) language sql as $$ select 1 $$;
2659+ drop procedure add$0(complex);
2660+ " ) , @r"
2661+ ββΈ
2662+ 2 β create procedure add(complex) language sql as $$ select null $$;
2663+ β βββ 2. destination
2664+ 3 β create procedure add(bigint) language sql as $$ select 1 $$;
2665+ 4 β drop procedure add(complex);
2666+ β°β΄ β 1. source
2667+ " ) ;
2668+ }
2669+
2670+ #[ test]
2671+ fn goto_drop_procedure_second_overload ( ) {
2672+ assert_snapshot ! ( goto( "
2673+ create procedure add(complex) language sql as $$ select null $$;
2674+ create procedure add(bigint) language sql as $$ select 1 $$;
2675+ drop procedure add$0(bigint);
2676+ " ) , @r"
2677+ ββΈ
2678+ 3 β create procedure add(bigint) language sql as $$ select 1 $$;
2679+ β βββ 2. destination
2680+ 4 β drop procedure add(bigint);
2681+ β°β΄ β 1. source
2682+ " ) ;
2683+ }
2684+
2685+ #[ test]
2686+ fn goto_drop_procedure_multiple ( ) {
2687+ assert_snapshot ! ( goto( "
2688+ create procedure foo() language sql as $$ select 1 $$;
2689+ create procedure bar() language sql as $$ select 1 $$;
2690+ drop procedure foo(), bar$0();
2691+ " ) , @r"
2692+ ββΈ
2693+ 3 β create procedure bar() language sql as $$ select 1 $$;
2694+ β βββ 2. destination
2695+ 4 β drop procedure foo(), bar();
2696+ β°β΄ β 1. source
2697+ " ) ;
2698+ }
2699+
2700+ #[ test]
2701+ fn goto_procedure_definition_returns_self ( ) {
2702+ assert_snapshot ! ( goto( "
2703+ create procedure foo$0() language sql as $$ select 1 $$;
2704+ " ) , @r"
2705+ ββΈ
2706+ 2 β create procedure foo() language sql as $$ select 1 $$;
2707+ β β¬ββ¬
2708+ β β β
2709+ β β 1. source
2710+ β°β΄ 2. destination
2711+ " ) ;
2712+ }
2713+
2714+ #[ test]
2715+ fn goto_call_procedure ( ) {
2716+ assert_snapshot ! ( goto( "
2717+ create procedure foo() language sql as $$ select 1 $$;
2718+ call foo$0();
2719+ " ) , @r"
2720+ ββΈ
2721+ 2 β create procedure foo() language sql as $$ select 1 $$;
2722+ β βββ 2. destination
2723+ 3 β call foo();
2724+ β°β΄ β 1. source
2725+ " ) ;
2726+ }
2727+
2728+ #[ test]
2729+ fn goto_call_procedure_with_schema ( ) {
2730+ assert_snapshot ! ( goto( "
2731+ create procedure public.foo() language sql as $$ select 1 $$;
2732+ call public.foo$0();
2733+ " ) , @r"
2734+ ββΈ
2735+ 2 β create procedure public.foo() language sql as $$ select 1 $$;
2736+ β βββ 2. destination
2737+ 3 β call public.foo();
2738+ β°β΄ β 1. source
2739+ " ) ;
2740+ }
2741+
2742+ #[ test]
2743+ fn goto_call_procedure_with_search_path ( ) {
2744+ assert_snapshot ! ( goto( "
2745+ set search_path to myschema;
2746+ create procedure foo() language sql as $$ select 1 $$;
2747+ call myschema.foo$0();
2748+ " ) , @r"
2749+ ββΈ
2750+ 3 β create procedure foo() language sql as $$ select 1 $$;
2751+ β βββ 2. destination
2752+ 4 β call myschema.foo();
2753+ β°β΄ β 1. source
2754+ " ) ;
2755+ }
2756+
2757+ #[ test]
2758+ fn goto_drop_routine_procedure ( ) {
2759+ assert_snapshot ! ( goto( "
2760+ create procedure foo() language sql as $$ select 1 $$;
2761+ drop routine foo$0();
2762+ " ) , @r"
2763+ ββΈ
2764+ 2 β create procedure foo() language sql as $$ select 1 $$;
2765+ β βββ 2. destination
2766+ 3 β drop routine foo();
2767+ β°β΄ β 1. source
2768+ " ) ;
2769+ }
2770+
2771+ #[ test]
2772+ fn goto_drop_routine_prefers_function_over_procedure ( ) {
2773+ assert_snapshot ! ( goto( "
2774+ create function foo() returns int as $$ select 1 $$ language sql;
2775+ create procedure foo() language sql as $$ select 1 $$;
2776+ drop routine foo$0();
2777+ " ) , @r"
2778+ ββΈ
2779+ 2 β create function foo() returns int as $$ select 1 $$ language sql;
2780+ β βββ 2. destination
2781+ 3 β create procedure foo() language sql as $$ select 1 $$;
2782+ 4 β drop routine foo();
2783+ β°β΄ β 1. source
2784+ " ) ;
2785+ }
2786+
2787+ #[ test]
2788+ fn goto_drop_routine_prefers_aggregate_over_procedure ( ) {
2789+ assert_snapshot ! ( goto( "
2790+ create aggregate foo(int) (sfunc = int4_avg_accum, stype = _int8);
2791+ create procedure foo(int) language sql as $$ select 1 $$;
2792+ drop routine foo$0(int);
2793+ " ) , @r"
2794+ ββΈ
2795+ 2 β create aggregate foo(int) (sfunc = int4_avg_accum, stype = _int8);
2796+ β βββ 2. destination
2797+ 3 β create procedure foo(int) language sql as $$ select 1 $$;
2798+ 4 β drop routine foo(int);
2799+ β°β΄ β 1. source
2800+ " ) ;
2801+ }
2802+
24562803 #[ test]
24572804 fn goto_table_alias_in_qualified_column ( ) {
24582805 assert_snapshot ! ( goto( "
0 commit comments