Code Review Videos > How I Fixed > How I Fixed: — missing source code In JetBrains DataGrip

How I Fixed: — missing source code In JetBrains DataGrip

Bit of an odd one today. I was browsing around a production system (my own, thank you), and tracing my way through some Postgres routines trying to track down why a query seemed to be returning an unexpected / outdated result.

When I opened one of the routines I was met with this:

-- auto-generated definition
create function my_function(search_term text... etc)
    stable
    language sql
as
$$
begin
-- missing source code
end;

$$;

alter function my_function(text ...) owner to ...;
Code language: SQL (Structured Query Language) (sql)

The real content of this function is not important. What is important is the bit in the middle:

-- missing source code

Now, what’s really unusual about this is that the function couldn’t possibly be really missing the source code / query text, as the query itself works. Heck, the site would have been 500 erroring without that running, I’m sure.

And this wasn’t the only query impacted.

Literally every routine I opened, custom or default, showed the same thing. For example, the armor function (not entirely sure what that does, but it’s not one of mine:

jetbrains datagrip postgres missing source code

It actually may be that the out-of-the-box / provided functions are always missing the source code. I really have no idea, as I have never seen this before.

All in, a bit weird.

The Fix

The fix to this problem is pretty straightforward.

You need to tell DataGrip to “forget cached schemas”.

I suspect this fix is the same in any of the Jetbrains IDEs.

forget cached schemas to clear missing source code error in datagrip

Excuse all the whited out / redacted stuff. Some of the info in here is pretty sensitive.

Anyway, do that bit and you should then see your query text again.

The one caveat to this may be if you have some insane long running query that locks your database and then the necessary introspection process can’t run until that query finishes stops any of this from working. That, I suspect, is a problem fairly specific to me and entirely of my own making. But that’s a different issue.

For what it’s worth, I read that back and it sounds like you might need to do some “introspection” mumbo jumbo. Not so. That is all handled by DataGrip behind the scenes when you are browsing around your database tables.

datagrip introspecting your database

Anyway, that solved it for me.

Eventually.

2 thoughts on “How I Fixed: — missing source code In JetBrains DataGrip”

  1. This didn’t work for me, but for me the issue was I believe related to a error with DataGrip itself not recognizing a function in MS SQL Server and it was throwing an nonsense error. I’ve since opened a bug report about it.

    Reply
    • MS SQL isn’t one of the database I have ever used with DataGrip, but hopefully you get the issue resolved.

      Completely off-topic, but I had a read through your website – nice work.

      Sad to hear Saints Row has tamed down the crazy. I enjoyed one of them games probably 5+ years ago now (no idea which, the latest ones all seemed like remaking the same game over and over). Just Cause 3 was similar, mindless fun blowing up petrol stations and what not. Good times.

      I agree regarding Baldurs Gate 3 – that one cost me £50 and I barely got 20 hours out of it before getting bored. I really couldn’t get engaged by the mechanics or the storyline. I switched back to my third replay of Fallout 4 to get my RPG fix.

      These are cool on the DnD / Baldurs front – https://www.lego.com/en-gb/product/dungeons-dragons-71047

      A good game I played this year that is underhyped is Days Gone. I’m usually not a fan of zombie stuff, but fighting the hordes in that game is a good challenge / good stress reliever (kinda, can be stressful also!).

      My current favourite game is Beyond All Reason (BAR), the spiritual successor to Total Annihilation. I saw on your site you started PC gaming around 2010, so TA likely won’t be one you remember – it came out around the time of the original Half Life. But if you like RTS games it’s the best of recent years.

      I also enjoyed Borderlands 3 this year.

      Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.