On Tue, Mar 2, 2021 at 12:13 PM Peter Eisentraut
<peter.eisentr...@2ndquadrant.com> wrote:
>
> On 11.02.21 09:02, Peter Eisentraut wrote:
> >> Here is an updated patch to get it building again.
> >
> > Another updated patch to get things building again.  I've also fixed the
> > last TODO I had in there in qualifying function arguments as necessary
> > in ruleutils.c.
>
> Updated patch to resolve merge conflict.  No changes in functionality.

Hi,

I was making some tests with this patch and found this problem:

"""
CREATE OR REPLACE FUNCTION public.make_table()
 RETURNS void
 LANGUAGE sql
BEGIN ATOMIC
  CREATE TABLE created_table AS SELECT * FROM int8_tbl;
END;
ERROR:  unrecognized token: "?"
CONTEXT:  SQL function "make_table"
"""

Attached a backtrace from the point the error is thrown.

-- 
Jaime Casanova
Director de Servicios Profesionales
SYSTEMGUARDS - Consultores de PostgreSQL
#0  nodeRead (
    token=0x55c62af712b4 "? :resultRelation 0 :hasAggs false :hasWindowFuncs 
false :hasTargetSRFs false :hasSubLinks false :hasDistinctOn false 
:hasRecursive false :hasModifyingCTE false :hasForUpdate false :hasRowSecurity 
fal"..., tok_len=1)
    at read.c:421
        __errno_location = <optimized out>
        result = 0x55c62af712b3
        type = 1000004
        __func__ = "nodeRead"
#1  0x000055c62a706491 in _readQuery () at readfuncs.c:255
        local_node = 0x55c62af71b20
        token = 0x55c62af712a7 ":utilityStmt ? :resultRelation 0 :hasAggs false 
:hasWindowFuncs false :hasTargetSRFs false :hasSubLinks false :hasDistinctOn 
false :hasRecursive false :hasModifyingCTE false :hasForUpdate false :hasRo"...
        length = 12
#2  0x000055c62a711588 in parseNodeString () at readfuncs.c:2701
        return_value = 0xf4243000008e6
        token = 0x55c62af71273 "QUERY :commandType 5 :querySource 0 :canSetTag 
true :utilityStmt ? :resultRelation 0 :hasAggs false :hasWindowFuncs false 
:hasTargetSRFs false :hasSubLinks false :hasDistinctOn false :hasRecursive 
fal"...
        length = 5
        __func__ = "parseNodeString"
#3  0x000055c62a705b74 in nodeRead (
    token=0x55c62af71272 "{QUERY :commandType 5 :querySource 0 :canSetTag true 
:utilityStmt ? :resultRelation 0 :hasAggs false :hasWindowFuncs false 
:hasTargetSRFs false :hasSubLinks false :hasDistinctOn false :hasRecursive 
fa"..., tok_len=1)
    at read.c:334
        result = 0x55c62af71273
        type = 1000003
        __func__ = "nodeRead"
#4  0x000055c62a705e8d in nodeRead (
    token=0x55c62af71272 "{QUERY :commandType 5 :querySource 0 :canSetTag true 
:utilityStmt ? :resultRelation 0 :hasAggs false :hasWindowFuncs false 
:hasTargetSRFs false :hasSubLinks false :hasDistinctOn false :hasRecursive 
fa"..., tok_len=1)
    at read.c:400
        l = 0x0
        result = 0x55c62af71272
        type = 1000002
        __func__ = "nodeRead"
#5  0x000055c62a705e8d in nodeRead (
    token=0x55c62af71271 "({QUERY :commandType 5 :querySource 0 :canSetTag true 
:utilityStmt ? :resultRelation 0 :hasAggs false :hasWindowFuncs false 
:hasTargetSRFs false :hasSubLinks false :hasDistinctOn false :hasRecursive 
f"..., tok_len=1)
    at read.c:400
        l = 0x0
        result = 0x277
        type = 1000002
        __func__ = "nodeRead"
#6  0x000055c62a705700 in stringToNodeInternal (
    str=0x55c62af71270 "(({QUERY :commandType 5 :querySource 0 :canSetTag true 
:utilityStmt ? :resultRelation 0 :hasAggs false :hasWindowFuncs false 
:hasTargetSRFs false :hasSubLinks false :hasDistinctOn false :hasRecursive 
"..., 
    restore_loc_fields=false) at read.c:74
        retval = 0x7ffd9bafc9f0
        save_strtok = 0x55c62af712b5 " :resultRelation 0 :hasAggs false 
:hasWindowFuncs false :hasTargetSRFs false :hasSubLinks false :hasDistinctOn 
false :hasRecursive false :hasModifyingCTE false :hasForUpdate false 
:hasRowSecurity fals"...
#7  0x000055c62a705732 in stringToNode (
    str=0x55c62af71270 "(({QUERY :commandType 5 :querySource 0 :canSetTag true 
:utilityStmt ? :resultRelation 0 :hasAggs false :hasWindowFuncs false 
:hasTargetSRFs false :hasSubLinks false :hasDistinctOn false :hasRecursive 
"...) at read.c:91
No locals.
#8  0x000055c62a501a7d in fmgr_sql_validator (fcinfo=0x7ffd9bafcb00) at 
pg_proc.c:895
        n = 0x55c62af065a0
        funcoid = 23208
        tuple = 0x7f95f02b9348
        proc = 0x7f95f02b9390
        raw_parsetree_list = 0x55c62af065a0
        querytree_list = 0x55c62aa27bf2 <fmgr_info_cxt_security+81>
        lc = 0x7ffd9bafcb20
        isnull = false
        tmp = 140281956242456
        prosrc = 0x55c62af065a0 "\240e\360*\306U"
        callback_arg = {proname = 0x7f95f02b9394 "make_table", prosrc = 0x0}
        sqlerrcontext = {previous = 0x0, callback = 0x55c62a501c77 
<sql_function_parse_error_callback>, 
          arg = 0x7ffd9bafca50}
        haspolyarg = false
        i = 0
        __func__ = "fmgr_sql_validator"
#9  0x000055c62aa29c5f in FunctionCall1Coll (flinfo=0x7ffd9bafcb60, 
collation=0, arg1=23208) at fmgr.c:1141
        fcinfodata = {fcinfo = {flinfo = 0x7ffd9bafcb60, context = 0x0, 
resultinfo = 0x0, fncollation = 0, isnull = false, 
            nargs = 1, args = 0x7ffd9bafcb20}, 
          fcinfo_data = "`˯\233\375\177", '\000' <repeats 23 times>, 
"U\001\000\250Z\000\000\000\000\000\000\000{\242*\306U\000"}
        fcinfo = 0x7ffd9bafcb00
        result = 140727215442784
        __func__ = "FunctionCall1Coll"
#10 0x000055c62aa2a87b in OidFunctionCall1Coll (functionId=2248, collation=0, 
arg1=23208) at fmgr.c:1419
        flinfo = {fn_addr = 0x55c62a501586 <fmgr_sql_validator>, fn_oid = 2248, 
fn_nargs = 1, fn_strict = true, 
          fn_retset = false, fn_stats = 2 '\002', fn_extra = 0x0, fn_mcxt = 
0x55c62aed4bb0, fn_expr = 0x0}
#11 0x000055c62a5011cf in ProcedureCreate (procedureName=0x55c62aeb22d8 
"make_table", procNamespace=2200, replace=true, 
    returnsSet=false, returnType=2278, proowner=10, languageObjectId=14, 
languageValidator=2248, prosrc=0x0, probin=0x0, 
    prosqlbody=0x55c62aed6990, prokind=102 'f', security_definer=false, 
isLeakProof=false, isStrict=false, 
    volatility=118 'v', parallel=117 'u', parameterTypes=0x55c62aed4e68, 
allParameterTypes=0, parameterModes=0, 
    parameterNames=0, parameterDefaults=0x0, trftypes=0, proconfig=0, 
prosupport=0, procost=100, prorows=0)
    at pg_proc.c:708
        set_items = 0x0
        save_nestlevel = 0
        retval = 23208
        parameterCount = 0
        allParamCount = 0
        allParams = 0x55c62aed4e80
        paramModes = 0x0
        variadicType = 0
        proacl = 0x0
        rel = 0x7f95f0294440
        tup = 0x55c62af71270
        oldtup = 0x7f95f02b9fa0
        nulls = {false <repeats 20 times>, true, true, true, true, true, true, 
true, false, true, false}
        values = {0, 140727215442992, 2200, 10, 14, 1120403456, 0, 0, 0, 102, 
0, 0, 0, 0, 118, 117, 0, 0, 2278, 
          94309612080744, 0, 0, 0, 0, 0, 0, 0, 94309612071048, 0, 0}
        replaces = {false, true, true, false, true <repeats 25 times>, false}
        procname = {data = "make_table", '\000' <repeats 53 times>}
        tupDesc = 0x7f95f0294658
        is_update = true
        myself = {classId = 1255, objectId = 23208, objectSubId = 0}
        referenced = {classId = 1247, objectId = 2278, objectSubId = 0}
        detailmsg = 0x0
        i = 0
        trfid = 0
        addrs = 0x55c62aed3138
        __func__ = "ProcedureCreate"
#12 0x000055c62a5c2000 in CreateFunction (pstate=0x55c62aed4cd0, 
stmt=0x55c62aeb2ae8) at functioncmds.c:1220
        probin_str = 0x0
        prosrc_str = 0x0
        prosqlbody = 0x55c62aed6990
        prorettype = 2278
        returnsSet = false
        language = 0x55c62aeb24a0 "sql"
        languageOid = 14
        languageValidator = 2248
        transformDefElem = 0x0
        funcname = 0x55c62aeb22d8 "make_table"
        namespaceId = 2200
        aclresult = ACLCHECK_OK
        parameterTypes = 0x55c62aed4e68
        parameterTypes_list = 0x0
        allParameterTypes = 0x0
        parameterModes = 0x0
        parameterNames = 0x0
        inParameterNames_list = 0x0
        parameterDefaults = 0x0
        variadicArgType = 0
        trftypes_list = 0x0
        trftypes = 0x0
        requiredResultType = 0
        isWindowFunc = false
        isStrict = false
        security = false
        isLeakProof = false
        volatility = 118 'v'
        proconfig = 0x0
        procost = 100
        prorows = 0
        prosupport = 0
        languageTuple = 0x7f95f02b3778
        languageStruct = 0x7f95f02b37b8
        as_clause = 0x0
        parallel = 117 'u'
        __func__ = "CreateFunction"
#13 0x000055c62a895a0f in ProcessUtilitySlow (pstate=0x55c62aed4cd0, 
pstmt=0x55c62aeb2e58, 
    queryString=0x55c62aeb17e0 "CREATE OR REPLACE FUNCTION 
public.make_table()\n RETURNS void\n LANGUAGE sql\nBEGIN ATOMIC\n  CREATE TABLE 
created_table AS SELECT * FROM int8_tbl;\nEND;", 
context=PROCESS_UTILITY_TOPLEVEL, params=0x0, 
    queryEnv=0x0, dest=0x55c62aeb2f48, qc=0x7ffd9bafd870) at utility.c:1588
        _save_exception_stack = 0x7ffd9bafd710
        _save_context_stack = 0x0
        _local_sigjmp_buf = {{__jmpbuf = {0, 3816649187620432560, 
94309600313312, 140727215447712, 0, 0, 
              3816649187807079088, 6953580346614622896}, __mask_was_saved = 0, 
__saved_mask = {__val = {94309607634535, 0, 
                140727215445520, 2611991180, 140727215444688, 140727215445520, 
0, 140727215444736, 94309607632740, 0, 0, 
                140067473457152, 19147, 140727215445648, 2611992160, 
2611991276}}}}
        _do_rethrow = false
        parsetree = 0x55c62aeb2ae8
        isTopLevel = true
        isCompleteQuery = true
        needCleanup = false
        commandCollected = false
        address = {classId = 21958, objectId = 2611991616, objectSubId = 32765}
        secondaryObject = {classId = 0, objectId = 0, objectSubId = 0}
        __func__ = "ProcessUtilitySlow"
#14 0x000055c62a894751 in standard_ProcessUtility (pstmt=0x55c62aeb2e58, 
    queryString=0x55c62aeb17e0 "CREATE OR REPLACE FUNCTION 
public.make_table()\n RETURNS void\n LANGUAGE sql\nBEGIN ATOMIC\n  CREATE TABLE 
created_table AS SELECT * FROM int8_tbl;\nEND;", 
context=PROCESS_UTILITY_TOPLEVEL, params=0x0, 
    queryEnv=0x0, dest=0x55c62aeb2f48, qc=0x7ffd9bafd870) at utility.c:1034
        parsetree = 0x55c62aeb2ae8
        isTopLevel = true
        isAtomicContext = false
        pstate = 0x55c62aed4cd0
        readonly_flags = 0
        __func__ = "standard_ProcessUtility"
#15 0x000055c62a89392b in ProcessUtility (pstmt=0x55c62aeb2e58, 
    queryString=0x55c62aeb17e0 "CREATE OR REPLACE FUNCTION 
public.make_table()\n RETURNS void\n LANGUAGE sql\nBEGIN ATOMIC\n  CREATE TABLE 
created_table AS SELECT * FROM int8_tbl;\nEND;", 
context=PROCESS_UTILITY_TOPLEVEL, params=0x0, 
    queryEnv=0x0, dest=0x55c62aeb2f48, qc=0x7ffd9bafd870) at utility.c:525
No locals.
#16 0x000055c62a8926fb in PortalRunUtility (portal=0x55c62af16420, 
pstmt=0x55c62aeb2e58, isTopLevel=true, 
    setHoldSnapshot=false, dest=0x55c62aeb2f48, qc=0x7ffd9bafd870) at 
pquery.c:1159
        utilityStmt = 0x55c62aeb2ae8
        snapshot = 0x55c62aed8bb8
#17 0x000055c62a892928 in PortalRunMulti (portal=0x55c62af16420, 
isTopLevel=true, setHoldSnapshot=false, 
    dest=0x55c62aeb2f48, altdest=0x55c62aeb2f48, qc=0x7ffd9bafd870) at 
pquery.c:1305
        pstmt = 0x55c62aeb2e58
        stmtlist_item__state = {l = 0x55c62aeb2ef0, i = 0}
        active_snapshot_set = false
        stmtlist_item = 0x55c62aeb2f08
#18 0x000055c62a891dff in PortalRun (portal=0x55c62af16420, 
count=9223372036854775807, isTopLevel=true, run_once=true, 
    dest=0x55c62aeb2f48, altdest=0x55c62aeb2f48, qc=0x7ffd9bafd870) at 
pquery.c:779
        _save_exception_stack = 0x7ffd9bafd980
        _save_context_stack = 0x0
        _local_sigjmp_buf = {{__jmpbuf = {0, 3816649187496700592, 
94309600313312, 140727215447712, 0, 0, 
              3816649187557518000, 6953580344859437744}, __mask_was_saved = 0, 
__saved_mask = {__val = {17895196801, 
                94309611941680, 128, 94309611935424, 94309612356656, 
140727215445968, 1936, 94309607207853, 
                94309611935648, 140727215446000, 94309607386021, 13, 112, 
94309611941816, 112, 2611992576}}}}
        _do_rethrow = false
        result = false
        nprocessed = 94309611941704
        saveTopTransactionResourceOwner = 0x55c62aee0070
        saveTopTransactionContext = 0x55c62aed8a60
        saveActivePortal = 0x0
        saveResourceOwner = 0x55c62aee0070
        savePortalContext = 0x0
        saveMemoryContext = 0x55c62aed8a60
        __func__ = "PortalRun"
#19 0x000055c62a88b95b in exec_simple_query (
    query_string=0x55c62aeb17e0 "CREATE OR REPLACE FUNCTION 
public.make_table()\n RETURNS void\n LANGUAGE sql\nBEGIN ATOMIC\n  CREATE TABLE 
created_table AS SELECT * FROM int8_tbl;\nEND;") at postgres.c:1239
        snapshot_set = false
        per_parsetree_context = 0x0
        plantree_list = 0x55c62aeb2ef0
        parsetree = 0x55c62aeb2b40
        commandTag = CMDTAG_CREATE_FUNCTION
        qc = {commandTag = CMDTAG_UNKNOWN, nprocessed = 0}
        querytree_list = 0x55c62aeb2e00
        portal = 0x55c62af16420
        receiver = 0x55c62aeb2f48
        format = 0
        parsetree_item__state = {l = 0x55c62aeb2b78, i = 0}
        dest = DestRemote
        oldcontext = 0x55c62aed8a60
        parsetree_list = 0x55c62aeb2b78
        parsetree_item = 0x55c62aeb2b90
        save_log_statement_stats = false
        was_logged = false
        use_implicit_block = false
        msec_str = 
"\340\027\353*\306U\000\000\224\000\000\000\006\000\000\000\300د\233\375\177\000\000u\vl*\224\000\000"
        __func__ = "exec_simple_query"
#20 0x000055c62a88fe7a in PostgresMain (argc=1, argv=0x7ffd9bafdb00, 
dbname=0x55c62aede310 "regression", 
    username=0x55c62aede2e8 "jcasanov") at postgres.c:4393
        query_string = 0x55c62aeb17e0 "CREATE OR REPLACE FUNCTION 
public.make_table()\n RETURNS void\n LANGUAGE sql\nBEGIN ATOMIC\n  CREATE TABLE 
created_table AS SELECT * FROM int8_tbl;\nEND;"
        firstchar = 81
        input_message = {
          data = 0x55c62aeb17e0 "CREATE OR REPLACE FUNCTION 
public.make_table()\n RETURNS void\n LANGUAGE sql\nBEGIN ATOMIC\n  CREATE TABLE 
created_table AS SELECT * FROM int8_tbl;\nEND;", len = 149, maxlen = 1024, 
cursor = 149}
        local_sigjmp_buf = {{__jmpbuf = {0, 3816649187423300272, 
94309600313312, 140727215447712, 0, 0, 
              3816649187544935088, 6953580333111716528}, __mask_was_saved = 1, 
__saved_mask = {__val = {4194304, 0, 0, 0, 
                0, 0, 0, 33022, 8756825059622843968, 0, 1099511627520, 0, 0, 
4294901760, 18446462598732840960, 0}}}}
        send_ready_for_query = false
        idle_in_transaction_timeout_enabled = false
        idle_session_timeout_enabled = false
        __func__ = "PostgresMain"
#21 0x000055c62a7cb255 in BackendRun (port=0x55c62aed7e50) at postmaster.c:4488
        av = {0x55c62abc3daf "postgres", 0x0}
        ac = 1
#22 0x000055c62a7cab84 in BackendStartup (port=0x55c62aed7e50) at 
postmaster.c:4210
        bn = 0x55c62aed7e20
        pid = 0
        __func__ = "BackendStartup"
#23 0x000055c62a7c6fa5 in ServerLoop () at postmaster.c:1734
        port = 0x55c62aed7e50
        i = 2
        rmask = {fds_bits = {128, 0 <repeats 15 times>}}
        selres = 1
        now = 1614922009
        readmask = {fds_bits = {224, 0 <repeats 15 times>}}
        nSockets = 8
        last_lockfile_recheck_time = 1614922009
        last_touch_time = 1614920899
        __func__ = "ServerLoop"
#24 0x000055c62a7c67f4 in PostmasterMain (argc=3, argv=0x55c62aeaad60) at 
postmaster.c:1406
        opt = -1
        status = 0
        userDoption = 0x55c62aece6a0 "data"
        listen_addr_saved = true
        i = 64
        output_config_variable = 0x0
        __func__ = "PostmasterMain"
#25 0x000055c62a6c3e20 in main (argc=3, argv=0x55c62aeaad60) at main.c:209
        do_check_root = true
Detaching from program: /opt/var/pgdg/14dev/standard_sql_body/bin/postgres, 
process 19147
[Inferior 1 (process 19147) detached]

Reply via email to