Postgresql pawnpsql来自脚本的命令。我认为,不仅仅是服务器-客户端不匹配,问题在于客户端非常旧。一般来说,使用不同版本的psql客户端和服务器是没有问题的。不过,通常情况下,如果您在本地运行服务器安装,您应该使用它。@ovgolovin Er。。。您可以从脚本
Postgresql pawnpsql来自脚本的命令。我认为,不仅仅是服务器-客户端不匹配,问题在于客户端非常旧。一般来说,使用不同版本的psql客户端和服务器是没有问题的。不过,通常情况下,如果您在本地运行服务器安装,您应该使用它。@ovgolovin Er。。。您可以从脚本,postgresql,Postgresql,pawnpsql来自脚本的命令。我认为,不仅仅是服务器-客户端不匹配,问题在于客户端非常旧。一般来说,使用不同版本的psql客户端和服务器是没有问题的。不过,通常情况下,如果您在本地运行服务器安装,您应该使用它。@ovgolovin Er。。。您可以从脚本启动psql,而无需将其置于路径上。请尝试%PROGRAMFILES%\PostgreSQL\9.2\bin\psql.exe(根据版本进行调整)。@CraigRinger我并不是一个人在做这个项目。另一个成员使用Linux。您确定Linux上
pawn
psql
来自脚本的命令。我认为,不仅仅是服务器-客户端不匹配,问题在于客户端非常旧。一般来说,使用不同版本的psql客户端和服务器是没有问题的。不过,通常情况下,如果您在本地运行服务器安装,您应该使用它。@ovgolovin Er。。。您可以从脚本启动psql
,而无需将其置于路径上。请尝试%PROGRAMFILES%\PostgreSQL\9.2\bin\psql.exe
(根据版本进行调整)。@CraigRinger我并不是一个人在做这个项目。另一个成员使用Linux。您确定Linux上有%PROGRAMFILES%吗?:)
CREATE OR REPLACE FUNCTION increment_display_count(in_host_id int, in_host_owner_id int, in_date_ date) RETURNS void as $$
BEGIN
UPDATE display_count set display_count = display_count + 1
WHERE host_id = in_host_id AND host_owner_id = in_host_owner_id AND date_ = in_date_;
IF FOUND THEN
RETURN;
END IF;
BEGIN
INSERT INTO display_count (host_id, host_owner_id, date_, display_count) VALUES (in_host_id, in_host_owner_id, in_date_, 1);
EXCEPTION WHEN OTHERS THEN
UPDATE display_count set display_count = display_count + 1
WHERE host_id = in_host_id AND host_owner_id = in_host_owner_id AND date_ = in_date_;
END;
RETURN;
END;
$$
LANGUAGE plpgsql;
psql -h localhost -U postgres -d database -f create_database_function.sql
C:\Xubuntu_shared\pixel\pixel\src\main\scripts>psql -h localhost -U postgres -d
pixel_test -f create_database_function.sql
Password:
CREATE FUNCTION
C:\Xubuntu_shared\pixel\pixel\src\main\scripts>psql -h localhost -U postgres -d
pixel_test -f create_database_function.sql
Password:
psql:create_database_function.sql:4: ERROR: unterminated dollar-quoted string a
t or near "$$
BEGIN
UPDATE display_count set display_count = display_count + 1
WHERE host_id = in_host_id AND host_owner_id = in_host_owner_id AND date_ =
in_date_;" at character 121
psql:create_database_function.sql:6: ERROR: syntax error at or near "IF" at cha
racter 5
psql:create_database_function.sql:7: ERROR: syntax error at or near "IF" at cha
racter 9
psql:create_database_function.sql:9: ERROR: syntax error at or near "INSERT" at
character 19
psql:create_database_function.sql:12: ERROR: syntax error at or near "EXCEPTION
" at character 5
psql:create_database_function.sql:13: WARNING: there is no transaction in progr
ess
COMMIT
psql:create_database_function.sql:14: ERROR: syntax error at or near "RETURN" a
t character 5
psql:create_database_function.sql:15: WARNING: there is no transaction in progr
ess
COMMIT
psql:create_database_function.sql:17: ERROR: unterminated dollar-quoted string
at or near "$$
LANGUAGE plpgsql;" at character 1
pixel=> SELECT version();
version
-------------------------------------------------------------
PostgreSQL 9.2.3, compiled by Visual C++ build 1600, 32-bit
(1 row)
pixel=>
Oleg@OLEG-PC /C/Xubuntu_shared/pixel/pixel/src/main/scripts (pixel-dev2)
$ psql -U postgres
Password:
Welcome to psql.exe 7.4.6, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
Warning: Console codepage (866) differs from windows codepage (1251)
8-bit characters will not work correctly. See PostgreSQL
documentation "Installation on Windows" for details.
postgres=# select name,setting,source from pg_settings where source <> 'default'
;
name | setting
| source
----------------------------+---------------------------------------------------
---+----------------------
config_file | C:/Program Files/PostgreSQL/9.2/data/postgresql.co
nf | override
data_directory | C:/Program Files/PostgreSQL/9.2/data
| override
DateStyle | ISO, MDY
| configuration file
default_text_search_config | pg_catalog.english
| configuration file
hba_file | C:/Program Files/PostgreSQL/9.2/data/pg_hba.conf
| override
ident_file | C:/Program Files/PostgreSQL/9.2/data/pg_ident.conf
| override
lc_collate | C
| override
lc_ctype | C
| override
lc_messages | C
| configuration file
lc_monetary | C
| configuration file
lc_numeric | C
| configuration file
lc_time | C
| configuration file
listen_addresses | *
| configuration file
log_destination | stderr
| configuration file
log_line_prefix | %t
| configuration file
log_timezone | Europe/Moscow
| configuration file
logging_collector | on
| configuration file
max_connections | 100
| configuration file
max_stack_depth | 2048
| environment variable
port | 5432
| configuration file
server_encoding | UTF8
| override
shared_buffers | 4096
| configuration file
TimeZone | Europe/Moscow
| configuration file
transaction_deferrable | off
| override
transaction_isolation | read committed
| override
transaction_read_only | off
| override
wal_buffers | 128
| override
(27 rows)