Why use " != "

Started by ipigover 19 years ago4 messages
#1ipig
ipig@ercist.iscas.ac.cn

Hi,

in postgresql-8.1.3/src/backend/storage/lmgr/proc.c
there are 2 function InitProcess and InitDummyProcess, both use
" if (MyProc != NULL)
elog(ERROR, "you already exist"); " (line 215 and 315)

why use " != " ?

Best regards.

#2Qingqing Zhou
zhouqq@cs.toronto.edu
In reply to: ipig (#1)
Re: Why use " != "

""ipig"" <ipig@ercist.iscas.ac.cn> wrote

in postgresql-8.1.3/src/backend/storage/lmgr/proc.c
there are 2 function InitProcess and InitDummyProcess, both use
" if (MyProc != NULL)
elog(ERROR, "you already exist"); " (line 215 and 315)

why use " != " ?

I guess you misread "exist" to "exit"? Try to change "!=" to whatever you
think of, and see what will happen.

Regards,
Qingqing

#3Gurjeet Singh
singh.gurjeet@gmail.com
In reply to: ipig (#1)
Re: Why use " != "

It done so, because InitProcess() is supposed to be called only
once per backend, because it allocates a PGPROC from a LIST OF free
PGPROCs.

So with this test, and calling elog( ERROR, ... ) we are stopping
the caller from doing a second initialization for this backend.

Show quoted text

On 5/16/06, ipig <ipig@ercist.iscas.ac.cn> wrote:

Hi,

in postgresql-8.1.3/src/backend/storage/lmgr/proc.c
there are 2 function InitProcess and InitDummyProcess, both use
" if (MyProc != NULL)
elog(ERROR, "you already exist"); " (line 215 and 315)

why use " != " ?

Best regards.

#4ipig
ipig@ercist.iscas.ac.cn
In reply to: ipig (#1)
Re: Why use " != "

As Qingqing Zhou said, i misread "exist".
Thanks.

----- Original Message -----
From: "Gurjeet Singh" <singh.gurjeet@gmail.com>
To: "ipig" <ipig@ercist.iscas.ac.cn>
Cc: <pgsql-hackers@postgresql.org>
Sent: Tuesday, May 16, 2006 11:36 AM
Subject: Re: [HACKERS] Why use " != "

It done so, because InitProcess() is supposed to be called only
once per backend, because it allocates a PGPROC from a LIST OF free
PGPROCs.

So with this test, and calling elog( ERROR, ... ) we are stopping
the caller from doing a second initialization for this backend.

On 5/16/06, ipig <ipig@ercist.iscas.ac.cn> wrote:

Hi,

in postgresql-8.1.3/src/backend/storage/lmgr/proc.c
there are 2 function InitProcess and InitDummyProcess, both use
" if (MyProc != NULL)
elog(ERROR, "you already exist"); " (line 215 and 315)

why use " != " ?

Best regards.

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster