agora inbox for pgsql-hackers@postgresql.org  
help / color / mirror / Atom feed
Using a C++ library in PostgreSQL
5+ messages / 4 participants
[nested] [flat]

* Using a C++ library in PostgreSQL
@ 2009-07-19 14:13  Xin Wang <andywx@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Xin Wang @ 2009-07-19 14:13 UTC (permalink / raw)
  To: pgsql-hackers

Hi all,
    My research project is based on PostgreSQL. I want to get the
Post-Schema-Validation-Infoset (PSVI)
of an XML document being stored. However, the current libxml2 library does
not support PSVI at all. So
I have to use the Xerces C++ library in PostgreSQL. But I wonder if it is
possible to call a C++ API in
a C code base.
   Could anyone here give me some guidelines to do it? Can the recently
discussed "Mostly Harmless C++"
patch be helpful to what I want to do?

Thank you in advance!
Xin Wang


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Using a C++ library in PostgreSQL
@ 2009-07-19 16:57  Sam Mason <sam@samason.me.uk>
  parent: Xin Wang <andywx@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Sam Mason @ 2009-07-19 16:57 UTC (permalink / raw)
  To: pgsql-hackers

On Sun, Jul 19, 2009 at 10:13:35PM +0800, Xin Wang wrote:
>     My research project is based on PostgreSQL. I want to get the
> Post-Schema-Validation-Infoset (PSVI) of an XML document being
> stored. However, the current libxml2 library does not support PSVI at
> all. So I have to use the Xerces C++ library in PostgreSQL.

I've never had to do anything like this before, so these will just be
general recommendations that I believe I've seen made before on this
list.

> But I wonder if it is possible to call a C++ API in a C code base.

In most common cases, yes this is perfectly possible.  Just make sure
that you catch all exceptions and have all functions that have to be
callable from normal C code declared as 'extern "C"'.

I have a feeling that PG does things that interact badly with the way
C++ handles exceptions.  As far as I can tell[1], this only applies when
you're calling back into Postgres' C code from C++.  There are various
other annoyances (i.e. the sort of thing you always get when trying
to get code talking together that wasn't expecting to be) to do with
Postgres, like things in the headers using names that are reserved in
C++ and not in C.

> Could anyone here give me some guidelines to do it? Can the recently
> discussed "Mostly Harmless C++" patch be helpful to what I want to do?

Isolate all your C++ code away in one part of your code and have some C
code in the middle to do the translations between the two worlds.  As
far as PG should be concerned it will just be calling C code.

If you can't get that to work and performance doesn't matter too much;
put your C++ code into a separate program and have the C code run said
program when needed.

-- 
  Sam  http://samason.me.uk/

 [1] http://wiki.postgresql.org/wiki/C++_Compatibility



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* [PATCH v3 1/3] ALTER TABLE ADD PRIMARY KEY: mention table name in 'NOT NULL missing' error
@ 2023-02-27 15:04  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Alvaro Herrera @ 2023-02-27 15:04 UTC (permalink / raw)

---
 src/backend/catalog/index.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 7777e7ec77..bdf78b53ea 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -269,8 +269,8 @@ index_check_primary_key(Relation heapRel,
 		if (!attform->attnotnull)
 			ereport(ERROR,
 					(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
-					 errmsg("primary key column \"%s\" is not marked NOT NULL",
-							NameStr(attform->attname))));
+					 errmsg("primary key column \"%s\" is not marked NOT NULL in table \"%s\"",
+							NameStr(attform->attname), RelationGetRelationName(heapRel))));
 
 		ReleaseSysCache(atttuple);
 	}
-- 
2.30.2


--vznfmouvfpk5fnl5
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0002-Rebase-of-catalog-notnull-6-minus-psql-d-changes.patch"



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* [PATCH v4 1/3] ALTER TABLE ADD PRIMARY KEY: mention table name in 'NOT NULL missing' error
@ 2023-02-27 15:04  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 5+ messages in thread

From: Alvaro Herrera @ 2023-02-27 15:04 UTC (permalink / raw)

---
 src/backend/catalog/index.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 7777e7ec77..bdf78b53ea 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -269,8 +269,8 @@ index_check_primary_key(Relation heapRel,
 		if (!attform->attnotnull)
 			ereport(ERROR,
 					(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
-					 errmsg("primary key column \"%s\" is not marked NOT NULL",
-							NameStr(attform->attname))));
+					 errmsg("primary key column \"%s\" is not marked NOT NULL in table \"%s\"",
+							NameStr(attform->attname), RelationGetRelationName(heapRel))));
 
 		ReleaseSysCache(atttuple);
 	}
-- 
2.30.2


--kprtg3rp4osk374p
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v4-0002-Rebase-of-catalog-notnull-6-minus-psql-d-changes.patch"



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* [PATCH] Do not check the REPLICATION attribute when running REPACK.
@ 2026-04-20 07:20  Antonin Houska <ah@cybertec.at>
  0 siblings, 0 replies; 5+ messages in thread

From: Antonin Houska @ 2026-04-20 07:20 UTC (permalink / raw)

Although REPACK (CONCURRENTLY) uses replication slots, there is no concern
that the slot will leak data of other users because the MAINTAIN privilege on
the table is required anyway. The REPLICATION attribute is also not needed to
prevent REPACK from stealing slots from logical replication, since commit
e76d8c749c introduces a limit on the maximum number of slots used by REPACK.
---
 src/backend/commands/repack_worker.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/backend/commands/repack_worker.c b/src/backend/commands/repack_worker.c
index b17edd771e2..e4a4860805b 100644
--- a/src/backend/commands/repack_worker.c
+++ b/src/backend/commands/repack_worker.c
@@ -214,7 +214,6 @@ repack_setup_logical_decoding(Oid relid)
 	/*
 	 * Make sure we can use logical decoding.
 	 */
-	CheckSlotPermissions();
 	CheckLogicalDecodingRequirements(true);
 
 	/*
-- 
2.47.3


--=-=-=--





^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2026-04-20 07:20 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-07-19 14:13 Using a C++ library in PostgreSQL Xin Wang <andywx@gmail.com>
2009-07-19 16:57 ` Sam Mason <sam@samason.me.uk>
2023-02-27 15:04 [PATCH v3 1/3] ALTER TABLE ADD PRIMARY KEY: mention table name in 'NOT NULL missing' error Alvaro Herrera <alvherre@alvh.no-ip.org>
2023-02-27 15:04 [PATCH v4 1/3] ALTER TABLE ADD PRIMARY KEY: mention table name in 'NOT NULL missing' error Alvaro Herrera <alvherre@alvh.no-ip.org>
2026-04-20 07:20 [PATCH] Do not check the REPLICATION attribute when running REPACK. Antonin Houska <ah@cybertec.at>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox