471,075 Members | 1,276 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,075 software developers and data experts.

Comparing a varchar of length > 32

Hello,

we are using a table with a primary key of type varchar[50].
If we try to find entries with select * from <table> where <table.key> =
'<text>';
entries with a key length of more than 32 characters are not found.
Entries with a shorter key are found. Using "Like" instead of "=" works for
varchar keys with length > 32 as well.

Does anybody know about this Problem ?
(We use PostgresQL 7.4.1)

Thanks in advance,
Christian Enklaar.


Nov 23 '05 #1
3 1654
Christian Enklaar wrote:
Hello,

we are using a table with a primary key of type varchar[50].
If we try to find entries with select * from <table> where <table.key> =
'<text>';
entries with a key length of more than 32 characters are not found.
Entries with a shorter key are found. Using "Like" instead of "=" works for
varchar keys with length > 32 as well.

Does anybody know about this Problem ?
(We use PostgresQL 7.4.1)


I think you are hiding some informations.

It works here with a 7.4.5 and I'm not aware of any bug like this in previous
versions.

test=# \d test
Table "public.test"
Column | Type | Modifiers
--------+-----------------------+-----------
a | character varying(50) | not null
Indexes:
"test_pkey" primary key, btree (a)
test=# select a, length(a) from test;
a | length
----------------------------------------------------+--------
01234567890123456789012345678901234567890123 | 44
0123456789012345678901234567890123456789 | 40
01234567890123456789012345678901234567890123456789 | 50
(3 rows)
test=# select length(a) from test where a = '01234567890123456789012345678901234567890123';
length
--------
44
(1 row)
Just an idea, could you reindex your table ?
Regards
Gaetano Mendola

Nov 23 '05 #2
Christian Enklaar wrote:
we are using a table with a primary key of type varchar[50].
If we try to find entries with select * from <table> where
<table.key> = '<text>';
entries with a key length of more than 32 characters are not found.
Entries with a shorter key are found. Using "Like" instead of "="
works for varchar keys with length > 32 as well.


Please post the actual table definitions, the actual data, the actual
command you are running, and the actual results you are getting.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #3
Hello,

thanks for your help.

Seems as if the problem was related to our locale settings.

We are running PostgreSQL on QNX and did not set any specific locale when
creating the database.

Now when we explicitely use LOCALE C on database creation everything works
fine.

"Christian Enklaar" <ch***************@mbs-software.de> schrieb im
Newsbeitrag news:ci***********@news.hub.org...
Hello,

we are using a table with a primary key of type varchar[50].
If we try to find entries with select * from <table> where <table.key> =
'<text>';
entries with a key length of more than 32 characters are not found.
Entries with a shorter key are found. Using "Like" instead of "=" works for varchar keys with length > 32 as well.

Does anybody know about this Problem ?
(We use PostgresQL 7.4.1)

Thanks in advance,
Christian Enklaar.

Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by dmhendricks | last post: by
10 posts views Thread by Techie | last post: by
22 posts views Thread by jdokos | last post: by
7 posts views Thread by James o'konnor | last post: by
reply views Thread by Christian Enklaar | last post: by

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.