Lists: | pgsql-www |
---|
From: | Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com> |
---|---|
To: | pgsql-www(at)postgresql(dot)org |
Subject: | Fwd: Psql.exe error logging |
Date: | 2016-02-25 06:24:58 |
Message-ID: | CAOrOm8VqqV+x7YkOxW2ThjoohXf-e5A29y7g5DHzV_15b4uThw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-www |
Hi,
I am running a .sql file using psql.exe command. The command inserts data
from a file into a table as is, no checks.
Problem I am facing is when even if the command gives me an error, still it
completes successfully. I am running this command via java, so am not able
to catch the error.
It would be of great help if you could rescue me from this situation.
I have attached a screenshot also.
[image: Inline image 2]
Thanks,
Aman
From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com> |
Cc: | PostgreSQL www <pgsql-www(at)postgresql(dot)org> |
Subject: | Re: Fwd: Psql.exe error logging |
Date: | 2016-02-25 16:33:40 |
Message-ID: | CAKFQuwY=TDMK=MUBFV4PZbuysWkSi2-EBdDG0nrc34gvOX4=ow@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-www |
On Wed, Feb 24, 2016 at 11:24 PM, Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com>
wrote:
> Hi,
>
> I am running a .sql file using psql.exe command. The command inserts data
> from a file into a table as is, no checks.
>
> Problem I am facing is when even if the command gives me an error, still
> it completes successfully. I am running this command via java, so am not
> able to catch the error.
>
> It would be of great help if you could rescue me from this situation.
>
>
>
psql --set=ON_ERROR_STOP=1
http://www.postgresql.org/docs/current/static/app-psql.html
David J.
From: | Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | PostgreSQL www <pgsql-www(at)postgresql(dot)org> |
Subject: | Re: Fwd: Psql.exe error logging |
Date: | 2016-02-26 11:29:57 |
Message-ID: | CAOrOm8X4LHm=AibDqWaO0HsgE9V+gsOeOpUVOYQpR8nCWmPtEQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-www |
Hi David,
Thanks for the reply, but it still doesn't seem to run.
I followed the following steps:
1) updated the on_error_stop value to 1
[image: Inline image 1]
2) Ran a command that should fail and exit
[image: Inline image 1]
3) Checked my java log and it shows it ran without errors and continued
with the program.
Right now I have been able to write the error into a log file and then read
it to check if there was any error, but that doesn't seem to be a very
optimized way of handling psql error.
Request you if you could provide me some more tips on how to handle it.
Thanks,
Aman
On Thu, Feb 25, 2016 at 10:03 PM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> On Wed, Feb 24, 2016 at 11:24 PM, Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com>
> wrote:
>
>> Hi,
>>
>> I am running a .sql file using psql.exe command. The command inserts data
>> from a file into a table as is, no checks.
>>
>> Problem I am facing is when even if the command gives me an error, still
>> it completes successfully. I am running this command via java, so am not
>> able to catch the error.
>>
>> It would be of great help if you could rescue me from this situation.
>>
>>
>>
> psql --set=ON_ERROR_STOP=1
>
> http://www.postgresql.org/docs/current/static/app-psql.html
>
> David J.
>
From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com> |
Cc: | PostgreSQL www <pgsql-www(at)postgresql(dot)org> |
Subject: | Re: Fwd: Psql.exe error logging |
Date: | 2016-02-26 14:36:24 |
Message-ID: | CAKFQuwbW8qz4-DjW_Wp4ns0UsmXbaD+rbaLO-PtaM2MLh4dvew@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-www |
On Fri, Feb 26, 2016 at 4:29 AM, Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com>
wrote:
> Hi David,
>
> Thanks for the reply, but it still doesn't seem to run.
>
> I followed the following steps:
> 1) updated the on_error_stop value to 1
>
> [image: Inline image 1]
>
> 2) Ran a command that should fail and exit
>
> [image: Inline image 1]
>
>
Any particular reason you didn't just add the --set option from #1 to the
psql command in #2?
David J.
From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com> |
Cc: | PostgreSQL www <pgsql-www(at)postgresql(dot)org> |
Subject: | Re: Fwd: Psql.exe error logging |
Date: | 2016-02-26 15:21:19 |
Message-ID: | CAKFQuwaxGeF2g_+-ZRATprpT0s4bc=PCf9PEy6+VhpvJBdTEFg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-www |
On Fri, Feb 26, 2016 at 7:36 AM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> On Fri, Feb 26, 2016 at 4:29 AM, Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com>
> wrote:
>
>> Hi David,
>>
>> Thanks for the reply, but it still doesn't seem to run.
>>
>> I followed the following steps:
>> 1) updated the on_error_stop value to 1
>>
>> [image: Inline image 1]
>>
>
>> 2) Ran a command that should fail and exit
>>
>> [image: Inline image 1]
>>
>>
> Any particular reason you didn't just add the --set option from #1 to the
> psql command in #2?
>
>
>
As an aside, the portion of the command "psql -c -a -f <file>" is wrong
(though apparently not broken...). You specify, via "c", that you are
going to provide a single command for psql to execute but then fail to
provide any such command and instead change you mind and tell it your are
going to provide a script file, via "f", instead.
David J.
From: | Melvin Davidson <melvin6925(at)gmail(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com>, PostgreSQL www <pgsql-www(at)postgresql(dot)org> |
Subject: | Re: Fwd: Psql.exe error logging |
Date: | 2016-02-26 15:59:53 |
Message-ID: | CANu8FixA=Y8JnxnSw0+P3SZKryQjta3PeNsoKmQ0OwQqN+SUSA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-www |
On Fri, Feb 26, 2016 at 10:21 AM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> On Fri, Feb 26, 2016 at 7:36 AM, David G. Johnston <
> david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
>> On Fri, Feb 26, 2016 at 4:29 AM, Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com>
>> wrote:
>>
>>> Hi David,
>>>
>>> Thanks for the reply, but it still doesn't seem to run.
>>>
>>> I followed the following steps:
>>> 1) updated the on_error_stop value to 1
>>>
>>> [image: Inline image 1]
>>>
>>
>>> 2) Ran a command that should fail and exit
>>>
>>> [image: Inline image 1]
>>>
>>>
>> Any particular reason you didn't just add the --set option from #1 to
>> the psql command in #2?
>>
>>
>>
> As an aside, the portion of the command "psql -c -a -f <file>" is wrong
> (though apparently not broken...). You specify, via "c", that you are
> going to provide a single command for psql to execute but then fail to
> provide any such command and instead change you mind and tell it your are
> going to provide a script file, via "f", instead.
>
> David J.
>
>3) Checked my java log and it shows it ran without errors and continued
with the program.
Do you realize that all psql errors will go to the postgresql log file, not
java log?
--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.
From: | Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com> |
---|---|
To: | Melvin Davidson <melvin6925(at)gmail(dot)com> |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL www <pgsql-www(at)postgresql(dot)org> |
Subject: | Re: Fwd: Psql.exe error logging |
Date: | 2016-02-29 07:11:34 |
Message-ID: | CAOrOm8UxXEQo6YS1q7+-EEVzU9eteTocuf=SR26_Q5Q3YD-vfg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-www |
Hi David,
1) I thought that --set command is meant at DB level for all the commands
being run. So ran it first. Not sure how to use it within the command.
2) -c option: I was doing something but forgot to remove it and didn't
notice that it is still there. Now, if I run it with -c option, then also I
am facing the same issue.
3) I realize that the psql.log is different from java log. Reason for
creating this log is to read the error message from the file since command
exists successfully and not with some errors. %errorlevel% is 0 even if the
command fails, therefore my java does not stop. So i use this log file to
read if there is any error record else continue.
Now, I am facing one more issue: The creation of the log file command
sometimes creates a log file and sometimes doesn't ( through java). Wanted
to check if there is something I should keep in mind for this.? Command I
am running is:
"<path_to_exe>psql.exe" -U <value>-w -h <value>-d <value> -a -f "<path to
.sql file>copy_s_m_asset_391.sql" 2> ",log_file_path>psql.log"
Thanks a lot for you help on this. Really appreciate it.
Aman
On Fri, Feb 26, 2016 at 9:29 PM, Melvin Davidson <melvin6925(at)gmail(dot)com>
wrote:
>
>
> On Fri, Feb 26, 2016 at 10:21 AM, David G. Johnston <
> david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
>> On Fri, Feb 26, 2016 at 7:36 AM, David G. Johnston <
>> david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>>
>>> On Fri, Feb 26, 2016 at 4:29 AM, Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com>
>>> wrote:
>>>
>>>> Hi David,
>>>>
>>>> Thanks for the reply, but it still doesn't seem to run.
>>>>
>>>> I followed the following steps:
>>>> 1) updated the on_error_stop value to 1
>>>>
>>>> [image: Inline image 1]
>>>>
>>>
>>>> 2) Ran a command that should fail and exit
>>>>
>>>> [image: Inline image 1]
>>>>
>>>>
>>> Any particular reason you didn't just add the --set option from #1 to
>>> the psql command in #2?
>>>
>>>
>>>
>> As an aside, the portion of the command "psql -c -a -f <file>" is wrong
>> (though apparently not broken...). You specify, via "c", that you are
>> going to provide a single command for psql to execute but then fail to
>> provide any such command and instead change you mind and tell it your are
>> going to provide a script file, via "f", instead.
>>
>> David J.
>>
>
> >3) Checked my java log and it shows it ran without errors and continued
> with the program.
>
> Do you realize that all psql errors will go to the postgresql log file,
> not java log?
>
> --
> *Melvin Davidson*
> I reserve the right to fantasize. Whether or not you
> wish to share my fantasy is entirely up to you.
>
From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com> |
Cc: | Melvin Davidson <melvin6925(at)gmail(dot)com>, PostgreSQL www <pgsql-www(at)postgresql(dot)org> |
Subject: | Re: Fwd: Psql.exe error logging |
Date: | 2016-02-29 07:24:07 |
Message-ID: | CAKFQuwa+0O2VKaAfqbR3iOXTEoQKzTR13+6RQ_=hRF0DSVKOHQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-www |
On Monday, February 29, 2016, Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com> wrote:
> Hi David,
>
> 1) I thought that --set command is meant at DB level for all the commands
> being run. So ran it first. Not sure how to use it within the command.
>
>
everyone else is bottom posting. Please do the same.
On the point above: everytime you execute psql you connect to the database
using a clean session. Nothing carries over between sessions. So while
--set alters the session you have to make you specify it on the psql
invocation you actually want to have stop on errors.
David J.
From: | Craig Ringer <craig(at)2ndquadrant(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
Cc: | Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com>, Melvin Davidson <melvin6925(at)gmail(dot)com>, PostgreSQL www <pgsql-www(at)postgresql(dot)org> |
Subject: | Re: Fwd: Psql.exe error logging |
Date: | 2016-02-29 08:28:23 |
Message-ID: | CAMsr+YEJ4sNJrarc_PBTj2uAvLe03xd7as-jWvRJpbhUiwcFdg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-www |
On 29 February 2016 at 15:24, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
wrote:
> On Monday, February 29, 2016, Aman Rathi <aman(dot)rathi0904(at)gmail(dot)com> wrote:
>
>> Hi David,
>>
>> 1) I thought that --set command is meant at DB level for all the commands
>> being run. So ran it first. Not sure how to use it within the command.
>>
>>
> everyone else is bottom posting. Please do the same.
>
Also, this is on the pgsql-www mailing list. Shouldn't it really be on
-general?
'psql' could really use a flag that was shorthand for -v ON_ERROR_STOP=1
since it's an obvious and desirable thing that's horrid to specify and not
quite as easy to discover as it could be.
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services