Re: Nulls get converted to 0 problem

From: kdebisschop(at)alert(dot)infoplease(dot)com
To: Samuel Tardieu <sam(at)rfc1149(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Nulls get converted to 0 problem
Date: 2003-06-06 18:06:25
Message-ID: 1054918235.31564.1.camel@miles.debisschop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 2003-06-06 at 11:31, Samuel Tardieu wrote:
> >>>>> "kdebisschop" == kdebisschop <kdebisschop(at)alert(dot)infoplease(dot)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(at)alert(dot)infoplease(dot)com>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Matthew Rudolph 2003-06-06 18:13:15 Speed/Performance with pg_restore
Previous Message Bruno Wolff III 2003-06-06 17:35:12 Estimate of when CVS will be available again?