Re: Nulls get converted to 0 problem - Mailing list pgsql-general

From kdebisschop@alert.infoplease.com
Subject Re: Nulls get converted to 0 problem
Date
Msg-id 1054918235.31564.1.camel@miles.debisschop.net
Whole thread Raw
In response to Re: Nulls get converted to 0 problem  (Samuel Tardieu <sam@rfc1149.net>)
List pgsql-general
On Fri, 2003-06-06 at 11:31, Samuel Tardieu wrote:
> >>>>> "kdebisschop" == kdebisschop  <kdebisschop@alert.infoplease.com> writes:
>
> kdebisschop>   if (str == "")
> kdebisschop>     printf ("This comparison above can segfault on some
> kdebisschop>     systems\n");
>
> No, it can't. You are comparing pointers (str and a pointer to a NULL
> string). This is exactly the same as comparing integers. If any
> compiler generates code which does a segmentation fault, it is far
> from being (even remotely) a C compiler (and I'm not being pedantic
> here).
>
> If you meant strcmp(str, "") that's a completely different story.

I think you're right -- I was merely trying to illustrate that NULL and
"" are not the same in C. My example should probably have been labelled
as being more akin to psuedocode

Thanks for the clarification.


--
Karl DeBisschop <kdebisschop@alert.infoplease.com>


pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Select from multiple tables
Next
From: Jamie Lawrence
Date:
Subject: Re: Postmaster only takes 4-5% CPU