Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Dependency missed with a function used as default value

Aperta
#191 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
go, postgresql
Ambito
databases

Direzione di ricerca

Riprodurre il problema con le definizioni della funzione e della tabella PostgreSQL fornite, quindi tracciare la convalida delle dipendenze e l’ordine delle istruzioni di migrazione che produce le istruzioni DROP FUNCTION e DROP TABLE. Il lavoro è completato quando l’uso esplicito della funzione nel valore predefinito della colonna viene riconosciuto come una dipendenza e la convalida produce un ordine sicuro senza l’errore segnalato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Hello,

I have an issue with the following schema:

CREATE FUNCTION public.demo() RETURNS text
    LANGUAGE plpgsql
    AS $$
declare
begin
   return 'hi';
end;

$$;

CREATE TABLE public.demo2 (
    demo3 text DEFAULT public.demo() NOT NULL
);

The dependency between demo2 and demo is not detected, validation is not passing.

validating migration plan: running migration plan: executing migration statement: {DROP FUNCTION "public"."demo"() 3s 3s [HAS_UNTRACKABLE_DEPENDENCIES: Dependencies, i.e. other functions used in the function body, of non-sql functions cannot be tracked. As a result, we cannot guarantee that function dependencies are ordered properly relative to this statement. For drops, this means you need to ensure that all functions this function depends on are dropped after this statement.]}: ERROR: cannot drop function demo() because other objects depend on it (SQLSTATE 2BP01)

With generated statements lookings like this:

        {
            DDL:         "DROP FUNCTION \"public\".\"demo\"()",
            Timeout:     3000000000,
            LockTimeout: 3000000000,
            Hazards:     {
                {Type:"HAS_UNTRACKABLE_DEPENDENCIES", Message:"Dependencies, i.e. other functions used in the function body, of non-sql functions cannot be tracked. As a result, we cannot guarantee that function dependencies are ordered properly relative to this statement. For drops, this means you need to ensure that all functions this function depends on are dropped after this statement."},
            },
        },
        {
            DDL:         "DROP TABLE \"public\".\"demo2\"",
            Timeout:     1200000000000,
            LockTimeout: 3000000000,
            Hazards:     {
                {Type:"DELETES_DATA", Message:"Deletes all rows in the table (and the table itself)"},
            },
        },

I do understand that there are complexities tracking dependencies of functions, but could a 'obvious' dependency like that one, when the function is explicitly used somewhere else be detected?

I tried to dig a into the code but I was not sure where / how to find relevents part, if you have some pointers I would be happy to make a PR to improve that :)

Lingua principale
Go
Stelle
894
Fork
85
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di stripe/pg-schema-diff

Tutte le issue di stripe/pg-schema-diff

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.