将在PostgreSQL 12

问题描述

从Postgresql文档中尚不清楚:是否将添加生成的列锁定表?

我的Postgresql 12安装中有一张大桌子,我需要执行sql-patch:

ALTER TABLE abc ADD COLUMN gen TEXT GENERATED AS ALWAYS (...) STORED;

因此,就我而言,长时间锁定整个表是不可接受的。添加生成的列是否安全?

解决方法

由于生成的列为AddEventHandler("playerConnecting",function(playerName,setKickReason) playerName = (string.gsub(string.gsub(string.gsub(string.gsub(playerName,"-",""),","%."," ",""):lower()) for k,v in pairs(unauthNames) do local g,f = playerName:find(string.lower(v)) if g or f then local id = source; local ids = ExtractIdentifiers(id); local ip = ids.ip; local steam = ids.steam:gsub("steam:",""); local steamDec = tostring(tonumber(steam,16)); steam = "https://steamcommunity.com/profiles/" .. steamDec; local gameLicense = ids.license; local discord = ids.discord; local realName = GetPlayerName(source); print(playerName .. " has been kicked for having an unauthorised name") sendToDisc("Anti-abuse - Player kicked for having an unauthorised name",'Steam: **' .. steam .. '**\n' .. 'GameLicense: **' .. gameLicense .. '**\n' .. 'Discord UID: **' .. discord:gsub('discord:','') .. '**\n' .. 'Name: **' .. realName ..'**\n' .. 'Blacklisted Item: **' .. v ..'**\n'); setKickReason("[Anti-abuse] Your name,or part of it,is not permitted. Please check your name is not offensive,does not contain weblinks,odd characters or other restricted content: " ..v) CancelEvent() end end end) ,PostgreSQL必须重写该表,因此,这将花费很长时间。

为什么不使用视图来计算STORED上的列?