Re: Solution of the file name problem of copy on windows.

From: "Hiroshi Saito" <z-saito(at)guitar(dot)ocn(dot)ne(dot)jp>
To: "Itagaki Takahiro" <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Solution of the file name problem of copy on windows.
Date: 2009-04-13 15:12:36
Message-ID: 023558DBC4B14E82A186799942144A65@HIRO57887DE653
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi.

Anyhow, I appreciate discussion.

----- Original Message -----
From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>

> Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
>> Here is a patch to implement GetPlatformEncoding() and convert absolute
>> file paths from database encoding to platform encoding.
>
> This seems like a fairly significant overhead added to solve a really
> minor problem (if it's not minor why has it never come up before?).
>
> I'm also not convinced by any of the details --- why are GetACP and
> pg_get_encoding_from_locale the things to look at, and why is fd.c an
> appropriate place to hook in? Surely if we need it here, we need it in
> places like initdb as well. But really this is much too low a level to
> be solving the problem at. If we have to convert path encodings in the
> backend, we should be doing it once somewhere around the place where we
> identify the value of PGDATA. It should not be necessary to repeat all
> this for every file access within the database directory.

Ahh, I think this is a sensitive problem and requires careful handling too.
However, following tests are shown in order to help your understanding.
This is the case which can't be operated if no apply the patch of Itagaki-san.

C:\work>set PGDATA=C:\tmp\日本語 data

C:\work>set PGPORT=5444

C:\work>set PGHOME=C:\MinGW\local\pgsql

C:\work>cmd.exe
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\work>initdb -E UTF-8 --no-locale
データベースシステム内のファイルの所有者は"HIROSHI"ユーザでした。
このユーザがサーバプロセスを所有しなければなりません。

データベースクラスタはロケールCで初期化されます。
デフォルトのテキスト検索設定はenglishに設定されました。

ディレクトリC:/tmp/日本語 dataの権限を設定しています ... ok
サブディレクトリを作成しています ... ok
デフォルトのmax_connectionsを選択しています ... 100
デフォルトの shared_buffers を選択しています ... 32MB
設定ファイルを作成しています ... ok
C:/tmp/日本語 data/base/1にtemplate1データベースを作成しています ... ok
pg_authidを初期化しています ... ok
依存関係を初期化しています ... ok
システムビューを作成しています ... ok
システムオブジェクトの定義をロードしています ... ok
変換を作成しています ... ok
ディレクトリを作成しています ... ok
組み込みオブジェクトに権限を設定しています ... ok
情報スキーマを作成しています ... ok
template1データベースをバキュームしています ... ok
template1からtemplate0へコピーしています ... ok
template1からpostgresへコピーしています ... ok

警告: ローカル接続向けに"trust"認証が有効です。
pg_hba.confを編集する、もしくは、次回initdbを実行する時に-Aオプショ
ンを使用することで変更することができます。

成功しました。以下を使用してデータベースサーバを起動することができます。

"postmaster" -D "C:/tmp/日本語 data"
または
"pg_ctl" -D "C:/tmp/日本語 data" -l logfile start

C:\work>set PGCLIENTENCODING=SJIS

C:\work>psql postgres
psql (8.4beta1)
"help" でヘルプを表示します.

postgres=# create table 日本語(きー text);
CREATE TABLE
postgres=# insert into 日本語 values('いれた');
INSERT 0 1
postgres=# copy 日本語 to 'C:/tmp/日本語 data/日本語utf8.txt';
COPY 1
postgres=# delete from 日本語;
DELETE 1
postgres=# copy 日本語 from 'C:/tmp/日本語 data/日本語utf8.txt';
COPY 1
postgres=# select * from 日本語;
きー
--------
いれた
(1 行)

C:\work>dir "C:\tmp\日本語 data"
ドライブ C のボリューム ラベルは SYS です
ボリューム シリアル番号は 1433-2C7C です

C:\tmp\日本語 data のディレクトリ

2009/04/13 23:22 <DIR> .
2009/04/13 23:22 <DIR> ..
2009/04/13 23:18 <DIR> base
2009/04/13 23:19 <DIR> global
2009/04/13 23:17 <DIR> pg_clog
2009/04/13 23:17 3,616 pg_hba.conf
2009/04/13 23:17 1,611 pg_ident.conf
2009/04/13 23:17 <DIR> pg_multixact
2009/04/13 23:23 <DIR> pg_stat_tmp
2009/04/13 23:17 <DIR> pg_subtrans
2009/04/13 23:17 <DIR> pg_tblspc
2009/04/13 23:17 <DIR> pg_twophase
2009/04/13 23:17 4 PG_VERSION
2009/04/13 23:17 <DIR> pg_xlog
2009/04/13 23:17 17,112 postgresql.conf
2009/04/13 23:19 38 postmaster.opts
2009/04/13 23:19 24 postmaster.pid
2009/04/13 23:22 8 日本語utf8.txt
7 個のファイル 22,413 バイト
11 個のディレクトリ 42,780,246,016 バイトの空き領域

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message mito 2009-04-13 16:12:24 Affected rows count by rule as condtition
Previous Message Tom Lane 2009-04-13 14:40:41 Re: [PATCH] Add a test for pg_get_functiondef()