From 5ab816b5be62ea6d46ac48e2eada3f325c4fcea0 Mon Sep 17 00:00:00 2001 From: Tomasz Sowa Date: Mon, 1 Jan 2018 00:12:33 +0000 Subject: [PATCH] fixed: in progresql 10 we have to use ROW() expression to construct a row where only one item is given git-svn-id: svn://ttmath.org/publicrep/winix/trunk@1068 e52654a7-88a9-db11-a3e9-0013d4bc506e --- winixd/db/db.cpp | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/winixd/db/db.cpp b/winixd/db/db.cpp index 1dfa5f2..d1ccc53 100644 --- a/winixd/db/db.cpp +++ b/winixd/db/db.cpp @@ -5,7 +5,7 @@ */ /* - * Copyright (c) 2008-2014, Tomasz Sowa + * Copyright (c) 2008-2017, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -154,7 +154,7 @@ Error Db::ChangeUserPass(long user_id, const UserPass & up) { query.Clear(); query << R("update core.user set(has_pass, password, pass_encrypted," - "pass_type, pass_hash_salted) = (") + "pass_type, pass_hash_salted) = ROW(") << up.has_pass; // for safety @@ -178,7 +178,7 @@ return DoCommand(query); Error Db::ChangeUserEnv(long user_id, const PT::Space & space) { query.Clear(); - query << R("update core.user set(env) = (") + query << R("update core.user set(env) = ROW(") << space << R(") where id = ") << user_id @@ -191,7 +191,7 @@ return DoCommand(query); Error Db::ChangeUserAdminEnv(long user_id, const PT::Space & space) { query.Clear(); - query << R("update core.user set(aenv) = (") + query << R("update core.user set(aenv) = ROW(") << space << R(") where id = ") << user_id @@ -204,7 +204,7 @@ return DoCommand(query); Error Db::ChangeUserStatus(long user_id, int status) { query.Clear(); - query << R("update core.user set(status) = (") + query << R("update core.user set(status) = ROW(") << status << R(") where id = ") << user_id @@ -218,7 +218,7 @@ return DoCommand(query); Error Db::ChangeUserEmail(long user_id, const std::wstring & email) { query.Clear(); - query << R("update core.user set(email) = (") + query << R("update core.user set(email) = ROW(") << email << R(") where id = ") << user_id @@ -231,7 +231,7 @@ return DoCommand(query); Error Db::ChangeUserLocale(long user_id, size_t locale_id) { query.Clear(); - query << R("update core.user set(locale_id) = (") + query << R("update core.user set(locale_id) = ROW(") << locale_id << R(") where id = ") << user_id @@ -244,7 +244,7 @@ return DoCommand(query); Error Db::ChangeUserTimeZone(long user_id, size_t time_zone_id) { query.Clear(); - query << R("update core.user set(time_zone_id) = (") + query << R("update core.user set(time_zone_id) = ROW(") << time_zone_id << R(") where id = ") << user_id @@ -455,7 +455,7 @@ return EndTrans(result); Error Db::IncrementContentRef(long content_id) { query.Clear(); - query << R("update core.content set (ref) = (ref + 1) where id = ") + query << R("update core.content set (ref) = ROW(ref + 1) where id = ") << content_id << R(";"); @@ -466,7 +466,7 @@ return DoCommand(query); Error Db::DecrementContentRef(long content_id) { query.Clear(); - query << R("update core.content set (ref) = (ref - 1) where id = ") + query << R("update core.content set (ref) = ROW(ref - 1) where id = ") << content_id << R(";"); @@ -507,7 +507,7 @@ Error Db::EditItemInItem(Item & item, bool with_url) if( with_url ) query << R(", url"); - query << R(") = (") + query << R(") = ROW(") << item.user_id << item.modification_user_id << item.group_id @@ -565,7 +565,7 @@ Error Db::EditItemInContent(Item & item) // we don't change 'ref' here query.Clear(); query << R("update core.content set (content, content_type, file_path, file_fs, " - "file_type, has_thumb, hash, hash_type, file_size, modify_index) = (") + "file_type, has_thumb, hash, hash_type, file_size, modify_index) = ROW(") << item.content << static_cast(item.content_type) << item.file_path @@ -709,7 +709,7 @@ Error Db::EditLinkItem(long id, const std::wstring & link_to, int link_redirect) try { query.Clear(); - query << R("update core.item set (link_to, link_redirect) = (") + query << R("update core.item set (link_to, link_redirect) = ROW(") << link_to << link_redirect << R(") where id=") @@ -744,7 +744,7 @@ Error Db::EditTemplateItemById(long id, const std::wstring & new_html_template) try { query.Clear(); - query << R("update core.item set (template) = (") + query << R("update core.item set (template) = ROW(") << new_html_template << R(") where id=") << id @@ -774,7 +774,7 @@ return result; Error Db::EditSortIndexItemById(long id, int sort_index) { query.Clear(); - query << R("update core.item set (sort_index) = (") + query << R("update core.item set (sort_index) = ROW(") << sort_index << R(") where id=") << id @@ -1236,7 +1236,7 @@ Error Db::EditPrivById(Item & item, long id) try { query.Clear(); - query << R("update core.item set (user_id, modification_user_id, group_id, privileges, guest_name) = (") + query << R("update core.item set (user_id, modification_user_id, group_id, privileges, guest_name) = ROW(") << item.user_id << item.modification_user_id << item.group_id @@ -1271,7 +1271,7 @@ Error Db::EditParentUrlById(Item & item, long id) try { query.Clear(); - query << R("update core.item set (parent_id, url) = (") << item.parent_id; + query << R("update core.item set (parent_id, url) = ROW(") << item.parent_id; url_without_id = AddItemCreateUrlSubject(item); @@ -1313,7 +1313,7 @@ Error Db::EditFileById(const Item & item, long id) throw Error(WINIX_ERR_NO_ITEM); query.Clear(); - query << R("update core.content set (file_path, file_fs, file_type, has_thumb, hash, hash_type, file_size) = (") + query << R("update core.content set (file_path, file_fs, file_type, has_thumb, hash, hash_type, file_size) = ROW(") << item.file_path << item.file_fs << item.file_type @@ -1353,7 +1353,7 @@ Error Db::EditHasThumbById(bool has_thumb, long id) throw Error(WINIX_ERR_NO_ITEM); query.Clear(); - query << R("update core.content set (has_thumb) = (") + query << R("update core.content set (has_thumb) = ROW(") << static_cast(has_thumb) << R(") where id=") << content_id << R(";"); @@ -1375,7 +1375,7 @@ return EndTrans(result); Error Db::EditMetaById(const PT::Space & meta, long id) { query.Clear(); - query << R("update core.item set (meta) = (") + query << R("update core.item set (meta) = ROW(") << meta << R(") where id=") << id @@ -1388,7 +1388,7 @@ return DoCommand(query); Error Db::EditAdminMetaById(const PT::Space & ameta, long id) { query.Clear(); - query << R("update core.item set (ameta) = (") + query << R("update core.item set (ameta) = ROW(") << ameta << R(") where id=") << id @@ -1408,7 +1408,7 @@ Error Db::EditSubjectById(Item & item, long id) try { query.Clear(); - query << R("update core.item set (subject) = (") + query << R("update core.item set (subject) = ROW(") << item.subject << R(") where id=") << id @@ -1440,7 +1440,7 @@ Error Db::DelDirById(long id) { // decrementing ref in core.content query.Clear(); - query << R("update core.content set (ref) = (ref - 1) where content.id in " + query << R("update core.content set (ref) = ROW(ref - 1) where content.id in " "(select content_id from core.item where type=1 and parent_id=") << id << R(");");