pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedlibpq PQexecParams & value placeholders
4+ messages / 3 participants
[nested] [flat]
* libpq PQexecParams & value placeholders
@ 2018-12-14 11:33 Oleg <lego12239@yandex.ru>
0 siblings, 1 reply; 4+ messages in thread
From: Oleg @ 2018-12-14 11:33 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi, all.
Do we really need a numeric value placeholders like $1 in command string?
Construction of such string for complex non-static queries is very annoying.
Why do we can't simply use $$ placeholder, which take the next value from an
array of values?
--
Олег Неманов (Oleg Nemanov)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: libpq PQexecParams & value placeholders
@ 2018-12-14 11:47 Dmitry Igrishin <dmitigr@gmail.com>
parent: Oleg <lego12239@yandex.ru>
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Igrishin @ 2018-12-14 11:47 UTC (permalink / raw)
To: lego12239@yandex.ru; +Cc: pgsql-general@lists.postgresql.org
пт, 14 дек. 2018 г. в 14:33, Oleg <lego12239@yandex.ru>:
>
> Hi, all.
>
> Do we really need a numeric value placeholders like $1 in command string?
It's a syntax defined at the backend side.
(https://www.postgresql.org/docs/current/sql-prepare.html)
> Construction of such string for complex non-static queries is very annoying.
That's why there are libraries like Pgfe
(https://github.com/dmitigr/pgfe) or libpqtypes
(http://libpqtypes.esilo.com/)
> Why do we can't simply use $$ placeholder, which take the next value from an
> array of values?
Because $$ means a dollar-quoted opening tag
(https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: libpq PQexecParams & value placeholders
@ 2018-12-14 12:09 Oleg <lego12239@yandex.ru>
parent: Dmitry Igrishin <dmitigr@gmail.com>
0 siblings, 1 reply; 4+ messages in thread
From: Oleg @ 2018-12-14 12:09 UTC (permalink / raw)
To: Dmitry Igrishin <dmitigr@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
On Fri, Dec 14, 2018 at 02:47:12PM +0300, Dmitry Igrishin wrote:
> пт, 14 дек. 2018 г. в 14:33, Oleg <lego12239@yandex.ru>:
> >
> > Hi, all.
> >
> > Do we really need a numeric value placeholders like $1 in command string?
> It's a syntax defined at the backend side.
> (https://www.postgresql.org/docs/current/sql-prepare.html)
I know this, but i can't understand why this approach is used.
> > Construction of such string for complex non-static queries is very annoying.
> That's why there are libraries like Pgfe
> (https://github.com/dmitigr/pgfe) or libpqtypes
This is C++ :-(.
> (http://libpqtypes.esilo.com/)
This is great! PQexecf() is what i need. Why this api is not the part of libpq?
Thank you for the link!
> > Why do we can't simply use $$ placeholder, which take the next value from an
> > array of values?
> Because $$ means a dollar-quoted opening tag
> (https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING)
Ok. We can use any other placeholder string for such purpose. But not numeric
placeholders - these are not convenient.
--
Олег Неманов (Oleg Nemanov)
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: libpq PQexecParams & value placeholders
@ 2018-12-20 14:03 Merlin Moncure <mmoncure@gmail.com>
parent: Oleg <lego12239@yandex.ru>
0 siblings, 0 replies; 4+ messages in thread
From: Merlin Moncure @ 2018-12-20 14:03 UTC (permalink / raw)
To: Oleg <lego12239@yandex.ru>; +Cc: Dmitry Igrishin <dmitigr@gmail.com>; pgsql-general@lists.postgresql.org
On Fri, Dec 14, 2018 at 6:09 AM Oleg <lego12239@yandex.ru> wrote:
>
> On Fri, Dec 14, 2018 at 02:47:12PM +0300, Dmitry Igrishin wrote:
> > пт, 14 дек. 2018 г. в 14:33, Oleg <lego12239@yandex.ru>:
> > >
> > > Hi, all.
> > >
> > > Do we really need a numeric value placeholders like $1 in command string?
> > It's a syntax defined at the backend side.
> > (https://www.postgresql.org/docs/current/sql-prepare.html)
>
> I know this, but i can't understand why this approach is used.
>
> > > Construction of such string for complex non-static queries is very annoying.
> > That's why there are libraries like Pgfe
> > (https://github.com/dmitigr/pgfe) or libpqtypes
>
> This is C++ :-(.
>
> > (http://libpqtypes.esilo.com/)
>
> This is great! PQexecf() is what i need. Why this api is not the part of libpq?
> Thank you for the link!
FYI, I need to move the project to github and I have a few bugfixes
that have not been sent up yet. Please let me know if you have any
issues.
The postgres core team very graciously extended the libpq API in order
to make libpqtypes work seamlessly with libpq, so they deserve some
credit here. Direct C programming against the database is a somewhat
niche developer segment and when incorporating new libraries there you
have to carefully manage usefulness vs support down the line.
Having said that I still believe it remains to be the best way to
write against the libpq API, or C database development generally.
There's nothing else like it FWICT.
I personally lost some interest in the project when the json train
really started to leave the station as it changed the way I developed
against the database.
merlin
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2018-12-20 14:03 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-12-14 11:33 libpq PQexecParams & value placeholders Oleg <lego12239@yandex.ru>
2018-12-14 11:47 ` Dmitry Igrishin <dmitigr@gmail.com>
2018-12-14 12:09 ` Oleg <lego12239@yandex.ru>
2018-12-20 14:03 ` Merlin Moncure <mmoncure@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox