public inbox for [email protected]
help / color / mirror / Atom feedFrom: jian he <[email protected]>
To: Pavel Stehule <[email protected]>
Cc: Dmitry Dolgov <[email protected]>
Cc: Laurenz Albe <[email protected]>
Cc: Erik Rijkers <[email protected]>
Cc: Michael Paquier <[email protected]>
Cc: Amit Kapila <[email protected]>
Cc: DUVAL REMI <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Re: proposal: schema variables
Date: Mon, 6 Jan 2025 15:58:36 +0800
Message-ID: <CACJufxG7Mc2PK2B7+vkdDxvrsJNN3r+cpzvAFTZZXKnWZOcG6w@mail.gmail.com> (raw)
In-Reply-To: <CACJufxG6tFo1uOtTPoUw0ntzHddahd7EmR37DhsxMXxUixPaeQ@mail.gmail.com>
References: <CAFj8pRC+hPCc2X88xC=pTJoqmVPApDsageZOMyqaxi5788WxHA@mail.gmail.com>
<CAFj8pRDJ9cq00VYSHxs6LsoHNWjhYXyWWBtV6UgeWwhs0AHa9A@mail.gmail.com>
<CAFj8pRBPXTcw_3fpKtgVthV2+9rZGhxitZ40DnAwCrK601TZZg@mail.gmail.com>
<ndtfl4tsnpkb7m7hwvnmlpsascpgd3a7xvjmjhtxffsbrgygtm@4du6zsmnnwq5>
<CAFj8pRAu4XvNCGu1751t=2YEqLqTjDA3FavMExm2S0KYQq=DdQ@mail.gmail.com>
<CAFj8pRAsEoeZv0HEnA8CKgFKDSQ-wYw18Os1vdksWCV7ez2bVw@mail.gmail.com>
<3chredgnjcmccym2kczawfih226b4ac6co7p6z4jeofevrcosi@mrsxkx2x2c65>
<CAFj8pRBoWPDTOwn5FmMzc+1qiopw+N04U26nviOdF61fs8A2wQ@mail.gmail.com>
<stckyvkl4yyzvgjsaawojs3xikke7mmds5bhv7l7qerclywywk@h4v4n43xm6u2>
<CAFj8pRB_E1GM_YGT-ti4bXka6mhLdAAFeTe+BHgHFYC+qb-76g@mail.gmail.com>
<[email protected]>
<CAFj8pRBWqEb8i6WmrF_Xh64=48GtisKijgczMv7HTTpe4GswuA@mail.gmail.com>
<CAFj8pRAry0esQiHcK=6BwwFKDY0zanug6k07CEQzRPBqZ6iW0Q@mail.gmail.com>
<CACJufxFNjKrmyEi9SLfPCq4c9GUN+5eoOtbZwBPq9eKoO8REUw@mail.gmail.com>
<CAFj8pRALQ-j-Dz3R1ivCoXut8LEhN+kSa7U8Gshucdv5zU3AfQ@mail.gmail.com>
<CACJufxG7LvaNbF8ZSCcxOVUbm9W=KGjD=h_Wk+5imMw4s_2QxA@mail.gmail.com>
<CAFj8pRBY_2awVdER5piyy_JPqsU1Sgr4HLO-v6C1nUS3dJnang@mail.gmail.com>
<CACJufxEM=BLEn6YfgGonM7yuXMn7iqQJcH5PnDVbajWKanynfg@mail.gmail.com>
<CAFj8pRBxA868TpLDe9ofXdpVUNmHY8pzkxrjbZ0obCe0g+YZ-Q@mail.gmail.com>
<CACJufxEb1prZo4G4BhYym1VqKHaPVUv3SoggTR4uCqgCRY7Q-Q@mail.gmail.com>
<CAFj8pRDK2heEhQNcwD=tcKpG5YyPu7zOz2jdRW5A5QfoSUEi_g@mail.gmail.com>
<CACJufxEk16ArmFuTV9VYi6DJaZ+9Jrbt0-u0Zuov7sk-vpg_Dg@mail.gmail.com>
<CAFj8pRAaoPCc=n_TPpWdOvzEdc96xfJZR8W7PphMLxLbGxAq-Q@mail.gmail.com>
<CAFj8pRAzFCbTwqjaEvkvB0VBa9ofSEYxnv8wM3pHZTGtrRK0yQ@mail.gmail.com>
<CACJufxFwxAvJL944UQKwxV1YuM3GQNTbPRQ6LwtioSKBfpMN2A@mail.gmail.com>
<CAFj8pRAVoWzkx8Y3or-frYwszyLSjxzs9jYTm3rx00qN+21ZHg@mail.gmail.com>
<CAFj8pRDhpDwWrV7DbwoGz=-i3yesEU1oooYyMErQfjMXKw=pOQ@mail.gmail.com>
<CACJufxGdRAF=e57W3yd1cTrspB2bucnsr6ZfYY=bs+bfJWdRPw@mail.gmail.com>
<CACJufxG6tFo1uOtTPoUw0ntzHddahd7EmR37DhsxMXxUixPaeQ@mail.gmail.com>
comment out the changes in
src/backend/utils/cache/plancache.c
// /* process session variables */
// if (OidIsValid(parsetree->resultVariable))
// {
// if (acquire)
// LockDatabaseObject(VariableRelationId, parsetree->resultVariable,
// 0, AccessShareLock);
// else
// UnlockDatabaseObject(VariableRelationId,
parsetree->resultVariable,
// 0, AccessShareLock);
// }
// else if (IsA(node, Param))
// {
// Param *p = (Param *) node;
// if (p->paramkind == PARAM_VARIABLE)
// {
// if (acquire)
// LockDatabaseObject(VariableRelationId, p->paramvarid,
// 0, AccessShareLock);
// else
// UnlockDatabaseObject(VariableRelationId, p->paramvarid,
// 0, AccessShareLock);
// }
// }
the regress tests are still successful, that means these code changes
don't have related tests.
SetSessionVariable(Oid varid, Datum value, bool isNull)
{
create_sessionvars_hashtables();
svar = (SVariable) hash_search(sessionvars, &varid, HASH_ENTER, &found);
if (!found)
setup_session_variable(svar, varid);
/* if this fails, it won't change the stored value */
set_session_variable(svar, value, isNull);
}
after set_session_variable,
we want to make sure that svar->is_valid is true,
svar->value = value and svar->isnull= isNull.
Based on this, I've simplified the function set_session_variable,
refer v1-0001-minor-refactoring-set_session_variable.no-cfbot
we use PlannerGlobal
{
Oid basenodeSessionVarid;
Bitmapset *checkSelectPermVarids;
}
to solve the self-assigned corner case SELECT privilege.
(let v1.a =v1.a; in this case, we need have SELECT priv for v1.a
but let v1.a = 1, we don't need SELECT priv for v1.a).
i found out these two field value(information) most case is the same
as PlannerGlobal.sessionVariables;
I came up with another solution, introduce a bool (Query.is_Variable_assigned),
and get rid of PlannerGlobal.basenodeSessionVarid,
PlannerGlobal.checkSelectPermVarids.
not sure it make sense to you, refer
v1-0002-refactoring-LET-statement-self-assign-privileg.no-cfbot
Attachments:
[application/octet-stream] v1-0001-minor-refactoring-set_session_variable.no-cfbot (2.1K, 2-v1-0001-minor-refactoring-set_session_variable.no-cfbot)
download
[application/octet-stream] v1-0002-refactoring-LET-statement-self-assign-privileg.no-cfbot (4.5K, 3-v1-0002-refactoring-LET-statement-self-assign-privileg.no-cfbot)
download
view thread (439+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Re: proposal: schema variables
In-Reply-To: <CACJufxG7Mc2PK2B7+vkdDxvrsJNN3r+cpzvAFTZZXKnWZOcG6w@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox