質問編集履歴
7
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
|
48
48
|
|
49
|
-
使用ユーザの作成テーブルの権限はUPDATEとINSERTです。
|
49
|
+
使用ユーザの作成テーブルへの権限はUPDATEとINSERTです。
|
50
50
|
|
51
51
|
|
52
52
|
|
6
test
CHANGED
File without changes
|
test
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
|
39
|
-
コピペできない環境
|
39
|
+
コピペできない環境だったので、情報量の少ない質問になってしまい、申し訳なかったです。
|
40
40
|
|
41
41
|
|
42
42
|
|
5
test
CHANGED
File without changes
|
test
CHANGED
@@ -129,3 +129,55 @@
|
|
129
129
|
|
130
130
|
|
131
131
|
```
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
●一般ユーザでpsqlから下記を実行
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
```
|
140
|
+
|
141
|
+
database=> INSERT INTO mst_table (e_id, file_no, file_name, file_data)
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
database-> SELECT
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
database-> nextval('seq_id'),
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
database-> nextval('seq_no'),
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
database-> 'file.jpg',
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
database-> bytea_import('/home/appuser/tool/images/file.jpg');
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
ERROR: must be superuser to use server-side lo_import()
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
HINT: Anyone can use the client-side lo_import() provided by libpq.
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
CONTEXT: SQL statement "select lo_import(p_path)"
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
PL/pgSQL function bytea_import(text) line 5 at SQL statement
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
database=>
|
182
|
+
|
183
|
+
```
|
4
test
CHANGED
File without changes
|
test
CHANGED
@@ -106,11 +106,11 @@
|
|
106
106
|
|
107
107
|
```
|
108
108
|
|
109
|
-
create table mst_
|
109
|
+
create table mst_table (
|
110
110
|
|
111
111
|
|
112
112
|
|
113
|
-
e
|
113
|
+
e_id integer primary key,
|
114
114
|
|
115
115
|
|
116
116
|
|
3
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
追記
|
35
|
+
### 追記
|
36
36
|
|
37
37
|
|
38
38
|
|
@@ -100,94 +100,32 @@
|
|
100
100
|
|
101
101
|
|
102
102
|
|
103
|
-
●テーブル
|
103
|
+
●テーブルクリエイト文
|
104
|
-
|
105
|
-
```
|
106
|
-
|
107
|
-
列 | 型 | 修飾語
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
---------------+---------+--------------------
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
e_id | integer | not null
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
file_no | integer | not null default 0
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
file_name | text |
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
file_data | bytea |
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
インデックス:
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
"mst_table_pkey" PRIMARY KEY, btree (e_id)
|
136
|
-
|
137
|
-
```
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
●一般ユーザでpsqlから下記を実行
|
144
|
-
|
145
|
-
|
146
104
|
|
147
105
|
|
148
106
|
|
149
107
|
```
|
150
108
|
|
151
|
-
|
109
|
+
create table mst_cd_image (
|
152
110
|
|
153
111
|
|
154
112
|
|
155
|
-
d
|
113
|
+
experiment_id integer primary key,
|
156
114
|
|
157
115
|
|
158
116
|
|
159
|
-
dat
|
117
|
+
file_no integer default 0 not null,
|
160
118
|
|
161
119
|
|
162
120
|
|
163
|
-
|
121
|
+
file_name text ,
|
164
122
|
|
165
123
|
|
166
124
|
|
167
|
-
databa
|
125
|
+
file_data bytea
|
126
|
+
|
127
|
+
);
|
168
128
|
|
169
129
|
|
170
130
|
|
171
|
-
database-> bytea_import('/home/appuser/tool/images/file.jpg');
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
ERROR: must be superuser to use server-side lo_import()
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
HINT: Anyone can use the client-side lo_import() provided by libpq.
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
CONTEXT: SQL statement "select lo_import(p_path)"
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
PL/pgSQL function bytea_import(text) line 5 at SQL statement
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
database=>
|
192
|
-
|
193
131
|
```
|
2
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,3 +27,167 @@
|
|
27
27
|
PostgreSQL 9.2.4
|
28
28
|
|
29
29
|
DBサーバ CentOS7
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
追記
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
コピペできない環境にだったので、情報量の少ない質問になってしまい、申し訳なかったです。
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
ご指摘の通りユーザにUPDATE権限がなかったので追加しましたが、エラー内容は変わりませんでした。
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
使用ユーザの作成テーブルの権限はUPDATEとINSERTです。
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
●関数(スーバーユーザで実行)
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
create or replace function bytea_import(p_path text, p_result out bytea)
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
language plpgsql as $$
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
declare
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
l_oid oid;
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
begin
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
select lo_import(p_path) into l_oid;
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
select lo_get(l_oid) INTO p_result;
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
perform lo_unlink(l_oid);
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
end;$$;
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
```
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
●テーブル
|
104
|
+
|
105
|
+
```
|
106
|
+
|
107
|
+
列 | 型 | 修飾語
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
---------------+---------+--------------------
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
e_id | integer | not null
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
file_no | integer | not null default 0
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
file_name | text |
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
file_data | bytea |
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
インデックス:
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
"mst_table_pkey" PRIMARY KEY, btree (e_id)
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
●一般ユーザでpsqlから下記を実行
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
```
|
150
|
+
|
151
|
+
database=> INSERT INTO mst_table (e_id, file_no, file_name, file_data)
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
database-> SELECT
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
database-> nextval('seq_id'),
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
database-> nextval('seq_no'),
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
database-> 'file.jpg',
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
database-> bytea_import('/home/appuser/tool/images/file.jpg');
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
ERROR: must be superuser to use server-side lo_import()
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
HINT: Anyone can use the client-side lo_import() provided by libpq.
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
CONTEXT: SQL statement "select lo_import(p_path)"
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
PL/pgSQL function bytea_import(text) line 5 at SQL statement
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
database=>
|
192
|
+
|
193
|
+
```
|