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)
    language sql
-- missing source code


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.


Leave a Reply

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