Oid vatype;
FuncDetailCode fdresult;
char aggkind = 0;
+ ParseCallbackState pcbstate;
/*
* If there's an aggregate filter, transform it using transformWhereClause
* type. We'll fix up the variadic case below. We may also have to deal
* with default arguments.
*/
+
+ setup_parser_errposition_callback(&pcbstate, pstate, location);
+
fdresult = func_get_detail(funcname, fargs, argnames, nargs,
actual_arg_types,
!func_variadic, true,
&funcid, &rettype, &retset,
&nvargs, &vatype,
&declared_arg_types, &argdefaults);
+
+ cancel_parser_errposition_callback(&pcbstate);
+
if (fdresult == FUNCDETAIL_COERCION)
{
/*
static void op_error(ParseState *pstate, List *op, char oprkind,
Oid arg1, Oid arg2,
FuncDetailCode fdresult, int location);
-static bool make_oper_cache_key(OprCacheKey *key, List *opname,
- Oid ltypeId, Oid rtypeId);
+static bool make_oper_cache_key(ParseState *pstate, OprCacheKey *key,
+ List *opname, Oid ltypeId, Oid rtypeId,
+ int location);
static Oid find_oper_cache_entry(OprCacheKey *key);
static void make_oper_cache_entry(OprCacheKey *key, Oid opr_oid);
static void InvalidateOprCacheCallBack(Datum arg, int cacheid, uint32 hashvalue);
/*
* Try to find the mapping in the lookaside cache.
*/
- key_ok = make_oper_cache_key(&key, opname, ltypeId, rtypeId);
+ key_ok = make_oper_cache_key(pstate, &key, opname, ltypeId, rtypeId, location);
+
if (key_ok)
{
operOid = find_oper_cache_entry(&key);
/*
* Try to find the mapping in the lookaside cache.
*/
- key_ok = make_oper_cache_key(&key, op, arg, InvalidOid);
+ key_ok = make_oper_cache_key(pstate, &key, op, arg, InvalidOid, location);
+
if (key_ok)
{
operOid = find_oper_cache_entry(&key);
/*
* Try to find the mapping in the lookaside cache.
*/
- key_ok = make_oper_cache_key(&key, op, InvalidOid, arg);
+ key_ok = make_oper_cache_key(pstate, &key, op, InvalidOid, arg, location);
+
if (key_ok)
{
operOid = find_oper_cache_entry(&key);
*
* Returns TRUE if successful, FALSE if the search_path overflowed
* (hence no caching is possible).
+ *
+ * pstate/location are used only to report the error position; pass NULL/-1
+ * if not available.
*/
static bool
-make_oper_cache_key(OprCacheKey *key, List *opname, Oid ltypeId, Oid rtypeId)
+make_oper_cache_key(ParseState *pstate, OprCacheKey *key, List *opname,
+ Oid ltypeId, Oid rtypeId, int location)
{
char *schemaname;
char *opername;
if (schemaname)
{
+ ParseCallbackState pcbstate;
+
/* search only in exact schema given */
+ setup_parser_errposition_callback(&pcbstate, pstate, location);
key->search_path[0] = LookupExplicitNamespace(schemaname, false);
+ cancel_parser_errposition_callback(&pcbstate);
}
else
{
{
/* Look in specific schema only */
Oid namespaceId;
+ ParseCallbackState pcbstate;
+
+ setup_parser_errposition_callback(&pcbstate, pstate, typeName->location);
namespaceId = LookupExplicitNamespace(schemaname, missing_ok);
if (OidIsValid(namespaceId))
ObjectIdGetDatum(namespaceId));
else
typoid = InvalidOid;
+
+ cancel_parser_errposition_callback(&pcbstate);
}
else
{
ListCell *elements;
Oid namespaceid;
Oid existing_relid;
+ ParseCallbackState pcbstate;
/*
* We must not scribble on the passed-in CreateStmt, so copy it. (This is
*/
stmt = (CreateStmt *) copyObject(stmt);
+ /* Set up pstate */
+ pstate = make_parsestate(NULL);
+ pstate->p_sourcetext = queryString;
+
/*
* Look up the creation namespace. This also checks permissions on the
* target namespace, locks it against concurrent drops, checks for a
* preexisting relation in that namespace with the same name, and updates
* stmt->relation->relpersistence if the selected namespace is temporary.
*/
+ setup_parser_errposition_callback(&pcbstate, pstate,
+ stmt->relation->location);
namespaceid =
RangeVarGetAndCheckCreationNamespace(stmt->relation, NoLock,
&existing_relid);
+ cancel_parser_errposition_callback(&pcbstate);
/*
* If the relation already exists and the user specified "IF NOT EXISTS",
&& stmt->relation->relpersistence != RELPERSISTENCE_TEMP)
stmt->relation->schemaname = get_namespace_name(namespaceid);
- /* Set up pstate and CreateStmtContext */
- pstate = make_parsestate(NULL);
- pstate->p_sourcetext = queryString;
-
+ /* Set up CreateStmtContext */
cxt.pstate = pstate;
if (IsA(stmt, CreateForeignTableStmt))
{
CREATE UNLOGGED TABLE public.unlogged2 (a int primary key); -- also OK
CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key); -- not OK
ERROR: only temporary relations may be created in temporary schemas
+LINE 1: CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key);
+ ^
CREATE TABLE pg_temp.implicitly_temp (a int primary key); -- OK
CREATE TEMP TABLE explicitly_temp (a int primary key); -- also OK
CREATE TEMP TABLE pg_temp.doubly_temp (a int primary key); -- also OK
CREATE TEMP TABLE public.temp_to_perm (a int primary key); -- not OK
ERROR: cannot create temporary relation in non-temporary schema
+LINE 1: CREATE TEMP TABLE public.temp_to_perm (a int primary key);
+ ^
DROP TABLE unlogged1, public.unlogged2;
CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r';
CREATE TABLE as_select1 AS SELECT * FROM pg_class WHERE relkind = 'r';