473,625 Members | 3,329 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pg7.3.4: pg_atoi: zero-length string



Hi,

We're currently experiencing a problem where SQL statements are failing
when entring a '' for not not-null integer columns:

ERROR: pg_atoi: zero-length string

This was discovered just after a database migration from 7.2 to 7.3.4.

Example:

insert into renewal_cache
(dom, expiry, issued, aid) values
('data','2004-03-05','19980305', '')

The above example in just one case where 'aid' can accept a null value.
The use of quotes around all values was established as IIRC pg7.2
wouldn't accept statements without them. The use of this convention is
extensive.

Cheers,

Rob Fielding
Development
Designer Servers Ltd

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #1
6 2600
On Tue, Nov 04, 2003 at 11:21:35AM +0000, Rob Fielding wrote:


Hi,

We're currently experiencing a problem where SQL statements are failing
when entring a '' for not not-null integer columns:
Yes. This behaviour was made more compliant in 7.3. It's in the
release notes.
The above example in just one case where 'aid' can accept a null value.
That's not a null. It's a zero-length string.
The use of quotes around all values was established as IIRC pg7.2
wouldn't accept statements without them. The use of this convention is
extensive.


You could probably put in a rewrite rule to convert '' to NULL and
allow nulls on the column. It's the only suggestion I can think of,
short of going back to 7.2.

A

--
----
Andrew Sullivan 204-4141 Yonge Street
Afilias Canada Toronto, Ontario Canada
<an****@liberty rms.info> M2P 2A8
+1 416 646 3304 x110
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #2


Andrew Sullivan wrote:
On Tue, Nov 04, 2003 at 11:21:35AM +0000, Rob Fielding wrote:

Hi,

We're currently experiencing a problem where SQL statements are failing
when entring a '' for not not-null integer columns:

Yes. This behaviour was made more compliant in 7.3. It's in the
release notes.

The above example in just one case where 'aid' can accept a null value.


I've found this is a feature of 7.3 to not treat a empty string as a
NULL integer type. Silly lazy me ;)

As it turned out it relatively trivial to fix the offending statements
on the few occasions where it has been valid to do this.

Consider this a non-issue.
Cheers,

--

Rob Fielding
Development
Designer Servers Ltd
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #3
On Tue, Nov 04, 2003 at 12:19:58 +0000,
Rob Fielding <ro*@dsvr.net > wrote:

I've found this is a feature of 7.3 to not treat a empty string as a
NULL integer type. Silly lazy me ;)


It didn't even then. It was treated as 0. Oracle is the DB that treats
empty strings as null values.

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #4

The above example in just one case where 'aid' can accept a null value.


That's not a null. It's a zero-length string.


I've found this is a feature of 7.3 to not treat a empty string as a
NULL integer type. Silly lazy me.

As it turned out it relatively trivial to fix the offending statements
on the few occasions where it has been valid to do this.

Consider this a non-issue.
Cheers,

--

Rob Fielding
Development
Designer Servers Ltd
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postg resql.org

Nov 12 '05 #5
On Tue, Nov 04, 2003 at 12:19:58PM +0000, Rob Fielding wrote:
I've found this is a feature of 7.3 to not treat a empty string as a
NULL integer type. Silly lazy me ;)


For the record, it _never_ treated it as NULL. It treated it as
"empty string". '' != NULL. In fact, !(NULL=NULL) & !(NULL!=NULL).
SQL uses three-valued logic.

A

--
----
Andrew Sullivan 204-4141 Yonge Street
Afilias Canada Toronto, Ontario Canada
<an****@liberty rms.info> M2P 2A8
+1 416 646 3304 x110
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postg resql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #6
For the record, it _never_ treated it as NULL. It treated it as
"empty string". '' != NULL. In fact, !(NULL=NULL) & !(NULL!=NULL).
SQL uses three-valued logic.

You're absolutely right. That explains why, when I quickly looked, some
are zero's and some are NULLs - the NULLs where NULLs and the zeros
where empty strings.

Two different bad-programming examples. If I actually used these
columns for anything whenever they didn't have non zero or null data in
them then I'd have probably been alot more careful about what went in them.

I presume that an 32bit integer of zero and a NULL are represented
differently in the database ? I suppose internally you aren't
representing a NULL within the context of a 32bit integer field and it
would just probably be magic pointer to the next field - some sort of
exercise in space squashing? I don't know anything about the internal
stucture of the tuples.

Dependant on the above, it would probably make sense to clean up the
database, especially considering these columns are also indexed.
Cheers

--

Rob Fielding
Development
Designer Servers Ltd
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4725
by: Steven T. Hatton | last post by:
I mistakenly set this to the comp.std.c++ a few days back. I don't believe it passed the moderator's veto - and I did not expect or desire anything different. But the question remains: ISO/IEC 14882:2003(E) §8.5 says:   To zero-initialize an object of type T means: 5   -- if T is a scalar type (3.9), the object is set to the value of 0 (zero) converted to T;
28
9062
by: Andreas Prilop | last post by:
Jukka reports on http://www.cs.tut.fi/~jkorpela/chars/spaces.html that Internet Explorer 6 fails on the "zero width space" U+200B ​ Is this observation still valid? For which versions of MS Windows does it apply? Does it depend on the encoding (charset)? I have a test page in three encodings: http://www.unics.uni-hannover.de/nhtcapri/temp/zwsp.html http://www.unics.uni-hannover.de/nhtcapri/temp/zwsp.html11...
15
17648
by: I wish | last post by:
#include <string.h> int a; memset( a, 0, sizeof(a) ); Does that guarantee all bits zero? -- |
25
15616
by: Mantorok Redgormor | last post by:
Finally, control is returned to the host environment. If the value of status is zero or EXIT_SUCCESS, an implementation-defined form of the status successful termination is returned. beyond this paragraph from the standard, I can't determine if this macro will always be zero. It would surely be convenient if it is but it never states this directly. the "zero or" part, leads me to believe that the macro
53
8146
by: Zhiqiang Ye | last post by:
Hi, All I am reading FAQ of this group. I have a question about this: http://www.eskimo.com/~scs/C-faq/q7.31.html It says: " p = malloc(m * n); memset(p, 0, m * n); The zero fill is all-bits-zero, and does not therefore guarantee useful null pointer values (see section 5 of this list) or floating-point zero values.
25
4400
by: pm940 | last post by:
Hello. I've been reading some past discussions on the NULL vs. zero. References are always made to systems or machienes that use values other than zero to represent the NULL pointer. Although not a practice I follow, there are no doubt millions of lines of open source libraries and applications that do things like: p = malloc(...);
15
2120
by: Tomás | last post by:
Is the following fully legal and fully portable for all the unsigned types? The aim of the function is to take an array by reference and set each element's value to zero. #include <... template<class UnsignedNumericType, std::size_t const i> void SetAllElementsToZero( UnsignedNumericType (&array) ) { memset( array, 0, i * sizeof(UnsignedNumericType) );
4
7916
by: H.S. | last post by:
Hello, I am trying out a few methods with which to test of a given number is practically zero. as an example, does the following test correctly if a given number is zero within machine precision? I am trying out this method to check for a practical zero in an algorithm I am implementing in C++. ------------------------- #include <iostream> #include <iomanip>
23
4358
by: Hallvard B Furuseth | last post by:
As far as I can tell, (x & -1) is nonzero if the integer x is negative zero. So for signed types, x == 0 does not guarantee (x & foo) == 0. Is that right? (Not that I expect to ever encounter a non-two's-complement machine. Just wondering.) -- Hallvard
4
2685
by: lawrence k | last post by:
I've got a function that starts off like this: function alphabeticalListOfAlbumsByLetter($whichLetter="a") { } I pass in the letters (a, b, c, d, etc) and the numbers (0, 1, 2, 3, 4, etc). It finds in the database records starting with that letter or number. It works fine except when I try to pass in a zero. The PHP
0
8256
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8694
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1500
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.