https://supabase.com/ logo
#help
Title
# help
m

Muezz

04/28/2022, 11:31 AM
My database function runs but is not behaving the way I want it to. To figure out what is going on, I want to output some print-like statements to the console. I found out that
raise notice
will do what I am trying to do. But nothing appears in the console log. I also tried
raise exception
and that works but the problem with that is that the function stops because of that exception. I found this stackoverflow question where the anser for this is:
Check the value for "client_min_messages" in your session - it should be "NOTICE" or later to see notices.
I have gone through the settings and I cannot find any option to toggle this to
notice
.
n

Needle

04/28/2022, 11:31 AM
Hello @Muezz! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g

garyaustin

04/28/2022, 12:46 PM
Try raise log.
n

Needle

04/28/2022, 12:46 PM
wubba_lubba_whatever (2022-04-28)
c

chipilov

04/28/2022, 12:52 PM
@garyaustin can you send a reference to 'raise log'? As far as I know there is no 'log' level
@Muezz You can use
Copy code
raise warning
without any config changes - it should show in the console but will NOT terminate your transaction
m

Muezz

04/28/2022, 12:55 PM
I tried raise log just now. That didnt work
I tried
raise warning
and that is working.... The warning does not show up in the vs code debug console. It shows up in the postgres logs. Its better than nothing but it would have been more convenient if it was it vs code. For context,
raise exception
shows up in the vs code debug console.
g

garyaustin

04/28/2022, 1:17 PM
https://www.postgresql.org/docs/current/plpgsql-errors-and-messages.html. I’m pretty sure I have used raise log to get messages in the Postgres log under database. On the hosted platform.
m

Muezz

04/28/2022, 1:21 PM
I tried it but that didnt work.
raise warning
is working though. IS there a way to make this appear inside vs code?
g

garyaustin

04/28/2022, 1:34 PM
@chipilov Just to follow up on using log severity BUT I think you are referring to console and I was thinking the postgrest log...
Copy code
begin
raise log 'TEST NOTICE';
end;
I've only ever used logs since only on hosted.
c

chipilov

04/28/2022, 1:51 PM
@Muezz can you share a bit more about your setup - what extension are you using to run SQL/plPgSQL inside VS Code and see the Postgresql output in the VS Code console?
m

Muezz

04/28/2022, 2:07 PM
I am not using any extension (as far as I know... I am new to supabase). I am using flutter/dart to make an app and when I enter a row into a database table from inside my front-end app, it triggers a function and if that function contains
raise exception
, that exception shows up inside my vs code debug console (and the function stops at that exception obviously) I am using
raise warning
like you suggested so that the function completes. This warning only shows up in the postgres logs and it is a hassle to swtch between the SQL editor and the postgres logs. It would be convenient if these warnings showed up in the debug console like the exception. I hope that explains it.
c

chipilov

04/28/2022, 2:12 PM
I am afraid not 🙂 Specifically, I don't understand this: ", it triggers a function and if that function contains raise exception, that exception shows up inside my vs code debug console (and the function stops at that exception obviously)"...how does a failure in a trigger function (assuming it is PLpgSQL) show up in your VS Code console? As far as I know, VS Code console can only show output from processes that VS Code is attached to/listening - so I guess my question is how do you attach your VS Code to the Postgres instance (if that is even what is happening)? Do you have any server side code which might the thing showing the exception?
m

Muezz

04/28/2022, 2:22 PM
I do not know why too. I did not or have not done anything special here. It is a simple flutter app. In fact, I get some other errors too. If I leave my app on idle and then try to add a row to the table, the debug console says
JWT expired
. If I try to add a row with a column name that does not exist, I get smth like this
"column" does not exist for relation "table_name"
. At this point, I think it might just be a "feature" of the
supabase-dart
or
supabase-flutter
community libraries.
c

chipilov

04/28/2022, 2:37 PM
aha, ok, I think I understand now - if this is a flutter app, you are probably seeing the exceptions as they appear in the response to the flutter app from the DB
I missed that you mentioned flutter/dart above and thought we were talking about a web app - my bad
m

Muezz

04/28/2022, 2:43 PM
yeah thats probably it