mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-30 03:27:20 +02:00
libpgcommon is a new static library to allow sharing code among the various frontend programs and backend; this lets us eliminate duplicate implementations of common routines. We avoid libpgport, because that's intended as a place for porting issues; per discussion, it seems better to keep them separate. The first use case, and the only implemented by this patch, is pg_malloc and friends, which many frontend programs were already using. At the same time, we can use this to provide palloc emulation functions for the frontend; this way, some palloc-using files in the backend can also be used by the frontend cleanly. To do this, we change palloc() in the backend to be a function instead of a macro on top of MemoryContextAlloc(). This was previously believed to cause loss of performance, but this implementation has been tweaked by Tom and Andres so that on modern compilers it provides a slight improvement over the previous one. This lets us clean up some places that were already with localized hacks. Most of the pg_malloc/palloc changes in this patch were authored by Andres Freund. Zoltán Böszörményi also independently provided a form of that. libpgcommon infrastructure was authored by Álvaro.
50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
/*
|
|
* psql - the PostgreSQL interactive terminal
|
|
*
|
|
* Copyright (c) 2000-2013, PostgreSQL Global Development Group
|
|
*
|
|
* src/bin/psql/common.h
|
|
*/
|
|
#ifndef COMMON_H
|
|
#define COMMON_H
|
|
|
|
#include "postgres_fe.h"
|
|
#include <setjmp.h>
|
|
#include "libpq-fe.h"
|
|
|
|
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
|
|
|
|
extern bool setQFout(const char *fname);
|
|
|
|
extern void
|
|
psql_error(const char *fmt,...)
|
|
/* This lets gcc check the format string for consistency. */
|
|
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
|
|
|
extern void NoticeProcessor(void *arg, const char *message);
|
|
|
|
extern volatile bool sigint_interrupt_enabled;
|
|
|
|
extern sigjmp_buf sigint_interrupt_jmp;
|
|
|
|
extern volatile bool cancel_pressed;
|
|
|
|
/* Note: cancel_pressed is defined in print.c, see that file for reasons */
|
|
|
|
extern void setup_cancel_handler(void);
|
|
|
|
extern void SetCancelConn(void);
|
|
extern void ResetCancelConn(void);
|
|
|
|
extern PGresult *PSQLexec(const char *query, bool start_xact);
|
|
|
|
extern bool SendQuery(const char *query);
|
|
|
|
extern bool is_superuser(void);
|
|
extern bool standard_strings(void);
|
|
extern const char *session_username(void);
|
|
|
|
extern char *expand_tilde(char **filename);
|
|
|
|
#endif /* COMMON_H */
|