Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: ORDER BY ignoruje wykrzykniki, spacje itp...
Forum PHP.pl > Forum > Bazy danych > PostgreSQL
maur
To jest wynik zapytania SELECT value FROM test ORDER BY value ASC;
Kod
  value
----------
!
?
/
a
ą

b
c
ć
d
ę
s
ś
!zazolc
! zazolc
!zażółć
(16 rows)

Dlaczego ignoruje '?' i '!' jeśli po nich jest string...?



Dla chętnych, dokładny opis tego co robiłem:
Kod
Last login: Mon Jun 25 18:43:18 2007 from 192.168.0.113

z0128:~ # locale        ( Muszą być odpowiednie podczas tworzenia klastra postgresa...)
LANG=pl_PL
LC_CTYPE="pl_PL"
LC_NUMERIC="pl_PL"
LC_TIME="pl_PL"
LC_COLLATE="pl_PL"
LC_MONETARY="pl_PL"
LC_MESSAGES=C
LC_PAPER="pl_PL"
LC_NAME="pl_PL"
LC_ADDRESS="pl_PL"
LC_TELEPHONE="pl_PL"
LC_MEASUREMENT="pl_PL"
LC_IDENTIFICATION="pl_PL"
LC_ALL=
z0128:~ # /etc/init.d/postgresql stop
Shutting down PostgreSQLpostmaster stopped
                                                                      done
z0128:~ # rm /var/lib/pgsql/data -R
z0128:~ # su - postgres
postgres@z0128:~> locale|grep pl_PL|wc -l       (użytkownik postgres ma locale takie same jak root)
12
postgres@z0128:~> initdb -W --auth=md5 -D /var/lib/pgsql/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locales
  COLLATE:  pl_PL
  CTYPE:    pl_PL
  MESSAGES: C
  MONETARY: pl_PL
  NUMERIC:  pl_PL
  TIME:     pl_PL
The default database encoding has accordingly been set to LATIN2.

creating directory /var/lib/pgsql/data ... ok
creating directory /var/lib/pgsql/data/global ... ok
creating directory /var/lib/pgsql/data/pg_xlog ... ok
creating directory /var/lib/pgsql/data/pg_xlog/archive_status ... ok
creating directory /var/lib/pgsql/data/pg_clog ... ok
creating directory /var/lib/pgsql/data/pg_subtrans ... ok
creating directory /var/lib/pgsql/data/pg_twophase ... ok
creating directory /var/lib/pgsql/data/pg_multixact/members ... ok
creating directory /var/lib/pgsql/data/pg_multixact/offsets ... ok
creating directory /var/lib/pgsql/data/base ... ok
creating directory /var/lib/pgsql/data/base/1 ... ok
creating directory /var/lib/pgsql/data/pg_tblspc ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 1000
creating configuration files ... ok
creating template1 database in /var/lib/pgsql/data/base/1 ... ok
initializing pg_authid ... ok
Enter new superuser password:
Enter it again:
setting password ... ok
enabling unlimited row size for system tables ... ok
initializing dependencies ... ok
creating system views ... ok
loading pg_description ... ok
creating conversions ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

Success. You can now start the database server using:

    postmaster -D /var/lib/pgsql/data
or
    pg_ctl -D /var/lib/pgsql/data -l logfile start

postgres@z0128:~>
postgres@z0128:~> exit
logout
z0128:~ # /etc/init.d/postgresql start
Starting PostgreSQL                                                   done
z0128:~ # psql -U postgres
Password for user postgres:
Welcome to psql 8.1.4, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit
postgres=# CREATE DATABASE test;
CREATE DATABASE
postgres=# CREATE TABLE test (value text NOT NULL);
CREATE TABLE
postgres=# INSERT INTO test (value) VALUES ('/');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('a');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('b');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('c');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('d');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('ą');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('ć');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('ę');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('ś');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('s');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('!');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('?');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('?ą');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('!zażółć');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('!zazolc');
INSERT 0 1
postgres=# INSERT INTO test (value) VALUES ('! zazolc');
INSERT 0 1
postgres=# \o wynik.txt
postgres=# SELECT value FROM test ORDER BY value ASC;
postgres=# \q

# mały wycinek z show all;
client_encoding                 | LATIN2                               | Sets the client's character set encoding.
lc_collate                      | pl_PL                                | Shows the collation order locale.
lc_ctype                        | pl_PL                                | Shows the character classification and case conver
sion locale.
lc_messages                     | C                                    | Sets the language in which messages are displayed.
lc_monetary                     | pl_PL                                | Sets the locale for formatting monetary amounts.
lc_numeric                      | pl_PL                                | Sets the locale for formatting numbers.
lc_time                         | pl_PL                                | Sets the locale for formatting date and time value
server_encoding                 | LATIN2                               | Sets the server (database) character set encoding.

z0128:~ # locale -a | grep "pl\|POSIX"
pl_PL
pl_PL.utf8
POSIX


Zaczynam głupieć i mieć dość. bugs postgres mówią tylko o ignorowaniu 'białej spacji' w ustawieniach locali innych niż "C", to by się dało znieść, ale ignorowanie ?!/\ jest nieco nie do przyjęcia..

Z góry dzięki za jakąś wskazówkę/odpowiedź. winksmiley.jpg

pzdr.
AcidBurnt
mysle ze nie sa ignorowane tylko w sortowaniu laduja na poczatku/ koncu nawet w Twoim przykladzie to co jest z ! jest na koncu i ladnie posortowane w/g pozostalych znakow.. tak mi sie przynajmniej wydaje
maur
Cytat(AcidBurnt @ 25.06.2007, 19:59:04 ) *
mysle ze nie sa ignorowane tylko w sortowaniu laduja na poczatku/ koncu nawet w Twoim przykladzie to co jest z ! jest na koncu i ladnie posortowane w/g pozostalych znakow.. tak mi sie przynajmniej wydaje

Ok, jakby wszystkie wykrzykniki były na początku/końcu zrozumiałbym.
Ale czemu pojedyńcze znaki np wykrzyknik jest na górze (dobrze), a jak jest '!string' to jakby ignorował '!' i sortuje wg s?
Przyjrzyj się temu co wkleiłem. winksmiley.jpg
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.