public inbox for [email protected]  
help / color / mirror / Atom feed
From: [email protected]
To: [email protected]
Subject: PQexecParams and "SET TIME ZONE $1" gets 'syntax error at or near "$1" at character 15'
Date: Sat, 23 Nov 2024 23:01:04 +0800 (CST)
Message-ID: <837985448.725696.1732374064323@sg2000-ap-3> (raw)


I get get this same error

syntax error at or near "$1" at character 15

if I feed "const char *command" with the following texts.

SET TIME ZONE $1
SET TIME ZONE $1::TEXT

For some reasons, I can not add quotes around $1 as follows.

SET TIME ZONE '$1'
SET TIME ZONE '$1'::TEXT

Statements like "SELECT ... WHERE $1=..." have been working flawlessly.

It looks like PQexecParams doesn't handle statement with "SET ... $1". 

Are there workarounds for me or PQexecParams needs improvement?

Thank you!

view thread (2+ 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]
  Subject: Re: PQexecParams and "SET TIME ZONE $1" gets 'syntax error at or near "$1" at character 15'
  In-Reply-To: <837985448.725696.1732374064323@sg2000-ap-3>

* 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