I realize that there is nothing similar to SQL Server Management Studio, so I am mentally prepared to use the good old printf debugging.
The only question is how to do "printf" from a stored procedure?
To "print" a message, you can use raise notice from within a PL/pgSQL function:
http://www.postgresql.org/docs/current/static/plpgsql-errors-and-messages.html
Note that the client must have set the value of "client_min_messages" to the appropriate level in order to receive the "notice".
pgAdmin has a debugger for functions: http://www.pgadmin.org/docs/1.18/debugger.html
(But I have never use it as I don't use pgAdmin).
It sounds like you're looking for actual debugging capability. PostgreSQL actually introduced this functionality starting with PostgreSQL 8.3.
It's fantastic and totally makes PostgreSQL live up to it's tagline "the world's most advanced open source database". It's kind of a hassle to get running but these links might help get you started. Once enabled it allows you to set breakpoints or define inputs & evaluate functions all through a handy right-click menu in PGAdmin.
Along with the trusty ol' RAISE commands, there are also a couple 3rd-party tools that I have heard of, though I've never used them.
PLPGSQL Lint: https://github.com/okbob/plpgsql_lint
EDB Debugger: http://www.enterprisedb.com/docs/en/9.0/asguide/Postgres_Plus_Advanced_Server_Guide-17.htm. My understanding is that the EnterpriseDB Debugger comes bundled with their Postgres Studio package.
There is a debugger for PGAdmin: I tried this in ubuntu environment with Postgres 12 and it worked for me:
install this package
apt-get install postgresql-12-pldebugger
Run this command in the database where resides your Procedure
CREATE EXTENSION pldbgapi;
In your Postgresql installation folder and precisely in the data folder change this parameter in the postgresql.conf file
shared_preload_libraries = 'plugin_debugger'
NB: you need to restart your Postgres after making this change
in pgAdmin right click on the procedure present in the list of the procedures in your schema, put the values for parameters and choose debug
Related
I have installed DB2 10.1 in AIX 7.1 at /opt/IBM/db2/V10.1. But there is a script which is expecting DB2 at /opt/db2_10_1.
I am not sure if it is possible to change the directory of an installed software and if I do it, what are the points I have to keep in my mind before performing this step.
FYI- I am not an AIX or DB2 expert. I am just performing this task as instructed.
Did your instructions specify a non-default path for the Db2-installation?
(The path /opt/IBM/db2/V10.1 is a typical default for AIX )
Do not manually hack to change the installation directory of Db2, just because a script is badly written! Responsible admins would never allow such mistakes on production environments.
It is an error for a script to hard-code a Db2-installation path. That script should be coded correctly to determine the Db2-installation path, or to have that information provided via configuration or arguments.
A possible option is to create a symbolic link so that /opt/db2_10_1 points to the real path at /opt/IBM/db2/V10.1 , but this is not guaranteed to work for all situations, it depends on how badly written is the script - so other different errors may appear later from that script (although Db2 itself will function normally).
A separate matter is that it is unwise to install a Db2 version that is already out of support (end of life). Does the business understand the consequences of installing an out-of-support version? (unless the business has purchased an extended support contract from IBM).
You have to make new install
stop instance
rename sqllib directory
recreate instance using db2icrt in new binaries in install directory
import catalogued database with db2cfimp previously exported using db2cfexp
I have an application that deals with timezones, so naturally I want to be able to view the list of timezones in Postgresql.
I tried to view all available timezones with the following command:
SELECT * FROM pg_timezone_names;
Which prints the following error:
ERROR: timezone directory stack overflow
I even tried limiting the results and received the same error:
SELECT * FROM pg_timezone_names LIMIT 10;
At first I thought it might just be my IDE of choice having issues, but I tried to run the same sql query on the command line and received the same error. I can't, for the life of me, find an answer to this issue. Any information would be helpful. Thanks!
EDIT: I'm using Postgresql 9.3 on Gentoo. Self compiled version of postgresql-server.
Note: I can query the pg_timezone_abbrevs table just fine, just not pg_timezone_names.
According to this Postgres FAQ:
...
On platforms that receive regular software updates including new tzdata files, it may be more convenient to rely on the system's copy of the tzdata files. This is possible as a compile-time option. Most Linux distributions choose this approach for their pre-built versions of PostgreSQL.
...
The compile-time option referred to is the --with-system-tzdata, which is described about half-way down this page.
My guess is that this flag is set by the Portage distribution you're using, and that the tzdata is either missing or corrupted on your system. On Gentoo, the tzdata is distributed in the timezone-data package, which you can find here.
Try:
# emerge timezone-data
Then see if that fixes the problem.
This is an answer to my own question.
The following is at least true on the Gentoo distro of linux, but I assume can be present on others.
What causes the error mentioned in my post is a symlink loop by /usr/share/zoneinfo/posix
To solve this error you just have to delete that symlink, as follows:
rm /usr/share/zoneinfo/posix
Pretty easy fix. Be aware that any update to zoneinfo will cause this symlink to be recreated and thus requiring you to remove it again. I haven't had any issues with this link being removed, but I can't say the same for others. If anyone has a reason for NOT deleting this symlink, just post a comment stating so.
Had the exact same issue on Ubuntu 14.04 LTS with PostgreSQL 9.3.3 however my recursive symlink was with /usr/share/zoneinfo/localtime. Fixed by running:
$ sudo unlink /usr/share/zoneinfo/localtime
I will keep it short for the people who don't want to read too much. Currently, I am trying to run PostgreSQL.app 9.3.0. (Homebrew didn't work and complained that there might be conflicting versions).
It seems to run pretty well, however my psql's version is 9.1.0 and it causes some problems. Psql is probably a left over from another installation/uninstallation maybe a year ago.
Is there a way to update psql or locate it so that I can re-install it. Maybe these two screenshots maybe will give you an idea.
Thank you!
http://i.imgur.com/u3H4hxJ.png
http://i.imgur.com/DaBnzTi.png
Use the 'which' command in the terminal to determine the path/location of the command in question. For example:
$ which psql
/Library/PostgreSQL/9.3/bin/psql
The first image you posted is likely a result of running the psql that comes with default OS X installs. That version is located at:
/usr/bin/psql
I wouldn't recommend removing it however. Instead, once you've installed a version of psql that matches your server (or perhaps it's already there but is just behind the other version in your path), update your path so that the proper psql command comes before the default OS X one and any others. If you are using bash as your preferred shell, for example, then put this in your ~/.bash_profile file:
# add PostgreSQL binaries to the path
export PATH=/Library/PostgreSQL/9.3/bin:$PATH
I have GNU R installed (the S-like statistics package; version 2.8.1) and PostgreSQL (8.4.1), but I cannot connect GNU R to my RDBMS.
When I first did this (years ago - code lost) DBI for R didn't exist. Now it does. I am also confused as to which R package to use. A quick search returns:
RPostgreSQL seems to be the most up-to-date
RPgSQL Looks abandoned. I wish they would put a date on their webpage. ;-(
My Linux distribution doesn't package R packages (irony) but I am comfortable running R CMD INSTALL package.tar.gz.
I installed RPostgreSQL: a lot of documentation says to call dbConnect but I get the following error message: Error: object "dbConnect" not found.
Just for completeness, you have two more options
RODBC which is very mature and feature-complete but doesn't correspond to the DBI framework as the PostgreSQL, MySQL, SQLite, Oracle, ... interfaces do. You also need to fiddle with ODBC setup files which can be tricky. But ODBC may be useful for other data access uses too.
RdbiPgSQL from the BioConductor project which is also mature but uses yet another protocol that was to compete with DBI and never took of. This PostgreSQL package is featureful though.
But as a RPostgreSQL maintainer/co-author I am glad you found this one. As the other poster suggested, try library(RPostgreSQL) before issueing commands. If you encounter other problems, feel free to email me off-SO with a bug report.
Edit: There is another option of embedding R inside PostgreSQL using Joe Conway's PL/R.
Maybe you need to run require(RPostgreSQL) before you can use dbConnect?
My guess is you need to install the DBI package (most database packages depend on it).
If you use install.packages('RPpostgreSQL',dep=TRUE) from within R it should take care of any dependency issues.
RODBC works great for me. You just have to set up a data source name (DSN) for the database you want to connect to. I find this nice because then the specific connection info does not have to be stored in R, and it may vary for your collaborators.
Also, yes, it sounds like you haven't loaded the RPostgresSQL package.
I can't seem to find a good script or anything to use for installing Firebird (the InterBase-decendent RDBMS) using InstallShield. There is a way to silently install it using the firebird install executable, but I don't know enough about InstallShieldscripts to be able to do it! If anyone knows any information on
a) how to execute an exe from InstallShield
b) how to install firebord using InstallShield
I would be very appreciative! Thanks a lot, Matt
You should probably reword your question to get answers about how to execute an external program using command line parameters in an InstallShield script. Maybe the documentation would have enough info on that already.
Regarding the installation of Firebird, please have a look at this document which comes with the Firebird installation and shows all available switches for the Firebird setup executable. If you don't want the user to see that your program is installing Firebird you should probably use the /SP-, the /VERYSILENT and /SUPPRESSMSGBOXES switches. Other switches worth looking into are /NOICONS to suppress the creation of a program group in the start menu, and /COMPONENTS=... to install only what is absolutely necessary for your program to function.
Please note that installing Firebird is only a part of what you should do. For clear separation from other programs using Firebird you should create a new Firebird user account with password, and it's always a good idea to add an alias for your database to the aliases.conf file.